Test, documentation and vim support for double precision constants

This commit is contained in:
Dmitry Babokin
2013-09-17 23:36:16 +04:00
parent ff547fc6cb
commit f45f6cb32a
3 changed files with 38 additions and 1 deletions

View File

@@ -19,6 +19,11 @@ syn keyword ispcRepeat cdo cfor cwhile
syn keyword ispcBuiltin programCount programIndex syn keyword ispcBuiltin programCount programIndex
syn keyword ispcType export uniform varying int8 int16 int32 int64 syn keyword ispcType export uniform varying int8 int16 int32 int64
"double precision floating point number, with dot, optional exponent
syn match cFloat display contained "\d\+\.\d*d[-+]\=\d*\>"
"double precision floating point number, without dot, with exponent
syn match cFloat display contained "\d\+d[-+]\=\d\+\>"
" Default highlighting " Default highlighting
command -nargs=+ HiLink hi def link <args> command -nargs=+ HiLink hi def link <args>
HiLink ispcStatement Statement HiLink ispcStatement Statement

View File

@@ -270,6 +270,14 @@ new reserved words: ``unmasked``, ``foreach_unique``, ``foreach_active``,
and ``in``. Any program that happens to have a variable or function with and ``in``. Any program that happens to have a variable or function with
one of these names must be modified to rename that symbol. one of these names must be modified to rename that symbol.
Updating ISPC Programs For Changes In ISPC 1.4.5
----------------------------------------------
This release adds support for double precision floating point constants.
Double precision floating point constants are floating point number with
``d`` suffix and optional exponent part. Here are some examples: 3.14d,
31.4d-1, 1.d, 1.0d, 1d-2. Note that floating point number without suffix is
treated as single precision constant.
Getting Started with ISPC Getting Started with ISPC
========================= =========================
@@ -1349,7 +1357,8 @@ but are likely to be supported in future releases:
* Bitfield members of ``struct`` types * Bitfield members of ``struct`` types
* Variable numbers of arguments to functions * Variable numbers of arguments to functions
* Literal floating-point constants (even without a ``f`` suffix) are * Literal floating-point constants (even without a ``f`` suffix) are
currently treated as being ``float`` type, not ``double`` currently treated as being ``float`` type, not ``double``. To have a double
precision floating point constant use ``d`` suffix.
* The ``volatile`` qualifier * The ``volatile`` qualifier
* The ``register`` storage class for variables. (Will be ignored). * The ``register`` storage class for variables. (Will be ignored).

23
tests/double-consts.ispc Normal file
View File

@@ -0,0 +1,23 @@
export uniform int width() { return programCount; }
export void f_f(uniform float RET[], uniform float aFOO[]) {
double a = aFOO[programIndex];
// Test parsing of double constants.
double d1 = 1.0d40;
double d2 = 1.d40;
double d3 = 1d40;
double d4 = 10000000000000000000000000000000000000000.d;
double d5 = 10000000000000000000000000000000000000000.0d;
// All the constants should be equal and if it's evaluated as "float",
// then sqrt will evaluate to +inf.
if (d1 == d2 && d1 == d3 && d1 == d4 && d1 == d5 &&
((float)sqrt(d1)) < 2e20) {
RET[programIndex] = a;
}
}
export void result(uniform float RET[]) {
RET[programIndex] = 1 + programIndex;
}