cpu.x86: Use bit-range, don't call cpuid so many times
parent
2735d3a5d7
commit
d196f8f141
|
@ -93,18 +93,31 @@ HOOK: (cpuid) cpu ( rax rcx regs -- )
|
||||||
|
|
||||||
: cpuid ( rax -- 4array ) 0 cpuid-extended ;
|
: cpuid ( rax -- 4array ) 0 cpuid-extended ;
|
||||||
|
|
||||||
: cpu-stepping ( -- n ) 1 cpuid first 4 bits ;
|
: cpuid-processor-info ( -- eax ) 1 cpuid first ; inline
|
||||||
: cpu-model ( -- n ) 1 cpuid first -4 shift 4 bits ;
|
|
||||||
: cpu-family ( -- n ) 1 cpuid first -8 shift 4 bits ;
|
: parse-stepping ( eax -- n ) 3 0 bit-range ; inline
|
||||||
: cpu-processor-type ( -- n ) 1 cpuid first -12 shift 2 bits ;
|
: parse-model ( eax -- n ) 7 4 bit-range ; inline
|
||||||
: cpu-extended-model ( -- n ) 1 cpuid first -16 shift 4 bits ;
|
: parse-family ( eax -- n ) 11 8 bit-range ; inline
|
||||||
: cpu-extended-family ( -- n ) 1 cpuid first -20 shift 8 bits ;
|
: parse-processor-type ( eax -- n ) 13 12 bit-range ; inline
|
||||||
|
: parse-extended-model ( eax -- n ) 19 16 bit-range ; inline
|
||||||
|
: parse-extended-family ( eax -- n ) 27 20 bit-range ; inline
|
||||||
|
|
||||||
|
: cpu-stepping ( -- n ) cpuid-processor-info parse-stepping ;
|
||||||
|
: cpu-model ( -- n ) cpuid-processor-info parse-model ;
|
||||||
|
: cpu-family ( -- n ) cpuid-processor-info parse-family ;
|
||||||
|
: cpu-processor-type ( -- n ) cpuid-processor-info parse-processor-type ;
|
||||||
|
: cpu-extended-model ( -- n ) cpuid-processor-info parse-extended-model ;
|
||||||
|
: cpu-extended-family ( -- n ) cpuid-processor-info parse-extended-family ;
|
||||||
|
|
||||||
: cpu-family-model-string ( -- string )
|
: cpu-family-model-string ( -- string )
|
||||||
[
|
[
|
||||||
cpu-extended-family cpu-family [ >hex ] bi@
|
cpuid-processor-info {
|
||||||
"_"
|
[ parse-extended-family >hex ]
|
||||||
cpu-extended-model cpu-model [ >hex ] bi@
|
[ parse-family >hex ]
|
||||||
|
[ drop "_" ]
|
||||||
|
[ parse-extended-model >hex ]
|
||||||
|
[ parse-model >hex ]
|
||||||
|
} cleave
|
||||||
] "" append-outputs-as ;
|
] "" append-outputs-as ;
|
||||||
|
|
||||||
: popcnt? ( -- ? )
|
: popcnt? ( -- ? )
|
||||||
|
|
Loading…
Reference in New Issue