-
Notifications
You must be signed in to change notification settings - Fork 392
/
OMRCPU.cpp
715 lines (646 loc) · 28 KB
/
OMRCPU.cpp
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
141
142
143
144
145
146
147
148
149
150
151
152
153
154
155
156
157
158
159
160
161
162
163
164
165
166
167
168
169
170
171
172
173
174
175
176
177
178
179
180
181
182
183
184
185
186
187
188
189
190
191
192
193
194
195
196
197
198
199
200
201
202
203
204
205
206
207
208
209
210
211
212
213
214
215
216
217
218
219
220
221
222
223
224
225
226
227
228
229
230
231
232
233
234
235
236
237
238
239
240
241
242
243
244
245
246
247
248
249
250
251
252
253
254
255
256
257
258
259
260
261
262
263
264
265
266
267
268
269
270
271
272
273
274
275
276
277
278
279
280
281
282
283
284
285
286
287
288
289
290
291
292
293
294
295
296
297
298
299
300
301
302
303
304
305
306
307
308
309
310
311
312
313
314
315
316
317
318
319
320
321
322
323
324
325
326
327
328
329
330
331
332
333
334
335
336
337
338
339
340
341
342
343
344
345
346
347
348
349
350
351
352
353
354
355
356
357
358
359
360
361
362
363
364
365
366
367
368
369
370
371
372
373
374
375
376
377
378
379
380
381
382
383
384
385
386
387
388
389
390
391
392
393
394
395
396
397
398
399
400
401
402
403
404
405
406
407
408
409
410
411
412
413
414
415
416
417
418
419
420
421
422
423
424
425
426
427
428
429
430
431
432
433
434
435
436
437
438
439
440
441
442
443
444
445
446
447
448
449
450
451
452
453
454
455
456
457
458
459
460
461
462
463
464
465
466
467
468
469
470
471
472
473
474
475
476
477
478
479
480
481
482
483
484
485
486
487
488
489
490
491
492
493
494
495
496
497
498
499
500
501
502
503
504
505
506
507
508
509
510
511
512
513
514
515
516
517
518
519
520
521
522
523
524
525
526
527
528
529
530
531
532
533
534
535
536
537
538
539
540
541
542
543
544
545
546
547
548
549
550
551
552
553
554
555
556
557
558
559
560
561
562
563
564
565
566
567
568
569
570
571
572
573
574
575
576
577
578
579
580
581
582
583
584
585
586
587
588
589
590
591
592
593
594
595
596
597
598
599
600
601
602
603
604
605
606
607
608
609
610
611
612
613
614
615
616
617
618
619
620
621
622
623
624
625
626
627
628
629
630
631
632
633
634
635
636
637
638
639
640
641
642
643
644
645
646
647
648
649
650
651
652
653
654
655
656
657
658
659
660
661
662
663
664
665
666
667
668
669
670
671
672
673
674
675
676
677
678
679
680
681
682
683
684
685
686
687
688
689
690
691
692
693
694
695
696
697
698
699
700
701
702
703
704
705
706
707
708
709
710
711
712
713
714
715
/*******************************************************************************
* Copyright IBM Corp. and others 2000
*
* This program and the accompanying materials are made available under
* the terms of the Eclipse Public License 2.0 which accompanies this
* distribution and is available at https://www.eclipse.org/legal/epl-2.0/
* or the Apache License, Version 2.0 which accompanies this distribution
* and is available at https://www.apache.org/licenses/LICENSE-2.0.
*
* This Source Code may also be made available under the following Secondary
* Licenses when the conditions for such availability set forth in the
* Eclipse Public License, v. 2.0 are satisfied: GNU General Public License,
* version 2 with the GNU Classpath Exception [1] and GNU General Public
* License, version 2 with the OpenJDK Assembly Exception [2].
*
* [1] https://www.gnu.org/software/classpath/license.html
* [2] https://openjdk.org/legal/assembly-exception.html
*
* SPDX-License-Identifier: EPL-2.0 OR Apache-2.0 OR GPL-2.0-only WITH Classpath-exception-2.0 OR GPL-2.0-only WITH OpenJDK-assembly-exception-1.0
*******************************************************************************/
#include <stdlib.h>
#include <string.h>
#include "env/CPU.hpp"
#include "env/CompilerEnv.hpp"
#include "env/JitConfig.hpp"
#include "env/ProcessorInfo.hpp"
#include "infra/Flags.hpp"
#include "x/runtime/X86Runtime.hpp"
#include "codegen/CodeGenerator.hpp"
TR::CPU
OMR::X86::CPU::detect(OMRPortLibrary * const omrPortLib)
{
if (omrPortLib == NULL)
return TR::CPU();
// Only enable the features that compiler currently uses
uint32_t const enabledFeatures [] = {OMR_FEATURE_X86_FPU, OMR_FEATURE_X86_CX8, OMR_FEATURE_X86_CMOV,
OMR_FEATURE_X86_MMX, OMR_FEATURE_X86_SSE, OMR_FEATURE_X86_SSE2,
OMR_FEATURE_X86_SSSE3, OMR_FEATURE_X86_SSE4_1, OMR_FEATURE_X86_SSE4_2,
OMR_FEATURE_X86_POPCNT, OMR_FEATURE_X86_AESNI, OMR_FEATURE_X86_OSXSAVE,
OMR_FEATURE_X86_AVX, OMR_FEATURE_X86_AVX2, OMR_FEATURE_X86_FMA, OMR_FEATURE_X86_HLE,
OMR_FEATURE_X86_RTM, OMR_FEATURE_X86_AVX512F, OMR_FEATURE_X86_AVX512VL,
OMR_FEATURE_X86_AVX512BW, OMR_FEATURE_X86_AVX512DQ, OMR_FEATURE_X86_AVX512CD,
OMR_FEATURE_X86_AVX512_VBMI2, OMR_FEATURE_X86_AVX512_VPOPCNTDQ,
OMR_FEATURE_X86_AVX512_BITALG, OMR_FEATURE_X86_CLWB,
};
OMRPORT_ACCESS_FROM_OMRPORT(omrPortLib);
OMRProcessorDesc featureMasks;
memset(featureMasks.features, 0, OMRPORT_SYSINFO_FEATURES_SIZE*sizeof(uint32_t));
for (size_t i = 0; i < sizeof(enabledFeatures)/sizeof(uint32_t); i++)
{
omrsysinfo_processor_set_feature(&featureMasks, enabledFeatures[i], TRUE);
}
OMRProcessorDesc processorDescription;
omrsysinfo_get_processor_description(&processorDescription);
for (size_t i = 0; i < OMRPORT_SYSINFO_FEATURES_SIZE; i++)
{
processorDescription.features[i] &= featureMasks.features[i];
}
if (TRUE == omrsysinfo_processor_has_feature(&processorDescription, OMR_FEATURE_X86_OSXSAVE))
{
static const bool disableAVX = feGetEnv("TR_DisableAVX") != NULL;
if (((6 & _xgetbv(0)) != 6) || disableAVX) // '6' = mask for XCR0[2:1]='11b' (XMM state and YMM state are enabled)
{
// Unset OSXSAVE if not enabled via CR0
omrsysinfo_processor_set_feature(&processorDescription, OMR_FEATURE_X86_OSXSAVE, FALSE);
}
}
return TR::CPU(processorDescription);
}
void
OMR::X86::CPU::initializeTargetProcessorInfo(bool force)
{
OMR::X86::CodeGenerator::initializeX86TargetProcessorInfo(force);
}
TR_X86CPUIDBuffer *
OMR::X86::CPU::queryX86TargetCPUID()
{
static TR_X86CPUIDBuffer *buf = NULL;
if (!buf)
{
buf = reinterpret_cast<TR_X86CPUIDBuffer *>(malloc(sizeof(TR_X86CPUIDBuffer)));
if (!buf)
return NULL;
jitGetCPUID(buf);
}
return buf;
}
const char *
OMR::X86::CPU::getX86ProcessorVendorId()
{
static char buf[13];
// Terminate the vendor ID with NULL before returning.
//
strncpy(buf, self()->queryX86TargetCPUID()->_vendorId, 12);
buf[12] = '\0';
return buf;
}
uint32_t
OMR::X86::CPU::getX86ProcessorSignature()
{
return self()->queryX86TargetCPUID()->_processorSignature;
}
uint32_t
OMR::X86::CPU::getX86ProcessorFeatureFlags()
{
if (TR::Compiler->omrPortLib == NULL)
return self()->queryX86TargetCPUID()->_featureFlags;
return self()->_processorDescription.features[0];
}
uint32_t
OMR::X86::CPU::getX86ProcessorFeatureFlags2()
{
if (TR::Compiler->omrPortLib == NULL)
return self()->queryX86TargetCPUID()->_featureFlags2;
return self()->_processorDescription.features[1];
}
uint32_t
OMR::X86::CPU::getX86ProcessorFeatureFlags8()
{
if (TR::Compiler->omrPortLib == NULL)
return self()->queryX86TargetCPUID()->_featureFlags8;
return self()->_processorDescription.features[3];
}
uint32_t
OMR::X86::CPU::getX86ProcessorFeatureFlags10()
{
if (TR::Compiler->omrPortLib == NULL)
return self()->queryX86TargetCPUID()->_featureFlags10;
return self()->_processorDescription.features[4];
}
bool
OMR::X86::CPU::getSupportsHardwareSQRT()
{
return true;
}
bool
OMR::X86::CPU::supportsTransactionalMemoryInstructions()
{
return self()->supportsFeature(OMR_FEATURE_X86_RTM);
}
bool
OMR::X86::CPU::isGenuineIntel()
{
if (TR::Compiler->omrPortLib == NULL)
return TR::CodeGenerator::getX86ProcessorInfo().isGenuineIntel();
return self()->isAtLeast(OMR_PROCESSOR_X86_INTEL_FIRST) && self()->isAtMost(OMR_PROCESSOR_X86_INTEL_LAST);
}
bool
OMR::X86::CPU::isAuthenticAMD()
{
if (TR::Compiler->omrPortLib == NULL)
return TR::CodeGenerator::getX86ProcessorInfo().isAuthenticAMD();
return self()->isAtLeast(OMR_PROCESSOR_X86_AMD_FIRST) && self()->isAtMost(OMR_PROCESSOR_X86_AMD_LAST);
}
bool
OMR::X86::CPU::requiresLFence()
{
return false; /* Dummy for now, we may need TR::InstOpCode::LFENCE in future processors*/
}
bool
OMR::X86::CPU::supportsMFence()
{
if (TR::Compiler->omrPortLib == NULL)
return TR::CodeGenerator::getX86ProcessorInfo().supportsMFence();
return self()->supportsFeature(OMR_FEATURE_X86_SSE2);
}
bool
OMR::X86::CPU::supportsLFence()
{
if (TR::Compiler->omrPortLib == NULL)
return TR::CodeGenerator::getX86ProcessorInfo().supportsLFence();
return self()->supportsFeature(OMR_FEATURE_X86_SSE2);
}
bool
OMR::X86::CPU::supportsSFence()
{
if (TR::Compiler->omrPortLib == NULL)
return TR::CodeGenerator::getX86ProcessorInfo().supportsSFence();
return self()->supportsFeature(OMR_FEATURE_X86_SSE2) || self()->supportsFeature(OMR_FEATURE_X86_MMX);
}
bool
OMR::X86::CPU::prefersMultiByteNOP()
{
if (TR::Compiler->omrPortLib == NULL)
return TR::CodeGenerator::getX86ProcessorInfo().prefersMultiByteNOP();
return self()->isGenuineIntel() && !self()->is(OMR_PROCESSOR_X86_INTELPENTIUM);
}
bool
OMR::X86::CPU::supportsAVX()
{
if (TR::Compiler->omrPortLib == NULL)
return TR::CodeGenerator::getX86ProcessorInfo().supportsAVX();
return self()->supportsFeature(OMR_FEATURE_X86_AVX) && self()->supportsFeature(OMR_FEATURE_X86_OSXSAVE);
}
bool
OMR::X86::CPU::is(OMRProcessorArchitecture p)
{
if (TR::Compiler->omrPortLib == NULL)
return self()->is_old_api(p);
static bool disableOldVersionCPUDetectionTest = feGetEnv("TR_DisableOldVersionCPUDetectionTest") != NULL;
if (!disableOldVersionCPUDetectionTest)
TR_ASSERT_FATAL(self()->is_test(p), "old api and new api did not match, processor %d", p);
return _processorDescription.processor == p;
}
bool
OMR::X86::CPU::supportsFeature(uint32_t feature)
{
if (TR::Compiler->omrPortLib == NULL)
return self()->supports_feature_old_api(feature);
static bool disableOldVersionCPUDetectionTest = feGetEnv("TR_DisableOldVersionCPUDetectionTest") != NULL;
if (!disableOldVersionCPUDetectionTest)
TR_ASSERT_FATAL(self()->supports_feature_test(feature), "old api and new api did not match, feature %d", feature);
OMRPORT_ACCESS_FROM_OMRPORT(TR::Compiler->omrPortLib);
return TRUE == omrsysinfo_processor_has_feature(&_processorDescription, feature);
}
bool
OMR::X86::CPU::is_test(OMRProcessorArchitecture p)
{
switch(p)
{
case OMR_PROCESSOR_X86_INTELWESTMERE:
return TR::CodeGenerator::getX86ProcessorInfo().isIntelWestmere() == (_processorDescription.processor == p);
case OMR_PROCESSOR_X86_INTELNEHALEM:
return TR::CodeGenerator::getX86ProcessorInfo().isIntelNehalem() == (_processorDescription.processor == p);
case OMR_PROCESSOR_X86_INTELPENTIUM:
return TR::CodeGenerator::getX86ProcessorInfo().isIntelPentium() == (_processorDescription.processor == p);
case OMR_PROCESSOR_X86_INTELP6:
return TR::CodeGenerator::getX86ProcessorInfo().isIntelP6() == (_processorDescription.processor == p);
case OMR_PROCESSOR_X86_INTELPENTIUM4:
return TR::CodeGenerator::getX86ProcessorInfo().isIntelPentium4() == (_processorDescription.processor == p);
case OMR_PROCESSOR_X86_INTELCORE2:
return TR::CodeGenerator::getX86ProcessorInfo().isIntelCore2() == (_processorDescription.processor == p);
case OMR_PROCESSOR_X86_INTELTULSA:
return TR::CodeGenerator::getX86ProcessorInfo().isIntelTulsa() == (_processorDescription.processor == p);
case OMR_PROCESSOR_X86_INTELSANDYBRIDGE:
return TR::CodeGenerator::getX86ProcessorInfo().isIntelSandyBridge() == (_processorDescription.processor == p);
case OMR_PROCESSOR_X86_INTELIVYBRIDGE:
return TR::CodeGenerator::getX86ProcessorInfo().isIntelIvyBridge() == (_processorDescription.processor == p);
case OMR_PROCESSOR_X86_INTELHASWELL:
return TR::CodeGenerator::getX86ProcessorInfo().isIntelHaswell() == (_processorDescription.processor == p);
case OMR_PROCESSOR_X86_INTELBROADWELL:
return TR::CodeGenerator::getX86ProcessorInfo().isIntelBroadwell() == (_processorDescription.processor == p);
case OMR_PROCESSOR_X86_INTELSKYLAKE:
return TR::CodeGenerator::getX86ProcessorInfo().isIntelSkylake() == (_processorDescription.processor == p);
case OMR_PROCESSOR_X86_AMDATHLONDURON:
return TR::CodeGenerator::getX86ProcessorInfo().isAMDAthlonDuron() == (_processorDescription.processor == p);
case OMR_PROCESSOR_X86_AMDOPTERON:
return TR::CodeGenerator::getX86ProcessorInfo().isAMDOpteron() == (_processorDescription.processor == p);
case OMR_PROCESSOR_X86_AMDFAMILY15H:
return TR::CodeGenerator::getX86ProcessorInfo().isAMD15h() == (_processorDescription.processor == p);
default:
return false;
}
return false;
}
bool
OMR::X86::CPU::supports_feature_test(uint32_t feature)
{
OMRPORT_ACCESS_FROM_OMRPORT(TR::Compiler->omrPortLib);
bool ans = (TRUE == omrsysinfo_processor_has_feature(&_processorDescription, feature));
switch(feature)
{
case OMR_FEATURE_X86_OSXSAVE:
return TR::CodeGenerator::getX86ProcessorInfo().enabledXSAVE() == ans;
case OMR_FEATURE_X86_FPU:
return TR::CodeGenerator::getX86ProcessorInfo().hasBuiltInFPU() == ans;
case OMR_FEATURE_X86_VME:
return TR::CodeGenerator::getX86ProcessorInfo().supportsVirtualModeExtension() == ans;
case OMR_FEATURE_X86_DE:
return TR::CodeGenerator::getX86ProcessorInfo().supportsDebuggingExtension() == ans;
case OMR_FEATURE_X86_PSE:
return TR::CodeGenerator::getX86ProcessorInfo().supportsPageSizeExtension() == ans;
case OMR_FEATURE_X86_TSC:
return TR::CodeGenerator::getX86ProcessorInfo().supportsRDTSCInstruction() == ans;
case OMR_FEATURE_X86_MSR:
return TR::CodeGenerator::getX86ProcessorInfo().hasModelSpecificRegisters() == ans;
case OMR_FEATURE_X86_PAE:
return TR::CodeGenerator::getX86ProcessorInfo().supportsPhysicalAddressExtension() == ans;
case OMR_FEATURE_X86_MCE:
return TR::CodeGenerator::getX86ProcessorInfo().supportsMachineCheckException() == ans;
case OMR_FEATURE_X86_CX8:
return TR::CodeGenerator::getX86ProcessorInfo().supportsCMPXCHG8BInstruction() == ans;
case OMR_FEATURE_X86_CMPXCHG16B:
return TR::CodeGenerator::getX86ProcessorInfo().supportsCMPXCHG16BInstruction() == ans;
case OMR_FEATURE_X86_APIC:
return TR::CodeGenerator::getX86ProcessorInfo().hasAPICHardware() == ans;
case OMR_FEATURE_X86_MTRR:
return TR::CodeGenerator::getX86ProcessorInfo().hasMemoryTypeRangeRegisters() == ans;
case OMR_FEATURE_X86_PGE:
return TR::CodeGenerator::getX86ProcessorInfo().supportsPageGlobalFlag() == ans;
case OMR_FEATURE_X86_MCA:
return TR::CodeGenerator::getX86ProcessorInfo().hasMachineCheckArchitecture() == ans;
case OMR_FEATURE_X86_CMOV:
return TR::CodeGenerator::getX86ProcessorInfo().supportsCMOVInstructions() == ans;
case OMR_FEATURE_X86_PAT:
return TR::CodeGenerator::getX86ProcessorInfo().hasPageAttributeTable() == ans;
case OMR_FEATURE_X86_PSE_36:
return TR::CodeGenerator::getX86ProcessorInfo().has36BitPageSizeExtension() == ans;
case OMR_FEATURE_X86_PSN:
return TR::CodeGenerator::getX86ProcessorInfo().hasProcessorSerialNumber() == ans;
case OMR_FEATURE_X86_CLFSH:
return TR::CodeGenerator::getX86ProcessorInfo().supportsCLFLUSHInstruction() == ans;
case OMR_FEATURE_X86_CLWB:
return TR::CodeGenerator::getX86ProcessorInfo().supportsCLWBInstruction() == ans;
case OMR_FEATURE_X86_DS:
return TR::CodeGenerator::getX86ProcessorInfo().supportsDebugTraceStore() == ans;
case OMR_FEATURE_X86_ACPI:
return TR::CodeGenerator::getX86ProcessorInfo().hasACPIRegisters() == ans;
case OMR_FEATURE_X86_MMX:
return TR::CodeGenerator::getX86ProcessorInfo().supportsMMXInstructions() == ans;
case OMR_FEATURE_X86_FXSR:
return TR::CodeGenerator::getX86ProcessorInfo().supportsFastFPSavesRestores() == ans;
case OMR_FEATURE_X86_SSE:
return TR::CodeGenerator::getX86ProcessorInfo().supportsSSE() == ans;
case OMR_FEATURE_X86_SSE2:
return TR::CodeGenerator::getX86ProcessorInfo().supportsSSE2() == ans;
case OMR_FEATURE_X86_SSE3:
return TR::CodeGenerator::getX86ProcessorInfo().supportsSSE3() == ans;
case OMR_FEATURE_X86_SSSE3:
return TR::CodeGenerator::getX86ProcessorInfo().supportsSSSE3() == ans;
case OMR_FEATURE_X86_SSE4_1:
return TR::CodeGenerator::getX86ProcessorInfo().supportsSSE4_1() == ans;
case OMR_FEATURE_X86_SSE4_2:
return TR::CodeGenerator::getX86ProcessorInfo().supportsSSE4_2() == ans;
case OMR_FEATURE_X86_PCLMULQDQ:
return TR::CodeGenerator::getX86ProcessorInfo().supportsCLMUL() == ans;
case OMR_FEATURE_X86_AESNI:
return TR::CodeGenerator::getX86ProcessorInfo().supportsAESNI() == ans;
case OMR_FEATURE_X86_POPCNT:
return TR::CodeGenerator::getX86ProcessorInfo().supportsPOPCNT() == ans;
case OMR_FEATURE_X86_SS:
return TR::CodeGenerator::getX86ProcessorInfo().supportsSelfSnoop() == ans;
case OMR_FEATURE_X86_RTM:
return TR::CodeGenerator::getX86ProcessorInfo().supportsTM() == ans;
case OMR_FEATURE_X86_HTT:
return TR::CodeGenerator::getX86ProcessorInfo().supportsHyperThreading() == ans;
case OMR_FEATURE_X86_HLE:
return TR::CodeGenerator::getX86ProcessorInfo().supportsHLE() == ans;
case OMR_FEATURE_X86_TM:
return TR::CodeGenerator::getX86ProcessorInfo().hasThermalMonitor() == ans;
case OMR_FEATURE_X86_AVX:
return TR::CodeGenerator::getX86ProcessorInfo().supportsAVX() == ans;
case OMR_FEATURE_X86_AVX2:
return TR::CodeGenerator::getX86ProcessorInfo().supportsAVX2() == ans;
case OMR_FEATURE_X86_AVX512F:
return TR::CodeGenerator::getX86ProcessorInfo().supportsAVX512F() == ans;
case OMR_FEATURE_X86_AVX512VL:
return TR::CodeGenerator::getX86ProcessorInfo().supportsAVX512VL() == ans;
case OMR_FEATURE_X86_AVX512BW:
return TR::CodeGenerator::getX86ProcessorInfo().supportsAVX512BW() == ans;
case OMR_FEATURE_X86_AVX512DQ:
return TR::CodeGenerator::getX86ProcessorInfo().supportsAVX512DQ() == ans;
case OMR_FEATURE_X86_AVX512CD:
return TR::CodeGenerator::getX86ProcessorInfo().supportsAVX512CD() == ans;
case OMR_FEATURE_X86_AVX512_VBMI2:
return TR::CodeGenerator::getX86ProcessorInfo().supportsAVX512VBMI2() == ans;
case OMR_FEATURE_X86_AVX512_BITALG:
return TR::CodeGenerator::getX86ProcessorInfo().supportsAVX512BITALG() == ans;
case OMR_FEATURE_X86_AVX512_VPOPCNTDQ:
return TR::CodeGenerator::getX86ProcessorInfo().supportsAVX512VPOPCNTDQ() == ans;
case OMR_FEATURE_X86_FMA:
return TR::CodeGenerator::getX86ProcessorInfo().supportsFMA() == ans;
default:
return false;
}
return false;
}
bool
OMR::X86::CPU::is_old_api(OMRProcessorArchitecture p)
{
bool ans = false;
switch(p)
{
case OMR_PROCESSOR_X86_INTELWESTMERE:
ans = TR::CodeGenerator::getX86ProcessorInfo().isIntelWestmere();
break;
case OMR_PROCESSOR_X86_INTELNEHALEM:
ans = TR::CodeGenerator::getX86ProcessorInfo().isIntelNehalem();
break;
case OMR_PROCESSOR_X86_INTELPENTIUM:
ans = TR::CodeGenerator::getX86ProcessorInfo().isIntelPentium();
break;
case OMR_PROCESSOR_X86_INTELP6:
ans = TR::CodeGenerator::getX86ProcessorInfo().isIntelP6();
break;
case OMR_PROCESSOR_X86_INTELPENTIUM4:
ans = TR::CodeGenerator::getX86ProcessorInfo().isIntelPentium4();
break;
case OMR_PROCESSOR_X86_INTELCORE2:
ans = TR::CodeGenerator::getX86ProcessorInfo().isIntelCore2();
break;
case OMR_PROCESSOR_X86_INTELTULSA:
ans = TR::CodeGenerator::getX86ProcessorInfo().isIntelTulsa();
break;
case OMR_PROCESSOR_X86_INTELSANDYBRIDGE:
ans = TR::CodeGenerator::getX86ProcessorInfo().isIntelSandyBridge();
break;
case OMR_PROCESSOR_X86_INTELIVYBRIDGE:
ans = TR::CodeGenerator::getX86ProcessorInfo().isIntelIvyBridge();
break;
case OMR_PROCESSOR_X86_INTELHASWELL:
ans = TR::CodeGenerator::getX86ProcessorInfo().isIntelHaswell();
break;
case OMR_PROCESSOR_X86_INTELBROADWELL:
ans = TR::CodeGenerator::getX86ProcessorInfo().isIntelBroadwell();
break;
case OMR_PROCESSOR_X86_INTELSKYLAKE:
ans = TR::CodeGenerator::getX86ProcessorInfo().isIntelSkylake();
break;
case OMR_PROCESSOR_X86_AMDATHLONDURON:
ans = TR::CodeGenerator::getX86ProcessorInfo().isAMDAthlonDuron();
break;
case OMR_PROCESSOR_X86_AMDOPTERON:
ans = TR::CodeGenerator::getX86ProcessorInfo().isAMDOpteron();
break;
case OMR_PROCESSOR_X86_AMDFAMILY15H:
ans = TR::CodeGenerator::getX86ProcessorInfo().isAMD15h();
break;
default:
TR_ASSERT_FATAL(false, "Unknown processor %d", p);
break;
}
return ans;
}
bool
OMR::X86::CPU::supports_feature_old_api(uint32_t feature)
{
bool supported = false;
switch(feature)
{
case OMR_FEATURE_X86_OSXSAVE:
supported = TR::CodeGenerator::getX86ProcessorInfo().enabledXSAVE();
break;
case OMR_FEATURE_X86_FPU:
supported = TR::CodeGenerator::getX86ProcessorInfo().hasBuiltInFPU();
break;
case OMR_FEATURE_X86_VME:
supported = TR::CodeGenerator::getX86ProcessorInfo().supportsVirtualModeExtension();
break;
case OMR_FEATURE_X86_DE:
supported = TR::CodeGenerator::getX86ProcessorInfo().supportsDebuggingExtension();
break;
case OMR_FEATURE_X86_PSE:
supported = TR::CodeGenerator::getX86ProcessorInfo().supportsPageSizeExtension();
break;
case OMR_FEATURE_X86_TSC:
supported = TR::CodeGenerator::getX86ProcessorInfo().supportsRDTSCInstruction();
break;
case OMR_FEATURE_X86_MSR:
supported = TR::CodeGenerator::getX86ProcessorInfo().hasModelSpecificRegisters();
break;
case OMR_FEATURE_X86_PAE:
supported = TR::CodeGenerator::getX86ProcessorInfo().supportsPhysicalAddressExtension();
break;
case OMR_FEATURE_X86_MCE:
supported = TR::CodeGenerator::getX86ProcessorInfo().supportsMachineCheckException();
break;
case OMR_FEATURE_X86_CX8:
supported = TR::CodeGenerator::getX86ProcessorInfo().supportsCMPXCHG8BInstruction();
break;
case OMR_FEATURE_X86_CMPXCHG16B:
supported = TR::CodeGenerator::getX86ProcessorInfo().supportsCMPXCHG16BInstruction();
break;
case OMR_FEATURE_X86_APIC:
supported = TR::CodeGenerator::getX86ProcessorInfo().hasAPICHardware();
break;
case OMR_FEATURE_X86_MTRR:
supported = TR::CodeGenerator::getX86ProcessorInfo().hasMemoryTypeRangeRegisters();
break;
case OMR_FEATURE_X86_PGE:
supported = TR::CodeGenerator::getX86ProcessorInfo().supportsPageGlobalFlag();
break;
case OMR_FEATURE_X86_MCA:
supported = TR::CodeGenerator::getX86ProcessorInfo().hasMachineCheckArchitecture();
break;
case OMR_FEATURE_X86_CMOV:
supported = TR::CodeGenerator::getX86ProcessorInfo().supportsCMOVInstructions();
break;
case OMR_FEATURE_X86_PAT:
supported = TR::CodeGenerator::getX86ProcessorInfo().hasPageAttributeTable();
break;
case OMR_FEATURE_X86_PSE_36:
supported = TR::CodeGenerator::getX86ProcessorInfo().has36BitPageSizeExtension();
break;
case OMR_FEATURE_X86_PSN:
supported = TR::CodeGenerator::getX86ProcessorInfo().hasProcessorSerialNumber();
break;
case OMR_FEATURE_X86_CLFSH:
supported = TR::CodeGenerator::getX86ProcessorInfo().supportsCLFLUSHInstruction();
break;
case OMR_FEATURE_X86_DS:
supported = TR::CodeGenerator::getX86ProcessorInfo().supportsDebugTraceStore();
break;
case OMR_FEATURE_X86_ACPI:
supported = TR::CodeGenerator::getX86ProcessorInfo().hasACPIRegisters();
break;
case OMR_FEATURE_X86_MMX:
supported = TR::CodeGenerator::getX86ProcessorInfo().supportsMMXInstructions();
break;
case OMR_FEATURE_X86_FXSR:
supported = TR::CodeGenerator::getX86ProcessorInfo().supportsFastFPSavesRestores();
break;
case OMR_FEATURE_X86_SSE:
supported = TR::CodeGenerator::getX86ProcessorInfo().supportsSSE();
break;
case OMR_FEATURE_X86_SSE2:
supported = TR::CodeGenerator::getX86ProcessorInfo().supportsSSE2();
break;
case OMR_FEATURE_X86_SSE3:
supported = TR::CodeGenerator::getX86ProcessorInfo().supportsSSE3();
break;
case OMR_FEATURE_X86_SSSE3:
supported = TR::CodeGenerator::getX86ProcessorInfo().supportsSSSE3();
break;
case OMR_FEATURE_X86_SSE4_1:
supported = TR::CodeGenerator::getX86ProcessorInfo().supportsSSE4_1();
break;
case OMR_FEATURE_X86_SSE4_2:
supported = TR::CodeGenerator::getX86ProcessorInfo().supportsSSE4_2();
break;
case OMR_FEATURE_X86_PCLMULQDQ:
supported = TR::CodeGenerator::getX86ProcessorInfo().supportsCLMUL();
break;
case OMR_FEATURE_X86_AESNI:
supported = TR::CodeGenerator::getX86ProcessorInfo().supportsAESNI();
break;
case OMR_FEATURE_X86_POPCNT:
supported = TR::CodeGenerator::getX86ProcessorInfo().supportsPOPCNT();
break;
case OMR_FEATURE_X86_SS:
supported = TR::CodeGenerator::getX86ProcessorInfo().supportsSelfSnoop();
break;
case OMR_FEATURE_X86_RTM:
supported = TR::CodeGenerator::getX86ProcessorInfo().supportsTM();
break;
case OMR_FEATURE_X86_HTT:
supported = TR::CodeGenerator::getX86ProcessorInfo().supportsHyperThreading();
break;
case OMR_FEATURE_X86_HLE:
supported = TR::CodeGenerator::getX86ProcessorInfo().supportsHLE();
break;
case OMR_FEATURE_X86_TM:
supported = TR::CodeGenerator::getX86ProcessorInfo().hasThermalMonitor();
break;
case OMR_FEATURE_X86_AVX:
supported = TR::CodeGenerator::getX86ProcessorInfo().supportsAVX();
break;
case OMR_FEATURE_X86_AVX2:
supported = TR::CodeGenerator::getX86ProcessorInfo().supportsAVX2();
break;
case OMR_FEATURE_X86_AVX512F:
supported = TR::CodeGenerator::getX86ProcessorInfo().supportsAVX512F();
break;
case OMR_FEATURE_X86_AVX512VL:
supported = TR::CodeGenerator::getX86ProcessorInfo().supportsAVX512VL();
break;
case OMR_FEATURE_X86_AVX512BW:
supported = TR::CodeGenerator::getX86ProcessorInfo().supportsAVX512BW();
break;
case OMR_FEATURE_X86_AVX512DQ:
supported = TR::CodeGenerator::getX86ProcessorInfo().supportsAVX512DQ();
break;
case OMR_FEATURE_X86_AVX512CD:
supported = TR::CodeGenerator::getX86ProcessorInfo().supportsAVX512CD();
break;
case OMR_FEATURE_X86_AVX512_VBMI2:
supported = TR::CodeGenerator::getX86ProcessorInfo().supportsAVX512VBMI2();
break;
case OMR_FEATURE_X86_AVX512_BITALG:
supported = TR::CodeGenerator::getX86ProcessorInfo().supportsAVX512BITALG();
break;
case OMR_FEATURE_X86_AVX512_VPOPCNTDQ:
supported = TR::CodeGenerator::getX86ProcessorInfo().supportsAVX512VPOPCNTDQ();
break;
case OMR_FEATURE_X86_FMA:
supported = TR::CodeGenerator::getX86ProcessorInfo().supportsFMA();
break;
default:
TR_ASSERT_FATAL(false, "Unknown feature %d", feature);
break;
}
return supported;
}
const char*
OMR::X86::CPU::getProcessorName()
{
const char* returnString = "";
switch(_processorDescription.processor)
{
case OMR_PROCESSOR_X86_INTELPENTIUM:
returnString = "X86 Intel Pentium";
break;
case OMR_PROCESSOR_X86_INTELP6:
returnString = "X86 Intel P6";
break;
case OMR_PROCESSOR_X86_INTELPENTIUM4:
returnString = "X86 Intel Netburst Microarchitecture";
break;
case OMR_PROCESSOR_X86_INTELCORE2:
returnString = "X86 Intel Core2 Microarchitecture";
break;
case OMR_PROCESSOR_X86_INTELTULSA:
returnString = "X86 Intel Tulsa";
break;
case OMR_PROCESSOR_X86_INTELNEHALEM:
returnString = "X86 Intel Nehalem";
break;
case OMR_PROCESSOR_X86_INTELWESTMERE:
returnString = "X86 Intel Westmere";
break;
case OMR_PROCESSOR_X86_INTELSANDYBRIDGE:
returnString = "X86 Intel Sandy Bridge";
break;
case OMR_PROCESSOR_X86_INTELIVYBRIDGE:
returnString = "X86 Intel Ivy Bridge";
break;
case OMR_PROCESSOR_X86_INTELHASWELL:
returnString = "X86 Intel Haswell";
break;
case OMR_PROCESSOR_X86_INTELBROADWELL:
returnString = "X86 Intel Broadwell";
break;
case OMR_PROCESSOR_X86_INTELSKYLAKE:
returnString = "X86 Intel Skylake";
break;
case OMR_PROCESSOR_X86_AMDK5:
returnString = "X86 AMDK5";
break;
case OMR_PROCESSOR_X86_AMDK6:
returnString = "X86 AMDK6";
break;
case OMR_PROCESSOR_X86_AMDATHLONDURON:
returnString = "X86 AMD Athlon-Duron";
break;
case OMR_PROCESSOR_X86_AMDOPTERON:
returnString = "X86 AMD Opteron";
break;
case OMR_PROCESSOR_X86_AMDFAMILY15H:
returnString = "X86 AMD Family 15h";
break;
default:
returnString = "Unknown X86 Processor";
break;
}
return returnString;
}