Jason Sams | 709a097 | 2012-11-15 18:18:04 -0800 | [diff] [blame] | 1 | /* |
| 2 | * Copyright (C) 2011-2012 The Android Open Source Project |
| 3 | * |
| 4 | * Licensed under the Apache License, Version 2.0 (the "License"); |
| 5 | * you may not use this file except in compliance with the License. |
| 6 | * You may obtain a copy of the License at |
| 7 | * |
| 8 | * http://www.apache.org/licenses/LICENSE-2.0 |
| 9 | * |
| 10 | * Unless required by applicable law or agreed to in writing, software |
| 11 | * distributed under the License is distributed on an "AS IS" BASIS, |
| 12 | * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. |
| 13 | * See the License for the specific language governing permissions and |
| 14 | * limitations under the License. |
| 15 | */ |
| 16 | |
| 17 | #include "rsContext.h" |
| 18 | #include "rsScriptC.h" |
| 19 | #include "rsMatrix4x4.h" |
| 20 | #include "rsMatrix3x3.h" |
| 21 | #include "rsMatrix2x2.h" |
| 22 | #include "rsRuntime.h" |
| 23 | |
Jason Sams | 709a097 | 2012-11-15 18:18:04 -0800 | [diff] [blame] | 24 | #include "rsCpuCore.h" |
| 25 | #include "rsCpuScript.h" |
| 26 | |
| 27 | #include <time.h> |
| 28 | |
| 29 | using namespace android; |
| 30 | using namespace android::renderscript; |
| 31 | |
| 32 | typedef float float2 __attribute__((ext_vector_type(2))); |
| 33 | typedef float float3 __attribute__((ext_vector_type(3))); |
| 34 | typedef float float4 __attribute__((ext_vector_type(4))); |
Tim Murray | 60fe47d | 2014-05-27 13:29:32 -0700 | [diff] [blame] | 35 | typedef double double2 __attribute__((ext_vector_type(2))); |
| 36 | typedef double double3 __attribute__((ext_vector_type(3))); |
| 37 | typedef double double4 __attribute__((ext_vector_type(4))); |
Jason Sams | 709a097 | 2012-11-15 18:18:04 -0800 | [diff] [blame] | 38 | typedef char char2 __attribute__((ext_vector_type(2))); |
| 39 | typedef char char3 __attribute__((ext_vector_type(3))); |
| 40 | typedef char char4 __attribute__((ext_vector_type(4))); |
| 41 | typedef unsigned char uchar2 __attribute__((ext_vector_type(2))); |
| 42 | typedef unsigned char uchar3 __attribute__((ext_vector_type(3))); |
| 43 | typedef unsigned char uchar4 __attribute__((ext_vector_type(4))); |
| 44 | typedef short short2 __attribute__((ext_vector_type(2))); |
| 45 | typedef short short3 __attribute__((ext_vector_type(3))); |
| 46 | typedef short short4 __attribute__((ext_vector_type(4))); |
| 47 | typedef unsigned short ushort2 __attribute__((ext_vector_type(2))); |
| 48 | typedef unsigned short ushort3 __attribute__((ext_vector_type(3))); |
| 49 | typedef unsigned short ushort4 __attribute__((ext_vector_type(4))); |
| 50 | typedef int32_t int2 __attribute__((ext_vector_type(2))); |
| 51 | typedef int32_t int3 __attribute__((ext_vector_type(3))); |
| 52 | typedef int32_t int4 __attribute__((ext_vector_type(4))); |
| 53 | typedef uint32_t uint2 __attribute__((ext_vector_type(2))); |
| 54 | typedef uint32_t uint3 __attribute__((ext_vector_type(3))); |
| 55 | typedef uint32_t uint4 __attribute__((ext_vector_type(4))); |
| 56 | typedef long long long2 __attribute__((ext_vector_type(2))); |
| 57 | typedef long long long3 __attribute__((ext_vector_type(3))); |
| 58 | typedef long long long4 __attribute__((ext_vector_type(4))); |
| 59 | typedef unsigned long long ulong2 __attribute__((ext_vector_type(2))); |
| 60 | typedef unsigned long long ulong3 __attribute__((ext_vector_type(3))); |
| 61 | typedef unsigned long long ulong4 __attribute__((ext_vector_type(4))); |
| 62 | |
| 63 | |
| 64 | ////////////////////////////////////////////////////////////////////////////// |
| 65 | // Message routines |
| 66 | ////////////////////////////////////////////////////////////////////////////// |
| 67 | |
| 68 | |
Jason Sams | 709a097 | 2012-11-15 18:18:04 -0800 | [diff] [blame] | 69 | static void SC_debugF(const char *s, float f) { |
Jason Sams | 941a617 | 2013-04-03 11:28:45 -0700 | [diff] [blame] | 70 | ALOGD("float %s %f, 0x%08x", s, f, *((int *) (&f))); |
Jason Sams | 709a097 | 2012-11-15 18:18:04 -0800 | [diff] [blame] | 71 | } |
| 72 | static void SC_debugFv2(const char *s, float f1, float f2) { |
Jason Sams | 941a617 | 2013-04-03 11:28:45 -0700 | [diff] [blame] | 73 | ALOGD("float x2 %s {%f, %f}", s, f1, f2); |
Jason Sams | 709a097 | 2012-11-15 18:18:04 -0800 | [diff] [blame] | 74 | } |
| 75 | static void SC_debugFv3(const char *s, float f1, float f2, float f3) { |
Jason Sams | 941a617 | 2013-04-03 11:28:45 -0700 | [diff] [blame] | 76 | ALOGD("float x3 %s {%f, %f, %f}", s, f1, f2, f3); |
Jason Sams | 709a097 | 2012-11-15 18:18:04 -0800 | [diff] [blame] | 77 | } |
| 78 | static void SC_debugFv4(const char *s, float f1, float f2, float f3, float f4) { |
Jason Sams | 941a617 | 2013-04-03 11:28:45 -0700 | [diff] [blame] | 79 | ALOGD("float x4 %s {%f, %f, %f, %f}", s, f1, f2, f3, f4); |
Jason Sams | 709a097 | 2012-11-15 18:18:04 -0800 | [diff] [blame] | 80 | } |
Jason Sams | 941a617 | 2013-04-03 11:28:45 -0700 | [diff] [blame] | 81 | static void SC_debugF2(const char *s, const float2 *f) { |
| 82 | ALOGD("float2 %s {%f, %f}", s, f->x, f->y); |
Jason Sams | 709a097 | 2012-11-15 18:18:04 -0800 | [diff] [blame] | 83 | } |
Jason Sams | 941a617 | 2013-04-03 11:28:45 -0700 | [diff] [blame] | 84 | static void SC_debugF3(const char *s, const float3 *f) { |
| 85 | ALOGD("float3 %s {%f, %f, %f}", s, f->x, f->y, f->z); |
Jason Sams | 709a097 | 2012-11-15 18:18:04 -0800 | [diff] [blame] | 86 | } |
Jason Sams | 941a617 | 2013-04-03 11:28:45 -0700 | [diff] [blame] | 87 | static void SC_debugF4(const char *s, const float4 *f) { |
| 88 | ALOGD("float4 %s {%f, %f, %f, %f}", s, f->x, f->y, f->z, f->w); |
Jason Sams | 709a097 | 2012-11-15 18:18:04 -0800 | [diff] [blame] | 89 | } |
| 90 | static void SC_debugD(const char *s, double d) { |
Jason Sams | 941a617 | 2013-04-03 11:28:45 -0700 | [diff] [blame] | 91 | ALOGD("double %s %f, 0x%08llx", s, d, *((long long *) (&d))); |
Jason Sams | 709a097 | 2012-11-15 18:18:04 -0800 | [diff] [blame] | 92 | } |
Tim Murray | 60fe47d | 2014-05-27 13:29:32 -0700 | [diff] [blame] | 93 | static void SC_debugD2(const char *s, const double2 *f) { |
| 94 | ALOGD("double2 %s {%f, %f}", s, f->x, f->y); |
| 95 | } |
| 96 | static void SC_debugD3(const char *s, const double3 *f) { |
| 97 | ALOGD("double3 %s {%f, %f, %f}", s, f->x, f->y, f->z); |
| 98 | } |
| 99 | static void SC_debugD4(const char *s, const double4 *f) { |
| 100 | ALOGD("double4 %s {%f, %f, %f, %f}", s, f->x, f->y, f->z, f->w); |
| 101 | } |
| 102 | |
Jason Sams | 709a097 | 2012-11-15 18:18:04 -0800 | [diff] [blame] | 103 | static void SC_debugFM4v4(const char *s, const float *f) { |
Jason Sams | 941a617 | 2013-04-03 11:28:45 -0700 | [diff] [blame] | 104 | ALOGD("matrix4x4 %s {%f, %f, %f, %f", s, f[0], f[4], f[8], f[12]); |
| 105 | ALOGD(" %s %f, %f, %f, %f", s, f[1], f[5], f[9], f[13]); |
| 106 | ALOGD(" %s %f, %f, %f, %f", s, f[2], f[6], f[10], f[14]); |
| 107 | ALOGD(" %s %f, %f, %f, %f}", s, f[3], f[7], f[11], f[15]); |
Jason Sams | 709a097 | 2012-11-15 18:18:04 -0800 | [diff] [blame] | 108 | } |
| 109 | static void SC_debugFM3v3(const char *s, const float *f) { |
Jason Sams | 941a617 | 2013-04-03 11:28:45 -0700 | [diff] [blame] | 110 | ALOGD("matrix3x3 %s {%f, %f, %f", s, f[0], f[3], f[6]); |
| 111 | ALOGD(" %s %f, %f, %f", s, f[1], f[4], f[7]); |
| 112 | ALOGD(" %s %f, %f, %f}",s, f[2], f[5], f[8]); |
Jason Sams | 709a097 | 2012-11-15 18:18:04 -0800 | [diff] [blame] | 113 | } |
| 114 | static void SC_debugFM2v2(const char *s, const float *f) { |
Jason Sams | 941a617 | 2013-04-03 11:28:45 -0700 | [diff] [blame] | 115 | ALOGD("matrix2x2 %s {%f, %f", s, f[0], f[2]); |
| 116 | ALOGD(" %s %f, %f}",s, f[1], f[3]); |
Jason Sams | 709a097 | 2012-11-15 18:18:04 -0800 | [diff] [blame] | 117 | } |
| 118 | static void SC_debugI8(const char *s, char c) { |
Jason Sams | 941a617 | 2013-04-03 11:28:45 -0700 | [diff] [blame] | 119 | ALOGD("char %s %hhd 0x%hhx", s, c, (unsigned char)c); |
Jason Sams | 709a097 | 2012-11-15 18:18:04 -0800 | [diff] [blame] | 120 | } |
Jason Sams | 941a617 | 2013-04-03 11:28:45 -0700 | [diff] [blame] | 121 | static void SC_debugC2(const char *s, const char2 *c) { |
| 122 | ALOGD("char2 %s {%hhd, %hhd} 0x%hhx 0x%hhx", s, c->x, c->y, (unsigned char)c->x, (unsigned char)c->y); |
Jason Sams | 709a097 | 2012-11-15 18:18:04 -0800 | [diff] [blame] | 123 | } |
Jason Sams | 941a617 | 2013-04-03 11:28:45 -0700 | [diff] [blame] | 124 | static void SC_debugC3(const char *s, const char3 *c) { |
| 125 | ALOGD("char3 %s {%hhd, %hhd, %hhd} 0x%hhx 0x%hhx 0x%hhx", s, c->x, c->y, c->z, (unsigned char)c->x, (unsigned char)c->y, (unsigned char)c->z); |
Jason Sams | 709a097 | 2012-11-15 18:18:04 -0800 | [diff] [blame] | 126 | } |
Jason Sams | 941a617 | 2013-04-03 11:28:45 -0700 | [diff] [blame] | 127 | static void SC_debugC4(const char *s, const char4 *c) { |
| 128 | ALOGD("char4 %s {%hhd, %hhd, %hhd, %hhd} 0x%hhx 0x%hhx 0x%hhx 0x%hhx", s, c->x, c->y, c->z, c->w, (unsigned char)c->x, (unsigned char)c->y, (unsigned char)c->z, (unsigned char)c->w); |
Jason Sams | 709a097 | 2012-11-15 18:18:04 -0800 | [diff] [blame] | 129 | } |
| 130 | static void SC_debugU8(const char *s, unsigned char c) { |
Jason Sams | 941a617 | 2013-04-03 11:28:45 -0700 | [diff] [blame] | 131 | ALOGD("uchar %s %hhu 0x%hhx", s, c, c); |
Jason Sams | 709a097 | 2012-11-15 18:18:04 -0800 | [diff] [blame] | 132 | } |
Jason Sams | 941a617 | 2013-04-03 11:28:45 -0700 | [diff] [blame] | 133 | static void SC_debugUC2(const char *s, const uchar2 *c) { |
| 134 | ALOGD("uchar2 %s {%hhu, %hhu} 0x%hhx 0x%hhx", s, c->x, c->y, c->x, c->y); |
Jason Sams | 709a097 | 2012-11-15 18:18:04 -0800 | [diff] [blame] | 135 | } |
Jason Sams | 941a617 | 2013-04-03 11:28:45 -0700 | [diff] [blame] | 136 | static void SC_debugUC3(const char *s, const uchar3 *c) { |
| 137 | ALOGD("uchar3 %s {%hhu, %hhu, %hhu} 0x%hhx 0x%hhx 0x%hhx", s, c->x, c->y, c->z, c->x, c->y, c->z); |
Jason Sams | 709a097 | 2012-11-15 18:18:04 -0800 | [diff] [blame] | 138 | } |
Jason Sams | 941a617 | 2013-04-03 11:28:45 -0700 | [diff] [blame] | 139 | static void SC_debugUC4(const char *s, const uchar4 *c) { |
| 140 | ALOGD("uchar4 %s {%hhu, %hhu, %hhu, %hhu} 0x%hhx 0x%hhx 0x%hhx 0x%hhx", s, c->x, c->y, c->z, c->w, c->x, c->y, c->z, c->w); |
Jason Sams | 709a097 | 2012-11-15 18:18:04 -0800 | [diff] [blame] | 141 | } |
| 142 | static void SC_debugI16(const char *s, short c) { |
Jason Sams | 941a617 | 2013-04-03 11:28:45 -0700 | [diff] [blame] | 143 | ALOGD("short %s %hd 0x%hx", s, c, c); |
Jason Sams | 709a097 | 2012-11-15 18:18:04 -0800 | [diff] [blame] | 144 | } |
Jason Sams | 941a617 | 2013-04-03 11:28:45 -0700 | [diff] [blame] | 145 | static void SC_debugS2(const char *s, const short2 *c) { |
| 146 | ALOGD("short2 %s {%hd, %hd} 0x%hx 0x%hx", s, c->x, c->y, c->x, c->y); |
Jason Sams | 709a097 | 2012-11-15 18:18:04 -0800 | [diff] [blame] | 147 | } |
Jason Sams | 941a617 | 2013-04-03 11:28:45 -0700 | [diff] [blame] | 148 | static void SC_debugS3(const char *s, const short3 *c) { |
| 149 | ALOGD("short3 %s {%hd, %hd, %hd} 0x%hx 0x%hx 0x%hx", s, c->x, c->y, c->z, c->x, c->y, c->z); |
Jason Sams | 709a097 | 2012-11-15 18:18:04 -0800 | [diff] [blame] | 150 | } |
Jason Sams | 941a617 | 2013-04-03 11:28:45 -0700 | [diff] [blame] | 151 | static void SC_debugS4(const char *s, const short4 *c) { |
| 152 | ALOGD("short4 %s {%hd, %hd, %hd, %hd} 0x%hx 0x%hx 0x%hx 0x%hx", s, c->x, c->y, c->z, c->w, c->x, c->y, c->z, c->w); |
Jason Sams | 709a097 | 2012-11-15 18:18:04 -0800 | [diff] [blame] | 153 | } |
| 154 | static void SC_debugU16(const char *s, unsigned short c) { |
Jason Sams | 941a617 | 2013-04-03 11:28:45 -0700 | [diff] [blame] | 155 | ALOGD("ushort %s %hu 0x%hx", s, c, c); |
Jason Sams | 709a097 | 2012-11-15 18:18:04 -0800 | [diff] [blame] | 156 | } |
Jason Sams | 941a617 | 2013-04-03 11:28:45 -0700 | [diff] [blame] | 157 | static void SC_debugUS2(const char *s, const ushort2 *c) { |
| 158 | ALOGD("ushort2 %s {%hu, %hu} 0x%hx 0x%hx", s, c->x, c->y, c->x, c->y); |
Jason Sams | 709a097 | 2012-11-15 18:18:04 -0800 | [diff] [blame] | 159 | } |
Jason Sams | 941a617 | 2013-04-03 11:28:45 -0700 | [diff] [blame] | 160 | static void SC_debugUS3(const char *s, const ushort3 *c) { |
| 161 | ALOGD("ushort3 %s {%hu, %hu, %hu} 0x%hx 0x%hx 0x%hx", s, c->x, c->y, c->z, c->x, c->y, c->z); |
Jason Sams | 709a097 | 2012-11-15 18:18:04 -0800 | [diff] [blame] | 162 | } |
Jason Sams | 941a617 | 2013-04-03 11:28:45 -0700 | [diff] [blame] | 163 | static void SC_debugUS4(const char *s, const ushort4 *c) { |
| 164 | ALOGD("ushort4 %s {%hu, %hu, %hu, %hu} 0x%hx 0x%hx 0x%hx 0x%hx", s, c->x, c->y, c->z, c->w, c->x, c->y, c->z, c->w); |
Jason Sams | 709a097 | 2012-11-15 18:18:04 -0800 | [diff] [blame] | 165 | } |
| 166 | static void SC_debugI32(const char *s, int32_t i) { |
Jason Sams | 941a617 | 2013-04-03 11:28:45 -0700 | [diff] [blame] | 167 | ALOGD("int %s %d 0x%x", s, i, i); |
Jason Sams | 709a097 | 2012-11-15 18:18:04 -0800 | [diff] [blame] | 168 | } |
Jason Sams | 941a617 | 2013-04-03 11:28:45 -0700 | [diff] [blame] | 169 | static void SC_debugI2(const char *s, const int2 *i) { |
| 170 | ALOGD("int2 %s {%d, %d} 0x%x 0x%x", s, i->x, i->y, i->x, i->y); |
Jason Sams | 709a097 | 2012-11-15 18:18:04 -0800 | [diff] [blame] | 171 | } |
Jason Sams | 941a617 | 2013-04-03 11:28:45 -0700 | [diff] [blame] | 172 | static void SC_debugI3(const char *s, const int3 *i) { |
| 173 | ALOGD("int3 %s {%d, %d, %d} 0x%x 0x%x 0x%x", s, i->x, i->y, i->z, i->x, i->y, i->z); |
Jason Sams | 709a097 | 2012-11-15 18:18:04 -0800 | [diff] [blame] | 174 | } |
Jason Sams | 941a617 | 2013-04-03 11:28:45 -0700 | [diff] [blame] | 175 | static void SC_debugI4(const char *s, const int4 *i) { |
| 176 | ALOGD("int4 %s {%d, %d, %d, %d} 0x%x 0x%x 0x%x 0x%x", s, i->x, i->y, i->z, i->w, i->x, i->y, i->z, i->w); |
Jason Sams | 709a097 | 2012-11-15 18:18:04 -0800 | [diff] [blame] | 177 | } |
| 178 | static void SC_debugU32(const char *s, uint32_t i) { |
Jason Sams | 941a617 | 2013-04-03 11:28:45 -0700 | [diff] [blame] | 179 | ALOGD("uint %s %u 0x%x", s, i, i); |
Jason Sams | 709a097 | 2012-11-15 18:18:04 -0800 | [diff] [blame] | 180 | } |
Jason Sams | 941a617 | 2013-04-03 11:28:45 -0700 | [diff] [blame] | 181 | static void SC_debugUI2(const char *s, const uint2 *i) { |
| 182 | ALOGD("uint2 %s {%u, %u} 0x%x 0x%x", s, i->x, i->y, i->x, i->y); |
Jason Sams | 709a097 | 2012-11-15 18:18:04 -0800 | [diff] [blame] | 183 | } |
Jason Sams | 941a617 | 2013-04-03 11:28:45 -0700 | [diff] [blame] | 184 | static void SC_debugUI3(const char *s, const uint3 *i) { |
| 185 | ALOGD("uint3 %s {%u, %u, %u} 0x%x 0x%x 0x%x", s, i->x, i->y, i->z, i->x, i->y, i->z); |
Jason Sams | 709a097 | 2012-11-15 18:18:04 -0800 | [diff] [blame] | 186 | } |
Jason Sams | 941a617 | 2013-04-03 11:28:45 -0700 | [diff] [blame] | 187 | static void SC_debugUI4(const char *s, const uint4 *i) { |
| 188 | ALOGD("uint4 %s {%u, %u, %u, %u} 0x%x 0x%x 0x%x 0x%x", s, i->x, i->y, i->z, i->w, i->x, i->y, i->z, i->w); |
Jason Sams | 709a097 | 2012-11-15 18:18:04 -0800 | [diff] [blame] | 189 | } |
| 190 | static void SC_debugLL64(const char *s, long long ll) { |
Jason Sams | 941a617 | 2013-04-03 11:28:45 -0700 | [diff] [blame] | 191 | ALOGD("long %s %lld 0x%llx", s, ll, ll); |
Jason Sams | 709a097 | 2012-11-15 18:18:04 -0800 | [diff] [blame] | 192 | } |
Jason Sams | 941a617 | 2013-04-03 11:28:45 -0700 | [diff] [blame] | 193 | static void SC_debugL2(const char *s, const long2 *ll) { |
| 194 | ALOGD("long2 %s {%lld, %lld} 0x%llx 0x%llx", s, ll->x, ll->y, ll->x, ll->y); |
Jason Sams | 709a097 | 2012-11-15 18:18:04 -0800 | [diff] [blame] | 195 | } |
Jason Sams | 941a617 | 2013-04-03 11:28:45 -0700 | [diff] [blame] | 196 | static void SC_debugL3(const char *s, const long3 *ll) { |
| 197 | ALOGD("long3 %s {%lld, %lld, %lld} 0x%llx 0x%llx 0x%llx", s, ll->x, ll->y, ll->z, ll->x, ll->y, ll->z); |
Jason Sams | 709a097 | 2012-11-15 18:18:04 -0800 | [diff] [blame] | 198 | } |
Jason Sams | 941a617 | 2013-04-03 11:28:45 -0700 | [diff] [blame] | 199 | static void SC_debugL4(const char *s, const long4 *ll) { |
| 200 | ALOGD("long4 %s {%lld, %lld, %lld, %lld} 0x%llx 0x%llx 0x%llx 0x%llx", s, ll->x, ll->y, ll->z, ll->w, ll->x, ll->y, ll->z, ll->w); |
Jason Sams | 709a097 | 2012-11-15 18:18:04 -0800 | [diff] [blame] | 201 | } |
| 202 | static void SC_debugULL64(const char *s, unsigned long long ll) { |
Jason Sams | 941a617 | 2013-04-03 11:28:45 -0700 | [diff] [blame] | 203 | ALOGD("ulong %s %llu 0x%llx", s, ll, ll); |
Jason Sams | 709a097 | 2012-11-15 18:18:04 -0800 | [diff] [blame] | 204 | } |
Jason Sams | 941a617 | 2013-04-03 11:28:45 -0700 | [diff] [blame] | 205 | static void SC_debugUL2(const char *s, const ulong2 *ll) { |
| 206 | ALOGD("ulong2 %s {%llu, %llu} 0x%llx 0x%llx", s, ll->x, ll->y, ll->x, ll->y); |
Jason Sams | 709a097 | 2012-11-15 18:18:04 -0800 | [diff] [blame] | 207 | } |
Jason Sams | 941a617 | 2013-04-03 11:28:45 -0700 | [diff] [blame] | 208 | static void SC_debugUL3(const char *s, const ulong3 *ll) { |
| 209 | ALOGD("ulong3 %s {%llu, %llu, %llu} 0x%llx 0x%llx 0x%llx", s, ll->x, ll->y, ll->z, ll->x, ll->y, ll->z); |
Jason Sams | 709a097 | 2012-11-15 18:18:04 -0800 | [diff] [blame] | 210 | } |
Jason Sams | 941a617 | 2013-04-03 11:28:45 -0700 | [diff] [blame] | 211 | static void SC_debugUL4(const char *s, const ulong4 *ll) { |
| 212 | ALOGD("ulong4 %s {%llu, %llu, %llu, %llu} 0x%llx 0x%llx 0x%llx 0x%llx", s, ll->x, ll->y, ll->z, ll->w, ll->x, ll->y, ll->z, ll->w); |
Jason Sams | 709a097 | 2012-11-15 18:18:04 -0800 | [diff] [blame] | 213 | } |
| 214 | static void SC_debugP(const char *s, const void *p) { |
Jason Sams | 941a617 | 2013-04-03 11:28:45 -0700 | [diff] [blame] | 215 | ALOGD("void * %s %p", s, p); |
Jason Sams | 709a097 | 2012-11-15 18:18:04 -0800 | [diff] [blame] | 216 | } |
| 217 | |
| 218 | |
| 219 | ////////////////////////////////////////////////////////////////////////////// |
| 220 | // Stub implementation |
| 221 | ////////////////////////////////////////////////////////////////////////////// |
| 222 | |
| 223 | // llvm name mangling ref |
| 224 | // <builtin-type> ::= v # void |
| 225 | // ::= b # bool |
| 226 | // ::= c # char |
| 227 | // ::= a # signed char |
| 228 | // ::= h # unsigned char |
| 229 | // ::= s # short |
| 230 | // ::= t # unsigned short |
| 231 | // ::= i # int |
| 232 | // ::= j # unsigned int |
| 233 | // ::= l # long |
| 234 | // ::= m # unsigned long |
| 235 | // ::= x # long long, __int64 |
| 236 | // ::= y # unsigned long long, __int64 |
| 237 | // ::= f # float |
| 238 | // ::= d # double |
| 239 | |
| 240 | static RsdCpuReference::CpuSymbol gSyms[] = { |
| 241 | { "memset", (void *)&memset, true }, |
| 242 | { "memcpy", (void *)&memcpy, true }, |
| 243 | |
| 244 | // Debug |
| 245 | { "_Z7rsDebugPKcf", (void *)&SC_debugF, true }, |
| 246 | { "_Z7rsDebugPKcff", (void *)&SC_debugFv2, true }, |
| 247 | { "_Z7rsDebugPKcfff", (void *)&SC_debugFv3, true }, |
| 248 | { "_Z7rsDebugPKcffff", (void *)&SC_debugFv4, true }, |
Jason Sams | 941a617 | 2013-04-03 11:28:45 -0700 | [diff] [blame] | 249 | { "_Z7rsDebugPKcPKDv2_f", (void *)&SC_debugF2, true }, |
| 250 | { "_Z7rsDebugPKcPKDv3_f", (void *)&SC_debugF3, true }, |
| 251 | { "_Z7rsDebugPKcPKDv4_f", (void *)&SC_debugF4, true }, |
Jason Sams | 709a097 | 2012-11-15 18:18:04 -0800 | [diff] [blame] | 252 | { "_Z7rsDebugPKcd", (void *)&SC_debugD, true }, |
Tim Murray | 60fe47d | 2014-05-27 13:29:32 -0700 | [diff] [blame] | 253 | { "_Z7rsDebugPKcPKDv2_d", (void *)&SC_debugD2, true }, |
| 254 | { "_Z7rsDebugPKcPKDv3_d", (void *)&SC_debugD3, true }, |
| 255 | { "_Z7rsDebugPKcPKDv4_d", (void *)&SC_debugD4, true }, |
Jason Sams | 709a097 | 2012-11-15 18:18:04 -0800 | [diff] [blame] | 256 | { "_Z7rsDebugPKcPK12rs_matrix4x4", (void *)&SC_debugFM4v4, true }, |
| 257 | { "_Z7rsDebugPKcPK12rs_matrix3x3", (void *)&SC_debugFM3v3, true }, |
| 258 | { "_Z7rsDebugPKcPK12rs_matrix2x2", (void *)&SC_debugFM2v2, true }, |
| 259 | { "_Z7rsDebugPKcc", (void *)&SC_debugI8, true }, |
Jason Sams | 941a617 | 2013-04-03 11:28:45 -0700 | [diff] [blame] | 260 | { "_Z7rsDebugPKcPKDv2_c", (void *)&SC_debugC2, true }, |
| 261 | { "_Z7rsDebugPKcPKDv3_c", (void *)&SC_debugC3, true }, |
| 262 | { "_Z7rsDebugPKcPKDv4_c", (void *)&SC_debugC4, true }, |
Jason Sams | 709a097 | 2012-11-15 18:18:04 -0800 | [diff] [blame] | 263 | { "_Z7rsDebugPKch", (void *)&SC_debugU8, true }, |
Jason Sams | 941a617 | 2013-04-03 11:28:45 -0700 | [diff] [blame] | 264 | { "_Z7rsDebugPKcPKDv2_h", (void *)&SC_debugUC2, true }, |
| 265 | { "_Z7rsDebugPKcPKDv3_h", (void *)&SC_debugUC3, true }, |
| 266 | { "_Z7rsDebugPKcPKDv4_h", (void *)&SC_debugUC4, true }, |
Jason Sams | 709a097 | 2012-11-15 18:18:04 -0800 | [diff] [blame] | 267 | { "_Z7rsDebugPKcs", (void *)&SC_debugI16, true }, |
Jason Sams | 941a617 | 2013-04-03 11:28:45 -0700 | [diff] [blame] | 268 | { "_Z7rsDebugPKcPKDv2_s", (void *)&SC_debugS2, true }, |
| 269 | { "_Z7rsDebugPKcPKDv3_s", (void *)&SC_debugS3, true }, |
| 270 | { "_Z7rsDebugPKcPKDv4_s", (void *)&SC_debugS4, true }, |
Jason Sams | 709a097 | 2012-11-15 18:18:04 -0800 | [diff] [blame] | 271 | { "_Z7rsDebugPKct", (void *)&SC_debugU16, true }, |
Jason Sams | 941a617 | 2013-04-03 11:28:45 -0700 | [diff] [blame] | 272 | { "_Z7rsDebugPKcPKDv2_t", (void *)&SC_debugUS2, true }, |
| 273 | { "_Z7rsDebugPKcPKDv3_t", (void *)&SC_debugUS3, true }, |
| 274 | { "_Z7rsDebugPKcPKDv4_t", (void *)&SC_debugUS4, true }, |
Jason Sams | 709a097 | 2012-11-15 18:18:04 -0800 | [diff] [blame] | 275 | { "_Z7rsDebugPKci", (void *)&SC_debugI32, true }, |
Jason Sams | 941a617 | 2013-04-03 11:28:45 -0700 | [diff] [blame] | 276 | { "_Z7rsDebugPKcPKDv2_i", (void *)&SC_debugI2, true }, |
| 277 | { "_Z7rsDebugPKcPKDv3_i", (void *)&SC_debugI3, true }, |
| 278 | { "_Z7rsDebugPKcPKDv4_i", (void *)&SC_debugI4, true }, |
Jason Sams | 709a097 | 2012-11-15 18:18:04 -0800 | [diff] [blame] | 279 | { "_Z7rsDebugPKcj", (void *)&SC_debugU32, true }, |
Jason Sams | 941a617 | 2013-04-03 11:28:45 -0700 | [diff] [blame] | 280 | { "_Z7rsDebugPKcPKDv2_j", (void *)&SC_debugUI2, true }, |
| 281 | { "_Z7rsDebugPKcPKDv3_j", (void *)&SC_debugUI3, true }, |
| 282 | { "_Z7rsDebugPKcPKDv4_j", (void *)&SC_debugUI4, true }, |
Jason Sams | 709a097 | 2012-11-15 18:18:04 -0800 | [diff] [blame] | 283 | // Both "long" and "unsigned long" need to be redirected to their |
| 284 | // 64-bit counterparts, since we have hacked Slang to use 64-bit |
| 285 | // for "long" on Arm (to be similar to Java). |
| 286 | { "_Z7rsDebugPKcl", (void *)&SC_debugLL64, true }, |
Jason Sams | 941a617 | 2013-04-03 11:28:45 -0700 | [diff] [blame] | 287 | { "_Z7rsDebugPKcPKDv2_l", (void *)&SC_debugL2, true }, |
| 288 | { "_Z7rsDebugPKcPKDv3_l", (void *)&SC_debugL3, true }, |
| 289 | { "_Z7rsDebugPKcPKDv4_l", (void *)&SC_debugL4, true }, |
Jason Sams | 709a097 | 2012-11-15 18:18:04 -0800 | [diff] [blame] | 290 | { "_Z7rsDebugPKcm", (void *)&SC_debugULL64, true }, |
Jason Sams | 941a617 | 2013-04-03 11:28:45 -0700 | [diff] [blame] | 291 | { "_Z7rsDebugPKcPKDv2_m", (void *)&SC_debugUL2, true }, |
| 292 | { "_Z7rsDebugPKcPKDv3_m", (void *)&SC_debugUL3, true }, |
| 293 | { "_Z7rsDebugPKcPKDv4_m", (void *)&SC_debugUL4, true }, |
Jason Sams | 709a097 | 2012-11-15 18:18:04 -0800 | [diff] [blame] | 294 | { "_Z7rsDebugPKcx", (void *)&SC_debugLL64, true }, |
Jason Sams | 941a617 | 2013-04-03 11:28:45 -0700 | [diff] [blame] | 295 | { "_Z7rsDebugPKcPKDv2_x", (void *)&SC_debugL2, true }, |
| 296 | { "_Z7rsDebugPKcPKDv3_x", (void *)&SC_debugL3, true }, |
| 297 | { "_Z7rsDebugPKcPKDv4_x", (void *)&SC_debugL4, true }, |
Jason Sams | 709a097 | 2012-11-15 18:18:04 -0800 | [diff] [blame] | 298 | { "_Z7rsDebugPKcy", (void *)&SC_debugULL64, true }, |
Jason Sams | 941a617 | 2013-04-03 11:28:45 -0700 | [diff] [blame] | 299 | { "_Z7rsDebugPKcPKDv2_y", (void *)&SC_debugUL2, true }, |
| 300 | { "_Z7rsDebugPKcPKDv3_y", (void *)&SC_debugUL3, true }, |
| 301 | { "_Z7rsDebugPKcPKDv4_y", (void *)&SC_debugUL4, true }, |
Jason Sams | 709a097 | 2012-11-15 18:18:04 -0800 | [diff] [blame] | 302 | { "_Z7rsDebugPKcPKv", (void *)&SC_debugP, true }, |
| 303 | |
| 304 | { NULL, NULL, false } |
| 305 | }; |
| 306 | |
| 307 | |
| 308 | void * RsdCpuScriptImpl::lookupRuntimeStub(void* pContext, char const* name) { |
| 309 | RsdCpuScriptImpl *s = (RsdCpuScriptImpl *)pContext; |
| 310 | const RsdCpuReference::CpuSymbol *syms = gSyms; |
| 311 | const RsdCpuReference::CpuSymbol *sym = NULL; |
| 312 | |
| 313 | sym = s->mCtx->symLookup(name); |
| 314 | if (!sym) { |
| 315 | sym = s->lookupSymbolMath(name); |
| 316 | } |
| 317 | if (!sym) { |
| 318 | while (syms->fnPtr) { |
| 319 | if (!strcmp(syms->name, name)) { |
| 320 | sym = syms; |
| 321 | } |
| 322 | syms++; |
| 323 | } |
| 324 | } |
| 325 | |
| 326 | if (sym) { |
| 327 | s->mIsThreadable &= sym->threadable; |
| 328 | return sym->fnPtr; |
| 329 | } |
| 330 | ALOGE("ScriptC sym lookup failed for %s", name); |
| 331 | return NULL; |
| 332 | } |
| 333 | |
| 334 | |