mirror of
https://github.com/capstone-engine/llvm-capstone.git
synced 2025-04-01 12:43:47 +00:00
libclc: Initial vload implementation
Should work for all targets and data types. Completely unoptimized. Patch by: Aaron Watry llvm-svn: 185006
This commit is contained in:
parent
c0af47de00
commit
66ecbc7c18
@ -71,6 +71,7 @@
|
||||
#include <clc/shared/clamp.h>
|
||||
#include <clc/shared/max.h>
|
||||
#include <clc/shared/min.h>
|
||||
#include <clc/shared/vload.h>
|
||||
|
||||
/* 6.11.5 Geometric Functions */
|
||||
#include <clc/geometric/cross.h>
|
||||
|
37
libclc/generic/include/clc/shared/vload.h
Normal file
37
libclc/generic/include/clc/shared/vload.h
Normal file
@ -0,0 +1,37 @@
|
||||
#define _CLC_VLOAD_DECL(PRIM_TYPE, VEC_TYPE, WIDTH, ADDR_SPACE) \
|
||||
_CLC_OVERLOAD _CLC_DECL VEC_TYPE vload##WIDTH(size_t offset, const ADDR_SPACE PRIM_TYPE *x);
|
||||
|
||||
#define _CLC_VECTOR_VLOAD_DECL(PRIM_TYPE, ADDR_SPACE) \
|
||||
_CLC_VLOAD_DECL(PRIM_TYPE, PRIM_TYPE##2, 2, ADDR_SPACE) \
|
||||
_CLC_VLOAD_DECL(PRIM_TYPE, PRIM_TYPE##3, 3, ADDR_SPACE) \
|
||||
_CLC_VLOAD_DECL(PRIM_TYPE, PRIM_TYPE##4, 4, ADDR_SPACE) \
|
||||
_CLC_VLOAD_DECL(PRIM_TYPE, PRIM_TYPE##8, 8, ADDR_SPACE) \
|
||||
_CLC_VLOAD_DECL(PRIM_TYPE, PRIM_TYPE##16, 16, ADDR_SPACE)
|
||||
|
||||
#define _CLC_VECTOR_VLOAD_PRIM1(PRIM_TYPE) \
|
||||
_CLC_VECTOR_VLOAD_DECL(PRIM_TYPE, __private) \
|
||||
_CLC_VECTOR_VLOAD_DECL(PRIM_TYPE, __local) \
|
||||
_CLC_VECTOR_VLOAD_DECL(PRIM_TYPE, __constant) \
|
||||
_CLC_VECTOR_VLOAD_DECL(PRIM_TYPE, __global) \
|
||||
|
||||
#define _CLC_VECTOR_VLOAD_PRIM() \
|
||||
_CLC_VECTOR_VLOAD_PRIM1(char) \
|
||||
_CLC_VECTOR_VLOAD_PRIM1(uchar) \
|
||||
_CLC_VECTOR_VLOAD_PRIM1(short) \
|
||||
_CLC_VECTOR_VLOAD_PRIM1(ushort) \
|
||||
_CLC_VECTOR_VLOAD_PRIM1(int) \
|
||||
_CLC_VECTOR_VLOAD_PRIM1(uint) \
|
||||
_CLC_VECTOR_VLOAD_PRIM1(long) \
|
||||
_CLC_VECTOR_VLOAD_PRIM1(ulong) \
|
||||
_CLC_VECTOR_VLOAD_PRIM1(float) \
|
||||
|
||||
#ifdef cl_khr_fp64
|
||||
#define _CLC_VECTOR_VLOAD() \
|
||||
_CLC_VECTOR_VLOAD_PRIM1(double) \
|
||||
_CLC_VECTOR_VLOAD_PRIM()
|
||||
#else
|
||||
#define _CLC_VECTOR_VLOAD() \
|
||||
_CLC_VECTOR_VLOAD_PRIM()
|
||||
#endif
|
||||
|
||||
_CLC_VECTOR_VLOAD()
|
@ -23,5 +23,6 @@ relational/any.cl
|
||||
shared/clamp.cl
|
||||
shared/max.cl
|
||||
shared/min.cl
|
||||
shared/vload.cl
|
||||
workitem/get_global_id.cl
|
||||
workitem/get_global_size.cl
|
||||
|
47
libclc/generic/lib/shared/vload.cl
Normal file
47
libclc/generic/lib/shared/vload.cl
Normal file
@ -0,0 +1,47 @@
|
||||
#include <clc/clc.h>
|
||||
|
||||
#define VLOAD_VECTORIZE(PRIM_TYPE, ADDR_SPACE) \
|
||||
_CLC_OVERLOAD _CLC_DEF PRIM_TYPE##2 vload2(size_t offset, const ADDR_SPACE PRIM_TYPE *x) { \
|
||||
return (PRIM_TYPE##2)(x[offset] , x[offset+1]); \
|
||||
} \
|
||||
\
|
||||
_CLC_OVERLOAD _CLC_DEF PRIM_TYPE##3 vload3(size_t offset, const ADDR_SPACE PRIM_TYPE *x) { \
|
||||
return (PRIM_TYPE##3)(x[offset] , x[offset+1], x[offset+2]); \
|
||||
} \
|
||||
\
|
||||
_CLC_OVERLOAD _CLC_DEF PRIM_TYPE##4 vload4(size_t offset, const ADDR_SPACE PRIM_TYPE *x) { \
|
||||
return (PRIM_TYPE##4)(x[offset], x[offset+1], x[offset+2], x[offset+3]); \
|
||||
} \
|
||||
\
|
||||
_CLC_OVERLOAD _CLC_DEF PRIM_TYPE##8 vload8(size_t offset, const ADDR_SPACE PRIM_TYPE *x) { \
|
||||
return (PRIM_TYPE##8)(vload4(offset, x), vload4(offset+4, x)); \
|
||||
} \
|
||||
\
|
||||
_CLC_OVERLOAD _CLC_DEF PRIM_TYPE##16 vload16(size_t offset, const ADDR_SPACE PRIM_TYPE *x) { \
|
||||
return (PRIM_TYPE##16)(vload8(offset, x), vload8(offset+8, x)); \
|
||||
} \
|
||||
|
||||
#define VLOAD_ADDR_SPACES(SCALAR_GENTYPE) \
|
||||
VLOAD_VECTORIZE(SCALAR_GENTYPE, __private) \
|
||||
VLOAD_VECTORIZE(SCALAR_GENTYPE, __local) \
|
||||
VLOAD_VECTORIZE(SCALAR_GENTYPE, __constant) \
|
||||
VLOAD_VECTORIZE(SCALAR_GENTYPE, __global) \
|
||||
|
||||
#define VLOAD_TYPES() \
|
||||
VLOAD_ADDR_SPACES(char) \
|
||||
VLOAD_ADDR_SPACES(uchar) \
|
||||
VLOAD_ADDR_SPACES(short) \
|
||||
VLOAD_ADDR_SPACES(ushort) \
|
||||
VLOAD_ADDR_SPACES(int) \
|
||||
VLOAD_ADDR_SPACES(uint) \
|
||||
VLOAD_ADDR_SPACES(long) \
|
||||
VLOAD_ADDR_SPACES(ulong) \
|
||||
VLOAD_ADDR_SPACES(float) \
|
||||
|
||||
VLOAD_TYPES()
|
||||
|
||||
#ifdef cl_khr_fp64
|
||||
#pragma OPENCL EXTENSION cl_khr_fp64 : enable
|
||||
VLOAD_ADDR_SPACES(double)
|
||||
#endif
|
||||
|
Loading…
x
Reference in New Issue
Block a user