mirror of
https://github.com/php/php-src.git
synced 2025-08-15 21:48:51 +02:00
Implement configuration option for explicit native intrinsics
It mimics -march=native, AVX and more to go, if needed.
This commit is contained in:
parent
e51aadcc4e
commit
acbd348969
2 changed files with 54 additions and 0 deletions
|
@ -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();
|
||||
|
||||
|
|
|
@ -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
|
||||
|
|
Loading…
Add table
Add a link
Reference in a new issue