cpu.x86.features: Add some words to check cpu features. Replace alien-assembly popcnt? instruction with general cpuid one.
parent
1897f5fb4a
commit
de52d96d93
|
@ -4,7 +4,7 @@ USING: alien alien.c-types arrays assocs combinators
|
||||||
compiler.codegen.labels cpu.architecture cpu.x86.assembler
|
compiler.codegen.labels cpu.architecture cpu.x86.assembler
|
||||||
cpu.x86.assembler.operands init kernel math math.order
|
cpu.x86.assembler.operands init kernel math math.order
|
||||||
math.parser memoize namespaces sequences
|
math.parser memoize namespaces sequences
|
||||||
specialized-arrays system ;
|
specialized-arrays system math.bitwise combinators.smart ;
|
||||||
SPECIALIZED-ARRAY: uint
|
SPECIALIZED-ARRAY: uint
|
||||||
IN: cpu.x86.features
|
IN: cpu.x86.features
|
||||||
|
|
||||||
|
@ -90,14 +90,32 @@ HOOK: (cpuid) cpu ( n regs -- )
|
||||||
: cpuid ( n -- 4array )
|
: cpuid ( n -- 4array )
|
||||||
4 <uint-array> [ (cpuid) ] keep >array ;
|
4 <uint-array> [ (cpuid) ] keep >array ;
|
||||||
|
|
||||||
: popcnt? ( -- ? )
|
: cpu-stepping ( -- n ) 1 cpuid first 4 bits ;
|
||||||
bool { } cdecl [
|
: cpu-model ( -- n ) 1 cpuid first -4 shift 4 bits ;
|
||||||
return-reg 1 MOV
|
: cpu-family ( -- n ) 1 cpuid first -8 shift 4 bits ;
|
||||||
CPUID
|
: cpu-processor-type ( -- n ) 1 cpuid first -12 shift 2 bits ;
|
||||||
return-reg dup XOR
|
: cpu-extended-model ( -- n ) 1 cpuid first -16 shift 4 bits ;
|
||||||
ECX 23 BT
|
: cpu-extended-family ( -- n ) 1 cpuid first -20 shift 8 bits ;
|
||||||
return-reg SETB
|
|
||||||
] alien-assembly ;
|
: cpu-family-model-string ( -- string )
|
||||||
|
[
|
||||||
|
cpu-extended-family cpu-family [ >hex ] bi@
|
||||||
|
"_"
|
||||||
|
cpu-extended-model cpu-model [ >hex ] bi@
|
||||||
|
] "" append-outputs-as ;
|
||||||
|
|
||||||
|
: popcnt? ( -- ? ) 1 cpuid third 23 bit? ;
|
||||||
|
: tscdeadline? ( -- ? ) 1 cpuid third 24 bit? ;
|
||||||
|
: aes? ( -- ? ) 1 cpuid third 25 bit? ;
|
||||||
|
: xsave? ( -- ? ) 1 cpuid third 26 bit? ;
|
||||||
|
: osxsave? ( -- ? ) 1 cpuid third 27 bit? ;
|
||||||
|
: avx? ( -- ? ) 1 cpuid third 28 bit? ;
|
||||||
|
: f16c? ( -- ? ) 1 cpuid third 29 bit? ;
|
||||||
|
: rdrnd? ( -- ? ) 1 cpuid third 30 bit? ;
|
||||||
|
|
||||||
|
: msr? ( -- ? ) 1 cpuid fourth 5 bit? ;
|
||||||
|
: tm1? ( -- ? ) 1 cpuid fourth 29 bit? ;
|
||||||
|
: tm2? ( -- ? ) 1 cpuid third 8 bit? ;
|
||||||
|
|
||||||
MEMO: enable-popcnt? ( -- ? )
|
MEMO: enable-popcnt? ( -- ? )
|
||||||
popcnt? "disable-popcnt" get not and ;
|
popcnt? "disable-popcnt" get not and ;
|
||||||
|
|
Loading…
Reference in New Issue