1 ! Copyright (C) 2009 Slava Pestov.
2 ! See http://factorcode.org/license.txt for BSD license.
3 USING: system kernel memoize math math.order math.parser
4 namespaces alien.c-types alien.syntax combinators locals init io
5 compiler compiler.units accessors ;
10 FUNCTION: int sse_version ( ) ;
12 FUNCTION: longlong read_timestamp_counter ( ) ;
16 MEMO: sse-version ( -- n )
18 "sse-version" get string>number [ min ] when* ;
20 [ \ sse-version reset-memoized ] "cpu.x86.features" add-init-hook
22 : sse? ( -- ? ) sse-version 10 >= ;
23 : sse2? ( -- ? ) sse-version 20 >= ;
24 : sse3? ( -- ? ) sse-version 30 >= ;
25 : ssse3? ( -- ? ) sse-version 33 >= ;
26 : sse4.1? ( -- ? ) sse-version 41 >= ;
27 : sse4.2? ( -- ? ) sse-version 42 >= ;
29 : sse-string ( version -- string )
40 HOOK: instruction-count cpu ( -- n )
42 M: x86 instruction-count read_timestamp_counter ;
44 : count-instructions ( quot -- n )
45 instruction-count [ call ] dip instruction-count swap - ; inline