Update runtime header generator
bug 5653293
Check in new headers. Will require compiler update
to start using.
Change-Id: Ic21360d4775085356865cb15080f8704120b4f0f
diff --git a/api/gen_runtime.cpp b/api/gen_runtime.cpp
index a545a2e..cdfdf5d 100644
--- a/api/gen_runtime.cpp
+++ b/api/gen_runtime.cpp
@@ -249,12 +249,51 @@
return s;
}
+void writeLegal(FILE *o) {
+ fprintf(o, "/*\n");
+ fprintf(o, " * Copyright (C) 2014 The Android Open Source Project\n");
+ fprintf(o, " *\n");
+ fprintf(o, " * Licensed under the Apache License, Version 2.0 (the \"License\");\n");
+ fprintf(o, " * you may not use this file except in compliance with the License.\n");
+ fprintf(o, " * You may obtain a copy of the License at\n");
+ fprintf(o, " *\n");
+ fprintf(o, " * http://www.apache.org/licenses/LICENSE-2.0\n");
+ fprintf(o, " *\n");
+ fprintf(o, " * Unless required by applicable law or agreed to in writing, software\n");
+ fprintf(o, " * distributed under the License is distributed on an \"AS IS\" BASIS,\n");
+ fprintf(o, " * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.\n");
+ fprintf(o, " * See the License for the specific language governing permissions and\n");
+ fprintf(o, " * limitations under the License.\n");
+ fprintf(o, " */\n\n");
+}
+
+void writeIfdef(FILE *o, string filename, bool isStart) {
+ string t = "__";
+ t += filename;
+ t += "__";
+
+ for (size_t i = 2; i < t.size(); i++) {
+ if (t[i] == '.') {
+ t[i] = '_';
+ }
+ }
+
+ if (isStart) {
+ fprintf(o, "#ifndef %s\n", t.c_str());
+ fprintf(o, "#define %s\n", t.c_str());
+ } else {
+ fprintf(o, "#endif // %s\n", t.c_str());
+ }
+}
+
+
+
void writeHeaderFunc(FILE *o, const Func *f, int i1, int i2, int i3, int i4) {
string s;
if (f->mMinVersion || f->mMaxVersion) {
if (f->mMaxVersion) {
- fprintf(o, "#if (defined(RS_VERSION) && (RS_VERSION >= %i) && (RS_VERSION < %i))\n",
+ fprintf(o, "#if (defined(RS_VERSION) && (RS_VERSION >= %i) && (RS_VERSION <= %i))\n",
f->mMinVersion, f->mMaxVersion);
} else {
fprintf(o, "#if (defined(RS_VERSION) && (RS_VERSION >= %i))\n",
@@ -285,7 +324,11 @@
fprintf(o, " */\n");
s.clear();
- s += "extern ";
+ if (f->mInline.size() > 0) {
+ s += "static ";
+ } else {
+ s += "extern ";
+ }
s += f->mRet;
s += " __attribute__((const, overloadable))";
s += f->mName;
@@ -295,12 +338,23 @@
}
for (size_t ct=1; ct < f->mArgs.size(); ct++) {
s += ", ";
- s += f->mArgs[0];
+ s += f->mArgs[ct];
}
- s += ");";
+ if (f->mInline.size() > 0) {
+ s += ") {";
+ } else {
+ s += ");";
+ }
s = stringExpand(s, f, i1, i2, i3, i4);
fprintf(o, "%s\n", s.c_str());
+ if (f->mInline.size() > 0) {
+ for (size_t ct=0; ct < f->mInline.size(); ct++) {
+ s = stringExpand(f->mInline[ct], f, i1, i2, i3, i4);
+ fprintf(o, " %s\n", s.c_str());
+ }
+ fprintf(o, "}\n");
+ }
if (f->mMinVersion || f->mMaxVersion) {
fprintf(o, "#endif\n");
@@ -378,9 +432,12 @@
return -1;
}
+ writeLegal(gOut);
+ writeIfdef(gOut, outpath, true);
for (size_t ct=0; ct < gFuncs.size(); ct++) {
writeHeaderFuncs(gOut, gFuncs[ct]);
}
+ writeIfdef(gOut, outpath, false);
fclose (gIn);
fclose (gOut);
diff --git a/api/runtime.spec b/api/runtime.spec
index 65e29ea..279d67f 100644
--- a/api/runtime.spec
+++ b/api/runtime.spec
@@ -18,7 +18,7 @@
w: 2, 3, 4
t: u8, u16, u32, u64, i8, i16, i32, i64, f32, f64
t: u8, u16, u32, u64, i8, i16, i32, i64, f32, f64
-name: convert_uchar#1
+name: convert_#3#1
arg: #2#1
ret: #3#1
comment:
@@ -299,6 +299,7 @@
name: fdim
ret: #2#1
arg: #2#1
+arg: #2#1
comment:
Return the positive difference between two values.
version: 9
@@ -446,8 +447,8 @@
w: 1, 2, 3, 4
t: f32
name: ilogb
-ret: #2#1
-arg: #2#1
+ret: int#1
+arg: float#1
comment:
Return the integer exponent of a value
version: 9
@@ -479,6 +480,34 @@
start:
w: 1, 2, 3, 4
+name: ldexp
+ret: float#1
+arg: float#1 x
+arg: int#1 y
+comment:
+ Return (x * 2^y)
+
+ @param x Supports 1,2,3,4 components
+ @param y Supports single component or matching vector.
+version: 9
+end:
+
+start:
+w: 2, 3, 4
+name: ldexp
+ret: float#1
+arg: float#1 x
+arg: int y
+comment:
+ Return (x * 2^y)
+
+ @param x Supports 1,2,3,4 components
+ @param y Supports single component or matching vector.
+version: 9
+end:
+
+start:
+w: 1, 2, 3, 4
t: f32
name: lgamma
ret: #2#1
@@ -835,7 +864,7 @@
w: 1, 2, 3, 4
t: i8, i16, i32
name: abs
-ret: #2#1
+ret: u#2#1
arg: #2#1 value
comment:
Return the absolute value of a value.
@@ -866,7 +895,7 @@
end:
start:
-w: 1, 2, 3, 4
+w: 1
t: i8 i16 i32 u8 u16 u32
name: min
ret: #2#1
@@ -880,6 +909,60 @@
end:
start:
+w: 2
+t: i8 i16 i32 u8 u16 u32
+name: min
+ret: #2#1
+arg: #2#1 v1
+arg: #2#1 v2
+comment:
+ Return the minimum value from two arguments
+inline:
+ #2#1 tmp;
+ tmp.x = (v1.x < v2.x ? v1.x : v2.x);
+ tmp.y = (v1.y < v2.y ? v1.y : v2.y);
+ return tmp;
+version: 9 19
+end:
+
+start:
+w: 3
+t: i8 i16 i32 u8 u16 u32
+name: min
+ret: #2#1
+arg: #2#1 v1
+arg: #2#1 v2
+comment:
+ Return the minimum value from two arguments
+inline:
+ #2#1 tmp;
+ tmp.x = (v1.x < v2.x ? v1.x : v2.x);
+ tmp.y = (v1.y < v2.y ? v1.y : v2.y);
+ tmp.z = (v1.z < v2.z ? v1.z : v2.z);
+ return tmp;
+version: 9 19
+end:
+
+start:
+w: 4
+t: i8 i16 i32 u8 u16 u32
+name: min
+ret: #2#1
+arg: #2#1 v1
+arg: #2#1 v2
+comment:
+ Return the minimum value from two arguments
+inline:
+ #2#1 tmp;
+ tmp.x = (v1.x < v2.x ? v1.x : v2.x);
+ tmp.y = (v1.y < v2.y ? v1.y : v2.y);
+ tmp.z = (v1.z < v2.z ? v1.z : v2.z);
+ tmp.w = (v1.w < v2.w ? v1.w : v2.w);
+ return tmp;
+version: 9 19
+end:
+
+start:
w: 1, 2, 3, 4
t: i8 i16 i32 i64 u8 u16 u32 u64
name: min
@@ -888,7 +971,7 @@
arg: #2#1 v2
comment:
Return the minimum value from two arguments
-version: 19
+version: 20
end:
start:
@@ -904,7 +987,7 @@
end:
start:
-w: 1, 2, 3, 4
+w: 1
t: i8 i16 i32 u8 u16 u32
name: max
ret: #2#1
@@ -913,7 +996,61 @@
comment:
Return the maximum value from two arguments
inline:
- return (v1 < v2 ? v1 : v2);
+ return (v1 > v2 ? v1 : v2);
+version: 9 19
+end:
+
+start:
+w: 2
+t: i8 i16 i32 u8 u16 u32
+name: max
+ret: #2#1
+arg: #2#1 v1
+arg: #2#1 v2
+comment:
+ Return the maximum value from two arguments
+inline:
+ #2#1 tmp;
+ tmp.x = (v1.x > v2.x ? v1.x : v2.x);
+ tmp.y = (v1.y > v2.y ? v1.y : v2.y);
+ return tmp;
+version: 9 19
+end:
+
+start:
+w: 3
+t: i8 i16 i32 u8 u16 u32
+name: max
+ret: #2#1
+arg: #2#1 v1
+arg: #2#1 v2
+comment:
+ Return the maximum value from two arguments
+inline:
+ #2#1 tmp;
+ tmp.x = (v1.x > v2.x ? v1.x : v2.x);
+ tmp.y = (v1.y > v2.y ? v1.y : v2.y);
+ tmp.z = (v1.z > v2.z ? v1.z : v2.z);
+ return tmp;
+version: 9 19
+end:
+
+start:
+w: 4
+t: i8 i16 i32 u8 u16 u32
+name: max
+ret: #2#1
+arg: #2#1 v1
+arg: #2#1 v2
+comment:
+ Return the maximum value from two arguments
+inline:
+ #2#1 tmp;
+ tmp.x = (v1.x > v2.x ? v1.x : v2.x);
+ tmp.y = (v1.y > v2.y ? v1.y : v2.y);
+ tmp.z = (v1.z > v2.z ? v1.z : v2.z);
+ tmp.w = (v1.w > v2.w ? v1.w : v2.w);
+ return tmp;
version: 9 19
end:
@@ -926,7 +1063,7 @@
arg: #2#1 v2
comment:
Return the maximum value from two arguments
-version: 19
+version: 20
end:
start:
@@ -1050,7 +1187,8 @@
t: f32
name: step
ret: #2#1
-arg: #2#1 value
+arg: #2#1 edge
+arg: #2#1 v
comment:
if (v < edge)
return 0.f;
@@ -1060,11 +1198,11 @@
end:
start:
-w: 1, 2, 3, 4
+w: 2, 3, 4
t: f32
name: step
ret: #2#1
-arg: #2 edge
+arg: #2#1 edge
arg: #2 v
comment:
if (v < edge)
@@ -1079,7 +1217,7 @@
t: f32
name: sign
ret: #2#1
-arg: #2 v
+arg: #2#1 v
comment:
Return the sign of a value.