www.digitalmars.com         C & C++   DMDScript  

digitalmars.D.bugs - [Issue 15228] New: Expose architecture specific feature sets at


          Issue ID: 15228
           Summary: Expose architecture specific feature sets at
           Product: D
           Version: D2
          Hardware: All
                OS: All
            Status: NEW
          Severity: enhancement
          Priority: P1
         Component: dmd
          Assignee: nobody puremagic.com
          Reporter: Marco.Leise gmx.de

GDC and LLVM allow you to target a specific CPU model or activate additional
feature sets like SSE4 on the command line. This allows them to use different
instructions for intrinsics internally and better optimize the code. For
example some newer x86 CPUs have a "count-leading-zeroes" instruction that
other models need to emulate.

If these were exposed in D at compile-time we could replace indirect function
calls to either a generic or SSE4 based function with an inlinable call to the
SSE4 function on later CPUs. This can come into effect everywhere a program is
compiled from source for local use as in Vibe.d, Source only Linux
distributions or personal projects, but also when distributing "SSE enhanced
versions" of programs.

As these flags are only relevant to subsets of the supported architectures they
should probably be implemented as "version(SSE4_2)" etc. Existing code using
-version=SSE4_2 on the command-line will in all likeliness continue to work as
intended. I understand that since DMD always creates generic builds it is
mostly a matter of documenting the version defines on
http://dlang.org/version.html#PredefinedVersions. Though "extensions" available
on all x64 CPUs like SSE2 should still be advertised when building with -m64,
adding some benefit even there.

Oct 20 2015