56
56
57
57
module core.cpuid ;
58
58
59
+ version (GNU ) version = GNU_OR_LDC ;
60
+ version (LDC ) version = GNU_OR_LDC ;
61
+
59
62
@trusted :
60
63
nothrow :
61
64
@nogc :
@@ -426,7 +429,7 @@ CpuFeatures* getCpuFeatures() @nogc nothrow
426
429
}
427
430
428
431
429
- version (GNU ) {
432
+ version (GNU_OR_LDC ) {
430
433
version (X86 )
431
434
enum supportedX86 = true ;
432
435
else version (X86_64 )
@@ -509,7 +512,7 @@ void getcacheinfoCPUID2()
509
512
// for old single-core CPUs.
510
513
uint numinfos = 1 ;
511
514
do {
512
- version (GNU ) asm pure nothrow @nogc {
515
+ version (GNU_OR_LDC ) asm pure nothrow @nogc {
513
516
" cpuid" : " =a" (a[0 ]), " =b" (a[1 ]), " =c" (a[2 ]), " =d" (a[3 ]) : " a" (2 );
514
517
} else asm pure nothrow @nogc {
515
518
mov EAX , 2 ;
@@ -553,7 +556,7 @@ void getcacheinfoCPUID4()
553
556
int cachenum = 0 ;
554
557
for (;;) {
555
558
uint a, b, number_of_sets;
556
- version (GNU ) asm pure nothrow @nogc {
559
+ version (GNU_OR_LDC ) asm pure nothrow @nogc {
557
560
" cpuid" : " =a" (a), " =b" (b), " =c" (number_of_sets) : " a" (4 ), " c" (cachenum) : " edx" ;
558
561
} else asm pure nothrow @nogc {
559
562
mov EAX , 4 ;
@@ -593,7 +596,7 @@ void getcacheinfoCPUID4()
593
596
void getAMDcacheinfo ()
594
597
{
595
598
uint dummy, c5, c6, d6;
596
- version (GNU ) asm pure nothrow @nogc {
599
+ version (GNU_OR_LDC ) asm pure nothrow @nogc {
597
600
" cpuid" : " =a" (dummy), " =c" (c5) : " a" (0x8000_0005) : " ebx" , " edx" ;
598
601
} else asm pure nothrow @nogc {
599
602
mov EAX , 0x8000_0005; // L1 cache
@@ -612,7 +615,7 @@ void getAMDcacheinfo()
612
615
// AMD K6-III or K6-2+ or later.
613
616
ubyte numcores = 1 ;
614
617
if (max_extended_cpuid >= 0x8000_0008) {
615
- version (GNU ) asm pure nothrow @nogc {
618
+ version (GNU_OR_LDC ) asm pure nothrow @nogc {
616
619
" cpuid" : " =a" (dummy), " =c" (numcores) : " a" (0x8000_0008) : " ebx" , " edx" ;
617
620
} else asm pure nothrow @nogc {
618
621
mov EAX , 0x8000_0008;
@@ -623,7 +626,7 @@ void getAMDcacheinfo()
623
626
if (numcores> cpuFeatures.maxCores) cpuFeatures.maxCores = numcores;
624
627
}
625
628
626
- version (GNU ) asm pure nothrow @nogc {
629
+ version (GNU_OR_LDC ) asm pure nothrow @nogc {
627
630
" cpuid" : " =a" (dummy), " =c" (c6), " =d" (d6) : " a" (0x8000_0006) : " ebx" ;
628
631
} else asm pure nothrow @nogc {
629
632
mov EAX , 0x8000_0006; // L2/L3 cache
@@ -652,7 +655,7 @@ void getCpuInfo0B()
652
655
int threadsPerCore;
653
656
uint a, b, c, d;
654
657
do {
655
- version (GNU ) asm pure nothrow @nogc {
658
+ version (GNU_OR_LDC ) asm pure nothrow @nogc {
656
659
" cpuid" : " =a" (a), " =b" (b), " =c" (c), " =d" (d) : " a" (0x0B ), " c" (level);
657
660
} else asm pure nothrow @nogc {
658
661
mov EAX , 0x0B ;
@@ -684,7 +687,7 @@ void cpuidX86()
684
687
685
688
uint a, b, c, d;
686
689
uint * venptr = cast (uint * )cf.vendorID.ptr;
687
- version (GNU )
690
+ version (GNU_OR_LDC )
688
691
{
689
692
asm pure nothrow @nogc {
690
693
" cpuid" : " =a" (max_cpuid), " =b" (venptr[0 ]), " =d" (venptr[1 ]), " =c" (venptr[2 ]) : " a" (0 );
@@ -731,7 +734,7 @@ void cpuidX86()
731
734
cf.probablyIntel = cf.vendorID == " GenuineIntel" ;
732
735
cf.probablyAMD = (cf.vendorID == " AuthenticAMD" || cf.vendorID == " HygonGenuine" );
733
736
uint apic = 0 ; // brand index, apic id
734
- version (GNU ) asm pure nothrow @nogc {
737
+ version (GNU_OR_LDC ) asm pure nothrow @nogc {
735
738
" cpuid" : " =a" (a), " =b" (apic), " =c" (cf.miscfeatures), " =d" (cf.features) : " a" (1 );
736
739
} else {
737
740
asm pure nothrow @nogc {
@@ -754,7 +757,7 @@ void cpuidX86()
754
757
755
758
if (max_cpuid >= 7 )
756
759
{
757
- version (GNU ) asm pure nothrow @nogc {
760
+ version (GNU_OR_LDC ) asm pure nothrow @nogc {
758
761
" cpuid" : " =a" (a), " =b" (cf.extfeatures), " =c" (c) : " a" (7 ), " c" (0 ) : " edx" ;
759
762
} else {
760
763
uint ext;
@@ -770,7 +773,7 @@ void cpuidX86()
770
773
771
774
if (cf.miscfeatures & OSXSAVE_BIT )
772
775
{
773
- version (GNU ) asm pure nothrow @nogc {
776
+ version (GNU_OR_LDC ) asm pure nothrow @nogc {
774
777
" xgetbv" : " =a" (a), " =d" (d) : " c" (0 );
775
778
} else asm pure nothrow @nogc {
776
779
mov ECX , 0 ;
@@ -784,7 +787,7 @@ void cpuidX86()
784
787
cf.amdfeatures = 0 ;
785
788
cf.amdmiscfeatures = 0 ;
786
789
if (max_extended_cpuid >= 0x8000_0001) {
787
- version (GNU ) asm pure nothrow @nogc {
790
+ version (GNU_OR_LDC ) asm pure nothrow @nogc {
788
791
" cpuid" : " =a" (a), " =c" (cf.amdmiscfeatures), " =d" (cf.amdfeatures) : " a" (0x8000_0001) : " ebx" ;
789
792
} else {
790
793
asm pure nothrow @nogc {
@@ -805,7 +808,7 @@ void cpuidX86()
805
808
cf.maxCores = 1 ;
806
809
if (hyperThreadingBit) {
807
810
// determine max number of cores for AMD
808
- version (GNU ) asm pure nothrow @nogc {
811
+ version (GNU_OR_LDC ) asm pure nothrow @nogc {
809
812
" cpuid" : " =a" (a), " =c" (c) : " a" (0x8000_0008) : " ebx" , " edx" ;
810
813
} else asm pure nothrow @nogc {
811
814
mov EAX , 0x8000_0008;
@@ -818,7 +821,7 @@ void cpuidX86()
818
821
819
822
if (max_extended_cpuid >= 0x8000_0004) {
820
823
uint * pnb = cast (uint * )cf.processorNameBuffer.ptr;
821
- version (GNU )
824
+ version (GNU_OR_LDC )
822
825
{
823
826
asm pure nothrow @nogc {
824
827
" cpuid" : " =a" (pnb[0 ]), " =b" (pnb[1 ]), " =c" (pnb[ 2 ]), " =d" (pnb[ 3 ]) : " a" (0x8000_0002);
@@ -950,7 +953,7 @@ void cpuidX86()
950
953
else cf.maxThreads = cf.maxCores;
951
954
952
955
if (cf.probablyAMD && max_extended_cpuid >= 0x8000_001E) {
953
- version (GNU ) asm pure nothrow @nogc {
956
+ version (GNU_OR_LDC ) asm pure nothrow @nogc {
954
957
" cpuid" : " =a" a, " =b" b : " a" 0x8000_001E : " ecx" , " edx" ;
955
958
} else {
956
959
asm pure nothrow @nogc {
0 commit comments