diff options
author | Anatol Belski <ab@php.net> | 2018-01-29 18:24:27 +0100 |
---|---|---|
committer | Anatol Belski <ab@php.net> | 2018-01-29 18:26:03 +0100 |
commit | acbd348969ea9f9a334c74dcc309da62e9bdc24e (patch) | |
tree | 02b2ec48a8a6c653344d615c9ebb18d87295c0c8 /win32/build | |
parent | e51aadcc4e48cdce049afda75e769bf1ff946ed3 (diff) | |
download | php-git-acbd348969ea9f9a334c74dcc309da62e9bdc24e.tar.gz |
Implement configuration option for explicit native intrinsics
It mimics -march=native, AVX and more to go, if needed.
Diffstat (limited to 'win32/build')
-rw-r--r-- | win32/build/config.w32 | 7 | ||||
-rw-r--r-- | win32/build/confutils.js | 47 |
2 files changed, 54 insertions, 0 deletions
diff --git a/win32/build/config.w32 b/win32/build/config.w32 index a043ddbb20..7697838bb1 100644 --- a/win32/build/config.w32 +++ b/win32/build/config.w32 @@ -342,3 +342,10 @@ ARG_ENABLE("test-ini", "Enable automatic php.ini generation. The test.ini will b ARG_WITH("test-ini-ext-exclude", "Comma separated list of shared extensions to \ be excluded from the test.ini", "no"); +ARG_ENABLE("native-intrinsics", "Comma separated list of intrinsic optimizations to enable. \ + Available optimization names are sse, sse2, sse4.1, sse4.2. SSE and SSE2 are enabled \ + by default. The best optimization specified will automatically enable all the older \ + optimizations. Note, that the produced binary might not work properly, if the \ + optimizations are not available on the target processor.", "no"); +toolset_setup_intrinsic_cflags(); + diff --git a/win32/build/confutils.js b/win32/build/confutils.js index d588df78a7..c15af50a51 100644 --- a/win32/build/confutils.js +++ b/win32/build/confutils.js @@ -3219,6 +3219,53 @@ function toolset_setup_common_cflags() } } +function toolset_setup_intrinsic_cflags() +{ + var default_enabled = "sse2"; + /* XXX AVX and above needs to be reflected in /arch, for now SSE4.2 is + the best possible optimization.*/ + var avail = WScript.CreateObject("Scripting.Dictionary"); + avail.Add("sse", "__SSE__"); + avail.Add("sse2", "__SSE2__"); + avail.Add("sse3", "__SSE3__"); + avail.Add("ssse3", "__SSSE3__"); + avail.Add("sse4.1", "__SSE4_1__"); + avail.Add("sse4.2", "__SSE4_2__"); + /* From oldest to newest. */ + var scale = new Array("sse", "sse2", "sse3", "ssse3", "sse4.1", "sse4.2"); + + if (VS_TOOLSET) { + if ("no" == PHP_NATIVE_INTRINSICS || "yes" == PHP_NATIVE_INTRINSICS) { + PHP_NATIVE_INTRINSICS = default_enabled; + } + + if ("all" == PHP_NATIVE_INTRINSICS) { + var list = (new VBArray(avail.Keys())).toArray(); + + for (var i in list) { + AC_DEFINE(avail.Item(list[i]), 1); + } + } else { + var list = PHP_NATIVE_INTRINSICS.split(","); + var j = 0; + for (var k = 0; k < scale.length; k++) { + for (var i = 0; i < list.length; i++) { + var it = list[i].toLowerCase(); + if (scale[k] == it) { + j = k > j ? k : j; + } else if (!avail.Exists(it)) { + WARNING("Unknown intrinsic name '" + it + "' ignored"); + } + } + } + for (var i = 0; i <= j; i++) { + var it = scale[i]; + AC_DEFINE(avail.Item(it), 1); + } + } + } +} + function toolset_setup_common_ldlags() { // General DLL link flags |