diff --git a/contrib/ispc.vim b/contrib/ispc.vim index cc8493f0..4d870dcd 100644 --- a/contrib/ispc.vim +++ b/contrib/ispc.vim @@ -19,6 +19,11 @@ syn keyword ispcRepeat cdo cfor cwhile syn keyword ispcBuiltin programCount programIndex 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 command -nargs=+ HiLink hi def link HiLink ispcStatement Statement diff --git a/docs/ispc.rst b/docs/ispc.rst index ff07f6d8..224faaa9 100644 --- a/docs/ispc.rst +++ b/docs/ispc.rst @@ -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 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 ========================= @@ -1349,7 +1357,8 @@ but are likely to be supported in future releases: * Bitfield members of ``struct`` types * Variable numbers of arguments to functions * 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 ``register`` storage class for variables. (Will be ignored). diff --git a/tests/double-consts.ispc b/tests/double-consts.ispc new file mode 100644 index 00000000..3259156a --- /dev/null +++ b/tests/double-consts.ispc @@ -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; +}