clang-format the src/Reactor directory
Bug: b/144825072
Change-Id: I1f14af4446536c760d11d32aa03edb5f497e75e4
Reviewed-on: https://swiftshader-review.googlesource.com/c/SwiftShader/+/39656
Kokoro-Presubmit: kokoro <noreply+kokoro@google.com>
Tested-by: Ben Clayton <bclayton@google.com>
Reviewed-by: Nicolas Capens <nicolascapens@google.com>
diff --git a/src/Reactor/CPUID.cpp b/src/Reactor/CPUID.cpp
index f3b9024..12637a7 100644
--- a/src/Reactor/CPUID.cpp
+++ b/src/Reactor/CPUID.cpp
@@ -15,16 +15,16 @@
#include "CPUID.hpp"
#if defined(_WIN32)
- #ifndef WIN32_LEAN_AND_MEAN
- #define WIN32_LEAN_AND_MEAN
- #endif
- #include <windows.h>
- #include <intrin.h>
- #include <float.h>
+# ifndef WIN32_LEAN_AND_MEAN
+# define WIN32_LEAN_AND_MEAN
+# endif
+# include <windows.h>
+# include <intrin.h>
+# include <float.h>
#else
- #include <unistd.h>
- #include <sched.h>
- #include <sys/types.h>
+# include <unistd.h>
+# include <sched.h>
+# include <sys/types.h>
#endif
namespace rr {
@@ -162,18 +162,20 @@
static void cpuid(int registers[4], int info)
{
- #if defined(__i386__) || defined(__x86_64__)
- #if defined(_WIN32)
- __cpuid(registers, info);
- #else
- __asm volatile("cpuid": "=a" (registers[0]), "=b" (registers[1]), "=c" (registers[2]), "=d" (registers[3]): "a" (info));
- #endif
- #else
- registers[0] = 0;
- registers[1] = 0;
- registers[2] = 0;
- registers[3] = 0;
- #endif
+#if defined(__i386__) || defined(__x86_64__)
+# if defined(_WIN32)
+ __cpuid(registers, info);
+# else
+ __asm volatile("cpuid"
+ : "=a"(registers[0]), "=b"(registers[1]), "=c"(registers[2]), "=d"(registers[3])
+ : "a"(info));
+# endif
+#else
+ registers[0] = 0;
+ registers[1] = 0;
+ registers[2] = 0;
+ registers[3] = 0;
+#endif
}
bool CPUID::detectMMX()
diff --git a/src/Reactor/CPUID.hpp b/src/Reactor/CPUID.hpp
index 577e237..a97c6d4 100644
--- a/src/Reactor/CPUID.hpp
+++ b/src/Reactor/CPUID.hpp
@@ -18,11 +18,11 @@
namespace rr {
#if !defined(__i386__) && defined(_M_IX86)
- #define __i386__ 1
+# define __i386__ 1
#endif
-#if !defined(__x86_64__) && (defined(_M_AMD64) || defined (_M_X64))
- #define __x86_64__ 1
+#if !defined(__x86_64__) && (defined(_M_AMD64) || defined(_M_X64))
+# define __x86_64__ 1
#endif
class CPUID
@@ -30,7 +30,7 @@
public:
static bool supportsMMX();
static bool supportsCMOV();
- static bool supportsMMX2(); // MMX instructions added by SSE: pshufw, pmulhuw, pmovmskb, pavgw/b, pextrw, pinsrw, pmaxsw/ub, etc.
+ static bool supportsMMX2(); // MMX instructions added by SSE: pshufw, pmulhuw, pmovmskb, pavgw/b, pextrw, pinsrw, pmaxsw/ub, etc.
static bool supportsSSE();
static bool supportsSSE2();
static bool supportsSSE3();
@@ -89,7 +89,7 @@
inline bool CPUID::supportsMMX2()
{
- return supportsSSE(); // Coincides with 64-bit integer vector instructions supported by SSE
+ return supportsSSE(); // Coincides with 64-bit integer vector instructions supported by SSE
}
inline bool CPUID::supportsSSE()
@@ -119,4 +119,4 @@
} // namespace rr
-#endif // rr_CPUID_hpp
+#endif // rr_CPUID_hpp
diff --git a/src/Reactor/Coroutine.hpp b/src/Reactor/Coroutine.hpp
index 8bd601e..92ad2e3 100644
--- a/src/Reactor/Coroutine.hpp
+++ b/src/Reactor/Coroutine.hpp
@@ -17,7 +17,7 @@
#include <memory>
#ifndef rr_ReactorCoroutine_hpp
-#define rr_ReactorCoroutine_hpp
+# define rr_ReactorCoroutine_hpp
namespace rr {
@@ -26,17 +26,19 @@
{
protected:
StreamBase(const std::shared_ptr<Routine> &routine, Nucleus::CoroutineHandle handle)
- : routine(routine), handle(handle) {}
+ : routine(routine)
+ , handle(handle)
+ {}
~StreamBase()
{
- auto pfn = (Nucleus::CoroutineDestroy*)routine->getEntry(Nucleus::CoroutineEntryDestroy);
+ auto pfn = (Nucleus::CoroutineDestroy *)routine->getEntry(Nucleus::CoroutineEntryDestroy);
pfn(handle);
}
- bool await(void* out)
+ bool await(void *out)
{
- auto pfn = (Nucleus::CoroutineAwait*)routine->getEntry(Nucleus::CoroutineEntryAwait);
+ auto pfn = (Nucleus::CoroutineAwait *)routine->getEntry(Nucleus::CoroutineEntryAwait);
return pfn(handle, out);
}
@@ -53,13 +55,14 @@
{
public:
inline Stream(const std::shared_ptr<Routine> &routine, Nucleus::CoroutineHandle handle)
- : StreamBase(routine, handle) {}
+ : StreamBase(routine, handle)
+ {}
// await() retrieves the next yielded value from the coroutine.
// Returns true if the coroutine yieled a value and out was assigned a
// new value. If await() returns false, the coroutine has finished
// execution and await() will return false for all future calls.
- inline bool await(T& out) { return StreamBase::await(&out); }
+ inline bool await(T &out) { return StreamBase::await(&out); }
};
template<typename FunctionType>
@@ -143,7 +146,7 @@
protected:
std::unique_ptr<Nucleus> core;
std::shared_ptr<Routine> routine;
- std::vector<Type*> arguments;
+ std::vector<Type *> arguments;
};
template<typename Return, typename... Arguments>
@@ -151,7 +154,7 @@
{
core.reset(new Nucleus());
- std::vector<Type*> types = {CToReactorT<Arguments>::getType()...};
+ std::vector<Type *> types = { CToReactorT<Arguments>::getType()... };
for(auto type : types)
{
if(type != Void::getType())
@@ -180,20 +183,23 @@
finalize();
using Sig = Nucleus::CoroutineBegin<Arguments...>;
- auto pfn = (Sig*)routine->getEntry(Nucleus::CoroutineEntryBegin);
+ auto pfn = (Sig *)routine->getEntry(Nucleus::CoroutineEntryBegin);
auto handle = pfn(args...);
return std::unique_ptr<Stream<Return>>(new Stream<Return>(routine, handle));
}
-#ifdef Yield // Defined in WinBase.h
-#undef Yield
-#endif
+# ifdef Yield // Defined in WinBase.h
+# undef Yield
+# endif
// Suspends execution of the coroutine and yields val to the caller.
// Execution of the coroutine will resume after val is retrieved.
template<typename T>
-inline void Yield(const T &val) { Nucleus::yield(ValueOf(val)); }
+inline void Yield(const T &val)
+{
+ Nucleus::yield(ValueOf(val));
+}
-} // namespace rr
+} // namespace rr
-#endif // rr_ReactorCoroutine_hpp
\ No newline at end of file
+#endif // rr_ReactorCoroutine_hpp
\ No newline at end of file
diff --git a/src/Reactor/Debug.cpp b/src/Reactor/Debug.cpp
index df8e8fc..65a894f 100644
--- a/src/Reactor/Debug.cpp
+++ b/src/Reactor/Debug.cpp
@@ -14,8 +14,8 @@
#include "Debug.hpp"
-#include <string>
#include <stdarg.h>
+#include <string>
namespace rr {
diff --git a/src/Reactor/Debug.hpp b/src/Reactor/Debug.hpp
index da8a48d..c0f3232 100644
--- a/src/Reactor/Debug.hpp
+++ b/src/Reactor/Debug.hpp
@@ -17,18 +17,18 @@
#ifndef rr_DEBUG_H_
#define rr_DEBUG_H_
-#include <stdlib.h>
#include <assert.h>
#include <stdio.h>
+#include <stdlib.h>
#if !defined(TRACE_OUTPUT_FILE)
-#define TRACE_OUTPUT_FILE "debug.txt"
+# define TRACE_OUTPUT_FILE "debug.txt"
#endif
#if defined(__GNUC__) || defined(__clang__)
-#define CHECK_PRINTF_ARGS __attribute__((format(printf, 1, 2)))
+# define CHECK_PRINTF_ARGS __attribute__((format(printf, 1, 2)))
#else
-#define CHECK_PRINTF_ARGS
+# define CHECK_PRINTF_ARGS
#endif
namespace rr {
@@ -49,9 +49,9 @@
// A macro to output a trace of a function call and its arguments to the
// debugging log. Disabled if RR_DISABLE_TRACE is defined.
#if defined(RR_DISABLE_TRACE)
-#define TRACE(message, ...) (void(0))
+# define TRACE(message, ...) (void(0))
#else
-#define TRACE(message, ...) rr::trace("%s:%d TRACE: " message "\n", __FILE__, __LINE__, ##__VA_ARGS__)
+# define TRACE(message, ...) rr::trace("%s:%d TRACE: " message "\n", __FILE__, __LINE__, ##__VA_ARGS__)
#endif
// A macro to print a warning message to the debugging log and stderr to denote
@@ -75,26 +75,34 @@
// WARN() in release builds (NDEBUG && !DCHECK_ALWAYS_ON)
#undef DABORT
#if !defined(NDEBUG) || defined(DCHECK_ALWAYS_ON)
-#define DABORT(message, ...) ABORT(message, ##__VA_ARGS__)
+# define DABORT(message, ...) ABORT(message, ##__VA_ARGS__)
#else
-#define DABORT(message, ...) WARN(message, ##__VA_ARGS__)
+# define DABORT(message, ...) WARN(message, ##__VA_ARGS__)
#endif
// A macro asserting a condition.
// If the condition fails, the condition and message is passed to DABORT().
#undef ASSERT_MSG
-#define ASSERT_MSG(expression, format, ...) do { \
- if(!(expression)) { \
- DABORT("ASSERT(%s): " format "\n", #expression, ##__VA_ARGS__); \
- } } while(0)
+#define ASSERT_MSG(expression, format, ...) \
+ do \
+ { \
+ if(!(expression)) \
+ { \
+ DABORT("ASSERT(%s): " format "\n", #expression, ##__VA_ARGS__); \
+ } \
+ } while(0)
// A macro asserting a condition.
// If the condition fails, the condition is passed to DABORT().
#undef ASSERT
-#define ASSERT(expression) do { \
- if(!(expression)) { \
- DABORT("ASSERT(%s)\n", #expression); \
- } } while(0)
+#define ASSERT(expression) \
+ do \
+ { \
+ if(!(expression)) \
+ { \
+ DABORT("ASSERT(%s)\n", #expression); \
+ } \
+ } while(0)
// A macro to indicate unimplemented functionality.
#undef UNIMPLEMENTED
@@ -107,12 +115,16 @@
// A macro asserting a condition and performing a return.
#undef ASSERT_OR_RETURN
#if !defined(NDEBUG) || defined(DCHECK_ALWAYS_ON)
-#define ASSERT_OR_RETURN(expression) ASSERT(expression)
+# define ASSERT_OR_RETURN(expression) ASSERT(expression)
#else
-#define ASSERT_OR_RETURN(expression) do { \
- if(!(expression)) { \
- return; \
- } } while(0)
+# define ASSERT_OR_RETURN(expression) \
+ do \
+ { \
+ if(!(expression)) \
+ { \
+ return; \
+ } \
+ } while(0)
#endif
-#endif // rr_DEBUG_H_
+#endif // rr_DEBUG_H_
diff --git a/src/Reactor/DebugAndroid.cpp b/src/Reactor/DebugAndroid.cpp
index 2a6569c..5194cc3 100644
--- a/src/Reactor/DebugAndroid.cpp
+++ b/src/Reactor/DebugAndroid.cpp
@@ -14,16 +14,16 @@
#include "DebugAndroid.hpp"
-#include <stdlib.h>
-#include <unistd.h>
-#include <sys/types.h>
#include <cutils/properties.h>
+#include <stdlib.h>
+#include <sys/types.h>
+#include <unistd.h>
void AndroidEnterDebugger()
{
ALOGE(__FUNCTION__);
#ifndef NDEBUG
- static volatile int * const makefault = nullptr;
+ static volatile int *const makefault = nullptr;
char value[PROPERTY_VALUE_MAX];
property_get("debug.db.uid", value, "-1");
int debug_uid = atoi(value);
@@ -31,7 +31,8 @@
{
ALOGE("Waiting for debugger: gdbserver :${PORT} --attach %u. Look for thread %u", getpid(), gettid());
volatile int waiting = 1;
- while(waiting) {
+ while(waiting)
+ {
sleep(1);
}
}
diff --git a/src/Reactor/DebugAndroid.hpp b/src/Reactor/DebugAndroid.hpp
index bb7451e..a8cbc9f 100644
--- a/src/Reactor/DebugAndroid.hpp
+++ b/src/Reactor/DebugAndroid.hpp
@@ -16,11 +16,11 @@
#define DebugAndroid_hpp
#if ANDROID_PLATFORM_SDK_VERSION < 27
-#include <cutils/log.h>
+# include <cutils/log.h>
#elif ANDROID_PLATFORM_SDK_VERSION >= 27
-#include <log/log.h>
+# include <log/log.h>
#else
-#error "ANDROID_PLATFORM_SDK_VERSION is not defined"
+# error "ANDROID_PLATFORM_SDK_VERSION is not defined"
#endif
#include <cassert>
@@ -48,52 +48,61 @@
*/
void AndroidEnterDebugger();
-#define ASSERT(E) do { \
- if(!(E)) { \
- ALOGE("badness: assertion_failed %s in %s at %s:%d", #E, \
- __FUNCTION__, __FILE__, __LINE__); \
- AndroidEnterDebugger(); \
- } \
+#define ASSERT(E) \
+ do \
+ { \
+ if(!(E)) \
+ { \
+ ALOGE("badness: assertion_failed %s in %s at %s:%d", #E, \
+ __FUNCTION__, __FILE__, __LINE__); \
+ AndroidEnterDebugger(); \
+ } \
} while(0)
#undef assert
#define assert(E) ASSERT(E)
-#define ERR(format, ...) \
- do { \
+#define ERR(format, ...) \
+ do \
+ { \
ALOGE("badness: err %s %s:%d (" format ")", __FUNCTION__, __FILE__, \
- __LINE__, ##__VA_ARGS__); \
- AndroidEnterDebugger(); \
+ __LINE__, ##__VA_ARGS__); \
+ AndroidEnterDebugger(); \
} while(0)
-#define FIXME(format, ...) \
- do { \
+#define FIXME(format, ...) \
+ do \
+ { \
ALOGE("badness: fixme %s %s:%d (" format ")", __FUNCTION__, __FILE__, \
- __LINE__, ##__VA_ARGS__); \
- AndroidEnterDebugger(); \
+ __LINE__, ##__VA_ARGS__); \
+ AndroidEnterDebugger(); \
} while(0)
// TODO: Handle __VA_ARGS__ (can be empty)
-#define UNIMPLEMENTED(...) do { \
- ALOGE("badness: unimplemented: %s %s:%d", \
- __FUNCTION__, __FILE__, __LINE__); \
- AndroidEnterDebugger(); \
+#define UNIMPLEMENTED(...) \
+ do \
+ { \
+ ALOGE("badness: unimplemented: %s %s:%d", \
+ __FUNCTION__, __FILE__, __LINE__); \
+ AndroidEnterDebugger(); \
} while(0)
-#define UNREACHABLE(value) do { \
+#define UNREACHABLE(value) \
+ do \
+ { \
ALOGE("badness: unreachable case reached: %s %s:%d. %s: %d", \
- __FUNCTION__, __FILE__, __LINE__, #value, value); \
- AndroidEnterDebugger(); \
+ __FUNCTION__, __FILE__, __LINE__, #value, value); \
+ AndroidEnterDebugger(); \
} while(0)
#ifndef NDEBUG
- #define TRACE(format, ...) \
+# define TRACE(format, ...) \
ALOGV("%s %s:%d (" format ")", __FUNCTION__, __FILE__, \
- __LINE__, ##__VA_ARGS__)
+ __LINE__, ##__VA_ARGS__)
#else
- #define TRACE(...) ((void)0)
+# define TRACE(...) ((void)0)
#endif
void trace(const char *format, ...);
-#endif // DebugAndroid_hpp
+#endif // DebugAndroid_hpp
diff --git a/src/Reactor/EmulatedReactor.cpp b/src/Reactor/EmulatedReactor.cpp
index 3740224..6fb7385 100644
--- a/src/Reactor/EmulatedReactor.cpp
+++ b/src/Reactor/EmulatedReactor.cpp
@@ -7,18 +7,18 @@
namespace rr {
namespace {
-template <typename T>
+template<typename T>
struct UnderlyingType
{
using Type = typename decltype(rr::Extract(std::declval<RValue<T>>(), 0))::rvalue_underlying_type;
};
-template <typename T>
+template<typename T>
using UnderlyingTypeT = typename UnderlyingType<T>::Type;
// Call single arg function on a vector type
-template <typename Func, typename T>
-RValue<T> call4(Func func, const RValue<T>& x)
+template<typename Func, typename T>
+RValue<T> call4(Func func, const RValue<T> &x)
{
T result;
result = Insert(result, Call(func, Extract(x, 0)), 0);
@@ -29,8 +29,8 @@
}
// Call two arg function on a vector type
-template <typename Func, typename T>
-RValue<T> call4(Func func, const RValue<T>& x, const RValue<T>& y)
+template<typename Func, typename T>
+RValue<T> call4(Func func, const RValue<T> &x, const RValue<T> &y)
{
T result;
result = Insert(result, Call(func, Extract(x, 0), Extract(y, 0)), 0);
@@ -40,8 +40,8 @@
return result;
}
-template <typename T, typename EL = UnderlyingTypeT<T>>
-void gather(T& out, RValue<Pointer<EL>> base, RValue<Int4> offsets, RValue<Int4> mask, unsigned int alignment, bool zeroMaskedLanes)
+template<typename T, typename EL = UnderlyingTypeT<T>>
+void gather(T &out, RValue<Pointer<EL>> base, RValue<Int4> offsets, RValue<Int4> mask, unsigned int alignment, bool zeroMaskedLanes)
{
constexpr bool atomic = false;
constexpr std::memory_order order = std::memory_order_relaxed;
@@ -64,7 +64,7 @@
}
}
-template <typename T, typename EL = UnderlyingTypeT<T>>
+template<typename T, typename EL = UnderlyingTypeT<T>>
void scatter(RValue<Pointer<EL>> base, RValue<T> val, RValue<Int4> offsets, RValue<Int4> mask, unsigned int alignment)
{
constexpr bool atomic = false;
diff --git a/src/Reactor/ExecutableMemory.cpp b/src/Reactor/ExecutableMemory.cpp
index b6cee9c..3fec84d 100644
--- a/src/Reactor/ExecutableMemory.cpp
+++ b/src/Reactor/ExecutableMemory.cpp
@@ -17,20 +17,20 @@
#include "Debug.hpp"
#if defined(_WIN32)
- #ifndef WIN32_LEAN_AND_MEAN
- #define WIN32_LEAN_AND_MEAN
- #endif
- #include <windows.h>
- #include <intrin.h>
+# ifndef WIN32_LEAN_AND_MEAN
+# define WIN32_LEAN_AND_MEAN
+# endif
+# include <windows.h>
+# include <intrin.h>
#elif defined(__Fuchsia__)
- #include <unistd.h>
- #include <zircon/process.h>
- #include <zircon/syscalls.h>
+# include <unistd.h>
+# include <zircon/process.h>
+# include <zircon/syscalls.h>
#else
- #include <errno.h>
- #include <sys/mman.h>
- #include <stdlib.h>
- #include <unistd.h>
+# include <errno.h>
+# include <sys/mman.h>
+# include <stdlib.h>
+# include <unistd.h>
#endif
#include <memory.h>
@@ -38,8 +38,8 @@
#undef allocate
#undef deallocate
-#if(defined(__i386__) || defined(_M_IX86) || defined(__x86_64__) || defined (_M_X64)) && !defined(__x86__)
-#define __x86__
+#if(defined(__i386__) || defined(_M_IX86) || defined(__x86_64__) || defined(_M_X64)) && !defined(__x86__)
+# define __x86__
#endif
namespace rr {
@@ -47,61 +47,62 @@
struct Allocation
{
-// size_t bytes;
+ // size_t bytes;
unsigned char *block;
};
void *allocateRaw(size_t bytes, size_t alignment)
{
- ASSERT((alignment & (alignment - 1)) == 0); // Power of 2 alignment.
+ ASSERT((alignment & (alignment - 1)) == 0); // Power of 2 alignment.
- #if defined(LINUX_ENABLE_NAMED_MMAP)
- if(alignment < sizeof(void*))
+#if defined(LINUX_ENABLE_NAMED_MMAP)
+ if(alignment < sizeof(void *))
+ {
+ return malloc(bytes);
+ }
+ else
+ {
+ void *allocation;
+ int result = posix_memalign(&allocation, alignment, bytes);
+ if(result != 0)
{
- return malloc(bytes);
+ errno = result;
+ allocation = nullptr;
}
- else
- {
- void *allocation;
- int result = posix_memalign(&allocation, alignment, bytes);
- if(result != 0)
- {
- errno = result;
- allocation = nullptr;
- }
- return allocation;
- }
- #else
- unsigned char *block = new unsigned char[bytes + sizeof(Allocation) + alignment];
- unsigned char *aligned = nullptr;
+ return allocation;
+ }
+#else
+ unsigned char *block = new unsigned char[bytes + sizeof(Allocation) + alignment];
+ unsigned char *aligned = nullptr;
- if(block)
- {
- aligned = (unsigned char*)((uintptr_t)(block + sizeof(Allocation) + alignment - 1) & -(intptr_t)alignment);
- Allocation *allocation = (Allocation*)(aligned - sizeof(Allocation));
+ if(block)
+ {
+ aligned = (unsigned char *)((uintptr_t)(block + sizeof(Allocation) + alignment - 1) & -(intptr_t)alignment);
+ Allocation *allocation = (Allocation *)(aligned - sizeof(Allocation));
// allocation->bytes = bytes;
- allocation->block = block;
- }
+ allocation->block = block;
+ }
- return aligned;
- #endif
+ return aligned;
+#endif
}
#if defined(_WIN32)
DWORD permissionsToProtectMode(int permissions)
{
- switch(permissions) {
+ switch(permissions)
+ {
case PERMISSION_READ:
- return PAGE_READONLY;
+ return PAGE_READONLY;
case PERMISSION_EXECUTE:
- return PAGE_EXECUTE;
+ return PAGE_EXECUTE;
case PERMISSION_READ | PERMISSION_WRITE:
- return PAGE_READWRITE;
+ return PAGE_READWRITE;
case PERMISSION_READ | PERMISSION_EXECUTE:
- return PAGE_EXECUTE_READ;
+ return PAGE_EXECUTE_READ;
case PERMISSION_READ | PERMISSION_WRITE | PERMISSION_EXECUTE:
- return PAGE_EXECUTE_READWRITE;
+ return PAGE_EXECUTE_READWRITE;
}
return PAGE_NOACCESS;
}
@@ -131,26 +132,26 @@
// Create a file descriptor for anonymous memory with the given
// name. Returns -1 on failure.
// TODO: remove once libc wrapper exists.
-int memfd_create(const char* name, unsigned int flags)
+int memfd_create(const char *name, unsigned int flags)
{
- #if __aarch64__
- #define __NR_memfd_create 279
- #elif __arm__
- #define __NR_memfd_create 279
- #elif __powerpc64__
- #define __NR_memfd_create 360
- #elif __i386__
- #define __NR_memfd_create 356
- #elif __x86_64__
- #define __NR_memfd_create 319
- #endif /* __NR_memfd_create__ */
- #ifdef __NR_memfd_create
- // In the event of no system call this returns -1 with errno set
- // as ENOSYS.
- return syscall(__NR_memfd_create, name, flags);
- #else
- return -1;
- #endif
+# if __aarch64__
+# define __NR_memfd_create 279
+# elif __arm__
+# define __NR_memfd_create 279
+# elif __powerpc64__
+# define __NR_memfd_create 360
+# elif __i386__
+# define __NR_memfd_create 356
+# elif __x86_64__
+# define __NR_memfd_create 319
+# endif /* __NR_memfd_create__ */
+# ifdef __NR_memfd_create
+ // In the event of no system call this returns -1 with errno set
+ // as ENOSYS.
+ return syscall(__NR_memfd_create, name, flags);
+# else
+ return -1;
+# endif
}
// Returns a file descriptor for use with an anonymous mmap, if
@@ -175,7 +176,8 @@
#endif // defined(LINUX_ENABLE_NAMED_MMAP)
#if defined(__Fuchsia__)
-zx_vm_option_t permissionsToZxVmOptions(int permissions) {
+zx_vm_option_t permissionsToZxVmOptions(int permissions)
+{
zx_vm_option_t result = 0;
if(permissions & PERMISSION_READ)
{
@@ -201,13 +203,13 @@
if(pageSize == 0)
{
- #if defined(_WIN32)
- SYSTEM_INFO systemInfo;
- GetSystemInfo(&systemInfo);
- pageSize = systemInfo.dwPageSize;
- #else
- pageSize = sysconf(_SC_PAGESIZE);
- #endif
+#if defined(_WIN32)
+ SYSTEM_INFO systemInfo;
+ GetSystemInfo(&systemInfo);
+ pageSize = systemInfo.dwPageSize;
+#else
+ pageSize = sysconf(_SC_PAGESIZE);
+#endif
}
return pageSize;
@@ -227,23 +229,23 @@
void deallocate(void *memory)
{
- #if defined(LINUX_ENABLE_NAMED_MMAP)
- free(memory);
- #else
- if(memory)
- {
- unsigned char *aligned = (unsigned char*)memory;
- Allocation *allocation = (Allocation*)(aligned - sizeof(Allocation));
+#if defined(LINUX_ENABLE_NAMED_MMAP)
+ free(memory);
+#else
+ if(memory)
+ {
+ unsigned char *aligned = (unsigned char *)memory;
+ Allocation *allocation = (Allocation *)(aligned - sizeof(Allocation));
- delete[] allocation->block;
- }
- #endif
+ delete[] allocation->block;
+ }
+#endif
}
// Rounds |x| up to a multiple of |m|, where |m| is a power of 2.
inline uintptr_t roundUp(uintptr_t x, uintptr_t m)
{
- ASSERT(m > 0 && (m & (m - 1)) == 0); // |m| must be a power of 2.
+ ASSERT(m > 0 && (m & (m - 1)) == 0); // |m| must be a power of 2.
return (x + m - 1) & ~(m - 1);
}
@@ -253,74 +255,76 @@
size_t length = roundUp(bytes, pageSize);
void *mapping = nullptr;
- #if defined(LINUX_ENABLE_NAMED_MMAP)
- int flags = MAP_PRIVATE;
+#if defined(LINUX_ENABLE_NAMED_MMAP)
+ int flags = MAP_PRIVATE;
- // Try to name the memory region for the executable code,
- // to aid profilers.
- int anonFd = anonymousFd();
- if(anonFd == -1)
- {
- flags |= MAP_ANONYMOUS;
- }
- else
- {
- ensureAnonFileSize(anonFd, length);
- }
+ // Try to name the memory region for the executable code,
+ // to aid profilers.
+ int anonFd = anonymousFd();
+ if(anonFd == -1)
+ {
+ flags |= MAP_ANONYMOUS;
+ }
+ else
+ {
+ ensureAnonFileSize(anonFd, length);
+ }
- mapping = mmap(
- nullptr, length, permissionsToMmapProt(permissions), flags, anonFd, 0);
+ mapping = mmap(
+ nullptr, length, permissionsToMmapProt(permissions), flags, anonFd, 0);
- if(mapping == MAP_FAILED)
- {
- mapping = nullptr;
- }
- #elif defined(__Fuchsia__)
- zx_handle_t vmo;
- if(zx_vmo_create(length, 0, &vmo) != ZX_OK) {
- return nullptr;
- }
- if(need_exec &&
- zx_vmo_replace_as_executable(vmo, ZX_HANDLE_INVALID, &vmo) != ZX_OK)
- {
- return nullptr;
- }
- zx_vaddr_t reservation;
- zx_status_t status = zx_vmar_map(
- zx_vmar_root_self(), permissionsToZxVmOptions(permissions), 0, vmo,
- 0, length, &reservation);
- zx_handle_close(vmo);
- if(status != ZX_OK) {
- return nullptr;
- }
+ if(mapping == MAP_FAILED)
+ {
+ mapping = nullptr;
+ }
+#elif defined(__Fuchsia__)
+ zx_handle_t vmo;
+ if(zx_vmo_create(length, 0, &vmo) != ZX_OK)
+ {
+ return nullptr;
+ }
+ if(need_exec &&
+ zx_vmo_replace_as_executable(vmo, ZX_HANDLE_INVALID, &vmo) != ZX_OK)
+ {
+ return nullptr;
+ }
+ zx_vaddr_t reservation;
+ zx_status_t status = zx_vmar_map(
+ zx_vmar_root_self(), permissionsToZxVmOptions(permissions), 0, vmo,
+ 0, length, &reservation);
+ zx_handle_close(vmo);
+ if(status != ZX_OK)
+ {
+ return nullptr;
+ }
- // zx_vmar_map() returns page-aligned address.
- ASSERT(roundUp(reservation, pageSize) == reservation);
+ // zx_vmar_map() returns page-aligned address.
+ ASSERT(roundUp(reservation, pageSize) == reservation);
- mapping = reinterpret_cast<void*>(reservation);
- #elif defined(__APPLE__)
- int prot = permissionsToMmapProt(permissions);
- int flags = MAP_PRIVATE | MAP_ANONYMOUS;
- // On macOS 10.14 and higher, executables that are code signed with the
- // "runtime" option cannot execute writable memory by default. They can opt
- // into this capability by specifying the "com.apple.security.cs.allow-jit"
- // code signing entitlement and allocating the region with the MAP_JIT flag.
- mapping = mmap(nullptr, length, prot, flags | MAP_JIT, -1, 0);
+ mapping = reinterpret_cast<void *>(reservation);
+#elif defined(__APPLE__)
+ int prot = permissionsToMmapProt(permissions);
+ int flags = MAP_PRIVATE | MAP_ANONYMOUS;
+ // On macOS 10.14 and higher, executables that are code signed with the
+ // "runtime" option cannot execute writable memory by default. They can opt
+ // into this capability by specifying the "com.apple.security.cs.allow-jit"
+ // code signing entitlement and allocating the region with the MAP_JIT flag.
+ mapping = mmap(nullptr, length, prot, flags | MAP_JIT, -1, 0);
- if(mapping == MAP_FAILED)
- {
- // Retry without MAP_JIT (for older macOS versions).
- mapping = mmap(nullptr, length, prot, flags, -1, 0);
- }
+ if(mapping == MAP_FAILED)
+ {
+ // Retry without MAP_JIT (for older macOS versions).
+ mapping = mmap(nullptr, length, prot, flags, -1, 0);
+ }
- if(mapping == MAP_FAILED)
- {
- mapping = nullptr;
- }
- #else
- mapping = allocate(length, pageSize);
- protectMemoryPages(mapping, length, permissions);
- #endif
+ if(mapping == MAP_FAILED)
+ {
+ mapping = nullptr;
+ }
+#else
+ mapping = allocate(length, pageSize);
+ protectMemoryPages(mapping, length, permissions);
+#endif
return mapping;
}
@@ -331,48 +335,48 @@
return;
bytes = roundUp(bytes, memoryPageSize());
- #if defined(_WIN32)
- unsigned long oldProtection;
- BOOL result =
- VirtualProtect(memory, bytes, permissionsToProtectMode(permissions),
- &oldProtection);
- ASSERT(result);
- #elif defined(__Fuchsia__)
- zx_status_t status = zx_vmar_protect(
- zx_vmar_root_self(), permissionsToZxVmOptions(permissions),
- reinterpret_cast<zx_vaddr_t>(memory), bytes);
- ASSERT(status == ZX_OK);
- #else
- int result =
- mprotect(memory, bytes, permissionsToMmapProt(permissions));
- ASSERT(result == 0);
- #endif
+#if defined(_WIN32)
+ unsigned long oldProtection;
+ BOOL result =
+ VirtualProtect(memory, bytes, permissionsToProtectMode(permissions),
+ &oldProtection);
+ ASSERT(result);
+#elif defined(__Fuchsia__)
+ zx_status_t status = zx_vmar_protect(
+ zx_vmar_root_self(), permissionsToZxVmOptions(permissions),
+ reinterpret_cast<zx_vaddr_t>(memory), bytes);
+ ASSERT(status == ZX_OK);
+#else
+ int result =
+ mprotect(memory, bytes, permissionsToMmapProt(permissions));
+ ASSERT(result == 0);
+#endif
}
void deallocateMemoryPages(void *memory, size_t bytes)
{
- #if defined(_WIN32)
- unsigned long oldProtection;
- BOOL result =
- VirtualProtect(memory, bytes, PAGE_READWRITE, &oldProtection);
- ASSERT(result);
- deallocate(memory);
- #elif defined(LINUX_ENABLE_NAMED_MMAP) || defined(__APPLE__)
- size_t pageSize = memoryPageSize();
- size_t length = (bytes + pageSize - 1) & ~(pageSize - 1);
- int result = munmap(memory, length);
- ASSERT(result == 0);
- #elif defined(__Fuchsia__)
- size_t pageSize = memoryPageSize();
- size_t length = roundUp(bytes, pageSize);
- zx_status_t status = zx_vmar_unmap(
- zx_vmar_root_self(), reinterpret_cast<zx_vaddr_t>(memory), length);
- ASSERT(status == ZX_OK);
- #else
- int result = mprotect(memory, bytes, PROT_READ | PROT_WRITE);
- ASSERT(result == 0);
- deallocate(memory);
- #endif
+#if defined(_WIN32)
+ unsigned long oldProtection;
+ BOOL result =
+ VirtualProtect(memory, bytes, PAGE_READWRITE, &oldProtection);
+ ASSERT(result);
+ deallocate(memory);
+#elif defined(LINUX_ENABLE_NAMED_MMAP) || defined(__APPLE__)
+ size_t pageSize = memoryPageSize();
+ size_t length = (bytes + pageSize - 1) & ~(pageSize - 1);
+ int result = munmap(memory, length);
+ ASSERT(result == 0);
+#elif defined(__Fuchsia__)
+ size_t pageSize = memoryPageSize();
+ size_t length = roundUp(bytes, pageSize);
+ zx_status_t status = zx_vmar_unmap(
+ zx_vmar_root_self(), reinterpret_cast<zx_vaddr_t>(memory), length);
+ ASSERT(status == ZX_OK);
+#else
+ int result = mprotect(memory, bytes, PROT_READ | PROT_WRITE);
+ ASSERT(result == 0);
+ deallocate(memory);
+#endif
}
} // namespace rr
diff --git a/src/Reactor/ExecutableMemory.hpp b/src/Reactor/ExecutableMemory.hpp
index b0ca05e..dbbe32a 100644
--- a/src/Reactor/ExecutableMemory.hpp
+++ b/src/Reactor/ExecutableMemory.hpp
@@ -23,7 +23,8 @@
size_t memoryPageSize();
-enum MemoryPermission {
+enum MemoryPermission
+{
PERMISSION_READ = 1,
PERMISSION_WRITE = 2,
PERMISSION_EXECUTE = 4,
@@ -31,7 +32,7 @@
// Allocates memory with the specified permissions. If |need_exec| is true then
// the allocate memory can be made marked executable using protectMemoryPages().
-void* allocateMemoryPages(size_t bytes, int permissions, bool need_exec);
+void *allocateMemoryPages(size_t bytes, int permissions, bool need_exec);
// Sets permissions for memory allocated with allocateMemoryPages().
void protectMemoryPages(void *memory, size_t bytes, int permissions);
@@ -58,7 +59,9 @@
class unaligned_ref
{
public:
- explicit unaligned_ref(void *ptr) : ptr((P*)ptr) {}
+ explicit unaligned_ref(void *ptr)
+ : ptr((P *)ptr)
+ {}
template<typename V>
P operator=(V value)
@@ -69,7 +72,7 @@
operator P()
{
- return unaligned_read((P*)ptr);
+ return unaligned_read((P *)ptr);
}
private:
@@ -83,7 +86,9 @@
friend class unaligned_ptr;
public:
- unaligned_ptr(P *ptr) : ptr(ptr) {}
+ unaligned_ptr(P *ptr)
+ : ptr(ptr)
+ {}
unaligned_ref<P> operator*()
{
@@ -102,4 +107,4 @@
} // namespace rr
-#endif // rr_ExecutableMemory_hpp
+#endif // rr_ExecutableMemory_hpp
diff --git a/src/Reactor/LLVMReactor.cpp b/src/Reactor/LLVMReactor.cpp
index 4b6bb77..7b06cb4 100644
--- a/src/Reactor/LLVMReactor.cpp
+++ b/src/Reactor/LLVMReactor.cpp
@@ -12,16 +12,16 @@
// See the License for the specific language governing permissions and
// limitations under the License.
-#include "Reactor.hpp"
-#include "Debug.hpp"
#include "LLVMReactor.hpp"
+#include "Debug.hpp"
#include "LLVMReactorDebugInfo.hpp"
+#include "Reactor.hpp"
-#include "x86.hpp"
#include "CPUID.hpp"
-#include "Thread.hpp"
#include "ExecutableMemory.hpp"
#include "MutexLock.hpp"
+#include "Thread.hpp"
+#include "x86.hpp"
#undef min
#undef max
@@ -29,13 +29,13 @@
#if defined(__clang__)
// LLVM has occurances of the extra-semi warning in its headers, which will be
// treated as an error in SwiftShader targets.
-#pragma clang diagnostic push
-#pragma clang diagnostic ignored "-Wextra-semi"
+# pragma clang diagnostic push
+# pragma clang diagnostic ignored "-Wextra-semi"
#endif // defined(__clang__)
#ifdef _MSC_VER
__pragma(warning(push))
-__pragma(warning(disable : 4146)) // unary minus operator applied to unsigned type, result still unsigned
+ __pragma(warning(disable : 4146)) // unary minus operator applied to unsigned type, result still unsigned
#endif
#include "llvm/Analysis/LoopPass.h"
@@ -51,10 +51,10 @@
#include "llvm/IR/DataLayout.h"
#include "llvm/IR/Function.h"
#include "llvm/IR/GlobalVariable.h"
-#include "llvm/IR/Intrinsics.h"
#include "llvm/IR/IRBuilder.h"
-#include "llvm/IR/LegacyPassManager.h"
+#include "llvm/IR/Intrinsics.h"
#include "llvm/IR/LLVMContext.h"
+#include "llvm/IR/LegacyPassManager.h"
#include "llvm/IR/Mangler.h"
#include "llvm/IR/Module.h"
#include "llvm/IR/Verifier.h"
@@ -62,21 +62,24 @@
#include "llvm/Support/TargetSelect.h"
#include "llvm/Target/TargetOptions.h"
#include "llvm/Transforms/Coroutines.h"
-#include "llvm/Transforms/InstCombine/InstCombine.h"
#include "llvm/Transforms/IPO.h"
#include "llvm/Transforms/IPO/PassManagerBuilder.h"
+#include "llvm/Transforms/InstCombine/InstCombine.h"
#include "llvm/Transforms/Scalar.h"
#include "llvm/Transforms/Scalar/GVN.h"
#if defined(__clang__)
-#pragma clang diagnostic pop
-#endif // defined(__clang__)
+# pragma clang diagnostic pop
+#endif // defined(__clang__)
#ifdef _MSC_VER
-__pragma(warning(pop))
+ __pragma(warning(pop))
#endif
-#define ARGS(...) {__VA_ARGS__}
+#define ARGS(...) \
+ { \
+ __VA_ARGS__ \
+ }
#define CreateCall2 CreateCall
#define CreateCall3 CreateCall
@@ -89,27 +92,27 @@
#include <thread>
#if defined(__i386__) || defined(__x86_64__)
-#include <xmmintrin.h>
+# include <xmmintrin.h>
#endif
#include <math.h>
#if defined(__x86_64__) && defined(_WIN32)
- extern "C" void X86CompilationCallback()
- {
- UNIMPLEMENTED("X86CompilationCallback");
- }
+ extern "C" void X86CompilationCallback()
+{
+ UNIMPLEMENTED("X86CompilationCallback");
+}
#endif
#if defined(_WIN64)
- extern "C" void __chkstk();
+extern "C" void __chkstk();
#elif defined(_WIN32)
- extern "C" void _chkstk();
+extern "C" void _chkstk();
#endif
namespace rr {
-void* resolveExternalSymbol(const char*);
+void *resolveExternalSymbol(const char *);
} // namespace rr
@@ -122,33 +125,34 @@
// This uses a static in a function to avoid the cost of a global static
// initializer. See http://neugierig.org/software/chromium/notes/2011/08/static-initializers.html
static rr::Config config = rr::Config::Edit()
- .add(rr::Optimization::Pass::ScalarReplAggregates)
- .add(rr::Optimization::Pass::InstructionCombining)
- .apply({});
+ .add(rr::Optimization::Pass::ScalarReplAggregates)
+ .add(rr::Optimization::Pass::InstructionCombining)
+ .apply({});
return config;
}
// Cache provides a simple, thread-safe key-value store.
-template <typename KEY, typename VALUE>
+template<typename KEY, typename VALUE>
class Cache
{
public:
Cache() = default;
- Cache(const Cache& other);
+ Cache(const Cache &other);
VALUE getOrCreate(KEY key, std::function<VALUE()> create);
+
private:
- mutable std::mutex mutex; // mutable required for copy constructor.
+ mutable std::mutex mutex; // mutable required for copy constructor.
std::unordered_map<KEY, VALUE> map;
};
-template <typename KEY, typename VALUE>
-Cache<KEY, VALUE>::Cache(const Cache& other)
+template<typename KEY, typename VALUE>
+Cache<KEY, VALUE>::Cache(const Cache &other)
{
std::unique_lock<std::mutex> lock(other.mutex);
map = other.map;
}
-template <typename KEY, typename VALUE>
+template<typename KEY, typename VALUE>
VALUE Cache<KEY, VALUE>::getOrCreate(KEY key, std::function<VALUE()> create)
{
std::unique_lock<std::mutex> lock(mutex);
@@ -169,11 +173,11 @@
public:
using TargetMachineSPtr = std::shared_ptr<llvm::TargetMachine>;
- static JITGlobals * get();
+ static JITGlobals *get();
const std::string mcpu;
const std::vector<std::string> mattrs;
- const char* const march;
+ const char *const march;
const llvm::TargetOptions targetOptions;
const llvm::DataLayout dataLayout;
@@ -187,7 +191,7 @@
const char *march,
const llvm::TargetOptions &targetOptions,
const llvm::DataLayout &dataLayout);
- JITGlobals(const JITGlobals&) = default;
+ JITGlobals(const JITGlobals &) = default;
// The cache key here is actually a rr::Optimization::Level. We use int
// as 'enum class' types do not provide builtin hash functions until
@@ -195,7 +199,7 @@
Cache<int, TargetMachineSPtr> targetMachines;
};
-JITGlobals * JITGlobals::get()
+JITGlobals *JITGlobals::get()
{
static JITGlobals instance = create();
return &instance;
@@ -206,15 +210,15 @@
return targetMachines.getOrCreate(static_cast<int>(optlevel), [&]() {
return TargetMachineSPtr(llvm::EngineBuilder()
#ifdef ENABLE_RR_DEBUG_INFO
- .setOptLevel(toLLVM(rr::Optimization::Level::None))
+ .setOptLevel(toLLVM(rr::Optimization::Level::None))
#else
- .setOptLevel(toLLVM(optlevel))
-#endif // ENABLE_RR_DEBUG_INFO
- .setMCPU(mcpu)
- .setMArch(march)
- .setMAttrs(mattrs)
- .setTargetOptions(targetOptions)
- .selectTarget());
+ .setOptLevel(toLLVM(optlevel))
+#endif // ENABLE_RR_DEBUG_INFO
+ .setMCPU(mcpu)
+ .setMArch(march)
+ .setMAttrs(mattrs)
+ .setTargetOptions(targetOptions)
+ .selectTarget());
});
}
@@ -237,10 +241,10 @@
bool ok = llvm::sys::getHostCPUFeatures(features);
#if defined(__i386__) || defined(__x86_64__) || \
-(defined(__linux__) && (defined(__arm__) || defined(__aarch64__)))
+ (defined(__linux__) && (defined(__arm__) || defined(__aarch64__)))
ASSERT_MSG(ok, "llvm::sys::getHostCPUFeatures returned false");
#else
- (void) ok; // getHostCPUFeatures always returns false on other platforms
+ (void)ok; // getHostCPUFeatures always returns false on other platforms
#endif
std::vector<std::string> mattrs;
@@ -249,7 +253,7 @@
if(feature.second) { mattrs.push_back(feature.first()); }
}
- const char* march = nullptr;
+ const char *march = nullptr;
#if defined(__x86_64__)
march = "x86-64";
#elif defined(__i386__)
@@ -259,28 +263,28 @@
#elif defined(__arm__)
march = "arm";
#elif defined(__mips__)
-#if defined(__mips64)
+# if defined(__mips64)
march = "mips64el";
-#else
+# else
march = "mipsel";
-#endif
+# endif
#elif defined(__powerpc64__) && __BYTE_ORDER__ == __ORDER_LITTLE_ENDIAN__
march = "ppc64le";
#else
- #error "unknown architecture"
+# error "unknown architecture"
#endif
llvm::TargetOptions targetOptions;
targetOptions.UnsafeFPMath = false;
auto targetMachine = std::unique_ptr<llvm::TargetMachine>(
- llvm::EngineBuilder()
- .setOptLevel(llvm::CodeGenOpt::None)
- .setMCPU(mcpu)
- .setMArch(march)
- .setMAttrs(mattrs)
- .setTargetOptions(targetOptions)
- .selectTarget());
+ llvm::EngineBuilder()
+ .setOptLevel(llvm::CodeGenOpt::None)
+ .setMCPU(mcpu)
+ .setMArch(march)
+ .setMAttrs(mattrs)
+ .setTargetOptions(targetOptions)
+ .selectTarget());
auto dataLayout = targetMachine->createDataLayout();
@@ -291,25 +295,25 @@
{
switch(level)
{
- case rr::Optimization::Level::None: return ::llvm::CodeGenOpt::None;
- case rr::Optimization::Level::Less: return ::llvm::CodeGenOpt::Less;
- case rr::Optimization::Level::Default: return ::llvm::CodeGenOpt::Default;
+ case rr::Optimization::Level::None: return ::llvm::CodeGenOpt::None;
+ case rr::Optimization::Level::Less: return ::llvm::CodeGenOpt::Less;
+ case rr::Optimization::Level::Default: return ::llvm::CodeGenOpt::Default;
case rr::Optimization::Level::Aggressive: return ::llvm::CodeGenOpt::Aggressive;
default: UNREACHABLE("Unknown Optimization Level %d", int(level));
}
return ::llvm::CodeGenOpt::Default;
}
-JITGlobals::JITGlobals(const char* mcpu,
+JITGlobals::JITGlobals(const char *mcpu,
const std::vector<std::string> &mattrs,
- const char* march,
+ const char *march,
const llvm::TargetOptions &targetOptions,
- const llvm::DataLayout &dataLayout) :
- mcpu(mcpu),
- mattrs(mattrs),
- march(march),
- targetOptions(targetOptions),
- dataLayout(dataLayout)
+ const llvm::DataLayout &dataLayout)
+ : mcpu(mcpu)
+ , mattrs(mattrs)
+ , march(march)
+ , targetOptions(targetOptions)
+ , dataLayout(dataLayout)
{
}
@@ -320,9 +324,10 @@
~MemoryMapper() final {}
llvm::sys::MemoryBlock allocateMappedMemory(
- llvm::SectionMemoryManager::AllocationPurpose purpose,
- size_t numBytes, const llvm::sys::MemoryBlock *const nearBlock,
- unsigned flags, std::error_code &errorCode) final {
+ llvm::SectionMemoryManager::AllocationPurpose purpose,
+ size_t numBytes, const llvm::sys::MemoryBlock *const nearBlock,
+ unsigned flags, std::error_code &errorCode) final
+ {
errorCode = std::error_code();
// Round up numBytes to page size.
@@ -330,37 +335,40 @@
numBytes = (numBytes + pageSize - 1) & ~(pageSize - 1);
bool need_exec =
- purpose == llvm::SectionMemoryManager::AllocationPurpose::Code;
- void* addr = rr::allocateMemoryPages(
- numBytes, flagsToPermissions(flags), need_exec);
+ purpose == llvm::SectionMemoryManager::AllocationPurpose::Code;
+ void *addr = rr::allocateMemoryPages(
+ numBytes, flagsToPermissions(flags), need_exec);
if(!addr)
return llvm::sys::MemoryBlock();
return llvm::sys::MemoryBlock(addr, numBytes);
}
std::error_code protectMappedMemory(const llvm::sys::MemoryBlock &block,
- unsigned flags) {
+ unsigned flags)
+ {
// Round down base address to align with a page boundary. This matches
// DefaultMMapper behavior.
- void* addr = block.base();
+ void *addr = block.base();
size_t size = block.size();
size_t pageSize = rr::memoryPageSize();
- addr = reinterpret_cast<void*>(
- reinterpret_cast<uintptr_t>(addr) & ~(pageSize - 1));
+ addr = reinterpret_cast<void *>(
+ reinterpret_cast<uintptr_t>(addr) & ~(pageSize - 1));
size += reinterpret_cast<uintptr_t>(block.base()) -
- reinterpret_cast<uintptr_t>(addr);
+ reinterpret_cast<uintptr_t>(addr);
rr::protectMemoryPages(addr, size, flagsToPermissions(flags));
return std::error_code();
}
- std::error_code releaseMappedMemory(llvm::sys::MemoryBlock &block) {
+ std::error_code releaseMappedMemory(llvm::sys::MemoryBlock &block)
+ {
rr::deallocateMemoryPages(block.base(), block.size());
return std::error_code();
}
private:
- int flagsToPermissions(unsigned flags) {
+ int flagsToPermissions(unsigned flags)
+ {
int result = 0;
if(flags & llvm::sys::Memory::MF_READ)
{
@@ -376,7 +384,6 @@
}
return result;
}
-
};
// JITRoutine is a rr::Routine that holds a LLVM JIT session, compiler and
@@ -394,48 +401,47 @@
public:
JITRoutine(
- std::unique_ptr<llvm::Module> module,
- llvm::Function **funcs,
- size_t count,
- const rr::Config &config) :
- resolver(createLegacyLookupResolver(
- session,
- [&](const std::string &name) {
- void *func = rr::resolveExternalSymbol(name.c_str());
- if(func != nullptr)
- {
- return llvm::JITSymbol(
- reinterpret_cast<uintptr_t>(func), llvm::JITSymbolFlags::Absolute);
- }
- return objLayer.findSymbol(name, true);
- },
- [](llvm::Error err) {
- if(err)
- {
- // TODO: Log the symbol resolution errors.
- return;
- }
- })),
- targetMachine(JITGlobals::get()->getTargetMachine(config.getOptimization().getLevel())),
- compileLayer(objLayer, llvm::orc::SimpleCompiler(*targetMachine)),
- objLayer(
- session,
- [this](llvm::orc::VModuleKey) {
- return ObjLayer::Resources{std::make_shared<llvm::SectionMemoryManager>(&memoryMapper), resolver};
- },
- ObjLayer::NotifyLoadedFtor(),
- [](llvm::orc::VModuleKey, const llvm::object::ObjectFile &Obj, const llvm::RuntimeDyld::LoadedObjectInfo &L) {
+ std::unique_ptr<llvm::Module> module,
+ llvm::Function **funcs,
+ size_t count,
+ const rr::Config &config)
+ : resolver(createLegacyLookupResolver(
+ session,
+ [&](const std::string &name) {
+ void *func = rr::resolveExternalSymbol(name.c_str());
+ if(func != nullptr)
+ {
+ return llvm::JITSymbol(
+ reinterpret_cast<uintptr_t>(func), llvm::JITSymbolFlags::Absolute);
+ }
+ return objLayer.findSymbol(name, true);
+ },
+ [](llvm::Error err) {
+ if(err)
+ {
+ // TODO: Log the symbol resolution errors.
+ return;
+ }
+ }))
+ , targetMachine(JITGlobals::get()->getTargetMachine(config.getOptimization().getLevel()))
+ , compileLayer(objLayer, llvm::orc::SimpleCompiler(*targetMachine))
+ , objLayer(
+ session,
+ [this](llvm::orc::VModuleKey) {
+ return ObjLayer::Resources{ std::make_shared<llvm::SectionMemoryManager>(&memoryMapper), resolver };
+ },
+ ObjLayer::NotifyLoadedFtor(),
+ [](llvm::orc::VModuleKey, const llvm::object::ObjectFile &Obj, const llvm::RuntimeDyld::LoadedObjectInfo &L) {
#ifdef ENABLE_RR_DEBUG_INFO
- rr::DebugInfo::NotifyObjectEmitted(Obj, L);
-#endif // ENABLE_RR_DEBUG_INFO
- },
- [](llvm::orc::VModuleKey, const llvm::object::ObjectFile &Obj) {
+ rr::DebugInfo::NotifyObjectEmitted(Obj, L);
+#endif // ENABLE_RR_DEBUG_INFO
+ },
+ [](llvm::orc::VModuleKey, const llvm::object::ObjectFile &Obj) {
#ifdef ENABLE_RR_DEBUG_INFO
- rr::DebugInfo::NotifyFreeingObject(Obj);
-#endif // ENABLE_RR_DEBUG_INFO
- }
- ),
- addresses(count)
+ rr::DebugInfo::NotifyFreeingObject(Obj);
+#endif // ENABLE_RR_DEBUG_INFO
+ })
+ , addresses(count)
{
std::vector<std::string> mangledNames(count);
for(size_t i = 0; i < count; i++)
@@ -490,10 +496,10 @@
class JITBuilder
{
public:
- JITBuilder(const rr::Config &config) :
- config(config),
- module(new llvm::Module("", context)),
- builder(new llvm::IRBuilder<>(context))
+ JITBuilder(const rr::Config &config)
+ : config(config)
+ , module(new llvm::Module("", context))
+ , builder(new llvm::IRBuilder<>(context))
{
module->setDataLayout(JITGlobals::get()->dataLayout);
}
@@ -504,30 +510,30 @@
#ifdef ENABLE_RR_DEBUG_INFO
if(debugInfo != nullptr)
{
- return; // Don't optimize if we're generating debug info.
+ return; // Don't optimize if we're generating debug info.
}
-#endif // ENABLE_RR_DEBUG_INFO
+#endif // ENABLE_RR_DEBUG_INFO
std::unique_ptr<llvm::legacy::PassManager> passManager(
- new llvm::legacy::PassManager());
+ new llvm::legacy::PassManager());
for(auto pass : cfg.getOptimization().getPasses())
{
switch(pass)
{
- case rr::Optimization::Pass::Disabled: break;
- case rr::Optimization::Pass::CFGSimplification: passManager->add(llvm::createCFGSimplificationPass()); break;
- case rr::Optimization::Pass::LICM: passManager->add(llvm::createLICMPass()); break;
- case rr::Optimization::Pass::AggressiveDCE: passManager->add(llvm::createAggressiveDCEPass()); break;
- case rr::Optimization::Pass::GVN: passManager->add(llvm::createGVNPass()); break;
- case rr::Optimization::Pass::InstructionCombining: passManager->add(llvm::createInstructionCombiningPass()); break;
- case rr::Optimization::Pass::Reassociate: passManager->add(llvm::createReassociatePass()); break;
- case rr::Optimization::Pass::DeadStoreElimination: passManager->add(llvm::createDeadStoreEliminationPass()); break;
- case rr::Optimization::Pass::SCCP: passManager->add(llvm::createSCCPPass()); break;
- case rr::Optimization::Pass::ScalarReplAggregates: passManager->add(llvm::createSROAPass()); break;
- case rr::Optimization::Pass::EarlyCSEPass: passManager->add(llvm::createEarlyCSEPass()); break;
- default:
- UNREACHABLE("pass: %d", int(pass));
+ case rr::Optimization::Pass::Disabled: break;
+ case rr::Optimization::Pass::CFGSimplification: passManager->add(llvm::createCFGSimplificationPass()); break;
+ case rr::Optimization::Pass::LICM: passManager->add(llvm::createLICMPass()); break;
+ case rr::Optimization::Pass::AggressiveDCE: passManager->add(llvm::createAggressiveDCEPass()); break;
+ case rr::Optimization::Pass::GVN: passManager->add(llvm::createGVNPass()); break;
+ case rr::Optimization::Pass::InstructionCombining: passManager->add(llvm::createInstructionCombiningPass()); break;
+ case rr::Optimization::Pass::Reassociate: passManager->add(llvm::createReassociatePass()); break;
+ case rr::Optimization::Pass::DeadStoreElimination: passManager->add(llvm::createDeadStoreEliminationPass()); break;
+ case rr::Optimization::Pass::SCCP: passManager->add(llvm::createSCCPPass()); break;
+ case rr::Optimization::Pass::ScalarReplAggregates: passManager->add(llvm::createSROAPass()); break;
+ case rr::Optimization::Pass::EarlyCSEPass: passManager->add(llvm::createEarlyCSEPass()); break;
+ default:
+ UNREACHABLE("pass: %d", int(pass));
}
}
@@ -570,38 +576,39 @@
std::mutex codegenMutex;
#ifdef ENABLE_RR_PRINT
-std::string replace(std::string str, const std::string& substr, const std::string& replacement)
+std::string replace(std::string str, const std::string &substr, const std::string &replacement)
{
size_t pos = 0;
- while((pos = str.find(substr, pos)) != std::string::npos) {
+ while((pos = str.find(substr, pos)) != std::string::npos)
+ {
str.replace(pos, substr.length(), replacement);
pos += replacement.length();
}
return str;
}
-#endif // ENABLE_RR_PRINT
+#endif // ENABLE_RR_PRINT
-template <typename T>
+template<typename T>
T alignUp(T val, T alignment)
{
return alignment * ((val + alignment - 1) / alignment);
}
-void* alignedAlloc(size_t size, size_t alignment)
+void *alignedAlloc(size_t size, size_t alignment)
{
ASSERT(alignment < 256);
auto allocation = new uint8_t[size + sizeof(uint8_t) + alignment];
auto aligned = allocation;
- aligned += sizeof(uint8_t); // Make space for the base-address offset.
- aligned = reinterpret_cast<uint8_t*>(alignUp(reinterpret_cast<uintptr_t>(aligned), alignment)); // align
+ aligned += sizeof(uint8_t); // Make space for the base-address offset.
+ aligned = reinterpret_cast<uint8_t *>(alignUp(reinterpret_cast<uintptr_t>(aligned), alignment)); // align
auto offset = static_cast<uint8_t>(aligned - allocation);
aligned[-1] = offset;
return aligned;
}
-void alignedFree(void* ptr)
+void alignedFree(void *ptr)
{
- auto aligned = reinterpret_cast<uint8_t*>(ptr);
+ auto aligned = reinterpret_cast<uint8_t *>(ptr);
auto offset = aligned[-1];
auto allocation = aligned - offset;
delete[] allocation;
@@ -612,7 +619,7 @@
llvm::VectorType *ty = llvm::cast<llvm::VectorType>(x->getType());
llvm::VectorType *extTy =
- llvm::VectorType::getExtendedElementVectorType(ty);
+ llvm::VectorType::getExtendedElementVectorType(ty);
x = jit->builder->CreateZExt(x, extTy);
y = jit->builder->CreateZExt(y, extTy);
@@ -670,7 +677,7 @@
llvm::Value *lowerRound(llvm::Value *x)
{
llvm::Function *nearbyint = llvm::Intrinsic::getDeclaration(
- jit->module.get(), llvm::Intrinsic::nearbyint, {x->getType()});
+ jit->module.get(), llvm::Intrinsic::nearbyint, { x->getType() });
return jit->builder->CreateCall(nearbyint, ARGS(x));
}
@@ -682,14 +689,14 @@
llvm::Value *lowerFloor(llvm::Value *x)
{
llvm::Function *floor = llvm::Intrinsic::getDeclaration(
- jit->module.get(), llvm::Intrinsic::floor, {x->getType()});
+ jit->module.get(), llvm::Intrinsic::floor, { x->getType() });
return jit->builder->CreateCall(floor, ARGS(x));
}
llvm::Value *lowerTrunc(llvm::Value *x)
{
llvm::Function *trunc = llvm::Intrinsic::getDeclaration(
- jit->module.get(), llvm::Intrinsic::trunc, {x->getType()});
+ jit->module.get(), llvm::Intrinsic::trunc, { x->getType() });
return jit->builder->CreateCall(trunc, ARGS(x));
}
@@ -731,7 +738,7 @@
llvm::Value *lowerSQRT(llvm::Value *x)
{
llvm::Function *sqrt = llvm::Intrinsic::getDeclaration(
- jit->module.get(), llvm::Intrinsic::sqrt, {x->getType()});
+ jit->module.get(), llvm::Intrinsic::sqrt, { x->getType() });
return jit->builder->CreateCall(sqrt, ARGS(x));
}
@@ -742,8 +749,8 @@
if(llvm::VectorType *vectorTy = llvm::dyn_cast<llvm::VectorType>(ty))
{
one = llvm::ConstantVector::getSplat(
- vectorTy->getNumElements(),
- llvm::ConstantFP::get(vectorTy->getElementType(), 1));
+ vectorTy->getNumElements(),
+ llvm::ConstantFP::get(vectorTy->getElementType(), 1));
}
else
{
@@ -761,8 +768,8 @@
{
llvm::VectorType *ty = llvm::cast<llvm::VectorType>(x->getType());
llvm::Value *y = llvm::ConstantVector::getSplat(
- ty->getNumElements(),
- llvm::ConstantInt::get(ty->getElementType(), scalarY));
+ ty->getNumElements(),
+ llvm::ConstantInt::get(ty->getElementType(), scalarY));
return jit->builder->CreateShl(x, y);
}
@@ -770,8 +777,8 @@
{
llvm::VectorType *ty = llvm::cast<llvm::VectorType>(x->getType());
llvm::Value *y = llvm::ConstantVector::getSplat(
- ty->getNumElements(),
- llvm::ConstantInt::get(ty->getElementType(), scalarY));
+ ty->getNumElements(),
+ llvm::ConstantInt::get(ty->getElementType(), scalarY));
return jit->builder->CreateAShr(x, y);
}
@@ -779,8 +786,8 @@
{
llvm::VectorType *ty = llvm::cast<llvm::VectorType>(x->getType());
llvm::Value *y = llvm::ConstantVector::getSplat(
- ty->getNumElements(),
- llvm::ConstantInt::get(ty->getElementType(), scalarY));
+ ty->getNumElements(),
+ llvm::ConstantInt::get(ty->getElementType(), scalarY));
return jit->builder->CreateLShr(x, y);
}
@@ -814,7 +821,7 @@
llvm::VectorType *dstTy = llvm::VectorType::getTruncatedElementVectorType(srcTy);
llvm::IntegerType *dstElemTy =
- llvm::cast<llvm::IntegerType>(dstTy->getElementType());
+ llvm::cast<llvm::IntegerType>(dstTy->getElementType());
uint64_t truncNumBits = dstElemTy->getIntegerBitWidth();
ASSERT_MSG(truncNumBits < 64, "shift 64 must be handled separately. truncNumBits: %d", int(truncNumBits));
@@ -851,11 +858,11 @@
llvm::Value *cmp = jit->builder->CreateICmpSLT(x, zero);
llvm::Value *ret = jit->builder->CreateZExt(
- jit->builder->CreateExtractElement(cmp, static_cast<uint64_t>(0)), retTy);
+ jit->builder->CreateExtractElement(cmp, static_cast<uint64_t>(0)), retTy);
for(uint64_t i = 1, n = ty->getNumElements(); i < n; ++i)
{
llvm::Value *elem = jit->builder->CreateZExt(
- jit->builder->CreateExtractElement(cmp, i), retTy);
+ jit->builder->CreateExtractElement(cmp, i), retTy);
ret = jit->builder->CreateOr(ret, jit->builder->CreateShl(elem, i));
}
return ret;
@@ -868,11 +875,11 @@
llvm::Value *cmp = jit->builder->CreateFCmpULT(x, zero);
llvm::Value *ret = jit->builder->CreateZExt(
- jit->builder->CreateExtractElement(cmp, static_cast<uint64_t>(0)), retTy);
+ jit->builder->CreateExtractElement(cmp, static_cast<uint64_t>(0)), retTy);
for(uint64_t i = 1, n = ty->getNumElements(); i < n; ++i)
{
llvm::Value *elem = jit->builder->CreateZExt(
- jit->builder->CreateExtractElement(cmp, i), retTy);
+ jit->builder->CreateExtractElement(cmp, i), retTy);
ret = jit->builder->CreateOr(ret, jit->builder->CreateShl(elem, i));
}
return ret;
@@ -882,38 +889,38 @@
#if(LLVM_VERSION_MAJOR >= 8) || (!defined(__i386__) && !defined(__x86_64__))
llvm::Value *lowerPUADDSAT(llvm::Value *x, llvm::Value *y)
{
- #if LLVM_VERSION_MAJOR >= 8
- return jit->builder->CreateBinaryIntrinsic(llvm::Intrinsic::uadd_sat, x, y);
- #else
- return lowerPSAT(x, y, true, false);
- #endif
+# if LLVM_VERSION_MAJOR >= 8
+ return jit->builder->CreateBinaryIntrinsic(llvm::Intrinsic::uadd_sat, x, y);
+# else
+ return lowerPSAT(x, y, true, false);
+# endif
}
llvm::Value *lowerPSADDSAT(llvm::Value *x, llvm::Value *y)
{
- #if LLVM_VERSION_MAJOR >= 8
- return jit->builder->CreateBinaryIntrinsic(llvm::Intrinsic::sadd_sat, x, y);
- #else
- return lowerPSAT(x, y, true, true);
- #endif
+# if LLVM_VERSION_MAJOR >= 8
+ return jit->builder->CreateBinaryIntrinsic(llvm::Intrinsic::sadd_sat, x, y);
+# else
+ return lowerPSAT(x, y, true, true);
+# endif
}
llvm::Value *lowerPUSUBSAT(llvm::Value *x, llvm::Value *y)
{
- #if LLVM_VERSION_MAJOR >= 8
- return jit->builder->CreateBinaryIntrinsic(llvm::Intrinsic::usub_sat, x, y);
- #else
- return lowerPSAT(x, y, false, false);
- #endif
+# if LLVM_VERSION_MAJOR >= 8
+ return jit->builder->CreateBinaryIntrinsic(llvm::Intrinsic::usub_sat, x, y);
+# else
+ return lowerPSAT(x, y, false, false);
+# endif
}
llvm::Value *lowerPSSUBSAT(llvm::Value *x, llvm::Value *y)
{
- #if LLVM_VERSION_MAJOR >= 8
- return jit->builder->CreateBinaryIntrinsic(llvm::Intrinsic::ssub_sat, x, y);
- #else
- return lowerPSAT(x, y, false, true);
- #endif
+# if LLVM_VERSION_MAJOR >= 8
+ return jit->builder->CreateBinaryIntrinsic(llvm::Intrinsic::ssub_sat, x, y);
+# else
+ return lowerPSAT(x, y, false, true);
+# endif
}
#endif // (LLVM_VERSION_MAJOR >= 8) || (!defined(__i386__) && !defined(__x86_64__))
@@ -958,10 +965,10 @@
auto i8Base = jit->builder->CreatePointerCast(base, i8PtrTy);
auto i8Ptrs = jit->builder->CreateGEP(i8Base, offsets);
auto elPtrs = jit->builder->CreatePointerCast(i8Ptrs, elPtrVecTy);
- auto i8Mask = jit->builder->CreateIntCast(mask, ::llvm::VectorType::get(i1Ty, numEls), false); // vec<int, int, ...> -> vec<bool, bool, ...>
+ auto i8Mask = jit->builder->CreateIntCast(mask, ::llvm::VectorType::get(i1Ty, numEls), false); // vec<int, int, ...> -> vec<bool, bool, ...>
auto passthrough = zeroMaskedLanes ? ::llvm::Constant::getNullValue(elVecTy) : llvm::UndefValue::get(elVecTy);
auto align = ::llvm::ConstantInt::get(i32Ty, alignment);
- auto func = ::llvm::Intrinsic::getDeclaration(jit->module.get(), llvm::Intrinsic::masked_gather, { elVecTy, elPtrVecTy } );
+ auto func = ::llvm::Intrinsic::getDeclaration(jit->module.get(), llvm::Intrinsic::masked_gather, { elVecTy, elPtrVecTy });
return jit->builder->CreateCall(func, { elPtrs, align, i8Mask, passthrough });
}
@@ -984,32 +991,31 @@
auto i8Base = jit->builder->CreatePointerCast(base, i8PtrTy);
auto i8Ptrs = jit->builder->CreateGEP(i8Base, offsets);
auto elPtrs = jit->builder->CreatePointerCast(i8Ptrs, elPtrVecTy);
- auto i8Mask = jit->builder->CreateIntCast(mask, ::llvm::VectorType::get(i1Ty, numEls), false); // vec<int, int, ...> -> vec<bool, bool, ...>
+ auto i8Mask = jit->builder->CreateIntCast(mask, ::llvm::VectorType::get(i1Ty, numEls), false); // vec<int, int, ...> -> vec<bool, bool, ...>
auto align = ::llvm::ConstantInt::get(i32Ty, alignment);
- auto func = ::llvm::Intrinsic::getDeclaration(jit->module.get(), llvm::Intrinsic::masked_scatter, { elVecTy, elPtrVecTy } );
+ auto func = ::llvm::Intrinsic::getDeclaration(jit->module.get(), llvm::Intrinsic::masked_scatter, { elVecTy, elPtrVecTy });
jit->builder->CreateCall(func, { val, elPtrs, align, i8Mask });
}
-}
+} // namespace
namespace rr {
-const Capabilities Caps =
-{
- true, // CoroutinesSupported
+const Capabilities Caps = {
+ true, // CoroutinesSupported
};
static std::memory_order atomicOrdering(llvm::AtomicOrdering memoryOrder)
{
switch(memoryOrder)
{
- case llvm::AtomicOrdering::Monotonic: return std::memory_order_relaxed; // https://llvm.org/docs/Atomics.html#monotonic
- case llvm::AtomicOrdering::Acquire: return std::memory_order_acquire;
- case llvm::AtomicOrdering::Release: return std::memory_order_release;
- case llvm::AtomicOrdering::AcquireRelease: return std::memory_order_acq_rel;
- case llvm::AtomicOrdering::SequentiallyConsistent: return std::memory_order_seq_cst;
- default:
- UNREACHABLE("memoryOrder: %d", int(memoryOrder));
- return std::memory_order_acq_rel;
+ case llvm::AtomicOrdering::Monotonic: return std::memory_order_relaxed; // https://llvm.org/docs/Atomics.html#monotonic
+ case llvm::AtomicOrdering::Acquire: return std::memory_order_acquire;
+ case llvm::AtomicOrdering::Release: return std::memory_order_release;
+ case llvm::AtomicOrdering::AcquireRelease: return std::memory_order_acq_rel;
+ case llvm::AtomicOrdering::SequentiallyConsistent: return std::memory_order_seq_cst;
+ default:
+ UNREACHABLE("memoryOrder: %d", int(memoryOrder));
+ return std::memory_order_acq_rel;
}
}
@@ -1022,28 +1028,28 @@
switch(memoryOrder)
{
- case std::memory_order_relaxed: return llvm::AtomicOrdering::Monotonic; // https://llvm.org/docs/Atomics.html#monotonic
- case std::memory_order_consume: return llvm::AtomicOrdering::Acquire; // https://llvm.org/docs/Atomics.html#acquire: "It should also be used for C++11/C11 memory_order_consume."
- case std::memory_order_acquire: return llvm::AtomicOrdering::Acquire;
- case std::memory_order_release: return llvm::AtomicOrdering::Release;
- case std::memory_order_acq_rel: return llvm::AtomicOrdering::AcquireRelease;
- case std::memory_order_seq_cst: return llvm::AtomicOrdering::SequentiallyConsistent;
- default:
- UNREACHABLE("memoryOrder: %d", int(memoryOrder));
- return llvm::AtomicOrdering::AcquireRelease;
+ case std::memory_order_relaxed: return llvm::AtomicOrdering::Monotonic; // https://llvm.org/docs/Atomics.html#monotonic
+ case std::memory_order_consume: return llvm::AtomicOrdering::Acquire; // https://llvm.org/docs/Atomics.html#acquire: "It should also be used for C++11/C11 memory_order_consume."
+ case std::memory_order_acquire: return llvm::AtomicOrdering::Acquire;
+ case std::memory_order_release: return llvm::AtomicOrdering::Release;
+ case std::memory_order_acq_rel: return llvm::AtomicOrdering::AcquireRelease;
+ case std::memory_order_seq_cst: return llvm::AtomicOrdering::SequentiallyConsistent;
+ default:
+ UNREACHABLE("memoryOrder: %d", int(memoryOrder));
+ return llvm::AtomicOrdering::AcquireRelease;
}
}
-template <typename T>
+template<typename T>
static void atomicLoad(void *ptr, void *ret, llvm::AtomicOrdering ordering)
{
- *reinterpret_cast<T*>(ret) = std::atomic_load_explicit<T>(reinterpret_cast<std::atomic<T>*>(ptr), atomicOrdering(ordering));
+ *reinterpret_cast<T *>(ret) = std::atomic_load_explicit<T>(reinterpret_cast<std::atomic<T> *>(ptr), atomicOrdering(ordering));
}
-template <typename T>
+template<typename T>
static void atomicStore(void *ptr, void *val, llvm::AtomicOrdering ordering)
{
- std::atomic_store_explicit<T>(reinterpret_cast<std::atomic<T>*>(ptr), *reinterpret_cast<T*>(val), atomicOrdering(ordering));
+ std::atomic_store_explicit<T>(reinterpret_cast<std::atomic<T> *>(ptr), *reinterpret_cast<T *>(val), atomicOrdering(ordering));
}
#ifdef __ANDROID__
@@ -1062,7 +1068,7 @@
}
#endif
-void* resolveExternalSymbol(const char* name)
+void *resolveExternalSymbol(const char *name)
{
struct Atomic
{
@@ -1097,8 +1103,8 @@
static void nop() {}
static void neverCalled() { UNREACHABLE("Should never be called"); }
- static void* coroutine_alloc_frame(size_t size) { return alignedAlloc(size, 16); }
- static void coroutine_free_frame(void* ptr) { alignedFree(ptr); }
+ static void *coroutine_alloc_frame(size_t size) { return alignedAlloc(size, 16); }
+ static void coroutine_free_frame(void *ptr) { alignedFree(ptr); }
#ifdef __ANDROID__
// forwarders since we can't take address of builtins
@@ -1111,10 +1117,22 @@
static uint32_t sync_lock_test_and_set_4(uint32_t *ptr, uint32_t val) { return __sync_lock_test_and_set_4(ptr, val); }
static uint32_t sync_val_compare_and_swap_4(uint32_t *ptr, uint32_t expected, uint32_t desired) { return __sync_val_compare_and_swap_4(ptr, expected, desired); }
- static uint32_t sync_fetch_and_max_4(uint32_t *ptr, uint32_t val) { return sync_fetch_and_op(ptr, val, [](int32_t a, int32_t b) { return std::max(a,b);}); }
- static uint32_t sync_fetch_and_min_4(uint32_t *ptr, uint32_t val) { return sync_fetch_and_op(ptr, val, [](int32_t a, int32_t b) { return std::min(a,b);}); }
- static uint32_t sync_fetch_and_umax_4(uint32_t *ptr, uint32_t val) { return sync_fetch_and_op(ptr, val, [](uint32_t a, uint32_t b) { return std::max(a,b);}); }
- static uint32_t sync_fetch_and_umin_4(uint32_t *ptr, uint32_t val) { return sync_fetch_and_op(ptr, val, [](uint32_t a, uint32_t b) { return std::min(a,b);}); }
+ static uint32_t sync_fetch_and_max_4(uint32_t *ptr, uint32_t val)
+ {
+ return sync_fetch_and_op(ptr, val, [](int32_t a, int32_t b) { return std::max(a, b); });
+ }
+ static uint32_t sync_fetch_and_min_4(uint32_t *ptr, uint32_t val)
+ {
+ return sync_fetch_and_op(ptr, val, [](int32_t a, int32_t b) { return std::min(a, b); });
+ }
+ static uint32_t sync_fetch_and_umax_4(uint32_t *ptr, uint32_t val)
+ {
+ return sync_fetch_and_op(ptr, val, [](uint32_t a, uint32_t b) { return std::max(a, b); });
+ }
+ static uint32_t sync_fetch_and_umin_4(uint32_t *ptr, uint32_t val)
+ {
+ return sync_fetch_and_op(ptr, val, [](uint32_t a, uint32_t b) { return std::min(a, b); });
+ }
#endif
};
@@ -1127,81 +1145,81 @@
Resolver()
{
- functions.emplace("nop", reinterpret_cast<void*>(F::nop));
- functions.emplace("floorf", reinterpret_cast<void*>(floorf));
- functions.emplace("nearbyintf", reinterpret_cast<void*>(nearbyintf));
- functions.emplace("truncf", reinterpret_cast<void*>(truncf));
- functions.emplace("printf", reinterpret_cast<void*>(printf));
- functions.emplace("puts", reinterpret_cast<void*>(puts));
- functions.emplace("fmodf", reinterpret_cast<void*>(fmodf));
+ functions.emplace("nop", reinterpret_cast<void *>(F::nop));
+ functions.emplace("floorf", reinterpret_cast<void *>(floorf));
+ functions.emplace("nearbyintf", reinterpret_cast<void *>(nearbyintf));
+ functions.emplace("truncf", reinterpret_cast<void *>(truncf));
+ functions.emplace("printf", reinterpret_cast<void *>(printf));
+ functions.emplace("puts", reinterpret_cast<void *>(puts));
+ functions.emplace("fmodf", reinterpret_cast<void *>(fmodf));
- functions.emplace("sinf", reinterpret_cast<void*>(sinf));
- functions.emplace("cosf", reinterpret_cast<void*>(cosf));
- functions.emplace("asinf", reinterpret_cast<void*>(asinf));
- functions.emplace("acosf", reinterpret_cast<void*>(acosf));
- functions.emplace("atanf", reinterpret_cast<void*>(atanf));
- functions.emplace("sinhf", reinterpret_cast<void*>(sinhf));
- functions.emplace("coshf", reinterpret_cast<void*>(coshf));
- functions.emplace("tanhf", reinterpret_cast<void*>(tanhf));
- functions.emplace("asinhf", reinterpret_cast<void*>(asinhf));
- functions.emplace("acoshf", reinterpret_cast<void*>(acoshf));
- functions.emplace("atanhf", reinterpret_cast<void*>(atanhf));
- functions.emplace("atan2f", reinterpret_cast<void*>(atan2f));
- functions.emplace("powf", reinterpret_cast<void*>(powf));
- functions.emplace("expf", reinterpret_cast<void*>(expf));
- functions.emplace("logf", reinterpret_cast<void*>(logf));
- functions.emplace("exp2f", reinterpret_cast<void*>(exp2f));
- functions.emplace("log2f", reinterpret_cast<void*>(log2f));
+ functions.emplace("sinf", reinterpret_cast<void *>(sinf));
+ functions.emplace("cosf", reinterpret_cast<void *>(cosf));
+ functions.emplace("asinf", reinterpret_cast<void *>(asinf));
+ functions.emplace("acosf", reinterpret_cast<void *>(acosf));
+ functions.emplace("atanf", reinterpret_cast<void *>(atanf));
+ functions.emplace("sinhf", reinterpret_cast<void *>(sinhf));
+ functions.emplace("coshf", reinterpret_cast<void *>(coshf));
+ functions.emplace("tanhf", reinterpret_cast<void *>(tanhf));
+ functions.emplace("asinhf", reinterpret_cast<void *>(asinhf));
+ functions.emplace("acoshf", reinterpret_cast<void *>(acoshf));
+ functions.emplace("atanhf", reinterpret_cast<void *>(atanhf));
+ functions.emplace("atan2f", reinterpret_cast<void *>(atan2f));
+ functions.emplace("powf", reinterpret_cast<void *>(powf));
+ functions.emplace("expf", reinterpret_cast<void *>(expf));
+ functions.emplace("logf", reinterpret_cast<void *>(logf));
+ functions.emplace("exp2f", reinterpret_cast<void *>(exp2f));
+ functions.emplace("log2f", reinterpret_cast<void *>(log2f));
- functions.emplace("sin", reinterpret_cast<void*>(static_cast<double(*)(double)>(sin)));
- functions.emplace("cos", reinterpret_cast<void*>(static_cast<double(*)(double)>(cos)));
- functions.emplace("asin", reinterpret_cast<void*>(static_cast<double(*)(double)>(asin)));
- functions.emplace("acos", reinterpret_cast<void*>(static_cast<double(*)(double)>(acos)));
- functions.emplace("atan", reinterpret_cast<void*>(static_cast<double(*)(double)>(atan)));
- functions.emplace("sinh", reinterpret_cast<void*>(static_cast<double(*)(double)>(sinh)));
- functions.emplace("cosh", reinterpret_cast<void*>(static_cast<double(*)(double)>(cosh)));
- functions.emplace("tanh", reinterpret_cast<void*>(static_cast<double(*)(double)>(tanh)));
- functions.emplace("asinh", reinterpret_cast<void*>(static_cast<double(*)(double)>(asinh)));
- functions.emplace("acosh", reinterpret_cast<void*>(static_cast<double(*)(double)>(acosh)));
- functions.emplace("atanh", reinterpret_cast<void*>(static_cast<double(*)(double)>(atanh)));
- functions.emplace("atan2", reinterpret_cast<void*>(static_cast<double(*)(double,double)>(atan2)));
- functions.emplace("pow", reinterpret_cast<void*>(static_cast<double(*)(double,double)>(pow)));
- functions.emplace("exp", reinterpret_cast<void*>(static_cast<double(*)(double)>(exp)));
- functions.emplace("log", reinterpret_cast<void*>(static_cast<double(*)(double)>(log)));
- functions.emplace("exp2", reinterpret_cast<void*>(static_cast<double(*)(double)>(exp2)));
- functions.emplace("log2", reinterpret_cast<void*>(static_cast<double(*)(double)>(log2)));
+ functions.emplace("sin", reinterpret_cast<void *>(static_cast<double (*)(double)>(sin)));
+ functions.emplace("cos", reinterpret_cast<void *>(static_cast<double (*)(double)>(cos)));
+ functions.emplace("asin", reinterpret_cast<void *>(static_cast<double (*)(double)>(asin)));
+ functions.emplace("acos", reinterpret_cast<void *>(static_cast<double (*)(double)>(acos)));
+ functions.emplace("atan", reinterpret_cast<void *>(static_cast<double (*)(double)>(atan)));
+ functions.emplace("sinh", reinterpret_cast<void *>(static_cast<double (*)(double)>(sinh)));
+ functions.emplace("cosh", reinterpret_cast<void *>(static_cast<double (*)(double)>(cosh)));
+ functions.emplace("tanh", reinterpret_cast<void *>(static_cast<double (*)(double)>(tanh)));
+ functions.emplace("asinh", reinterpret_cast<void *>(static_cast<double (*)(double)>(asinh)));
+ functions.emplace("acosh", reinterpret_cast<void *>(static_cast<double (*)(double)>(acosh)));
+ functions.emplace("atanh", reinterpret_cast<void *>(static_cast<double (*)(double)>(atanh)));
+ functions.emplace("atan2", reinterpret_cast<void *>(static_cast<double (*)(double, double)>(atan2)));
+ functions.emplace("pow", reinterpret_cast<void *>(static_cast<double (*)(double, double)>(pow)));
+ functions.emplace("exp", reinterpret_cast<void *>(static_cast<double (*)(double)>(exp)));
+ functions.emplace("log", reinterpret_cast<void *>(static_cast<double (*)(double)>(log)));
+ functions.emplace("exp2", reinterpret_cast<void *>(static_cast<double (*)(double)>(exp2)));
+ functions.emplace("log2", reinterpret_cast<void *>(static_cast<double (*)(double)>(log2)));
- functions.emplace("atomic_load", reinterpret_cast<void*>(Atomic::load));
- functions.emplace("atomic_store", reinterpret_cast<void*>(Atomic::store));
+ functions.emplace("atomic_load", reinterpret_cast<void *>(Atomic::load));
+ functions.emplace("atomic_store", reinterpret_cast<void *>(Atomic::store));
// FIXME (b/119409619): use an allocator here so we can control all memory allocations
- functions.emplace("coroutine_alloc_frame", reinterpret_cast<void*>(F::coroutine_alloc_frame));
- functions.emplace("coroutine_free_frame", reinterpret_cast<void*>(F::coroutine_free_frame));
+ functions.emplace("coroutine_alloc_frame", reinterpret_cast<void *>(F::coroutine_alloc_frame));
+ functions.emplace("coroutine_free_frame", reinterpret_cast<void *>(F::coroutine_free_frame));
#ifdef __APPLE__
- functions.emplace("sincosf_stret", reinterpret_cast<void*>(__sincosf_stret));
+ functions.emplace("sincosf_stret", reinterpret_cast<void *>(__sincosf_stret));
#elif defined(__linux__)
- functions.emplace("sincosf", reinterpret_cast<void*>(sincosf));
+ functions.emplace("sincosf", reinterpret_cast<void *>(sincosf));
#elif defined(_WIN64)
- functions.emplace("chkstk", reinterpret_cast<void*>(__chkstk));
+ functions.emplace("chkstk", reinterpret_cast<void *>(__chkstk));
#elif defined(_WIN32)
- functions.emplace("chkstk", reinterpret_cast<void*>(_chkstk));
+ functions.emplace("chkstk", reinterpret_cast<void *>(_chkstk));
#endif
#ifdef __ANDROID__
- functions.emplace("aeabi_unwind_cpp_pr0", reinterpret_cast<void*>(F::neverCalled));
- functions.emplace("sync_synchronize", reinterpret_cast<void*>(F::sync_synchronize));
- functions.emplace("sync_fetch_and_add_4", reinterpret_cast<void*>(F::sync_fetch_and_add_4));
- functions.emplace("sync_fetch_and_and_4", reinterpret_cast<void*>(F::sync_fetch_and_and_4));
- functions.emplace("sync_fetch_and_or_4", reinterpret_cast<void*>(F::sync_fetch_and_or_4));
- functions.emplace("sync_fetch_and_xor_4", reinterpret_cast<void*>(F::sync_fetch_and_xor_4));
- functions.emplace("sync_fetch_and_sub_4", reinterpret_cast<void*>(F::sync_fetch_and_sub_4));
- functions.emplace("sync_lock_test_and_set_4", reinterpret_cast<void*>(F::sync_lock_test_and_set_4));
- functions.emplace("sync_val_compare_and_swap_4", reinterpret_cast<void*>(F::sync_val_compare_and_swap_4));
- functions.emplace("sync_fetch_and_max_4", reinterpret_cast<void*>(F::sync_fetch_and_max_4));
- functions.emplace("sync_fetch_and_min_4", reinterpret_cast<void*>(F::sync_fetch_and_min_4));
- functions.emplace("sync_fetch_and_umax_4", reinterpret_cast<void*>(F::sync_fetch_and_umax_4));
- functions.emplace("sync_fetch_and_umin_4", reinterpret_cast<void*>(F::sync_fetch_and_umin_4));
+ functions.emplace("aeabi_unwind_cpp_pr0", reinterpret_cast<void *>(F::neverCalled));
+ functions.emplace("sync_synchronize", reinterpret_cast<void *>(F::sync_synchronize));
+ functions.emplace("sync_fetch_and_add_4", reinterpret_cast<void *>(F::sync_fetch_and_add_4));
+ functions.emplace("sync_fetch_and_and_4", reinterpret_cast<void *>(F::sync_fetch_and_and_4));
+ functions.emplace("sync_fetch_and_or_4", reinterpret_cast<void *>(F::sync_fetch_and_or_4));
+ functions.emplace("sync_fetch_and_xor_4", reinterpret_cast<void *>(F::sync_fetch_and_xor_4));
+ functions.emplace("sync_fetch_and_sub_4", reinterpret_cast<void *>(F::sync_fetch_and_sub_4));
+ functions.emplace("sync_lock_test_and_set_4", reinterpret_cast<void *>(F::sync_lock_test_and_set_4));
+ functions.emplace("sync_val_compare_and_swap_4", reinterpret_cast<void *>(F::sync_val_compare_and_swap_4));
+ functions.emplace("sync_fetch_and_max_4", reinterpret_cast<void *>(F::sync_fetch_and_max_4));
+ functions.emplace("sync_fetch_and_min_4", reinterpret_cast<void *>(F::sync_fetch_and_min_4));
+ functions.emplace("sync_fetch_and_umax_4", reinterpret_cast<void *>(F::sync_fetch_and_umax_4));
+ functions.emplace("sync_fetch_and_umin_4", reinterpret_cast<void *>(F::sync_fetch_and_umin_4));
#endif
}
};
@@ -1210,7 +1228,7 @@
// Trim off any underscores from the start of the symbol. LLVM likes
// to append these on macOS.
- const char* trimmed = name;
+ const char *trimmed = name;
while(trimmed[0] == '_') { trimmed++; }
auto it = resolver.functions.find(trimmed);
@@ -1250,56 +1268,56 @@
// Use 128-bit vectors to implement logically shorter ones.
switch(asInternalType(t))
{
- case Type_v2i32: return T(Int4::getType());
- case Type_v4i16: return T(Short8::getType());
- case Type_v2i16: return T(Short8::getType());
- case Type_v8i8: return T(Byte16::getType());
- case Type_v4i8: return T(Byte16::getType());
- case Type_v2f32: return T(Float4::getType());
- case Type_LLVM: return reinterpret_cast<llvm::Type*>(t);
- default:
- UNREACHABLE("asInternalType(t): %d", int(asInternalType(t)));
- return nullptr;
+ case Type_v2i32: return T(Int4::getType());
+ case Type_v4i16: return T(Short8::getType());
+ case Type_v2i16: return T(Short8::getType());
+ case Type_v8i8: return T(Byte16::getType());
+ case Type_v4i8: return T(Byte16::getType());
+ case Type_v2f32: return T(Float4::getType());
+ case Type_LLVM: return reinterpret_cast<llvm::Type *>(t);
+ default:
+ UNREACHABLE("asInternalType(t): %d", int(asInternalType(t)));
+ return nullptr;
}
}
Type *T(InternalType t)
{
- return reinterpret_cast<Type*>(t);
+ return reinterpret_cast<Type *>(t);
}
-inline std::vector<llvm::Type*> &T(std::vector<Type*> &t)
+inline std::vector<llvm::Type *> &T(std::vector<Type *> &t)
{
- return reinterpret_cast<std::vector<llvm::Type*>&>(t);
+ return reinterpret_cast<std::vector<llvm::Type *> &>(t);
}
inline llvm::BasicBlock *B(BasicBlock *t)
{
- return reinterpret_cast<llvm::BasicBlock*>(t);
+ return reinterpret_cast<llvm::BasicBlock *>(t);
}
inline BasicBlock *B(llvm::BasicBlock *t)
{
- return reinterpret_cast<BasicBlock*>(t);
+ return reinterpret_cast<BasicBlock *>(t);
}
static size_t typeSize(Type *type)
{
switch(asInternalType(type))
{
- case Type_v2i32: return 8;
- case Type_v4i16: return 8;
- case Type_v2i16: return 4;
- case Type_v8i8: return 8;
- case Type_v4i8: return 4;
- case Type_v2f32: return 8;
- case Type_LLVM:
+ case Type_v2i32: return 8;
+ case Type_v4i16: return 8;
+ case Type_v2i16: return 4;
+ case Type_v8i8: return 8;
+ case Type_v4i8: return 4;
+ case Type_v2f32: return 8;
+ case Type_LLVM:
{
llvm::Type *t = T(type);
if(t->isPointerTy())
{
- return sizeof(void*);
+ return sizeof(void *);
}
// At this point we should only have LLVM 'primitive' types.
@@ -1312,9 +1330,9 @@
return (bits + 7) / 8;
}
break;
- default:
- UNREACHABLE("asInternalType(type): %d", int(asInternalType(type)));
- return 0;
+ default:
+ UNREACHABLE("asInternalType(type): %d", int(asInternalType(type)));
+ return 0;
}
}
@@ -1322,20 +1340,20 @@
{
switch(asInternalType(type))
{
- case Type_v2i32: return 2;
- case Type_v4i16: return 4;
- case Type_v2i16: return 2;
- case Type_v8i8: return 8;
- case Type_v4i8: return 4;
- case Type_v2f32: return 2;
- case Type_LLVM: return llvm::cast<llvm::VectorType>(T(type))->getNumElements();
- default:
- UNREACHABLE("asInternalType(type): %d", int(asInternalType(type)));
- return 0;
+ case Type_v2i32: return 2;
+ case Type_v4i16: return 4;
+ case Type_v2i16: return 2;
+ case Type_v8i8: return 8;
+ case Type_v4i8: return 4;
+ case Type_v2f32: return 2;
+ case Type_LLVM: return llvm::cast<llvm::VectorType>(T(type))->getNumElements();
+ default:
+ UNREACHABLE("asInternalType(type): %d", int(asInternalType(type)));
+ return 0;
}
}
-static ::llvm::Function* createFunction(const char *name, ::llvm::Type *retTy, const std::vector<::llvm::Type*> ¶ms)
+static ::llvm::Function *createFunction(const char *name, ::llvm::Type *retTy, const std::vector<::llvm::Type *> ¶ms)
{
llvm::FunctionType *functionType = llvm::FunctionType::get(retTy, params, false);
auto func = llvm::Function::Create(functionType, llvm::GlobalValue::InternalLinkage, name, jit->module.get());
@@ -1346,7 +1364,7 @@
Nucleus::Nucleus()
{
- ::codegenMutex.lock(); // Reactor and LLVM are currently not thread safe
+ ::codegenMutex.lock(); // Reactor and LLVM are currently not thread safe
ASSERT(jit == nullptr);
jit.reset(new JITBuilder(Nucleus::getDefaultConfig()));
@@ -1400,7 +1418,7 @@
{
jit->debugInfo->Finalize();
}
-#endif // ENABLE_RR_DEBUG_INFO
+#endif // ENABLE_RR_DEBUG_INFO
if(false)
{
@@ -1415,7 +1433,7 @@
pm.add(llvm::createVerifierPass());
pm.run(*jit->module);
}
-#endif // defined(ENABLE_RR_LLVM_IR_VERIFICATION) || !defined(NDEBUG)
+#endif // defined(ENABLE_RR_LLVM_IR_VERIFICATION) || !defined(NDEBUG)
jit->optimize(cfg);
@@ -1445,7 +1463,7 @@
}
else
{
- declaration = new llvm::AllocaInst(T(type), 0, (llvm::Value*)nullptr);
+ declaration = new llvm::AllocaInst(T(type), 0, (llvm::Value *)nullptr);
}
entryBlock.getInstList().push_front(declaration);
@@ -1465,20 +1483,20 @@
void Nucleus::setInsertBlock(BasicBlock *basicBlock)
{
-// assert(jit->builder->GetInsertBlock()->back().isTerminator());
+ // assert(jit->builder->GetInsertBlock()->back().isTerminator());
Variable::materializeAll();
jit->builder->SetInsertPoint(B(basicBlock));
}
-void Nucleus::createFunction(Type *ReturnType, std::vector<Type*> &Params)
+void Nucleus::createFunction(Type *ReturnType, std::vector<Type *> &Params)
{
jit->function = rr::createFunction("", T(ReturnType), T(Params));
#ifdef ENABLE_RR_DEBUG_INFO
jit->debugInfo = std::unique_ptr<DebugInfo>(new DebugInfo(jit->builder.get(), &jit->context, jit->module.get(), jit->function));
-#endif // ENABLE_RR_DEBUG_INFO
+#endif // ENABLE_RR_DEBUG_INFO
jit->builder->SetInsertPoint(llvm::BasicBlock::Create(jit->context, "", jit->function));
}
@@ -1670,28 +1688,28 @@
RR_DEBUG_INFO_UPDATE_LOC();
switch(asInternalType(type))
{
- case Type_v2i32:
- case Type_v4i16:
- case Type_v8i8:
- case Type_v2f32:
- return createBitCast(
- createInsertElement(
- V(llvm::UndefValue::get(llvm::VectorType::get(T(Long::getType()), 2))),
- createLoad(createBitCast(ptr, Pointer<Long>::getType()), Long::getType(), isVolatile, alignment, atomic, memoryOrder),
- 0),
- type);
- case Type_v2i16:
- case Type_v4i8:
- if(alignment != 0) // Not a local variable (all vectors are 128-bit).
- {
- Value *u = V(llvm::UndefValue::get(llvm::VectorType::get(T(Long::getType()), 2)));
- Value *i = createLoad(createBitCast(ptr, Pointer<Int>::getType()), Int::getType(), isVolatile, alignment, atomic, memoryOrder);
- i = createZExt(i, Long::getType());
- Value *v = createInsertElement(u, i, 0);
- return createBitCast(v, type);
- }
- // Fallthrough to non-emulated case.
- case Type_LLVM:
+ case Type_v2i32:
+ case Type_v4i16:
+ case Type_v8i8:
+ case Type_v2f32:
+ return createBitCast(
+ createInsertElement(
+ V(llvm::UndefValue::get(llvm::VectorType::get(T(Long::getType()), 2))),
+ createLoad(createBitCast(ptr, Pointer<Long>::getType()), Long::getType(), isVolatile, alignment, atomic, memoryOrder),
+ 0),
+ type);
+ case Type_v2i16:
+ case Type_v4i8:
+ if(alignment != 0) // Not a local variable (all vectors are 128-bit).
+ {
+ Value *u = V(llvm::UndefValue::get(llvm::VectorType::get(T(Long::getType()), 2)));
+ Value *i = createLoad(createBitCast(ptr, Pointer<Int>::getType()), Int::getType(), isVolatile, alignment, atomic, memoryOrder);
+ i = createZExt(i, Long::getType());
+ Value *v = createInsertElement(u, i, 0);
+ return createBitCast(v, type);
+ }
+ // Fallthrough to non-emulated case.
+ case Type_LLVM:
{
auto elTy = T(type);
ASSERT(V(ptr)->getType()->getContainedType(0) == elTy);
@@ -1730,22 +1748,22 @@
auto i8Ty = ::llvm::Type::getInt8Ty(jit->context);
auto i8PtrTy = i8Ty->getPointerTo();
auto voidTy = ::llvm::Type::getVoidTy(jit->context);
- auto funcTy = ::llvm::FunctionType::get(voidTy, {sizetTy, i8PtrTy, i8PtrTy, intTy}, false);
+ auto funcTy = ::llvm::FunctionType::get(voidTy, { sizetTy, i8PtrTy, i8PtrTy, intTy }, false);
auto func = jit->module->getOrInsertFunction("__atomic_load", funcTy);
auto size = jit->module->getDataLayout().getTypeStoreSize(elTy);
auto out = allocateStackVariable(type);
jit->builder->CreateCall(func, {
- ::llvm::ConstantInt::get(sizetTy, size),
- jit->builder->CreatePointerCast(V(ptr), i8PtrTy),
- jit->builder->CreatePointerCast(V(out), i8PtrTy),
- ::llvm::ConstantInt::get(intTy, uint64_t(atomicOrdering(true, memoryOrder))),
- });
- return V(jit->builder->CreateLoad(V(out)));
+ ::llvm::ConstantInt::get(sizetTy, size),
+ jit->builder->CreatePointerCast(V(ptr), i8PtrTy),
+ jit->builder->CreatePointerCast(V(out), i8PtrTy),
+ ::llvm::ConstantInt::get(intTy, uint64_t(atomicOrdering(true, memoryOrder))),
+ });
+ return V(jit->builder->CreateLoad(V(out)));
}
}
- default:
- UNREACHABLE("asInternalType(type): %d", int(asInternalType(type)));
- return nullptr;
+ default:
+ UNREACHABLE("asInternalType(type): %d", int(asInternalType(type)));
+ return nullptr;
}
}
@@ -1754,28 +1772,28 @@
RR_DEBUG_INFO_UPDATE_LOC();
switch(asInternalType(type))
{
- case Type_v2i32:
- case Type_v4i16:
- case Type_v8i8:
- case Type_v2f32:
- createStore(
- createExtractElement(
- createBitCast(value, T(llvm::VectorType::get(T(Long::getType()), 2))), Long::getType(), 0),
- createBitCast(ptr, Pointer<Long>::getType()),
- Long::getType(), isVolatile, alignment, atomic, memoryOrder);
- return value;
- case Type_v2i16:
- case Type_v4i8:
- if(alignment != 0) // Not a local variable (all vectors are 128-bit).
- {
+ case Type_v2i32:
+ case Type_v4i16:
+ case Type_v8i8:
+ case Type_v2f32:
createStore(
- createExtractElement(createBitCast(value, Int4::getType()), Int::getType(), 0),
- createBitCast(ptr, Pointer<Int>::getType()),
- Int::getType(), isVolatile, alignment, atomic, memoryOrder);
+ createExtractElement(
+ createBitCast(value, T(llvm::VectorType::get(T(Long::getType()), 2))), Long::getType(), 0),
+ createBitCast(ptr, Pointer<Long>::getType()),
+ Long::getType(), isVolatile, alignment, atomic, memoryOrder);
return value;
- }
- // Fallthrough to non-emulated case.
- case Type_LLVM:
+ case Type_v2i16:
+ case Type_v4i8:
+ if(alignment != 0) // Not a local variable (all vectors are 128-bit).
+ {
+ createStore(
+ createExtractElement(createBitCast(value, Int4::getType()), Int::getType(), 0),
+ createBitCast(ptr, Pointer<Int>::getType()),
+ Int::getType(), isVolatile, alignment, atomic, memoryOrder);
+ return value;
+ }
+ // Fallthrough to non-emulated case.
+ case Type_LLVM:
{
auto elTy = T(type);
ASSERT(V(ptr)->getType()->getContainedType(0) == elTy);
@@ -1812,24 +1830,24 @@
auto i8Ty = ::llvm::Type::getInt8Ty(jit->context);
auto i8PtrTy = i8Ty->getPointerTo();
auto voidTy = ::llvm::Type::getVoidTy(jit->context);
- auto funcTy = ::llvm::FunctionType::get(voidTy, {sizetTy, i8PtrTy, i8PtrTy, intTy}, false);
+ auto funcTy = ::llvm::FunctionType::get(voidTy, { sizetTy, i8PtrTy, i8PtrTy, intTy }, false);
auto func = jit->module->getOrInsertFunction("__atomic_store", funcTy);
auto size = jit->module->getDataLayout().getTypeStoreSize(elTy);
auto copy = allocateStackVariable(type);
jit->builder->CreateStore(V(value), V(copy));
jit->builder->CreateCall(func, {
- ::llvm::ConstantInt::get(sizetTy, size),
- jit->builder->CreatePointerCast(V(ptr), i8PtrTy),
- jit->builder->CreatePointerCast(V(copy), i8PtrTy),
- ::llvm::ConstantInt::get(intTy, uint64_t(atomicOrdering(true, memoryOrder))),
- });
+ ::llvm::ConstantInt::get(sizetTy, size),
+ jit->builder->CreatePointerCast(V(ptr), i8PtrTy),
+ jit->builder->CreatePointerCast(V(copy), i8PtrTy),
+ ::llvm::ConstantInt::get(intTy, uint64_t(atomicOrdering(true, memoryOrder))),
+ });
}
return value;
}
- default:
- UNREACHABLE("asInternalType(type): %d", int(asInternalType(type)));
- return nullptr;
+ default:
+ UNREACHABLE("asInternalType(type): %d", int(asInternalType(type)));
+ return nullptr;
}
}
@@ -1843,10 +1861,10 @@
auto i32Ty = ::llvm::Type::getInt32Ty(jit->context);
auto elVecTy = ::llvm::VectorType::get(T(elTy), numEls);
auto elVecPtrTy = elVecTy->getPointerTo();
- auto i8Mask = jit->builder->CreateIntCast(V(mask), ::llvm::VectorType::get(i1Ty, numEls), false); // vec<int, int, ...> -> vec<bool, bool, ...>
+ auto i8Mask = jit->builder->CreateIntCast(V(mask), ::llvm::VectorType::get(i1Ty, numEls), false); // vec<int, int, ...> -> vec<bool, bool, ...>
auto passthrough = zeroMaskedLanes ? ::llvm::Constant::getNullValue(elVecTy) : llvm::UndefValue::get(elVecTy);
auto align = ::llvm::ConstantInt::get(i32Ty, alignment);
- auto func = ::llvm::Intrinsic::getDeclaration(jit->module.get(), llvm::Intrinsic::masked_load, { elVecTy, elVecPtrTy } );
+ auto func = ::llvm::Intrinsic::getDeclaration(jit->module.get(), llvm::Intrinsic::masked_load, { elVecTy, elVecPtrTy });
return V(jit->builder->CreateCall(func, { V(ptr), align, i8Mask, passthrough }));
}
@@ -1861,9 +1879,9 @@
auto i32Ty = ::llvm::Type::getInt32Ty(jit->context);
auto elVecTy = V(val)->getType();
auto elVecPtrTy = elVecTy->getPointerTo();
- auto i8Mask = jit->builder->CreateIntCast(V(mask), ::llvm::VectorType::get(i1Ty, numEls), false); // vec<int, int, ...> -> vec<bool, bool, ...>
+ auto i8Mask = jit->builder->CreateIntCast(V(mask), ::llvm::VectorType::get(i1Ty, numEls), false); // vec<int, int, ...> -> vec<bool, bool, ...>
auto align = ::llvm::ConstantInt::get(i32Ty, alignment);
- auto func = ::llvm::Intrinsic::getDeclaration(jit->module.get(), llvm::Intrinsic::masked_store, { elVecTy, elVecPtrTy } );
+ auto func = ::llvm::Intrinsic::getDeclaration(jit->module.get(), llvm::Intrinsic::masked_store, { elVecTy, elVecPtrTy });
jit->builder->CreateCall(func, { V(val), V(ptr), align, i8Mask });
}
@@ -1896,7 +1914,7 @@
{
RR_DEBUG_INFO_UPDATE_LOC();
ASSERT(V(ptr)->getType()->getContainedType(0) == T(type));
- if(sizeof(void*) == 8)
+ if(sizeof(void *) == 8)
{
// LLVM manual: "When indexing into an array, pointer or vector,
// integers of any width are allowed, and they are not required to
@@ -1911,9 +1929,7 @@
// x86 supports automatic zero-extending of 32-bit registers to
// 64-bit. Thus when indexing into an array using a uint32 is
// actually faster than an int32.
- index = unsignedIndex ?
- createZExt(index, Long::getType()) :
- createSExt(index, Long::getType());
+ index = unsignedIndex ? createZExt(index, Long::getType()) : createSExt(index, Long::getType());
}
// For non-emulated types we can rely on LLVM's GEP to calculate the
@@ -1925,15 +1941,13 @@
// For emulated types we have to multiply the index by the intended
// type size ourselves to obain the byte offset.
- index = (sizeof(void*) == 8) ?
- createMul(index, createConstantLong((int64_t)typeSize(type))) :
- createMul(index, createConstantInt((int)typeSize(type)));
+ index = (sizeof(void *) == 8) ? createMul(index, createConstantLong((int64_t)typeSize(type))) : createMul(index, createConstantInt((int)typeSize(type)));
// Cast to a byte pointer, apply the byte offset, and cast back to the
// original pointer type.
return createBitCast(
- V(jit->builder->CreateGEP(V(createBitCast(ptr, T(llvm::PointerType::get(T(Byte::getType()), 0)))), V(index))),
- T(llvm::PointerType::get(T(type), 0)));
+ V(jit->builder->CreateGEP(V(createBitCast(ptr, T(llvm::PointerType::get(T(Byte::getType()), 0)))), V(index))),
+ T(llvm::PointerType::get(T(type), 0)));
}
Value *Nucleus::createAtomicAdd(Value *ptr, Value *value, std::memory_order memoryOrder)
@@ -1990,7 +2004,6 @@
return V(jit->builder->CreateAtomicRMW(llvm::AtomicRMWInst::UMax, V(ptr), V(value), atomicOrdering(true, memoryOrder)));
}
-
Value *Nucleus::createAtomicExchange(Value *ptr, Value *value, std::memory_order memoryOrder)
{
RR_DEBUG_INFO_UPDATE_LOC();
@@ -2002,8 +2015,8 @@
RR_DEBUG_INFO_UPDATE_LOC();
// Note: AtomicCmpXchgInstruction returns a 2-member struct containing {result, success-flag}, not the result directly.
return V(jit->builder->CreateExtractValue(
- jit->builder->CreateAtomicCmpXchg(V(ptr), V(compare), V(value), atomicOrdering(true, memoryOrderEqual), atomicOrdering(true, memoryOrderUnequal)),
- llvm::ArrayRef<unsigned>(0u)));
+ jit->builder->CreateAtomicCmpXchg(V(ptr), V(compare), V(value), atomicOrdering(true, memoryOrderEqual), atomicOrdering(true, memoryOrderUnequal)),
+ llvm::ArrayRef<unsigned>(0u)));
}
Value *Nucleus::createTrunc(Value *v, Type *destType)
@@ -2255,7 +2268,7 @@
swizzle[i] = llvm::ConstantInt::get(llvm::Type::getInt32Ty(jit->context), select[i]);
}
- llvm::Value *shuffle = llvm::ConstantVector::get(llvm::ArrayRef<llvm::Constant*>(swizzle, size));
+ llvm::Value *shuffle = llvm::ConstantVector::get(llvm::ArrayRef<llvm::Constant *>(swizzle, size));
return V(jit->builder->CreateShuffleVector(V(v1), V(v2), shuffle));
}
@@ -2269,7 +2282,7 @@
SwitchCases *Nucleus::createSwitch(Value *control, BasicBlock *defaultBranch, unsigned numCases)
{
RR_DEBUG_INFO_UPDATE_LOC();
- return reinterpret_cast<SwitchCases*>(jit->builder->CreateSwitch(V(control), B(defaultBranch), numCases));
+ return reinterpret_cast<SwitchCases *>(jit->builder->CreateSwitch(V(control), B(defaultBranch), numCases));
}
void Nucleus::addSwitchCase(SwitchCases *switchCases, int label, BasicBlock *branch)
@@ -2359,8 +2372,8 @@
Value *Nucleus::createConstantVector(const int64_t *constants, Type *type)
{
ASSERT(llvm::isa<llvm::VectorType>(T(type)));
- const int numConstants = elementCount(type); // Number of provided constants for the (emulated) type.
- const int numElements = llvm::cast<llvm::VectorType>(T(type))->getNumElements(); // Number of elements of the underlying vector type.
+ const int numConstants = elementCount(type); // Number of provided constants for the (emulated) type.
+ const int numElements = llvm::cast<llvm::VectorType>(T(type))->getNumElements(); // Number of elements of the underlying vector type.
ASSERT(numElements <= 16 && numConstants <= numElements);
llvm::Constant *constantVector[16];
@@ -2369,14 +2382,14 @@
constantVector[i] = llvm::ConstantInt::get(T(type)->getContainedType(0), constants[i % numConstants]);
}
- return V(llvm::ConstantVector::get(llvm::ArrayRef<llvm::Constant*>(constantVector, numElements)));
+ return V(llvm::ConstantVector::get(llvm::ArrayRef<llvm::Constant *>(constantVector, numElements)));
}
Value *Nucleus::createConstantVector(const double *constants, Type *type)
{
ASSERT(llvm::isa<llvm::VectorType>(T(type)));
- const int numConstants = elementCount(type); // Number of provided constants for the (emulated) type.
- const int numElements = llvm::cast<llvm::VectorType>(T(type))->getNumElements(); // Number of elements of the underlying vector type.
+ const int numConstants = elementCount(type); // Number of provided constants for the (emulated) type.
+ const int numElements = llvm::cast<llvm::VectorType>(T(type))->getNumElements(); // Number of elements of the underlying vector type.
ASSERT(numElements <= 8 && numConstants <= numElements);
llvm::Constant *constantVector[8];
@@ -2385,7 +2398,7 @@
constantVector[i] = llvm::ConstantFP::get(T(type)->getContainedType(0), constants[i % numConstants]);
}
- return V(llvm::ConstantVector::get(llvm::ArrayRef<llvm::Constant*>(constantVector, numElements)));
+ return V(llvm::ConstantVector::get(llvm::ArrayRef<llvm::Constant *>(constantVector, numElements)));
}
Type *Void::getType()
@@ -2560,7 +2573,7 @@
Short4::Short4(RValue<Int4> cast)
{
RR_DEBUG_INFO_UPDATE_LOC();
- int select[8] = {0, 2, 4, 6, 0, 2, 4, 6};
+ int select[8] = { 0, 2, 4, 6, 0, 2, 4, 6 };
Value *short8 = Nucleus::createBitCast(cast.value, Short8::getType());
Value *packed = Nucleus::createShuffleVector(short8, short8, select);
@@ -2591,7 +2604,7 @@
{
RR_DEBUG_INFO_UPDATE_LOC();
#if defined(__i386__) || defined(__x86_64__)
-// return RValue<Short4>(Nucleus::createShl(lhs.value, rhs.value));
+ // return RValue<Short4>(Nucleus::createShl(lhs.value, rhs.value));
return x86::psllw(lhs, rhs);
#else
@@ -2724,7 +2737,7 @@
#if defined(__i386__) || defined(__x86_64__)
if(CPUID::supportsSSE4_1())
{
- Int4 int4(Min(cast, Float4(0xFFFF))); // packusdw takes care of 0x0000 saturation
+ Int4 int4(Min(cast, Float4(0xFFFF))); // packusdw takes care of 0x0000 saturation
*this = As<Short4>(PackUnsigned(int4, int4));
}
else
@@ -2743,7 +2756,7 @@
{
RR_DEBUG_INFO_UPDATE_LOC();
#if defined(__i386__) || defined(__x86_64__)
-// return RValue<Short4>(Nucleus::createShl(lhs.value, rhs.value));
+ // return RValue<Short4>(Nucleus::createShl(lhs.value, rhs.value));
return As<UShort4>(x86::psllw(As<Short4>(lhs), rhs));
#else
@@ -2755,7 +2768,7 @@
{
RR_DEBUG_INFO_UPDATE_LOC();
#if defined(__i386__) || defined(__x86_64__)
-// return RValue<Short4>(Nucleus::createLShr(lhs.value, rhs.value));
+ // return RValue<Short4>(Nucleus::createLShr(lhs.value, rhs.value));
return x86::psrlw(lhs, rhs);
#else
@@ -2879,7 +2892,7 @@
{
RR_DEBUG_INFO_UPDATE_LOC();
#if defined(__i386__) || defined(__x86_64__)
- return x86::psrlw(lhs, rhs); // FIXME: Fallback required
+ return x86::psrlw(lhs, rhs); // FIXME: Fallback required
#else
return As<UShort8>(V(lowerVectorLShr(V(lhs.value), rhs)));
#endif
@@ -2888,8 +2901,7 @@
RValue<UShort8> Swizzle(RValue<UShort8> x, char select0, char select1, char select2, char select3, char select4, char select5, char select6, char select7)
{
RR_DEBUG_INFO_UPDATE_LOC();
- int pshufb[16] =
- {
+ int pshufb[16] = {
select0 + 0,
select0 + 1,
select1 + 0,
@@ -2930,7 +2942,7 @@
return T(llvm::VectorType::get(T(UShort::getType()), 8));
}
-RValue<Int> operator++(Int &val, int) // Post-increment
+RValue<Int> operator++(Int &val, int) // Post-increment
{
RR_DEBUG_INFO_UPDATE_LOC();
RValue<Int> res = val;
@@ -2941,7 +2953,7 @@
return res;
}
-const Int &operator++(Int &val) // Pre-increment
+const Int &operator++(Int &val) // Pre-increment
{
RR_DEBUG_INFO_UPDATE_LOC();
Value *inc = Nucleus::createAdd(val.loadValue(), Nucleus::createConstantInt(1));
@@ -2950,7 +2962,7 @@
return val;
}
-RValue<Int> operator--(Int &val, int) // Post-decrement
+RValue<Int> operator--(Int &val, int) // Post-decrement
{
RR_DEBUG_INFO_UPDATE_LOC();
RValue<Int> res = val;
@@ -2961,7 +2973,7 @@
return res;
}
-const Int &operator--(Int &val) // Pre-decrement
+const Int &operator--(Int &val) // Pre-decrement
{
RR_DEBUG_INFO_UPDATE_LOC();
Value *inc = Nucleus::createSub(val.loadValue(), Nucleus::createConstantInt(1));
@@ -2997,7 +3009,7 @@
storeValue(integer);
}
-RValue<UInt> operator++(UInt &val, int) // Post-increment
+RValue<UInt> operator++(UInt &val, int) // Post-increment
{
RR_DEBUG_INFO_UPDATE_LOC();
RValue<UInt> res = val;
@@ -3008,7 +3020,7 @@
return res;
}
-const UInt &operator++(UInt &val) // Pre-increment
+const UInt &operator++(UInt &val) // Pre-increment
{
RR_DEBUG_INFO_UPDATE_LOC();
Value *inc = Nucleus::createAdd(val.loadValue(), Nucleus::createConstantInt(1));
@@ -3017,7 +3029,7 @@
return val;
}
-RValue<UInt> operator--(UInt &val, int) // Post-decrement
+RValue<UInt> operator--(UInt &val, int) // Post-decrement
{
RR_DEBUG_INFO_UPDATE_LOC();
RValue<UInt> res = val;
@@ -3028,7 +3040,7 @@
return res;
}
-const UInt &operator--(UInt &val) // Pre-decrement
+const UInt &operator--(UInt &val) // Pre-decrement
{
RR_DEBUG_INFO_UPDATE_LOC();
Value *inc = Nucleus::createSub(val.loadValue(), Nucleus::createConstantInt(1));
@@ -3066,7 +3078,7 @@
{
RR_DEBUG_INFO_UPDATE_LOC();
#if defined(__i386__) || defined(__x86_64__)
-// return RValue<Int2>(Nucleus::createShl(lhs.value, rhs.value));
+ // return RValue<Int2>(Nucleus::createShl(lhs.value, rhs.value));
return x86::pslld(lhs, rhs);
#else
@@ -3078,7 +3090,7 @@
{
RR_DEBUG_INFO_UPDATE_LOC();
#if defined(__i386__) || defined(__x86_64__)
-// return RValue<Int2>(Nucleus::createAShr(lhs.value, rhs.value));
+ // return RValue<Int2>(Nucleus::createAShr(lhs.value, rhs.value));
return x86::psrad(lhs, rhs);
#else
@@ -3095,7 +3107,7 @@
{
RR_DEBUG_INFO_UPDATE_LOC();
#if defined(__i386__) || defined(__x86_64__)
-// return RValue<UInt2>(Nucleus::createShl(lhs.value, rhs.value));
+ // return RValue<UInt2>(Nucleus::createShl(lhs.value, rhs.value));
return As<UInt2>(x86::pslld(As<Int2>(lhs), rhs));
#else
@@ -3107,7 +3119,7 @@
{
RR_DEBUG_INFO_UPDATE_LOC();
#if defined(__i386__) || defined(__x86_64__)
-// return RValue<UInt2>(Nucleus::createLShr(lhs.value, rhs.value));
+ // return RValue<UInt2>(Nucleus::createLShr(lhs.value, rhs.value));
return x86::psrld(lhs, rhs);
#else
@@ -3120,7 +3132,8 @@
return T(Type_v2i32);
}
-Int4::Int4(RValue<Byte4> cast) : XYZW(this)
+Int4::Int4(RValue<Byte4> cast)
+ : XYZW(this)
{
RR_DEBUG_INFO_UPDATE_LOC();
#if defined(__i386__) || defined(__x86_64__)
@@ -3131,11 +3144,11 @@
else
#endif
{
- int swizzle[16] = {0, 16, 1, 17, 2, 18, 3, 19, 4, 20, 5, 21, 6, 22, 7, 23};
+ int swizzle[16] = { 0, 16, 1, 17, 2, 18, 3, 19, 4, 20, 5, 21, 6, 22, 7, 23 };
Value *a = Nucleus::createBitCast(cast.value, Byte16::getType());
Value *b = Nucleus::createShuffleVector(a, Nucleus::createNullValue(Byte16::getType()), swizzle);
- int swizzle2[8] = {0, 8, 1, 9, 2, 10, 3, 11};
+ int swizzle2[8] = { 0, 8, 1, 9, 2, 10, 3, 11 };
Value *c = Nucleus::createBitCast(b, Short8::getType());
Value *d = Nucleus::createShuffleVector(c, Nucleus::createNullValue(Short8::getType()), swizzle2);
@@ -3143,7 +3156,8 @@
}
}
-Int4::Int4(RValue<SByte4> cast) : XYZW(this)
+Int4::Int4(RValue<SByte4> cast)
+ : XYZW(this)
{
RR_DEBUG_INFO_UPDATE_LOC();
#if defined(__i386__) || defined(__x86_64__)
@@ -3154,11 +3168,11 @@
else
#endif
{
- int swizzle[16] = {0, 0, 1, 1, 2, 2, 3, 3, 4, 4, 5, 5, 6, 6, 7, 7};
+ int swizzle[16] = { 0, 0, 1, 1, 2, 2, 3, 3, 4, 4, 5, 5, 6, 6, 7, 7 };
Value *a = Nucleus::createBitCast(cast.value, Byte16::getType());
Value *b = Nucleus::createShuffleVector(a, a, swizzle);
- int swizzle2[8] = {0, 0, 1, 1, 2, 2, 3, 3};
+ int swizzle2[8] = { 0, 0, 1, 1, 2, 2, 3, 3 };
Value *c = Nucleus::createBitCast(b, Short8::getType());
Value *d = Nucleus::createShuffleVector(c, c, swizzle2);
@@ -3166,7 +3180,8 @@
}
}
-Int4::Int4(RValue<Short4> cast) : XYZW(this)
+Int4::Int4(RValue<Short4> cast)
+ : XYZW(this)
{
RR_DEBUG_INFO_UPDATE_LOC();
#if defined(__i386__) || defined(__x86_64__)
@@ -3177,13 +3192,14 @@
else
#endif
{
- int swizzle[8] = {0, 0, 1, 1, 2, 2, 3, 3};
+ int swizzle[8] = { 0, 0, 1, 1, 2, 2, 3, 3 };
Value *c = Nucleus::createShuffleVector(cast.value, cast.value, swizzle);
*this = As<Int4>(c) >> 16;
}
}
-Int4::Int4(RValue<UShort4> cast) : XYZW(this)
+Int4::Int4(RValue<UShort4> cast)
+ : XYZW(this)
{
RR_DEBUG_INFO_UPDATE_LOC();
#if defined(__i386__) || defined(__x86_64__)
@@ -3194,19 +3210,20 @@
else
#endif
{
- int swizzle[8] = {0, 8, 1, 9, 2, 10, 3, 11};
+ int swizzle[8] = { 0, 8, 1, 9, 2, 10, 3, 11 };
Value *c = Nucleus::createShuffleVector(cast.value, Short8(0, 0, 0, 0, 0, 0, 0, 0).loadValue(), swizzle);
*this = As<Int4>(c);
}
}
-Int4::Int4(RValue<Int> rhs) : XYZW(this)
+Int4::Int4(RValue<Int> rhs)
+ : XYZW(this)
{
RR_DEBUG_INFO_UPDATE_LOC();
Value *vector = loadValue();
Value *insert = Nucleus::createInsertElement(vector, rhs.value, 0);
- int swizzle[4] = {0, 0, 0, 0};
+ int swizzle[4] = { 0, 0, 0, 0 };
Value *replicate = Nucleus::createShuffleVector(insert, insert, swizzle);
storeValue(replicate);
@@ -3359,20 +3376,22 @@
return T(llvm::VectorType::get(T(Int::getType()), 4));
}
-UInt4::UInt4(RValue<Float4> cast) : XYZW(this)
+UInt4::UInt4(RValue<Float4> cast)
+ : XYZW(this)
{
RR_DEBUG_INFO_UPDATE_LOC();
Value *xyzw = Nucleus::createFPToUI(cast.value, UInt4::getType());
storeValue(xyzw);
}
-UInt4::UInt4(RValue<UInt> rhs) : XYZW(this)
+UInt4::UInt4(RValue<UInt> rhs)
+ : XYZW(this)
{
RR_DEBUG_INFO_UPDATE_LOC();
Value *vector = loadValue();
Value *insert = Nucleus::createInsertElement(vector, rhs.value, 0);
- int swizzle[4] = {0, 0, 0, 0};
+ int swizzle[4] = { 0, 0, 0, 0 };
Value *replicate = Nucleus::createShuffleVector(insert, insert, swizzle);
storeValue(replicate);
@@ -3539,7 +3558,7 @@
}
else
{
- return Float(Int(x)); // Rounded toward zero
+ return Float(Int(x)); // Rounded toward zero
}
#else
return RValue<Float>(V(lowerTrunc(V(x.value))));
@@ -3609,23 +3628,24 @@
RValue<Float> Exp2(RValue<Float> v)
{
- auto func = llvm::Intrinsic::getDeclaration(jit->module.get(), llvm::Intrinsic::exp2, { T(Float::getType()) } );
+ auto func = llvm::Intrinsic::getDeclaration(jit->module.get(), llvm::Intrinsic::exp2, { T(Float::getType()) });
return RValue<Float>(V(jit->builder->CreateCall(func, V(v.value))));
}
RValue<Float> Log2(RValue<Float> v)
{
- auto func = llvm::Intrinsic::getDeclaration(jit->module.get(), llvm::Intrinsic::log2, { T(Float::getType()) } );
+ auto func = llvm::Intrinsic::getDeclaration(jit->module.get(), llvm::Intrinsic::log2, { T(Float::getType()) });
return RValue<Float>(V(jit->builder->CreateCall(func, V(v.value))));
}
-Float4::Float4(RValue<Float> rhs) : XYZW(this)
+Float4::Float4(RValue<Float> rhs)
+ : XYZW(this)
{
RR_DEBUG_INFO_UPDATE_LOC();
Value *vector = loadValue();
Value *insert = Nucleus::createInsertElement(vector, rhs.value, 0);
- int swizzle[4] = {0, 0, 0, 0};
+ int swizzle[4] = { 0, 0, 0, 0 };
Value *replicate = Nucleus::createShuffleVector(insert, insert, swizzle);
storeValue(replicate);
@@ -3700,42 +3720,42 @@
RValue<Int4> CmpEQ(RValue<Float4> x, RValue<Float4> y)
{
RR_DEBUG_INFO_UPDATE_LOC();
-// return As<Int4>(x86::cmpeqps(x, y));
+ // return As<Int4>(x86::cmpeqps(x, y));
return RValue<Int4>(Nucleus::createSExt(Nucleus::createFCmpOEQ(x.value, y.value), Int4::getType()));
}
RValue<Int4> CmpLT(RValue<Float4> x, RValue<Float4> y)
{
RR_DEBUG_INFO_UPDATE_LOC();
-// return As<Int4>(x86::cmpltps(x, y));
+ // return As<Int4>(x86::cmpltps(x, y));
return RValue<Int4>(Nucleus::createSExt(Nucleus::createFCmpOLT(x.value, y.value), Int4::getType()));
}
RValue<Int4> CmpLE(RValue<Float4> x, RValue<Float4> y)
{
RR_DEBUG_INFO_UPDATE_LOC();
-// return As<Int4>(x86::cmpleps(x, y));
+ // return As<Int4>(x86::cmpleps(x, y));
return RValue<Int4>(Nucleus::createSExt(Nucleus::createFCmpOLE(x.value, y.value), Int4::getType()));
}
RValue<Int4> CmpNEQ(RValue<Float4> x, RValue<Float4> y)
{
RR_DEBUG_INFO_UPDATE_LOC();
-// return As<Int4>(x86::cmpneqps(x, y));
+ // return As<Int4>(x86::cmpneqps(x, y));
return RValue<Int4>(Nucleus::createSExt(Nucleus::createFCmpONE(x.value, y.value), Int4::getType()));
}
RValue<Int4> CmpNLT(RValue<Float4> x, RValue<Float4> y)
{
RR_DEBUG_INFO_UPDATE_LOC();
-// return As<Int4>(x86::cmpnltps(x, y));
+ // return As<Int4>(x86::cmpnltps(x, y));
return RValue<Int4>(Nucleus::createSExt(Nucleus::createFCmpOGE(x.value, y.value), Int4::getType()));
}
RValue<Int4> CmpNLE(RValue<Float4> x, RValue<Float4> y)
{
RR_DEBUG_INFO_UPDATE_LOC();
-// return As<Int4>(x86::cmpnleps(x, y));
+ // return As<Int4>(x86::cmpnleps(x, y));
return RValue<Int4>(Nucleus::createSExt(Nucleus::createFCmpOGT(x.value, y.value), Int4::getType()));
}
@@ -3821,9 +3841,9 @@
}
else
{
- frc = x - Float4(Int4(x)); // Signed fractional part.
+ frc = x - Float4(Int4(x)); // Signed fractional part.
- frc += As<Float4>(As<Int4>(CmpNLE(Float4(0.0f), frc)) & As<Int4>(Float4(1.0f))); // Add 1.0 if negative.
+ frc += As<Float4>(As<Int4>(CmpNLE(Float4(0.0f), frc)) & As<Int4>(Float4(1.0f))); // Add 1.0 if negative.
}
#else
frc = x - Floor(x);
@@ -3868,13 +3888,13 @@
RValue<Float4> Sin(RValue<Float4> v)
{
- auto func = llvm::Intrinsic::getDeclaration(jit->module.get(), llvm::Intrinsic::sin, { V(v.value)->getType() } );
+ auto func = llvm::Intrinsic::getDeclaration(jit->module.get(), llvm::Intrinsic::sin, { V(v.value)->getType() });
return RValue<Float4>(V(jit->builder->CreateCall(func, V(v.value))));
}
RValue<Float4> Cos(RValue<Float4> v)
{
- auto func = llvm::Intrinsic::getDeclaration(jit->module.get(), llvm::Intrinsic::cos, { V(v.value)->getType() } );
+ auto func = llvm::Intrinsic::getDeclaration(jit->module.get(), llvm::Intrinsic::cos, { V(v.value)->getType() });
return RValue<Float4>(V(jit->builder->CreateCall(func, V(v.value))));
}
@@ -3883,9 +3903,9 @@
return Sin(v) / Cos(v);
}
-static RValue<Float4> TransformFloat4PerElement(RValue<Float4> v, const char* name)
+static RValue<Float4> TransformFloat4PerElement(RValue<Float4> v, const char *name)
{
- auto funcTy = ::llvm::FunctionType::get(T(Float::getType()), ::llvm::ArrayRef<llvm::Type*>(T(Float::getType())), false);
+ auto funcTy = ::llvm::FunctionType::get(T(Float::getType()), ::llvm::ArrayRef<llvm::Type *>(T(Float::getType())), false);
auto func = jit->module->getOrInsertFunction(name, funcTy);
llvm::Value *out = ::llvm::UndefValue::get(T(Float4::getType()));
for(uint64_t i = 0; i < 4; i++)
@@ -3943,7 +3963,7 @@
RValue<Float4> Atan2(RValue<Float4> x, RValue<Float4> y)
{
- ::llvm::SmallVector<::llvm::Type*, 2> paramTys;
+ ::llvm::SmallVector<::llvm::Type *, 2> paramTys;
paramTys.push_back(T(Float::getType()));
paramTys.push_back(T(Float::getType()));
auto funcTy = ::llvm::FunctionType::get(T(Float::getType()), paramTys, false);
@@ -3952,9 +3972,8 @@
for(uint64_t i = 0; i < 4; i++)
{
auto el = jit->builder->CreateCall2(func, ARGS(
- V(Nucleus::createExtractElement(x.value, Float::getType(), i)),
- V(Nucleus::createExtractElement(y.value, Float::getType(), i))
- ));
+ V(Nucleus::createExtractElement(x.value, Float::getType(), i)),
+ V(Nucleus::createExtractElement(y.value, Float::getType(), i))));
out = V(Nucleus::createInsertElement(V(out), V(el), i));
}
return RValue<Float4>(V(out));
@@ -3968,62 +3987,58 @@
RValue<Float4> Exp(RValue<Float4> v)
{
- auto func = llvm::Intrinsic::getDeclaration(jit->module.get(), llvm::Intrinsic::exp, { T(Float4::getType()) } );
+ auto func = llvm::Intrinsic::getDeclaration(jit->module.get(), llvm::Intrinsic::exp, { T(Float4::getType()) });
return RValue<Float4>(V(jit->builder->CreateCall(func, V(v.value))));
}
RValue<Float4> Log(RValue<Float4> v)
{
- auto func = llvm::Intrinsic::getDeclaration(jit->module.get(), llvm::Intrinsic::log, { T(Float4::getType()) } );
+ auto func = llvm::Intrinsic::getDeclaration(jit->module.get(), llvm::Intrinsic::log, { T(Float4::getType()) });
return RValue<Float4>(V(jit->builder->CreateCall(func, V(v.value))));
}
RValue<Float4> Exp2(RValue<Float4> v)
{
- auto func = llvm::Intrinsic::getDeclaration(jit->module.get(), llvm::Intrinsic::exp2, { T(Float4::getType()) } );
+ auto func = llvm::Intrinsic::getDeclaration(jit->module.get(), llvm::Intrinsic::exp2, { T(Float4::getType()) });
return RValue<Float4>(V(jit->builder->CreateCall(func, V(v.value))));
}
RValue<Float4> Log2(RValue<Float4> v)
{
- auto func = llvm::Intrinsic::getDeclaration(jit->module.get(), llvm::Intrinsic::log2, { T(Float4::getType()) } );
+ auto func = llvm::Intrinsic::getDeclaration(jit->module.get(), llvm::Intrinsic::log2, { T(Float4::getType()) });
return RValue<Float4>(V(jit->builder->CreateCall(func, V(v.value))));
}
RValue<UInt> Ctlz(RValue<UInt> v, bool isZeroUndef)
{
- auto func = llvm::Intrinsic::getDeclaration(jit->module.get(), llvm::Intrinsic::ctlz, { T(UInt::getType()) } );
+ auto func = llvm::Intrinsic::getDeclaration(jit->module.get(), llvm::Intrinsic::ctlz, { T(UInt::getType()) });
return RValue<UInt>(V(jit->builder->CreateCall2(func, ARGS(
- V(v.value),
- isZeroUndef ? ::llvm::ConstantInt::getTrue(jit->context) : ::llvm::ConstantInt::getFalse(jit->context)
- ))));
+ V(v.value),
+ isZeroUndef ? ::llvm::ConstantInt::getTrue(jit->context) : ::llvm::ConstantInt::getFalse(jit->context)))));
}
RValue<UInt4> Ctlz(RValue<UInt4> v, bool isZeroUndef)
{
- auto func = llvm::Intrinsic::getDeclaration(jit->module.get(), llvm::Intrinsic::ctlz, { T(UInt4::getType()) } );
+ auto func = llvm::Intrinsic::getDeclaration(jit->module.get(), llvm::Intrinsic::ctlz, { T(UInt4::getType()) });
return RValue<UInt4>(V(jit->builder->CreateCall2(func, ARGS(
- V(v.value),
- isZeroUndef ? ::llvm::ConstantInt::getTrue(jit->context) : ::llvm::ConstantInt::getFalse(jit->context)
- ))));
+ V(v.value),
+ isZeroUndef ? ::llvm::ConstantInt::getTrue(jit->context) : ::llvm::ConstantInt::getFalse(jit->context)))));
}
RValue<UInt> Cttz(RValue<UInt> v, bool isZeroUndef)
{
- auto func = llvm::Intrinsic::getDeclaration(jit->module.get(), llvm::Intrinsic::cttz, { T(UInt::getType()) } );
+ auto func = llvm::Intrinsic::getDeclaration(jit->module.get(), llvm::Intrinsic::cttz, { T(UInt::getType()) });
return RValue<UInt>(V(jit->builder->CreateCall2(func, ARGS(
- V(v.value),
- isZeroUndef ? ::llvm::ConstantInt::getTrue(jit->context) : ::llvm::ConstantInt::getFalse(jit->context)
- ))));
+ V(v.value),
+ isZeroUndef ? ::llvm::ConstantInt::getTrue(jit->context) : ::llvm::ConstantInt::getFalse(jit->context)))));
}
RValue<UInt4> Cttz(RValue<UInt4> v, bool isZeroUndef)
{
- auto func = llvm::Intrinsic::getDeclaration(jit->module.get(), llvm::Intrinsic::cttz, { T(UInt4::getType()) } );
+ auto func = llvm::Intrinsic::getDeclaration(jit->module.get(), llvm::Intrinsic::cttz, { T(UInt4::getType()) });
return RValue<UInt4>(V(jit->builder->CreateCall2(func, ARGS(
- V(v.value),
- isZeroUndef ? ::llvm::ConstantInt::getTrue(jit->context) : ::llvm::ConstantInt::getFalse(jit->context)
- ))));
+ V(v.value),
+ isZeroUndef ? ::llvm::ConstantInt::getTrue(jit->context) : ::llvm::ConstantInt::getFalse(jit->context)))));
}
Type *Float4::getType()
@@ -4039,7 +4054,7 @@
return RValue<Long>(V(jit->builder->CreateCall(rdtsc)));
}
-RValue<Pointer<Byte>> ConstantPointer(void const * ptr)
+RValue<Pointer<Byte>> ConstantPointer(void const *ptr)
{
// Note: this should work for 32-bit pointers as well because 'inttoptr'
// is defined to truncate (and zero extend) if necessary.
@@ -4047,23 +4062,23 @@
return RValue<Pointer<Byte>>(V(jit->builder->CreateIntToPtr(ptrAsInt, T(Pointer<Byte>::getType()))));
}
-RValue<Pointer<Byte>> ConstantData(void const * data, size_t size)
+RValue<Pointer<Byte>> ConstantData(void const *data, size_t size)
{
- auto str = ::llvm::StringRef(reinterpret_cast<const char*>(data), size);
+ auto str = ::llvm::StringRef(reinterpret_cast<const char *>(data), size);
auto ptr = jit->builder->CreateGlobalStringPtr(str);
return RValue<Pointer<Byte>>(V(ptr));
}
-Value* Call(RValue<Pointer<Byte>> fptr, Type* retTy, std::initializer_list<Value*> args, std::initializer_list<Type*> argTys)
+Value *Call(RValue<Pointer<Byte>> fptr, Type *retTy, std::initializer_list<Value *> args, std::initializer_list<Type *> argTys)
{
- ::llvm::SmallVector<::llvm::Type*, 8> paramTys;
+ ::llvm::SmallVector<::llvm::Type *, 8> paramTys;
for(auto ty : argTys) { paramTys.push_back(T(ty)); }
auto funcTy = ::llvm::FunctionType::get(T(retTy), paramTys, false);
auto funcPtrTy = funcTy->getPointerTo();
auto funcPtr = jit->builder->CreatePointerCast(V(fptr.value), funcPtrTy);
- ::llvm::SmallVector<::llvm::Value*, 8> arguments;
+ ::llvm::SmallVector<::llvm::Value *, 8> arguments;
for(auto arg : args) { arguments.push_back(V(arg)); }
return V(jit->builder->CreateCall(funcPtr, arguments));
}
@@ -4110,7 +4125,7 @@
RValue<Float> sqrtss(RValue<Float> val)
{
- llvm::Function *sqrt = llvm::Intrinsic::getDeclaration(jit->module.get(), llvm::Intrinsic::sqrt, {V(val.value)->getType()});
+ llvm::Function *sqrt = llvm::Intrinsic::getDeclaration(jit->module.get(), llvm::Intrinsic::sqrt, { V(val.value)->getType() });
return RValue<Float>(V(jit->builder->CreateCall(sqrt, ARGS(V(val.value)))));
}
@@ -4132,7 +4147,7 @@
RValue<Float4> sqrtps(RValue<Float4> val)
{
- llvm::Function *sqrtps = llvm::Intrinsic::getDeclaration(jit->module.get(), llvm::Intrinsic::sqrt, {V(val.value)->getType()});
+ llvm::Function *sqrtps = llvm::Intrinsic::getDeclaration(jit->module.get(), llvm::Intrinsic::sqrt, { V(val.value)->getType() });
return RValue<Float4>(V(jit->builder->CreateCall(sqrtps, ARGS(V(val.value)))));
}
@@ -4202,90 +4217,90 @@
RValue<Short4> paddsw(RValue<Short4> x, RValue<Short4> y)
{
- #if LLVM_VERSION_MAJOR >= 8
- return As<Short4>(V(lowerPSADDSAT(V(x.value), V(y.value))));
- #else
- llvm::Function *paddsw = llvm::Intrinsic::getDeclaration(jit->module.get(), llvm::Intrinsic::x86_sse2_padds_w);
+# if LLVM_VERSION_MAJOR >= 8
+ return As<Short4>(V(lowerPSADDSAT(V(x.value), V(y.value))));
+# else
+ llvm::Function *paddsw = llvm::Intrinsic::getDeclaration(jit->module.get(), llvm::Intrinsic::x86_sse2_padds_w);
- return As<Short4>(V(jit->builder->CreateCall2(paddsw, ARGS(V(x.value), V(y.value)))));
- #endif
+ return As<Short4>(V(jit->builder->CreateCall2(paddsw, ARGS(V(x.value), V(y.value)))));
+# endif
}
RValue<Short4> psubsw(RValue<Short4> x, RValue<Short4> y)
{
- #if LLVM_VERSION_MAJOR >= 8
- return As<Short4>(V(lowerPSSUBSAT(V(x.value), V(y.value))));
- #else
- llvm::Function *psubsw = llvm::Intrinsic::getDeclaration(jit->module.get(), llvm::Intrinsic::x86_sse2_psubs_w);
+# if LLVM_VERSION_MAJOR >= 8
+ return As<Short4>(V(lowerPSSUBSAT(V(x.value), V(y.value))));
+# else
+ llvm::Function *psubsw = llvm::Intrinsic::getDeclaration(jit->module.get(), llvm::Intrinsic::x86_sse2_psubs_w);
- return As<Short4>(V(jit->builder->CreateCall2(psubsw, ARGS(V(x.value), V(y.value)))));
- #endif
+ return As<Short4>(V(jit->builder->CreateCall2(psubsw, ARGS(V(x.value), V(y.value)))));
+# endif
}
RValue<UShort4> paddusw(RValue<UShort4> x, RValue<UShort4> y)
{
- #if LLVM_VERSION_MAJOR >= 8
- return As<UShort4>(V(lowerPUADDSAT(V(x.value), V(y.value))));
- #else
- llvm::Function *paddusw = llvm::Intrinsic::getDeclaration(jit->module.get(), llvm::Intrinsic::x86_sse2_paddus_w);
+# if LLVM_VERSION_MAJOR >= 8
+ return As<UShort4>(V(lowerPUADDSAT(V(x.value), V(y.value))));
+# else
+ llvm::Function *paddusw = llvm::Intrinsic::getDeclaration(jit->module.get(), llvm::Intrinsic::x86_sse2_paddus_w);
- return As<UShort4>(V(jit->builder->CreateCall2(paddusw, ARGS(V(x.value), V(y.value)))));
- #endif
+ return As<UShort4>(V(jit->builder->CreateCall2(paddusw, ARGS(V(x.value), V(y.value)))));
+# endif
}
RValue<UShort4> psubusw(RValue<UShort4> x, RValue<UShort4> y)
{
- #if LLVM_VERSION_MAJOR >= 8
- return As<UShort4>(V(lowerPUSUBSAT(V(x.value), V(y.value))));
- #else
- llvm::Function *psubusw = llvm::Intrinsic::getDeclaration(jit->module.get(), llvm::Intrinsic::x86_sse2_psubus_w);
+# if LLVM_VERSION_MAJOR >= 8
+ return As<UShort4>(V(lowerPUSUBSAT(V(x.value), V(y.value))));
+# else
+ llvm::Function *psubusw = llvm::Intrinsic::getDeclaration(jit->module.get(), llvm::Intrinsic::x86_sse2_psubus_w);
- return As<UShort4>(V(jit->builder->CreateCall2(psubusw, ARGS(V(x.value), V(y.value)))));
- #endif
+ return As<UShort4>(V(jit->builder->CreateCall2(psubusw, ARGS(V(x.value), V(y.value)))));
+# endif
}
RValue<SByte8> paddsb(RValue<SByte8> x, RValue<SByte8> y)
{
- #if LLVM_VERSION_MAJOR >= 8
- return As<SByte8>(V(lowerPSADDSAT(V(x.value), V(y.value))));
- #else
- llvm::Function *paddsb = llvm::Intrinsic::getDeclaration(jit->module.get(), llvm::Intrinsic::x86_sse2_padds_b);
+# if LLVM_VERSION_MAJOR >= 8
+ return As<SByte8>(V(lowerPSADDSAT(V(x.value), V(y.value))));
+# else
+ llvm::Function *paddsb = llvm::Intrinsic::getDeclaration(jit->module.get(), llvm::Intrinsic::x86_sse2_padds_b);
- return As<SByte8>(V(jit->builder->CreateCall2(paddsb, ARGS(V(x.value), V(y.value)))));
- #endif
+ return As<SByte8>(V(jit->builder->CreateCall2(paddsb, ARGS(V(x.value), V(y.value)))));
+# endif
}
RValue<SByte8> psubsb(RValue<SByte8> x, RValue<SByte8> y)
{
- #if LLVM_VERSION_MAJOR >= 8
- return As<SByte8>(V(lowerPSSUBSAT(V(x.value), V(y.value))));
- #else
- llvm::Function *psubsb = llvm::Intrinsic::getDeclaration(jit->module.get(), llvm::Intrinsic::x86_sse2_psubs_b);
+# if LLVM_VERSION_MAJOR >= 8
+ return As<SByte8>(V(lowerPSSUBSAT(V(x.value), V(y.value))));
+# else
+ llvm::Function *psubsb = llvm::Intrinsic::getDeclaration(jit->module.get(), llvm::Intrinsic::x86_sse2_psubs_b);
- return As<SByte8>(V(jit->builder->CreateCall2(psubsb, ARGS(V(x.value), V(y.value)))));
- #endif
+ return As<SByte8>(V(jit->builder->CreateCall2(psubsb, ARGS(V(x.value), V(y.value)))));
+# endif
}
RValue<Byte8> paddusb(RValue<Byte8> x, RValue<Byte8> y)
{
- #if LLVM_VERSION_MAJOR >= 8
- return As<Byte8>(V(lowerPUADDSAT(V(x.value), V(y.value))));
- #else
- llvm::Function *paddusb = llvm::Intrinsic::getDeclaration(jit->module.get(), llvm::Intrinsic::x86_sse2_paddus_b);
+# if LLVM_VERSION_MAJOR >= 8
+ return As<Byte8>(V(lowerPUADDSAT(V(x.value), V(y.value))));
+# else
+ llvm::Function *paddusb = llvm::Intrinsic::getDeclaration(jit->module.get(), llvm::Intrinsic::x86_sse2_paddus_b);
- return As<Byte8>(V(jit->builder->CreateCall2(paddusb, ARGS(V(x.value), V(y.value)))));
- #endif
+ return As<Byte8>(V(jit->builder->CreateCall2(paddusb, ARGS(V(x.value), V(y.value)))));
+# endif
}
RValue<Byte8> psubusb(RValue<Byte8> x, RValue<Byte8> y)
{
- #if LLVM_VERSION_MAJOR >= 8
- return As<Byte8>(V(lowerPUSUBSAT(V(x.value), V(y.value))));
- #else
- llvm::Function *psubusb = llvm::Intrinsic::getDeclaration(jit->module.get(), llvm::Intrinsic::x86_sse2_psubus_b);
+# if LLVM_VERSION_MAJOR >= 8
+ return As<Byte8>(V(lowerPUSUBSAT(V(x.value), V(y.value))));
+# else
+ llvm::Function *psubusb = llvm::Intrinsic::getDeclaration(jit->module.get(), llvm::Intrinsic::x86_sse2_psubus_b);
- return As<Byte8>(V(jit->builder->CreateCall2(psubusb, ARGS(V(x.value), V(y.value)))));
- #endif
+ return As<Byte8>(V(jit->builder->CreateCall2(psubusb, ARGS(V(x.value), V(y.value)))));
+# endif
}
RValue<UShort4> pavgw(RValue<UShort4> x, RValue<UShort4> y)
@@ -4554,9 +4569,9 @@
#ifdef ENABLE_RR_PRINT
// extractAll returns a vector containing the extracted n scalar value of
// the vector vec.
-static std::vector<Value*> extractAll(Value* vec, int n)
+static std::vector<Value *> extractAll(Value *vec, int n)
{
- std::vector<Value*> elements;
+ std::vector<Value *> elements;
elements.reserve(n);
for(int i = 0; i < n; i++)
{
@@ -4568,10 +4583,10 @@
// toInt returns all the integer values in vals extended to a native width
// integer.
-static std::vector<Value*> toInt(const std::vector<Value*>& vals, bool isSigned)
+static std::vector<Value *> toInt(const std::vector<Value *> &vals, bool isSigned)
{
- auto intTy = ::llvm::Type::getIntNTy(jit->context, sizeof(int) * 8); // Natural integer width.
- std::vector<Value*> elements;
+ auto intTy = ::llvm::Type::getIntNTy(jit->context, sizeof(int) * 8); // Natural integer width.
+ std::vector<Value *> elements;
elements.reserve(vals.size());
for(auto v : vals)
{
@@ -4588,10 +4603,10 @@
}
// toDouble returns all the float values in vals extended to doubles.
-static std::vector<Value*> toDouble(const std::vector<Value*>& vals)
+static std::vector<Value *> toDouble(const std::vector<Value *> &vals)
{
auto doubleTy = ::llvm::Type::getDoubleTy(jit->context);
- std::vector<Value*> elements;
+ std::vector<Value *> elements;
elements.reserve(vals.size());
for(auto v : vals)
{
@@ -4600,29 +4615,74 @@
return elements;
}
-std::vector<Value*> PrintValue::Ty<Byte>::val(const RValue<Byte>& v) { return toInt({v.value}, false); }
-std::vector<Value*> PrintValue::Ty<Byte4>::val(const RValue<Byte4>& v) { return toInt(extractAll(v.value, 4), false); }
-std::vector<Value*> PrintValue::Ty<Int>::val(const RValue<Int>& v) { return toInt({v.value}, true); }
-std::vector<Value*> PrintValue::Ty<Int2>::val(const RValue<Int2>& v) { return toInt(extractAll(v.value, 2), true); }
-std::vector<Value*> PrintValue::Ty<Int4>::val(const RValue<Int4>& v) { return toInt(extractAll(v.value, 4), true); }
-std::vector<Value*> PrintValue::Ty<UInt>::val(const RValue<UInt>& v) { return toInt({v.value}, false); }
-std::vector<Value*> PrintValue::Ty<UInt2>::val(const RValue<UInt2>& v) { return toInt(extractAll(v.value, 2), false); }
-std::vector<Value*> PrintValue::Ty<UInt4>::val(const RValue<UInt4>& v) { return toInt(extractAll(v.value, 4), false); }
-std::vector<Value*> PrintValue::Ty<Short>::val(const RValue<Short>& v) { return toInt({v.value}, true); }
-std::vector<Value*> PrintValue::Ty<Short4>::val(const RValue<Short4>& v) { return toInt(extractAll(v.value, 4), true); }
-std::vector<Value*> PrintValue::Ty<UShort>::val(const RValue<UShort>& v) { return toInt({v.value}, false); }
-std::vector<Value*> PrintValue::Ty<UShort4>::val(const RValue<UShort4>& v) { return toInt(extractAll(v.value, 4), false); }
-std::vector<Value*> PrintValue::Ty<Float>::val(const RValue<Float>& v) { return toDouble({v.value}); }
-std::vector<Value*> PrintValue::Ty<Float4>::val(const RValue<Float4>& v) { return toDouble(extractAll(v.value, 4)); }
-std::vector<Value*> PrintValue::Ty<const char*>::val(const char* v) { return {V(jit->builder->CreateGlobalStringPtr(v))}; }
+std::vector<Value *> PrintValue::Ty<Byte>::val(const RValue<Byte> &v)
+{
+ return toInt({ v.value }, false);
+}
+std::vector<Value *> PrintValue::Ty<Byte4>::val(const RValue<Byte4> &v)
+{
+ return toInt(extractAll(v.value, 4), false);
+}
+std::vector<Value *> PrintValue::Ty<Int>::val(const RValue<Int> &v)
+{
+ return toInt({ v.value }, true);
+}
+std::vector<Value *> PrintValue::Ty<Int2>::val(const RValue<Int2> &v)
+{
+ return toInt(extractAll(v.value, 2), true);
+}
+std::vector<Value *> PrintValue::Ty<Int4>::val(const RValue<Int4> &v)
+{
+ return toInt(extractAll(v.value, 4), true);
+}
+std::vector<Value *> PrintValue::Ty<UInt>::val(const RValue<UInt> &v)
+{
+ return toInt({ v.value }, false);
+}
+std::vector<Value *> PrintValue::Ty<UInt2>::val(const RValue<UInt2> &v)
+{
+ return toInt(extractAll(v.value, 2), false);
+}
+std::vector<Value *> PrintValue::Ty<UInt4>::val(const RValue<UInt4> &v)
+{
+ return toInt(extractAll(v.value, 4), false);
+}
+std::vector<Value *> PrintValue::Ty<Short>::val(const RValue<Short> &v)
+{
+ return toInt({ v.value }, true);
+}
+std::vector<Value *> PrintValue::Ty<Short4>::val(const RValue<Short4> &v)
+{
+ return toInt(extractAll(v.value, 4), true);
+}
+std::vector<Value *> PrintValue::Ty<UShort>::val(const RValue<UShort> &v)
+{
+ return toInt({ v.value }, false);
+}
+std::vector<Value *> PrintValue::Ty<UShort4>::val(const RValue<UShort4> &v)
+{
+ return toInt(extractAll(v.value, 4), false);
+}
+std::vector<Value *> PrintValue::Ty<Float>::val(const RValue<Float> &v)
+{
+ return toDouble({ v.value });
+}
+std::vector<Value *> PrintValue::Ty<Float4>::val(const RValue<Float4> &v)
+{
+ return toDouble(extractAll(v.value, 4));
+}
+std::vector<Value *> PrintValue::Ty<const char *>::val(const char *v)
+{
+ return { V(jit->builder->CreateGlobalStringPtr(v)) };
+}
-void Printv(const char* function, const char* file, int line, const char* fmt, std::initializer_list<PrintValue> args)
+void Printv(const char *function, const char *file, int line, const char *fmt, std::initializer_list<PrintValue> args)
{
// LLVM types used below.
auto i32Ty = ::llvm::Type::getInt32Ty(jit->context);
- auto intTy = ::llvm::Type::getIntNTy(jit->context, sizeof(int) * 8); // Natural integer width.
+ auto intTy = ::llvm::Type::getIntNTy(jit->context, sizeof(int) * 8); // Natural integer width.
auto i8PtrTy = ::llvm::Type::getInt8PtrTy(jit->context);
- auto funcTy = ::llvm::FunctionType::get(i32Ty, {i8PtrTy}, true);
+ auto funcTy = ::llvm::FunctionType::get(i32Ty, { i8PtrTy }, true);
auto func = jit->module->getOrInsertFunction("printf", funcTy);
@@ -4635,12 +4695,12 @@
// Perform subsitution on all '{n}' bracketed indices in the format
// message.
int i = 0;
- for(const PrintValue& arg : args)
+ for(const PrintValue &arg : args)
{
str = replace(str, "{" + std::to_string(i++) + "}", arg.format);
}
- ::llvm::SmallVector<::llvm::Value*, 8> vals;
+ ::llvm::SmallVector<::llvm::Value *, 8> vals;
// The format message is always the first argument.
vals.push_back(jit->builder->CreateGlobalStringPtr(str));
@@ -4660,7 +4720,7 @@
}
// Add all format arguments.
- for(const PrintValue& arg : args)
+ for(const PrintValue &arg : args)
{
for(auto val : arg.values)
{
@@ -4670,7 +4730,7 @@
jit->builder->CreateCall(func, vals);
}
-#endif // ENABLE_RR_PRINT
+#endif // ENABLE_RR_PRINT
void Nop()
{
@@ -4687,17 +4747,17 @@
{
jit->debugInfo->EmitLocation();
}
-#endif // ENABLE_RR_DEBUG_INFO
+#endif // ENABLE_RR_DEBUG_INFO
}
-void EmitDebugVariable(Value* value)
+void EmitDebugVariable(Value *value)
{
#ifdef ENABLE_RR_DEBUG_INFO
if(jit->debugInfo != nullptr)
{
jit->debugInfo->EmitVariable(value);
}
-#endif // ENABLE_RR_DEBUG_INFO
+#endif // ENABLE_RR_DEBUG_INFO
}
void FlushDebug()
@@ -4707,7 +4767,7 @@
{
jit->debugInfo->Flush();
}
-#endif // ENABLE_RR_DEBUG_INFO
+#endif // ENABLE_RR_DEBUG_INFO
}
} // namespace rr
@@ -4740,7 +4800,7 @@
// LLVM intrinsics
auto coro_id = ::llvm::Intrinsic::getDeclaration(jit->module.get(), llvm::Intrinsic::coro_id);
- auto coro_size = ::llvm::Intrinsic::getDeclaration(jit->module.get(), llvm::Intrinsic::coro_size, {i32Ty});
+ auto coro_size = ::llvm::Intrinsic::getDeclaration(jit->module.get(), llvm::Intrinsic::coro_size, { i32Ty });
auto coro_begin = ::llvm::Intrinsic::getDeclaration(jit->module.get(), llvm::Intrinsic::coro_begin);
auto coro_resume = ::llvm::Intrinsic::getDeclaration(jit->module.get(), ::llvm::Intrinsic::coro_resume);
auto coro_end = ::llvm::Intrinsic::getDeclaration(jit->module.get(), ::llvm::Intrinsic::coro_end);
@@ -4750,9 +4810,9 @@
auto coro_done = ::llvm::Intrinsic::getDeclaration(jit->module.get(), ::llvm::Intrinsic::coro_done);
auto coro_suspend = ::llvm::Intrinsic::getDeclaration(jit->module.get(), ::llvm::Intrinsic::coro_suspend);
- auto allocFrameTy = ::llvm::FunctionType::get(i8PtrTy, {i32Ty}, false);
+ auto allocFrameTy = ::llvm::FunctionType::get(i8PtrTy, { i32Ty }, false);
auto allocFrame = jit->module->getOrInsertFunction("coroutine_alloc_frame", allocFrameTy);
- auto freeFrameTy = ::llvm::FunctionType::get(voidTy, {i8PtrTy}, false);
+ auto freeFrameTy = ::llvm::FunctionType::get(voidTy, { i8PtrTy }, false);
auto freeFrame = jit->module->getOrInsertFunction("coroutine_free_frame", freeFrameTy);
auto oldInsertionPoint = jit->builder->saveIP();
@@ -4781,18 +4841,18 @@
auto doneBlock = llvm::BasicBlock::Create(jit->context, "done", jit->coroutine.await);
auto resumeBlock = llvm::BasicBlock::Create(jit->context, "resume", jit->coroutine.await);
- auto done = jit->builder->CreateCall(coro_done, {handle}, "done");
+ auto done = jit->builder->CreateCall(coro_done, { handle }, "done");
jit->builder->CreateCondBr(done, doneBlock, resumeBlock);
jit->builder->SetInsertPoint(doneBlock);
jit->builder->CreateRet(::llvm::ConstantInt::getFalse(i1Ty));
jit->builder->SetInsertPoint(resumeBlock);
- auto promiseAlignment = ::llvm::ConstantInt::get(i32Ty, 4); // TODO: Get correct alignment.
- auto promisePtr = jit->builder->CreateCall(coro_promise, {handle, promiseAlignment, ::llvm::ConstantInt::get(i1Ty, 0)});
+ auto promiseAlignment = ::llvm::ConstantInt::get(i32Ty, 4); // TODO: Get correct alignment.
+ auto promisePtr = jit->builder->CreateCall(coro_promise, { handle, promiseAlignment, ::llvm::ConstantInt::get(i1Ty, 0) });
auto promise = jit->builder->CreateLoad(jit->builder->CreatePointerCast(promisePtr, promisePtrTy));
jit->builder->CreateStore(promise, outPtr);
- jit->builder->CreateCall(coro_resume, {handle});
+ jit->builder->CreateCall(coro_resume, { handle });
jit->builder->CreateRet(::llvm::ConstantInt::getTrue(i1Ty));
}
@@ -4806,7 +4866,7 @@
{
auto handle = jit->coroutine.destroy->arg_begin();
jit->builder->SetInsertPoint(llvm::BasicBlock::Create(jit->context, "", jit->coroutine.destroy));
- jit->builder->CreateCall(coro_destroy, {handle});
+ jit->builder->CreateCall(coro_destroy, { handle });
jit->builder->CreateRetVoid();
}
@@ -4845,7 +4905,7 @@
#ifdef ENABLE_RR_DEBUG_INFO
jit->debugInfo = std::unique_ptr<rr::DebugInfo>(new rr::DebugInfo(jit->builder.get(), &jit->context, jit->module.get(), jit->function));
-#endif // ENABLE_RR_DEBUG_INFO
+#endif // ENABLE_RR_DEBUG_INFO
jit->coroutine.suspendBlock = llvm::BasicBlock::Create(jit->context, "suspend", jit->function);
jit->coroutine.endBlock = llvm::BasicBlock::Create(jit->context, "end", jit->function);
@@ -4854,45 +4914,45 @@
jit->builder->SetInsertPoint(jit->coroutine.entryBlock, jit->coroutine.entryBlock->begin());
jit->coroutine.promise = jit->builder->CreateAlloca(promiseTy, nullptr, "promise");
jit->coroutine.id = jit->builder->CreateCall(coro_id, {
- ::llvm::ConstantInt::get(i32Ty, 0),
- jit->builder->CreatePointerCast(jit->coroutine.promise, i8PtrTy),
- ::llvm::ConstantPointerNull::get(i8PtrTy),
- ::llvm::ConstantPointerNull::get(i8PtrTy),
- });
+ ::llvm::ConstantInt::get(i32Ty, 0),
+ jit->builder->CreatePointerCast(jit->coroutine.promise, i8PtrTy),
+ ::llvm::ConstantPointerNull::get(i8PtrTy),
+ ::llvm::ConstantPointerNull::get(i8PtrTy),
+ });
auto size = jit->builder->CreateCall(coro_size, {});
- auto frame = jit->builder->CreateCall(allocFrame, {size});
- jit->coroutine.handle = jit->builder->CreateCall(coro_begin, {jit->coroutine.id, frame});
+ auto frame = jit->builder->CreateCall(allocFrame, { size });
+ jit->coroutine.handle = jit->builder->CreateCall(coro_begin, { jit->coroutine.id, frame });
// Build the suspend block
jit->builder->SetInsertPoint(jit->coroutine.suspendBlock);
- jit->builder->CreateCall(coro_end, {jit->coroutine.handle, ::llvm::ConstantInt::get(i1Ty, 0)});
+ jit->builder->CreateCall(coro_end, { jit->coroutine.handle, ::llvm::ConstantInt::get(i1Ty, 0) });
jit->builder->CreateRet(jit->coroutine.handle);
// Build the end block
jit->builder->SetInsertPoint(jit->coroutine.endBlock);
auto action = jit->builder->CreateCall(coro_suspend, {
- ::llvm::ConstantTokenNone::get(jit->context),
- ::llvm::ConstantInt::get(i1Ty, 1), // final: true
- });
+ ::llvm::ConstantTokenNone::get(jit->context),
+ ::llvm::ConstantInt::get(i1Ty, 1), // final: true
+ });
auto switch_ = jit->builder->CreateSwitch(action, jit->coroutine.suspendBlock, 3);
// switch_->addCase(::llvm::ConstantInt::get(i8Ty, SuspendActionResume), trapBlock); // TODO: Trap attempting to resume after final suspend
switch_->addCase(::llvm::ConstantInt::get(i8Ty, SuspendActionDestroy), jit->coroutine.destroyBlock);
// Build the destroy block
jit->builder->SetInsertPoint(jit->coroutine.destroyBlock);
- auto memory = jit->builder->CreateCall(coro_free, {jit->coroutine.id, jit->coroutine.handle});
- jit->builder->CreateCall(freeFrame, {memory});
+ auto memory = jit->builder->CreateCall(coro_free, { jit->coroutine.id, jit->coroutine.handle });
+ jit->builder->CreateCall(freeFrame, { memory });
jit->builder->CreateBr(jit->coroutine.suspendBlock);
// Switch back to original insert point to continue building the coroutine.
jit->builder->restoreIP(oldInsertionPoint);
}
-} // anonymous namespace
+} // anonymous namespace
namespace rr {
-void Nucleus::createCoroutine(Type *YieldType, std::vector<Type*> &Params)
+void Nucleus::createCoroutine(Type *YieldType, std::vector<Type *> &Params)
{
// Coroutines are initially created as a regular function.
// Upon the first call to Yield(), the function is promoted to a true
@@ -4906,15 +4966,15 @@
auto promisePtrTy = promiseTy->getPointerTo();
jit->function = rr::createFunction("coroutine_begin", handleTy, T(Params));
- jit->coroutine.await = rr::createFunction("coroutine_await", boolTy, {handleTy, promisePtrTy});
- jit->coroutine.destroy = rr::createFunction("coroutine_destroy", voidTy, {handleTy});
+ jit->coroutine.await = rr::createFunction("coroutine_await", boolTy, { handleTy, promisePtrTy });
+ jit->coroutine.destroy = rr::createFunction("coroutine_destroy", voidTy, { handleTy });
jit->coroutine.yieldType = promiseTy;
jit->coroutine.entryBlock = llvm::BasicBlock::Create(jit->context, "function", jit->function);
jit->builder->SetInsertPoint(jit->coroutine.entryBlock);
}
-void Nucleus::yield(Value* val)
+void Nucleus::yield(Value *val)
{
if(jit->coroutine.id == nullptr)
{
@@ -4955,9 +5015,9 @@
// Store the promise (yield value)
jit->builder->CreateStore(V(val), jit->coroutine.promise);
auto action = jit->builder->CreateCall(coro_suspend, {
- ::llvm::ConstantTokenNone::get(jit->context),
- ::llvm::ConstantInt::get(i1Ty, 0), // final: true
- });
+ ::llvm::ConstantTokenNone::get(jit->context),
+ ::llvm::ConstantInt::get(i1Ty, 0), // final: true
+ });
auto switch_ = jit->builder->CreateSwitch(action, jit->coroutine.suspendBlock, 3);
switch_->addCase(::llvm::ConstantInt::get(i8Ty, SuspendActionResume), resumeBlock);
switch_->addCase(::llvm::ConstantInt::get(i8Ty, SuspendActionDestroy), jit->coroutine.destroyBlock);
@@ -4992,7 +5052,7 @@
{
jit->debugInfo->Finalize();
}
-#endif // ENABLE_RR_DEBUG_INFO
+#endif // ENABLE_RR_DEBUG_INFO
if(false)
{
@@ -5019,7 +5079,7 @@
pm.add(llvm::createVerifierPass());
pm.run(*jit->module);
}
-#endif // defined(ENABLE_RR_LLVM_IR_VERIFICATION) || !defined(NDEBUG)
+#endif // defined(ENABLE_RR_LLVM_IR_VERIFICATION) || !defined(NDEBUG)
auto cfg = cfgEdit.apply(jit->config);
jit->optimize(cfg);
@@ -5041,4 +5101,4 @@
return routine;
}
-} // namespace rr
\ No newline at end of file
+} // namespace rr
\ No newline at end of file
diff --git a/src/Reactor/LLVMReactor.hpp b/src/Reactor/LLVMReactor.hpp
index bbf3332..0b91ef8 100644
--- a/src/Reactor/LLVMReactor.hpp
+++ b/src/Reactor/LLVMReactor.hpp
@@ -31,17 +31,17 @@
inline Type *T(llvm::Type *t)
{
- return reinterpret_cast<Type*>(t);
+ return reinterpret_cast<Type *>(t);
}
inline llvm::Value *V(Value *t)
{
- return reinterpret_cast<llvm::Value*>(t);
+ return reinterpret_cast<llvm::Value *>(t);
}
inline Value *V(llvm::Value *t)
{
- return reinterpret_cast<Value*>(t);
+ return reinterpret_cast<Value *>(t);
}
// Emits a no-op instruction that will not be optimized away.
@@ -51,4 +51,4 @@
} // namespace rr
-#endif // rr_LLVMReactor_hpp
+#endif // rr_LLVMReactor_hpp
diff --git a/src/Reactor/LLVMReactorDebugInfo.cpp b/src/Reactor/LLVMReactorDebugInfo.cpp
index db97080..0cf4723 100644
--- a/src/Reactor/LLVMReactorDebugInfo.cpp
+++ b/src/Reactor/LLVMReactorDebugInfo.cpp
@@ -16,52 +16,55 @@
#ifdef ENABLE_RR_DEBUG_INFO
-#include "Reactor.hpp"
-#include "LLVMReactor.hpp"
+# include "LLVMReactor.hpp"
+# include "Reactor.hpp"
-#include "boost/stacktrace.hpp"
+# include "boost/stacktrace.hpp"
-#include "llvm/Demangle/Demangle.h"
-#include "llvm/ExecutionEngine/JITEventListener.h"
-#include "llvm/IR/DIBuilder.h"
-#include "llvm/IR/Intrinsics.h"
-#include "llvm/IR/IRBuilder.h"
+# include "llvm/Demangle/Demangle.h"
+# include "llvm/ExecutionEngine/JITEventListener.h"
+# include "llvm/IR/DIBuilder.h"
+# include "llvm/IR/IRBuilder.h"
+# include "llvm/IR/Intrinsics.h"
-#include <cctype>
-#include <fstream>
-#include <mutex>
-#include <regex>
-#include <sstream>
-#include <string>
+# include <cctype>
+# include <fstream>
+# include <mutex>
+# include <regex>
+# include <sstream>
+# include <string>
-#if 0
-#define LOG(msg, ...) printf(msg "\n", ##__VA_ARGS__)
-#else
-#define LOG(msg, ...)
-#endif
+# if 0
+# define LOG(msg, ...) printf(msg "\n", ##__VA_ARGS__)
+# else
+# define LOG(msg, ...)
+# endif
namespace {
-std::pair<llvm::StringRef, llvm::StringRef> splitPath(const char* path)
+std::pair<llvm::StringRef, llvm::StringRef> splitPath(const char *path)
{
return llvm::StringRef(path).rsplit('/');
}
// Note: createGDBRegistrationListener() returns a pointer to a singleton.
// Nothing is actually created.
-auto jitEventListener = llvm::JITEventListener::createGDBRegistrationListener(); // guarded by jitEventListenerMutex
+auto jitEventListener = llvm::JITEventListener::createGDBRegistrationListener(); // guarded by jitEventListenerMutex
std::mutex jitEventListenerMutex;
-} // anonymous namespaces
+} // namespace
namespace rr {
DebugInfo::DebugInfo(
- llvm::IRBuilder<> *builder,
- llvm::LLVMContext *context,
- llvm::Module *module,
- llvm::Function *function)
- : builder(builder), context(context), module(module), function(function)
+ llvm::IRBuilder<> *builder,
+ llvm::LLVMContext *context,
+ llvm::Module *module,
+ llvm::Function *function)
+ : builder(builder)
+ , context(context)
+ , module(module)
+ , function(function)
{
using namespace ::llvm;
@@ -70,10 +73,10 @@
auto fileAndDir = splitPath(location.function.file.c_str());
diBuilder.reset(new llvm::DIBuilder(*module));
diCU = diBuilder->createCompileUnit(
- llvm::dwarf::DW_LANG_C,
- diBuilder->createFile(fileAndDir.first, fileAndDir.second),
- "Reactor",
- 0, "", 0);
+ llvm::dwarf::DW_LANG_C,
+ diBuilder->createFile(fileAndDir.first, fileAndDir.second),
+ "Reactor",
+ 0, "", 0);
registerBasicTypes();
@@ -82,17 +85,17 @@
auto file = getOrCreateFile(location.function.file.c_str());
auto sp = diBuilder->createFunction(
- file, // scope
- "ReactorFunction", // function name
- "ReactorFunction", // linkage
- file, // file
- location.line, // line
- funcTy, // type
- false, // internal linkage
- true, // definition
- location.line, // scope line
- DINode::FlagPrototyped, // flags
- false // is optimized
+ file, // scope
+ "ReactorFunction", // function name
+ "ReactorFunction", // linkage
+ file, // file
+ location.line, // line
+ funcTy, // type
+ false, // internal linkage
+ true, // definition
+ location.line, // scope line
+ DINode::FlagPrototyped, // flags
+ false // is optimized
);
diSubprogram = sp;
function->setSubprogram(sp);
@@ -114,11 +117,11 @@
void DebugInfo::EmitLocation()
{
- auto const& backtrace = getCallerBacktrace();
+ auto const &backtrace = getCallerBacktrace();
syncScope(backtrace);
builder->SetCurrentDebugLocation(getLocation(backtrace, backtrace.size() - 1));
-#ifdef ENABLE_RR_EMIT_PRINT_LOCATION
+# ifdef ENABLE_RR_EMIT_PRINT_LOCATION
static Location lastLocation;
if(backtrace.size() == 0)
{
@@ -130,7 +133,7 @@
rr::Print("rr> {0} [{1}:{2}]\n", currLocation.function.name.c_str(), currLocation.function.file.c_str(), currLocation.line);
lastLocation = std::move(currLocation);
}
-#endif // ENABLE_RR_EMIT_PRINT_LOCATION
+# endif // ENABLE_RR_EMIT_PRINT_LOCATION
}
void DebugInfo::Flush()
@@ -138,17 +141,16 @@
emitPending(diScope.back(), builder);
}
-void DebugInfo::syncScope(Backtrace const& backtrace)
+void DebugInfo::syncScope(Backtrace const &backtrace)
{
- auto shrink = [this](size_t newsize)
- {
+ auto shrink = [this](size_t newsize) {
while(diScope.size() > newsize)
{
auto &scope = diScope.back();
LOG("- STACK(%d): di: %p, location: %s:%d",
- int(diScope.size() - 1), scope.di,
- scope.location.function.file.c_str(),
- int(scope.location.line));
+ int(diScope.size() - 1), scope.di,
+ scope.location.function.file.c_str(),
+ int(scope.location.line));
emitPending(scope, builder);
diScope.pop_back();
}
@@ -168,7 +170,7 @@
if(oldLocation.function != newLocation.function)
{
LOG(" STACK(%d): Changed function %s -> %s", int(i),
- oldLocation.function.name.c_str(), newLocation.function.name.c_str());
+ oldLocation.function.name.c_str(), newLocation.function.name.c_str());
shrink(i);
break;
}
@@ -179,10 +181,10 @@
auto file = getOrCreateFile(newLocation.function.file.c_str());
auto di = diBuilder->createLexicalBlock(scope.di, file, newLocation.line, 0);
LOG(" STACK(%d): Jumped backwards %d -> %d. di: %p -> %p", int(i),
- oldLocation.line, newLocation.line, scope.di, di);
+ oldLocation.line, newLocation.line, scope.di, di);
emitPending(scope, builder);
- scope = {newLocation, di};
- shrink(i+1);
+ scope = { newLocation, di };
+ shrink(i + 1);
break;
}
@@ -203,40 +205,39 @@
auto name = "jit!" + (status == 0 ? std::string(buf) : location.function.name);
auto func = diBuilder->createFunction(
- file, // scope
- name, // function name
- "", // linkage
- file, // file
- location.line, // line
- funcTy, // type
- false, // internal linkage
- true, // definition
- location.line, // scope line
- llvm::DINode::FlagPrototyped, // flags
- false // is optimized
+ file, // scope
+ name, // function name
+ "", // linkage
+ file, // file
+ location.line, // line
+ funcTy, // type
+ false, // internal linkage
+ true, // definition
+ location.line, // scope line
+ llvm::DINode::FlagPrototyped, // flags
+ false // is optimized
);
- diScope.push_back({location, func});
+ diScope.push_back({ location, func });
LOG("+ STACK(%d): di: %p, location: %s:%d", int(i), di,
- location.function.file.c_str(), int(location.line));
+ location.function.file.c_str(), int(location.line));
}
}
-llvm::DILocation* DebugInfo::getLocation(const Backtrace &backtrace, size_t i)
+llvm::DILocation *DebugInfo::getLocation(const Backtrace &backtrace, size_t i)
{
if(backtrace.size() == 0) { return nullptr; }
assert(backtrace.size() == diScope.size());
return llvm::DILocation::get(
- *context,
- backtrace[i].line,
- 0,
- diScope[i].di,
- i > 0 ? getLocation(backtrace, i - 1) : diRootLocation
- );
+ *context,
+ backtrace[i].line,
+ 0,
+ diScope[i].di,
+ i > 0 ? getLocation(backtrace, i - 1) : diRootLocation);
}
void DebugInfo::EmitVariable(Value *variable)
{
- auto const& backtrace = getCallerBacktrace();
+ auto const &backtrace = getCallerBacktrace();
syncScope(backtrace);
for(int i = backtrace.size() - 1; i >= 0; i--)
@@ -321,7 +322,7 @@
bool isAlloca = llvm::isa<llvm::AllocaInst>(pending.value);
LOG(" EMIT(%s): di: %p, location: %s:%d, isAlloca: %s", pending.name.c_str(), scope.di,
- pending.location.function.file.c_str(), pending.location.line, isAlloca ? "true" : "false");
+ pending.location.function.file.c_str(), pending.location.line, isAlloca ? "true" : "false");
auto value = pending.value;
@@ -367,12 +368,11 @@
if(pending.addNopOnNextLine)
{
builder->SetCurrentDebugLocation(llvm::DILocation::get(
- *context,
- pending.diLocation->getLine() + 1,
- 0,
- pending.diLocation->getScope(),
- pending.diLocation->getInlinedAt()
- ));
+ *context,
+ pending.diLocation->getLine() + 1,
+ 0,
+ pending.diLocation->getScope(),
+ pending.diLocation->getInlinedAt()));
Nop();
}
@@ -382,7 +382,7 @@
void DebugInfo::NotifyObjectEmitted(const llvm::object::ObjectFile &Obj, const llvm::LoadedObjectInfo &L)
{
std::unique_lock<std::mutex> lock(jitEventListenerMutex);
- jitEventListener->NotifyObjectEmitted(Obj, static_cast<const llvm::RuntimeDyld::LoadedObjectInfo&>(L));
+ jitEventListener->NotifyObjectEmitted(Obj, static_cast<const llvm::RuntimeDyld::LoadedObjectInfo &>(L));
}
void DebugInfo::NotifyFreeingObject(const llvm::object::ObjectFile &Obj)
@@ -411,24 +411,24 @@
diTypes.emplace(T(Half::getType()), diBuilder->createBasicType("Half", 16, dwarf::DW_ATE_float));
diTypes.emplace(T(Float::getType()), diBuilder->createBasicType("Float", 32, dwarf::DW_ATE_float));
- diTypes.emplace(T(Byte4::getType()), diBuilder->createVectorType(128, 128, diTypes[T(Byte::getType())], {vec16}));
- diTypes.emplace(T(SByte4::getType()), diBuilder->createVectorType(128, 128, diTypes[T(SByte::getType())], {vec16}));
- diTypes.emplace(T(Byte8::getType()), diBuilder->createVectorType(128, 128, diTypes[T(Byte::getType())], {vec16}));
- diTypes.emplace(T(SByte8::getType()), diBuilder->createVectorType(128, 128, diTypes[T(SByte::getType())], {vec16}));
- diTypes.emplace(T(Byte16::getType()), diBuilder->createVectorType(128, 128, diTypes[T(Byte::getType())], {vec16}));
- diTypes.emplace(T(SByte16::getType()), diBuilder->createVectorType(128, 128, diTypes[T(SByte::getType())], {vec16}));
- diTypes.emplace(T(Short2::getType()), diBuilder->createVectorType(128, 128, diTypes[T(Short::getType())], {vec8}));
- diTypes.emplace(T(UShort2::getType()), diBuilder->createVectorType(128, 128, diTypes[T(UShort::getType())], {vec8}));
- diTypes.emplace(T(Short4::getType()), diBuilder->createVectorType(128, 128, diTypes[T(Short::getType())], {vec8}));
- diTypes.emplace(T(UShort4::getType()), diBuilder->createVectorType(128, 128, diTypes[T(UShort::getType())], {vec8}));
- diTypes.emplace(T(Short8::getType()), diBuilder->createVectorType(128, 128, diTypes[T(Short::getType())], {vec8}));
- diTypes.emplace(T(UShort8::getType()), diBuilder->createVectorType(128, 128, diTypes[T(UShort::getType())], {vec8}));
- diTypes.emplace(T(Int2::getType()), diBuilder->createVectorType(128, 128, diTypes[T(Int::getType())], {vec4}));
- diTypes.emplace(T(UInt2::getType()), diBuilder->createVectorType(128, 128, diTypes[T(UInt::getType())], {vec4}));
- diTypes.emplace(T(Int4::getType()), diBuilder->createVectorType(128, 128, diTypes[T(Int::getType())], {vec4}));
- diTypes.emplace(T(UInt4::getType()), diBuilder->createVectorType(128, 128, diTypes[T(UInt::getType())], {vec4}));
- diTypes.emplace(T(Float2::getType()), diBuilder->createVectorType(128, 128, diTypes[T(Float::getType())], {vec4}));
- diTypes.emplace(T(Float4::getType()), diBuilder->createVectorType(128, 128, diTypes[T(Float::getType())], {vec4}));
+ diTypes.emplace(T(Byte4::getType()), diBuilder->createVectorType(128, 128, diTypes[T(Byte::getType())], { vec16 }));
+ diTypes.emplace(T(SByte4::getType()), diBuilder->createVectorType(128, 128, diTypes[T(SByte::getType())], { vec16 }));
+ diTypes.emplace(T(Byte8::getType()), diBuilder->createVectorType(128, 128, diTypes[T(Byte::getType())], { vec16 }));
+ diTypes.emplace(T(SByte8::getType()), diBuilder->createVectorType(128, 128, diTypes[T(SByte::getType())], { vec16 }));
+ diTypes.emplace(T(Byte16::getType()), diBuilder->createVectorType(128, 128, diTypes[T(Byte::getType())], { vec16 }));
+ diTypes.emplace(T(SByte16::getType()), diBuilder->createVectorType(128, 128, diTypes[T(SByte::getType())], { vec16 }));
+ diTypes.emplace(T(Short2::getType()), diBuilder->createVectorType(128, 128, diTypes[T(Short::getType())], { vec8 }));
+ diTypes.emplace(T(UShort2::getType()), diBuilder->createVectorType(128, 128, diTypes[T(UShort::getType())], { vec8 }));
+ diTypes.emplace(T(Short4::getType()), diBuilder->createVectorType(128, 128, diTypes[T(Short::getType())], { vec8 }));
+ diTypes.emplace(T(UShort4::getType()), diBuilder->createVectorType(128, 128, diTypes[T(UShort::getType())], { vec8 }));
+ diTypes.emplace(T(Short8::getType()), diBuilder->createVectorType(128, 128, diTypes[T(Short::getType())], { vec8 }));
+ diTypes.emplace(T(UShort8::getType()), diBuilder->createVectorType(128, 128, diTypes[T(UShort::getType())], { vec8 }));
+ diTypes.emplace(T(Int2::getType()), diBuilder->createVectorType(128, 128, diTypes[T(Int::getType())], { vec4 }));
+ diTypes.emplace(T(UInt2::getType()), diBuilder->createVectorType(128, 128, diTypes[T(UInt::getType())], { vec4 }));
+ diTypes.emplace(T(Int4::getType()), diBuilder->createVectorType(128, 128, diTypes[T(Int::getType())], { vec4 }));
+ diTypes.emplace(T(UInt4::getType()), diBuilder->createVectorType(128, 128, diTypes[T(UInt::getType())], { vec4 }));
+ diTypes.emplace(T(Float2::getType()), diBuilder->createVectorType(128, 128, diTypes[T(Float::getType())], { vec4 }));
+ diTypes.emplace(T(Float4::getType()), diBuilder->createVectorType(128, 128, diTypes[T(Float::getType())], { vec4 }));
}
DebugInfo::Location DebugInfo::getCallerLocation() const
@@ -439,11 +439,11 @@
DebugInfo::Backtrace DebugInfo::getCallerBacktrace(size_t limit /* = 0 */) const
{
auto shouldSkipFile = [](llvm::StringRef fileSR) {
- return fileSR.empty() ||
- fileSR.endswith_lower("ReactorDebugInfo.cpp") ||
- fileSR.endswith_lower("Reactor.cpp") ||
- fileSR.endswith_lower("Reactor.hpp") ||
- fileSR.endswith_lower("stacktrace.hpp");
+ return fileSR.empty() ||
+ fileSR.endswith_lower("ReactorDebugInfo.cpp") ||
+ fileSR.endswith_lower("Reactor.cpp") ||
+ fileSR.endswith_lower("Reactor.hpp") ||
+ fileSR.endswith_lower("stacktrace.hpp");
};
std::vector<DebugInfo::Location> locations;
@@ -475,7 +475,7 @@
return locations;
}
-llvm::DIType *DebugInfo::getOrCreateType(llvm::Type* type)
+llvm::DIType *DebugInfo::getOrCreateType(llvm::Type *type)
{
auto it = diTypes.find(type);
if(it != diTypes.end()) { return it->second; }
@@ -483,8 +483,8 @@
if(type->isPointerTy())
{
auto dbgTy = diBuilder->createPointerType(
- getOrCreateType(type->getPointerElementType()),
- sizeof(void*)*8, alignof(void*)*8);
+ getOrCreateType(type->getPointerElementType()),
+ sizeof(void *) * 8, alignof(void *) * 8);
diTypes.emplace(type, dbgTy);
return dbgTy;
}
@@ -493,7 +493,7 @@
return nullptr;
}
-llvm::DIFile *DebugInfo::getOrCreateFile(const char* path)
+llvm::DIFile *DebugInfo::getOrCreateFile(const char *path)
{
auto it = diFiles.find(path);
if(it != diFiles.end()) { return it->second; }
@@ -503,17 +503,17 @@
return file;
}
-DebugInfo::LineTokens const *DebugInfo::getOrParseFileTokens(const char* path)
+DebugInfo::LineTokens const *DebugInfo::getOrParseFileTokens(const char *path)
{
static std::regex reLocalDecl(
- "^" // line start
- "\\s*" // initial whitespace
- "(?:For\\s*\\(\\s*)?" // optional 'For('
- "((?:\\w+(?:<[^>]+>)?)(?:::\\w+(?:<[^>]+>)?)*)" // type (match group 1)
- "\\s+" // whitespace between type and name
- "(\\w+)" // identifier (match group 2)
- "\\s*" // whitespace after identifier
- "(\\[.*\\])?"); // optional array suffix (match group 3)
+ "^" // line start
+ "\\s*" // initial whitespace
+ "(?:For\\s*\\(\\s*)?" // optional 'For('
+ "((?:\\w+(?:<[^>]+>)?)(?:::\\w+(?:<[^>]+>)?)*)" // type (match group 1)
+ "\\s+" // whitespace between type and name
+ "(\\w+)" // identifier (match group 2)
+ "\\s*" // whitespace after identifier
+ "(\\[.*\\])?"); // optional array suffix (match group 3)
auto it = fileTokens.find(path);
if(it != fileTokens.end())
@@ -533,15 +533,15 @@
if(std::regex_search(line, match, reLocalDecl) && match.size() > 3)
{
bool isArray = match.str(3) != "";
- if(!isArray) // Cannot deal with C-arrays of values.
+ if(!isArray) // Cannot deal with C-arrays of values.
{
if(match.str(1) == "return")
{
- (*tokens)[lineCount] = Token{Token::Return};
+ (*tokens)[lineCount] = Token{ Token::Return };
}
else
{
- (*tokens)[lineCount] = Token{Token::Identifier, match.str(2)};
+ (*tokens)[lineCount] = Token{ Token::Identifier, match.str(2) };
}
}
}
@@ -554,4 +554,4 @@
} // namespace rr
-#endif // ENABLE_RR_DEBUG_INFO
+#endif // ENABLE_RR_DEBUG_INFO
diff --git a/src/Reactor/LLVMReactorDebugInfo.hpp b/src/Reactor/LLVMReactorDebugInfo.hpp
index f97e3d0..6f320aa 100644
--- a/src/Reactor/LLVMReactorDebugInfo.hpp
+++ b/src/Reactor/LLVMReactorDebugInfo.hpp
@@ -19,10 +19,10 @@
#ifdef ENABLE_RR_DEBUG_INFO
-#include <unordered_set>
-#include <unordered_map>
-#include <vector>
-#include <memory>
+# include <memory>
+# include <unordered_map>
+# include <unordered_set>
+# include <vector>
// Forward declarations
namespace llvm {
@@ -46,12 +46,12 @@
class Type;
class Value;
-namespace object
-{
- class ObjectFile;
+namespace object {
+class ObjectFile;
}
-template <typename T, typename Inserter> class IRBuilder;
+template<typename T, typename Inserter>
+class IRBuilder;
} // namespace llvm
@@ -68,9 +68,9 @@
using IRBuilder = llvm::IRBuilder<llvm::ConstantFolder, llvm::IRBuilderDefaultInserter>;
DebugInfo(IRBuilder *builder,
- llvm::LLVMContext *context,
- llvm::Module *module,
- llvm::Function *function);
+ llvm::LLVMContext *context,
+ llvm::Module *module,
+ llvm::Function *function);
~DebugInfo();
@@ -116,15 +116,15 @@
std::string name;
std::string file;
- bool operator == (const FunctionLocation &rhs) const { return name == rhs.name && file == rhs.file; }
- bool operator != (const FunctionLocation &rhs) const { return !(*this == rhs); }
+ bool operator==(const FunctionLocation &rhs) const { return name == rhs.name && file == rhs.file; }
+ bool operator!=(const FunctionLocation &rhs) const { return !(*this == rhs); }
struct Hash
{
std::size_t operator()(const FunctionLocation &l) const noexcept
{
return std::hash<std::string>()(l.file) * 31 +
- std::hash<std::string>()(l.name);
+ std::hash<std::string>()(l.name);
}
};
};
@@ -134,15 +134,15 @@
FunctionLocation function;
unsigned int line = 0;
- bool operator == (const Location &rhs) const { return function == rhs.function && line == rhs.line; }
- bool operator != (const Location &rhs) const { return !(*this == rhs); }
+ bool operator==(const Location &rhs) const { return function == rhs.function && line == rhs.line; }
+ bool operator!=(const Location &rhs) const { return !(*this == rhs); }
struct Hash
{
std::size_t operator()(const Location &l) const noexcept
{
return FunctionLocation::Hash()(l.function) * 31 +
- std::hash<unsigned int>()(l.line);
+ std::hash<unsigned int>()(l.line);
}
};
};
@@ -181,14 +181,14 @@
// frames will be returned.
Backtrace getCallerBacktrace(size_t limit = 0) const;
- llvm::DILocation* getLocation(const Backtrace &backtrace, size_t i);
+ llvm::DILocation *getLocation(const Backtrace &backtrace, size_t i);
- llvm::DIType *getOrCreateType(llvm::Type* type);
- llvm::DIFile *getOrCreateFile(const char* path);
- LineTokens const *getOrParseFileTokens(const char* path);
+ llvm::DIType *getOrCreateType(llvm::Type *type);
+ llvm::DIFile *getOrCreateFile(const char *path);
+ LineTokens const *getOrParseFileTokens(const char *path);
// Synchronizes diScope with the current backtrace.
- void syncScope(Backtrace const& backtrace);
+ void syncScope(Backtrace const &backtrace);
IRBuilder *builder;
llvm::LLVMContext *context;
@@ -200,14 +200,14 @@
llvm::DISubprogram *diSubprogram;
llvm::DILocation *diRootLocation;
std::vector<Scope> diScope;
- std::unordered_map<std::string, llvm::DIFile*> diFiles;
- std::unordered_map<llvm::Type*, llvm::DIType*> diTypes;
+ std::unordered_map<std::string, llvm::DIFile *> diFiles;
+ std::unordered_map<llvm::Type *, llvm::DIType *> diTypes;
std::unordered_map<std::string, std::unique_ptr<LineTokens>> fileTokens;
- std::vector<void const*> pushed;
+ std::vector<void const *> pushed;
};
} // namespace rr
-#endif // ENABLE_RR_DEBUG_INFO
+#endif // ENABLE_RR_DEBUG_INFO
-#endif // rr_LLVMReactorDebugInfo_hpp
+#endif // rr_LLVMReactorDebugInfo_hpp
diff --git a/src/Reactor/MutexLock.hpp b/src/Reactor/MutexLock.hpp
index 000819a..94b37f0 100644
--- a/src/Reactor/MutexLock.hpp
+++ b/src/Reactor/MutexLock.hpp
@@ -20,7 +20,7 @@
#if defined(__linux__)
// Use a pthread mutex on Linux. Since many processes may use Reactor
// at the same time it's best to just have the scheduler overhead.
-#include <pthread.h>
+# include <pthread.h>
namespace rr {
@@ -58,9 +58,9 @@
} // namespace rr
-#else // !__linux__
+#else // !__linux__
-#include <atomic>
+# include <atomic>
namespace rr {
@@ -174,6 +174,6 @@
} // namespace rr
-#endif // !__linux__
+#endif // !__linux__
-#endif // rr_MutexLock_hpp
+#endif // rr_MutexLock_hpp
diff --git a/src/Reactor/Nucleus.hpp b/src/Reactor/Nucleus.hpp
index 67e990f..4239973 100644
--- a/src/Reactor/Nucleus.hpp
+++ b/src/Reactor/Nucleus.hpp
@@ -23,7 +23,7 @@
#include <vector>
#ifdef None
-#undef None // TODO(b/127920555)
+# undef None // TODO(b/127920555)
#endif
static_assert(sizeof(short) == 2, "Reactor's 'Short' type is 16-bit, and requires the C++ 'short' to match that.");
@@ -68,18 +68,19 @@
using Passes = std::vector<Pass>;
- Optimization(Level level = Level::Default, const Passes& passes = {})
- : level(level), passes(passes)
+ Optimization(Level level = Level::Default, const Passes &passes = {})
+ : level(level)
+ , passes(passes)
{
- #if defined(REACTOR_DEFAULT_OPT_LEVEL)
+#if defined(REACTOR_DEFAULT_OPT_LEVEL)
{
this->level = Level::REACTOR_DEFAULT_OPT_LEVEL;
}
- #endif
+#endif
}
Level getLevel() const { return level; }
- const Passes & getPasses() const { return passes; }
+ const Passes &getPasses() const { return passes; }
private:
Level level = Level::Default;
@@ -98,19 +99,41 @@
public:
static const Edit None;
- Edit & set(Optimization::Level level) { optLevel = level; optLevelChanged = true; return *this; }
- Edit & add(Optimization::Pass pass) { optPassEdits.push_back({ListEdit::Add, pass}); return *this; }
- Edit & remove(Optimization::Pass pass) { optPassEdits.push_back({ListEdit::Remove, pass}); return *this; }
- Edit & clearOptimizationPasses() { optPassEdits.push_back({ListEdit::Clear, Optimization::Pass::Disabled}); return *this; }
+ Edit &set(Optimization::Level level)
+ {
+ optLevel = level;
+ optLevelChanged = true;
+ return *this;
+ }
+ Edit &add(Optimization::Pass pass)
+ {
+ optPassEdits.push_back({ ListEdit::Add, pass });
+ return *this;
+ }
+ Edit &remove(Optimization::Pass pass)
+ {
+ optPassEdits.push_back({ ListEdit::Remove, pass });
+ return *this;
+ }
+ Edit &clearOptimizationPasses()
+ {
+ optPassEdits.push_back({ ListEdit::Clear, Optimization::Pass::Disabled });
+ return *this;
+ }
Config apply(const Config &cfg) const;
private:
- enum class ListEdit { Add, Remove, Clear };
+ enum class ListEdit
+ {
+ Add,
+ Remove,
+ Clear
+ };
using OptPassesEdit = std::pair<ListEdit, Optimization::Pass>;
- template <typename T>
- void apply(const std::vector<std::pair<ListEdit, T>> & edits, std::vector<T>& list) const;
+ template<typename T>
+ void apply(const std::vector<std::pair<ListEdit, T>> &edits, std::vector<T> &list) const;
Optimization::Level optLevel;
bool optLevelChanged = false;
@@ -118,9 +141,11 @@
};
Config() = default;
- Config(const Optimization & optimization) : optimization(optimization) {}
+ Config(const Optimization &optimization)
+ : optimization(optimization)
+ {}
- const Optimization & getOptimization() const { return optimization; }
+ const Optimization &getOptimization() const { return optimization; }
private:
Optimization optimization;
@@ -146,15 +171,15 @@
static BasicBlock *getInsertBlock();
static void setInsertBlock(BasicBlock *basicBlock);
- static void createFunction(Type *ReturnType, std::vector<Type*> &Params);
+ static void createFunction(Type *ReturnType, std::vector<Type *> &Params);
static Value *getArgument(unsigned int index);
// Coroutines
- using CoroutineHandle = void*;
+ using CoroutineHandle = void *;
- template <typename... ARGS>
+ template<typename... ARGS>
using CoroutineBegin = CoroutineHandle(ARGS...);
- using CoroutineAwait = bool(CoroutineHandle, void* yieldValue);
+ using CoroutineAwait = bool(CoroutineHandle, void *yieldValue);
using CoroutineDestroy = void(CoroutineHandle);
enum CoroutineEntries
@@ -165,9 +190,9 @@
CoroutineEntryCount
};
- static void createCoroutine(Type *ReturnType, std::vector<Type*> &Params);
+ static void createCoroutine(Type *ReturnType, std::vector<Type *> &Params);
std::shared_ptr<Routine> acquireCoroutine(const char *name, const Config::Edit &cfg = Config::Edit::None);
- static void yield(Value*);
+ static void yield(Value *);
// Terminators
static void createRetVoid();
@@ -201,7 +226,7 @@
static Value *createNot(Value *V);
// Memory instructions
- static Value *createLoad(Value *ptr, Type *type, bool isVolatile = false, unsigned int alignment = 0, bool atomic = false , std::memory_order memoryOrder = std::memory_order_relaxed);
+ static Value *createLoad(Value *ptr, Type *type, bool isVolatile = false, unsigned int alignment = 0, bool atomic = false, std::memory_order memoryOrder = std::memory_order_relaxed);
static Value *createStore(Value *value, Value *ptr, Type *type, bool isVolatile = false, unsigned int aligment = 0, bool atomic = false, std::memory_order memoryOrder = std::memory_order_relaxed);
static Value *createGEP(Value *ptr, Type *type, Value *index, bool unsignedIndex);
@@ -294,4 +319,4 @@
} // namespace rr
-#endif // rr_Nucleus_hpp
+#endif // rr_Nucleus_hpp
diff --git a/src/Reactor/Optimizer.cpp b/src/Reactor/Optimizer.cpp
index 8b74f82..86cface 100644
--- a/src/Reactor/Optimizer.cpp
+++ b/src/Reactor/Optimizer.cpp
@@ -50,45 +50,45 @@
Ice::Cfg *function;
Ice::GlobalContext *context;
- struct Uses : std::vector<Ice::Inst*>
+ struct Uses : std::vector<Ice::Inst *>
{
bool areOnlyLoadStore() const;
void insert(Ice::Operand *value, Ice::Inst *instruction);
void erase(Ice::Inst *instruction);
- std::vector<Ice::Inst*> loads;
- std::vector<Ice::Inst*> stores;
+ std::vector<Ice::Inst *> loads;
+ std::vector<Ice::Inst *> stores;
};
struct LoadStoreInst
{
- LoadStoreInst(Ice::Inst* inst, bool isStore)
- : inst(inst),
- address(isStore ? storeAddress(inst) : loadAddress(inst)),
- isStore(isStore)
+ LoadStoreInst(Ice::Inst *inst, bool isStore)
+ : inst(inst)
+ , address(isStore ? storeAddress(inst) : loadAddress(inst))
+ , isStore(isStore)
{
}
- Ice::Inst* inst;
+ Ice::Inst *inst;
Ice::Operand *address;
bool isStore;
};
- Optimizer::Uses* getUses(Ice::Operand*);
- void setUses(Ice::Operand*, Optimizer::Uses*);
- bool hasUses(Ice::Operand*) const;
+ Optimizer::Uses *getUses(Ice::Operand *);
+ void setUses(Ice::Operand *, Optimizer::Uses *);
+ bool hasUses(Ice::Operand *) const;
- Ice::CfgNode* getNode(Ice::Inst*);
- void setNode(Ice::Inst*, Ice::CfgNode*);
+ Ice::CfgNode *getNode(Ice::Inst *);
+ void setNode(Ice::Inst *, Ice::CfgNode *);
- Ice::Inst* getDefinition(Ice::Variable*);
- void setDefinition(Ice::Variable*, Ice::Inst*);
+ Ice::Inst *getDefinition(Ice::Variable *);
+ void setDefinition(Ice::Variable *, Ice::Inst *);
- const std::vector<LoadStoreInst>& getLoadStoreInsts(Ice::CfgNode*);
- void setLoadStoreInsts(Ice::CfgNode*, std::vector<LoadStoreInst>*);
- bool hasLoadStoreInsts(Ice::CfgNode* node) const;
+ const std::vector<LoadStoreInst> &getLoadStoreInsts(Ice::CfgNode *);
+ void setLoadStoreInsts(Ice::CfgNode *, std::vector<LoadStoreInst> *);
+ bool hasLoadStoreInsts(Ice::CfgNode *node) const;
- std::vector<Optimizer::Uses*> allocatedUses;
+ std::vector<Optimizer::Uses *> allocatedUses;
};
void Optimizer::run(Ice::Cfg *function)
@@ -133,8 +133,7 @@
}
}
}
- }
- while(modified);
+ } while(modified);
}
void Optimizer::eliminateUnitializedLoads()
@@ -150,7 +149,7 @@
if(!llvm::isa<Ice::InstAlloca>(alloca))
{
- break; // Allocas are all at the top
+ break; // Allocas are all at the top
}
Ice::Operand *address = alloca.getDest();
@@ -213,7 +212,7 @@
if(!llvm::isa<Ice::InstAlloca>(alloca))
{
- break; // Allocas are all at the top
+ break; // Allocas are all at the top
}
Ice::Operand *address = alloca.getDest();
@@ -313,7 +312,7 @@
{
Ice::CfgNode *entryBlock = function->getEntryNode();
- std::vector<std::vector<LoadStoreInst>* > allocatedVectors;
+ std::vector<std::vector<LoadStoreInst> *> allocatedVectors;
for(Ice::Inst &alloca : entryBlock->getInsts())
{
@@ -324,7 +323,7 @@
if(!llvm::isa<Ice::InstAlloca>(alloca))
{
- break; // Allocas are all at the top
+ break; // Allocas are all at the top
}
Ice::Operand *address = alloca.getDest();
@@ -357,7 +356,7 @@
{
if(!hasLoadStoreInsts(singleBasicBlock))
{
- std::vector<LoadStoreInst>* loadStoreInstVector = new std::vector<LoadStoreInst>();
+ std::vector<LoadStoreInst> *loadStoreInstVector = new std::vector<LoadStoreInst>();
setLoadStoreInsts(singleBasicBlock, loadStoreInstVector);
allocatedVectors.push_back(loadStoreInstVector);
for(Ice::Inst &inst : singleBasicBlock->getInsts())
@@ -381,9 +380,9 @@
Ice::Operand *storeValue = nullptr;
bool unmatchedLoads = false;
- for(auto& loadStoreInst : getLoadStoreInsts(singleBasicBlock))
+ for(auto &loadStoreInst : getLoadStoreInsts(singleBasicBlock))
{
- Ice::Inst* inst = loadStoreInst.inst;
+ Ice::Inst *inst = loadStoreInst.inst;
if((loadStoreInst.address != address) || inst->isDeleted())
{
@@ -478,7 +477,7 @@
{
for(Ice::Inst *use : *getUses(oldValue))
{
- assert(!use->isDeleted()); // Should have been removed from uses already
+ assert(!use->isDeleted()); // Should have been removed from uses already
for(Ice::SizeT i = 0; i < use->getSrcSize(); i++)
{
@@ -547,12 +546,12 @@
{
if(hasUses(address))
{
- Optimizer::Uses* uses = getUses(address);
- return uses->size() == uses->stores.size(); // Dead if all uses are stores
+ Optimizer::Uses *uses = getUses(address);
+ return uses->size() == uses->stores.size(); // Dead if all uses are stores
}
else
{
- return true; // No uses
+ return true; // No uses
}
}
}
@@ -700,16 +699,16 @@
// Check for matching type and sub-vector width.
return storeSubVector->getSrc(1)->getType() == loadSubVector->getDest()->getType() &&
llvm::cast<Ice::ConstantInteger32>(storeSubVector->getSrc(3))->getValue() ==
- llvm::cast<Ice::ConstantInteger32>(loadSubVector->getSrc(2))->getValue();
+ llvm::cast<Ice::ConstantInteger32>(loadSubVector->getSrc(2))->getValue();
}
}
return false;
}
-Optimizer::Uses* Optimizer::getUses(Ice::Operand* operand)
+Optimizer::Uses *Optimizer::getUses(Ice::Operand *operand)
{
- Optimizer::Uses* uses = (Optimizer::Uses*)operand->Ice::Operand::getExternalData();
+ Optimizer::Uses *uses = (Optimizer::Uses *)operand->Ice::Operand::getExternalData();
if(!uses)
{
uses = new Optimizer::Uses;
@@ -719,47 +718,47 @@
return uses;
}
-void Optimizer::setUses(Ice::Operand* operand, Optimizer::Uses* uses)
+void Optimizer::setUses(Ice::Operand *operand, Optimizer::Uses *uses)
{
operand->Ice::Operand::setExternalData(uses);
}
-bool Optimizer::hasUses(Ice::Operand* operand) const
+bool Optimizer::hasUses(Ice::Operand *operand) const
{
return operand->Ice::Operand::getExternalData() != nullptr;
}
-Ice::CfgNode* Optimizer::getNode(Ice::Inst* inst)
+Ice::CfgNode *Optimizer::getNode(Ice::Inst *inst)
{
- return (Ice::CfgNode*)inst->Ice::Inst::getExternalData();
+ return (Ice::CfgNode *)inst->Ice::Inst::getExternalData();
}
-void Optimizer::setNode(Ice::Inst* inst, Ice::CfgNode* node)
+void Optimizer::setNode(Ice::Inst *inst, Ice::CfgNode *node)
{
inst->Ice::Inst::setExternalData(node);
}
-Ice::Inst* Optimizer::getDefinition(Ice::Variable* var)
+Ice::Inst *Optimizer::getDefinition(Ice::Variable *var)
{
- return (Ice::Inst*)var->Ice::Variable::getExternalData();
+ return (Ice::Inst *)var->Ice::Variable::getExternalData();
}
-void Optimizer::setDefinition(Ice::Variable* var, Ice::Inst* inst)
+void Optimizer::setDefinition(Ice::Variable *var, Ice::Inst *inst)
{
var->Ice::Variable::setExternalData(inst);
}
-const std::vector<Optimizer::LoadStoreInst>& Optimizer::getLoadStoreInsts(Ice::CfgNode* node)
+const std::vector<Optimizer::LoadStoreInst> &Optimizer::getLoadStoreInsts(Ice::CfgNode *node)
{
- return *((const std::vector<LoadStoreInst>*)node->Ice::CfgNode::getExternalData());
+ return *((const std::vector<LoadStoreInst> *)node->Ice::CfgNode::getExternalData());
}
-void Optimizer::setLoadStoreInsts(Ice::CfgNode* node, std::vector<LoadStoreInst>* insts)
+void Optimizer::setLoadStoreInsts(Ice::CfgNode *node, std::vector<LoadStoreInst> *insts)
{
node->Ice::CfgNode::setExternalData(insts);
}
-bool Optimizer::hasLoadStoreInsts(Ice::CfgNode* node) const
+bool Optimizer::hasLoadStoreInsts(Ice::CfgNode *node) const
{
return node->Ice::CfgNode::getExternalData() != nullptr;
}
@@ -825,7 +824,7 @@
}
}
-} // anonymous namespace
+} // anonymous namespace
namespace rr {
diff --git a/src/Reactor/Optimizer.hpp b/src/Reactor/Optimizer.hpp
index 8aa2019..b51c74a 100644
--- a/src/Reactor/Optimizer.hpp
+++ b/src/Reactor/Optimizer.hpp
@@ -23,4 +23,4 @@
} // namespace rr
-#endif // rr_Optimizer_hpp
+#endif // rr_Optimizer_hpp
diff --git a/src/Reactor/Print.hpp b/src/Reactor/Print.hpp
index ff4ad81..a0dee69 100644
--- a/src/Reactor/Print.hpp
+++ b/src/Reactor/Print.hpp
@@ -16,15 +16,15 @@
#define rr_Print_hpp
#if !defined(NDEBUG)
-#define ENABLE_RR_PRINT 1 // Enables RR_PRINT(), RR_WATCH()
-#endif // !defined(NDEBUG)
+# define ENABLE_RR_PRINT 1 // Enables RR_PRINT(), RR_WATCH()
+#endif // !defined(NDEBUG)
#ifdef ENABLE_RR_PRINT
-#include "Reactor.hpp"
+# include "Reactor.hpp"
-#include <string>
-#include <vector>
+# include <string>
+# include <vector>
namespace rr {
@@ -45,16 +45,18 @@
// printf format specifier.
// * A 'static std::vector<rr::Value*> val(const T& v)' method that
// returns all the printf format values.
- template <typename T> struct Ty
+ template<typename T>
+ struct Ty
{
// static std::string fmt(const T& v);
// static std::vector<rr::Value*> val(const T& v);
};
// returns the printf values for all the values in the given array.
- template <typename T>
- static std::vector<Value*> val(const T* list, int count) {
- std::vector<Value*> values;
+ template<typename T>
+ static std::vector<Value *> val(const T *list, int count)
+ {
+ std::vector<Value *> values;
values.reserve(count);
for(int i = 0; i < count; i++)
{
@@ -66,8 +68,8 @@
// fmt returns the comma-delimited list of printf format strings for
// every element in the provided list, all enclosed in square brackets.
- template <typename T>
- static std::string fmt(const T* list, int count)
+ template<typename T>
+ static std::string fmt(const T *list, int count)
{
std::string out = "[";
for(int i = 0; i < count; i++)
@@ -78,7 +80,7 @@
return out + "]";
}
- static std::string addr(const void* ptr)
+ static std::string addr(const void *ptr)
{
char buf[32];
snprintf(buf, sizeof(buf), "%p", ptr);
@@ -87,36 +89,69 @@
public:
const std::string format;
- const std::vector<Value*> values;
+ const std::vector<Value *> values;
// Constructs a PrintValue for the given value.
- template <typename T>
- PrintValue(const T& v) : format(fmt(v)), values(val(v)) {}
+ template<typename T>
+ PrintValue(const T &v)
+ : format(fmt(v))
+ , values(val(v))
+ {}
// Constructs a PrintValue for the given static array.
- template <typename T, int N>
- PrintValue(const T (&v)[N]) : format(fmt(&v[0], N)), values(val(&v[0], N)) {}
+ template<typename T, int N>
+ PrintValue(const T (&v)[N])
+ : format(fmt(&v[0], N))
+ , values(val(&v[0], N))
+ {}
// Constructs a PrintValue for the given array starting at arr of length
// len.
- template <typename T>
- PrintValue(const T* arr, int len) : format(fmt(arr, len)), values(val(arr, len)) {}
+ template<typename T>
+ PrintValue(const T *arr, int len)
+ : format(fmt(arr, len))
+ , values(val(arr, len))
+ {}
// PrintValue constructors for plain-old-data values.
- PrintValue(bool v) : format(v ? "true" : "false") {}
- PrintValue(int8_t v) : format(std::to_string(v)) {}
- PrintValue(uint8_t v) : format(std::to_string(v)) {}
- PrintValue(int16_t v) : format(std::to_string(v)) {}
- PrintValue(uint16_t v) : format(std::to_string(v)) {}
- PrintValue(int32_t v) : format(std::to_string(v)) {}
- PrintValue(uint32_t v) : format(std::to_string(v)) {}
- PrintValue(int64_t v) : format(std::to_string(v)) {}
- PrintValue(uint64_t v) : format(std::to_string(v)) {}
- PrintValue(float v) : format(std::to_string(v)) {}
- PrintValue(double v) : format(std::to_string(v)) {}
+ PrintValue(bool v)
+ : format(v ? "true" : "false")
+ {}
+ PrintValue(int8_t v)
+ : format(std::to_string(v))
+ {}
+ PrintValue(uint8_t v)
+ : format(std::to_string(v))
+ {}
+ PrintValue(int16_t v)
+ : format(std::to_string(v))
+ {}
+ PrintValue(uint16_t v)
+ : format(std::to_string(v))
+ {}
+ PrintValue(int32_t v)
+ : format(std::to_string(v))
+ {}
+ PrintValue(uint32_t v)
+ : format(std::to_string(v))
+ {}
+ PrintValue(int64_t v)
+ : format(std::to_string(v))
+ {}
+ PrintValue(uint64_t v)
+ : format(std::to_string(v))
+ {}
+ PrintValue(float v)
+ : format(std::to_string(v))
+ {}
+ PrintValue(double v)
+ : format(std::to_string(v))
+ {}
- template <typename T>
- PrintValue(const T* v) : format(addr(v)) {}
+ template<typename T>
+ PrintValue(const T *v)
+ : format(addr(v))
+ {}
// vals is a helper to build composite value lists.
// vals returns the full, sequential list of printf argument values used
@@ -144,12 +179,12 @@
// }
// };
// }
- template<typename ... ARGS>
- static std::vector<Value*> vals(ARGS... v)
+ template<typename... ARGS>
+ static std::vector<Value *> vals(ARGS... v)
{
- std::vector< std::vector<Value*> > lists = {val(v)...};
- std::vector<Value*> joined;
- for(const auto& list : lists)
+ std::vector<std::vector<Value *>> lists = { val(v)... };
+ std::vector<Value *> joined;
+ for(const auto &list : lists)
{
joined.insert(joined.end(), list.begin(), list.end());
}
@@ -158,128 +193,155 @@
// returns the printf format specifier for the given type via the
// PrintValue::Ty<T> specialization.
- template <typename T>
- static std::string fmt(const T& v) { return Ty<T>::fmt(v); }
+ template<typename T>
+ static std::string fmt(const T &v)
+ {
+ return Ty<T>::fmt(v);
+ }
// returns the printf value for the given type with a
// PrintValue::Ty<T> specialization.
- template <typename T>
- static std::vector<Value*> val(const T& v) { return Ty<T>::val(v); }
+ template<typename T>
+ static std::vector<Value *> val(const T &v)
+ {
+ return Ty<T>::val(v);
+ }
};
// PrintValue::Ty<T> specializations for basic types.
-template <> struct PrintValue::Ty<const char*>
+template<>
+struct PrintValue::Ty<const char *>
{
- static std::string fmt(const char* v) { return "%s"; }
- static std::vector<Value*> val(const char* v);
+ static std::string fmt(const char *v) { return "%s"; }
+ static std::vector<Value *> val(const char *v);
};
-template <> struct PrintValue::Ty<std::string>
+template<>
+struct PrintValue::Ty<std::string>
{
- static std::string fmt(const std::string& v) { return PrintValue::Ty<const char*>::fmt(v.c_str()); }
- static std::vector<Value*> val(const std::string& v) { return PrintValue::Ty<const char*>::val(v.c_str()); }
+ static std::string fmt(const std::string &v) { return PrintValue::Ty<const char *>::fmt(v.c_str()); }
+ static std::vector<Value *> val(const std::string &v) { return PrintValue::Ty<const char *>::val(v.c_str()); }
};
// PrintValue::Ty<T> specializations for standard Reactor types.
-template <> struct PrintValue::Ty<Bool>
+template<>
+struct PrintValue::Ty<Bool>
{
- static std::string fmt(const RValue<Bool>& v) { return "%d"; }
- static std::vector<Value*> val(const RValue<Bool>& v) { return {v.value}; }
+ static std::string fmt(const RValue<Bool> &v) { return "%d"; }
+ static std::vector<Value *> val(const RValue<Bool> &v) { return { v.value }; }
};
-template <> struct PrintValue::Ty<Byte>
+template<>
+struct PrintValue::Ty<Byte>
{
- static std::string fmt(const RValue<Byte>& v) { return "%d"; }
- static std::vector<Value*> val(const RValue<Byte>& v);
+ static std::string fmt(const RValue<Byte> &v) { return "%d"; }
+ static std::vector<Value *> val(const RValue<Byte> &v);
};
-template <> struct PrintValue::Ty<Byte4>
+template<>
+struct PrintValue::Ty<Byte4>
{
- static std::string fmt(const RValue<Byte4>& v) { return "[%d, %d, %d, %d]"; }
- static std::vector<Value*> val(const RValue<Byte4>& v);
+ static std::string fmt(const RValue<Byte4> &v) { return "[%d, %d, %d, %d]"; }
+ static std::vector<Value *> val(const RValue<Byte4> &v);
};
-template <> struct PrintValue::Ty<Int>
+template<>
+struct PrintValue::Ty<Int>
{
- static std::string fmt(const RValue<Int>& v) { return "%d"; }
- static std::vector<Value*> val(const RValue<Int>& v);
+ static std::string fmt(const RValue<Int> &v) { return "%d"; }
+ static std::vector<Value *> val(const RValue<Int> &v);
};
-template <> struct PrintValue::Ty<Int2>
+template<>
+struct PrintValue::Ty<Int2>
{
- static std::string fmt(const RValue<Int>& v) { return "[%d, %d]"; }
- static std::vector<Value*> val(const RValue<Int2>& v);
+ static std::string fmt(const RValue<Int> &v) { return "[%d, %d]"; }
+ static std::vector<Value *> val(const RValue<Int2> &v);
};
-template <> struct PrintValue::Ty<Int4>
+template<>
+struct PrintValue::Ty<Int4>
{
- static std::string fmt(const RValue<Int4>& v) { return "[%d, %d, %d, %d]"; }
- static std::vector<Value*> val(const RValue<Int4>& v);
+ static std::string fmt(const RValue<Int4> &v) { return "[%d, %d, %d, %d]"; }
+ static std::vector<Value *> val(const RValue<Int4> &v);
};
-template <> struct PrintValue::Ty<UInt>
+template<>
+struct PrintValue::Ty<UInt>
{
- static std::string fmt(const RValue<UInt>& v) { return "%u"; }
- static std::vector<Value*> val(const RValue<UInt>& v);
+ static std::string fmt(const RValue<UInt> &v) { return "%u"; }
+ static std::vector<Value *> val(const RValue<UInt> &v);
};
-template <> struct PrintValue::Ty<UInt2>
+template<>
+struct PrintValue::Ty<UInt2>
{
- static std::string fmt(const RValue<UInt>& v) { return "[%u, %u]"; }
- static std::vector<Value*> val(const RValue<UInt2>& v);
+ static std::string fmt(const RValue<UInt> &v) { return "[%u, %u]"; }
+ static std::vector<Value *> val(const RValue<UInt2> &v);
};
-template <> struct PrintValue::Ty<UInt4>
+template<>
+struct PrintValue::Ty<UInt4>
{
- static std::string fmt(const RValue<UInt4>& v) { return "[%u, %u, %u, %u]"; }
- static std::vector<Value*> val(const RValue<UInt4>& v);
+ static std::string fmt(const RValue<UInt4> &v) { return "[%u, %u, %u, %u]"; }
+ static std::vector<Value *> val(const RValue<UInt4> &v);
};
-template <> struct PrintValue::Ty<Short>
+template<>
+struct PrintValue::Ty<Short>
{
- static std::string fmt(const RValue<Short>& v) { return "%d"; }
- static std::vector<Value*> val(const RValue<Short>& v);
+ static std::string fmt(const RValue<Short> &v) { return "%d"; }
+ static std::vector<Value *> val(const RValue<Short> &v);
};
-template <> struct PrintValue::Ty<Short4>
+template<>
+struct PrintValue::Ty<Short4>
{
- static std::string fmt(const RValue<Short4>& v) { return "[%d, %d, %d, %d]"; }
- static std::vector<Value*> val(const RValue<Short4>& v);
+ static std::string fmt(const RValue<Short4> &v) { return "[%d, %d, %d, %d]"; }
+ static std::vector<Value *> val(const RValue<Short4> &v);
};
-template <> struct PrintValue::Ty<UShort>
+template<>
+struct PrintValue::Ty<UShort>
{
- static std::string fmt(const RValue<UShort>& v) { return "%u"; }
- static std::vector<Value*> val(const RValue<UShort>& v);
+ static std::string fmt(const RValue<UShort> &v) { return "%u"; }
+ static std::vector<Value *> val(const RValue<UShort> &v);
};
-template <> struct PrintValue::Ty<UShort4>
+template<>
+struct PrintValue::Ty<UShort4>
{
- static std::string fmt(const RValue<UShort4>& v) { return "[%u, %u, %u, %u]"; }
- static std::vector<Value*> val(const RValue<UShort4>& v);
+ static std::string fmt(const RValue<UShort4> &v) { return "[%u, %u, %u, %u]"; }
+ static std::vector<Value *> val(const RValue<UShort4> &v);
};
-template <> struct PrintValue::Ty<Float>
+template<>
+struct PrintValue::Ty<Float>
{
- static std::string fmt(const RValue<Float>& v) { return "[%f]"; }
- static std::vector<Value*> val(const RValue<Float>& v);
+ static std::string fmt(const RValue<Float> &v) { return "[%f]"; }
+ static std::vector<Value *> val(const RValue<Float> &v);
};
-template <> struct PrintValue::Ty<Float4>
+template<>
+struct PrintValue::Ty<Float4>
{
- static std::string fmt(const RValue<Float4>& v) { return "[%f, %f, %f, %f]"; }
- static std::vector<Value*> val(const RValue<Float4>& v);
+ static std::string fmt(const RValue<Float4> &v) { return "[%f, %f, %f, %f]"; }
+ static std::vector<Value *> val(const RValue<Float4> &v);
};
-template <> struct PrintValue::Ty<Long>
+template<>
+struct PrintValue::Ty<Long>
{
- static std::string fmt(const RValue<Long>& v) { return "%lld"; }
- static std::vector<Value*> val(const RValue<Long>& v) { return {v.value}; }
+ static std::string fmt(const RValue<Long> &v) { return "%lld"; }
+ static std::vector<Value *> val(const RValue<Long> &v) { return { v.value }; }
};
-template <typename T> struct PrintValue::Ty< Pointer<T> >
+template<typename T>
+struct PrintValue::Ty<Pointer<T>>
{
- static std::string fmt(const RValue<Pointer<T>>& v) { return "%p"; }
- static std::vector<Value*> val(const RValue<Pointer<T>>& v) { return {v.value}; }
+ static std::string fmt(const RValue<Pointer<T>> &v) { return "%p"; }
+ static std::vector<Value *> val(const RValue<Pointer<T>> &v) { return { v.value }; }
};
-template <typename T> struct PrintValue::Ty< Reference<T> >
+template<typename T>
+struct PrintValue::Ty<Reference<T>>
{
- static std::string fmt(const Reference<T>& v) { return PrintValue::Ty<T>::fmt(v); }
- static std::vector<Value*> val(const Reference<T>& v) { return PrintValue::Ty<T>::val(v); }
+ static std::string fmt(const Reference<T> &v) { return PrintValue::Ty<T>::fmt(v); }
+ static std::vector<Value *> val(const Reference<T> &v) { return PrintValue::Ty<T>::val(v); }
};
-template <typename T> struct PrintValue::Ty< RValue<T> >
+template<typename T>
+struct PrintValue::Ty<RValue<T>>
{
- static std::string fmt(const RValue<T>& v) { return PrintValue::Ty<T>::fmt(v); }
- static std::vector<Value*> val(const RValue<T>& v) { return PrintValue::Ty<T>::val(v); }
+ static std::string fmt(const RValue<T> &v) { return PrintValue::Ty<T>::fmt(v); }
+ static std::vector<Value *> val(const RValue<T> &v) { return PrintValue::Ty<T>::val(v); }
};
// Printv emits a call to printf() using the function, file and line,
// message and optional values.
// See Printv below.
-void Printv(const char* function, const char* file, int line, const char* msg, std::initializer_list<PrintValue> vals);
+void Printv(const char *function, const char *file, int line, const char *msg, std::initializer_list<PrintValue> vals);
// Printv emits a call to printf() using the provided message and optional
// values.
@@ -291,22 +353,25 @@
// "red and green"
// Arguments can be indexed in any order.
// Invalid indices are not substituted.
-inline void Printv(const char* msg, std::initializer_list<PrintValue> vals)
+inline void Printv(const char *msg, std::initializer_list<PrintValue> vals)
{
Printv(nullptr, nullptr, 0, msg, vals);
}
// Print is a wrapper over Printv that wraps the variadic arguments into an
// initializer_list before calling Printv.
-template <typename ... ARGS>
-void Print(const char* msg, const ARGS& ... vals) { Printv(msg, {vals...}); }
+template<typename... ARGS>
+void Print(const char *msg, const ARGS &... vals)
+{
+ Printv(msg, { vals... });
+}
// Print is a wrapper over Printv that wraps the variadic arguments into an
// initializer_list before calling Printv.
-template <typename ... ARGS>
-void Print(const char* function, const char* file, int line, const char* msg, const ARGS& ... vals)
+template<typename... ARGS>
+void Print(const char *function, const char *file, int line, const char *msg, const ARGS &... vals)
{
- Printv(function, file, line, msg, {vals...});
+ Printv(function, file, line, msg, { vals... });
}
// RR_LOG is a macro that calls Print(), automatically populating the
@@ -314,19 +379,19 @@
//
// RR_LOG() is intended to be used for debugging JIT compiled code, and is
// not intended for production use.
-#if defined(_WIN32)
- #define RR_LOG(msg, ...) Print(__FUNCSIG__, __FILE__, static_cast<int>(__LINE__), msg "\n", ##__VA_ARGS__)
-#else
- #define RR_LOG(msg, ...) Print(__PRETTY_FUNCTION__, __FILE__, static_cast<int>(__LINE__), msg "\n", ##__VA_ARGS__)
-#endif
+# if defined(_WIN32)
+# define RR_LOG(msg, ...) Print(__FUNCSIG__, __FILE__, static_cast<int>(__LINE__), msg "\n", ##__VA_ARGS__)
+# else
+# define RR_LOG(msg, ...) Print(__PRETTY_FUNCTION__, __FILE__, static_cast<int>(__LINE__), msg "\n", ##__VA_ARGS__)
+# endif
// Macro magic to perform variadic dispatch.
// See: https://renenyffenegger.ch/notes/development/languages/C-C-plus-plus/preprocessor/macros/__VA_ARGS__/count-arguments
// Note, this doesn't attempt to use the ##__VA_ARGS__ trick to handle 0
-#define RR_MSVC_EXPAND_BUG(X) X // Helper macro to force expanding __VA_ARGS__ to satisfy MSVC compiler.
-#define RR_GET_NTH_ARG(_1, _2, _3, _4, _5, _6, _7, _8, _9, _10, _11, _12, _13, _14, _15, _16, N, ...) N
-#define RR_COUNT_ARGUMENTS(...) RR_MSVC_EXPAND_BUG(RR_GET_NTH_ARG(__VA_ARGS__, 16, 15, 14, 13, 12, 11, 10, 9, 8, 7, 6, 5, 4, 3, 2, 1, 0))
-static_assert(1 == RR_COUNT_ARGUMENTS(a), "RR_COUNT_ARGUMENTS broken"); // Sanity checks.
+# define RR_MSVC_EXPAND_BUG(X) X // Helper macro to force expanding __VA_ARGS__ to satisfy MSVC compiler.
+# define RR_GET_NTH_ARG(_1, _2, _3, _4, _5, _6, _7, _8, _9, _10, _11, _12, _13, _14, _15, _16, N, ...) N
+# define RR_COUNT_ARGUMENTS(...) RR_MSVC_EXPAND_BUG(RR_GET_NTH_ARG(__VA_ARGS__, 16, 15, 14, 13, 12, 11, 10, 9, 8, 7, 6, 5, 4, 3, 2, 1, 0))
+static_assert(1 == RR_COUNT_ARGUMENTS(a), "RR_COUNT_ARGUMENTS broken"); // Sanity checks.
static_assert(2 == RR_COUNT_ARGUMENTS(a, b), "RR_COUNT_ARGUMENTS broken");
static_assert(3 == RR_COUNT_ARGUMENTS(a, b, c), "RR_COUNT_ARGUMENTS broken");
@@ -336,21 +401,43 @@
//
// RR_WATCH_FMT(...) uses the RR_COUNT_ARGUMENTS helper macro to delegate to a
// corresponding RR_WATCH_FMT_n specialization macro below.
-#define RR_WATCH_CONCAT(a, b) a ## b
-#define RR_WATCH_CONCAT2(a, b) RR_WATCH_CONCAT(a, b)
-#define RR_WATCH_FMT(...) RR_MSVC_EXPAND_BUG(RR_WATCH_CONCAT2(RR_WATCH_FMT_, RR_COUNT_ARGUMENTS(__VA_ARGS__))(__VA_ARGS__))
-#define RR_WATCH_FMT_1(_1) "\n " #_1 ": {0}"
-#define RR_WATCH_FMT_2(_1, _2) RR_WATCH_FMT_1(_1) "\n " #_2 ": {1}"
-#define RR_WATCH_FMT_3(_1, _2, _3) RR_WATCH_FMT_2(_1, _2) "\n " #_3 ": {2}"
-#define RR_WATCH_FMT_4(_1, _2, _3, _4) RR_WATCH_FMT_3(_1, _2, _3) "\n " #_4 ": {3}"
-#define RR_WATCH_FMT_5(_1, _2, _3, _4, _5) RR_WATCH_FMT_4(_1, _2, _3, _4) "\n " #_5 ": {4}"
-#define RR_WATCH_FMT_6(_1, _2, _3, _4, _5, _6) RR_WATCH_FMT_5(_1, _2, _3, _4, _5) "\n " #_6 ": {5}"
-#define RR_WATCH_FMT_7(_1, _2, _3, _4, _5, _6, _7) RR_WATCH_FMT_6(_1, _2, _3, _4, _5, _6) "\n " #_7 ": {6}"
-#define RR_WATCH_FMT_8(_1, _2, _3, _4, _5, _6, _7, _8) RR_WATCH_FMT_7(_1, _2, _3, _4, _5, _6, _7) "\n " #_8 ": {7}"
-#define RR_WATCH_FMT_9(_1, _2, _3, _4, _5, _6, _7, _8, _9) RR_WATCH_FMT_8(_1, _2, _3, _4, _5, _6, _7, _8) "\n " #_9 ": {8}"
-#define RR_WATCH_FMT_10(_1, _2, _3, _4, _5, _6, _7, _8, _9, _10) RR_WATCH_FMT_9(_1, _2, _3, _4, _5, _6, _7, _8, _9) "\n " #_10 ": {9}"
-#define RR_WATCH_FMT_11(_1, _2, _3, _4, _5, _6, _7, _8, _9, _10, _11) RR_WATCH_FMT_10(_1, _2, _3, _4, _5, _6, _7, _8, _9, _10) "\n " #_11 ": {10}"
-#define RR_WATCH_FMT_12(_1, _2, _3, _4, _5, _6, _7, _8, _9, _10, _11, _12) RR_WATCH_FMT_11(_1, _2, _3, _4, _5, _6, _7, _8, _9, _10, _11) "\n " #_12 ": {11}"
+# define RR_WATCH_CONCAT(a, b) a##b
+# define RR_WATCH_CONCAT2(a, b) RR_WATCH_CONCAT(a, b)
+# define RR_WATCH_FMT(...) RR_MSVC_EXPAND_BUG(RR_WATCH_CONCAT2(RR_WATCH_FMT_, RR_COUNT_ARGUMENTS(__VA_ARGS__))(__VA_ARGS__))
+# define RR_WATCH_FMT_1(_1) "\n " # _1 ": {0}"
+# define RR_WATCH_FMT_2(_1, _2) \
+ RR_WATCH_FMT_1(_1) \
+ "\n " #_2 ": {1}"
+# define RR_WATCH_FMT_3(_1, _2, _3) \
+ RR_WATCH_FMT_2(_1, _2) \
+ "\n " #_3 ": {2}"
+# define RR_WATCH_FMT_4(_1, _2, _3, _4) \
+ RR_WATCH_FMT_3(_1, _2, _3) \
+ "\n " #_4 ": {3}"
+# define RR_WATCH_FMT_5(_1, _2, _3, _4, _5) \
+ RR_WATCH_FMT_4(_1, _2, _3, _4) \
+ "\n " #_5 ": {4}"
+# define RR_WATCH_FMT_6(_1, _2, _3, _4, _5, _6) \
+ RR_WATCH_FMT_5(_1, _2, _3, _4, _5) \
+ "\n " #_6 ": {5}"
+# define RR_WATCH_FMT_7(_1, _2, _3, _4, _5, _6, _7) \
+ RR_WATCH_FMT_6(_1, _2, _3, _4, _5, _6) \
+ "\n " #_7 ": {6}"
+# define RR_WATCH_FMT_8(_1, _2, _3, _4, _5, _6, _7, _8) \
+ RR_WATCH_FMT_7(_1, _2, _3, _4, _5, _6, _7) \
+ "\n " #_8 ": {7}"
+# define RR_WATCH_FMT_9(_1, _2, _3, _4, _5, _6, _7, _8, _9) \
+ RR_WATCH_FMT_8(_1, _2, _3, _4, _5, _6, _7, _8) \
+ "\n " #_9 ": {8}"
+# define RR_WATCH_FMT_10(_1, _2, _3, _4, _5, _6, _7, _8, _9, _10) \
+ RR_WATCH_FMT_9(_1, _2, _3, _4, _5, _6, _7, _8, _9) \
+ "\n " #_10 ": {9}"
+# define RR_WATCH_FMT_11(_1, _2, _3, _4, _5, _6, _7, _8, _9, _10, _11) \
+ RR_WATCH_FMT_10(_1, _2, _3, _4, _5, _6, _7, _8, _9, _10) \
+ "\n " #_11 ": {10}"
+# define RR_WATCH_FMT_12(_1, _2, _3, _4, _5, _6, _7, _8, _9, _10, _11, _12) \
+ RR_WATCH_FMT_11(_1, _2, _3, _4, _5, _6, _7, _8, _9, _10, _11) \
+ "\n " #_12 ": {11}"
// RR_WATCH() is a helper that prints the name and value of all the supplied
// arguments.
@@ -362,7 +449,7 @@
//
// RR_WATCH() is intended to be used for debugging JIT compiled code, and
// is not intended for production use.
-#define RR_WATCH(...) RR_LOG(RR_WATCH_FMT(__VA_ARGS__), __VA_ARGS__)
+# define RR_WATCH(...) RR_LOG(RR_WATCH_FMT(__VA_ARGS__), __VA_ARGS__)
} // namespace rr
diff --git a/src/Reactor/Reactor.cpp b/src/Reactor/Reactor.cpp
index c088e7b..fe8e103 100644
--- a/src/Reactor/Reactor.cpp
+++ b/src/Reactor/Reactor.cpp
@@ -20,19 +20,21 @@
// Define REACTOR_MATERIALIZE_LVALUES_ON_DEFINITION to non-zero to ensure all
// variables have a stack location obtained throuch alloca().
#ifndef REACTOR_MATERIALIZE_LVALUES_ON_DEFINITION
-#define REACTOR_MATERIALIZE_LVALUES_ON_DEFINITION 0
+# define REACTOR_MATERIALIZE_LVALUES_ON_DEFINITION 0
#endif
namespace {
// Introduced in C++20.
-template <class ForwardIterator, class UnaryPredicate>
+template<class ForwardIterator, class UnaryPredicate>
ForwardIterator remove_if(ForwardIterator first, ForwardIterator last,
- UnaryPredicate pred)
+ UnaryPredicate pred)
{
ForwardIterator result = first;
- while(first!=last) {
- if(!pred(*first)) {
+ while(first != last)
+ {
+ if(!pred(*first))
+ {
*result = std::move(*first);
++result;
}
@@ -54,39 +56,41 @@
auto level = optLevelChanged ? optLevel : cfg.optimization.getLevel();
auto passes = cfg.optimization.getPasses();
apply(optPassEdits, passes);
- return Config{ Optimization{level, passes} };
+ return Config{ Optimization{ level, passes } };
}
-template <typename T>
-void rr::Config::Edit::apply(const std::vector<std::pair<ListEdit, T>> & edits, std::vector<T>& list) const
+template<typename T>
+void rr::Config::Edit::apply(const std::vector<std::pair<ListEdit, T>> &edits, std::vector<T> &list) const
{
- for(auto & edit : edits)
+ for(auto &edit : edits)
{
switch(edit.first)
{
- case ListEdit::Add:
- list.push_back(edit.second);
- break;
- case ListEdit::Remove:
- ::remove_if(list.begin(), list.end(), [&](T item) { return item == edit.second; });
- break;
- case ListEdit::Clear:
- list.clear();
- break;
+ case ListEdit::Add:
+ list.push_back(edit.second);
+ break;
+ case ListEdit::Remove:
+ ::remove_if(list.begin(), list.end(), [&](T item) { return item == edit.second; });
+ break;
+ case ListEdit::Clear:
+ list.clear();
+ break;
}
}
}
// Set of variables that do not have a stack location yet.
-std::unordered_set<Variable*> Variable::unmaterializedVariables;
+std::unordered_set<Variable *> Variable::unmaterializedVariables;
-Variable::Variable(Type *type, int arraySize) : arraySize(arraySize), type(type)
+Variable::Variable(Type *type, int arraySize)
+ : arraySize(arraySize)
+ , type(type)
{
- #if REACTOR_MATERIALIZE_LVALUES_ON_DEFINITION
- materialize();
- #else
- unmaterializedVariables.emplace(this);
- #endif
+#if REACTOR_MATERIALIZE_LVALUES_ON_DEFINITION
+ materialize();
+#else
+ unmaterializedVariables.emplace(this);
+#endif
}
Variable::~Variable()
@@ -126,12 +130,11 @@
//
static Value *createBlend4(Value *lhs, Value *rhs, uint16_t select)
{
- int swizzle[4] =
- {
+ int swizzle[4] = {
(select >> 12) & 0x07,
- (select >> 8) & 0x07,
- (select >> 4) & 0x07,
- (select >> 0) & 0x07,
+ (select >> 8) & 0x07,
+ (select >> 4) & 0x07,
+ (select >> 0) & 0x07,
};
return Nucleus::createShuffleVector(lhs, rhs, swizzle);
@@ -153,12 +156,11 @@
//
static Value *createSwizzle4(Value *val, uint16_t select)
{
- int swizzle[4] =
- {
+ int swizzle[4] = {
(select >> 12) & 0x03,
- (select >> 8) & 0x03,
- (select >> 4) & 0x03,
- (select >> 0) & 0x03,
+ (select >> 8) & 0x03,
+ (select >> 4) & 0x03,
+ (select >> 0) & 0x03,
};
return Nucleus::createShuffleVector(val, val, swizzle);
@@ -166,15 +168,14 @@
static Value *createMask4(Value *lhs, Value *rhs, uint16_t select)
{
- bool mask[4] = {false, false, false, false};
+ bool mask[4] = { false, false, false, false };
mask[(select >> 12) & 0x03] = true;
- mask[(select >> 8) & 0x03] = true;
- mask[(select >> 4) & 0x03] = true;
- mask[(select >> 0) & 0x03] = true;
+ mask[(select >> 8) & 0x03] = true;
+ mask[(select >> 4) & 0x03] = true;
+ mask[(select >> 0) & 0x03] = true;
- int swizzle[4] =
- {
+ int swizzle[4] = {
mask[0] ? 4 : 0,
mask[1] ? 5 : 1,
mask[2] ? 6 : 2,
@@ -450,7 +451,7 @@
return RValue<Byte>(Nucleus::createNot(val.value));
}
-RValue<Byte> operator++(Byte &val, int) // Post-increment
+RValue<Byte> operator++(Byte &val, int) // Post-increment
{
RValue<Byte> res = val;
@@ -460,7 +461,7 @@
return res;
}
-const Byte &operator++(Byte &val) // Pre-increment
+const Byte &operator++(Byte &val) // Pre-increment
{
Value *inc = Nucleus::createAdd(val.loadValue(), Nucleus::createConstantByte((unsigned char)1));
val.storeValue(inc);
@@ -468,7 +469,7 @@
return val;
}
-RValue<Byte> operator--(Byte &val, int) // Post-decrement
+RValue<Byte> operator--(Byte &val, int) // Post-decrement
{
RValue<Byte> res = val;
@@ -478,7 +479,7 @@
return res;
}
-const Byte &operator--(Byte &val) // Pre-decrement
+const Byte &operator--(Byte &val) // Pre-decrement
{
Value *inc = Nucleus::createSub(val.loadValue(), Nucleus::createConstantByte((unsigned char)1));
val.storeValue(inc);
@@ -695,7 +696,7 @@
return RValue<SByte>(Nucleus::createNot(val.value));
}
-RValue<SByte> operator++(SByte &val, int) // Post-increment
+RValue<SByte> operator++(SByte &val, int) // Post-increment
{
RValue<SByte> res = val;
@@ -705,7 +706,7 @@
return res;
}
-const SByte &operator++(SByte &val) // Pre-increment
+const SByte &operator++(SByte &val) // Pre-increment
{
Value *inc = Nucleus::createAdd(val.loadValue(), Nucleus::createConstantByte((signed char)1));
val.storeValue(inc);
@@ -713,7 +714,7 @@
return val;
}
-RValue<SByte> operator--(SByte &val, int) // Post-decrement
+RValue<SByte> operator--(SByte &val, int) // Post-decrement
{
RValue<SByte> res = val;
@@ -723,7 +724,7 @@
return res;
}
-const SByte &operator--(SByte &val) // Pre-decrement
+const SByte &operator--(SByte &val) // Pre-decrement
{
Value *inc = Nucleus::createSub(val.loadValue(), Nucleus::createConstantByte((signed char)1));
val.storeValue(inc);
@@ -933,7 +934,7 @@
return RValue<Short>(Nucleus::createNot(val.value));
}
-RValue<Short> operator++(Short &val, int) // Post-increment
+RValue<Short> operator++(Short &val, int) // Post-increment
{
RValue<Short> res = val;
@@ -943,7 +944,7 @@
return res;
}
-const Short &operator++(Short &val) // Pre-increment
+const Short &operator++(Short &val) // Pre-increment
{
Value *inc = Nucleus::createAdd(val.loadValue(), Nucleus::createConstantShort((short)1));
val.storeValue(inc);
@@ -951,7 +952,7 @@
return val;
}
-RValue<Short> operator--(Short &val, int) // Post-decrement
+RValue<Short> operator--(Short &val, int) // Post-decrement
{
RValue<Short> res = val;
@@ -961,7 +962,7 @@
return res;
}
-const Short &operator--(Short &val) // Pre-decrement
+const Short &operator--(Short &val) // Pre-decrement
{
Value *inc = Nucleus::createSub(val.loadValue(), Nucleus::createConstantShort((short)1));
val.storeValue(inc);
@@ -1178,7 +1179,7 @@
return RValue<UShort>(Nucleus::createNot(val.value));
}
-RValue<UShort> operator++(UShort &val, int) // Post-increment
+RValue<UShort> operator++(UShort &val, int) // Post-increment
{
RValue<UShort> res = val;
@@ -1188,7 +1189,7 @@
return res;
}
-const UShort &operator++(UShort &val) // Pre-increment
+const UShort &operator++(UShort &val) // Pre-increment
{
Value *inc = Nucleus::createAdd(val.loadValue(), Nucleus::createConstantShort((unsigned short)1));
val.storeValue(inc);
@@ -1196,7 +1197,7 @@
return val;
}
-RValue<UShort> operator--(UShort &val, int) // Post-decrement
+RValue<UShort> operator--(UShort &val, int) // Post-decrement
{
RValue<UShort> res = val;
@@ -1206,7 +1207,7 @@
return res;
}
-const UShort &operator--(UShort &val) // Pre-decrement
+const UShort &operator--(UShort &val) // Pre-decrement
{
Value *inc = Nucleus::createSub(val.loadValue(), Nucleus::createConstantShort((unsigned short)1));
val.storeValue(inc);
@@ -1257,7 +1258,7 @@
Byte8::Byte8(uint8_t x0, uint8_t x1, uint8_t x2, uint8_t x3, uint8_t x4, uint8_t x5, uint8_t x6, uint8_t x7)
{
- int64_t constantVector[8] = {x0, x1, x2, x3, x4, x5, x6, x7};
+ int64_t constantVector[8] = { x0, x1, x2, x3, x4, x5, x6, x7 };
storeValue(Nucleus::createConstantVector(constantVector, getType()));
}
@@ -1418,7 +1419,7 @@
RValue<Short4> Unpack(RValue<Byte4> x)
{
- int shuffle[16] = {0, 0, 1, 1, 2, 2, 3, 3, 4, 4, 5, 5, 6, 6, 7, 7}; // Real type is v16i8
+ int shuffle[16] = { 0, 0, 1, 1, 2, 2, 3, 3, 4, 4, 5, 5, 6, 6, 7, 7 }; // Real type is v16i8
return As<Short4>(Nucleus::createShuffleVector(x.value, x.value, shuffle));
}
@@ -1429,20 +1430,20 @@
RValue<Short4> UnpackLow(RValue<Byte8> x, RValue<Byte8> y)
{
- int shuffle[16] = {0, 16, 1, 17, 2, 18, 3, 19, 4, 20, 5, 21, 6, 22, 7, 23}; // Real type is v16i8
+ int shuffle[16] = { 0, 16, 1, 17, 2, 18, 3, 19, 4, 20, 5, 21, 6, 22, 7, 23 }; // Real type is v16i8
return As<Short4>(Nucleus::createShuffleVector(x.value, y.value, shuffle));
}
RValue<Short4> UnpackHigh(RValue<Byte8> x, RValue<Byte8> y)
{
- int shuffle[16] = {0, 16, 1, 17, 2, 18, 3, 19, 4, 20, 5, 21, 6, 22, 7, 23}; // Real type is v16i8
+ int shuffle[16] = { 0, 16, 1, 17, 2, 18, 3, 19, 4, 20, 5, 21, 6, 22, 7, 23 }; // Real type is v16i8
auto lowHigh = RValue<Byte16>(Nucleus::createShuffleVector(x.value, y.value, shuffle));
return As<Short4>(Swizzle(As<Int4>(lowHigh), 0x2323));
}
SByte8::SByte8(uint8_t x0, uint8_t x1, uint8_t x2, uint8_t x3, uint8_t x4, uint8_t x5, uint8_t x6, uint8_t x7)
{
- int64_t constantVector[8] = {x0, x1, x2, x3, x4, x5, x6, x7};
+ int64_t constantVector[8] = { x0, x1, x2, x3, x4, x5, x6, x7 };
Value *vector = Nucleus::createConstantVector(constantVector, getType());
storeValue(Nucleus::createBitCast(vector, getType()));
@@ -1605,13 +1606,13 @@
RValue<Short4> UnpackLow(RValue<SByte8> x, RValue<SByte8> y)
{
- int shuffle[16] = {0, 16, 1, 17, 2, 18, 3, 19, 4, 20, 5, 21, 6, 22, 7, 23}; // Real type is v16i8
+ int shuffle[16] = { 0, 16, 1, 17, 2, 18, 3, 19, 4, 20, 5, 21, 6, 22, 7, 23 }; // Real type is v16i8
return As<Short4>(Nucleus::createShuffleVector(x.value, y.value, shuffle));
}
RValue<Short4> UnpackHigh(RValue<SByte8> x, RValue<SByte8> y)
{
- int shuffle[16] = {0, 16, 1, 17, 2, 18, 3, 19, 4, 20, 5, 21, 6, 22, 7, 23}; // Real type is v16i8
+ int shuffle[16] = { 0, 16, 1, 17, 2, 18, 3, 19, 4, 20, 5, 21, 6, 22, 7, 23 }; // Real type is v16i8
auto lowHigh = RValue<Byte16>(Nucleus::createShuffleVector(x.value, y.value, shuffle));
return As<Short4>(Swizzle(As<Int4>(lowHigh), 0x2323));
}
@@ -1682,13 +1683,13 @@
Short4::Short4(short xyzw)
{
- int64_t constantVector[4] = {xyzw, xyzw, xyzw, xyzw};
+ int64_t constantVector[4] = { xyzw, xyzw, xyzw, xyzw };
storeValue(Nucleus::createConstantVector(constantVector, getType()));
}
Short4::Short4(short x, short y, short z, short w)
{
- int64_t constantVector[4] = {x, y, z, w};
+ int64_t constantVector[4] = { x, y, z, w };
storeValue(Nucleus::createConstantVector(constantVector, getType()));
}
@@ -1883,13 +1884,13 @@
RValue<Int2> UnpackLow(RValue<Short4> x, RValue<Short4> y)
{
- int shuffle[8] = {0, 8, 1, 9, 2, 10, 3, 11}; // Real type is v8i16
+ int shuffle[8] = { 0, 8, 1, 9, 2, 10, 3, 11 }; // Real type is v8i16
return As<Int2>(Nucleus::createShuffleVector(x.value, y.value, shuffle));
}
RValue<Int2> UnpackHigh(RValue<Short4> x, RValue<Short4> y)
{
- int shuffle[8] = {0, 8, 1, 9, 2, 10, 3, 11}; // Real type is v8i16
+ int shuffle[8] = { 0, 8, 1, 9, 2, 10, 3, 11 }; // Real type is v8i16
auto lowHigh = RValue<Short8>(Nucleus::createShuffleVector(x.value, y.value, shuffle));
return As<Int2>(Swizzle(As<Int4>(lowHigh), 0x2323));
}
@@ -1897,16 +1898,15 @@
RValue<Short4> Swizzle(RValue<Short4> x, uint16_t select)
{
// Real type is v8i16
- int shuffle[8] =
- {
+ int shuffle[8] = {
(select >> 12) & 0x03,
- (select >> 8) & 0x03,
- (select >> 4) & 0x03,
- (select >> 0) & 0x03,
+ (select >> 8) & 0x03,
+ (select >> 4) & 0x03,
+ (select >> 0) & 0x03,
(select >> 12) & 0x03,
- (select >> 8) & 0x03,
- (select >> 4) & 0x03,
- (select >> 0) & 0x03,
+ (select >> 8) & 0x03,
+ (select >> 4) & 0x03,
+ (select >> 0) & 0x03,
};
return As<Short4>(Nucleus::createShuffleVector(x.value, x.value, shuffle));
@@ -1929,13 +1929,13 @@
UShort4::UShort4(unsigned short xyzw)
{
- int64_t constantVector[4] = {xyzw, xyzw, xyzw, xyzw};
+ int64_t constantVector[4] = { xyzw, xyzw, xyzw, xyzw };
storeValue(Nucleus::createConstantVector(constantVector, getType()));
}
UShort4::UShort4(unsigned short x, unsigned short y, unsigned short z, unsigned short w)
{
- int64_t constantVector[4] = {x, y, z, w};
+ int64_t constantVector[4] = { x, y, z, w };
storeValue(Nucleus::createConstantVector(constantVector, getType()));
}
@@ -2066,13 +2066,13 @@
Short8::Short8(short c)
{
- int64_t constantVector[8] = {c, c, c, c, c, c, c, c};
+ int64_t constantVector[8] = { c, c, c, c, c, c, c, c };
storeValue(Nucleus::createConstantVector(constantVector, getType()));
}
Short8::Short8(short c0, short c1, short c2, short c3, short c4, short c5, short c6, short c7)
{
- int64_t constantVector[8] = {c0, c1, c2, c3, c4, c5, c6, c7};
+ int64_t constantVector[8] = { c0, c1, c2, c3, c4, c5, c6, c7 };
storeValue(Nucleus::createConstantVector(constantVector, getType()));
}
@@ -2089,7 +2089,7 @@
Short8::Short8(RValue<Short4> lo, RValue<Short4> hi)
{
- int shuffle[8] = {0, 1, 2, 3, 8, 9, 10, 11}; // Real type is v8i16
+ int shuffle[8] = { 0, 1, 2, 3, 8, 9, 10, 11 }; // Real type is v8i16
Value *packed = Nucleus::createShuffleVector(lo.value, hi.value, shuffle);
storeValue(packed);
@@ -2137,13 +2137,13 @@
UShort8::UShort8(unsigned short c)
{
- int64_t constantVector[8] = {c, c, c, c, c, c, c, c};
+ int64_t constantVector[8] = { c, c, c, c, c, c, c, c };
storeValue(Nucleus::createConstantVector(constantVector, getType()));
}
UShort8::UShort8(unsigned short c0, unsigned short c1, unsigned short c2, unsigned short c3, unsigned short c4, unsigned short c5, unsigned short c6, unsigned short c7)
{
- int64_t constantVector[8] = {c0, c1, c2, c3, c4, c5, c6, c7};
+ int64_t constantVector[8] = { c0, c1, c2, c3, c4, c5, c6, c7 };
storeValue(Nucleus::createConstantVector(constantVector, getType()));
}
@@ -2160,7 +2160,7 @@
UShort8::UShort8(RValue<UShort4> lo, RValue<UShort4> hi)
{
- int shuffle[8] = {0, 1, 2, 3, 8, 9, 10, 11}; // Real type is v8i16
+ int shuffle[8] = { 0, 1, 2, 3, 8, 9, 10, 11 }; // Real type is v8i16
Value *packed = Nucleus::createShuffleVector(lo.value, hi.value, shuffle);
storeValue(packed);
@@ -2593,62 +2593,62 @@
return lhs = lhs - rhs;
}
-RValue<Long> AddAtomic(RValue<Pointer<Long> > x, RValue<Long> y)
+RValue<Long> AddAtomic(RValue<Pointer<Long>> x, RValue<Long> y)
{
return RValue<Long>(Nucleus::createAtomicAdd(x.value, y.value));
}
-RValue<UInt> AddAtomic(RValue<Pointer<UInt> > x, RValue<UInt> y, std::memory_order memoryOrder)
+RValue<UInt> AddAtomic(RValue<Pointer<UInt>> x, RValue<UInt> y, std::memory_order memoryOrder)
{
return RValue<UInt>(Nucleus::createAtomicAdd(x.value, y.value, memoryOrder));
}
-RValue<UInt> SubAtomic(RValue<Pointer<UInt> > x, RValue<UInt> y, std::memory_order memoryOrder)
+RValue<UInt> SubAtomic(RValue<Pointer<UInt>> x, RValue<UInt> y, std::memory_order memoryOrder)
{
return RValue<UInt>(Nucleus::createAtomicSub(x.value, y.value, memoryOrder));
}
-RValue<UInt> AndAtomic(RValue<Pointer<UInt> > x, RValue<UInt> y, std::memory_order memoryOrder)
+RValue<UInt> AndAtomic(RValue<Pointer<UInt>> x, RValue<UInt> y, std::memory_order memoryOrder)
{
return RValue<UInt>(Nucleus::createAtomicAnd(x.value, y.value, memoryOrder));
}
-RValue<UInt> OrAtomic(RValue<Pointer<UInt> > x, RValue<UInt> y, std::memory_order memoryOrder)
+RValue<UInt> OrAtomic(RValue<Pointer<UInt>> x, RValue<UInt> y, std::memory_order memoryOrder)
{
return RValue<UInt>(Nucleus::createAtomicOr(x.value, y.value, memoryOrder));
}
-RValue<UInt> XorAtomic(RValue<Pointer<UInt> > x, RValue<UInt> y, std::memory_order memoryOrder)
+RValue<UInt> XorAtomic(RValue<Pointer<UInt>> x, RValue<UInt> y, std::memory_order memoryOrder)
{
return RValue<UInt>(Nucleus::createAtomicXor(x.value, y.value, memoryOrder));
}
-RValue<Int> MinAtomic(RValue<Pointer<Int> > x, RValue<Int> y, std::memory_order memoryOrder)
+RValue<Int> MinAtomic(RValue<Pointer<Int>> x, RValue<Int> y, std::memory_order memoryOrder)
{
return RValue<Int>(Nucleus::createAtomicMin(x.value, y.value, memoryOrder));
}
-RValue<UInt> MinAtomic(RValue<Pointer<UInt> > x, RValue<UInt> y, std::memory_order memoryOrder)
+RValue<UInt> MinAtomic(RValue<Pointer<UInt>> x, RValue<UInt> y, std::memory_order memoryOrder)
{
return RValue<UInt>(Nucleus::createAtomicUMin(x.value, y.value, memoryOrder));
}
-RValue<Int> MaxAtomic(RValue<Pointer<Int> > x, RValue<Int> y, std::memory_order memoryOrder)
+RValue<Int> MaxAtomic(RValue<Pointer<Int>> x, RValue<Int> y, std::memory_order memoryOrder)
{
return RValue<Int>(Nucleus::createAtomicMax(x.value, y.value, memoryOrder));
}
-RValue<UInt> MaxAtomic(RValue<Pointer<UInt> > x, RValue<UInt> y, std::memory_order memoryOrder)
+RValue<UInt> MaxAtomic(RValue<Pointer<UInt>> x, RValue<UInt> y, std::memory_order memoryOrder)
{
return RValue<UInt>(Nucleus::createAtomicUMax(x.value, y.value, memoryOrder));
}
-RValue<UInt> ExchangeAtomic(RValue<Pointer<UInt> > x, RValue<UInt> y, std::memory_order memoryOrder)
+RValue<UInt> ExchangeAtomic(RValue<Pointer<UInt>> x, RValue<UInt> y, std::memory_order memoryOrder)
{
return RValue<UInt>(Nucleus::createAtomicExchange(x.value, y.value, memoryOrder));
}
-RValue<UInt> CompareExchangeAtomic(RValue<Pointer<UInt> > x, RValue<UInt> y, RValue<UInt> compare, std::memory_order memoryOrderEqual, std::memory_order memoryOrderUnequal)
+RValue<UInt> CompareExchangeAtomic(RValue<Pointer<UInt>> x, RValue<UInt> y, RValue<UInt> compare, std::memory_order memoryOrderEqual, std::memory_order memoryOrderUnequal)
{
return RValue<UInt>(Nucleus::createAtomicCompareExchange(x.value, y.value, compare.value, memoryOrderEqual, memoryOrderUnequal));
}
@@ -2934,7 +2934,7 @@
Int2::Int2(int x, int y)
{
- int64_t constantVector[2] = {x, y};
+ int64_t constantVector[2] = { x, y };
storeValue(Nucleus::createConstantVector(constantVector, getType()));
}
@@ -2957,7 +2957,7 @@
Int2::Int2(RValue<Int> lo, RValue<Int> hi)
{
- int shuffle[4] = {0, 4, 1, 5};
+ int shuffle[4] = { 0, 4, 1, 5 };
Value *packed = Nucleus::createShuffleVector(Int4(lo).loadValue(), Int4(hi).loadValue(), shuffle);
storeValue(Nucleus::createBitCast(packed, Int2::getType()));
@@ -3093,13 +3093,13 @@
RValue<Short4> UnpackLow(RValue<Int2> x, RValue<Int2> y)
{
- int shuffle[4] = {0, 4, 1, 5}; // Real type is v4i32
+ int shuffle[4] = { 0, 4, 1, 5 }; // Real type is v4i32
return As<Short4>(Nucleus::createShuffleVector(x.value, y.value, shuffle));
}
RValue<Short4> UnpackHigh(RValue<Int2> x, RValue<Int2> y)
{
- int shuffle[4] = {0, 4, 1, 5}; // Real type is v4i32
+ int shuffle[4] = { 0, 4, 1, 5 }; // Real type is v4i32
auto lowHigh = RValue<Int4>(Nucleus::createShuffleVector(x.value, y.value, shuffle));
return As<Short4>(Swizzle(lowHigh, 0x2323));
}
@@ -3116,7 +3116,7 @@
UInt2::UInt2(unsigned int x, unsigned int y)
{
- int64_t constantVector[2] = {x, y};
+ int64_t constantVector[2] = { x, y };
storeValue(Nucleus::createConstantVector(constantVector, getType()));
}
@@ -3275,91 +3275,106 @@
return RValue<UInt2>(Nucleus::createInsertElement(val.value, element.value, i));
}
-Int4::Int4() : XYZW(this)
+Int4::Int4()
+ : XYZW(this)
{
}
-Int4::Int4(RValue<Float4> cast) : XYZW(this)
+Int4::Int4(RValue<Float4> cast)
+ : XYZW(this)
{
Value *xyzw = Nucleus::createFPToSI(cast.value, Int4::getType());
storeValue(xyzw);
}
-Int4::Int4(int xyzw) : XYZW(this)
+Int4::Int4(int xyzw)
+ : XYZW(this)
{
constant(xyzw, xyzw, xyzw, xyzw);
}
-Int4::Int4(int x, int yzw) : XYZW(this)
+Int4::Int4(int x, int yzw)
+ : XYZW(this)
{
constant(x, yzw, yzw, yzw);
}
-Int4::Int4(int x, int y, int zw) : XYZW(this)
+Int4::Int4(int x, int y, int zw)
+ : XYZW(this)
{
constant(x, y, zw, zw);
}
-Int4::Int4(int x, int y, int z, int w) : XYZW(this)
+Int4::Int4(int x, int y, int z, int w)
+ : XYZW(this)
{
constant(x, y, z, w);
}
void Int4::constant(int x, int y, int z, int w)
{
- int64_t constantVector[4] = {x, y, z, w};
+ int64_t constantVector[4] = { x, y, z, w };
storeValue(Nucleus::createConstantVector(constantVector, getType()));
}
-Int4::Int4(RValue<Int4> rhs) : XYZW(this)
+Int4::Int4(RValue<Int4> rhs)
+ : XYZW(this)
{
storeValue(rhs.value);
}
-Int4::Int4(const Int4 &rhs) : XYZW(this)
+Int4::Int4(const Int4 &rhs)
+ : XYZW(this)
{
Value *value = rhs.loadValue();
storeValue(value);
}
-Int4::Int4(const Reference<Int4> &rhs) : XYZW(this)
+Int4::Int4(const Reference<Int4> &rhs)
+ : XYZW(this)
{
Value *value = rhs.loadValue();
storeValue(value);
}
-Int4::Int4(RValue<UInt4> rhs) : XYZW(this)
+Int4::Int4(RValue<UInt4> rhs)
+ : XYZW(this)
{
storeValue(rhs.value);
}
-Int4::Int4(const UInt4 &rhs) : XYZW(this)
+Int4::Int4(const UInt4 &rhs)
+ : XYZW(this)
{
Value *value = rhs.loadValue();
storeValue(value);
}
-Int4::Int4(const Reference<UInt4> &rhs) : XYZW(this)
+Int4::Int4(const Reference<UInt4> &rhs)
+ : XYZW(this)
{
Value *value = rhs.loadValue();
storeValue(value);
}
-Int4::Int4(RValue<Int2> lo, RValue<Int2> hi) : XYZW(this)
+Int4::Int4(RValue<Int2> lo, RValue<Int2> hi)
+ : XYZW(this)
{
- int shuffle[4] = {0, 1, 4, 5}; // Real type is v4i32
+ int shuffle[4] = { 0, 1, 4, 5 }; // Real type is v4i32
Value *packed = Nucleus::createShuffleVector(lo.value, hi.value, shuffle);
storeValue(packed);
}
-Int4::Int4(const Int &rhs) : XYZW(this)
+Int4::Int4(const Int &rhs)
+ : XYZW(this)
{
*this = RValue<Int>(rhs.loadValue());
}
-Int4::Int4(const Reference<Int> &rhs) : XYZW(this)
+Int4::Int4(const Reference<Int> &rhs)
+ : XYZW(this)
{
*this = RValue<Int>(rhs.loadValue());
}
@@ -3522,84 +3537,98 @@
return RValue<Int4>(createBlend4(x.value, y.value, select));
}
-UInt4::UInt4() : XYZW(this)
+UInt4::UInt4()
+ : XYZW(this)
{
}
-UInt4::UInt4(int xyzw) : XYZW(this)
+UInt4::UInt4(int xyzw)
+ : XYZW(this)
{
constant(xyzw, xyzw, xyzw, xyzw);
}
-UInt4::UInt4(int x, int yzw) : XYZW(this)
+UInt4::UInt4(int x, int yzw)
+ : XYZW(this)
{
constant(x, yzw, yzw, yzw);
}
-UInt4::UInt4(int x, int y, int zw) : XYZW(this)
+UInt4::UInt4(int x, int y, int zw)
+ : XYZW(this)
{
constant(x, y, zw, zw);
}
-UInt4::UInt4(int x, int y, int z, int w) : XYZW(this)
+UInt4::UInt4(int x, int y, int z, int w)
+ : XYZW(this)
{
constant(x, y, z, w);
}
void UInt4::constant(int x, int y, int z, int w)
{
- int64_t constantVector[4] = {x, y, z, w};
+ int64_t constantVector[4] = { x, y, z, w };
storeValue(Nucleus::createConstantVector(constantVector, getType()));
}
-UInt4::UInt4(RValue<UInt4> rhs) : XYZW(this)
+UInt4::UInt4(RValue<UInt4> rhs)
+ : XYZW(this)
{
storeValue(rhs.value);
}
-UInt4::UInt4(const UInt4 &rhs) : XYZW(this)
+UInt4::UInt4(const UInt4 &rhs)
+ : XYZW(this)
{
Value *value = rhs.loadValue();
storeValue(value);
}
-UInt4::UInt4(const Reference<UInt4> &rhs) : XYZW(this)
+UInt4::UInt4(const Reference<UInt4> &rhs)
+ : XYZW(this)
{
Value *value = rhs.loadValue();
storeValue(value);
}
-UInt4::UInt4(RValue<Int4> rhs) : XYZW(this)
+UInt4::UInt4(RValue<Int4> rhs)
+ : XYZW(this)
{
storeValue(rhs.value);
}
-UInt4::UInt4(const Int4 &rhs) : XYZW(this)
+UInt4::UInt4(const Int4 &rhs)
+ : XYZW(this)
{
Value *value = rhs.loadValue();
storeValue(value);
}
-UInt4::UInt4(const Reference<Int4> &rhs) : XYZW(this)
+UInt4::UInt4(const Reference<Int4> &rhs)
+ : XYZW(this)
{
Value *value = rhs.loadValue();
storeValue(value);
}
-UInt4::UInt4(RValue<UInt2> lo, RValue<UInt2> hi) : XYZW(this)
+UInt4::UInt4(RValue<UInt2> lo, RValue<UInt2> hi)
+ : XYZW(this)
{
- int shuffle[4] = {0, 1, 4, 5}; // Real type is v4i32
+ int shuffle[4] = { 0, 1, 4, 5 }; // Real type is v4i32
Value *packed = Nucleus::createShuffleVector(lo.value, hi.value, shuffle);
storeValue(packed);
}
-UInt4::UInt4(const UInt &rhs) : XYZW(this)
+UInt4::UInt4(const UInt &rhs)
+ : XYZW(this)
{
*this = RValue<UInt>(rhs.loadValue());
}
-UInt4::UInt4(const Reference<UInt> &rhs) : XYZW(this)
+UInt4::UInt4(const Reference<UInt> &rhs)
+ : XYZW(this)
{
*this = RValue<UInt>(rhs.loadValue());
}
@@ -3766,15 +3795,15 @@
{
UInt fp32i = As<UInt>(cast);
UInt abs = fp32i & 0x7FFFFFFF;
- UShort fp16i((fp32i & 0x80000000) >> 16); // sign
+ UShort fp16i((fp32i & 0x80000000) >> 16); // sign
- If(abs > 0x47FFEFFF) // Infinity
+ If(abs > 0x47FFEFFF) // Infinity
{
fp16i |= UShort(0x7FFF);
}
Else
{
- If(abs < 0x38800000) // Denormal
+ If(abs < 0x38800000) // Denormal
{
Int mantissa = (abs & 0x007FFFFF) | 0x00800000;
Int e = 113 - (abs >> 23);
@@ -4004,7 +4033,8 @@
storeValue(Nucleus::createBitCast(cast.value, getType()));
}
-Float4::Float4(RValue<Byte4> cast) : XYZW(this)
+Float4::Float4(RValue<Byte4> cast)
+ : XYZW(this)
{
Value *a = Int4(cast).loadValue();
Value *xyzw = Nucleus::createSIToFP(a, Float4::getType());
@@ -4012,7 +4042,8 @@
storeValue(xyzw);
}
-Float4::Float4(RValue<SByte4> cast) : XYZW(this)
+Float4::Float4(RValue<SByte4> cast)
+ : XYZW(this)
{
Value *a = Int4(cast).loadValue();
Value *xyzw = Nucleus::createSIToFP(a, Float4::getType());
@@ -4020,26 +4051,30 @@
storeValue(xyzw);
}
-Float4::Float4(RValue<Short4> cast) : XYZW(this)
+Float4::Float4(RValue<Short4> cast)
+ : XYZW(this)
{
Int4 c(cast);
storeValue(Nucleus::createSIToFP(RValue<Int4>(c).value, Float4::getType()));
}
-Float4::Float4(RValue<UShort4> cast) : XYZW(this)
+Float4::Float4(RValue<UShort4> cast)
+ : XYZW(this)
{
Int4 c(cast);
storeValue(Nucleus::createSIToFP(RValue<Int4>(c).value, Float4::getType()));
}
-Float4::Float4(RValue<Int4> cast) : XYZW(this)
+Float4::Float4(RValue<Int4> cast)
+ : XYZW(this)
{
Value *xyzw = Nucleus::createSIToFP(cast.value, Float4::getType());
storeValue(xyzw);
}
-Float4::Float4(RValue<UInt4> cast) : XYZW(this)
+Float4::Float4(RValue<UInt4> cast)
+ : XYZW(this)
{
RValue<Float4> result = Float4(Int4(cast & UInt4(0x7FFFFFFF))) +
As<Float4>((As<Int4>(cast) >> 31) & As<Int4>(Float4(0x80000000u)));
@@ -4047,26 +4082,31 @@
storeValue(result.value);
}
-Float4::Float4() : XYZW(this)
+Float4::Float4()
+ : XYZW(this)
{
}
-Float4::Float4(float xyzw) : XYZW(this)
+Float4::Float4(float xyzw)
+ : XYZW(this)
{
constant(xyzw, xyzw, xyzw, xyzw);
}
-Float4::Float4(float x, float yzw) : XYZW(this)
+Float4::Float4(float x, float yzw)
+ : XYZW(this)
{
constant(x, yzw, yzw, yzw);
}
-Float4::Float4(float x, float y, float zw) : XYZW(this)
+Float4::Float4(float x, float y, float zw)
+ : XYZW(this)
{
constant(x, y, zw, zw);
}
-Float4::Float4(float x, float y, float z, float w) : XYZW(this)
+Float4::Float4(float x, float y, float z, float w)
+ : XYZW(this)
{
constant(x, y, z, w);
}
@@ -4088,7 +4128,7 @@
void Float4::infinity_constant(bool negative)
{
double inf = negative ? -INFINITY : INFINITY;
- double constantVector[4] = {inf, inf, inf, inf};
+ double constantVector[4] = { inf, inf, inf, inf };
storeValue(Nucleus::createConstantVector(constantVector, getType()));
}
@@ -4097,33 +4137,38 @@
// See Float(float) constructor for the rationale behind this assert.
ASSERT(std::isfinite(x) && std::isfinite(y) && std::isfinite(z) && std::isfinite(w));
- double constantVector[4] = {x, y, z, w};
+ double constantVector[4] = { x, y, z, w };
storeValue(Nucleus::createConstantVector(constantVector, getType()));
}
-Float4::Float4(RValue<Float4> rhs) : XYZW(this)
+Float4::Float4(RValue<Float4> rhs)
+ : XYZW(this)
{
storeValue(rhs.value);
}
-Float4::Float4(const Float4 &rhs) : XYZW(this)
+Float4::Float4(const Float4 &rhs)
+ : XYZW(this)
{
Value *value = rhs.loadValue();
storeValue(value);
}
-Float4::Float4(const Reference<Float4> &rhs) : XYZW(this)
+Float4::Float4(const Reference<Float4> &rhs)
+ : XYZW(this)
{
Value *value = rhs.loadValue();
storeValue(value);
}
-Float4::Float4(const Float &rhs) : XYZW(this)
+Float4::Float4(const Float &rhs)
+ : XYZW(this)
{
*this = RValue<Float>(rhs.loadValue());
}
-Float4::Float4(const Reference<Float> &rhs) : XYZW(this)
+Float4::Float4(const Reference<Float> &rhs)
+ : XYZW(this)
{
*this = RValue<Float>(rhs.loadValue());
}
@@ -4235,7 +4280,7 @@
{
// TODO: Optimize.
Value *vector = Nucleus::createBitCast(x.value, Int4::getType());
- int64_t constantVector[4] = {0x7FFFFFFF, 0x7FFFFFFF, 0x7FFFFFFF, 0x7FFFFFFF};
+ int64_t constantVector[4] = { 0x7FFFFFFF, 0x7FFFFFFF, 0x7FFFFFFF, 0x7FFFFFFF };
Value *result = Nucleus::createAnd(vector, Nucleus::createConstantVector(constantVector, Int4::getType()));
return As<Float4>(result);
@@ -4263,12 +4308,11 @@
RValue<Float4> ShuffleLowHigh(RValue<Float4> x, RValue<Float4> y, uint16_t imm)
{
- int shuffle[4] =
- {
+ int shuffle[4] = {
((imm >> 12) & 0x03) + 0,
- ((imm >> 8) & 0x03) + 0,
- ((imm >> 4) & 0x03) + 4,
- ((imm >> 0) & 0x03) + 4,
+ ((imm >> 8) & 0x03) + 0,
+ ((imm >> 4) & 0x03) + 4,
+ ((imm >> 0) & 0x03) + 4,
};
return RValue<Float4>(Nucleus::createShuffleVector(x.value, y.value, shuffle));
@@ -4276,13 +4320,13 @@
RValue<Float4> UnpackLow(RValue<Float4> x, RValue<Float4> y)
{
- int shuffle[4] = {0, 4, 1, 5};
+ int shuffle[4] = { 0, 4, 1, 5 };
return RValue<Float4>(Nucleus::createShuffleVector(x.value, y.value, shuffle));
}
RValue<Float4> UnpackHigh(RValue<Float4> x, RValue<Float4> y)
{
- int shuffle[4] = {2, 6, 3, 7};
+ int shuffle[4] = { 2, 6, 3, 7 };
return RValue<Float4>(Nucleus::createShuffleVector(x.value, y.value, shuffle));
}
@@ -4401,22 +4445,49 @@
void Fence(std::memory_order memoryOrder)
{
ASSERT_MSG(memoryOrder == std::memory_order_acquire ||
- memoryOrder == std::memory_order_release ||
- memoryOrder == std::memory_order_acq_rel ||
- memoryOrder == std::memory_order_seq_cst,
- "Unsupported memoryOrder: %d", int(memoryOrder));
+ memoryOrder == std::memory_order_release ||
+ memoryOrder == std::memory_order_acq_rel ||
+ memoryOrder == std::memory_order_seq_cst,
+ "Unsupported memoryOrder: %d", int(memoryOrder));
Nucleus::createFence(memoryOrder);
}
-Bool CToReactor<bool>::cast(bool v) { return type(v); }
-Byte CToReactor<uint8_t>::cast(uint8_t v) { return type(v); }
-SByte CToReactor<int8_t>::cast(int8_t v) { return type(v); }
-Short CToReactor<int16_t>::cast(int16_t v) { return type(v); }
-UShort CToReactor<uint16_t>::cast(uint16_t v) { return type(v); }
-Int CToReactor<int32_t>::cast(int32_t v) { return type(v); }
-UInt CToReactor<uint32_t>::cast(uint32_t v) { return type(v); }
-Float CToReactor<float>::cast(float v) { return type(v); }
-Float4 CToReactor<float[4]>::cast(float v[4]) { return type(v[0], v[1], v[2], v[3]); }
+Bool CToReactor<bool>::cast(bool v)
+{
+ return type(v);
+}
+Byte CToReactor<uint8_t>::cast(uint8_t v)
+{
+ return type(v);
+}
+SByte CToReactor<int8_t>::cast(int8_t v)
+{
+ return type(v);
+}
+Short CToReactor<int16_t>::cast(int16_t v)
+{
+ return type(v);
+}
+UShort CToReactor<uint16_t>::cast(uint16_t v)
+{
+ return type(v);
+}
+Int CToReactor<int32_t>::cast(int32_t v)
+{
+ return type(v);
+}
+UInt CToReactor<uint32_t>::cast(uint32_t v)
+{
+ return type(v);
+}
+Float CToReactor<float>::cast(float v)
+{
+ return type(v);
+}
+Float4 CToReactor<float[4]>::cast(float v[4])
+{
+ return type(v[0], v[1], v[2], v[3]);
+}
// TODO: Long has no constructor that takes a uint64_t
// Long CToReactor<uint64_t>::cast(uint64_t v) { return type(v); }
diff --git a/src/Reactor/Reactor.hpp b/src/Reactor/Reactor.hpp
index fc55c51..59b3d0a 100644
--- a/src/Reactor/Reactor.hpp
+++ b/src/Reactor/Reactor.hpp
@@ -26,34 +26,33 @@
#include <tuple>
#include <unordered_set>
-#undef Bool // b/127920555
+#undef Bool // b/127920555
#ifdef ENABLE_RR_DEBUG_INFO
- // Functions used for generating JIT debug info.
- // See docs/ReactorDebugInfo.md for more information.
- namespace rr
- {
- // Update the current source location for debug.
- void EmitDebugLocation();
- // Bind value to its symbolic name taken from the backtrace.
- void EmitDebugVariable(class Value* value);
- // Flush any pending variable bindings before the line ends.
- void FlushDebug();
- }
- #define RR_DEBUG_INFO_UPDATE_LOC() rr::EmitDebugLocation()
- #define RR_DEBUG_INFO_EMIT_VAR(value) rr::EmitDebugVariable(value)
- #define RR_DEBUG_INFO_FLUSH() rr::FlushDebug()
+// Functions used for generating JIT debug info.
+// See docs/ReactorDebugInfo.md for more information.
+namespace rr {
+// Update the current source location for debug.
+void EmitDebugLocation();
+// Bind value to its symbolic name taken from the backtrace.
+void EmitDebugVariable(class Value *value);
+// Flush any pending variable bindings before the line ends.
+void FlushDebug();
+} // namespace rr
+# define RR_DEBUG_INFO_UPDATE_LOC() rr::EmitDebugLocation()
+# define RR_DEBUG_INFO_EMIT_VAR(value) rr::EmitDebugVariable(value)
+# define RR_DEBUG_INFO_FLUSH() rr::FlushDebug()
#else
- #define RR_DEBUG_INFO_UPDATE_LOC()
- #define RR_DEBUG_INFO_EMIT_VAR(value)
- #define RR_DEBUG_INFO_FLUSH()
-#endif // ENABLE_RR_DEBUG_INFO
+# define RR_DEBUG_INFO_UPDATE_LOC()
+# define RR_DEBUG_INFO_EMIT_VAR(value)
+# define RR_DEBUG_INFO_FLUSH()
+#endif // ENABLE_RR_DEBUG_INFO
namespace rr {
struct Capabilities
{
- bool CoroutinesSupported; // Support for rr::Coroutine<F>
+ bool CoroutinesSupported; // Support for rr::Coroutine<F>
};
extern const Capabilities Caps;
@@ -109,7 +108,7 @@
friend class PrintValue;
Variable() = delete;
- Variable &operator=(const Variable&) = delete;
+ Variable &operator=(const Variable &) = delete;
public:
void materialize() const;
@@ -122,7 +121,7 @@
protected:
Variable(Type *type, int arraySize);
- Variable(const Variable&) = default;
+ Variable(const Variable &) = default;
~Variable();
@@ -132,7 +131,7 @@
static void materializeAll();
static void killUnmaterialized();
- static std::unordered_set<Variable*> unmaterializedVariables;
+ static std::unordered_set<Variable *> unmaterializedVariables;
Type *const type;
mutable Value *rvalue = nullptr;
@@ -154,7 +153,7 @@
// self() returns the this pointer to this LValue<T> object.
// This function exists because operator&() is overloaded.
- inline LValue<T>* self() { return this; }
+ inline LValue<T> *self() { return this; }
};
template<class T>
@@ -239,7 +238,7 @@
#ifdef ENABLE_RR_DEBUG_INFO
RValue(const RValue<T> &rvalue);
-#endif // ENABLE_RR_DEBUG_INFO
+#endif // ENABLE_RR_DEBUG_INFO
RValue(const T &lvalue);
RValue(typename BoolLiteral<T>::type i);
@@ -247,15 +246,17 @@
RValue(typename FloatLiteral<T>::type f);
RValue(const Reference<T> &rhs);
- RValue<T> &operator=(const RValue<T>&) = delete;
+ RValue<T> &operator=(const RValue<T> &) = delete;
- Value *value; // FIXME: Make private
+ Value *value; // FIXME: Make private
};
template<typename T>
struct Argument
{
- explicit Argument(Value *value) : value(value) {}
+ explicit Argument(Value *value)
+ : value(value)
+ {}
Value *value;
};
@@ -271,7 +272,7 @@
Bool(const Bool &rhs);
Bool(const Reference<Bool> &rhs);
-// RValue<Bool> operator=(bool rhs); // FIXME: Implement
+ // RValue<Bool> operator=(bool rhs); // FIXME: Implement
RValue<Bool> operator=(RValue<Bool> rhs);
RValue<Bool> operator=(const Bool &rhs);
RValue<Bool> operator=(const Reference<Bool> &rhs);
@@ -301,7 +302,7 @@
Byte(const Byte &rhs);
Byte(const Reference<Byte> &rhs);
-// RValue<Byte> operator=(unsigned char rhs); // FIXME: Implement
+ // RValue<Byte> operator=(unsigned char rhs); // FIXME: Implement
RValue<Byte> operator=(RValue<Byte> rhs);
RValue<Byte> operator=(const Byte &rhs);
RValue<Byte> operator=(const Reference<Byte> &rhs);
@@ -332,10 +333,10 @@
RValue<Byte> operator+(RValue<Byte> val);
RValue<Byte> operator-(RValue<Byte> val);
RValue<Byte> operator~(RValue<Byte> val);
-RValue<Byte> operator++(Byte &val, int); // Post-increment
-const Byte &operator++(Byte &val); // Pre-increment
-RValue<Byte> operator--(Byte &val, int); // Post-decrement
-const Byte &operator--(Byte &val); // Pre-decrement
+RValue<Byte> operator++(Byte &val, int); // Post-increment
+const Byte &operator++(Byte &val); // Pre-increment
+RValue<Byte> operator--(Byte &val, int); // Post-decrement
+const Byte &operator--(Byte &val); // Pre-decrement
RValue<Bool> operator<(RValue<Byte> lhs, RValue<Byte> rhs);
RValue<Bool> operator<=(RValue<Byte> lhs, RValue<Byte> rhs);
RValue<Bool> operator>(RValue<Byte> lhs, RValue<Byte> rhs);
@@ -357,7 +358,7 @@
SByte(const SByte &rhs);
SByte(const Reference<SByte> &rhs);
-// RValue<SByte> operator=(signed char rhs); // FIXME: Implement
+ // RValue<SByte> operator=(signed char rhs); // FIXME: Implement
RValue<SByte> operator=(RValue<SByte> rhs);
RValue<SByte> operator=(const SByte &rhs);
RValue<SByte> operator=(const Reference<SByte> &rhs);
@@ -388,10 +389,10 @@
RValue<SByte> operator+(RValue<SByte> val);
RValue<SByte> operator-(RValue<SByte> val);
RValue<SByte> operator~(RValue<SByte> val);
-RValue<SByte> operator++(SByte &val, int); // Post-increment
-const SByte &operator++(SByte &val); // Pre-increment
-RValue<SByte> operator--(SByte &val, int); // Post-decrement
-const SByte &operator--(SByte &val); // Pre-decrement
+RValue<SByte> operator++(SByte &val, int); // Post-increment
+const SByte &operator++(SByte &val); // Pre-increment
+RValue<SByte> operator--(SByte &val, int); // Post-decrement
+const SByte &operator--(SByte &val); // Pre-decrement
RValue<Bool> operator<(RValue<SByte> lhs, RValue<SByte> rhs);
RValue<Bool> operator<=(RValue<SByte> lhs, RValue<SByte> rhs);
RValue<Bool> operator>(RValue<SByte> lhs, RValue<SByte> rhs);
@@ -412,7 +413,7 @@
Short(const Short &rhs);
Short(const Reference<Short> &rhs);
-// RValue<Short> operator=(short rhs); // FIXME: Implement
+ // RValue<Short> operator=(short rhs); // FIXME: Implement
RValue<Short> operator=(RValue<Short> rhs);
RValue<Short> operator=(const Short &rhs);
RValue<Short> operator=(const Reference<Short> &rhs);
@@ -443,10 +444,10 @@
RValue<Short> operator+(RValue<Short> val);
RValue<Short> operator-(RValue<Short> val);
RValue<Short> operator~(RValue<Short> val);
-RValue<Short> operator++(Short &val, int); // Post-increment
-const Short &operator++(Short &val); // Pre-increment
-RValue<Short> operator--(Short &val, int); // Post-decrement
-const Short &operator--(Short &val); // Pre-decrement
+RValue<Short> operator++(Short &val, int); // Post-increment
+const Short &operator++(Short &val); // Pre-increment
+RValue<Short> operator--(Short &val, int); // Post-decrement
+const Short &operator--(Short &val); // Pre-decrement
RValue<Bool> operator<(RValue<Short> lhs, RValue<Short> rhs);
RValue<Bool> operator<=(RValue<Short> lhs, RValue<Short> rhs);
RValue<Bool> operator>(RValue<Short> lhs, RValue<Short> rhs);
@@ -468,7 +469,7 @@
UShort(const UShort &rhs);
UShort(const Reference<UShort> &rhs);
-// RValue<UShort> operator=(unsigned short rhs); // FIXME: Implement
+ // RValue<UShort> operator=(unsigned short rhs); // FIXME: Implement
RValue<UShort> operator=(RValue<UShort> rhs);
RValue<UShort> operator=(const UShort &rhs);
RValue<UShort> operator=(const Reference<UShort> &rhs);
@@ -499,10 +500,10 @@
RValue<UShort> operator+(RValue<UShort> val);
RValue<UShort> operator-(RValue<UShort> val);
RValue<UShort> operator~(RValue<UShort> val);
-RValue<UShort> operator++(UShort &val, int); // Post-increment
-const UShort &operator++(UShort &val); // Pre-increment
-RValue<UShort> operator--(UShort &val, int); // Post-decrement
-const UShort &operator--(UShort &val); // Pre-decrement
+RValue<UShort> operator++(UShort &val, int); // Post-increment
+const UShort &operator++(UShort &val); // Pre-increment
+RValue<UShort> operator--(UShort &val, int); // Post-decrement
+const UShort &operator--(UShort &val); // Pre-decrement
RValue<Bool> operator<(RValue<UShort> lhs, RValue<UShort> rhs);
RValue<Bool> operator<=(RValue<UShort> lhs, RValue<UShort> rhs);
RValue<Bool> operator>(RValue<UShort> lhs, RValue<UShort> rhs);
@@ -516,14 +517,14 @@
explicit Byte4(RValue<Byte8> cast);
Byte4() = default;
-// Byte4(int x, int y, int z, int w);
-// Byte4(RValue<Byte4> rhs);
-// Byte4(const Byte4 &rhs);
+ // Byte4(int x, int y, int z, int w);
+ // Byte4(RValue<Byte4> rhs);
+ // Byte4(const Byte4 &rhs);
Byte4(const Reference<Byte4> &rhs);
-// RValue<Byte4> operator=(RValue<Byte4> rhs);
-// RValue<Byte4> operator=(const Byte4 &rhs);
-// RValue<Byte4> operator=(const Reference<Byte4> &rhs);
+ // RValue<Byte4> operator=(RValue<Byte4> rhs);
+ // RValue<Byte4> operator=(const Byte4 &rhs);
+ // RValue<Byte4> operator=(const Reference<Byte4> &rhs);
static Type *getType();
};
@@ -560,14 +561,14 @@
{
public:
SByte4() = default;
-// SByte4(int x, int y, int z, int w);
-// SByte4(RValue<SByte4> rhs);
-// SByte4(const SByte4 &rhs);
-// SByte4(const Reference<SByte4> &rhs);
+ // SByte4(int x, int y, int z, int w);
+ // SByte4(RValue<SByte4> rhs);
+ // SByte4(const SByte4 &rhs);
+ // SByte4(const Reference<SByte4> &rhs);
-// RValue<SByte4> operator=(RValue<SByte4> rhs);
-// RValue<SByte4> operator=(const SByte4 &rhs);
-// RValue<SByte4> operator=(const Reference<SByte4> &rhs);
+ // RValue<SByte4> operator=(RValue<SByte4> rhs);
+ // RValue<SByte4> operator=(const SByte4 &rhs);
+ // RValue<SByte4> operator=(const Reference<SByte4> &rhs);
static Type *getType();
};
@@ -710,7 +711,7 @@
{
public:
Byte16() = default;
-// Byte16(int x, int y, int z, int w);
+ // Byte16(int x, int y, int z, int w);
Byte16(RValue<Byte16> rhs);
Byte16(const Byte16 &rhs);
Byte16(const Reference<Byte16> &rhs);
@@ -754,14 +755,14 @@
{
public:
SByte16() = default;
-// SByte16(int x, int y, int z, int w);
-// SByte16(RValue<SByte16> rhs);
-// SByte16(const SByte16 &rhs);
-// SByte16(const Reference<SByte16> &rhs);
+ // SByte16(int x, int y, int z, int w);
+ // SByte16(RValue<SByte16> rhs);
+ // SByte16(const SByte16 &rhs);
+ // SByte16(const Reference<SByte16> &rhs);
-// RValue<SByte16> operator=(RValue<SByte16> rhs);
-// RValue<SByte16> operator=(const SByte16 &rhs);
-// RValue<SByte16> operator=(const Reference<SByte16> &rhs);
+ // RValue<SByte16> operator=(RValue<SByte16> rhs);
+ // RValue<SByte16> operator=(const SByte16 &rhs);
+ // RValue<SByte16> operator=(const Reference<SByte16> &rhs);
static Type *getType();
};
@@ -815,7 +816,7 @@
public:
explicit Short4(RValue<Int> cast);
explicit Short4(RValue<Int4> cast);
-// explicit Short4(RValue<Float> cast);
+ // explicit Short4(RValue<Float> cast);
explicit Short4(RValue<Float4> cast);
Short4() = default;
@@ -957,7 +958,7 @@
Short8(short c);
Short8(short c0, short c1, short c2, short c3, short c4, short c5, short c6, short c7);
Short8(RValue<Short8> rhs);
-// Short8(const Short8 &rhs);
+ // Short8(const Short8 &rhs);
Short8(const Reference<Short8> &rhs);
Short8(RValue<Short4> lo, RValue<Short4> hi);
@@ -1015,7 +1016,7 @@
UShort8(unsigned short c);
UShort8(unsigned short c0, unsigned short c1, unsigned short c2, unsigned short c3, unsigned short c4, unsigned short c5, unsigned short c6, unsigned short c7);
UShort8(RValue<UShort8> rhs);
-// UShort8(const UShort8 &rhs);
+ // UShort8(const UShort8 &rhs);
UShort8(const Reference<UShort8> &rhs);
UShort8(RValue<UShort4> lo, RValue<UShort4> hi);
@@ -1121,10 +1122,10 @@
RValue<Int> operator+(RValue<Int> val);
RValue<Int> operator-(RValue<Int> val);
RValue<Int> operator~(RValue<Int> val);
-RValue<Int> operator++(Int &val, int); // Post-increment
-const Int &operator++(Int &val); // Pre-increment
-RValue<Int> operator--(Int &val, int); // Post-decrement
-const Int &operator--(Int &val); // Pre-decrement
+RValue<Int> operator++(Int &val, int); // Post-increment
+const Int &operator++(Int &val); // Pre-increment
+RValue<Int> operator--(Int &val, int); // Post-decrement
+const Int &operator--(Int &val); // Pre-decrement
RValue<Bool> operator<(RValue<Int> lhs, RValue<Int> rhs);
RValue<Bool> operator<=(RValue<Int> lhs, RValue<Int> rhs);
RValue<Bool> operator>(RValue<Int> lhs, RValue<Int> rhs);
@@ -1140,30 +1141,30 @@
class Long : public LValue<Long>
{
public:
-// Long(Argument<Long> argument);
+ // Long(Argument<Long> argument);
-// explicit Long(RValue<Short> cast);
-// explicit Long(RValue<UShort> cast);
+ // explicit Long(RValue<Short> cast);
+ // explicit Long(RValue<UShort> cast);
explicit Long(RValue<Int> cast);
explicit Long(RValue<UInt> cast);
-// explicit Long(RValue<Float> cast);
+ // explicit Long(RValue<Float> cast);
Long() = default;
-// Long(qword x);
+ // Long(qword x);
Long(RValue<Long> rhs);
-// Long(RValue<ULong> rhs);
-// Long(const Long &rhs);
-// Long(const Reference<Long> &rhs);
-// Long(const ULong &rhs);
-// Long(const Reference<ULong> &rhs);
+ // Long(RValue<ULong> rhs);
+ // Long(const Long &rhs);
+ // Long(const Reference<Long> &rhs);
+ // Long(const ULong &rhs);
+ // Long(const Reference<ULong> &rhs);
RValue<Long> operator=(int64_t rhs);
RValue<Long> operator=(RValue<Long> rhs);
-// RValue<Long> operator=(RValue<ULong> rhs);
+ // RValue<Long> operator=(RValue<ULong> rhs);
RValue<Long> operator=(const Long &rhs);
RValue<Long> operator=(const Reference<Long> &rhs);
-// RValue<Long> operator=(const ULong &rhs);
-// RValue<Long> operator=(const Reference<ULong> &rhs);
+ // RValue<Long> operator=(const ULong &rhs);
+ // RValue<Long> operator=(const Reference<ULong> &rhs);
static Type *getType();
};
@@ -1203,7 +1204,7 @@
// RValue<Bool> operator==(RValue<Long> lhs, RValue<Long> rhs);
// RValue<Long> RoundLong(RValue<Float> cast);
-RValue<Long> AddAtomic( RValue<Pointer<Long>> x, RValue<Long> y);
+RValue<Long> AddAtomic(RValue<Pointer<Long>> x, RValue<Long> y);
class UInt : public LValue<UInt>
{
@@ -1258,10 +1259,10 @@
RValue<UInt> operator+(RValue<UInt> val);
RValue<UInt> operator-(RValue<UInt> val);
RValue<UInt> operator~(RValue<UInt> val);
-RValue<UInt> operator++(UInt &val, int); // Post-increment
-const UInt &operator++(UInt &val); // Pre-increment
-RValue<UInt> operator--(UInt &val, int); // Post-decrement
-const UInt &operator--(UInt &val); // Pre-decrement
+RValue<UInt> operator++(UInt &val, int); // Post-increment
+const UInt &operator++(UInt &val); // Pre-increment
+RValue<UInt> operator--(UInt &val, int); // Post-decrement
+const UInt &operator--(UInt &val); // Pre-decrement
RValue<Bool> operator<(RValue<UInt> lhs, RValue<UInt> rhs);
RValue<Bool> operator<=(RValue<UInt> lhs, RValue<UInt> rhs);
RValue<Bool> operator>(RValue<UInt> lhs, RValue<UInt> rhs);
@@ -1290,7 +1291,7 @@
class Int2 : public LValue<Int2>
{
public:
-// explicit Int2(RValue<Int> cast);
+ // explicit Int2(RValue<Int> cast);
explicit Int2(RValue<Int4> cast);
Int2() = default;
@@ -1509,342 +1510,342 @@
SwizzleMask1<Vector4, 0x1111> y;
SwizzleMask1<Vector4, 0x2222> z;
SwizzleMask1<Vector4, 0x3333> w;
- Swizzle2<Vector4, 0x0000> xx;
- Swizzle2<Vector4, 0x1000> yx;
- Swizzle2<Vector4, 0x2000> zx;
- Swizzle2<Vector4, 0x3000> wx;
+ Swizzle2<Vector4, 0x0000> xx;
+ Swizzle2<Vector4, 0x1000> yx;
+ Swizzle2<Vector4, 0x2000> zx;
+ Swizzle2<Vector4, 0x3000> wx;
SwizzleMask2<Vector4, 0x0111> xy;
- Swizzle2<Vector4, 0x1111> yy;
- Swizzle2<Vector4, 0x2111> zy;
- Swizzle2<Vector4, 0x3111> wy;
+ Swizzle2<Vector4, 0x1111> yy;
+ Swizzle2<Vector4, 0x2111> zy;
+ Swizzle2<Vector4, 0x3111> wy;
SwizzleMask2<Vector4, 0x0222> xz;
SwizzleMask2<Vector4, 0x1222> yz;
- Swizzle2<Vector4, 0x2222> zz;
- Swizzle2<Vector4, 0x3222> wz;
+ Swizzle2<Vector4, 0x2222> zz;
+ Swizzle2<Vector4, 0x3222> wz;
SwizzleMask2<Vector4, 0x0333> xw;
SwizzleMask2<Vector4, 0x1333> yw;
SwizzleMask2<Vector4, 0x2333> zw;
- Swizzle2<Vector4, 0x3333> ww;
- Swizzle4<Vector4, 0x0000> xxx;
- Swizzle4<Vector4, 0x1000> yxx;
- Swizzle4<Vector4, 0x2000> zxx;
- Swizzle4<Vector4, 0x3000> wxx;
- Swizzle4<Vector4, 0x0100> xyx;
- Swizzle4<Vector4, 0x1100> yyx;
- Swizzle4<Vector4, 0x2100> zyx;
- Swizzle4<Vector4, 0x3100> wyx;
- Swizzle4<Vector4, 0x0200> xzx;
- Swizzle4<Vector4, 0x1200> yzx;
- Swizzle4<Vector4, 0x2200> zzx;
- Swizzle4<Vector4, 0x3200> wzx;
- Swizzle4<Vector4, 0x0300> xwx;
- Swizzle4<Vector4, 0x1300> ywx;
- Swizzle4<Vector4, 0x2300> zwx;
- Swizzle4<Vector4, 0x3300> wwx;
- Swizzle4<Vector4, 0x0011> xxy;
- Swizzle4<Vector4, 0x1011> yxy;
- Swizzle4<Vector4, 0x2011> zxy;
- Swizzle4<Vector4, 0x3011> wxy;
- Swizzle4<Vector4, 0x0111> xyy;
- Swizzle4<Vector4, 0x1111> yyy;
- Swizzle4<Vector4, 0x2111> zyy;
- Swizzle4<Vector4, 0x3111> wyy;
- Swizzle4<Vector4, 0x0211> xzy;
- Swizzle4<Vector4, 0x1211> yzy;
- Swizzle4<Vector4, 0x2211> zzy;
- Swizzle4<Vector4, 0x3211> wzy;
- Swizzle4<Vector4, 0x0311> xwy;
- Swizzle4<Vector4, 0x1311> ywy;
- Swizzle4<Vector4, 0x2311> zwy;
- Swizzle4<Vector4, 0x3311> wwy;
- Swizzle4<Vector4, 0x0022> xxz;
- Swizzle4<Vector4, 0x1022> yxz;
- Swizzle4<Vector4, 0x2022> zxz;
- Swizzle4<Vector4, 0x3022> wxz;
+ Swizzle2<Vector4, 0x3333> ww;
+ Swizzle4<Vector4, 0x0000> xxx;
+ Swizzle4<Vector4, 0x1000> yxx;
+ Swizzle4<Vector4, 0x2000> zxx;
+ Swizzle4<Vector4, 0x3000> wxx;
+ Swizzle4<Vector4, 0x0100> xyx;
+ Swizzle4<Vector4, 0x1100> yyx;
+ Swizzle4<Vector4, 0x2100> zyx;
+ Swizzle4<Vector4, 0x3100> wyx;
+ Swizzle4<Vector4, 0x0200> xzx;
+ Swizzle4<Vector4, 0x1200> yzx;
+ Swizzle4<Vector4, 0x2200> zzx;
+ Swizzle4<Vector4, 0x3200> wzx;
+ Swizzle4<Vector4, 0x0300> xwx;
+ Swizzle4<Vector4, 0x1300> ywx;
+ Swizzle4<Vector4, 0x2300> zwx;
+ Swizzle4<Vector4, 0x3300> wwx;
+ Swizzle4<Vector4, 0x0011> xxy;
+ Swizzle4<Vector4, 0x1011> yxy;
+ Swizzle4<Vector4, 0x2011> zxy;
+ Swizzle4<Vector4, 0x3011> wxy;
+ Swizzle4<Vector4, 0x0111> xyy;
+ Swizzle4<Vector4, 0x1111> yyy;
+ Swizzle4<Vector4, 0x2111> zyy;
+ Swizzle4<Vector4, 0x3111> wyy;
+ Swizzle4<Vector4, 0x0211> xzy;
+ Swizzle4<Vector4, 0x1211> yzy;
+ Swizzle4<Vector4, 0x2211> zzy;
+ Swizzle4<Vector4, 0x3211> wzy;
+ Swizzle4<Vector4, 0x0311> xwy;
+ Swizzle4<Vector4, 0x1311> ywy;
+ Swizzle4<Vector4, 0x2311> zwy;
+ Swizzle4<Vector4, 0x3311> wwy;
+ Swizzle4<Vector4, 0x0022> xxz;
+ Swizzle4<Vector4, 0x1022> yxz;
+ Swizzle4<Vector4, 0x2022> zxz;
+ Swizzle4<Vector4, 0x3022> wxz;
SwizzleMask4<Vector4, 0x0122> xyz;
- Swizzle4<Vector4, 0x1122> yyz;
- Swizzle4<Vector4, 0x2122> zyz;
- Swizzle4<Vector4, 0x3122> wyz;
- Swizzle4<Vector4, 0x0222> xzz;
- Swizzle4<Vector4, 0x1222> yzz;
- Swizzle4<Vector4, 0x2222> zzz;
- Swizzle4<Vector4, 0x3222> wzz;
- Swizzle4<Vector4, 0x0322> xwz;
- Swizzle4<Vector4, 0x1322> ywz;
- Swizzle4<Vector4, 0x2322> zwz;
- Swizzle4<Vector4, 0x3322> wwz;
- Swizzle4<Vector4, 0x0033> xxw;
- Swizzle4<Vector4, 0x1033> yxw;
- Swizzle4<Vector4, 0x2033> zxw;
- Swizzle4<Vector4, 0x3033> wxw;
+ Swizzle4<Vector4, 0x1122> yyz;
+ Swizzle4<Vector4, 0x2122> zyz;
+ Swizzle4<Vector4, 0x3122> wyz;
+ Swizzle4<Vector4, 0x0222> xzz;
+ Swizzle4<Vector4, 0x1222> yzz;
+ Swizzle4<Vector4, 0x2222> zzz;
+ Swizzle4<Vector4, 0x3222> wzz;
+ Swizzle4<Vector4, 0x0322> xwz;
+ Swizzle4<Vector4, 0x1322> ywz;
+ Swizzle4<Vector4, 0x2322> zwz;
+ Swizzle4<Vector4, 0x3322> wwz;
+ Swizzle4<Vector4, 0x0033> xxw;
+ Swizzle4<Vector4, 0x1033> yxw;
+ Swizzle4<Vector4, 0x2033> zxw;
+ Swizzle4<Vector4, 0x3033> wxw;
SwizzleMask4<Vector4, 0x0133> xyw;
- Swizzle4<Vector4, 0x1133> yyw;
- Swizzle4<Vector4, 0x2133> zyw;
- Swizzle4<Vector4, 0x3133> wyw;
+ Swizzle4<Vector4, 0x1133> yyw;
+ Swizzle4<Vector4, 0x2133> zyw;
+ Swizzle4<Vector4, 0x3133> wyw;
SwizzleMask4<Vector4, 0x0233> xzw;
SwizzleMask4<Vector4, 0x1233> yzw;
- Swizzle4<Vector4, 0x2233> zzw;
- Swizzle4<Vector4, 0x3233> wzw;
- Swizzle4<Vector4, 0x0333> xww;
- Swizzle4<Vector4, 0x1333> yww;
- Swizzle4<Vector4, 0x2333> zww;
- Swizzle4<Vector4, 0x3333> www;
- Swizzle4<Vector4, 0x0000> xxxx;
- Swizzle4<Vector4, 0x1000> yxxx;
- Swizzle4<Vector4, 0x2000> zxxx;
- Swizzle4<Vector4, 0x3000> wxxx;
- Swizzle4<Vector4, 0x0100> xyxx;
- Swizzle4<Vector4, 0x1100> yyxx;
- Swizzle4<Vector4, 0x2100> zyxx;
- Swizzle4<Vector4, 0x3100> wyxx;
- Swizzle4<Vector4, 0x0200> xzxx;
- Swizzle4<Vector4, 0x1200> yzxx;
- Swizzle4<Vector4, 0x2200> zzxx;
- Swizzle4<Vector4, 0x3200> wzxx;
- Swizzle4<Vector4, 0x0300> xwxx;
- Swizzle4<Vector4, 0x1300> ywxx;
- Swizzle4<Vector4, 0x2300> zwxx;
- Swizzle4<Vector4, 0x3300> wwxx;
- Swizzle4<Vector4, 0x0010> xxyx;
- Swizzle4<Vector4, 0x1010> yxyx;
- Swizzle4<Vector4, 0x2010> zxyx;
- Swizzle4<Vector4, 0x3010> wxyx;
- Swizzle4<Vector4, 0x0110> xyyx;
- Swizzle4<Vector4, 0x1110> yyyx;
- Swizzle4<Vector4, 0x2110> zyyx;
- Swizzle4<Vector4, 0x3110> wyyx;
- Swizzle4<Vector4, 0x0210> xzyx;
- Swizzle4<Vector4, 0x1210> yzyx;
- Swizzle4<Vector4, 0x2210> zzyx;
- Swizzle4<Vector4, 0x3210> wzyx;
- Swizzle4<Vector4, 0x0310> xwyx;
- Swizzle4<Vector4, 0x1310> ywyx;
- Swizzle4<Vector4, 0x2310> zwyx;
- Swizzle4<Vector4, 0x3310> wwyx;
- Swizzle4<Vector4, 0x0020> xxzx;
- Swizzle4<Vector4, 0x1020> yxzx;
- Swizzle4<Vector4, 0x2020> zxzx;
- Swizzle4<Vector4, 0x3020> wxzx;
- Swizzle4<Vector4, 0x0120> xyzx;
- Swizzle4<Vector4, 0x1120> yyzx;
- Swizzle4<Vector4, 0x2120> zyzx;
- Swizzle4<Vector4, 0x3120> wyzx;
- Swizzle4<Vector4, 0x0220> xzzx;
- Swizzle4<Vector4, 0x1220> yzzx;
- Swizzle4<Vector4, 0x2220> zzzx;
- Swizzle4<Vector4, 0x3220> wzzx;
- Swizzle4<Vector4, 0x0320> xwzx;
- Swizzle4<Vector4, 0x1320> ywzx;
- Swizzle4<Vector4, 0x2320> zwzx;
- Swizzle4<Vector4, 0x3320> wwzx;
- Swizzle4<Vector4, 0x0030> xxwx;
- Swizzle4<Vector4, 0x1030> yxwx;
- Swizzle4<Vector4, 0x2030> zxwx;
- Swizzle4<Vector4, 0x3030> wxwx;
- Swizzle4<Vector4, 0x0130> xywx;
- Swizzle4<Vector4, 0x1130> yywx;
- Swizzle4<Vector4, 0x2130> zywx;
- Swizzle4<Vector4, 0x3130> wywx;
- Swizzle4<Vector4, 0x0230> xzwx;
- Swizzle4<Vector4, 0x1230> yzwx;
- Swizzle4<Vector4, 0x2230> zzwx;
- Swizzle4<Vector4, 0x3230> wzwx;
- Swizzle4<Vector4, 0x0330> xwwx;
- Swizzle4<Vector4, 0x1330> ywwx;
- Swizzle4<Vector4, 0x2330> zwwx;
- Swizzle4<Vector4, 0x3330> wwwx;
- Swizzle4<Vector4, 0x0001> xxxy;
- Swizzle4<Vector4, 0x1001> yxxy;
- Swizzle4<Vector4, 0x2001> zxxy;
- Swizzle4<Vector4, 0x3001> wxxy;
- Swizzle4<Vector4, 0x0101> xyxy;
- Swizzle4<Vector4, 0x1101> yyxy;
- Swizzle4<Vector4, 0x2101> zyxy;
- Swizzle4<Vector4, 0x3101> wyxy;
- Swizzle4<Vector4, 0x0201> xzxy;
- Swizzle4<Vector4, 0x1201> yzxy;
- Swizzle4<Vector4, 0x2201> zzxy;
- Swizzle4<Vector4, 0x3201> wzxy;
- Swizzle4<Vector4, 0x0301> xwxy;
- Swizzle4<Vector4, 0x1301> ywxy;
- Swizzle4<Vector4, 0x2301> zwxy;
- Swizzle4<Vector4, 0x3301> wwxy;
- Swizzle4<Vector4, 0x0011> xxyy;
- Swizzle4<Vector4, 0x1011> yxyy;
- Swizzle4<Vector4, 0x2011> zxyy;
- Swizzle4<Vector4, 0x3011> wxyy;
- Swizzle4<Vector4, 0x0111> xyyy;
- Swizzle4<Vector4, 0x1111> yyyy;
- Swizzle4<Vector4, 0x2111> zyyy;
- Swizzle4<Vector4, 0x3111> wyyy;
- Swizzle4<Vector4, 0x0211> xzyy;
- Swizzle4<Vector4, 0x1211> yzyy;
- Swizzle4<Vector4, 0x2211> zzyy;
- Swizzle4<Vector4, 0x3211> wzyy;
- Swizzle4<Vector4, 0x0311> xwyy;
- Swizzle4<Vector4, 0x1311> ywyy;
- Swizzle4<Vector4, 0x2311> zwyy;
- Swizzle4<Vector4, 0x3311> wwyy;
- Swizzle4<Vector4, 0x0021> xxzy;
- Swizzle4<Vector4, 0x1021> yxzy;
- Swizzle4<Vector4, 0x2021> zxzy;
- Swizzle4<Vector4, 0x3021> wxzy;
- Swizzle4<Vector4, 0x0121> xyzy;
- Swizzle4<Vector4, 0x1121> yyzy;
- Swizzle4<Vector4, 0x2121> zyzy;
- Swizzle4<Vector4, 0x3121> wyzy;
- Swizzle4<Vector4, 0x0221> xzzy;
- Swizzle4<Vector4, 0x1221> yzzy;
- Swizzle4<Vector4, 0x2221> zzzy;
- Swizzle4<Vector4, 0x3221> wzzy;
- Swizzle4<Vector4, 0x0321> xwzy;
- Swizzle4<Vector4, 0x1321> ywzy;
- Swizzle4<Vector4, 0x2321> zwzy;
- Swizzle4<Vector4, 0x3321> wwzy;
- Swizzle4<Vector4, 0x0031> xxwy;
- Swizzle4<Vector4, 0x1031> yxwy;
- Swizzle4<Vector4, 0x2031> zxwy;
- Swizzle4<Vector4, 0x3031> wxwy;
- Swizzle4<Vector4, 0x0131> xywy;
- Swizzle4<Vector4, 0x1131> yywy;
- Swizzle4<Vector4, 0x2131> zywy;
- Swizzle4<Vector4, 0x3131> wywy;
- Swizzle4<Vector4, 0x0231> xzwy;
- Swizzle4<Vector4, 0x1231> yzwy;
- Swizzle4<Vector4, 0x2231> zzwy;
- Swizzle4<Vector4, 0x3231> wzwy;
- Swizzle4<Vector4, 0x0331> xwwy;
- Swizzle4<Vector4, 0x1331> ywwy;
- Swizzle4<Vector4, 0x2331> zwwy;
- Swizzle4<Vector4, 0x3331> wwwy;
- Swizzle4<Vector4, 0x0002> xxxz;
- Swizzle4<Vector4, 0x1002> yxxz;
- Swizzle4<Vector4, 0x2002> zxxz;
- Swizzle4<Vector4, 0x3002> wxxz;
- Swizzle4<Vector4, 0x0102> xyxz;
- Swizzle4<Vector4, 0x1102> yyxz;
- Swizzle4<Vector4, 0x2102> zyxz;
- Swizzle4<Vector4, 0x3102> wyxz;
- Swizzle4<Vector4, 0x0202> xzxz;
- Swizzle4<Vector4, 0x1202> yzxz;
- Swizzle4<Vector4, 0x2202> zzxz;
- Swizzle4<Vector4, 0x3202> wzxz;
- Swizzle4<Vector4, 0x0302> xwxz;
- Swizzle4<Vector4, 0x1302> ywxz;
- Swizzle4<Vector4, 0x2302> zwxz;
- Swizzle4<Vector4, 0x3302> wwxz;
- Swizzle4<Vector4, 0x0012> xxyz;
- Swizzle4<Vector4, 0x1012> yxyz;
- Swizzle4<Vector4, 0x2012> zxyz;
- Swizzle4<Vector4, 0x3012> wxyz;
- Swizzle4<Vector4, 0x0112> xyyz;
- Swizzle4<Vector4, 0x1112> yyyz;
- Swizzle4<Vector4, 0x2112> zyyz;
- Swizzle4<Vector4, 0x3112> wyyz;
- Swizzle4<Vector4, 0x0212> xzyz;
- Swizzle4<Vector4, 0x1212> yzyz;
- Swizzle4<Vector4, 0x2212> zzyz;
- Swizzle4<Vector4, 0x3212> wzyz;
- Swizzle4<Vector4, 0x0312> xwyz;
- Swizzle4<Vector4, 0x1312> ywyz;
- Swizzle4<Vector4, 0x2312> zwyz;
- Swizzle4<Vector4, 0x3312> wwyz;
- Swizzle4<Vector4, 0x0022> xxzz;
- Swizzle4<Vector4, 0x1022> yxzz;
- Swizzle4<Vector4, 0x2022> zxzz;
- Swizzle4<Vector4, 0x3022> wxzz;
- Swizzle4<Vector4, 0x0122> xyzz;
- Swizzle4<Vector4, 0x1122> yyzz;
- Swizzle4<Vector4, 0x2122> zyzz;
- Swizzle4<Vector4, 0x3122> wyzz;
- Swizzle4<Vector4, 0x0222> xzzz;
- Swizzle4<Vector4, 0x1222> yzzz;
- Swizzle4<Vector4, 0x2222> zzzz;
- Swizzle4<Vector4, 0x3222> wzzz;
- Swizzle4<Vector4, 0x0322> xwzz;
- Swizzle4<Vector4, 0x1322> ywzz;
- Swizzle4<Vector4, 0x2322> zwzz;
- Swizzle4<Vector4, 0x3322> wwzz;
- Swizzle4<Vector4, 0x0032> xxwz;
- Swizzle4<Vector4, 0x1032> yxwz;
- Swizzle4<Vector4, 0x2032> zxwz;
- Swizzle4<Vector4, 0x3032> wxwz;
- Swizzle4<Vector4, 0x0132> xywz;
- Swizzle4<Vector4, 0x1132> yywz;
- Swizzle4<Vector4, 0x2132> zywz;
- Swizzle4<Vector4, 0x3132> wywz;
- Swizzle4<Vector4, 0x0232> xzwz;
- Swizzle4<Vector4, 0x1232> yzwz;
- Swizzle4<Vector4, 0x2232> zzwz;
- Swizzle4<Vector4, 0x3232> wzwz;
- Swizzle4<Vector4, 0x0332> xwwz;
- Swizzle4<Vector4, 0x1332> ywwz;
- Swizzle4<Vector4, 0x2332> zwwz;
- Swizzle4<Vector4, 0x3332> wwwz;
- Swizzle4<Vector4, 0x0003> xxxw;
- Swizzle4<Vector4, 0x1003> yxxw;
- Swizzle4<Vector4, 0x2003> zxxw;
- Swizzle4<Vector4, 0x3003> wxxw;
- Swizzle4<Vector4, 0x0103> xyxw;
- Swizzle4<Vector4, 0x1103> yyxw;
- Swizzle4<Vector4, 0x2103> zyxw;
- Swizzle4<Vector4, 0x3103> wyxw;
- Swizzle4<Vector4, 0x0203> xzxw;
- Swizzle4<Vector4, 0x1203> yzxw;
- Swizzle4<Vector4, 0x2203> zzxw;
- Swizzle4<Vector4, 0x3203> wzxw;
- Swizzle4<Vector4, 0x0303> xwxw;
- Swizzle4<Vector4, 0x1303> ywxw;
- Swizzle4<Vector4, 0x2303> zwxw;
- Swizzle4<Vector4, 0x3303> wwxw;
- Swizzle4<Vector4, 0x0013> xxyw;
- Swizzle4<Vector4, 0x1013> yxyw;
- Swizzle4<Vector4, 0x2013> zxyw;
- Swizzle4<Vector4, 0x3013> wxyw;
- Swizzle4<Vector4, 0x0113> xyyw;
- Swizzle4<Vector4, 0x1113> yyyw;
- Swizzle4<Vector4, 0x2113> zyyw;
- Swizzle4<Vector4, 0x3113> wyyw;
- Swizzle4<Vector4, 0x0213> xzyw;
- Swizzle4<Vector4, 0x1213> yzyw;
- Swizzle4<Vector4, 0x2213> zzyw;
- Swizzle4<Vector4, 0x3213> wzyw;
- Swizzle4<Vector4, 0x0313> xwyw;
- Swizzle4<Vector4, 0x1313> ywyw;
- Swizzle4<Vector4, 0x2313> zwyw;
- Swizzle4<Vector4, 0x3313> wwyw;
- Swizzle4<Vector4, 0x0023> xxzw;
- Swizzle4<Vector4, 0x1023> yxzw;
- Swizzle4<Vector4, 0x2023> zxzw;
- Swizzle4<Vector4, 0x3023> wxzw;
+ Swizzle4<Vector4, 0x2233> zzw;
+ Swizzle4<Vector4, 0x3233> wzw;
+ Swizzle4<Vector4, 0x0333> xww;
+ Swizzle4<Vector4, 0x1333> yww;
+ Swizzle4<Vector4, 0x2333> zww;
+ Swizzle4<Vector4, 0x3333> www;
+ Swizzle4<Vector4, 0x0000> xxxx;
+ Swizzle4<Vector4, 0x1000> yxxx;
+ Swizzle4<Vector4, 0x2000> zxxx;
+ Swizzle4<Vector4, 0x3000> wxxx;
+ Swizzle4<Vector4, 0x0100> xyxx;
+ Swizzle4<Vector4, 0x1100> yyxx;
+ Swizzle4<Vector4, 0x2100> zyxx;
+ Swizzle4<Vector4, 0x3100> wyxx;
+ Swizzle4<Vector4, 0x0200> xzxx;
+ Swizzle4<Vector4, 0x1200> yzxx;
+ Swizzle4<Vector4, 0x2200> zzxx;
+ Swizzle4<Vector4, 0x3200> wzxx;
+ Swizzle4<Vector4, 0x0300> xwxx;
+ Swizzle4<Vector4, 0x1300> ywxx;
+ Swizzle4<Vector4, 0x2300> zwxx;
+ Swizzle4<Vector4, 0x3300> wwxx;
+ Swizzle4<Vector4, 0x0010> xxyx;
+ Swizzle4<Vector4, 0x1010> yxyx;
+ Swizzle4<Vector4, 0x2010> zxyx;
+ Swizzle4<Vector4, 0x3010> wxyx;
+ Swizzle4<Vector4, 0x0110> xyyx;
+ Swizzle4<Vector4, 0x1110> yyyx;
+ Swizzle4<Vector4, 0x2110> zyyx;
+ Swizzle4<Vector4, 0x3110> wyyx;
+ Swizzle4<Vector4, 0x0210> xzyx;
+ Swizzle4<Vector4, 0x1210> yzyx;
+ Swizzle4<Vector4, 0x2210> zzyx;
+ Swizzle4<Vector4, 0x3210> wzyx;
+ Swizzle4<Vector4, 0x0310> xwyx;
+ Swizzle4<Vector4, 0x1310> ywyx;
+ Swizzle4<Vector4, 0x2310> zwyx;
+ Swizzle4<Vector4, 0x3310> wwyx;
+ Swizzle4<Vector4, 0x0020> xxzx;
+ Swizzle4<Vector4, 0x1020> yxzx;
+ Swizzle4<Vector4, 0x2020> zxzx;
+ Swizzle4<Vector4, 0x3020> wxzx;
+ Swizzle4<Vector4, 0x0120> xyzx;
+ Swizzle4<Vector4, 0x1120> yyzx;
+ Swizzle4<Vector4, 0x2120> zyzx;
+ Swizzle4<Vector4, 0x3120> wyzx;
+ Swizzle4<Vector4, 0x0220> xzzx;
+ Swizzle4<Vector4, 0x1220> yzzx;
+ Swizzle4<Vector4, 0x2220> zzzx;
+ Swizzle4<Vector4, 0x3220> wzzx;
+ Swizzle4<Vector4, 0x0320> xwzx;
+ Swizzle4<Vector4, 0x1320> ywzx;
+ Swizzle4<Vector4, 0x2320> zwzx;
+ Swizzle4<Vector4, 0x3320> wwzx;
+ Swizzle4<Vector4, 0x0030> xxwx;
+ Swizzle4<Vector4, 0x1030> yxwx;
+ Swizzle4<Vector4, 0x2030> zxwx;
+ Swizzle4<Vector4, 0x3030> wxwx;
+ Swizzle4<Vector4, 0x0130> xywx;
+ Swizzle4<Vector4, 0x1130> yywx;
+ Swizzle4<Vector4, 0x2130> zywx;
+ Swizzle4<Vector4, 0x3130> wywx;
+ Swizzle4<Vector4, 0x0230> xzwx;
+ Swizzle4<Vector4, 0x1230> yzwx;
+ Swizzle4<Vector4, 0x2230> zzwx;
+ Swizzle4<Vector4, 0x3230> wzwx;
+ Swizzle4<Vector4, 0x0330> xwwx;
+ Swizzle4<Vector4, 0x1330> ywwx;
+ Swizzle4<Vector4, 0x2330> zwwx;
+ Swizzle4<Vector4, 0x3330> wwwx;
+ Swizzle4<Vector4, 0x0001> xxxy;
+ Swizzle4<Vector4, 0x1001> yxxy;
+ Swizzle4<Vector4, 0x2001> zxxy;
+ Swizzle4<Vector4, 0x3001> wxxy;
+ Swizzle4<Vector4, 0x0101> xyxy;
+ Swizzle4<Vector4, 0x1101> yyxy;
+ Swizzle4<Vector4, 0x2101> zyxy;
+ Swizzle4<Vector4, 0x3101> wyxy;
+ Swizzle4<Vector4, 0x0201> xzxy;
+ Swizzle4<Vector4, 0x1201> yzxy;
+ Swizzle4<Vector4, 0x2201> zzxy;
+ Swizzle4<Vector4, 0x3201> wzxy;
+ Swizzle4<Vector4, 0x0301> xwxy;
+ Swizzle4<Vector4, 0x1301> ywxy;
+ Swizzle4<Vector4, 0x2301> zwxy;
+ Swizzle4<Vector4, 0x3301> wwxy;
+ Swizzle4<Vector4, 0x0011> xxyy;
+ Swizzle4<Vector4, 0x1011> yxyy;
+ Swizzle4<Vector4, 0x2011> zxyy;
+ Swizzle4<Vector4, 0x3011> wxyy;
+ Swizzle4<Vector4, 0x0111> xyyy;
+ Swizzle4<Vector4, 0x1111> yyyy;
+ Swizzle4<Vector4, 0x2111> zyyy;
+ Swizzle4<Vector4, 0x3111> wyyy;
+ Swizzle4<Vector4, 0x0211> xzyy;
+ Swizzle4<Vector4, 0x1211> yzyy;
+ Swizzle4<Vector4, 0x2211> zzyy;
+ Swizzle4<Vector4, 0x3211> wzyy;
+ Swizzle4<Vector4, 0x0311> xwyy;
+ Swizzle4<Vector4, 0x1311> ywyy;
+ Swizzle4<Vector4, 0x2311> zwyy;
+ Swizzle4<Vector4, 0x3311> wwyy;
+ Swizzle4<Vector4, 0x0021> xxzy;
+ Swizzle4<Vector4, 0x1021> yxzy;
+ Swizzle4<Vector4, 0x2021> zxzy;
+ Swizzle4<Vector4, 0x3021> wxzy;
+ Swizzle4<Vector4, 0x0121> xyzy;
+ Swizzle4<Vector4, 0x1121> yyzy;
+ Swizzle4<Vector4, 0x2121> zyzy;
+ Swizzle4<Vector4, 0x3121> wyzy;
+ Swizzle4<Vector4, 0x0221> xzzy;
+ Swizzle4<Vector4, 0x1221> yzzy;
+ Swizzle4<Vector4, 0x2221> zzzy;
+ Swizzle4<Vector4, 0x3221> wzzy;
+ Swizzle4<Vector4, 0x0321> xwzy;
+ Swizzle4<Vector4, 0x1321> ywzy;
+ Swizzle4<Vector4, 0x2321> zwzy;
+ Swizzle4<Vector4, 0x3321> wwzy;
+ Swizzle4<Vector4, 0x0031> xxwy;
+ Swizzle4<Vector4, 0x1031> yxwy;
+ Swizzle4<Vector4, 0x2031> zxwy;
+ Swizzle4<Vector4, 0x3031> wxwy;
+ Swizzle4<Vector4, 0x0131> xywy;
+ Swizzle4<Vector4, 0x1131> yywy;
+ Swizzle4<Vector4, 0x2131> zywy;
+ Swizzle4<Vector4, 0x3131> wywy;
+ Swizzle4<Vector4, 0x0231> xzwy;
+ Swizzle4<Vector4, 0x1231> yzwy;
+ Swizzle4<Vector4, 0x2231> zzwy;
+ Swizzle4<Vector4, 0x3231> wzwy;
+ Swizzle4<Vector4, 0x0331> xwwy;
+ Swizzle4<Vector4, 0x1331> ywwy;
+ Swizzle4<Vector4, 0x2331> zwwy;
+ Swizzle4<Vector4, 0x3331> wwwy;
+ Swizzle4<Vector4, 0x0002> xxxz;
+ Swizzle4<Vector4, 0x1002> yxxz;
+ Swizzle4<Vector4, 0x2002> zxxz;
+ Swizzle4<Vector4, 0x3002> wxxz;
+ Swizzle4<Vector4, 0x0102> xyxz;
+ Swizzle4<Vector4, 0x1102> yyxz;
+ Swizzle4<Vector4, 0x2102> zyxz;
+ Swizzle4<Vector4, 0x3102> wyxz;
+ Swizzle4<Vector4, 0x0202> xzxz;
+ Swizzle4<Vector4, 0x1202> yzxz;
+ Swizzle4<Vector4, 0x2202> zzxz;
+ Swizzle4<Vector4, 0x3202> wzxz;
+ Swizzle4<Vector4, 0x0302> xwxz;
+ Swizzle4<Vector4, 0x1302> ywxz;
+ Swizzle4<Vector4, 0x2302> zwxz;
+ Swizzle4<Vector4, 0x3302> wwxz;
+ Swizzle4<Vector4, 0x0012> xxyz;
+ Swizzle4<Vector4, 0x1012> yxyz;
+ Swizzle4<Vector4, 0x2012> zxyz;
+ Swizzle4<Vector4, 0x3012> wxyz;
+ Swizzle4<Vector4, 0x0112> xyyz;
+ Swizzle4<Vector4, 0x1112> yyyz;
+ Swizzle4<Vector4, 0x2112> zyyz;
+ Swizzle4<Vector4, 0x3112> wyyz;
+ Swizzle4<Vector4, 0x0212> xzyz;
+ Swizzle4<Vector4, 0x1212> yzyz;
+ Swizzle4<Vector4, 0x2212> zzyz;
+ Swizzle4<Vector4, 0x3212> wzyz;
+ Swizzle4<Vector4, 0x0312> xwyz;
+ Swizzle4<Vector4, 0x1312> ywyz;
+ Swizzle4<Vector4, 0x2312> zwyz;
+ Swizzle4<Vector4, 0x3312> wwyz;
+ Swizzle4<Vector4, 0x0022> xxzz;
+ Swizzle4<Vector4, 0x1022> yxzz;
+ Swizzle4<Vector4, 0x2022> zxzz;
+ Swizzle4<Vector4, 0x3022> wxzz;
+ Swizzle4<Vector4, 0x0122> xyzz;
+ Swizzle4<Vector4, 0x1122> yyzz;
+ Swizzle4<Vector4, 0x2122> zyzz;
+ Swizzle4<Vector4, 0x3122> wyzz;
+ Swizzle4<Vector4, 0x0222> xzzz;
+ Swizzle4<Vector4, 0x1222> yzzz;
+ Swizzle4<Vector4, 0x2222> zzzz;
+ Swizzle4<Vector4, 0x3222> wzzz;
+ Swizzle4<Vector4, 0x0322> xwzz;
+ Swizzle4<Vector4, 0x1322> ywzz;
+ Swizzle4<Vector4, 0x2322> zwzz;
+ Swizzle4<Vector4, 0x3322> wwzz;
+ Swizzle4<Vector4, 0x0032> xxwz;
+ Swizzle4<Vector4, 0x1032> yxwz;
+ Swizzle4<Vector4, 0x2032> zxwz;
+ Swizzle4<Vector4, 0x3032> wxwz;
+ Swizzle4<Vector4, 0x0132> xywz;
+ Swizzle4<Vector4, 0x1132> yywz;
+ Swizzle4<Vector4, 0x2132> zywz;
+ Swizzle4<Vector4, 0x3132> wywz;
+ Swizzle4<Vector4, 0x0232> xzwz;
+ Swizzle4<Vector4, 0x1232> yzwz;
+ Swizzle4<Vector4, 0x2232> zzwz;
+ Swizzle4<Vector4, 0x3232> wzwz;
+ Swizzle4<Vector4, 0x0332> xwwz;
+ Swizzle4<Vector4, 0x1332> ywwz;
+ Swizzle4<Vector4, 0x2332> zwwz;
+ Swizzle4<Vector4, 0x3332> wwwz;
+ Swizzle4<Vector4, 0x0003> xxxw;
+ Swizzle4<Vector4, 0x1003> yxxw;
+ Swizzle4<Vector4, 0x2003> zxxw;
+ Swizzle4<Vector4, 0x3003> wxxw;
+ Swizzle4<Vector4, 0x0103> xyxw;
+ Swizzle4<Vector4, 0x1103> yyxw;
+ Swizzle4<Vector4, 0x2103> zyxw;
+ Swizzle4<Vector4, 0x3103> wyxw;
+ Swizzle4<Vector4, 0x0203> xzxw;
+ Swizzle4<Vector4, 0x1203> yzxw;
+ Swizzle4<Vector4, 0x2203> zzxw;
+ Swizzle4<Vector4, 0x3203> wzxw;
+ Swizzle4<Vector4, 0x0303> xwxw;
+ Swizzle4<Vector4, 0x1303> ywxw;
+ Swizzle4<Vector4, 0x2303> zwxw;
+ Swizzle4<Vector4, 0x3303> wwxw;
+ Swizzle4<Vector4, 0x0013> xxyw;
+ Swizzle4<Vector4, 0x1013> yxyw;
+ Swizzle4<Vector4, 0x2013> zxyw;
+ Swizzle4<Vector4, 0x3013> wxyw;
+ Swizzle4<Vector4, 0x0113> xyyw;
+ Swizzle4<Vector4, 0x1113> yyyw;
+ Swizzle4<Vector4, 0x2113> zyyw;
+ Swizzle4<Vector4, 0x3113> wyyw;
+ Swizzle4<Vector4, 0x0213> xzyw;
+ Swizzle4<Vector4, 0x1213> yzyw;
+ Swizzle4<Vector4, 0x2213> zzyw;
+ Swizzle4<Vector4, 0x3213> wzyw;
+ Swizzle4<Vector4, 0x0313> xwyw;
+ Swizzle4<Vector4, 0x1313> ywyw;
+ Swizzle4<Vector4, 0x2313> zwyw;
+ Swizzle4<Vector4, 0x3313> wwyw;
+ Swizzle4<Vector4, 0x0023> xxzw;
+ Swizzle4<Vector4, 0x1023> yxzw;
+ Swizzle4<Vector4, 0x2023> zxzw;
+ Swizzle4<Vector4, 0x3023> wxzw;
SwizzleMask4<Vector4, 0x0123> xyzw;
- Swizzle4<Vector4, 0x1123> yyzw;
- Swizzle4<Vector4, 0x2123> zyzw;
- Swizzle4<Vector4, 0x3123> wyzw;
- Swizzle4<Vector4, 0x0223> xzzw;
- Swizzle4<Vector4, 0x1223> yzzw;
- Swizzle4<Vector4, 0x2223> zzzw;
- Swizzle4<Vector4, 0x3223> wzzw;
- Swizzle4<Vector4, 0x0323> xwzw;
- Swizzle4<Vector4, 0x1323> ywzw;
- Swizzle4<Vector4, 0x2323> zwzw;
- Swizzle4<Vector4, 0x3323> wwzw;
- Swizzle4<Vector4, 0x0033> xxww;
- Swizzle4<Vector4, 0x1033> yxww;
- Swizzle4<Vector4, 0x2033> zxww;
- Swizzle4<Vector4, 0x3033> wxww;
- Swizzle4<Vector4, 0x0133> xyww;
- Swizzle4<Vector4, 0x1133> yyww;
- Swizzle4<Vector4, 0x2133> zyww;
- Swizzle4<Vector4, 0x3133> wyww;
- Swizzle4<Vector4, 0x0233> xzww;
- Swizzle4<Vector4, 0x1233> yzww;
- Swizzle4<Vector4, 0x2233> zzww;
- Swizzle4<Vector4, 0x3233> wzww;
- Swizzle4<Vector4, 0x0333> xwww;
- Swizzle4<Vector4, 0x1333> ywww;
- Swizzle4<Vector4, 0x2333> zwww;
- Swizzle4<Vector4, 0x3333> wwww;
+ Swizzle4<Vector4, 0x1123> yyzw;
+ Swizzle4<Vector4, 0x2123> zyzw;
+ Swizzle4<Vector4, 0x3123> wyzw;
+ Swizzle4<Vector4, 0x0223> xzzw;
+ Swizzle4<Vector4, 0x1223> yzzw;
+ Swizzle4<Vector4, 0x2223> zzzw;
+ Swizzle4<Vector4, 0x3223> wzzw;
+ Swizzle4<Vector4, 0x0323> xwzw;
+ Swizzle4<Vector4, 0x1323> ywzw;
+ Swizzle4<Vector4, 0x2323> zwzw;
+ Swizzle4<Vector4, 0x3323> wwzw;
+ Swizzle4<Vector4, 0x0033> xxww;
+ Swizzle4<Vector4, 0x1033> yxww;
+ Swizzle4<Vector4, 0x2033> zxww;
+ Swizzle4<Vector4, 0x3033> wxww;
+ Swizzle4<Vector4, 0x0133> xyww;
+ Swizzle4<Vector4, 0x1133> yyww;
+ Swizzle4<Vector4, 0x2133> zyww;
+ Swizzle4<Vector4, 0x3133> wyww;
+ Swizzle4<Vector4, 0x0233> xzww;
+ Swizzle4<Vector4, 0x1233> yzww;
+ Swizzle4<Vector4, 0x2233> zzww;
+ Swizzle4<Vector4, 0x3233> wzww;
+ Swizzle4<Vector4, 0x0333> xwww;
+ Swizzle4<Vector4, 0x1333> ywww;
+ Swizzle4<Vector4, 0x2333> zwww;
+ Swizzle4<Vector4, 0x3333> wwww;
};
};
@@ -1935,8 +1936,14 @@
RValue<Int4> CmpNEQ(RValue<Int4> x, RValue<Int4> y);
RValue<Int4> CmpNLT(RValue<Int4> x, RValue<Int4> y);
RValue<Int4> CmpNLE(RValue<Int4> x, RValue<Int4> y);
-inline RValue<Int4> CmpGT(RValue<Int4> x, RValue<Int4> y) { return CmpNLE(x, y); }
-inline RValue<Int4> CmpGE(RValue<Int4> x, RValue<Int4> y) { return CmpNLT(x, y); }
+inline RValue<Int4> CmpGT(RValue<Int4> x, RValue<Int4> y)
+{
+ return CmpNLE(x, y);
+}
+inline RValue<Int4> CmpGE(RValue<Int4> x, RValue<Int4> y)
+{
+ return CmpNLT(x, y);
+}
RValue<Int4> Max(RValue<Int4> x, RValue<Int4> y);
RValue<Int4> Min(RValue<Int4> x, RValue<Int4> y);
RValue<Int4> RoundInt(RValue<Float4> cast);
@@ -2022,8 +2029,14 @@
RValue<UInt4> CmpNEQ(RValue<UInt4> x, RValue<UInt4> y);
RValue<UInt4> CmpNLT(RValue<UInt4> x, RValue<UInt4> y);
RValue<UInt4> CmpNLE(RValue<UInt4> x, RValue<UInt4> y);
-inline RValue<UInt4> CmpGT(RValue<UInt4> x, RValue<UInt4> y) { return CmpNLE(x, y); }
-inline RValue<UInt4> CmpGE(RValue<UInt4> x, RValue<UInt4> y) { return CmpNLT(x, y); }
+inline RValue<UInt4> CmpGT(RValue<UInt4> x, RValue<UInt4> y)
+{
+ return CmpNLE(x, y);
+}
+inline RValue<UInt4> CmpGE(RValue<UInt4> x, RValue<UInt4> y)
+{
+ return CmpNLT(x, y);
+}
RValue<UInt4> Max(RValue<UInt4> x, RValue<UInt4> y);
RValue<UInt4> Min(RValue<UInt4> x, RValue<UInt4> y);
RValue<UInt4> MulHigh(RValue<UInt4> x, RValue<UInt4> y);
@@ -2058,7 +2071,7 @@
template<int T>
Float(const SwizzleMask1<Float4, T> &rhs);
-// RValue<Float> operator=(float rhs); // FIXME: Implement
+ // RValue<Float> operator=(float rhs); // FIXME: Implement
RValue<Float> operator=(RValue<Float> rhs);
RValue<Float> operator=(const Float &rhs);
RValue<Float> operator=(const Reference<Float> &rhs);
@@ -2128,35 +2141,35 @@
class Float2 : public LValue<Float2>
{
public:
-// explicit Float2(RValue<Byte2> cast);
-// explicit Float2(RValue<Short2> cast);
-// explicit Float2(RValue<UShort2> cast);
-// explicit Float2(RValue<Int2> cast);
-// explicit Float2(RValue<UInt2> cast);
+ // explicit Float2(RValue<Byte2> cast);
+ // explicit Float2(RValue<Short2> cast);
+ // explicit Float2(RValue<UShort2> cast);
+ // explicit Float2(RValue<Int2> cast);
+ // explicit Float2(RValue<UInt2> cast);
explicit Float2(RValue<Float4> cast);
Float2() = default;
-// Float2(float x, float y);
-// Float2(RValue<Float2> rhs);
-// Float2(const Float2 &rhs);
-// Float2(const Reference<Float2> &rhs);
-// Float2(RValue<Float> rhs);
-// Float2(const Float &rhs);
-// Float2(const Reference<Float> &rhs);
+ // Float2(float x, float y);
+ // Float2(RValue<Float2> rhs);
+ // Float2(const Float2 &rhs);
+ // Float2(const Reference<Float2> &rhs);
+ // Float2(RValue<Float> rhs);
+ // Float2(const Float &rhs);
+ // Float2(const Reference<Float> &rhs);
-// template<int T>
-// Float2(const SwizzleMask1<T> &rhs);
+ // template<int T>
+ // Float2(const SwizzleMask1<T> &rhs);
-// RValue<Float2> operator=(float replicate);
-// RValue<Float2> operator=(RValue<Float2> rhs);
-// RValue<Float2> operator=(const Float2 &rhs);
-// RValue<Float2> operator=(const Reference<Float2> &rhs);
-// RValue<Float2> operator=(RValue<Float> rhs);
-// RValue<Float2> operator=(const Float &rhs);
-// RValue<Float2> operator=(const Reference<Float> &rhs);
+ // RValue<Float2> operator=(float replicate);
+ // RValue<Float2> operator=(RValue<Float2> rhs);
+ // RValue<Float2> operator=(const Float2 &rhs);
+ // RValue<Float2> operator=(const Reference<Float2> &rhs);
+ // RValue<Float2> operator=(RValue<Float> rhs);
+ // RValue<Float2> operator=(const Float &rhs);
+ // RValue<Float2> operator=(const Reference<Float> &rhs);
-// template<int T>
-// RValue<Float2> operator=(const SwizzleMask1<T> &rhs);
+ // template<int T>
+ // RValue<Float2> operator=(const SwizzleMask1<T> &rhs);
static Type *getType();
};
@@ -2231,6 +2244,7 @@
static Type *getType();
static Float4 negative_inf();
static Float4 positive_inf();
+
private:
void constant(float x, float y, float z, float w);
void infinity_constant(bool negative);
@@ -2272,8 +2286,14 @@
RValue<Int4> CmpNEQ(RValue<Float4> x, RValue<Float4> y);
RValue<Int4> CmpNLT(RValue<Float4> x, RValue<Float4> y);
RValue<Int4> CmpNLE(RValue<Float4> x, RValue<Float4> y);
-inline RValue<Int4> CmpGT(RValue<Float4> x, RValue<Float4> y) { return CmpNLE(x, y); }
-inline RValue<Int4> CmpGE(RValue<Float4> x, RValue<Float4> y) { return CmpNLT(x, y); }
+inline RValue<Int4> CmpGT(RValue<Float4> x, RValue<Float4> y)
+{
+ return CmpNLE(x, y);
+}
+inline RValue<Int4> CmpGE(RValue<Float4> x, RValue<Float4> y)
+{
+ return CmpNLT(x, y);
+}
// Unordered comparison functions
RValue<Int4> CmpUEQ(RValue<Float4> x, RValue<Float4> y);
@@ -2282,8 +2302,14 @@
RValue<Int4> CmpUNEQ(RValue<Float4> x, RValue<Float4> y);
RValue<Int4> CmpUNLT(RValue<Float4> x, RValue<Float4> y);
RValue<Int4> CmpUNLE(RValue<Float4> x, RValue<Float4> y);
-inline RValue<Int4> CmpUGT(RValue<Float4> x, RValue<Float4> y) { return CmpUNLE(x, y); }
-inline RValue<Int4> CmpUGE(RValue<Float4> x, RValue<Float4> y) { return CmpUNLT(x, y); }
+inline RValue<Int4> CmpUGT(RValue<Float4> x, RValue<Float4> y)
+{
+ return CmpUNLE(x, y);
+}
+inline RValue<Int4> CmpUGE(RValue<Float4> x, RValue<Float4> y)
+{
+ return CmpUNLT(x, y);
+}
RValue<Int4> IsInf(RValue<Float4> x);
RValue<Int4> IsNan(RValue<Float4> x);
@@ -2337,14 +2363,16 @@
{
public:
template<class S>
- Pointer(RValue<Pointer<S>> pointerS, int alignment = 1) : alignment(alignment)
+ Pointer(RValue<Pointer<S>> pointerS, int alignment = 1)
+ : alignment(alignment)
{
Value *pointerT = Nucleus::createBitCast(pointerS.value, Nucleus::getPointerType(T::getType()));
LValue<Pointer<T>>::storeValue(pointerT);
}
template<class S>
- Pointer(const Pointer<S> &pointer, int alignment = 1) : alignment(alignment)
+ Pointer(const Pointer<S> &pointer, int alignment = 1)
+ : alignment(alignment)
{
Value *pointerS = pointer.loadValue();
Value *pointerT = Nucleus::createBitCast(pointerS, Nucleus::getPointerType(T::getType()));
@@ -2390,7 +2418,7 @@
RValue<Pointer<Byte>> operator-=(Pointer<Byte> &lhs, RValue<Int> offset);
RValue<Pointer<Byte>> operator-=(Pointer<Byte> &lhs, RValue<UInt> offset);
-template <typename T>
+template<typename T>
RValue<Bool> operator==(const Pointer<T> &lhs, const Pointer<T> &rhs)
{
return RValue<Bool>(Nucleus::createPtrEQ(lhs.loadValue(), rhs.loadValue()));
@@ -2456,7 +2484,7 @@
// self() returns the this pointer to this Array object.
// This function exists because operator&() is overloaded by LValue<T>.
- inline Array* self() { return this; }
+ inline Array *self() { return this; }
};
// RValue<Array<T>> operator++(Array<T> &val, int); // Post-increment
@@ -2468,8 +2496,8 @@
// ValueOf returns a rr::Value* for the given C-type, RValue<T>, LValue<T>
// or Reference<T>.
-template <typename T>
-inline Value* ValueOf(const T &v)
+template<typename T>
+inline Value *ValueOf(const T &v)
{
return ReactorType<T>::cast(v).loadValue();
}
@@ -2479,7 +2507,7 @@
template<class T>
void Return(const T &ret)
{
- static_assert(CanBeUsedAsReturn< ReactorTypeT<T> >::value, "Unsupported type for Return()");
+ static_assert(CanBeUsedAsReturn<ReactorTypeT<T>>::value, "Unsupported type for Return()");
Nucleus::createRet(ValueOf<T>(ret));
// Place any unreachable instructions in an unreferenced block.
Nucleus::setInsertBlock(Nucleus::createBasicBlock());
@@ -2513,7 +2541,7 @@
protected:
Nucleus *core;
- std::vector<Type*> arguments;
+ std::vector<Type *> arguments;
};
template<typename Return>
@@ -2543,12 +2571,12 @@
// Hide base implementations of operator()
- RoutineType operator()(const char* name, ...)
+ RoutineType operator()(const char *name, ...)
{
return RoutineType(BaseType::operator()(name));
}
- RoutineType operator()(const Config::Edit& cfg, const char* name, ...)
+ RoutineType operator()(const Config::Edit &cfg, const char *name, ...)
{
return RoutineType(BaseType::operator()(cfg, name));
}
@@ -2563,11 +2591,12 @@
namespace rr {
template<class T>
-LValue<T>::LValue(int arraySize) : Variable(T::getType(), arraySize)
+LValue<T>::LValue(int arraySize)
+ : Variable(T::getType(), arraySize)
{
#ifdef ENABLE_RR_DEBUG_INFO
materialize();
-#endif // ENABLE_RR_DEBUG_INFO
+#endif // ENABLE_RR_DEBUG_INFO
}
inline void Variable::materialize() const
@@ -2632,7 +2661,8 @@
}
template<class T>
-Reference<T>::Reference(Value *pointer, int alignment) : alignment(alignment)
+Reference<T>::Reference(Value *pointer, int alignment)
+ : alignment(alignment)
{
address = pointer;
}
@@ -2674,16 +2704,17 @@
#ifdef ENABLE_RR_DEBUG_INFO
template<class T>
-RValue<T>::RValue(const RValue<T> &rvalue) : value(rvalue.value)
+RValue<T>::RValue(const RValue<T> &rvalue)
+ : value(rvalue.value)
{
RR_DEBUG_INFO_EMIT_VAR(value);
}
-#endif // ENABLE_RR_DEBUG_INFO
+#endif // ENABLE_RR_DEBUG_INFO
template<class T>
RValue<T>::RValue(Value *rvalue)
{
- assert(Nucleus::createBitCast(rvalue, T::getType()) == rvalue); // Run-time type should match T, so bitcast is no-op.
+ assert(Nucleus::createBitCast(rvalue, T::getType()) == rvalue); // Run-time type should match T, so bitcast is no-op.
value = rvalue;
RR_DEBUG_INFO_EMIT_VAR(value);
@@ -2766,7 +2797,7 @@
}
template<class Vector4, int T>
-SwizzleMask1<Vector4, T>::operator RValue<typename Scalar<Vector4>::Type>() const // FIXME: Call a non-template function
+SwizzleMask1<Vector4, T>::operator RValue<typename Scalar<Vector4>::Type>() const // FIXME: Call a non-template function
{
RR_DEBUG_INFO_UPDATE_LOC();
return Extract(*parent, T & 0x3);
@@ -2796,7 +2827,7 @@
}
template<class Vector4, int T>
-RValue<Vector4> SwizzleMask1<Vector4, T>::operator=(RValue<typename Scalar<Vector4>::Type> rhs) // FIXME: Call a non-template function
+RValue<Vector4> SwizzleMask1<Vector4, T>::operator=(RValue<typename Scalar<Vector4>::Type> rhs) // FIXME: Call a non-template function
{
RR_DEBUG_INFO_UPDATE_LOC();
return *parent = Insert(*parent, rhs, T & 0x3);
@@ -2831,40 +2862,46 @@
}
template<int T>
-Float4::Float4(const SwizzleMask1<Float4, T> &rhs) : XYZW(this)
+Float4::Float4(const SwizzleMask1<Float4, T> &rhs)
+ : XYZW(this)
{
*this = rhs.operator RValue<Float4>();
}
template<int T>
-Float4::Float4(const Swizzle4<Float4, T> &rhs) : XYZW(this)
+Float4::Float4(const Swizzle4<Float4, T> &rhs)
+ : XYZW(this)
{
*this = rhs.operator RValue<Float4>();
}
template<int X, int Y>
-Float4::Float4(const Swizzle2<Float4, X> &x, const Swizzle2<Float4, Y> &y) : XYZW(this)
+Float4::Float4(const Swizzle2<Float4, X> &x, const Swizzle2<Float4, Y> &y)
+ : XYZW(this)
{
RR_DEBUG_INFO_UPDATE_LOC();
*this = ShuffleLowHigh(*x.parent, *y.parent, (uint16_t(X) & 0xFF00u) | (uint16_t(Y >> 8) & 0x00FFu));
}
template<int X, int Y>
-Float4::Float4(const SwizzleMask2<Float4, X> &x, const Swizzle2<Float4, Y> &y) : XYZW(this)
+Float4::Float4(const SwizzleMask2<Float4, X> &x, const Swizzle2<Float4, Y> &y)
+ : XYZW(this)
{
RR_DEBUG_INFO_UPDATE_LOC();
*this = ShuffleLowHigh(*x.parent, *y.parent, (uint16_t(X) & 0xFF00u) | (uint16_t(Y >> 8) & 0x00FFu));
}
template<int X, int Y>
-Float4::Float4(const Swizzle2<Float4, X> &x, const SwizzleMask2<Float4, Y> &y) : XYZW(this)
+Float4::Float4(const Swizzle2<Float4, X> &x, const SwizzleMask2<Float4, Y> &y)
+ : XYZW(this)
{
RR_DEBUG_INFO_UPDATE_LOC();
*this = ShuffleLowHigh(*x.parent, *y.parent, (uint16_t(X) & 0xFF00u) | (uint16_t(Y >> 8) & 0x00FFu));
}
template<int X, int Y>
-Float4::Float4(const SwizzleMask2<Float4, X> &x, const SwizzleMask2<Float4, Y> &y) : XYZW(this)
+Float4::Float4(const SwizzleMask2<Float4, X> &x, const SwizzleMask2<Float4, Y> &y)
+ : XYZW(this)
{
RR_DEBUG_INFO_UPDATE_LOC();
*this = ShuffleLowHigh(*x.parent, *y.parent, (uint16_t(X) & 0xFF00u) | (uint16_t(Y >> 8) & 0x00FFu));
@@ -2883,42 +2920,49 @@
}
// Returns a reactor pointer to the fixed-address ptr.
-RValue<Pointer<Byte>> ConstantPointer(void const * ptr);
+RValue<Pointer<Byte>> ConstantPointer(void const *ptr);
// Returns a reactor pointer to an immutable copy of the data of size bytes.
-RValue<Pointer<Byte>> ConstantData(void const * data, size_t size);
+RValue<Pointer<Byte>> ConstantData(void const *data, size_t size);
template<class T>
-Pointer<T>::Pointer(Argument<Pointer<T>> argument) : alignment(1)
+Pointer<T>::Pointer(Argument<Pointer<T>> argument)
+ : alignment(1)
{
LValue<Pointer<T>>::storeValue(argument.value);
}
template<class T>
-Pointer<T>::Pointer() : alignment(1) {}
+Pointer<T>::Pointer()
+ : alignment(1)
+{}
template<class T>
-Pointer<T>::Pointer(RValue<Pointer<T>> rhs) : alignment(1)
+Pointer<T>::Pointer(RValue<Pointer<T>> rhs)
+ : alignment(1)
{
LValue<Pointer<T>>::storeValue(rhs.value);
}
template<class T>
-Pointer<T>::Pointer(const Pointer<T> &rhs) : alignment(rhs.alignment)
+Pointer<T>::Pointer(const Pointer<T> &rhs)
+ : alignment(rhs.alignment)
{
Value *value = rhs.loadValue();
LValue<Pointer<T>>::storeValue(value);
}
template<class T>
-Pointer<T>::Pointer(const Reference<Pointer<T>> &rhs) : alignment(rhs.getAlignment())
+Pointer<T>::Pointer(const Reference<Pointer<T>> &rhs)
+ : alignment(rhs.getAlignment())
{
Value *value = rhs.loadValue();
LValue<Pointer<T>>::storeValue(value);
}
template<class T>
-Pointer<T>::Pointer(std::nullptr_t) : alignment(1)
+Pointer<T>::Pointer(std::nullptr_t)
+ : alignment(1)
{
Value *value = Nucleus::createNullPointer(T::getType());
LValue<Pointer<T>>::storeValue(value);
@@ -3008,7 +3052,8 @@
}
template<class T, int S>
-Array<T, S>::Array(int size) : LValue<T>(size)
+Array<T, S>::Array(int size)
+ : LValue<T>(size)
{
}
@@ -3110,7 +3155,7 @@
{
core = new Nucleus();
- Type *types[] = {Arguments::getType()...};
+ Type *types[] = { Arguments::getType()... };
for(Type *type : types)
{
if(type != Void::getType())
@@ -3204,12 +3249,13 @@
// Calls the function pointer fptr with the given arguments, return type
// and parameter types. Returns the call's return value if the function has
// a non-void return type.
-Value* Call(RValue<Pointer<Byte>> fptr, Type* retTy, std::initializer_list<Value*> args, std::initializer_list<Type*> paramTys);
+Value *Call(RValue<Pointer<Byte>> fptr, Type *retTy, std::initializer_list<Value *> args, std::initializer_list<Type *> paramTys);
-template <typename F>
-class CallHelper {};
+template<typename F>
+class CallHelper
+{};
-template<typename Return, typename ... Arguments>
+template<typename Return, typename... Arguments>
class CallHelper<Return(Arguments...)>
{
public:
@@ -3218,74 +3264,77 @@
static inline RReturn Call(Return(fptr)(Arguments...), CToReactorT<Arguments>... args)
{
return RValue<RReturn>(rr::Call(
- ConstantPointer(reinterpret_cast<void*>(fptr)),
- RReturn::getType(),
- { ValueOf(args) ... },
- { CToReactorT<Arguments>::getType() ... }));
+ ConstantPointer(reinterpret_cast<void *>(fptr)),
+ RReturn::getType(),
+ { ValueOf(args)... },
+ { CToReactorT<Arguments>::getType()... }));
}
static inline RReturn Call(Pointer<Byte> fptr, CToReactorT<Arguments>... args)
{
return RValue<RReturn>(rr::Call(
- fptr,
- RReturn::getType(),
- { ValueOf(args) ... },
- { CToReactorT<Arguments>::getType() ... }));
+ fptr,
+ RReturn::getType(),
+ { ValueOf(args)... },
+ { CToReactorT<Arguments>::getType()... }));
}
};
-template<typename ... Arguments>
+template<typename... Arguments>
class CallHelper<void(Arguments...)>
{
public:
static inline void Call(void(fptr)(Arguments...), CToReactorT<Arguments>... args)
{
- rr::Call(ConstantPointer(reinterpret_cast<void*>(fptr)),
- Void::getType(),
- { ValueOf(args) ... },
- { CToReactorT<Arguments>::getType() ... });
+ rr::Call(ConstantPointer(reinterpret_cast<void *>(fptr)),
+ Void::getType(),
+ { ValueOf(args)... },
+ { CToReactorT<Arguments>::getType()... });
}
static inline void Call(Pointer<Byte> fptr, CToReactorT<Arguments>... args)
{
rr::Call(fptr,
- Void::getType(),
- { ValueOf(args) ... },
- { CToReactorT<Arguments>::getType() ... });
+ Void::getType(),
+ { ValueOf(args)... },
+ { CToReactorT<Arguments>::getType()... });
}
};
-template <typename T>
-inline ReactorTypeT<T> CastToReactor(const T& v) { return ReactorType<T>::cast(v); }
+template<typename T>
+inline ReactorTypeT<T> CastToReactor(const T &v)
+{
+ return ReactorType<T>::cast(v);
+}
// Calls the static function pointer fptr with the given arguments args.
-template<typename Return, typename ... CArgs, typename ... RArgs>
-inline CToReactorT<Return> Call(Return(fptr)(CArgs...), RArgs&&... args)
+template<typename Return, typename... CArgs, typename... RArgs>
+inline CToReactorT<Return> Call(Return(fptr)(CArgs...), RArgs &&... args)
{
return CallHelper<Return(CArgs...)>::Call(fptr, CastToReactor(std::forward<RArgs>(args))...);
}
// Calls the static function pointer fptr with the given arguments args.
// Overload for calling functions with void return type.
-template<typename ... CArgs, typename ... RArgs>
-inline void Call(void(fptr)(CArgs...), RArgs&&... args)
+template<typename... CArgs, typename... RArgs>
+inline void Call(void(fptr)(CArgs...), RArgs &&... args)
{
CallHelper<void(CArgs...)>::Call(fptr, CastToReactor(std::forward<RArgs>(args))...);
}
// Calls the member function pointer fptr with the given arguments args.
// object can be a Class*, or a Pointer<Byte>.
-template<typename Return, typename Class, typename C, typename ... CArgs, typename ... RArgs>
-inline CToReactorT<Return> Call(Return(Class::* fptr)(CArgs...), C&& object, RArgs&&... args)
+template<typename Return, typename Class, typename C, typename... CArgs, typename... RArgs>
+inline CToReactorT<Return> Call(Return (Class::*fptr)(CArgs...), C &&object, RArgs &&... args)
{
- using Helper = CallHelper<Return(Class*, void*, CArgs...)>;
+ using Helper = CallHelper<Return(Class *, void *, CArgs...)>;
using fptrTy = decltype(fptr);
struct Static
{
- static inline Return Call(Class* object, void* fptrptr, CArgs... args)
+ static inline Return Call(Class *object, void *fptrptr, CArgs... args)
{
- auto fptr = *reinterpret_cast<fptrTy*>(fptrptr);
+ auto fptr = *reinterpret_cast<fptrTy *>(fptrptr);
return (object->*fptr)(std::forward<CArgs>(args)...);
}
};
@@ -3299,17 +3348,17 @@
// Calls the member function pointer fptr with the given arguments args.
// Overload for calling functions with void return type.
// object can be a Class*, or a Pointer<Byte>.
-template<typename Class, typename C, typename ... CArgs, typename ... RArgs>
-inline void Call(void(Class::* fptr)(CArgs...), C&& object, RArgs&&... args)
+template<typename Class, typename C, typename... CArgs, typename... RArgs>
+inline void Call(void (Class::*fptr)(CArgs...), C &&object, RArgs &&... args)
{
- using Helper = CallHelper<void(Class*, void*, CArgs...)>;
+ using Helper = CallHelper<void(Class *, void *, CArgs...)>;
using fptrTy = decltype(fptr);
struct Static
{
- static inline void Call(Class* object, void* fptrptr, CArgs... args)
+ static inline void Call(Class *object, void *fptrptr, CArgs... args)
{
- auto fptr = *reinterpret_cast<fptrTy*>(fptrptr);
+ auto fptr = *reinterpret_cast<fptrTy *>(fptrptr);
(object->*fptr)(std::forward<CArgs>(args)...);
}
};
@@ -3322,8 +3371,8 @@
// Calls the Reactor function pointer fptr with the signature
// FUNCTION_SIGNATURE and arguments.
-template<typename FUNCTION_SIGNATURE, typename ... RArgs>
-inline void Call(Pointer<Byte> fptr, RArgs&& ... args)
+template<typename FUNCTION_SIGNATURE, typename... RArgs>
+inline void Call(Pointer<Byte> fptr, RArgs &&... args)
{
CallHelper<FUNCTION_SIGNATURE>::Call(fptr, CastToReactor(std::forward<RArgs>(args))...);
}
@@ -3335,7 +3384,8 @@
class ForData
{
public:
- ForData(bool init) : loopOnce(init)
+ ForData(bool init)
+ : loopOnce(init)
{
}
@@ -3391,7 +3441,8 @@
class IfElseData
{
public:
- IfElseData(RValue<Bool> cmp) : iteration(0)
+ IfElseData(RValue<Bool> cmp)
+ : iteration(0)
{
condition = cmp.value;
@@ -3442,39 +3493,48 @@
int iteration;
};
-#define For(init, cond, inc) \
-for(ForData for__ = true; for__; for__ = false) \
-for(init; for__.setup() && for__.test(cond); inc, for__.end())
+#define For(init, cond, inc) \
+ for(ForData for__ = true; for__; for__ = false) \
+ for(init; for__.setup() && for__.test(cond); inc, for__.end())
#define While(cond) For((void)0, cond, (void)0)
-#define Do \
-{ \
- BasicBlock *body__ = Nucleus::createBasicBlock(); \
- Nucleus::createBr(body__); \
- Nucleus::setInsertBlock(body__);
+#define Do \
+ { \
+ BasicBlock *body__ = Nucleus::createBasicBlock(); \
+ Nucleus::createBr(body__); \
+ Nucleus::setInsertBlock(body__);
#define Until(cond) \
BasicBlock *end__ = Nucleus::createBasicBlock(); \
Nucleus::createCondBr((cond).value, end__, body__); \
Nucleus::setInsertBlock(end__); \
-} do {} while(false) // Require a semi-colon at the end of the Until()
+ } \
+ do \
+ { \
+ } while(false) // Require a semi-colon at the end of the Until()
-enum {IF_BLOCK__, ELSE_CLAUSE__, ELSE_BLOCK__, IFELSE_NUM__};
+enum
+{
+ IF_BLOCK__,
+ ELSE_CLAUSE__,
+ ELSE_BLOCK__,
+ IFELSE_NUM__
+};
-#define If(cond) \
-for(IfElseData ifElse__(cond); ifElse__ < IFELSE_NUM__; ++ifElse__) \
-if(ifElse__ == IF_BLOCK__)
+#define If(cond) \
+ for(IfElseData ifElse__(cond); ifElse__ < IFELSE_NUM__; ++ifElse__) \
+ if(ifElse__ == IF_BLOCK__)
-#define Else \
-else if(ifElse__ == ELSE_CLAUSE__) \
-{ \
- ifElse__.elseClause(); \
-} \
-else // ELSE_BLOCK__
+#define Else \
+ else if(ifElse__ == ELSE_CLAUSE__) \
+ { \
+ ifElse__.elseClause(); \
+ } \
+ else // ELSE_BLOCK__
} // namespace rr
#include "Traits.inl"
-#endif // rr_Reactor_hpp
+#endif // rr_Reactor_hpp
diff --git a/src/Reactor/ReactorUnitTests.cpp b/src/Reactor/ReactorUnitTests.cpp
index 8ffeb7c..ff69d2f 100644
--- a/src/Reactor/ReactorUnitTests.cpp
+++ b/src/Reactor/ReactorUnitTests.cpp
@@ -12,8 +12,8 @@
// See the License for the specific language governing permissions and
// limitations under the License.
-#include "Reactor.hpp"
#include "Coroutine.hpp"
+#include "Reactor.hpp"
#include "gtest/gtest.h"
@@ -30,8 +30,12 @@
struct float4_value
{
float4_value() = default;
- explicit float4_value(float rep) : v{ rep, rep, rep, rep } {}
- float4_value(float x, float y, float z, float w) : v{ x, y, z, w } {}
+ explicit float4_value(float rep)
+ : v{ rep, rep, rep, rep }
+ {}
+ float4_value(float x, float y, float z, float w)
+ : v{ x, y, z, w }
+ {}
bool operator==(const float4_value &rhs) const
{
@@ -39,7 +43,8 @@
}
// For gtest printing
- friend std::ostream& operator<<(std::ostream& os, const float4_value& value) {
+ friend std::ostream &operator<<(std::ostream &os, const float4_value &value)
+ {
return os << "[" << value.v[0] << ", " << value.v[1] << ", " << value.v[2] << ", " << value.v[3] << "]";
}
@@ -47,26 +52,25 @@
};
// For gtest printing of pairs
-namespace std
+namespace std {
+template<typename T, typename U>
+std::ostream &operator<<(std::ostream &os, const std::pair<T, U> &value)
{
- template <typename T, typename U>
- std::ostream& operator<<(std::ostream& os, const std::pair<T, U>& value) {
- return os << "{ " << value.first << ", " << value.second << " }";
- }
+ return os << "{ " << value.first << ", " << value.second << " }";
}
-
+} // namespace std
// Invoke a void(float4*) routine on &v.v, returning wrapped result in v
-template <typename RoutineType>
-float4_value invokeRoutine(RoutineType& routine, float4_value v)
+template<typename RoutineType>
+float4_value invokeRoutine(RoutineType &routine, float4_value v)
{
routine(&v.v);
return v;
}
// Invoke a void(float4*, float4*) routine on &v1.v, &v2.v returning wrapped result in v1
-template <typename RoutineType>
-float4_value invokeRoutine(RoutineType& routine, float4_value v1, float4_value v2)
+template<typename RoutineType>
+float4_value invokeRoutine(RoutineType &routine, float4_value v1, float4_value v2)
{
routine(&v1.v, &v2.v);
return v1;
@@ -89,7 +93,7 @@
TEST(ReactorUnitTests, Sample)
{
- FunctionT<int(int*, int)> function;
+ FunctionT<int(int *, int)> function;
{
Pointer<Int> p = function.Arg<0>();
Int x = p[-1];
@@ -114,7 +118,7 @@
if(routine)
{
- int one[2] = {1, 0};
+ int one[2] = { 1, 0 };
int result = routine(&one[1], 2);
EXPECT_EQ(result, reference(&one[1], 2));
}
@@ -146,7 +150,7 @@
if(routine)
{
int result = routine();
- EXPECT_EQ(result, result); // Anything is fine, just don't crash
+ EXPECT_EQ(result, result); // Anything is fine, just don't crash
}
}
@@ -197,15 +201,15 @@
TEST(ReactorUnitTests, SubVectorLoadStore)
{
- FunctionT<int(void*, void*)> function;
+ FunctionT<int(void *, void *)> function;
{
Pointer<Byte> in = function.Arg<0>();
Pointer<Byte> out = function.Arg<1>();
- *Pointer<Int4>(out + 16 * 0) = *Pointer<Int4>(in + 16 * 0);
+ *Pointer<Int4>(out + 16 * 0) = *Pointer<Int4>(in + 16 * 0);
*Pointer<Short4>(out + 16 * 1) = *Pointer<Short4>(in + 16 * 1);
- *Pointer<Byte8>(out + 16 * 2) = *Pointer<Byte8>(in + 16 * 2);
- *Pointer<Byte4>(out + 16 * 3) = *Pointer<Byte4>(in + 16 * 3);
+ *Pointer<Byte8>(out + 16 * 2) = *Pointer<Byte8>(in + 16 * 2);
+ *Pointer<Byte4>(out + 16 * 3) = *Pointer<Byte4>(in + 16 * 3);
*Pointer<Short2>(out + 16 * 4) = *Pointer<Short2>(in + 16 * 4);
Return(0);
@@ -215,17 +219,17 @@
if(routine)
{
- int8_t in[16 * 5] = {1, 2, 3, 4, 5, 6, 7, 8, 9, 10, 11, 12, 13, 14, 15, 16,
- 17, 18, 19, 20, 21, 22, 23, 24, 0, 0, 0, 0, 0, 0, 0, 0,
- 25, 26, 27, 28, 29, 30, 31, 32, 0, 0, 0, 0, 0, 0, 0, 0,
- 33, 34, 35, 36, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0,
- 37, 38, 39, 40, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0};
+ int8_t in[16 * 5] = { 1, 2, 3, 4, 5, 6, 7, 8, 9, 10, 11, 12, 13, 14, 15, 16,
+ 17, 18, 19, 20, 21, 22, 23, 24, 0, 0, 0, 0, 0, 0, 0, 0,
+ 25, 26, 27, 28, 29, 30, 31, 32, 0, 0, 0, 0, 0, 0, 0, 0,
+ 33, 34, 35, 36, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0,
+ 37, 38, 39, 40, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0 };
- int8_t out[16 * 5] = {-1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1,
- -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1,
- -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1,
- -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1,
- -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1};
+ int8_t out[16 * 5] = { -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1,
+ -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1,
+ -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1,
+ -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1,
+ -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1 };
routine(in, out);
@@ -235,9 +239,9 @@
{
int i = row * 16 + col;
- if(in[i] == 0)
+ if(in[i] == 0)
{
- EXPECT_EQ(out[i], -1) << "Row " << row << " column " << col << " not left untouched.";
+ EXPECT_EQ(out[i], -1) << "Row " << row << " column " << col << " not left untouched.";
}
else
{
@@ -250,7 +254,7 @@
TEST(ReactorUnitTests, VectorConstant)
{
- FunctionT<int(void*)> function;
+ FunctionT<int(void *)> function;
{
Pointer<Byte> out = function.Arg<0>();
@@ -266,15 +270,15 @@
if(routine)
{
- int8_t out[16 * 4] = {-1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1,
- -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1,
- -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1,
- -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1};
+ int8_t out[16 * 4] = { -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1,
+ -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1,
+ -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1,
+ -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1 };
- int8_t exp[16 * 4] = {1, 2, 3, 4, 5, 6, 7, 8, 9, 10, 11, 12, 13, 14, 15, 16,
- 17, 18, 19, 20, 21, 22, 23, 24, -1, -1, -1, -1, -1, -1, -1, -1,
- 25, 26, 27, 28, 29, 30, 31, 32, -1, -1, -1, -1, -1, -1, -1, -1,
- 33, 34, 35, 36, 37, 38, 39, 40, -1, -1, -1, -1, -1, -1, -1, -1};
+ int8_t exp[16 * 4] = { 1, 2, 3, 4, 5, 6, 7, 8, 9, 10, 11, 12, 13, 14, 15, 16,
+ 17, 18, 19, 20, 21, 22, 23, 24, -1, -1, -1, -1, -1, -1, -1, -1,
+ 25, 26, 27, 28, 29, 30, 31, 32, -1, -1, -1, -1, -1, -1, -1, -1,
+ 33, 34, 35, 36, 37, 38, 39, 40, -1, -1, -1, -1, -1, -1, -1, -1 };
routine(out);
@@ -292,11 +296,11 @@
TEST(ReactorUnitTests, Concatenate)
{
- FunctionT<int(void*)> function;
+ FunctionT<int(void *)> function;
{
Pointer<Byte> out = function.Arg<0>();
- *Pointer<Int4>(out + 16 * 0) = Int4(Int2(0x04030201, 0x08070605), Int2(0x0C0B0A09, 0x100F0E0D));
+ *Pointer<Int4>(out + 16 * 0) = Int4(Int2(0x04030201, 0x08070605), Int2(0x0C0B0A09, 0x100F0E0D));
*Pointer<Short8>(out + 16 * 1) = Short8(Short4(0x0201, 0x0403, 0x0605, 0x0807), Short4(0x0A09, 0x0C0B, 0x0E0D, 0x100F));
Return(0);
@@ -306,11 +310,11 @@
if(routine)
{
- int8_t ref[16 * 5] = {1, 2, 3, 4, 5, 6, 7, 8, 9, 10, 11, 12, 13, 14, 15, 16,
- 1, 2, 3, 4, 5, 6, 7, 8, 9, 10, 11, 12, 13, 14, 15, 16};
+ int8_t ref[16 * 5] = { 1, 2, 3, 4, 5, 6, 7, 8, 9, 10, 11, 12, 13, 14, 15, 16,
+ 1, 2, 3, 4, 5, 6, 7, 8, 9, 10, 11, 12, 13, 14, 15, 16 };
- int8_t out[16 * 5] = {-1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1,
- -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1};
+ int8_t out[16 * 5] = { -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1,
+ -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1 };
routine(out);
@@ -328,8 +332,7 @@
TEST(ReactorUnitTests, Swizzle)
{
- auto swizzleCode = [](int i) -> uint16_t
- {
+ auto swizzleCode = [](int i) -> uint16_t {
auto x = (i >> 0) & 0x03;
auto y = (i >> 2) & 0x03;
auto z = (i >> 4) & 0x03;
@@ -338,7 +341,7 @@
};
{
- FunctionT<int(void*)> function;
+ FunctionT<int(void *)> function;
{
Pointer<Byte> out = function.Arg<0>();
@@ -362,13 +365,13 @@
for(int i = 0; i < 256; i++)
{
*Pointer<Short4>(out + 16 * (512 + 6) + (8 * i)) =
- Swizzle(Short4(1, 2, 3, 4), swizzleCode(i));
+ Swizzle(Short4(1, 2, 3, 4), swizzleCode(i));
}
for(int i = 0; i < 256; i++)
{
*Pointer<Int4>(out + 16 * (512 + 6 + i) + (8 * 256)) =
- Swizzle(Int4(1, 2, 3, 4), swizzleCode(i));
+ Swizzle(Int4(1, 2, 3, 4), swizzleCode(i));
}
Return(0);
@@ -436,14 +439,14 @@
for(int i = 0; i < 256; i++)
{
- EXPECT_EQ(out.i[4 + i/2][0 + (i%2) * 2] & 0xFFFF,
- ((i >> 0) & 0x03) + 1);
- EXPECT_EQ(out.i[4 + i/2][0 + (i%2) * 2] >> 16,
- ((i >> 2) & 0x03) + 1);
- EXPECT_EQ(out.i[4 + i/2][1 + (i%2) * 2] & 0xFFFF,
- ((i >> 4) & 0x03) + 1);
- EXPECT_EQ(out.i[4 + i/2][1 + (i%2) * 2] >> 16,
- ((i >> 6) & 0x03) + 1);
+ EXPECT_EQ(out.i[4 + i / 2][0 + (i % 2) * 2] & 0xFFFF,
+ ((i >> 0) & 0x03) + 1);
+ EXPECT_EQ(out.i[4 + i / 2][0 + (i % 2) * 2] >> 16,
+ ((i >> 2) & 0x03) + 1);
+ EXPECT_EQ(out.i[4 + i / 2][1 + (i % 2) * 2] & 0xFFFF,
+ ((i >> 4) & 0x03) + 1);
+ EXPECT_EQ(out.i[4 + i / 2][1 + (i % 2) * 2] >> 16,
+ ((i >> 6) & 0x03) + 1);
}
for(int i = 0; i < 256; i++)
@@ -483,14 +486,13 @@
auto rangeIndexToSelect = [](int i) {
return static_cast<unsigned short>(
- (((i >> 9) & 7) << 0) |
- (((i >> 6) & 7) << 4) |
- (((i >> 3) & 7) << 8) |
- (((i >> 0) & 7) << 12)
- );
+ (((i >> 9) & 7) << 0) |
+ (((i >> 6) & 7) << 4) |
+ (((i >> 3) & 7) << 8) |
+ (((i >> 0) & 7) << 12));
};
- FunctionT<int(void*)> function;
+ FunctionT<int(void *)> function;
{
Pointer<Byte> out = function.Arg<0>();
@@ -554,7 +556,6 @@
}
}
}
-
}
TEST(ReactorUnitTests, Branching)
@@ -583,24 +584,23 @@
}
For(Int i = 0, i < 5, i++)
- x += 10000;
+ x += 10000;
}
- For(Int i = 0, i < 10, i++)
- for(int i = 0; i < 10; i++)
- For(Int i = 0, i < 10, i++)
- {
- x += 1000000;
- }
+ For(Int i = 0, i < 10, i++) for(int i = 0; i < 10; i++)
+ For(Int i = 0, i < 10, i++)
+ {
+ x += 1000000;
+ }
For(Int i = 0, i < 2, i++)
- If(x == 1000402222)
- {
- If(x != 1000402222)
- x += 1000000000;
- }
- Else
- x = -5;
+ If(x == 1000402222)
+ {
+ If(x != 1000402222)
+ x += 1000000000;
+ }
+ Else
+ x = -5;
Return(x);
}
@@ -613,12 +613,11 @@
EXPECT_EQ(result, 1000402222);
}
-
}
TEST(ReactorUnitTests, MinMax)
{
- FunctionT<int(void*)> function;
+ FunctionT<int(void *)> function;
{
Pointer<Byte> out = function.Arg<0>();
@@ -702,7 +701,7 @@
TEST(ReactorUnitTests, NotNeg)
{
- FunctionT<int(void*)> function;
+ FunctionT<int(void *)> function;
{
Pointer<Byte> out = function.Arg<0>();
@@ -780,13 +779,13 @@
TEST(ReactorUnitTests, FPtoUI)
{
- FunctionT<int(void*)> function;
+ FunctionT<int(void *)> function;
{
Pointer<Byte> out = function.Arg<0>();
- *Pointer<UInt>(out + 0) = UInt(Float(0xF0000000u));
- *Pointer<UInt>(out + 4) = UInt(Float(0xC0000000u));
- *Pointer<UInt>(out + 8) = UInt(Float(0x00000001u));
+ *Pointer<UInt>(out + 0) = UInt(Float(0xF0000000u));
+ *Pointer<UInt>(out + 4) = UInt(Float(0xC0000000u));
+ *Pointer<UInt>(out + 8) = UInt(Float(0x00000001u));
*Pointer<UInt>(out + 12) = UInt(Float(0xF000F000u));
*Pointer<UInt4>(out + 16) = UInt4(Float4(0xF0000000u, 0x80000000u, 0x00000000u, 0xCCCC0000u));
@@ -818,7 +817,7 @@
TEST(ReactorUnitTests, VectorCompare)
{
- FunctionT<int(void*)> function;
+ FunctionT<int(void *)> function;
{
Pointer<Byte> out = function.Arg<0>();
@@ -873,52 +872,52 @@
TEST(ReactorUnitTests, SaturatedAddAndSubtract)
{
- FunctionT<int(void*)> function;
+ FunctionT<int(void *)> function;
{
Pointer<Byte> out = function.Arg<0>();
*Pointer<Byte8>(out + 8 * 0) =
- AddSat(Byte8(1, 2, 3, 4, 5, 6, 7, 8),
- Byte8(7, 6, 5, 4, 3, 2, 1, 0));
+ AddSat(Byte8(1, 2, 3, 4, 5, 6, 7, 8),
+ Byte8(7, 6, 5, 4, 3, 2, 1, 0));
*Pointer<Byte8>(out + 8 * 1) =
- AddSat(Byte8(0xFE, 0xFE, 0xFE, 0xFE, 0xFE, 0xFE, 0xFE, 0xFE),
- Byte8(7, 6, 5, 4, 3, 2, 1, 0));
+ AddSat(Byte8(0xFE, 0xFE, 0xFE, 0xFE, 0xFE, 0xFE, 0xFE, 0xFE),
+ Byte8(7, 6, 5, 4, 3, 2, 1, 0));
*Pointer<Byte8>(out + 8 * 2) =
- SubSat(Byte8(1, 2, 3, 4, 5, 6, 7, 8),
- Byte8(7, 6, 5, 4, 3, 2, 1, 0));
+ SubSat(Byte8(1, 2, 3, 4, 5, 6, 7, 8),
+ Byte8(7, 6, 5, 4, 3, 2, 1, 0));
*Pointer<SByte8>(out + 8 * 3) =
- AddSat(SByte8(1, 2, 3, 4, 5, 6, 7, 8),
- SByte8(7, 6, 5, 4, 3, 2, 1, 0));
+ AddSat(SByte8(1, 2, 3, 4, 5, 6, 7, 8),
+ SByte8(7, 6, 5, 4, 3, 2, 1, 0));
*Pointer<SByte8>(out + 8 * 4) =
- AddSat(SByte8(0x7E, 0x7E, 0x7E, 0x7E, 0x7E, 0x7E, 0x7E, 0x7E),
- SByte8(7, 6, 5, 4, 3, 2, 1, 0));
+ AddSat(SByte8(0x7E, 0x7E, 0x7E, 0x7E, 0x7E, 0x7E, 0x7E, 0x7E),
+ SByte8(7, 6, 5, 4, 3, 2, 1, 0));
*Pointer<SByte8>(out + 8 * 5) =
- AddSat(SByte8(0x81, 0x82, 0x83, 0x84, 0x85, 0x86, 0x87, 0x88),
- SByte8(-7, -6, -5, -4, -3, -2, -1, -0));
+ AddSat(SByte8(0x81, 0x82, 0x83, 0x84, 0x85, 0x86, 0x87, 0x88),
+ SByte8(-7, -6, -5, -4, -3, -2, -1, -0));
*Pointer<SByte8>(out + 8 * 6) =
- SubSat(SByte8(0x81, 0x82, 0x83, 0x84, 0x85, 0x86, 0x87, 0x88),
- SByte8(7, 6, 5, 4, 3, 2, 1, 0));
+ SubSat(SByte8(0x81, 0x82, 0x83, 0x84, 0x85, 0x86, 0x87, 0x88),
+ SByte8(7, 6, 5, 4, 3, 2, 1, 0));
*Pointer<Short4>(out + 8 * 7) =
- AddSat(Short4(1, 2, 3, 4), Short4(3, 2, 1, 0));
+ AddSat(Short4(1, 2, 3, 4), Short4(3, 2, 1, 0));
*Pointer<Short4>(out + 8 * 8) =
- AddSat(Short4(0x7FFE, 0x7FFE, 0x7FFE, 0x7FFE),
- Short4(3, 2, 1, 0));
+ AddSat(Short4(0x7FFE, 0x7FFE, 0x7FFE, 0x7FFE),
+ Short4(3, 2, 1, 0));
*Pointer<Short4>(out + 8 * 9) =
- AddSat(Short4(0x8001, 0x8002, 0x8003, 0x8004),
- Short4(-3, -2, -1, -0));
+ AddSat(Short4(0x8001, 0x8002, 0x8003, 0x8004),
+ Short4(-3, -2, -1, -0));
*Pointer<Short4>(out + 8 * 10) =
- SubSat(Short4(0x8001, 0x8002, 0x8003, 0x8004),
- Short4(3, 2, 1, 0));
+ SubSat(Short4(0x8001, 0x8002, 0x8003, 0x8004),
+ Short4(3, 2, 1, 0));
*Pointer<UShort4>(out + 8 * 11) =
- AddSat(UShort4(1, 2, 3, 4), UShort4(3, 2, 1, 0));
+ AddSat(UShort4(1, 2, 3, 4), UShort4(3, 2, 1, 0));
*Pointer<UShort4>(out + 8 * 12) =
- AddSat(UShort4(0xFFFE, 0xFFFE, 0xFFFE, 0xFFFE),
- UShort4(3, 2, 1, 0));
+ AddSat(UShort4(0xFFFE, 0xFFFE, 0xFFFE, 0xFFFE),
+ UShort4(3, 2, 1, 0));
*Pointer<UShort4>(out + 8 * 13) =
- SubSat(UShort4(1, 2, 3, 4), UShort4(3, 2, 1, 0));
+ SubSat(UShort4(1, 2, 3, 4), UShort4(3, 2, 1, 0));
Return(0);
}
@@ -979,7 +978,7 @@
TEST(ReactorUnitTests, Unpack)
{
- FunctionT<int(void*, void*)> function;
+ FunctionT<int(void *, void *)> function;
{
Pointer<Byte> in = function.Arg<0>();
Pointer<Byte> out = function.Arg<1>();
@@ -988,7 +987,7 @@
Byte4 test_byte_b = *Pointer<Byte4>(in + 4 * 1);
*Pointer<Short4>(out + 8 * 0) =
- Unpack(test_byte_a, test_byte_b);
+ Unpack(test_byte_a, test_byte_b);
*Pointer<Short4>(out + 8 * 1) = Unpack(test_byte_a);
@@ -1019,25 +1018,25 @@
TEST(ReactorUnitTests, Pack)
{
- FunctionT<int(void*)> function;
+ FunctionT<int(void *)> function;
{
Pointer<Byte> out = function.Arg<0>();
*Pointer<SByte8>(out + 8 * 0) =
- PackSigned(Short4(-1, -2, 1, 2),
- Short4(3, 4, -3, -4));
+ PackSigned(Short4(-1, -2, 1, 2),
+ Short4(3, 4, -3, -4));
*Pointer<Byte8>(out + 8 * 1) =
- PackUnsigned(Short4(-1, -2, 1, 2),
- Short4(3, 4, -3, -4));
+ PackUnsigned(Short4(-1, -2, 1, 2),
+ Short4(3, 4, -3, -4));
*Pointer<Short8>(out + 8 * 2) =
- PackSigned(Int4(-1, -2, 1, 2),
- Int4(3, 4, -3, -4));
+ PackSigned(Int4(-1, -2, 1, 2),
+ Int4(3, 4, -3, -4));
*Pointer<UShort8>(out + 8 * 4) =
- PackUnsigned(Int4(-1, -2, 1, 2),
- Int4(3, 4, -3, -4));
+ PackUnsigned(Int4(-1, -2, 1, 2),
+ Int4(3, 4, -3, -4));
Return(0);
}
@@ -1074,30 +1073,30 @@
TEST(ReactorUnitTests, MulHigh)
{
- FunctionT<int(void*)> function;
+ FunctionT<int(void *)> function;
{
Pointer<Byte> out = function.Arg<0>();
*Pointer<Short4>(out + 16 * 0) =
- MulHigh(Short4(0x01AA, 0x02DD, 0x03EE, 0xF422),
- Short4(0x01BB, 0x02CC, 0x03FF, 0xF411));
+ MulHigh(Short4(0x01AA, 0x02DD, 0x03EE, 0xF422),
+ Short4(0x01BB, 0x02CC, 0x03FF, 0xF411));
*Pointer<UShort4>(out + 16 * 1) =
- MulHigh(UShort4(0x01AA, 0x02DD, 0x03EE, 0xF422),
- UShort4(0x01BB, 0x02CC, 0x03FF, 0xF411));
+ MulHigh(UShort4(0x01AA, 0x02DD, 0x03EE, 0xF422),
+ UShort4(0x01BB, 0x02CC, 0x03FF, 0xF411));
*Pointer<Int4>(out + 16 * 2) =
- MulHigh(Int4(0x000001AA, 0x000002DD, 0xC8000000, 0xF8000000),
- Int4(0x000001BB, 0x84000000, 0x000003EE, 0xD7000000));
+ MulHigh(Int4(0x000001AA, 0x000002DD, 0xC8000000, 0xF8000000),
+ Int4(0x000001BB, 0x84000000, 0x000003EE, 0xD7000000));
*Pointer<UInt4>(out + 16 * 3) =
- MulHigh(UInt4(0x000001AAu, 0x000002DDu, 0xC8000000u, 0xD8000000u),
- UInt4(0x000001BBu, 0x84000000u, 0x000003EEu, 0xD7000000u));
+ MulHigh(UInt4(0x000001AAu, 0x000002DDu, 0xC8000000u, 0xD8000000u),
+ UInt4(0x000001BBu, 0x84000000u, 0x000003EEu, 0xD7000000u));
*Pointer<Int4>(out + 16 * 4) =
- MulHigh(Int4(0x7FFFFFFF, 0x7FFFFFFF, 0x80008000, 0xFFFFFFFF),
- Int4(0x7FFFFFFF, 0x80000000, 0x80008000, 0xFFFFFFFF));
+ MulHigh(Int4(0x7FFFFFFF, 0x7FFFFFFF, 0x80008000, 0xFFFFFFFF),
+ Int4(0x7FFFFFFF, 0x80000000, 0x80008000, 0xFFFFFFFF));
*Pointer<UInt4>(out + 16 * 5) =
- MulHigh(UInt4(0x7FFFFFFFu, 0x7FFFFFFFu, 0x80008000u, 0xFFFFFFFFu),
- UInt4(0x7FFFFFFFu, 0x80000000u, 0x80008000u, 0xFFFFFFFFu));
+ MulHigh(UInt4(0x7FFFFFFFu, 0x7FFFFFFFu, 0x80008000u, 0xFFFFFFFFu),
+ UInt4(0x7FFFFFFFu, 0x80000000u, 0x80008000u, 0xFFFFFFFFu));
// (U)Short8 variants currently unimplemented.
@@ -1144,13 +1143,13 @@
TEST(ReactorUnitTests, MulAdd)
{
- FunctionT<int(void*)> function;
+ FunctionT<int(void *)> function;
{
Pointer<Byte> out = function.Arg<0>();
*Pointer<Int2>(out + 8 * 0) =
- MulAdd(Short4(0x1aa, 0x2dd, 0x3ee, 0xF422),
- Short4(0x1bb, 0x2cc, 0x3ff, 0xF411));
+ MulAdd(Short4(0x1aa, 0x2dd, 0x3ee, 0xF422),
+ Short4(0x1bb, 0x2cc, 0x3ff, 0xF411));
// (U)Short8 variant is mentioned but unimplemented
Return(0);
@@ -1173,7 +1172,7 @@
TEST(ReactorUnitTests, PointersEqual)
{
- FunctionT<int(void*, void*)> function;
+ FunctionT<int(void *, void *)> function;
{
Pointer<Byte> ptrA = function.Arg<0>();
Pointer<Byte> ptrB = function.Arg<1>();
@@ -1188,9 +1187,9 @@
}
auto routine = function("one");
- int* a = reinterpret_cast<int*>(uintptr_t(0x0000000000000000));
- int* b = reinterpret_cast<int*>(uintptr_t(0x00000000F0000000));
- int* c = reinterpret_cast<int*>(uintptr_t(0xF000000000000000));
+ int *a = reinterpret_cast<int *>(uintptr_t(0x0000000000000000));
+ int *b = reinterpret_cast<int *>(uintptr_t(0x00000000F0000000));
+ int *c = reinterpret_cast<int *>(uintptr_t(0xF000000000000000));
EXPECT_EQ(routine(&a, &a), 1);
EXPECT_EQ(routine(&b, &b), 1);
EXPECT_EQ(routine(&c, &c), 1);
@@ -1299,7 +1298,7 @@
float f = 0.0f;
};
- FunctionT<int(void*)> function;
+ FunctionT<int(void *)> function;
{
Pointer<Byte> c = function.Arg<0>();
auto res = Call(Class::Callback, c, 10, 20.0f);
@@ -1361,7 +1360,7 @@
float f = 0.0f;
};
- FunctionT<int(void*)> function;
+ FunctionT<int(void *)> function;
{
Pointer<Byte> c = function.Arg<0>();
auto res = Call(&Class::Callback, c, 10, 20.0f);
@@ -1381,14 +1380,14 @@
{
struct Class
{
- static void Callback(Class *c, const char* s)
+ static void Callback(Class *c, const char *s)
{
c->str = s;
}
std::string str;
};
- FunctionT<void(Class *c, const char *s)> function;
+ FunctionT<void(Class * c, const char *s)> function;
{
Pointer<Byte> c = function.Arg<0>();
Pointer<Byte> s = function.Arg<1>();
@@ -1487,7 +1486,7 @@
{
struct Class
{
- static int Func(int a, float b, int* c, float* d, int e, float f, int* g, float* h)
+ static int Func(int a, float b, int *c, float *d, int e, float f, int *g, float *h)
{
return a + b + *c + *d + e + f + *g + *h;
}
@@ -1542,7 +1541,6 @@
}
}
-
TEST(ReactorUnitTests, CallExternalCallRoutine)
{
// routine1 calls Class::Func, passing it a pointer to routine2, and Class::Func calls routine2
@@ -1559,15 +1557,15 @@
struct Class
{
- static float Func(void* p, float a, int b)
+ static float Func(void *p, float a, int b)
{
- auto funcToCall = reinterpret_cast<float(*)(float, int)>(p);
+ auto funcToCall = reinterpret_cast<float (*)(float, int)>(p);
return funcToCall(a, b);
}
};
auto routine1 = [] {
- FunctionT<float(void*, float, int)> function;
+ FunctionT<float(void *, float, int)> function;
{
Pointer<Byte> funcToCall = function.Arg<0>();
Float a = function.Arg<1>();
@@ -1578,7 +1576,7 @@
return function("one");
}();
- float result = routine1((void*)routine2.getEntry(), 12.f, 13);
+ float result = routine1((void *)routine2.getEntry(), 12.f, 13);
EXPECT_EQ(result, 25.f);
}
@@ -1590,80 +1588,80 @@
// It's necessary to inspect the registers in a debugger to actually verify.)
TEST(ReactorUnitTests, PreserveXMMRegisters)
{
- FunctionT<void(void*, void*)> function;
- {
- Pointer<Byte> in = function.Arg<0>();
- Pointer<Byte> out = function.Arg<1>();
+ FunctionT<void(void *, void *)> function;
+ {
+ Pointer<Byte> in = function.Arg<0>();
+ Pointer<Byte> out = function.Arg<1>();
- Float4 a = *Pointer<Float4>(in + 16 * 0);
- Float4 b = *Pointer<Float4>(in + 16 * 1);
- Float4 c = *Pointer<Float4>(in + 16 * 2);
- Float4 d = *Pointer<Float4>(in + 16 * 3);
- Float4 e = *Pointer<Float4>(in + 16 * 4);
- Float4 f = *Pointer<Float4>(in + 16 * 5);
- Float4 g = *Pointer<Float4>(in + 16 * 6);
- Float4 h = *Pointer<Float4>(in + 16 * 7);
- Float4 i = *Pointer<Float4>(in + 16 * 8);
- Float4 j = *Pointer<Float4>(in + 16 * 9);
- Float4 k = *Pointer<Float4>(in + 16 * 10);
- Float4 l = *Pointer<Float4>(in + 16 * 11);
- Float4 m = *Pointer<Float4>(in + 16 * 12);
- Float4 n = *Pointer<Float4>(in + 16 * 13);
- Float4 o = *Pointer<Float4>(in + 16 * 14);
- Float4 p = *Pointer<Float4>(in + 16 * 15);
+ Float4 a = *Pointer<Float4>(in + 16 * 0);
+ Float4 b = *Pointer<Float4>(in + 16 * 1);
+ Float4 c = *Pointer<Float4>(in + 16 * 2);
+ Float4 d = *Pointer<Float4>(in + 16 * 3);
+ Float4 e = *Pointer<Float4>(in + 16 * 4);
+ Float4 f = *Pointer<Float4>(in + 16 * 5);
+ Float4 g = *Pointer<Float4>(in + 16 * 6);
+ Float4 h = *Pointer<Float4>(in + 16 * 7);
+ Float4 i = *Pointer<Float4>(in + 16 * 8);
+ Float4 j = *Pointer<Float4>(in + 16 * 9);
+ Float4 k = *Pointer<Float4>(in + 16 * 10);
+ Float4 l = *Pointer<Float4>(in + 16 * 11);
+ Float4 m = *Pointer<Float4>(in + 16 * 12);
+ Float4 n = *Pointer<Float4>(in + 16 * 13);
+ Float4 o = *Pointer<Float4>(in + 16 * 14);
+ Float4 p = *Pointer<Float4>(in + 16 * 15);
- Float4 ab = a + b;
- Float4 cd = c + d;
- Float4 ef = e + f;
- Float4 gh = g + h;
- Float4 ij = i + j;
- Float4 kl = k + l;
- Float4 mn = m + n;
- Float4 op = o + p;
+ Float4 ab = a + b;
+ Float4 cd = c + d;
+ Float4 ef = e + f;
+ Float4 gh = g + h;
+ Float4 ij = i + j;
+ Float4 kl = k + l;
+ Float4 mn = m + n;
+ Float4 op = o + p;
- Float4 abcd = ab + cd;
- Float4 efgh = ef + gh;
- Float4 ijkl = ij + kl;
- Float4 mnop = mn + op;
+ Float4 abcd = ab + cd;
+ Float4 efgh = ef + gh;
+ Float4 ijkl = ij + kl;
+ Float4 mnop = mn + op;
- Float4 abcdefgh = abcd + efgh;
- Float4 ijklmnop = ijkl + mnop;
- Float4 sum = abcdefgh + ijklmnop;
- *Pointer<Float4>(out) = sum;
- Return();
- }
+ Float4 abcdefgh = abcd + efgh;
+ Float4 ijklmnop = ijkl + mnop;
+ Float4 sum = abcdefgh + ijklmnop;
+ *Pointer<Float4>(out) = sum;
+ Return();
+ }
- auto routine = function("one");
- assert(routine);
+ auto routine = function("one");
+ assert(routine);
- float input[64] = { 1.0f, 0.0f, 0.0f, 0.0f,
- -1.0f, 1.0f, -1.0f, 0.0f,
- 1.0f, 2.0f, -2.0f, 0.0f,
- -1.0f, 3.0f, -3.0f, 0.0f,
- 1.0f, 4.0f, -4.0f, 0.0f,
- -1.0f, 5.0f, -5.0f, 0.0f,
- 1.0f, 6.0f, -6.0f, 0.0f,
- -1.0f, 7.0f, -7.0f, 0.0f,
- 1.0f, 8.0f, -8.0f, 0.0f,
- -1.0f, 9.0f, -9.0f, 0.0f,
- 1.0f, 10.0f, -10.0f, 0.0f,
- -1.0f, 11.0f, -11.0f, 0.0f,
- 1.0f, 12.0f, -12.0f, 0.0f,
- -1.0f, 13.0f, -13.0f, 0.0f,
- 1.0f, 14.0f, -14.0f, 0.0f,
- -1.0f, 15.0f, -15.0f, 0.0f };
+ float input[64] = { 1.0f, 0.0f, 0.0f, 0.0f,
+ -1.0f, 1.0f, -1.0f, 0.0f,
+ 1.0f, 2.0f, -2.0f, 0.0f,
+ -1.0f, 3.0f, -3.0f, 0.0f,
+ 1.0f, 4.0f, -4.0f, 0.0f,
+ -1.0f, 5.0f, -5.0f, 0.0f,
+ 1.0f, 6.0f, -6.0f, 0.0f,
+ -1.0f, 7.0f, -7.0f, 0.0f,
+ 1.0f, 8.0f, -8.0f, 0.0f,
+ -1.0f, 9.0f, -9.0f, 0.0f,
+ 1.0f, 10.0f, -10.0f, 0.0f,
+ -1.0f, 11.0f, -11.0f, 0.0f,
+ 1.0f, 12.0f, -12.0f, 0.0f,
+ -1.0f, 13.0f, -13.0f, 0.0f,
+ 1.0f, 14.0f, -14.0f, 0.0f,
+ -1.0f, 15.0f, -15.0f, 0.0f };
- float result[4];
+ float result[4];
- routine(input, result);
+ routine(input, result);
- EXPECT_EQ(result[0], 0.0f);
- EXPECT_EQ(result[1], 120.0f);
- EXPECT_EQ(result[2], -120.0f);
- EXPECT_EQ(result[3], 0.0f);
+ EXPECT_EQ(result[0], 0.0f);
+ EXPECT_EQ(result[1], 120.0f);
+ EXPECT_EQ(result[2], -120.0f);
+ EXPECT_EQ(result[3], 0.0f);
}
-template <typename T>
+template<typename T>
class CToReactorTCastTest : public ::testing::Test
{
public:
@@ -1671,17 +1669,15 @@
using ReactorType = typename std::tuple_element<1, T>::type;
};
-using CToReactorTCastTestTypes = ::testing::Types
- < // Subset of types that can be used as arguments.
- // std::pair<bool, Bool>, FIXME(capn): Not supported as argument type by Subzero.
- // std::pair<uint8_t, Byte>, FIXME(capn): Not supported as argument type by Subzero.
- // std::pair<int8_t, SByte>, FIXME(capn): Not supported as argument type by Subzero.
- // std::pair<int16_t, Short>, FIXME(capn): Not supported as argument type by Subzero.
- // std::pair<uint16_t, UShort>, FIXME(capn): Not supported as argument type by Subzero.
- std::pair<int, Int>,
- std::pair<unsigned int, UInt>,
- std::pair<float, Float>
- >;
+using CToReactorTCastTestTypes = ::testing::Types< // Subset of types that can be used as arguments.
+ // std::pair<bool, Bool>, FIXME(capn): Not supported as argument type by Subzero.
+ // std::pair<uint8_t, Byte>, FIXME(capn): Not supported as argument type by Subzero.
+ // std::pair<int8_t, SByte>, FIXME(capn): Not supported as argument type by Subzero.
+ // std::pair<int16_t, Short>, FIXME(capn): Not supported as argument type by Subzero.
+ // std::pair<uint16_t, UShort>, FIXME(capn): Not supported as argument type by Subzero.
+ std::pair<int, Int>,
+ std::pair<unsigned int, UInt>,
+ std::pair<float, Float>>;
TYPED_TEST_SUITE(CToReactorTCastTest, CToReactorTCastTestTypes);
@@ -1693,28 +1689,27 @@
std::shared_ptr<Routine> routine;
{
- Function< Int(ReactorType) > function;
+ Function<Int(ReactorType)> function;
{
ReactorType a = function.template Arg<0>();
ReactorType b = CType{};
RValue<ReactorType> c = RValue<ReactorType>(CType{});
Bool same = (a == b) && (a == c);
- Return(IfThenElse(same, Int(1), Int(0))); // TODO: Ability to use Bools as return values.
+ Return(IfThenElse(same, Int(1), Int(0))); // TODO: Ability to use Bools as return values.
}
routine = function("one");
if(routine)
{
- auto callable = (int(*)(CType))routine->getEntry();
+ auto callable = (int (*)(CType))routine->getEntry();
CType in = {};
EXPECT_EQ(callable(in), 1);
}
}
-
}
-template <typename T>
+template<typename T>
class GEPTest : public ::testing::Test
{
public:
@@ -1722,37 +1717,35 @@
using ReactorType = typename std::tuple_element<1, T>::type;
};
-using GEPTestTypes = ::testing::Types
- <
- std::pair<bool, Bool>,
- std::pair<int8_t, Byte>,
- std::pair<int8_t, SByte>,
- std::pair<int8_t[4], Byte4>,
- std::pair<int8_t[4], SByte4>,
- std::pair<int8_t[8], Byte8>,
- std::pair<int8_t[8], SByte8>,
- std::pair<int8_t[16], Byte16>,
- std::pair<int8_t[16], SByte16>,
- std::pair<int16_t, Short>,
- std::pair<int16_t, UShort>,
- std::pair<int16_t[2], Short2>,
- std::pair<int16_t[2], UShort2>,
- std::pair<int16_t[4], Short4>,
- std::pair<int16_t[4], UShort4>,
- std::pair<int16_t[8], Short8>,
- std::pair<int16_t[8], UShort8>,
- std::pair<int, Int>,
- std::pair<int, UInt>,
- std::pair<int[2], Int2>,
- std::pair<int[2], UInt2>,
- std::pair<int[4], Int4>,
- std::pair<int[4], UInt4>,
- std::pair<int64_t, Long>,
- std::pair<int16_t, Half>,
- std::pair<float, Float>,
- std::pair<float[2], Float2>,
- std::pair<float[4], Float4>
- >;
+using GEPTestTypes = ::testing::Types<
+ std::pair<bool, Bool>,
+ std::pair<int8_t, Byte>,
+ std::pair<int8_t, SByte>,
+ std::pair<int8_t[4], Byte4>,
+ std::pair<int8_t[4], SByte4>,
+ std::pair<int8_t[8], Byte8>,
+ std::pair<int8_t[8], SByte8>,
+ std::pair<int8_t[16], Byte16>,
+ std::pair<int8_t[16], SByte16>,
+ std::pair<int16_t, Short>,
+ std::pair<int16_t, UShort>,
+ std::pair<int16_t[2], Short2>,
+ std::pair<int16_t[2], UShort2>,
+ std::pair<int16_t[4], Short4>,
+ std::pair<int16_t[4], UShort4>,
+ std::pair<int16_t[8], Short8>,
+ std::pair<int16_t[8], UShort8>,
+ std::pair<int, Int>,
+ std::pair<int, UInt>,
+ std::pair<int[2], Int2>,
+ std::pair<int[2], UInt2>,
+ std::pair<int[4], Int4>,
+ std::pair<int[4], UInt4>,
+ std::pair<int64_t, Long>,
+ std::pair<int16_t, Half>,
+ std::pair<float, Float>,
+ std::pair<float[2], Float2>,
+ std::pair<float[4], Float4>>;
TYPED_TEST_SUITE(GEPTest, GEPTestTypes);
@@ -1764,7 +1757,7 @@
std::shared_ptr<Routine> routine;
{
- Function< Pointer<ReactorType>(Pointer<ReactorType>, Int) > function;
+ Function<Pointer<ReactorType>(Pointer<ReactorType>, Int)> function;
{
Pointer<ReactorType> pointer = function.template Arg<0>();
Int index = function.template Arg<1>();
@@ -1775,10 +1768,11 @@
if(routine)
{
- auto callable = (CType*(*)(CType*, unsigned int))routine->getEntry();
+ auto callable = (CType * (*)(CType *, unsigned int)) routine->getEntry();
- union PtrInt {
- CType* p;
+ union PtrInt
+ {
+ CType *p;
size_t i;
};
@@ -1800,7 +1794,6 @@
}
}
}
-
}
TEST(ReactorUnitTests, Coroutines_Fibonacci)
@@ -1817,7 +1810,8 @@
Yield(Int(1));
Int current = 1;
Int next = 1;
- While(true) {
+ While(true)
+ {
Yield(next);
auto tmp = current + next;
current = next;
@@ -1827,10 +1821,35 @@
auto coroutine = function();
- int32_t expected[] =
- {
- 0, 1, 1, 2, 3, 5, 8, 13, 21, 34, 55, 89, 144, 233, 377, 610, 987, 1597,
- 2584, 4181, 6765, 10946, 17711, 28657, 46368, 75025, 121393, 196418,
+ int32_t expected[] = {
+ 0,
+ 1,
+ 1,
+ 2,
+ 3,
+ 5,
+ 8,
+ 13,
+ 21,
+ 34,
+ 55,
+ 89,
+ 144,
+ 233,
+ 377,
+ 610,
+ 987,
+ 1597,
+ 2584,
+ 4181,
+ 6765,
+ 10946,
+ 17711,
+ 28657,
+ 46368,
+ 75025,
+ 121393,
+ 196418,
317811,
};
@@ -1852,7 +1871,7 @@
return;
}
- Coroutine<uint8_t(uint8_t* data, int count)> function;
+ Coroutine<uint8_t(uint8_t * data, int count)> function;
{
Pointer<Byte> data = function.Arg<0>();
Int count = function.Arg<1>();
@@ -1863,29 +1882,31 @@
}
}
- uint8_t data[] = {10, 20, 30};
+ uint8_t data[] = { 10, 20, 30 };
auto coroutine = function(&data[0], 3);
uint8_t out = 0;
EXPECT_EQ(coroutine->await(out), true);
- EXPECT_EQ(out, 10); out = 0;
+ EXPECT_EQ(out, 10);
+ out = 0;
EXPECT_EQ(coroutine->await(out), true);
- EXPECT_EQ(out, 20); out = 0;
+ EXPECT_EQ(out, 20);
+ out = 0;
EXPECT_EQ(coroutine->await(out), true);
- EXPECT_EQ(out, 30); out = 99;
+ EXPECT_EQ(out, 30);
+ out = 99;
EXPECT_EQ(coroutine->await(out), false);
EXPECT_EQ(out, 99);
EXPECT_EQ(coroutine->await(out), false);
EXPECT_EQ(out, 99);
}
-
-template <typename TestFuncType, typename RefFuncType, typename TestValueType>
+template<typename TestFuncType, typename RefFuncType, typename TestValueType>
struct IntrinsicTestParams
{
- std::function<TestFuncType> testFunc; // Function we're testing (Reactor)
- std::function<RefFuncType> refFunc; // Reference function to test against (C)
- std::vector<TestValueType> testValues; // Values to input to functions
+ std::function<TestFuncType> testFunc; // Function we're testing (Reactor)
+ std::function<RefFuncType> refFunc; // Reference function to test against (C)
+ std::vector<TestValueType> testValues; // Values to input to functions
};
using IntrinsicTestParams_Float = IntrinsicTestParams<RValue<Float>(RValue<Float>), float(float), float>;
@@ -1903,7 +1924,7 @@
auto routine = function("one");
- for(auto&& v : GetParam().testValues)
+ for(auto &&v : GetParam().testValues)
{
SCOPED_TRACE(v);
EXPECT_FLOAT_EQ(routine(v), GetParam().refFunc(v));
@@ -1915,7 +1936,7 @@
{
void test()
{
- FunctionT<void(float4*)> function;
+ FunctionT<void(float4 *)> function;
{
Pointer<Float4> a = function.Arg<0>();
*a = GetParam().testFunc(*a);
@@ -1924,7 +1945,7 @@
auto routine = function("one");
- for(auto&& v : GetParam().testValues)
+ for(auto &&v : GetParam().testValues)
{
SCOPED_TRACE(v);
float4_value result = invokeRoutine(routine, float4_value{ v });
@@ -1941,7 +1962,7 @@
{
void test()
{
- FunctionT<void(float4*, float4*)> function;
+ FunctionT<void(float4 *, float4 *)> function;
{
Pointer<Float4> a = function.Arg<0>();
Pointer<Float4> b = function.Arg<1>();
@@ -1951,7 +1972,7 @@
auto routine = function("one");
- for(auto&& v : GetParam().testValues)
+ for(auto &&v : GetParam().testValues)
{
SCOPED_TRACE(v);
float4_value result = invokeRoutine(routine, float4_value{ v.first }, float4_value{ v.second });
@@ -1964,40 +1985,24 @@
}
};
-INSTANTIATE_TEST_SUITE_P(IntrinsicTestParams_Float, IntrinsicTest_Float, testing::Values(
- IntrinsicTestParams_Float{ [](Float v) { return rr::Exp2(v); }, exp2f, {0.f, 1.f, 12345.f} },
- IntrinsicTestParams_Float{ [](Float v) { return rr::Log2(v); }, log2f, {0.f, 1.f, 12345.f} },
- IntrinsicTestParams_Float{ [](Float v) { return rr::Sqrt(v); }, sqrtf, {0.f, 1.f, 12345.f} }
-));
+INSTANTIATE_TEST_SUITE_P(IntrinsicTestParams_Float, IntrinsicTest_Float, testing::Values(IntrinsicTestParams_Float{ [](Float v) { return rr::Exp2(v); }, exp2f, { 0.f, 1.f, 12345.f } }, IntrinsicTestParams_Float{ [](Float v) { return rr::Log2(v); }, log2f, { 0.f, 1.f, 12345.f } }, IntrinsicTestParams_Float{ [](Float v) { return rr::Sqrt(v); }, sqrtf, { 0.f, 1.f, 12345.f } }));
-INSTANTIATE_TEST_SUITE_P(IntrinsicTestParams_Float4, IntrinsicTest_Float4, testing::Values(
- IntrinsicTestParams_Float4{ [](RValue<Float4> v) { return rr::Sin(v); }, sinf, {0.f, 1.f, PI, 12345.f} },
- IntrinsicTestParams_Float4{ [](RValue<Float4> v) { return rr::Cos(v); }, cosf, {0.f, 1.f, PI, 12345.f} },
- IntrinsicTestParams_Float4{ [](RValue<Float4> v) { return rr::Tan(v); }, tanf, {0.f, 1.f, PI, 12345.f} },
- IntrinsicTestParams_Float4{ [](RValue<Float4> v) { return rr::Asin(v); }, asinf, {0.f, 1.f, -1.f} },
- IntrinsicTestParams_Float4{ [](RValue<Float4> v) { return rr::Acos(v); }, acosf, {0.f, 1.f, -1.f} },
- IntrinsicTestParams_Float4{ [](RValue<Float4> v) { return rr::Atan(v); }, atanf, {0.f, 1.f, PI, 12345.f} },
- IntrinsicTestParams_Float4{ [](RValue<Float4> v) { return rr::Sinh(v); }, sinhf, {0.f, 1.f, PI, 12345.f} },
- IntrinsicTestParams_Float4{ [](RValue<Float4> v) { return rr::Cosh(v); }, coshf, {0.f, 1.f, PI, 12345.f} },
- IntrinsicTestParams_Float4{ [](RValue<Float4> v) { return rr::Tanh(v); }, tanhf, {0.f, 1.f, PI, 12345.f} },
- IntrinsicTestParams_Float4{ [](RValue<Float4> v) { return rr::Asinh(v); }, asinhf, {0.f, 1.f, PI, 12345.f} },
- IntrinsicTestParams_Float4{ [](RValue<Float4> v) { return rr::Acosh(v); }, acoshf, { 1.f, PI, 12345.f} },
- IntrinsicTestParams_Float4{ [](RValue<Float4> v) { return rr::Atanh(v); }, atanhf, {0.f, 1.f, -1.f} },
- IntrinsicTestParams_Float4{ [](RValue<Float4> v) { return rr::Exp(v); }, expf, {0.f, 1.f, PI, 12345.f} },
- IntrinsicTestParams_Float4{ [](RValue<Float4> v) { return rr::Log(v); }, logf, {0.f, 1.f, PI, 12345.f} },
- IntrinsicTestParams_Float4{ [](RValue<Float4> v) { return rr::Exp2(v); }, exp2f, {0.f, 1.f, PI, 12345.f} },
- IntrinsicTestParams_Float4{ [](RValue<Float4> v) { return rr::Log2(v); }, log2f, {0.f, 1.f, PI, 12345.f} },
- IntrinsicTestParams_Float4{ [](RValue<Float4> v) { return rr::Sqrt(v); }, sqrtf, {0.f, 1.f, PI, 12345.f} }
-));
+INSTANTIATE_TEST_SUITE_P(IntrinsicTestParams_Float4, IntrinsicTest_Float4, testing::Values(IntrinsicTestParams_Float4{ [](RValue<Float4> v) { return rr::Sin(v); }, sinf, { 0.f, 1.f, PI, 12345.f } }, IntrinsicTestParams_Float4{ [](RValue<Float4> v) { return rr::Cos(v); }, cosf, { 0.f, 1.f, PI, 12345.f } }, IntrinsicTestParams_Float4{ [](RValue<Float4> v) { return rr::Tan(v); }, tanf, { 0.f, 1.f, PI, 12345.f } }, IntrinsicTestParams_Float4{ [](RValue<Float4> v) { return rr::Asin(v); }, asinf, { 0.f, 1.f, -1.f } }, IntrinsicTestParams_Float4{ [](RValue<Float4> v) { return rr::Acos(v); }, acosf, { 0.f, 1.f, -1.f } }, IntrinsicTestParams_Float4{ [](RValue<Float4> v) { return rr::Atan(v); }, atanf, { 0.f, 1.f, PI, 12345.f } }, IntrinsicTestParams_Float4{ [](RValue<Float4> v) { return rr::Sinh(v); }, sinhf, { 0.f, 1.f, PI, 12345.f } }, IntrinsicTestParams_Float4{ [](RValue<Float4> v) { return rr::Cosh(v); }, coshf, { 0.f, 1.f, PI, 12345.f } }, IntrinsicTestParams_Float4{ [](RValue<Float4> v) { return rr::Tanh(v); }, tanhf, { 0.f, 1.f, PI, 12345.f } }, IntrinsicTestParams_Float4{ [](RValue<Float4> v) { return rr::Asinh(v); }, asinhf, { 0.f, 1.f, PI, 12345.f } }, IntrinsicTestParams_Float4{ [](RValue<Float4> v) { return rr::Acosh(v); }, acoshf, { 1.f, PI, 12345.f } }, IntrinsicTestParams_Float4{ [](RValue<Float4> v) { return rr::Atanh(v); }, atanhf, { 0.f, 1.f, -1.f } }, IntrinsicTestParams_Float4{ [](RValue<Float4> v) { return rr::Exp(v); }, expf, { 0.f, 1.f, PI, 12345.f } }, IntrinsicTestParams_Float4{ [](RValue<Float4> v) { return rr::Log(v); }, logf, { 0.f, 1.f, PI, 12345.f } }, IntrinsicTestParams_Float4{ [](RValue<Float4> v) { return rr::Exp2(v); }, exp2f, { 0.f, 1.f, PI, 12345.f } }, IntrinsicTestParams_Float4{ [](RValue<Float4> v) { return rr::Log2(v); }, log2f, { 0.f, 1.f, PI, 12345.f } }, IntrinsicTestParams_Float4{ [](RValue<Float4> v) { return rr::Sqrt(v); }, sqrtf, { 0.f, 1.f, PI, 12345.f } }));
-INSTANTIATE_TEST_SUITE_P(IntrinsicTestParams_Float4_Float4, IntrinsicTest_Float4_Float4, testing::Values(
- IntrinsicTestParams_Float4_Float4{ [](RValue<Float4> v1, RValue<Float4> v2) { return Atan2(v1, v2); }, atan2f, { {0.f, 0.f}, {0.f, -1.f}, {-1.f, 0.f}, {12345.f, 12345.f} } },
- IntrinsicTestParams_Float4_Float4{ [](RValue<Float4> v1, RValue<Float4> v2) { return Pow(v1, v2); }, powf, { {0.f, 0.f}, {0.f, -1.f}, {-1.f, 0.f}, {12345.f, 12345.f} } }
-));
+INSTANTIATE_TEST_SUITE_P(IntrinsicTestParams_Float4_Float4, IntrinsicTest_Float4_Float4, testing::Values(IntrinsicTestParams_Float4_Float4{ [](RValue<Float4> v1, RValue<Float4> v2) { return Atan2(v1, v2); }, atan2f, { { 0.f, 0.f }, { 0.f, -1.f }, { -1.f, 0.f }, { 12345.f, 12345.f } } }, IntrinsicTestParams_Float4_Float4{ [](RValue<Float4> v1, RValue<Float4> v2) { return Pow(v1, v2); }, powf, { { 0.f, 0.f }, { 0.f, -1.f }, { -1.f, 0.f }, { 12345.f, 12345.f } } }));
-TEST_P(IntrinsicTest_Float, Test) { test(); }
-TEST_P(IntrinsicTest_Float4, Test) { test(); }
-TEST_P(IntrinsicTest_Float4_Float4, Test) { test(); }
+TEST_P(IntrinsicTest_Float, Test)
+{
+ test();
+}
+TEST_P(IntrinsicTest_Float4, Test)
+{
+ test();
+}
+TEST_P(IntrinsicTest_Float4_Float4, Test)
+{
+ test();
+}
TEST(ReactorUnitTests, Intrinsics_Ctlz)
{
@@ -2012,8 +2017,8 @@
auto routine = function("one");
auto callable = (uint32_t(*)(uint32_t))routine->getEntry();
-
- for(uint32_t i = 0; i < 31; ++i) {
+ for(uint32_t i = 0; i < 31; ++i)
+ {
uint32_t result = callable(1 << i);
EXPECT_EQ(result, 31 - i);
}
@@ -2033,11 +2038,12 @@
*out = rr::Ctlz(UInt4(x), false);
}
auto routine = function("one");
- auto callable = (void(*)(uint32_t*, uint32_t))routine->getEntry();
+ auto callable = (void (*)(uint32_t *, uint32_t))routine->getEntry();
uint32_t x[4];
- for(uint32_t i = 0; i < 31; ++i) {
+ for(uint32_t i = 0; i < 31; ++i)
+ {
callable(x, 1 << i);
EXPECT_EQ(x[0], 31 - i);
EXPECT_EQ(x[1], 31 - i);
@@ -2069,8 +2075,8 @@
auto routine = function("one");
auto callable = (uint32_t(*)(uint32_t))routine->getEntry();
-
- for(uint32_t i = 0; i < 31; ++i) {
+ for(uint32_t i = 0; i < 31; ++i)
+ {
uint32_t result = callable(1 << i);
EXPECT_EQ(result, i);
}
@@ -2090,11 +2096,12 @@
*out = rr::Cttz(UInt4(x), false);
}
auto routine = function("one");
- auto callable = (void(*)(uint32_t*, uint32_t))routine->getEntry();
+ auto callable = (void (*)(uint32_t *, uint32_t))routine->getEntry();
uint32_t x[4];
- for(uint32_t i = 0; i < 31; ++i) {
+ for(uint32_t i = 0; i < 31; ++i)
+ {
callable(x, 1 << i);
EXPECT_EQ(x[0], i);
EXPECT_EQ(x[1], i);
@@ -2126,22 +2133,21 @@
Scatter(base, *val, *offsets, mask, alignment);
}
- float buffer[16] = {0};
+ float buffer[16] = { 0 };
constexpr auto elemSize = sizeof(buffer[0]);
- int offsets[] =
- {
- 1 *elemSize,
- 6 *elemSize,
- 11 *elemSize,
- 13 *elemSize
+ int offsets[] = {
+ 1 * elemSize,
+ 6 * elemSize,
+ 11 * elemSize,
+ 13 * elemSize
};
- float val[4] = {10, 60, 110, 130};
+ float val[4] = { 10, 60, 110, 130 };
auto routine = function("one");
- auto entry = (void(*)(float*, float*, int*))routine->getEntry();
+ auto entry = (void (*)(float *, float *, int *))routine->getEntry();
entry(buffer, val, offsets);
@@ -2165,8 +2171,7 @@
*result = Gather(base, *offsets, mask, alignment, zeroMaskedLanes);
}
- float buffer[] =
- {
+ float buffer[] = {
0, 10, 20, 30,
40, 50, 60, 70,
80, 90, 100, 110,
@@ -2175,16 +2180,15 @@
constexpr auto elemSize = sizeof(buffer[0]);
- int offsets[] =
- {
- 1 *elemSize,
- 6 *elemSize,
- 11 *elemSize,
- 13 *elemSize
+ int offsets[] = {
+ 1 * elemSize,
+ 6 * elemSize,
+ 11 * elemSize,
+ 13 * elemSize
};
auto routine = function("one");
- auto entry = (void(*)(float*, int*, float*))routine->getEntry();
+ auto entry = (void (*)(float *, int *, float *))routine->getEntry();
float result[4] = {};
entry(buffer, offsets, result);
@@ -2222,7 +2226,7 @@
}
auto routine = function("one");
- auto entry = (void(*)(int*, int*))routine->getEntry();
+ auto entry = (void (*)(int *, int *))routine->getEntry();
int v[4] = { 42, 42, 42, 42 };
int result[4] = { 99, 99, 99, 99 };
@@ -2244,36 +2248,37 @@
////////////////////////////////
// Assert CToReactorT resolves to expected types.
-static_assert(std::is_same<CToReactorT<void>, Void>::value, "");
-static_assert(std::is_same<CToReactorT<bool>, Bool>::value, "");
-static_assert(std::is_same<CToReactorT<uint8_t>, Byte>::value, "");
-static_assert(std::is_same<CToReactorT<int8_t>, SByte>::value, "");
-static_assert(std::is_same<CToReactorT<int16_t>, Short>::value, "");
+static_assert(std::is_same<CToReactorT<void>, Void>::value, "");
+static_assert(std::is_same<CToReactorT<bool>, Bool>::value, "");
+static_assert(std::is_same<CToReactorT<uint8_t>, Byte>::value, "");
+static_assert(std::is_same<CToReactorT<int8_t>, SByte>::value, "");
+static_assert(std::is_same<CToReactorT<int16_t>, Short>::value, "");
static_assert(std::is_same<CToReactorT<uint16_t>, UShort>::value, "");
-static_assert(std::is_same<CToReactorT<int32_t>, Int>::value, "");
+static_assert(std::is_same<CToReactorT<int32_t>, Int>::value, "");
static_assert(std::is_same<CToReactorT<uint64_t>, Long>::value, "");
static_assert(std::is_same<CToReactorT<uint32_t>, UInt>::value, "");
-static_assert(std::is_same<CToReactorT<float>, Float>::value, "");
+static_assert(std::is_same<CToReactorT<float>, Float>::value, "");
// Assert CToReactorT for known pointer types resolves to expected types.
-static_assert(std::is_same<CToReactorT<void*>, Pointer<Byte>>::value, "");
-static_assert(std::is_same<CToReactorT<bool*>, Pointer<Bool>>::value, "");
-static_assert(std::is_same<CToReactorT<uint8_t*>, Pointer<Byte>>::value, "");
-static_assert(std::is_same<CToReactorT<int8_t*>, Pointer<SByte>>::value, "");
-static_assert(std::is_same<CToReactorT<int16_t*>, Pointer<Short>>::value, "");
-static_assert(std::is_same<CToReactorT<uint16_t*>, Pointer<UShort>>::value, "");
-static_assert(std::is_same<CToReactorT<int32_t*>, Pointer<Int>>::value, "");
-static_assert(std::is_same<CToReactorT<uint64_t*>, Pointer<Long>>::value, "");
-static_assert(std::is_same<CToReactorT<uint32_t*>, Pointer<UInt>>::value, "");
-static_assert(std::is_same<CToReactorT<float*>, Pointer<Float>>::value, "");
-static_assert(std::is_same<CToReactorT<uint16_t**>, Pointer<Pointer<UShort>>>::value, "");
-static_assert(std::is_same<CToReactorT<uint16_t***>, Pointer<Pointer<Pointer<UShort>>>>::value, "");
+static_assert(std::is_same<CToReactorT<void *>, Pointer<Byte>>::value, "");
+static_assert(std::is_same<CToReactorT<bool *>, Pointer<Bool>>::value, "");
+static_assert(std::is_same<CToReactorT<uint8_t *>, Pointer<Byte>>::value, "");
+static_assert(std::is_same<CToReactorT<int8_t *>, Pointer<SByte>>::value, "");
+static_assert(std::is_same<CToReactorT<int16_t *>, Pointer<Short>>::value, "");
+static_assert(std::is_same<CToReactorT<uint16_t *>, Pointer<UShort>>::value, "");
+static_assert(std::is_same<CToReactorT<int32_t *>, Pointer<Int>>::value, "");
+static_assert(std::is_same<CToReactorT<uint64_t *>, Pointer<Long>>::value, "");
+static_assert(std::is_same<CToReactorT<uint32_t *>, Pointer<UInt>>::value, "");
+static_assert(std::is_same<CToReactorT<float *>, Pointer<Float>>::value, "");
+static_assert(std::is_same<CToReactorT<uint16_t **>, Pointer<Pointer<UShort>>>::value, "");
+static_assert(std::is_same<CToReactorT<uint16_t ***>, Pointer<Pointer<Pointer<UShort>>>>::value, "");
// Assert CToReactorT for unknown pointer types resolves to Pointer<Byte>.
-struct S{};
-static_assert(std::is_same<CToReactorT<S*>, Pointer<Byte>>::value, "");
-static_assert(std::is_same<CToReactorT<S**>, Pointer<Pointer<Byte>>>::value, "");
-static_assert(std::is_same<CToReactorT<S***>, Pointer<Pointer<Pointer<Byte>>>>::value, "");
+struct S
+{};
+static_assert(std::is_same<CToReactorT<S *>, Pointer<Byte>>::value, "");
+static_assert(std::is_same<CToReactorT<S **>, Pointer<Pointer<Byte>>>::value, "");
+static_assert(std::is_same<CToReactorT<S ***>, Pointer<Pointer<Pointer<Byte>>>>::value, "");
// Assert IsRValue<> resolves true for RValue<> types.
static_assert(IsRValue<RValue<Void>>::value, "");
diff --git a/src/Reactor/Routine.hpp b/src/Reactor/Routine.hpp
index f8083b1..1c0ae1f 100644
--- a/src/Reactor/Routine.hpp
+++ b/src/Reactor/Routine.hpp
@@ -38,12 +38,12 @@
public:
RoutineT() = default;
- explicit RoutineT(const std::shared_ptr<Routine>& routine)
- : routine(routine)
+ explicit RoutineT(const std::shared_ptr<Routine> &routine)
+ : routine(routine)
{
if(routine)
{
- callable = reinterpret_cast<CallableType>(const_cast<void*>(routine->getEntry(0)));
+ callable = reinterpret_cast<CallableType>(const_cast<void *>(routine->getEntry(0)));
}
}
@@ -52,23 +52,23 @@
return callable != nullptr;
}
- template <typename... Args>
- Return operator()(Args&&... args) const
+ template<typename... Args>
+ Return operator()(Args &&... args) const
{
return callable(std::forward<Args>(args)...);
}
- const void* getEntry() const
+ const void *getEntry() const
{
- return reinterpret_cast<void*>(callable);
+ return reinterpret_cast<void *>(callable);
}
private:
std::shared_ptr<Routine> routine;
- using CallableType = Return(*)(Arguments...);
+ using CallableType = Return (*)(Arguments...);
CallableType callable = nullptr;
};
} // namespace rr
-#endif // rr_Routine_hpp
+#endif // rr_Routine_hpp
diff --git a/src/Reactor/SubzeroReactor.cpp b/src/Reactor/SubzeroReactor.cpp
index 6201ab1..2f3e9ee 100644
--- a/src/Reactor/SubzeroReactor.cpp
+++ b/src/Reactor/SubzeroReactor.cpp
@@ -12,44 +12,46 @@
// See the License for the specific language governing permissions and
// limitations under the License.
-#include "Reactor.hpp"
#include "Debug.hpp"
#include "EmulatedReactor.hpp"
+#include "Reactor.hpp"
-#include "Optimizer.hpp"
#include "ExecutableMemory.hpp"
+#include "Optimizer.hpp"
-#include "src/IceTypes.h"
#include "src/IceCfg.h"
-#include "src/IceELFStreamer.h"
-#include "src/IceGlobalContext.h"
#include "src/IceCfgNode.h"
#include "src/IceELFObjectWriter.h"
+#include "src/IceELFStreamer.h"
+#include "src/IceGlobalContext.h"
#include "src/IceGlobalInits.h"
+#include "src/IceTypes.h"
+#include "llvm/Support/Compiler.h"
#include "llvm/Support/FileSystem.h"
#include "llvm/Support/raw_os_ostream.h"
-#include "llvm/Support/Compiler.h"
#if __has_feature(memory_sanitizer)
-#include <sanitizer/msan_interface.h>
+# include <sanitizer/msan_interface.h>
#endif
#if defined(_WIN32)
-#ifndef WIN32_LEAN_AND_MEAN
-#define WIN32_LEAN_AND_MEAN
-#endif // !WIN32_LEAN_AND_MEAN
-#ifndef NOMINMAX
-#define NOMINMAX
-#endif // !NOMINMAX
-#include <Windows.h>
+# ifndef WIN32_LEAN_AND_MEAN
+# define WIN32_LEAN_AND_MEAN
+# endif // !WIN32_LEAN_AND_MEAN
+# ifndef NOMINMAX
+# define NOMINMAX
+# endif // !NOMINMAX
+# include <Windows.h>
#endif
-#include <mutex>
-#include <limits>
#include <iostream>
+#include <limits>
+#include <mutex>
-namespace rr { class ELFMemoryStreamer; }
+namespace rr {
+class ELFMemoryStreamer;
+}
namespace {
@@ -60,7 +62,7 @@
// This uses a static in a function to avoid the cost of a global static
// initializer. See http://neugierig.org/software/chromium/notes/2011/08/static-initializers.html
static rr::Config config = rr::Config::Edit()
- .apply({});
+ .apply({});
return config;
}
@@ -80,11 +82,11 @@
namespace {
#if !defined(__i386__) && defined(_M_IX86)
- #define __i386__ 1
+# define __i386__ 1
#endif
-#if !defined(__x86_64__) && (defined(_M_AMD64) || defined (_M_X64))
- #define __x86_64__ 1
+#if !defined(__x86_64__) && (defined(_M_AMD64) || defined(_M_X64))
+# define __x86_64__ 1
#endif
static Ice::OptLevel toIce(rr::Optimization::Level level)
@@ -92,9 +94,9 @@
switch(level)
{
// Note that Opt_0 and Opt_1 are not implemented by Subzero
- case rr::Optimization::Level::None: return Ice::Opt_m1;
- case rr::Optimization::Level::Less: return Ice::Opt_m1;
- case rr::Optimization::Level::Default: return Ice::Opt_2;
+ case rr::Optimization::Level::None: return Ice::Opt_m1;
+ case rr::Optimization::Level::Less: return Ice::Opt_m1;
+ case rr::Optimization::Level::Default: return Ice::Opt_2;
case rr::Optimization::Level::Aggressive: return Ice::Opt_2;
default: UNREACHABLE("Unknown Optimization Level %d", int(level));
}
@@ -110,42 +112,44 @@
private:
static void cpuid(int registers[4], int info)
{
- #if defined(__i386__) || defined(__x86_64__)
- #if defined(_WIN32)
- __cpuid(registers, info);
- #else
- __asm volatile("cpuid": "=a" (registers[0]), "=b" (registers[1]), "=c" (registers[2]), "=d" (registers[3]): "a" (info));
- #endif
- #else
- registers[0] = 0;
- registers[1] = 0;
- registers[2] = 0;
- registers[3] = 0;
- #endif
+#if defined(__i386__) || defined(__x86_64__)
+# if defined(_WIN32)
+ __cpuid(registers, info);
+# else
+ __asm volatile("cpuid"
+ : "=a"(registers[0]), "=b"(registers[1]), "=c"(registers[2]), "=d"(registers[3])
+ : "a"(info));
+# endif
+#else
+ registers[0] = 0;
+ registers[1] = 0;
+ registers[2] = 0;
+ registers[3] = 0;
+#endif
}
static bool detectARM()
{
- #if defined(__arm__) || defined(__aarch64__)
- return true;
- #elif defined(__i386__) || defined(__x86_64__)
- return false;
- #elif defined(__mips__)
- return false;
- #else
- #error "Unknown architecture"
- #endif
+#if defined(__arm__) || defined(__aarch64__)
+ return true;
+#elif defined(__i386__) || defined(__x86_64__)
+ return false;
+#elif defined(__mips__)
+ return false;
+#else
+# error "Unknown architecture"
+#endif
}
static bool detectSSE4_1()
{
- #if defined(__i386__) || defined(__x86_64__)
- int registers[4];
- cpuid(registers, 1);
- return (registers[2] & 0x00080000) != 0;
- #else
- return false;
- #endif
+#if defined(__i386__) || defined(__x86_64__)
+ int registers[4];
+ cpuid(registers, 1);
+ return (registers[2] & 0x00080000) != 0;
+#else
+ return false;
+#endif
}
};
@@ -166,9 +170,8 @@
namespace rr {
-const Capabilities Caps =
-{
- false, // CoroutinesSupported
+const Capabilities Caps = {
+ false, // CoroutinesSupported
};
enum EmulatedType
@@ -182,14 +185,17 @@
Type_v2i32 = Ice::IceType_v4i32 | EmulatedV2,
Type_v4i16 = Ice::IceType_v8i16 | EmulatedV4,
Type_v2i16 = Ice::IceType_v8i16 | EmulatedV2,
- Type_v8i8 = Ice::IceType_v16i8 | EmulatedV8,
- Type_v4i8 = Ice::IceType_v16i8 | EmulatedV4,
+ Type_v8i8 = Ice::IceType_v16i8 | EmulatedV8,
+ Type_v4i8 = Ice::IceType_v16i8 | EmulatedV4,
Type_v2f32 = Ice::IceType_v4f32 | EmulatedV2,
};
-class Value : public Ice::Operand {};
-class SwitchCases : public Ice::InstSwitch {};
-class BasicBlock : public Ice::CfgNode {};
+class Value : public Ice::Operand
+{};
+class SwitchCases : public Ice::InstSwitch
+{};
+class BasicBlock : public Ice::CfgNode
+{};
Ice::Type T(Type *t)
{
@@ -199,22 +205,22 @@
Type *T(Ice::Type t)
{
- return reinterpret_cast<Type*>(t);
+ return reinterpret_cast<Type *>(t);
}
Type *T(EmulatedType t)
{
- return reinterpret_cast<Type*>(t);
+ return reinterpret_cast<Type *>(t);
}
Value *V(Ice::Operand *v)
{
- return reinterpret_cast<Value*>(v);
+ return reinterpret_cast<Value *>(v);
}
BasicBlock *B(Ice::CfgNode *b)
{
- return reinterpret_cast<BasicBlock*>(b);
+ return reinterpret_cast<BasicBlock *>(b);
}
static size_t typeSize(Type *type)
@@ -223,25 +229,25 @@
{
switch(reinterpret_cast<std::intptr_t>(type))
{
- case Type_v2i32: return 8;
- case Type_v4i16: return 8;
- case Type_v2i16: return 4;
- case Type_v8i8: return 8;
- case Type_v4i8: return 4;
- case Type_v2f32: return 8;
- default: ASSERT(false);
+ case Type_v2i32: return 8;
+ case Type_v4i16: return 8;
+ case Type_v2i16: return 4;
+ case Type_v8i8: return 8;
+ case Type_v4i8: return 4;
+ case Type_v2f32: return 8;
+ default: ASSERT(false);
}
}
return Ice::typeWidthInBytes(T(type));
}
-using ElfHeader = std::conditional<sizeof(void*) == 8, Elf64_Ehdr, Elf32_Ehdr>::type;
-using SectionHeader = std::conditional<sizeof(void*) == 8, Elf64_Shdr, Elf32_Shdr>::type;
+using ElfHeader = std::conditional<sizeof(void *) == 8, Elf64_Ehdr, Elf32_Ehdr>::type;
+using SectionHeader = std::conditional<sizeof(void *) == 8, Elf64_Shdr, Elf32_Shdr>::type;
inline const SectionHeader *sectionHeader(const ElfHeader *elfHeader)
{
- return reinterpret_cast<const SectionHeader*>((intptr_t)elfHeader + elfHeader->e_shoff);
+ return reinterpret_cast<const SectionHeader *>((intptr_t)elfHeader + elfHeader->e_shoff);
}
inline const SectionHeader *elfSection(const ElfHeader *elfHeader, int index)
@@ -270,13 +276,13 @@
}
intptr_t symbolAddress = (intptr_t)elfHeader + symbolTable->sh_offset;
- Elf32_Sym &symbol = ((Elf32_Sym*)symbolAddress)[index];
+ Elf32_Sym &symbol = ((Elf32_Sym *)symbolAddress)[index];
uint16_t section = symbol.st_shndx;
if(section != SHN_UNDEF && section < SHN_LORESERVE)
{
const SectionHeader *target = elfSection(elfHeader, symbol.st_shndx);
- symbolValue = reinterpret_cast<void*>((intptr_t)elfHeader + symbol.st_value + target->sh_offset);
+ symbolValue = reinterpret_cast<void *>((intptr_t)elfHeader + symbol.st_value + target->sh_offset);
}
else
{
@@ -285,49 +291,49 @@
}
intptr_t address = (intptr_t)elfHeader + target->sh_offset;
- unaligned_ptr<int32_t> patchSite = (int32_t*)(address + relocation.r_offset);
+ unaligned_ptr<int32_t> patchSite = (int32_t *)(address + relocation.r_offset);
if(CPUID::ARM)
{
switch(relocation.getType())
{
- case R_ARM_NONE:
- // No relocation
- break;
- case R_ARM_MOVW_ABS_NC:
+ case R_ARM_NONE:
+ // No relocation
+ break;
+ case R_ARM_MOVW_ABS_NC:
{
- uint32_t thumb = 0; // Calls to Thumb code not supported.
+ uint32_t thumb = 0; // Calls to Thumb code not supported.
uint32_t lo = (uint32_t)(intptr_t)symbolValue | thumb;
*patchSite = (*patchSite & 0xFFF0F000) | ((lo & 0xF000) << 4) | (lo & 0x0FFF);
}
break;
- case R_ARM_MOVT_ABS:
+ case R_ARM_MOVT_ABS:
{
uint32_t hi = (uint32_t)(intptr_t)(symbolValue) >> 16;
*patchSite = (*patchSite & 0xFFF0F000) | ((hi & 0xF000) << 4) | (hi & 0x0FFF);
}
break;
- default:
- ASSERT(false && "Unsupported relocation type");
- return nullptr;
+ default:
+ ASSERT(false && "Unsupported relocation type");
+ return nullptr;
}
}
else
{
switch(relocation.getType())
{
- case R_386_NONE:
- // No relocation
- break;
- case R_386_32:
- *patchSite = (int32_t)((intptr_t)symbolValue + *patchSite);
- break;
- case R_386_PC32:
- *patchSite = (int32_t)((intptr_t)symbolValue + *patchSite - (intptr_t)patchSite);
- break;
- default:
- ASSERT(false && "Unsupported relocation type");
- return nullptr;
+ case R_386_NONE:
+ // No relocation
+ break;
+ case R_386_32:
+ *patchSite = (int32_t)((intptr_t)symbolValue + *patchSite);
+ break;
+ case R_386_PC32:
+ *patchSite = (int32_t)((intptr_t)symbolValue + *patchSite - (intptr_t)patchSite);
+ break;
+ default:
+ ASSERT(false && "Unsupported relocation type");
+ return nullptr;
}
}
@@ -355,13 +361,13 @@
}
intptr_t symbolAddress = (intptr_t)elfHeader + symbolTable->sh_offset;
- Elf64_Sym &symbol = ((Elf64_Sym*)symbolAddress)[index];
+ Elf64_Sym &symbol = ((Elf64_Sym *)symbolAddress)[index];
uint16_t section = symbol.st_shndx;
if(section != SHN_UNDEF && section < SHN_LORESERVE)
{
const SectionHeader *target = elfSection(elfHeader, symbol.st_shndx);
- symbolValue = reinterpret_cast<void*>((intptr_t)elfHeader + symbol.st_value + target->sh_offset);
+ symbolValue = reinterpret_cast<void *>((intptr_t)elfHeader + symbol.st_value + target->sh_offset);
}
else
{
@@ -370,26 +376,26 @@
}
intptr_t address = (intptr_t)elfHeader + target->sh_offset;
- unaligned_ptr<int32_t> patchSite32 = (int32_t*)(address + relocation.r_offset);
- unaligned_ptr<int64_t> patchSite64 = (int64_t*)(address + relocation.r_offset);
+ unaligned_ptr<int32_t> patchSite32 = (int32_t *)(address + relocation.r_offset);
+ unaligned_ptr<int64_t> patchSite64 = (int64_t *)(address + relocation.r_offset);
switch(relocation.getType())
{
- case R_X86_64_NONE:
- // No relocation
- break;
- case R_X86_64_64:
- *patchSite64 = (int64_t)((intptr_t)symbolValue + *patchSite64 + relocation.r_addend);
- break;
- case R_X86_64_PC32:
- *patchSite32 = (int32_t)((intptr_t)symbolValue + *patchSite32 - (intptr_t)patchSite32 + relocation.r_addend);
- break;
- case R_X86_64_32S:
- *patchSite32 = (int32_t)((intptr_t)symbolValue + *patchSite32 + relocation.r_addend);
- break;
- default:
- ASSERT(false && "Unsupported relocation type");
- return nullptr;
+ case R_X86_64_NONE:
+ // No relocation
+ break;
+ case R_X86_64_64:
+ *patchSite64 = (int64_t)((intptr_t)symbolValue + *patchSite64 + relocation.r_addend);
+ break;
+ case R_X86_64_PC32:
+ *patchSite32 = (int32_t)((intptr_t)symbolValue + *patchSite32 - (intptr_t)patchSite32 + relocation.r_addend);
+ break;
+ case R_X86_64_32S:
+ *patchSite32 = (int32_t)((intptr_t)symbolValue + *patchSite32 + relocation.r_addend);
+ break;
+ default:
+ ASSERT(false && "Unsupported relocation type");
+ return nullptr;
}
return symbolValue;
@@ -397,7 +403,7 @@
void *loadImage(uint8_t *const elfImage, size_t &codeSize)
{
- ElfHeader *elfHeader = (ElfHeader*)elfImage;
+ ElfHeader *elfHeader = (ElfHeader *)elfImage;
if(!elfHeader->checkMagic())
{
@@ -405,22 +411,22 @@
}
// Expect ELF bitness to match platform
- ASSERT(sizeof(void*) == 8 ? elfHeader->getFileClass() == ELFCLASS64 : elfHeader->getFileClass() == ELFCLASS32);
- #if defined(__i386__)
- ASSERT(sizeof(void*) == 4 && elfHeader->e_machine == EM_386);
- #elif defined(__x86_64__)
- ASSERT(sizeof(void*) == 8 && elfHeader->e_machine == EM_X86_64);
- #elif defined(__arm__)
- ASSERT(sizeof(void*) == 4 && elfHeader->e_machine == EM_ARM);
- #elif defined(__aarch64__)
- ASSERT(sizeof(void*) == 8 && elfHeader->e_machine == EM_AARCH64);
- #elif defined(__mips__)
- ASSERT(sizeof(void*) == 4 && elfHeader->e_machine == EM_MIPS);
- #else
- #error "Unsupported platform"
- #endif
+ ASSERT(sizeof(void *) == 8 ? elfHeader->getFileClass() == ELFCLASS64 : elfHeader->getFileClass() == ELFCLASS32);
+#if defined(__i386__)
+ ASSERT(sizeof(void *) == 4 && elfHeader->e_machine == EM_386);
+#elif defined(__x86_64__)
+ ASSERT(sizeof(void *) == 8 && elfHeader->e_machine == EM_X86_64);
+#elif defined(__arm__)
+ ASSERT(sizeof(void *) == 4 && elfHeader->e_machine == EM_ARM);
+#elif defined(__aarch64__)
+ ASSERT(sizeof(void *) == 8 && elfHeader->e_machine == EM_AARCH64);
+#elif defined(__mips__)
+ ASSERT(sizeof(void *) == 4 && elfHeader->e_machine == EM_MIPS);
+#else
+# error "Unsupported platform"
+#endif
- SectionHeader *sectionHeader = (SectionHeader*)(elfImage + elfHeader->e_shoff);
+ SectionHeader *sectionHeader = (SectionHeader *)(elfImage + elfHeader->e_shoff);
void *entry = nullptr;
for(int i = 0; i < elfHeader->e_shnum; i++)
@@ -435,21 +441,21 @@
}
else if(sectionHeader[i].sh_type == SHT_REL)
{
- ASSERT(sizeof(void*) == 4 && "UNIMPLEMENTED"); // Only expected/implemented for 32-bit code
+ ASSERT(sizeof(void *) == 4 && "UNIMPLEMENTED"); // Only expected/implemented for 32-bit code
for(Elf32_Word index = 0; index < sectionHeader[i].sh_size / sectionHeader[i].sh_entsize; index++)
{
- const Elf32_Rel &relocation = ((const Elf32_Rel*)(elfImage + sectionHeader[i].sh_offset))[index];
+ const Elf32_Rel &relocation = ((const Elf32_Rel *)(elfImage + sectionHeader[i].sh_offset))[index];
relocateSymbol(elfHeader, relocation, sectionHeader[i]);
}
}
else if(sectionHeader[i].sh_type == SHT_RELA)
{
- ASSERT(sizeof(void*) == 8 && "UNIMPLEMENTED"); // Only expected/implemented for 64-bit code
+ ASSERT(sizeof(void *) == 8 && "UNIMPLEMENTED"); // Only expected/implemented for 64-bit code
for(Elf32_Word index = 0; index < sectionHeader[i].sh_size / sectionHeader[i].sh_entsize; index++)
{
- const Elf64_Rela &relocation = ((const Elf64_Rela*)(elfImage + sectionHeader[i].sh_offset))[index];
+ const Elf64_Rela &relocation = ((const Elf64_Rela *)(elfImage + sectionHeader[i].sh_offset))[index];
relocateSymbol(elfHeader, relocation, sectionHeader[i]);
}
}
@@ -462,15 +468,17 @@
struct ExecutableAllocator
{
ExecutableAllocator() {}
- template<class U> ExecutableAllocator(const ExecutableAllocator<U> &other) {}
+ template<class U>
+ ExecutableAllocator(const ExecutableAllocator<U> &other)
+ {}
using value_type = T;
using size_type = std::size_t;
T *allocate(size_type n)
{
- return (T*)allocateMemoryPages(
- sizeof(T) * n, PERMISSION_READ | PERMISSION_WRITE, true);
+ return (T *)allocateMemoryPages(
+ sizeof(T) * n, PERMISSION_READ | PERMISSION_WRITE, true);
}
void deallocate(T *p, size_type n)
@@ -485,7 +493,8 @@
ELFMemoryStreamer &operator=(const ELFMemoryStreamer &) = delete;
public:
- ELFMemoryStreamer() : Routine()
+ ELFMemoryStreamer()
+ : Routine()
{
position = 0;
buffer.reserve(0x1000);
@@ -507,7 +516,8 @@
buffer[position] = Value;
position++;
}
- else ASSERT(false && "UNIMPLEMENTED");
+ else
+ ASSERT(false && "UNIMPLEMENTED");
}
void writeBytes(llvm::StringRef Bytes) override
@@ -522,9 +532,9 @@
void seek(uint64_t Off) override { position = Off; }
- const void* finalizeEntryBegin()
+ const void *finalizeEntryBegin()
{
- position = std::numeric_limits<std::size_t>::max(); // Can't stream more data after this
+ position = std::numeric_limits<std::size_t>::max(); // Can't stream more data after this
size_t codeSize = 0;
const void *entry = loadImage(&buffer[0], codeSize);
@@ -533,12 +543,12 @@
#if defined(_WIN32)
FlushInstructionCache(GetCurrentProcess(), NULL, 0);
#else
- __builtin___clear_cache((char*)entry, (char*)entry + codeSize);
+ __builtin___clear_cache((char *)entry, (char *)entry + codeSize);
#endif
return entry;
}
- void setEntry(int index, const void* func)
+ void setEntry(int index, const void *func)
{
ASSERT(func);
funcs[index] = func;
@@ -550,7 +560,7 @@
return funcs[index];
}
- const void* addConstantData(const void* data, size_t size)
+ const void *addConstantData(const void *data, size_t size)
{
auto buf = std::unique_ptr<uint8_t[]>(new uint8_t[size]);
memcpy(buf.get(), data, size);
@@ -560,7 +570,7 @@
}
private:
- std::array<const void*, Nucleus::CoroutineEntryCount> funcs = {};
+ std::array<const void *, Nucleus::CoroutineEntryCount> funcs = {};
std::vector<uint8_t, ExecutableAllocator<uint8_t>> buffer;
std::size_t position;
std::vector<std::unique_ptr<uint8_t[]>> constantData;
@@ -568,21 +578,21 @@
Nucleus::Nucleus()
{
- ::codegenMutex.lock(); // Reactor is currently not thread safe
+ ::codegenMutex.lock(); // Reactor is currently not thread safe
Ice::ClFlags &Flags = Ice::ClFlags::Flags;
Ice::ClFlags::getParsedClFlags(Flags);
- #if defined(__arm__)
- Flags.setTargetArch(Ice::Target_ARM32);
- Flags.setTargetInstructionSet(Ice::ARM32InstructionSet_HWDivArm);
- #elif defined(__mips__)
- Flags.setTargetArch(Ice::Target_MIPS32);
- Flags.setTargetInstructionSet(Ice::BaseInstructionSet);
- #else // x86
- Flags.setTargetArch(sizeof(void*) == 8 ? Ice::Target_X8664 : Ice::Target_X8632);
- Flags.setTargetInstructionSet(CPUID::SSE4_1 ? Ice::X86InstructionSet_SSE4_1 : Ice::X86InstructionSet_SSE2);
- #endif
+#if defined(__arm__)
+ Flags.setTargetArch(Ice::Target_ARM32);
+ Flags.setTargetInstructionSet(Ice::ARM32InstructionSet_HWDivArm);
+#elif defined(__mips__)
+ Flags.setTargetArch(Ice::Target_MIPS32);
+ Flags.setTargetInstructionSet(Ice::BaseInstructionSet);
+#else // x86
+ Flags.setTargetArch(sizeof(void *) == 8 ? Ice::Target_X8664 : Ice::Target_X8632);
+ Flags.setTargetInstructionSet(CPUID::SSE4_1 ? Ice::X86InstructionSet_SSE4_1 : Ice::X86InstructionSet_SSE2);
+#endif
Flags.setOutFileType(Ice::FT_Elf);
Flags.setOptLevel(toIce(getDefaultConfig().getOptimization().getLevel()));
Flags.setApplicationBinaryInterface(Ice::ABI_Platform);
@@ -598,7 +608,7 @@
Flags.setDecorateAsm(true);
}
- if(false) // Write out to a file
+ if(false) // Write out to a file
{
std::error_code errorCode;
::out = new Ice::Fdstream("out.o", errorCode, llvm::sys::fs::F_None);
@@ -694,7 +704,7 @@
objectWriter->setUndefinedSyms(::context->getConstantExternSyms());
objectWriter->writeNonUserSections();
- const void* entryBegin = ::routine->finalizeEntryBegin();
+ const void *entryBegin = ::routine->finalizeEntryBegin();
::routine->setEntry(Nucleus::CoroutineEntryBegin, entryBegin);
Routine *handoffRoutine = ::routine;
@@ -729,14 +739,14 @@
void Nucleus::setInsertBlock(BasicBlock *basicBlock)
{
-// ASSERT(::basicBlock->getInsts().back().getTerminatorEdges().size() >= 0 && "Previous basic block must have a terminator");
+ // ASSERT(::basicBlock->getInsts().back().getTerminatorEdges().size() >= 0 && "Previous basic block must have a terminator");
Variable::materializeAll();
::basicBlock = basicBlock;
}
-void Nucleus::createFunction(Type *ReturnType, std::vector<Type*> &Params)
+void Nucleus::createFunction(Type *ReturnType, std::vector<Type *> &Params)
{
uint32_t sequenceNumber = 0;
::function = Ice::Cfg::create(::context, sequenceNumber).release();
@@ -800,16 +810,16 @@
{
switch(op)
{
- case Ice::InstArithmetic::Add:
- case Ice::InstArithmetic::Fadd:
- case Ice::InstArithmetic::Mul:
- case Ice::InstArithmetic::Fmul:
- case Ice::InstArithmetic::And:
- case Ice::InstArithmetic::Or:
- case Ice::InstArithmetic::Xor:
- return true;
- default:
- return false;
+ case Ice::InstArithmetic::Add:
+ case Ice::InstArithmetic::Fadd:
+ case Ice::InstArithmetic::Mul:
+ case Ice::InstArithmetic::Fmul:
+ case Ice::InstArithmetic::And:
+ case Ice::InstArithmetic::Or:
+ case Ice::InstArithmetic::Xor:
+ return true;
+ default:
+ return false;
}
}
@@ -923,10 +933,8 @@
Value *Nucleus::createFNeg(Value *v)
{
- double c[4] = {-0.0, -0.0, -0.0, -0.0};
- Value *negativeZero = Ice::isVectorType(v->getType()) ?
- createConstantVector(c, T(v->getType())) :
- V(::context->getConstantFloat(-0.0f));
+ double c[4] = { -0.0, -0.0, -0.0, -0.0 };
+ Value *negativeZero = Ice::isVectorType(v->getType()) ? createConstantVector(c, T(v->getType())) : V(::context->getConstantFloat(-0.0f));
return createFSub(negativeZero, v);
}
@@ -937,22 +945,22 @@
{
return createXor(v, V(::context->getConstantInt(v->getType(), -1)));
}
- else // Vector
+ else // Vector
{
- int64_t c[16] = {-1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1};
+ int64_t c[16] = { -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1 };
return createXor(v, createConstantVector(c, T(v->getType())));
}
}
Value *Nucleus::createLoad(Value *ptr, Type *type, bool isVolatile, unsigned int align, bool atomic, std::memory_order memoryOrder)
{
- ASSERT(!atomic); // Unimplemented
+ ASSERT(!atomic); // Unimplemented
ASSERT(memoryOrder == std::memory_order_relaxed); // Unimplemented
int valueType = (int)reinterpret_cast<intptr_t>(type);
Ice::Variable *result = ::function->makeVariable(T(type));
- if((valueType & EmulatedBits) && (align != 0)) // Narrow vector not stored on stack.
+ if((valueType & EmulatedBits) && (align != 0)) // Narrow vector not stored on stack.
{
if(emulateIntrinsics)
{
@@ -980,11 +988,12 @@
auto bitcast = Ice::InstCast::create(::function, Ice::InstCast::Bitcast, result, vector.loadValue());
::basicBlock->appendInst(bitcast);
}
- else UNREACHABLE("typeSize(type): %d", int(typeSize(type)));
+ else
+ UNREACHABLE("typeSize(type): %d", int(typeSize(type)));
}
else
{
- const Ice::Intrinsics::IntrinsicInfo intrinsic = {Ice::Intrinsics::LoadSubVector, Ice::Intrinsics::SideEffects_F, Ice::Intrinsics::ReturnsTwice_F, Ice::Intrinsics::MemoryWrite_F};
+ const Ice::Intrinsics::IntrinsicInfo intrinsic = { Ice::Intrinsics::LoadSubVector, Ice::Intrinsics::SideEffects_F, Ice::Intrinsics::ReturnsTwice_F, Ice::Intrinsics::MemoryWrite_F };
auto target = ::context->getConstantUndef(Ice::IceType_i32);
auto load = Ice::InstIntrinsicCall::create(::function, 2, result, target, intrinsic);
load->addArg(ptr);
@@ -1003,23 +1012,23 @@
Value *Nucleus::createStore(Value *value, Value *ptr, Type *type, bool isVolatile, unsigned int align, bool atomic, std::memory_order memoryOrder)
{
- ASSERT(!atomic); // Unimplemented
+ ASSERT(!atomic); // Unimplemented
ASSERT(memoryOrder == std::memory_order_relaxed); // Unimplemented
- #if __has_feature(memory_sanitizer)
- // Mark all (non-stack) memory writes as initialized by calling __msan_unpoison
- if(align != 0)
- {
- auto call = Ice::InstCall::create(::function, 2, nullptr, ::context->getConstantInt64(reinterpret_cast<intptr_t>(__msan_unpoison)), false);
- call->addArg(ptr);
- call->addArg(::context->getConstantInt64(typeSize(type)));
- ::basicBlock->appendInst(call);
- }
- #endif
+#if __has_feature(memory_sanitizer)
+ // Mark all (non-stack) memory writes as initialized by calling __msan_unpoison
+ if(align != 0)
+ {
+ auto call = Ice::InstCall::create(::function, 2, nullptr, ::context->getConstantInt64(reinterpret_cast<intptr_t>(__msan_unpoison)), false);
+ call->addArg(ptr);
+ call->addArg(::context->getConstantInt64(typeSize(type)));
+ ::basicBlock->appendInst(call);
+ }
+#endif
int valueType = (int)reinterpret_cast<intptr_t>(type);
- if((valueType & EmulatedBits) && (align != 0)) // Narrow vector not stored on stack.
+ if((valueType & EmulatedBits) && (align != 0)) // Narrow vector not stored on stack.
{
if(emulateIntrinsics)
{
@@ -1049,11 +1058,12 @@
Int y = Extract(v, 1);
*Pointer<Int>(pointer + 4) = y;
}
- else UNREACHABLE("typeSize(type): %d", int(typeSize(type)));
+ else
+ UNREACHABLE("typeSize(type): %d", int(typeSize(type)));
}
else
{
- const Ice::Intrinsics::IntrinsicInfo intrinsic = {Ice::Intrinsics::StoreSubVector, Ice::Intrinsics::SideEffects_T, Ice::Intrinsics::ReturnsTwice_F, Ice::Intrinsics::MemoryWrite_T};
+ const Ice::Intrinsics::IntrinsicInfo intrinsic = { Ice::Intrinsics::StoreSubVector, Ice::Intrinsics::SideEffects_T, Ice::Intrinsics::ReturnsTwice_F, Ice::Intrinsics::MemoryWrite_T };
auto target = ::context->getConstantUndef(Ice::IceType_i32);
auto store = Ice::InstIntrinsicCall::create(::function, 3, nullptr, target, intrinsic);
store->addArg(value);
@@ -1094,7 +1104,7 @@
index = createMul(index, createConstantInt((int)typeSize(type)));
}
- if(sizeof(void*) == 8)
+ if(sizeof(void *) == 8)
{
if(unsignedIndex)
{
@@ -1453,7 +1463,7 @@
auto switchInst = Ice::InstSwitch::create(::function, numCases, control, defaultBranch);
::basicBlock->appendInst(switchInst);
- return reinterpret_cast<SwitchCases*>(switchInst);
+ return reinterpret_cast<SwitchCases *>(switchInst);
}
void Nucleus::addSwitchCase(SwitchCases *switchCases, int label, BasicBlock *branch)
@@ -1469,7 +1479,7 @@
Type *Nucleus::getPointerType(Type *ElementType)
{
- if(sizeof(void*) == 8)
+ if(sizeof(void *) == 8)
{
return T(Ice::IceType_i64);
}
@@ -1484,7 +1494,7 @@
if(Ice::isVectorType(T(Ty)))
{
ASSERT(Ice::typeNumElements(T(Ty)) <= 16);
- int64_t c[16] = {0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0};
+ int64_t c[16] = { 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0 };
return createConstantVector(c, Ty);
}
else
@@ -1540,7 +1550,7 @@
Value *Nucleus::createNullPointer(Type *Ty)
{
- return createNullValue(T(sizeof(void*) == 8 ? Ice::IceType_i64 : Ice::IceType_i32));
+ return createNullValue(T(sizeof(void *) == 8 ? Ice::IceType_i64 : Ice::IceType_i32));
}
Value *Nucleus::createConstantVector(const int64_t *constants, Type *type)
@@ -1551,79 +1561,79 @@
auto globalPool = ::function->getGlobalPool();
const int64_t *i = constants;
- const double *f = reinterpret_cast<const double*>(constants);
+ const double *f = reinterpret_cast<const double *>(constants);
Ice::VariableDeclaration::DataInitializer *dataInitializer = nullptr;
switch((int)reinterpret_cast<intptr_t>(type))
{
- case Ice::IceType_v4i32:
- case Ice::IceType_v4i1:
+ case Ice::IceType_v4i32:
+ case Ice::IceType_v4i1:
{
- const int initializer[4] = {(int)i[0], (int)i[1], (int)i[2], (int)i[3]};
+ const int initializer[4] = { (int)i[0], (int)i[1], (int)i[2], (int)i[3] };
static_assert(sizeof(initializer) == vectorSize, "!");
- dataInitializer = Ice::VariableDeclaration::DataInitializer::create(globalPool, (const char*)initializer, vectorSize);
+ dataInitializer = Ice::VariableDeclaration::DataInitializer::create(globalPool, (const char *)initializer, vectorSize);
}
break;
- case Ice::IceType_v4f32:
+ case Ice::IceType_v4f32:
{
- const float initializer[4] = {(float)f[0], (float)f[1], (float)f[2], (float)f[3]};
+ const float initializer[4] = { (float)f[0], (float)f[1], (float)f[2], (float)f[3] };
static_assert(sizeof(initializer) == vectorSize, "!");
- dataInitializer = Ice::VariableDeclaration::DataInitializer::create(globalPool, (const char*)initializer, vectorSize);
+ dataInitializer = Ice::VariableDeclaration::DataInitializer::create(globalPool, (const char *)initializer, vectorSize);
}
break;
- case Ice::IceType_v8i16:
- case Ice::IceType_v8i1:
+ case Ice::IceType_v8i16:
+ case Ice::IceType_v8i1:
{
- const short initializer[8] = {(short)i[0], (short)i[1], (short)i[2], (short)i[3], (short)i[4], (short)i[5], (short)i[6], (short)i[7]};
+ const short initializer[8] = { (short)i[0], (short)i[1], (short)i[2], (short)i[3], (short)i[4], (short)i[5], (short)i[6], (short)i[7] };
static_assert(sizeof(initializer) == vectorSize, "!");
- dataInitializer = Ice::VariableDeclaration::DataInitializer::create(globalPool, (const char*)initializer, vectorSize);
+ dataInitializer = Ice::VariableDeclaration::DataInitializer::create(globalPool, (const char *)initializer, vectorSize);
}
break;
- case Ice::IceType_v16i8:
- case Ice::IceType_v16i1:
+ case Ice::IceType_v16i8:
+ case Ice::IceType_v16i1:
{
- const char initializer[16] = {(char)i[0], (char)i[1], (char)i[2], (char)i[3], (char)i[4], (char)i[5], (char)i[6], (char)i[7], (char)i[8], (char)i[9], (char)i[10], (char)i[11], (char)i[12], (char)i[13], (char)i[14], (char)i[15]};
+ const char initializer[16] = { (char)i[0], (char)i[1], (char)i[2], (char)i[3], (char)i[4], (char)i[5], (char)i[6], (char)i[7], (char)i[8], (char)i[9], (char)i[10], (char)i[11], (char)i[12], (char)i[13], (char)i[14], (char)i[15] };
static_assert(sizeof(initializer) == vectorSize, "!");
- dataInitializer = Ice::VariableDeclaration::DataInitializer::create(globalPool, (const char*)initializer, vectorSize);
+ dataInitializer = Ice::VariableDeclaration::DataInitializer::create(globalPool, (const char *)initializer, vectorSize);
}
break;
- case Type_v2i32:
+ case Type_v2i32:
{
- const int initializer[4] = {(int)i[0], (int)i[1], (int)i[0], (int)i[1]};
+ const int initializer[4] = { (int)i[0], (int)i[1], (int)i[0], (int)i[1] };
static_assert(sizeof(initializer) == vectorSize, "!");
- dataInitializer = Ice::VariableDeclaration::DataInitializer::create(globalPool, (const char*)initializer, vectorSize);
+ dataInitializer = Ice::VariableDeclaration::DataInitializer::create(globalPool, (const char *)initializer, vectorSize);
}
break;
- case Type_v2f32:
+ case Type_v2f32:
{
- const float initializer[4] = {(float)f[0], (float)f[1], (float)f[0], (float)f[1]};
+ const float initializer[4] = { (float)f[0], (float)f[1], (float)f[0], (float)f[1] };
static_assert(sizeof(initializer) == vectorSize, "!");
- dataInitializer = Ice::VariableDeclaration::DataInitializer::create(globalPool, (const char*)initializer, vectorSize);
+ dataInitializer = Ice::VariableDeclaration::DataInitializer::create(globalPool, (const char *)initializer, vectorSize);
}
break;
- case Type_v4i16:
+ case Type_v4i16:
{
- const short initializer[8] = {(short)i[0], (short)i[1], (short)i[2], (short)i[3], (short)i[0], (short)i[1], (short)i[2], (short)i[3]};
+ const short initializer[8] = { (short)i[0], (short)i[1], (short)i[2], (short)i[3], (short)i[0], (short)i[1], (short)i[2], (short)i[3] };
static_assert(sizeof(initializer) == vectorSize, "!");
- dataInitializer = Ice::VariableDeclaration::DataInitializer::create(globalPool, (const char*)initializer, vectorSize);
+ dataInitializer = Ice::VariableDeclaration::DataInitializer::create(globalPool, (const char *)initializer, vectorSize);
}
break;
- case Type_v8i8:
+ case Type_v8i8:
{
- const char initializer[16] = {(char)i[0], (char)i[1], (char)i[2], (char)i[3], (char)i[4], (char)i[5], (char)i[6], (char)i[7], (char)i[0], (char)i[1], (char)i[2], (char)i[3], (char)i[4], (char)i[5], (char)i[6], (char)i[7]};
+ const char initializer[16] = { (char)i[0], (char)i[1], (char)i[2], (char)i[3], (char)i[4], (char)i[5], (char)i[6], (char)i[7], (char)i[0], (char)i[1], (char)i[2], (char)i[3], (char)i[4], (char)i[5], (char)i[6], (char)i[7] };
static_assert(sizeof(initializer) == vectorSize, "!");
- dataInitializer = Ice::VariableDeclaration::DataInitializer::create(globalPool, (const char*)initializer, vectorSize);
+ dataInitializer = Ice::VariableDeclaration::DataInitializer::create(globalPool, (const char *)initializer, vectorSize);
}
break;
- case Type_v4i8:
+ case Type_v4i8:
{
- const char initializer[16] = {(char)i[0], (char)i[1], (char)i[2], (char)i[3], (char)i[0], (char)i[1], (char)i[2], (char)i[3], (char)i[0], (char)i[1], (char)i[2], (char)i[3], (char)i[0], (char)i[1], (char)i[2], (char)i[3]};
+ const char initializer[16] = { (char)i[0], (char)i[1], (char)i[2], (char)i[3], (char)i[0], (char)i[1], (char)i[2], (char)i[3], (char)i[0], (char)i[1], (char)i[2], (char)i[3], (char)i[0], (char)i[1], (char)i[2], (char)i[3] };
static_assert(sizeof(initializer) == vectorSize, "!");
- dataInitializer = Ice::VariableDeclaration::DataInitializer::create(globalPool, (const char*)initializer, vectorSize);
+ dataInitializer = Ice::VariableDeclaration::DataInitializer::create(globalPool, (const char *)initializer, vectorSize);
}
break;
- default:
- UNREACHABLE("Unknown constant vector type: %d", (int)reinterpret_cast<intptr_t>(type));
+ default:
+ UNREACHABLE("Unknown constant vector type: %d", (int)reinterpret_cast<intptr_t>(type));
}
auto name = Ice::GlobalString::createWithoutString(::context);
@@ -1647,7 +1657,7 @@
Value *Nucleus::createConstantVector(const double *constants, Type *type)
{
- return createConstantVector((const int64_t*)constants, type);
+ return createConstantVector((const int64_t *)constants, type);
}
Type *Void::getType()
@@ -1690,24 +1700,23 @@
return T(Type_v4i8);
}
-namespace
+namespace {
+RValue<Byte> SaturateUnsigned(RValue<Short> x)
{
- RValue<Byte> SaturateUnsigned(RValue<Short> x)
- {
- return Byte(IfThenElse(Int(x) > 0xFF, Int(0xFF), IfThenElse(Int(x) < 0, Int(0), Int(x))));
- }
-
- RValue<Byte> Extract(RValue<Byte8> val, int i)
- {
- return RValue<Byte>(Nucleus::createExtractElement(val.value, Byte::getType(), i));
- }
-
- RValue<Byte8> Insert(RValue<Byte8> val, RValue<Byte> element, int i)
- {
- return RValue<Byte8>(Nucleus::createInsertElement(val.value, element.value, i));
- }
+ return Byte(IfThenElse(Int(x) > 0xFF, Int(0xFF), IfThenElse(Int(x) < 0, Int(0), Int(x))));
}
+RValue<Byte> Extract(RValue<Byte8> val, int i)
+{
+ return RValue<Byte>(Nucleus::createExtractElement(val.value, Byte::getType(), i));
+}
+
+RValue<Byte8> Insert(RValue<Byte8> val, RValue<Byte> element, int i)
+{
+ return RValue<Byte8>(Nucleus::createInsertElement(val.value, element.value, i));
+}
+} // namespace
+
RValue<Byte8> AddSat(RValue<Byte8> x, RValue<Byte8> y)
{
if(emulateIntrinsics)
@@ -1727,7 +1736,7 @@
else
{
Ice::Variable *result = ::function->makeVariable(Ice::IceType_v16i8);
- const Ice::Intrinsics::IntrinsicInfo intrinsic = {Ice::Intrinsics::AddSaturateUnsigned, Ice::Intrinsics::SideEffects_F, Ice::Intrinsics::ReturnsTwice_F, Ice::Intrinsics::MemoryWrite_F};
+ const Ice::Intrinsics::IntrinsicInfo intrinsic = { Ice::Intrinsics::AddSaturateUnsigned, Ice::Intrinsics::SideEffects_F, Ice::Intrinsics::ReturnsTwice_F, Ice::Intrinsics::MemoryWrite_F };
auto target = ::context->getConstantUndef(Ice::IceType_i32);
auto paddusb = Ice::InstIntrinsicCall::create(::function, 2, result, target, intrinsic);
paddusb->addArg(x.value);
@@ -1757,7 +1766,7 @@
else
{
Ice::Variable *result = ::function->makeVariable(Ice::IceType_v16i8);
- const Ice::Intrinsics::IntrinsicInfo intrinsic = {Ice::Intrinsics::SubtractSaturateUnsigned, Ice::Intrinsics::SideEffects_F, Ice::Intrinsics::ReturnsTwice_F, Ice::Intrinsics::MemoryWrite_F};
+ const Ice::Intrinsics::IntrinsicInfo intrinsic = { Ice::Intrinsics::SubtractSaturateUnsigned, Ice::Intrinsics::SideEffects_F, Ice::Intrinsics::ReturnsTwice_F, Ice::Intrinsics::MemoryWrite_F };
auto target = ::context->getConstantUndef(Ice::IceType_i32);
auto psubusw = Ice::InstIntrinsicCall::create(::function, 2, result, target, intrinsic);
psubusw->addArg(x.value);
@@ -1796,15 +1805,15 @@
}
else
{
- #if defined(__i386__) || defined(__x86_64__)
- // SSE2 doesn't support byte vector shifts, so shift as shorts and recombine.
- RValue<Short4> hi = (As<Short4>(lhs) >> rhs) & Short4(0xFF00u);
- RValue<Short4> lo = As<Short4>(As<UShort4>((As<Short4>(lhs) << 8) >> rhs) >> 8);
+#if defined(__i386__) || defined(__x86_64__)
+ // SSE2 doesn't support byte vector shifts, so shift as shorts and recombine.
+ RValue<Short4> hi = (As<Short4>(lhs) >> rhs) & Short4(0xFF00u);
+ RValue<Short4> lo = As<Short4>(As<UShort4>((As<Short4>(lhs) << 8) >> rhs) >> 8);
- return As<SByte8>(hi | lo);
- #else
- return RValue<SByte8>(Nucleus::createAShr(lhs.value, V(::context->getConstantInt32(rhs))));
- #endif
+ return As<SByte8>(hi | lo);
+#else
+ return RValue<SByte8>(Nucleus::createAShr(lhs.value, V(::context->getConstantInt32(rhs))));
+#endif
}
}
@@ -1818,7 +1827,7 @@
else
{
Ice::Variable *result = ::function->makeVariable(Ice::IceType_i32);
- const Ice::Intrinsics::IntrinsicInfo intrinsic = {Ice::Intrinsics::SignMask, Ice::Intrinsics::SideEffects_F, Ice::Intrinsics::ReturnsTwice_F, Ice::Intrinsics::MemoryWrite_F};
+ const Ice::Intrinsics::IntrinsicInfo intrinsic = { Ice::Intrinsics::SignMask, Ice::Intrinsics::SideEffects_F, Ice::Intrinsics::ReturnsTwice_F, Ice::Intrinsics::MemoryWrite_F };
auto target = ::context->getConstantUndef(Ice::IceType_i32);
auto movmsk = Ice::InstIntrinsicCall::create(::function, 1, result, target, intrinsic);
movmsk->addArg(x.value);
@@ -1877,7 +1886,7 @@
else
{
Ice::Variable *result = ::function->makeVariable(Ice::IceType_v16i8);
- const Ice::Intrinsics::IntrinsicInfo intrinsic = {Ice::Intrinsics::AddSaturateSigned, Ice::Intrinsics::SideEffects_F, Ice::Intrinsics::ReturnsTwice_F, Ice::Intrinsics::MemoryWrite_F};
+ const Ice::Intrinsics::IntrinsicInfo intrinsic = { Ice::Intrinsics::AddSaturateSigned, Ice::Intrinsics::SideEffects_F, Ice::Intrinsics::ReturnsTwice_F, Ice::Intrinsics::MemoryWrite_F };
auto target = ::context->getConstantUndef(Ice::IceType_i32);
auto paddsb = Ice::InstIntrinsicCall::create(::function, 2, result, target, intrinsic);
paddsb->addArg(x.value);
@@ -1907,7 +1916,7 @@
else
{
Ice::Variable *result = ::function->makeVariable(Ice::IceType_v16i8);
- const Ice::Intrinsics::IntrinsicInfo intrinsic = {Ice::Intrinsics::SubtractSaturateSigned, Ice::Intrinsics::SideEffects_F, Ice::Intrinsics::ReturnsTwice_F, Ice::Intrinsics::MemoryWrite_F};
+ const Ice::Intrinsics::IntrinsicInfo intrinsic = { Ice::Intrinsics::SubtractSaturateSigned, Ice::Intrinsics::SideEffects_F, Ice::Intrinsics::ReturnsTwice_F, Ice::Intrinsics::MemoryWrite_F };
auto target = ::context->getConstantUndef(Ice::IceType_i32);
auto psubsb = Ice::InstIntrinsicCall::create(::function, 2, result, target, intrinsic);
psubsb->addArg(x.value);
@@ -1928,7 +1937,7 @@
else
{
Ice::Variable *result = ::function->makeVariable(Ice::IceType_i32);
- const Ice::Intrinsics::IntrinsicInfo intrinsic = {Ice::Intrinsics::SignMask, Ice::Intrinsics::SideEffects_F, Ice::Intrinsics::ReturnsTwice_F, Ice::Intrinsics::MemoryWrite_F};
+ const Ice::Intrinsics::IntrinsicInfo intrinsic = { Ice::Intrinsics::SignMask, Ice::Intrinsics::SideEffects_F, Ice::Intrinsics::ReturnsTwice_F, Ice::Intrinsics::MemoryWrite_F };
auto target = ::context->getConstantUndef(Ice::IceType_i32);
auto movmsk = Ice::InstIntrinsicCall::create(::function, 1, result, target, intrinsic);
movmsk->addArg(x.value);
@@ -1975,7 +1984,7 @@
Short4::Short4(RValue<Int4> cast)
{
- int select[8] = {0, 2, 4, 6, 0, 2, 4, 6};
+ int select[8] = { 0, 2, 4, 6, 0, 2, 4, 6 };
Value *short8 = Nucleus::createBitCast(cast.value, Short8::getType());
Value *packed = Nucleus::createShuffleVector(short8, short8, select);
@@ -2076,7 +2085,7 @@
else
{
Ice::Variable *result = ::function->makeVariable(Ice::IceType_v8i16);
- const Ice::Intrinsics::IntrinsicInfo intrinsic = {Ice::Intrinsics::AddSaturateSigned, Ice::Intrinsics::SideEffects_F, Ice::Intrinsics::ReturnsTwice_F, Ice::Intrinsics::MemoryWrite_F};
+ const Ice::Intrinsics::IntrinsicInfo intrinsic = { Ice::Intrinsics::AddSaturateSigned, Ice::Intrinsics::SideEffects_F, Ice::Intrinsics::ReturnsTwice_F, Ice::Intrinsics::MemoryWrite_F };
auto target = ::context->getConstantUndef(Ice::IceType_i32);
auto paddsw = Ice::InstIntrinsicCall::create(::function, 2, result, target, intrinsic);
paddsw->addArg(x.value);
@@ -2102,7 +2111,7 @@
else
{
Ice::Variable *result = ::function->makeVariable(Ice::IceType_v8i16);
- const Ice::Intrinsics::IntrinsicInfo intrinsic = {Ice::Intrinsics::SubtractSaturateSigned, Ice::Intrinsics::SideEffects_F, Ice::Intrinsics::ReturnsTwice_F, Ice::Intrinsics::MemoryWrite_F};
+ const Ice::Intrinsics::IntrinsicInfo intrinsic = { Ice::Intrinsics::SubtractSaturateSigned, Ice::Intrinsics::SideEffects_F, Ice::Intrinsics::ReturnsTwice_F, Ice::Intrinsics::MemoryWrite_F };
auto target = ::context->getConstantUndef(Ice::IceType_i32);
auto psubsw = Ice::InstIntrinsicCall::create(::function, 2, result, target, intrinsic);
psubsw->addArg(x.value);
@@ -2128,7 +2137,7 @@
else
{
Ice::Variable *result = ::function->makeVariable(Ice::IceType_v8i16);
- const Ice::Intrinsics::IntrinsicInfo intrinsic = {Ice::Intrinsics::MultiplyHighSigned, Ice::Intrinsics::SideEffects_F, Ice::Intrinsics::ReturnsTwice_F, Ice::Intrinsics::MemoryWrite_F};
+ const Ice::Intrinsics::IntrinsicInfo intrinsic = { Ice::Intrinsics::MultiplyHighSigned, Ice::Intrinsics::SideEffects_F, Ice::Intrinsics::ReturnsTwice_F, Ice::Intrinsics::MemoryWrite_F };
auto target = ::context->getConstantUndef(Ice::IceType_i32);
auto pmulhw = Ice::InstIntrinsicCall::create(::function, 2, result, target, intrinsic);
pmulhw->addArg(x.value);
@@ -2152,7 +2161,7 @@
else
{
Ice::Variable *result = ::function->makeVariable(Ice::IceType_v8i16);
- const Ice::Intrinsics::IntrinsicInfo intrinsic = {Ice::Intrinsics::MultiplyAddPairs, Ice::Intrinsics::SideEffects_F, Ice::Intrinsics::ReturnsTwice_F, Ice::Intrinsics::MemoryWrite_F};
+ const Ice::Intrinsics::IntrinsicInfo intrinsic = { Ice::Intrinsics::MultiplyAddPairs, Ice::Intrinsics::SideEffects_F, Ice::Intrinsics::ReturnsTwice_F, Ice::Intrinsics::MemoryWrite_F };
auto target = ::context->getConstantUndef(Ice::IceType_i32);
auto pmaddwd = Ice::InstIntrinsicCall::create(::function, 2, result, target, intrinsic);
pmaddwd->addArg(x.value);
@@ -2182,7 +2191,7 @@
else
{
Ice::Variable *result = ::function->makeVariable(Ice::IceType_v16i8);
- const Ice::Intrinsics::IntrinsicInfo intrinsic = {Ice::Intrinsics::VectorPackSigned, Ice::Intrinsics::SideEffects_F, Ice::Intrinsics::ReturnsTwice_F, Ice::Intrinsics::MemoryWrite_F};
+ const Ice::Intrinsics::IntrinsicInfo intrinsic = { Ice::Intrinsics::VectorPackSigned, Ice::Intrinsics::SideEffects_F, Ice::Intrinsics::ReturnsTwice_F, Ice::Intrinsics::MemoryWrite_F };
auto target = ::context->getConstantUndef(Ice::IceType_i32);
auto pack = Ice::InstIntrinsicCall::create(::function, 2, result, target, intrinsic);
pack->addArg(x.value);
@@ -2212,7 +2221,7 @@
else
{
Ice::Variable *result = ::function->makeVariable(Ice::IceType_v16i8);
- const Ice::Intrinsics::IntrinsicInfo intrinsic = {Ice::Intrinsics::VectorPackUnsigned, Ice::Intrinsics::SideEffects_F, Ice::Intrinsics::ReturnsTwice_F, Ice::Intrinsics::MemoryWrite_F};
+ const Ice::Intrinsics::IntrinsicInfo intrinsic = { Ice::Intrinsics::VectorPackUnsigned, Ice::Intrinsics::SideEffects_F, Ice::Intrinsics::ReturnsTwice_F, Ice::Intrinsics::MemoryWrite_F };
auto target = ::context->getConstantUndef(Ice::IceType_i32);
auto pack = Ice::InstIntrinsicCall::create(::function, 2, result, target, intrinsic);
pack->addArg(x.value);
@@ -2358,7 +2367,7 @@
else
{
Ice::Variable *result = ::function->makeVariable(Ice::IceType_v8i16);
- const Ice::Intrinsics::IntrinsicInfo intrinsic = {Ice::Intrinsics::AddSaturateUnsigned, Ice::Intrinsics::SideEffects_F, Ice::Intrinsics::ReturnsTwice_F, Ice::Intrinsics::MemoryWrite_F};
+ const Ice::Intrinsics::IntrinsicInfo intrinsic = { Ice::Intrinsics::AddSaturateUnsigned, Ice::Intrinsics::SideEffects_F, Ice::Intrinsics::ReturnsTwice_F, Ice::Intrinsics::MemoryWrite_F };
auto target = ::context->getConstantUndef(Ice::IceType_i32);
auto paddusw = Ice::InstIntrinsicCall::create(::function, 2, result, target, intrinsic);
paddusw->addArg(x.value);
@@ -2384,7 +2393,7 @@
else
{
Ice::Variable *result = ::function->makeVariable(Ice::IceType_v8i16);
- const Ice::Intrinsics::IntrinsicInfo intrinsic = {Ice::Intrinsics::SubtractSaturateUnsigned, Ice::Intrinsics::SideEffects_F, Ice::Intrinsics::ReturnsTwice_F, Ice::Intrinsics::MemoryWrite_F};
+ const Ice::Intrinsics::IntrinsicInfo intrinsic = { Ice::Intrinsics::SubtractSaturateUnsigned, Ice::Intrinsics::SideEffects_F, Ice::Intrinsics::ReturnsTwice_F, Ice::Intrinsics::MemoryWrite_F };
auto target = ::context->getConstantUndef(Ice::IceType_i32);
auto psubusw = Ice::InstIntrinsicCall::create(::function, 2, result, target, intrinsic);
psubusw->addArg(x.value);
@@ -2410,7 +2419,7 @@
else
{
Ice::Variable *result = ::function->makeVariable(Ice::IceType_v8i16);
- const Ice::Intrinsics::IntrinsicInfo intrinsic = {Ice::Intrinsics::MultiplyHighUnsigned, Ice::Intrinsics::SideEffects_F, Ice::Intrinsics::ReturnsTwice_F, Ice::Intrinsics::MemoryWrite_F};
+ const Ice::Intrinsics::IntrinsicInfo intrinsic = { Ice::Intrinsics::MultiplyHighUnsigned, Ice::Intrinsics::SideEffects_F, Ice::Intrinsics::ReturnsTwice_F, Ice::Intrinsics::MemoryWrite_F };
auto target = ::context->getConstantUndef(Ice::IceType_i32);
auto pmulhuw = Ice::InstIntrinsicCall::create(::function, 2, result, target, intrinsic);
pmulhuw->addArg(x.value);
@@ -2626,27 +2635,27 @@
return T(Ice::IceType_v8i16);
}
-RValue<Int> operator++(Int &val, int) // Post-increment
+RValue<Int> operator++(Int &val, int) // Post-increment
{
RValue<Int> res = val;
val += 1;
return res;
}
-const Int &operator++(Int &val) // Pre-increment
+const Int &operator++(Int &val) // Pre-increment
{
val += 1;
return val;
}
-RValue<Int> operator--(Int &val, int) // Post-decrement
+RValue<Int> operator--(Int &val, int) // Post-decrement
{
RValue<Int> res = val;
val -= 1;
return res;
}
-const Int &operator--(Int &val) // Pre-decrement
+const Int &operator--(Int &val) // Pre-decrement
{
val -= 1;
return val;
@@ -2662,7 +2671,7 @@
else
{
Ice::Variable *result = ::function->makeVariable(Ice::IceType_i32);
- const Ice::Intrinsics::IntrinsicInfo intrinsic = {Ice::Intrinsics::Nearbyint, Ice::Intrinsics::SideEffects_F, Ice::Intrinsics::ReturnsTwice_F, Ice::Intrinsics::MemoryWrite_F};
+ const Ice::Intrinsics::IntrinsicInfo intrinsic = { Ice::Intrinsics::Nearbyint, Ice::Intrinsics::SideEffects_F, Ice::Intrinsics::ReturnsTwice_F, Ice::Intrinsics::MemoryWrite_F };
auto target = ::context->getConstantUndef(Ice::IceType_i32);
auto nearbyint = Ice::InstIntrinsicCall::create(::function, 1, result, target, intrinsic);
nearbyint->addArg(cast.value);
@@ -2690,35 +2699,36 @@
// If the value is negative, store 0, otherwise store the result of the conversion
storeValue((~(As<Int>(cast) >> 31) &
- // Check if the value can be represented as an Int
- IfThenElse(cast >= ustartf,
- // If the value is too large, subtract ustart and re-add it after conversion.
- As<Int>(As<UInt>(Int(cast - Float(ustartf))) + UInt(ustart)),
- // Otherwise, just convert normally
- Int(cast))).value);
+ // Check if the value can be represented as an Int
+ IfThenElse(cast >= ustartf,
+ // If the value is too large, subtract ustart and re-add it after conversion.
+ As<Int>(As<UInt>(Int(cast - Float(ustartf))) + UInt(ustart)),
+ // Otherwise, just convert normally
+ Int(cast)))
+ .value);
}
-RValue<UInt> operator++(UInt &val, int) // Post-increment
+RValue<UInt> operator++(UInt &val, int) // Post-increment
{
RValue<UInt> res = val;
val += 1;
return res;
}
-const UInt &operator++(UInt &val) // Pre-increment
+const UInt &operator++(UInt &val) // Pre-increment
{
val += 1;
return val;
}
-RValue<UInt> operator--(UInt &val, int) // Post-decrement
+RValue<UInt> operator--(UInt &val, int) // Post-decrement
{
RValue<UInt> res = val;
val -= 1;
return res;
}
-const UInt &operator--(UInt &val) // Pre-decrement
+const UInt &operator--(UInt &val) // Pre-decrement
{
val -= 1;
return val;
@@ -2822,17 +2832,18 @@
return T(Type_v2i32);
}
-Int4::Int4(RValue<Byte4> cast) : XYZW(this)
+Int4::Int4(RValue<Byte4> cast)
+ : XYZW(this)
{
Value *x = Nucleus::createBitCast(cast.value, Int::getType());
Value *a = Nucleus::createInsertElement(loadValue(), x, 0);
Value *e;
- int swizzle[16] = {0, 16, 1, 17, 2, 18, 3, 19, 4, 20, 5, 21, 6, 22, 7, 23};
+ int swizzle[16] = { 0, 16, 1, 17, 2, 18, 3, 19, 4, 20, 5, 21, 6, 22, 7, 23 };
Value *b = Nucleus::createBitCast(a, Byte16::getType());
Value *c = Nucleus::createShuffleVector(b, V(Nucleus::createNullValue(Byte16::getType())), swizzle);
- int swizzle2[8] = {0, 8, 1, 9, 2, 10, 3, 11};
+ int swizzle2[8] = { 0, 8, 1, 9, 2, 10, 3, 11 };
Value *d = Nucleus::createBitCast(c, Short8::getType());
e = Nucleus::createShuffleVector(d, V(Nucleus::createNullValue(Short8::getType())), swizzle2);
@@ -2840,43 +2851,47 @@
storeValue(f);
}
-Int4::Int4(RValue<SByte4> cast) : XYZW(this)
+Int4::Int4(RValue<SByte4> cast)
+ : XYZW(this)
{
Value *x = Nucleus::createBitCast(cast.value, Int::getType());
Value *a = Nucleus::createInsertElement(loadValue(), x, 0);
- int swizzle[16] = {0, 0, 1, 1, 2, 2, 3, 3, 4, 4, 5, 5, 6, 6, 7, 7};
+ int swizzle[16] = { 0, 0, 1, 1, 2, 2, 3, 3, 4, 4, 5, 5, 6, 6, 7, 7 };
Value *b = Nucleus::createBitCast(a, Byte16::getType());
Value *c = Nucleus::createShuffleVector(b, b, swizzle);
- int swizzle2[8] = {0, 0, 1, 1, 2, 2, 3, 3};
+ int swizzle2[8] = { 0, 0, 1, 1, 2, 2, 3, 3 };
Value *d = Nucleus::createBitCast(c, Short8::getType());
Value *e = Nucleus::createShuffleVector(d, d, swizzle2);
*this = As<Int4>(e) >> 24;
}
-Int4::Int4(RValue<Short4> cast) : XYZW(this)
+Int4::Int4(RValue<Short4> cast)
+ : XYZW(this)
{
- int swizzle[8] = {0, 0, 1, 1, 2, 2, 3, 3};
+ int swizzle[8] = { 0, 0, 1, 1, 2, 2, 3, 3 };
Value *c = Nucleus::createShuffleVector(cast.value, cast.value, swizzle);
*this = As<Int4>(c) >> 16;
}
-Int4::Int4(RValue<UShort4> cast) : XYZW(this)
+Int4::Int4(RValue<UShort4> cast)
+ : XYZW(this)
{
- int swizzle[8] = {0, 8, 1, 9, 2, 10, 3, 11};
+ int swizzle[8] = { 0, 8, 1, 9, 2, 10, 3, 11 };
Value *c = Nucleus::createShuffleVector(cast.value, Short8(0, 0, 0, 0, 0, 0, 0, 0).loadValue(), swizzle);
Value *d = Nucleus::createBitCast(c, Int4::getType());
storeValue(d);
}
-Int4::Int4(RValue<Int> rhs) : XYZW(this)
+Int4::Int4(RValue<Int> rhs)
+ : XYZW(this)
{
Value *vector = Nucleus::createBitCast(rhs.value, Int4::getType());
- int swizzle[4] = {0, 0, 0, 0};
+ int swizzle[4] = { 0, 0, 0, 0 };
Value *replicate = Nucleus::createShuffleVector(vector, vector, swizzle);
storeValue(replicate);
@@ -2984,7 +2999,7 @@
else
{
Ice::Variable *result = ::function->makeVariable(Ice::IceType_v4i32);
- const Ice::Intrinsics::IntrinsicInfo intrinsic = {Ice::Intrinsics::Nearbyint, Ice::Intrinsics::SideEffects_F, Ice::Intrinsics::ReturnsTwice_F, Ice::Intrinsics::MemoryWrite_F};
+ const Ice::Intrinsics::IntrinsicInfo intrinsic = { Ice::Intrinsics::Nearbyint, Ice::Intrinsics::SideEffects_F, Ice::Intrinsics::ReturnsTwice_F, Ice::Intrinsics::MemoryWrite_F };
auto target = ::context->getConstantUndef(Ice::IceType_i32);
auto nearbyint = Ice::InstIntrinsicCall::create(::function, 1, result, target, intrinsic);
nearbyint->addArg(cast.value);
@@ -3013,7 +3028,7 @@
else
{
Ice::Variable *result = ::function->makeVariable(Ice::IceType_v8i16);
- const Ice::Intrinsics::IntrinsicInfo intrinsic = {Ice::Intrinsics::VectorPackSigned, Ice::Intrinsics::SideEffects_F, Ice::Intrinsics::ReturnsTwice_F, Ice::Intrinsics::MemoryWrite_F};
+ const Ice::Intrinsics::IntrinsicInfo intrinsic = { Ice::Intrinsics::VectorPackSigned, Ice::Intrinsics::SideEffects_F, Ice::Intrinsics::ReturnsTwice_F, Ice::Intrinsics::MemoryWrite_F };
auto target = ::context->getConstantUndef(Ice::IceType_i32);
auto pack = Ice::InstIntrinsicCall::create(::function, 2, result, target, intrinsic);
pack->addArg(x.value);
@@ -3039,7 +3054,7 @@
else
{
Ice::Variable *result = ::function->makeVariable(Ice::IceType_v8i16);
- const Ice::Intrinsics::IntrinsicInfo intrinsic = {Ice::Intrinsics::VectorPackUnsigned, Ice::Intrinsics::SideEffects_F, Ice::Intrinsics::ReturnsTwice_F, Ice::Intrinsics::MemoryWrite_F};
+ const Ice::Intrinsics::IntrinsicInfo intrinsic = { Ice::Intrinsics::VectorPackUnsigned, Ice::Intrinsics::SideEffects_F, Ice::Intrinsics::ReturnsTwice_F, Ice::Intrinsics::MemoryWrite_F };
auto target = ::context->getConstantUndef(Ice::IceType_i32);
auto pack = Ice::InstIntrinsicCall::create(::function, 2, result, target, intrinsic);
pack->addArg(x.value);
@@ -3060,7 +3075,7 @@
else
{
Ice::Variable *result = ::function->makeVariable(Ice::IceType_i32);
- const Ice::Intrinsics::IntrinsicInfo intrinsic = {Ice::Intrinsics::SignMask, Ice::Intrinsics::SideEffects_F, Ice::Intrinsics::ReturnsTwice_F, Ice::Intrinsics::MemoryWrite_F};
+ const Ice::Intrinsics::IntrinsicInfo intrinsic = { Ice::Intrinsics::SignMask, Ice::Intrinsics::SideEffects_F, Ice::Intrinsics::ReturnsTwice_F, Ice::Intrinsics::MemoryWrite_F };
auto target = ::context->getConstantUndef(Ice::IceType_i32);
auto movmsk = Ice::InstIntrinsicCall::create(::function, 1, result, target, intrinsic);
movmsk->addArg(x.value);
@@ -3075,7 +3090,8 @@
return T(Ice::IceType_v4i32);
}
-UInt4::UInt4(RValue<Float4> cast) : XYZW(this)
+UInt4::UInt4(RValue<Float4> cast)
+ : XYZW(this)
{
// Smallest positive value representable in UInt, but not in Int
const unsigned int ustart = 0x80000000u;
@@ -3085,17 +3101,18 @@
Int4 uiValue = CmpNLT(cast, Float4(ustartf));
// If the value is too large, subtract ustart and re-add it after conversion.
uiValue = (uiValue & As<Int4>(As<UInt4>(Int4(cast - Float4(ustartf))) + UInt4(ustart))) |
- // Otherwise, just convert normally
+ // Otherwise, just convert normally
(~uiValue & Int4(cast));
// If the value is negative, store 0, otherwise store the result of the conversion
storeValue((~(As<Int4>(cast) >> 31) & uiValue).value);
}
-UInt4::UInt4(RValue<UInt> rhs) : XYZW(this)
+UInt4::UInt4(RValue<UInt> rhs)
+ : XYZW(this)
{
Value *vector = Nucleus::createBitCast(rhs.value, UInt4::getType());
- int swizzle[4] = {0, 0, 0, 0};
+ int swizzle[4] = { 0, 0, 0, 0 };
Value *replicate = Nucleus::createShuffleVector(vector, vector, swizzle);
storeValue(replicate);
@@ -3216,7 +3233,7 @@
RValue<Float> Sqrt(RValue<Float> x)
{
Ice::Variable *result = ::function->makeVariable(Ice::IceType_f32);
- const Ice::Intrinsics::IntrinsicInfo intrinsic = {Ice::Intrinsics::Sqrt, Ice::Intrinsics::SideEffects_F, Ice::Intrinsics::ReturnsTwice_F, Ice::Intrinsics::MemoryWrite_F};
+ const Ice::Intrinsics::IntrinsicInfo intrinsic = { Ice::Intrinsics::Sqrt, Ice::Intrinsics::SideEffects_F, Ice::Intrinsics::ReturnsTwice_F, Ice::Intrinsics::MemoryWrite_F };
auto target = ::context->getConstantUndef(Ice::IceType_i32);
auto sqrt = Ice::InstIntrinsicCall::create(::function, 1, result, target, intrinsic);
sqrt->addArg(x.value);
@@ -3260,11 +3277,12 @@
return T(Type_v2f32);
}
-Float4::Float4(RValue<Float> rhs) : XYZW(this)
+Float4::Float4(RValue<Float> rhs)
+ : XYZW(this)
{
Value *vector = Nucleus::createBitCast(rhs.value, Float4::getType());
- int swizzle[4] = {0, 0, 0, 0};
+ int swizzle[4] = { 0, 0, 0, 0 };
Value *replicate = Nucleus::createShuffleVector(vector, vector, swizzle);
storeValue(replicate);
@@ -3321,7 +3339,7 @@
else
{
Ice::Variable *result = ::function->makeVariable(Ice::IceType_v4f32);
- const Ice::Intrinsics::IntrinsicInfo intrinsic = {Ice::Intrinsics::Sqrt, Ice::Intrinsics::SideEffects_F, Ice::Intrinsics::ReturnsTwice_F, Ice::Intrinsics::MemoryWrite_F};
+ const Ice::Intrinsics::IntrinsicInfo intrinsic = { Ice::Intrinsics::Sqrt, Ice::Intrinsics::SideEffects_F, Ice::Intrinsics::ReturnsTwice_F, Ice::Intrinsics::MemoryWrite_F };
auto target = ::context->getConstantUndef(Ice::IceType_i32);
auto sqrt = Ice::InstIntrinsicCall::create(::function, 1, result, target, intrinsic);
sqrt->addArg(x.value);
@@ -3341,7 +3359,7 @@
else
{
Ice::Variable *result = ::function->makeVariable(Ice::IceType_i32);
- const Ice::Intrinsics::IntrinsicInfo intrinsic = {Ice::Intrinsics::SignMask, Ice::Intrinsics::SideEffects_F, Ice::Intrinsics::ReturnsTwice_F, Ice::Intrinsics::MemoryWrite_F};
+ const Ice::Intrinsics::IntrinsicInfo intrinsic = { Ice::Intrinsics::SignMask, Ice::Intrinsics::SideEffects_F, Ice::Intrinsics::ReturnsTwice_F, Ice::Intrinsics::MemoryWrite_F };
auto target = ::context->getConstantUndef(Ice::IceType_i32);
auto movmsk = Ice::InstIntrinsicCall::create(::function, 1, result, target, intrinsic);
movmsk->addArg(x.value);
@@ -3421,7 +3439,7 @@
else if(CPUID::SSE4_1)
{
Ice::Variable *result = ::function->makeVariable(Ice::IceType_v4f32);
- const Ice::Intrinsics::IntrinsicInfo intrinsic = {Ice::Intrinsics::Round, Ice::Intrinsics::SideEffects_F, Ice::Intrinsics::ReturnsTwice_F, Ice::Intrinsics::MemoryWrite_F};
+ const Ice::Intrinsics::IntrinsicInfo intrinsic = { Ice::Intrinsics::Round, Ice::Intrinsics::SideEffects_F, Ice::Intrinsics::ReturnsTwice_F, Ice::Intrinsics::MemoryWrite_F };
auto target = ::context->getConstantUndef(Ice::IceType_i32);
auto round = Ice::InstIntrinsicCall::create(::function, 2, result, target, intrinsic);
round->addArg(x.value);
@@ -3441,7 +3459,7 @@
if(CPUID::SSE4_1)
{
Ice::Variable *result = ::function->makeVariable(Ice::IceType_v4f32);
- const Ice::Intrinsics::IntrinsicInfo intrinsic = {Ice::Intrinsics::Round, Ice::Intrinsics::SideEffects_F, Ice::Intrinsics::ReturnsTwice_F, Ice::Intrinsics::MemoryWrite_F};
+ const Ice::Intrinsics::IntrinsicInfo intrinsic = { Ice::Intrinsics::Round, Ice::Intrinsics::SideEffects_F, Ice::Intrinsics::ReturnsTwice_F, Ice::Intrinsics::MemoryWrite_F };
auto target = ::context->getConstantUndef(Ice::IceType_i32);
auto round = Ice::InstIntrinsicCall::create(::function, 2, result, target, intrinsic);
round->addArg(x.value);
@@ -3466,9 +3484,9 @@
}
else
{
- frc = x - Float4(Int4(x)); // Signed fractional part.
+ frc = x - Float4(Int4(x)); // Signed fractional part.
- frc += As<Float4>(As<Int4>(CmpNLE(Float4(0.0f), frc)) & As<Int4>(Float4(1, 1, 1, 1))); // Add 1.0 if negative.
+ frc += As<Float4>(As<Int4>(CmpNLE(Float4(0.0f), frc)) & As<Int4>(Float4(1, 1, 1, 1))); // Add 1.0 if negative.
}
// x - floor(x) can be 1.0 for very small negative x.
@@ -3481,7 +3499,7 @@
if(CPUID::SSE4_1)
{
Ice::Variable *result = ::function->makeVariable(Ice::IceType_v4f32);
- const Ice::Intrinsics::IntrinsicInfo intrinsic = {Ice::Intrinsics::Round, Ice::Intrinsics::SideEffects_F, Ice::Intrinsics::ReturnsTwice_F, Ice::Intrinsics::MemoryWrite_F};
+ const Ice::Intrinsics::IntrinsicInfo intrinsic = { Ice::Intrinsics::Round, Ice::Intrinsics::SideEffects_F, Ice::Intrinsics::ReturnsTwice_F, Ice::Intrinsics::MemoryWrite_F };
auto target = ::context->getConstantUndef(Ice::IceType_i32);
auto round = Ice::InstIntrinsicCall::create(::function, 2, result, target, intrinsic);
round->addArg(x.value);
@@ -3501,7 +3519,7 @@
if(CPUID::SSE4_1)
{
Ice::Variable *result = ::function->makeVariable(Ice::IceType_v4f32);
- const Ice::Intrinsics::IntrinsicInfo intrinsic = {Ice::Intrinsics::Round, Ice::Intrinsics::SideEffects_F, Ice::Intrinsics::ReturnsTwice_F, Ice::Intrinsics::MemoryWrite_F};
+ const Ice::Intrinsics::IntrinsicInfo intrinsic = { Ice::Intrinsics::Round, Ice::Intrinsics::SideEffects_F, Ice::Intrinsics::ReturnsTwice_F, Ice::Intrinsics::MemoryWrite_F };
auto target = ::context->getConstantUndef(Ice::IceType_i32);
auto round = Ice::InstIntrinsicCall::create(::function, 2, result, target, intrinsic);
round->addArg(x.value);
@@ -3527,9 +3545,9 @@
return Long(Int(0));
}
-RValue<Pointer<Byte>> ConstantPointer(void const * ptr)
+RValue<Pointer<Byte>> ConstantPointer(void const *ptr)
{
- if(sizeof(void*) == 8)
+ if(sizeof(void *) == 8)
{
return RValue<Pointer<Byte>>(V(::context->getConstantInt64(reinterpret_cast<intptr_t>(ptr))));
}
@@ -3539,14 +3557,14 @@
}
}
-RValue<Pointer<Byte>> ConstantData(void const * data, size_t size)
+RValue<Pointer<Byte>> ConstantData(void const *data, size_t size)
{
// TODO: Try to use Ice::VariableDeclaration::DataInitializer and
// getConstantSym instead of tagging data on the routine.
return ConstantPointer(::routine->addConstantData(data, size));
}
-Value* Call(RValue<Pointer<Byte>> fptr, Type* retTy, std::initializer_list<Value*> args, std::initializer_list<Type*> argTys)
+Value *Call(RValue<Pointer<Byte>> fptr, Type *retTy, std::initializer_list<Value *> args, std::initializer_list<Type *> argTys)
{
Ice::Variable *ret = nullptr;
if(retTy != nullptr)
@@ -3564,15 +3582,25 @@
void Breakpoint()
{
- const Ice::Intrinsics::IntrinsicInfo intrinsic = {Ice::Intrinsics::Trap, Ice::Intrinsics::SideEffects_F, Ice::Intrinsics::ReturnsTwice_F, Ice::Intrinsics::MemoryWrite_F};
+ const Ice::Intrinsics::IntrinsicInfo intrinsic = { Ice::Intrinsics::Trap, Ice::Intrinsics::SideEffects_F, Ice::Intrinsics::ReturnsTwice_F, Ice::Intrinsics::MemoryWrite_F };
auto target = ::context->getConstantUndef(Ice::IceType_i32);
auto trap = Ice::InstIntrinsicCall::create(::function, 0, nullptr, target, intrinsic);
::basicBlock->appendInst(trap);
}
-void Nucleus::createFence(std::memory_order memoryOrder) { UNIMPLEMENTED("Subzero createFence()"); }
-Value *Nucleus::createMaskedLoad(Value *ptr, Type *elTy, Value *mask, unsigned int alignment, bool zeroMaskedLanes) { UNIMPLEMENTED("Subzero createMaskedLoad()"); return nullptr; }
-void Nucleus::createMaskedStore(Value *ptr, Value *val, Value *mask, unsigned int alignment) { UNIMPLEMENTED("Subzero createMaskedStore()"); }
+void Nucleus::createFence(std::memory_order memoryOrder)
+{
+ UNIMPLEMENTED("Subzero createFence()");
+}
+Value *Nucleus::createMaskedLoad(Value *ptr, Type *elTy, Value *mask, unsigned int alignment, bool zeroMaskedLanes)
+{
+ UNIMPLEMENTED("Subzero createMaskedLoad()");
+ return nullptr;
+}
+void Nucleus::createMaskedStore(Value *ptr, Value *val, Value *mask, unsigned int alignment)
+{
+ UNIMPLEMENTED("Subzero createMaskedStore()");
+}
RValue<Float4> Gather(RValue<Pointer<Float>> base, RValue<Int4> offsets, RValue<Int4> mask, unsigned int alignment, bool zeroMaskedLanes /* = false */)
{
@@ -3698,11 +3726,12 @@
{
if(emulateIntrinsics)
{
- UNIMPLEMENTED("Subzero Ctlz()"); return UInt(0);
+ UNIMPLEMENTED("Subzero Ctlz()");
+ return UInt(0);
}
else
{
- Ice::Variable* result = ::function->makeVariable(Ice::IceType_i32);
+ Ice::Variable *result = ::function->makeVariable(Ice::IceType_i32);
const Ice::Intrinsics::IntrinsicInfo intrinsic = { Ice::Intrinsics::Ctlz, Ice::Intrinsics::SideEffects_F, Ice::Intrinsics::ReturnsTwice_F, Ice::Intrinsics::MemoryWrite_F };
auto target = ::context->getConstantUndef(Ice::IceType_i32);
auto ctlz = Ice::InstIntrinsicCall::create(::function, 1, result, target, intrinsic);
@@ -3717,7 +3746,8 @@
{
if(emulateIntrinsics)
{
- UNIMPLEMENTED("Subzero Ctlz()"); return UInt4(0);
+ UNIMPLEMENTED("Subzero Ctlz()");
+ return UInt4(0);
}
else
{
@@ -3735,11 +3765,12 @@
{
if(emulateIntrinsics)
{
- UNIMPLEMENTED("Subzero Cttz()"); return UInt(0);
+ UNIMPLEMENTED("Subzero Cttz()");
+ return UInt(0);
}
else
{
- Ice::Variable* result = ::function->makeVariable(Ice::IceType_i32);
+ Ice::Variable *result = ::function->makeVariable(Ice::IceType_i32);
const Ice::Intrinsics::IntrinsicInfo intrinsic = { Ice::Intrinsics::Cttz, Ice::Intrinsics::SideEffects_F, Ice::Intrinsics::ReturnsTwice_F, Ice::Intrinsics::MemoryWrite_F };
auto target = ::context->getConstantUndef(Ice::IceType_i32);
auto ctlz = Ice::InstIntrinsicCall::create(::function, 1, result, target, intrinsic);
@@ -3754,7 +3785,8 @@
{
if(emulateIntrinsics)
{
- UNIMPLEMENTED("Subzero Cttz()"); return UInt4(0);
+ UNIMPLEMENTED("Subzero Cttz()");
+ return UInt4(0);
}
else
{
@@ -3769,16 +3801,19 @@
}
void EmitDebugLocation() {}
-void EmitDebugVariable(Value* value) {}
+void EmitDebugVariable(Value *value) {}
void FlushDebug() {}
-void Nucleus::createCoroutine(Type *YieldType, std::vector<Type*> &Params)
+void Nucleus::createCoroutine(Type *YieldType, std::vector<Type *> &Params)
{
// Subzero currently only supports coroutines as functions (i.e. that do not yield)
createFunction(YieldType, Params);
}
-static bool coroutineEntryAwaitStub(Nucleus::CoroutineHandle, void* yieldValue) { return false; }
+static bool coroutineEntryAwaitStub(Nucleus::CoroutineHandle, void *yieldValue)
+{
+ return false;
+}
static void coroutineEntryDestroyStub(Nucleus::CoroutineHandle) {}
std::shared_ptr<Routine> Nucleus::acquireCoroutine(const char *name, const Config::Edit &cfgEdit /* = Config::Edit::None */)
@@ -3788,12 +3823,15 @@
// For now, set the await and destroy entries to stubs, until we add proper coroutine support to the Subzero backend
auto routine = std::static_pointer_cast<ELFMemoryStreamer>(coroutineEntry);
- routine->setEntry(Nucleus::CoroutineEntryAwait, reinterpret_cast<const void*>(&coroutineEntryAwaitStub));
- routine->setEntry(Nucleus::CoroutineEntryDestroy, reinterpret_cast<const void*>(&coroutineEntryDestroyStub));
+ routine->setEntry(Nucleus::CoroutineEntryAwait, reinterpret_cast<const void *>(&coroutineEntryAwaitStub));
+ routine->setEntry(Nucleus::CoroutineEntryDestroy, reinterpret_cast<const void *>(&coroutineEntryDestroyStub));
return coroutineEntry;
}
-void Nucleus::yield(Value* val) { UNIMPLEMENTED("Yield"); }
+void Nucleus::yield(Value *val)
+{
+ UNIMPLEMENTED("Yield");
+}
} // namespace rr
diff --git a/src/Reactor/Thread.cpp b/src/Reactor/Thread.cpp
index 46f3550..069c197 100644
--- a/src/Reactor/Thread.cpp
+++ b/src/Reactor/Thread.cpp
@@ -19,74 +19,74 @@
Thread::Thread(void (*threadFunction)(void *parameters), void *parameters)
{
Event init;
- Entry entry = {threadFunction, parameters, &init};
+ Entry entry = { threadFunction, parameters, &init };
- #if defined(_WIN32)
- handle = CreateThread(NULL, 1024 * 1024, startFunction, &entry, 0, NULL);
- #else
- pthread_create(&handle, NULL, startFunction, &entry);
- #endif
+#if defined(_WIN32)
+ handle = CreateThread(NULL, 1024 * 1024, startFunction, &entry, 0, NULL);
+#else
+ pthread_create(&handle, NULL, startFunction, &entry);
+#endif
init.wait();
}
Thread::~Thread()
{
- join(); // Make threads exit before deleting them to not block here
+ join(); // Make threads exit before deleting them to not block here
}
void Thread::join()
{
if(!hasJoined)
{
- #if defined(_WIN32)
- WaitForSingleObject(handle, INFINITE);
- CloseHandle(handle);
- #else
- pthread_join(handle, NULL);
- #endif
+#if defined(_WIN32)
+ WaitForSingleObject(handle, INFINITE);
+ CloseHandle(handle);
+#else
+ pthread_join(handle, NULL);
+#endif
hasJoined = true;
}
}
#if defined(_WIN32)
- unsigned long __stdcall Thread::startFunction(void *parameters)
- {
- Entry entry = *(Entry*)parameters;
- entry.init->signal();
- entry.threadFunction(entry.threadParameters);
- return 0;
- }
+unsigned long __stdcall Thread::startFunction(void *parameters)
+{
+ Entry entry = *(Entry *)parameters;
+ entry.init->signal();
+ entry.threadFunction(entry.threadParameters);
+ return 0;
+}
#else
- void *Thread::startFunction(void *parameters)
- {
- Entry entry = *(Entry*)parameters;
- entry.init->signal();
- entry.threadFunction(entry.threadParameters);
- return nullptr;
- }
+void *Thread::startFunction(void *parameters)
+{
+ Entry entry = *(Entry *)parameters;
+ entry.init->signal();
+ entry.threadFunction(entry.threadParameters);
+ return nullptr;
+}
#endif
Event::Event()
{
- #if defined(_WIN32)
- handle = CreateEvent(NULL, FALSE, FALSE, NULL);
- #else
- pthread_cond_init(&handle, NULL);
- pthread_mutex_init(&mutex, NULL);
- signaled = false;
- #endif
+#if defined(_WIN32)
+ handle = CreateEvent(NULL, FALSE, FALSE, NULL);
+#else
+ pthread_cond_init(&handle, NULL);
+ pthread_mutex_init(&mutex, NULL);
+ signaled = false;
+#endif
}
Event::~Event()
{
- #if defined(_WIN32)
- CloseHandle(handle);
- #else
- pthread_cond_destroy(&handle);
- pthread_mutex_destroy(&mutex);
- #endif
+#if defined(_WIN32)
+ CloseHandle(handle);
+#else
+ pthread_cond_destroy(&handle);
+ pthread_mutex_destroy(&mutex);
+#endif
}
} // namespace rr
diff --git a/src/Reactor/Thread.hpp b/src/Reactor/Thread.hpp
index 7feb61e..a42e624 100644
--- a/src/Reactor/Thread.hpp
+++ b/src/Reactor/Thread.hpp
@@ -16,31 +16,31 @@
#define rr_Thread_hpp
#if defined(_WIN32)
- #ifndef WIN32_LEAN_AND_MEAN
- #define WIN32_LEAN_AND_MEAN
- #endif
- #include <windows.h>
- #include <intrin.h>
+# ifndef WIN32_LEAN_AND_MEAN
+# define WIN32_LEAN_AND_MEAN
+# endif
+# include <windows.h>
+# include <intrin.h>
#else
- #include <pthread.h>
- #include <sched.h>
- #include <unistd.h>
- #define TLS_OUT_OF_INDEXES (pthread_key_t)(~0)
+# include <pthread.h>
+# include <sched.h>
+# include <unistd.h>
+# define TLS_OUT_OF_INDEXES (pthread_key_t)(~0)
#endif
#include <stdlib.h>
#if defined(__clang__)
-#if __has_include(<atomic>) // clang has an explicit check for the availability of atomic
-#define USE_STD_ATOMIC 1
-#endif
+# if __has_include(<atomic>) // clang has an explicit check for the availability of atomic
+# define USE_STD_ATOMIC 1
+# endif
// atomic is available in C++11 or newer, and in Visual Studio 2012 or newer
-#elif (defined(_MSC_VER) && (_MSC_VER >= 1700)) || (__cplusplus >= 201103L)
-#define USE_STD_ATOMIC 1
+#elif(defined(_MSC_VER) && (_MSC_VER >= 1700)) || (__cplusplus >= 201103L)
+# define USE_STD_ATOMIC 1
#endif
#if USE_STD_ATOMIC
-#include <atomic>
+# include <atomic>
#endif
namespace rr {
@@ -59,11 +59,11 @@
static void yield();
static void sleep(int milliseconds);
- #if defined(_WIN32)
- typedef DWORD LocalStorageKey;
- #else
- typedef pthread_key_t LocalStorageKey;
- #endif
+#if defined(_WIN32)
+ typedef DWORD LocalStorageKey;
+#else
+ typedef pthread_key_t LocalStorageKey;
+#endif
static LocalStorageKey allocateLocalStorageKey(void (*destructor)(void *storage) = free);
static void freeLocalStorageKey(LocalStorageKey key);
@@ -79,13 +79,13 @@
Event *init;
};
- #if defined(_WIN32)
- static unsigned long __stdcall startFunction(void *parameters);
- HANDLE handle;
- #else
- static void *startFunction(void *parameters);
- pthread_t handle;
- #endif
+#if defined(_WIN32)
+ static unsigned long __stdcall startFunction(void *parameters);
+ HANDLE handle;
+#else
+ static void *startFunction(void *parameters);
+ pthread_t handle;
+#endif
bool hasJoined = false;
};
@@ -103,13 +103,13 @@
void wait();
private:
- #if defined(_WIN32)
- HANDLE handle;
- #else
- pthread_cond_t handle;
- pthread_mutex_t mutex;
- volatile bool signaled;
- #endif
+#if defined(_WIN32)
+ HANDLE handle;
+#else
+ pthread_cond_t handle;
+ pthread_mutex_t mutex;
+ volatile bool signaled;
+#endif
};
#if PERF_PROFILE
@@ -130,42 +130,42 @@
inline void Thread::yield()
{
- #if defined(_WIN32)
- Sleep(0);
- #elif defined(__APPLE__)
- pthread_yield_np();
- #else
- sched_yield();
- #endif
+#if defined(_WIN32)
+ Sleep(0);
+#elif defined(__APPLE__)
+ pthread_yield_np();
+#else
+ sched_yield();
+#endif
}
inline void Thread::sleep(int milliseconds)
{
- #if defined(_WIN32)
- Sleep(milliseconds);
- #else
- usleep(1000 * milliseconds);
- #endif
+#if defined(_WIN32)
+ Sleep(milliseconds);
+#else
+ usleep(1000 * milliseconds);
+#endif
}
inline Thread::LocalStorageKey Thread::allocateLocalStorageKey(void (*destructor)(void *storage))
{
- #if defined(_WIN32)
- return TlsAlloc();
- #else
- LocalStorageKey key;
- pthread_key_create(&key, destructor);
- return key;
- #endif
+#if defined(_WIN32)
+ return TlsAlloc();
+#else
+ LocalStorageKey key;
+ pthread_key_create(&key, destructor);
+ return key;
+#endif
}
inline void Thread::freeLocalStorageKey(LocalStorageKey key)
{
- #if defined(_WIN32)
- TlsFree(key);
- #else
- pthread_key_delete(key); // Using an invalid key is an error but not undefined behavior.
- #endif
+#if defined(_WIN32)
+ TlsFree(key);
+#else
+ pthread_key_delete(key); // Using an invalid key is an error but not undefined behavior.
+#endif
}
inline void *Thread::allocateLocalStorage(LocalStorageKey key, size_t size)
@@ -179,164 +179,178 @@
void *storage = malloc(size);
- #if defined(_WIN32)
- TlsSetValue(key, storage);
- #else
- pthread_setspecific(key, storage);
- #endif
+#if defined(_WIN32)
+ TlsSetValue(key, storage);
+#else
+ pthread_setspecific(key, storage);
+#endif
return storage;
}
inline void *Thread::getLocalStorage(LocalStorageKey key)
{
- #if defined(_WIN32)
- return TlsGetValue(key);
- #else
- if(key == TLS_OUT_OF_INDEXES) // Avoid undefined behavior.
- {
- return nullptr;
- }
+#if defined(_WIN32)
+ return TlsGetValue(key);
+#else
+ if(key == TLS_OUT_OF_INDEXES) // Avoid undefined behavior.
+ {
+ return nullptr;
+ }
- return pthread_getspecific(key);
- #endif
+ return pthread_getspecific(key);
+#endif
}
inline void Thread::freeLocalStorage(LocalStorageKey key)
{
free(getLocalStorage(key));
- #if defined(_WIN32)
- TlsSetValue(key, nullptr);
- #else
- pthread_setspecific(key, nullptr);
- #endif
+#if defined(_WIN32)
+ TlsSetValue(key, nullptr);
+#else
+ pthread_setspecific(key, nullptr);
+#endif
}
inline void Event::signal()
{
- #if defined(_WIN32)
- SetEvent(handle);
- #else
- pthread_mutex_lock(&mutex);
- signaled = true;
- pthread_cond_signal(&handle);
- pthread_mutex_unlock(&mutex);
- #endif
+#if defined(_WIN32)
+ SetEvent(handle);
+#else
+ pthread_mutex_lock(&mutex);
+ signaled = true;
+ pthread_cond_signal(&handle);
+ pthread_mutex_unlock(&mutex);
+#endif
}
inline void Event::wait()
{
- #if defined(_WIN32)
- WaitForSingleObject(handle, INFINITE);
- #else
- pthread_mutex_lock(&mutex);
- while(!signaled) pthread_cond_wait(&handle, &mutex);
- signaled = false;
- pthread_mutex_unlock(&mutex);
- #endif
+#if defined(_WIN32)
+ WaitForSingleObject(handle, INFINITE);
+#else
+ pthread_mutex_lock(&mutex);
+ while(!signaled) pthread_cond_wait(&handle, &mutex);
+ signaled = false;
+ pthread_mutex_unlock(&mutex);
+#endif
}
#if PERF_PROFILE
inline int64_t atomicExchange(volatile int64_t *target, int64_t value)
{
- #if defined(_WIN32)
- return InterlockedExchange64(target, value);
- #else
- int ret;
- __asm__ __volatile__("lock; xchg8 %x0,(%x1)" : "=r" (ret) :"r" (target), "0" (value) : "memory" );
- return ret;
- #endif
+# if defined(_WIN32)
+ return InterlockedExchange64(target, value);
+# else
+ int ret;
+ __asm__ __volatile__("lock; xchg8 %x0,(%x1)"
+ : "=r"(ret)
+ : "r"(target), "0"(value)
+ : "memory");
+ return ret;
+# endif
}
inline int atomicExchange(volatile int *target, int value)
{
- #if defined(_WIN32)
- return InterlockedExchange((volatile long*)target, (long)value);
- #else
- int ret;
- __asm__ __volatile__("lock; xchgl %x0,(%x1)" : "=r" (ret) :"r" (target), "0" (value) : "memory" );
- return ret;
- #endif
+# if defined(_WIN32)
+ return InterlockedExchange((volatile long *)target, (long)value);
+# else
+ int ret;
+ __asm__ __volatile__("lock; xchgl %x0,(%x1)"
+ : "=r"(ret)
+ : "r"(target), "0"(value)
+ : "memory");
+ return ret;
+# endif
}
#endif
inline int atomicIncrement(volatile int *value)
{
- #if defined(_WIN32)
- return InterlockedIncrement((volatile long*)value);
- #else
- return __sync_add_and_fetch(value, 1);
- #endif
+#if defined(_WIN32)
+ return InterlockedIncrement((volatile long *)value);
+#else
+ return __sync_add_and_fetch(value, 1);
+#endif
}
inline int atomicDecrement(volatile int *value)
{
- #if defined(_WIN32)
- return InterlockedDecrement((volatile long*)value);
- #else
- return __sync_sub_and_fetch(value, 1);
- #endif
+#if defined(_WIN32)
+ return InterlockedDecrement((volatile long *)value);
+#else
+ return __sync_sub_and_fetch(value, 1);
+#endif
}
-inline int atomicAdd(volatile int* target, int value)
+inline int atomicAdd(volatile int *target, int value)
{
- #if defined(_WIN32)
- return InterlockedExchangeAdd((volatile long*)target, value) + value;
- #else
- return __sync_add_and_fetch(target, value);
- #endif
+#if defined(_WIN32)
+ return InterlockedExchangeAdd((volatile long *)target, value) + value;
+#else
+ return __sync_add_and_fetch(target, value);
+#endif
}
inline void nop()
{
- #if defined(_WIN32)
- __nop();
- #else
- __asm__ __volatile__ ("nop");
- #endif
+#if defined(_WIN32)
+ __nop();
+#else
+ __asm__ __volatile__("nop");
+#endif
}
#if USE_STD_ATOMIC
- class AtomicInt
- {
- public:
- AtomicInt() : ai() {}
- AtomicInt(int i) : ai(i) {}
+class AtomicInt
+{
+public:
+ AtomicInt()
+ : ai()
+ {}
+ AtomicInt(int i)
+ : ai(i)
+ {}
- inline operator int() const { return ai.load(std::memory_order_acquire); }
- inline void operator=(const AtomicInt& i) { ai.store(i.ai.load(std::memory_order_acquire), std::memory_order_release); }
- inline void operator=(int i) { ai.store(i, std::memory_order_release); }
- inline void operator--() { ai.fetch_sub(1, std::memory_order_acq_rel); }
- inline void operator++() { ai.fetch_add(1, std::memory_order_acq_rel); }
- inline int operator--(int) { return ai.fetch_sub(1, std::memory_order_acq_rel) - 1; }
- inline int operator++(int) { return ai.fetch_add(1, std::memory_order_acq_rel) + 1; }
- inline void operator-=(int i) { ai.fetch_sub(i, std::memory_order_acq_rel); }
- inline void operator+=(int i) { ai.fetch_add(i, std::memory_order_acq_rel); }
- private:
- std::atomic<int> ai;
- };
+ inline operator int() const { return ai.load(std::memory_order_acquire); }
+ inline void operator=(const AtomicInt &i) { ai.store(i.ai.load(std::memory_order_acquire), std::memory_order_release); }
+ inline void operator=(int i) { ai.store(i, std::memory_order_release); }
+ inline void operator--() { ai.fetch_sub(1, std::memory_order_acq_rel); }
+ inline void operator++() { ai.fetch_add(1, std::memory_order_acq_rel); }
+ inline int operator--(int) { return ai.fetch_sub(1, std::memory_order_acq_rel) - 1; }
+ inline int operator++(int) { return ai.fetch_add(1, std::memory_order_acq_rel) + 1; }
+ inline void operator-=(int i) { ai.fetch_sub(i, std::memory_order_acq_rel); }
+ inline void operator+=(int i) { ai.fetch_add(i, std::memory_order_acq_rel); }
+
+private:
+ std::atomic<int> ai;
+};
#else
- class AtomicInt
- {
- public:
- AtomicInt() {}
- AtomicInt(int i) : vi(i) {}
+class AtomicInt
+{
+public:
+ AtomicInt() {}
+ AtomicInt(int i)
+ : vi(i)
+ {}
- inline operator int() const { return vi; } // Note: this isn't a guaranteed atomic operation
- inline void operator=(const AtomicInt& i) { atomicExchange(&vi, i.vi); }
- inline void operator=(int i) { atomicExchange(&vi, i); }
- inline void operator--() { atomicDecrement(&vi); }
- inline void operator++() { atomicIncrement(&vi); }
- inline int operator--(int) { return atomicDecrement(&vi); }
- inline int operator++(int) { return atomicIncrement(&vi); }
- inline void operator-=(int i) { atomicAdd(&vi, -i); }
- inline void operator+=(int i) { atomicAdd(&vi, i); }
- private:
- volatile int vi;
- };
+ inline operator int() const { return vi; } // Note: this isn't a guaranteed atomic operation
+ inline void operator=(const AtomicInt &i) { atomicExchange(&vi, i.vi); }
+ inline void operator=(int i) { atomicExchange(&vi, i); }
+ inline void operator--() { atomicDecrement(&vi); }
+ inline void operator++() { atomicIncrement(&vi); }
+ inline int operator--(int) { return atomicDecrement(&vi); }
+ inline int operator++(int) { return atomicIncrement(&vi); }
+ inline void operator-=(int i) { atomicAdd(&vi, -i); }
+ inline void operator+=(int i) { atomicAdd(&vi, i); }
+
+private:
+ volatile int vi;
+};
#endif
} // namespace rr
-#endif // rr_Thread_hpp
+#endif // rr_Thread_hpp
diff --git a/src/Reactor/Traits.hpp b/src/Reactor/Traits.hpp
index 53f36f0..fc7dfa7 100644
--- a/src/Reactor/Traits.hpp
+++ b/src/Reactor/Traits.hpp
@@ -19,7 +19,7 @@
#include <type_traits>
#ifdef Bool
-#undef Bool // b/127920555
+# undef Bool // b/127920555
#endif
namespace rr {
@@ -40,9 +40,12 @@
class Float;
class Float4;
-template<class T> class Pointer;
-template<class T> class LValue;
-template<class T> class RValue;
+template<class T>
+class Pointer;
+template<class T>
+class LValue;
+template<class T>
+class RValue;
// enabled_if_t is identical to C++14's std::enable_if_t.
// std::enable_if_t was introduced in C++14, but Reactor must support
@@ -51,19 +54,19 @@
using enable_if_t = typename std::enable_if<Condition, TrueType>::type;
// IsDefined<T>::value is true if T is a valid type, otherwise false.
-template <typename T, typename Enable = void>
+template<typename T, typename Enable = void>
struct IsDefined
{
static constexpr bool value = false;
};
-template <typename T>
-struct IsDefined<T, enable_if_t<(sizeof(T)>0)> >
+template<typename T>
+struct IsDefined<T, enable_if_t<(sizeof(T) > 0)>>
{
static constexpr bool value = true;
};
-template <>
+template<>
struct IsDefined<void>
{
static constexpr bool value = true;
@@ -71,144 +74,273 @@
// CToReactorT<T> resolves to the corresponding Reactor type for the given C
// template type T.
-template<typename T, typename ENABLE = void> struct CToReactor;
-template<typename T> using CToReactorT = typename CToReactor<T>::type;
+template<typename T, typename ENABLE = void>
+struct CToReactor;
+template<typename T>
+using CToReactorT = typename CToReactor<T>::type;
// CToReactor specializations for POD types.
-template<> struct CToReactor<void> { using type = Void; };
-template<> struct CToReactor<bool> { using type = Bool; static Bool cast(bool); };
-template<> struct CToReactor<uint8_t> { using type = Byte; static Byte cast(uint8_t); };
-template<> struct CToReactor<int8_t> { using type = SByte; static SByte cast(int8_t); };
-template<> struct CToReactor<int16_t> { using type = Short; static Short cast(int16_t); };
-template<> struct CToReactor<uint16_t> { using type = UShort; static UShort cast(uint16_t); };
-template<> struct CToReactor<int32_t> { using type = Int; static Int cast(int32_t); };
-template<> struct CToReactor<uint32_t> { using type = UInt; static UInt cast(uint32_t); };
-template<> struct CToReactor<float> { using type = Float; static Float cast(float); };
-template<> struct CToReactor<float[4]> { using type = Float4; static Float4 cast(float[4]); };
+template<>
+struct CToReactor<void>
+{
+ using type = Void;
+};
+template<>
+struct CToReactor<bool>
+{
+ using type = Bool;
+ static Bool cast(bool);
+};
+template<>
+struct CToReactor<uint8_t>
+{
+ using type = Byte;
+ static Byte cast(uint8_t);
+};
+template<>
+struct CToReactor<int8_t>
+{
+ using type = SByte;
+ static SByte cast(int8_t);
+};
+template<>
+struct CToReactor<int16_t>
+{
+ using type = Short;
+ static Short cast(int16_t);
+};
+template<>
+struct CToReactor<uint16_t>
+{
+ using type = UShort;
+ static UShort cast(uint16_t);
+};
+template<>
+struct CToReactor<int32_t>
+{
+ using type = Int;
+ static Int cast(int32_t);
+};
+template<>
+struct CToReactor<uint32_t>
+{
+ using type = UInt;
+ static UInt cast(uint32_t);
+};
+template<>
+struct CToReactor<float>
+{
+ using type = Float;
+ static Float cast(float);
+};
+template<>
+struct CToReactor<float[4]>
+{
+ using type = Float4;
+ static Float4 cast(float[4]);
+};
// TODO: Long has no constructor that takes a uint64_t
-template<> struct CToReactor<uint64_t> { using type = Long; /* static Long cast(uint64_t); */ };
+template<>
+struct CToReactor<uint64_t>
+{
+ using type = Long; /* static Long cast(uint64_t); */
+};
// HasReactorType<T>::value resolves to true iff there exists a
// CToReactorT specialization for type T.
template<typename T>
-using HasReactorType = IsDefined< CToReactorT<T> >;
+using HasReactorType = IsDefined<CToReactorT<T>>;
// CToReactorPtr<T>::type resolves to the corresponding Reactor Pointer<>
// type for T*.
// For T types that have a CToReactorT<> specialization,
// CToReactorPtr<T>::type resolves to Pointer< CToReactorT<T> >, otherwise
// CToReactorPtr<T>::type resolves to Pointer<Byte>.
-template<typename T, typename ENABLE = void> struct CToReactorPtr
+template<typename T, typename ENABLE = void>
+struct CToReactorPtr
{
using type = Pointer<Byte>;
- static inline type cast(const T* v); // implemented in Traits.inl
+ static inline type cast(const T *v); // implemented in Traits.inl
};
// CToReactorPtr specialization for T types that have a CToReactorT<>
// specialization.
-template<typename T> struct CToReactorPtr<T, enable_if_t< HasReactorType<T>::value > >
+template<typename T>
+struct CToReactorPtr<T, enable_if_t<HasReactorType<T>::value>>
{
- using type = Pointer< CToReactorT<T> >;
- static inline type cast(const T* v); // implemented in Traits.inl
+ using type = Pointer<CToReactorT<T>>;
+ static inline type cast(const T *v); // implemented in Traits.inl
};
// CToReactorPtr specialization for void*.
// Maps to Pointer<Byte> instead of Pointer<Void>.
-template<> struct CToReactorPtr<void, void>
+template<>
+struct CToReactorPtr<void, void>
{
using type = Pointer<Byte>;
- static inline type cast(const void* v); // implemented in Traits.inl
+ static inline type cast(const void *v); // implemented in Traits.inl
};
// CToReactorPtr specialization for function pointer types.
// Maps to Pointer<Byte>.
// Drops the 'const' qualifier from the cast() method to avoid warnings
// about const having no meaning for function types.
-template<typename T> struct CToReactorPtr<T, enable_if_t< std::is_function<T>::value > >
+template<typename T>
+struct CToReactorPtr<T, enable_if_t<std::is_function<T>::value>>
{
using type = Pointer<Byte>;
- static inline type cast(T* v); // implemented in Traits.inl
+ static inline type cast(T *v); // implemented in Traits.inl
};
-template<typename T> using CToReactorPtrT = typename CToReactorPtr<T>::type;
+template<typename T>
+using CToReactorPtrT = typename CToReactorPtr<T>::type;
// CToReactor specialization for pointer types.
// For T types that have a CToReactorT<> specialization,
// CToReactorT<T*>::type resolves to Pointer< CToReactorT<T> >, otherwise
// CToReactorT<T*>::type resolves to Pointer<Byte>.
template<typename T>
-struct CToReactor<T, enable_if_t<std::is_pointer<T>::value> >
+struct CToReactor<T, enable_if_t<std::is_pointer<T>::value>>
{
using elem = typename std::remove_pointer<T>::type;
using type = CToReactorPtrT<elem>;
- static inline type cast(T v); // implemented in Traits.inl
+ static inline type cast(T v); // implemented in Traits.inl
};
// CToReactor specialization for enum types.
template<typename T>
-struct CToReactor<T, enable_if_t<std::is_enum<T>::value> >
+struct CToReactor<T, enable_if_t<std::is_enum<T>::value>>
{
using underlying = typename std::underlying_type<T>::type;
using type = CToReactorT<underlying>;
- static type cast(T v); // implemented in Traits.inl
+ static type cast(T v); // implemented in Traits.inl
};
// IsRValue::value is true if T is of type RValue<X>, where X is any type.
-template <typename T, typename Enable = void> struct IsRValue { static constexpr bool value = false; };
-template <typename T> struct IsRValue<T, enable_if_t<IsDefined<typename T::rvalue_underlying_type>::value> > { static constexpr bool value = true; };
+template<typename T, typename Enable = void>
+struct IsRValue
+{
+ static constexpr bool value = false;
+};
+template<typename T>
+struct IsRValue<T, enable_if_t<IsDefined<typename T::rvalue_underlying_type>::value>>
+{
+ static constexpr bool value = true;
+};
// IsLValue::value is true if T is of, or derives from type LValue<T>.
-template <typename T> struct IsLValue { static constexpr bool value = std::is_base_of<LValue<T>, T>::value; };
+template<typename T>
+struct IsLValue
+{
+ static constexpr bool value = std::is_base_of<LValue<T>, T>::value;
+};
// IsReference::value is true if T is of type Reference<X>, where X is any type.
-template <typename T, typename Enable = void> struct IsReference { static constexpr bool value = false; };
-template <typename T> struct IsReference<T, enable_if_t<IsDefined<typename T::reference_underlying_type>::value> > { static constexpr bool value = true; };
+template<typename T, typename Enable = void>
+struct IsReference
+{
+ static constexpr bool value = false;
+};
+template<typename T>
+struct IsReference<T, enable_if_t<IsDefined<typename T::reference_underlying_type>::value>>
+{
+ static constexpr bool value = true;
+};
// ReactorTypeT<T> returns the LValue Reactor type for T.
// T can be a C-type, RValue or LValue.
-template<typename T, typename ENABLE = void> struct ReactorType;
-template<typename T> using ReactorTypeT = typename ReactorType<T>::type;
-template<typename T> struct ReactorType<T, enable_if_t<IsDefined<CToReactorT<T>>::value> >
+template<typename T, typename ENABLE = void>
+struct ReactorType;
+template<typename T>
+using ReactorTypeT = typename ReactorType<T>::type;
+template<typename T>
+struct ReactorType<T, enable_if_t<IsDefined<CToReactorT<T>>::value>>
{
using type = CToReactorT<T>;
static type cast(T v) { return CToReactor<T>::cast(v); }
};
-template<typename T> struct ReactorType<T, enable_if_t<IsRValue<T>::value> >
+template<typename T>
+struct ReactorType<T, enable_if_t<IsRValue<T>::value>>
{
using type = typename T::rvalue_underlying_type;
static type cast(T v) { return type(v); }
};
-template<typename T> struct ReactorType<T, enable_if_t<IsLValue<T>::value> >
+template<typename T>
+struct ReactorType<T, enable_if_t<IsLValue<T>::value>>
{
using type = T;
static type cast(T v) { return type(v); }
};
-template<typename T> struct ReactorType<T, enable_if_t<IsReference<T>::value> >
+template<typename T>
+struct ReactorType<T, enable_if_t<IsReference<T>::value>>
{
using type = T;
static type cast(T v) { return type(v); }
};
-
// Reactor types that can be used as a return type for a function.
-template <typename T> struct CanBeUsedAsReturn { static constexpr bool value = false; };
-template <> struct CanBeUsedAsReturn<Void> { static constexpr bool value = true; };
-template <> struct CanBeUsedAsReturn<Int> { static constexpr bool value = true; };
-template <> struct CanBeUsedAsReturn<UInt> { static constexpr bool value = true; };
-template <> struct CanBeUsedAsReturn<Float> { static constexpr bool value = true; };
-template <typename T> struct CanBeUsedAsReturn<Pointer<T>> { static constexpr bool value = true; };
+template<typename T>
+struct CanBeUsedAsReturn
+{
+ static constexpr bool value = false;
+};
+template<>
+struct CanBeUsedAsReturn<Void>
+{
+ static constexpr bool value = true;
+};
+template<>
+struct CanBeUsedAsReturn<Int>
+{
+ static constexpr bool value = true;
+};
+template<>
+struct CanBeUsedAsReturn<UInt>
+{
+ static constexpr bool value = true;
+};
+template<>
+struct CanBeUsedAsReturn<Float>
+{
+ static constexpr bool value = true;
+};
+template<typename T>
+struct CanBeUsedAsReturn<Pointer<T>>
+{
+ static constexpr bool value = true;
+};
// Reactor types that can be used as a parameter types for a function.
-template <typename T> struct CanBeUsedAsParameter { static constexpr bool value = false; };
-template <> struct CanBeUsedAsParameter<Int> { static constexpr bool value = true; };
-template <> struct CanBeUsedAsParameter<UInt> { static constexpr bool value = true; };
-template <> struct CanBeUsedAsParameter<Float> { static constexpr bool value = true; };
-template <typename T> struct CanBeUsedAsParameter<Pointer<T>> { static constexpr bool value = true; };
+template<typename T>
+struct CanBeUsedAsParameter
+{
+ static constexpr bool value = false;
+};
+template<>
+struct CanBeUsedAsParameter<Int>
+{
+ static constexpr bool value = true;
+};
+template<>
+struct CanBeUsedAsParameter<UInt>
+{
+ static constexpr bool value = true;
+};
+template<>
+struct CanBeUsedAsParameter<Float>
+{
+ static constexpr bool value = true;
+};
+template<typename T>
+struct CanBeUsedAsParameter<Pointer<T>>
+{
+ static constexpr bool value = true;
+};
// AssertParameterTypeIsValid statically asserts that all template parameter
// types can be used as a Reactor function parameter.
-template<typename T, typename ... other>
+template<typename T, typename... other>
struct AssertParameterTypeIsValid : AssertParameterTypeIsValid<other...>
{
static_assert(CanBeUsedAsParameter<T>::value, "Invalid parameter type");
@@ -224,7 +356,8 @@
template<typename Return, typename... Arguments>
class AssertFunctionSignatureIsValid;
template<typename Return>
-class AssertFunctionSignatureIsValid<Return(Void)> {};
+class AssertFunctionSignatureIsValid<Return(Void)>
+{};
template<typename Return, typename... Arguments>
class AssertFunctionSignatureIsValid<Return(Arguments...)>
{
@@ -234,4 +367,4 @@
} // namespace rr
-#endif // rr_Traits_hpp
+#endif // rr_Traits_hpp
diff --git a/src/Reactor/Traits.inl b/src/Reactor/Traits.inl
index 23a5941..d13ddc2 100644
--- a/src/Reactor/Traits.inl
+++ b/src/Reactor/Traits.inl
@@ -20,7 +20,7 @@
// Non-specialized implementation of CToReactorPtr::cast() defaults to
// returning a ConstantPointer for v.
template<typename T, typename ENABLE>
-Pointer<Byte> CToReactorPtr<T, ENABLE>::cast(const T* v)
+Pointer<Byte> CToReactorPtr<T, ENABLE>::cast(const T *v)
{
return ConstantPointer(v);
}
@@ -29,13 +29,13 @@
// specialization.
template<typename T>
Pointer<CToReactorT<T>>
-CToReactorPtr<T, enable_if_t< HasReactorType<T>::value > >::cast(const T* v)
+CToReactorPtr<T, enable_if_t<HasReactorType<T>::value>>::cast(const T *v)
{
return type(v);
}
// CToReactorPtr specialization for void*.
-Pointer<Byte> CToReactorPtr<void, void>::cast(const void* v)
+Pointer<Byte> CToReactorPtr<void, void>::cast(const void *v)
{
return ConstantPointer(v);
}
@@ -43,7 +43,7 @@
// CToReactorPtrT specialization for function pointer types.
template<typename T>
Pointer<Byte>
-CToReactorPtr<T, enable_if_t< std::is_function<T>::value > >::cast(T* v)
+CToReactorPtr<T, enable_if_t<std::is_function<T>::value>>::cast(T *v)
{
return ConstantPointer(v);
}
@@ -51,7 +51,7 @@
// CToReactor specialization for pointer types.
template<typename T>
CToReactorPtrT<typename std::remove_pointer<T>::type>
-CToReactor<T, enable_if_t<std::is_pointer<T>::value> >::cast(T v)
+CToReactor<T, enable_if_t<std::is_pointer<T>::value>>::cast(T v)
{
return CToReactorPtr<elem>::cast(v);
}
@@ -59,11 +59,11 @@
// CToReactor specialization for enum types.
template<typename T>
CToReactorT<typename std::underlying_type<T>::type>
-CToReactor<T, enable_if_t<std::is_enum<T>::value> >::cast(T v)
+CToReactor<T, enable_if_t<std::is_enum<T>::value>>::cast(T v)
{
return CToReactor<underlying>::cast(v);
}
} // namespace rr
-#endif // rr_Traits_inl
+#endif // rr_Traits_inl
diff --git a/src/Reactor/x86.hpp b/src/Reactor/x86.hpp
index dd98173..474ec40 100644
--- a/src/Reactor/x86.hpp
+++ b/src/Reactor/x86.hpp
@@ -106,4 +106,4 @@
} // namespace x86
} // namespace rr
-#endif // rr_x86_hpp
\ No newline at end of file
+#endif // rr_x86_hpp
\ No newline at end of file