@@ -67,19 +67,10 @@ class X86ELFObjectWriter : public MCELFObjectTargetWriter {
67
67
};
68
68
69
69
class X86AsmBackend : public MCAsmBackend {
70
- const StringRef CPU;
71
- bool HasNopl;
72
- const uint64_t MaxNopLength;
70
+ const MCSubtargetInfo &STI;
73
71
public:
74
- X86AsmBackend (const Target &T, StringRef CPU)
75
- : MCAsmBackend(), CPU(CPU),
76
- MaxNopLength ((CPU == " slm" || CPU == " silvermont" ) ? 7 : 15) {
77
- HasNopl = CPU != " generic" && CPU != " i386" && CPU != " i486" &&
78
- CPU != " i586" && CPU != " pentium" && CPU != " pentium-mmx" &&
79
- CPU != " i686" && CPU != " k6" && CPU != " k6-2" && CPU != " k6-3" &&
80
- CPU != " geode" && CPU != " winchip-c6" && CPU != " winchip2" &&
81
- CPU != " c3" && CPU != " c3-2" && CPU != " lakemont" && CPU != " " ;
82
- }
72
+ X86AsmBackend (const Target &T, const MCSubtargetInfo &STI)
73
+ : MCAsmBackend(), STI(STI) {}
83
74
84
75
unsigned getNumFixupKinds () const override {
85
76
return X86::NumTargetFixupKinds;
@@ -346,14 +337,15 @@ bool X86AsmBackend::writeNopData(uint64_t Count, MCObjectWriter *OW) const {
346
337
};
347
338
348
339
// This CPU doesn't support long nops. If needed add more.
349
- // FIXME: Can we get this from the subtarget somehow?
350
340
// FIXME: We could generated something better than plain 0x90.
351
- if (!HasNopl ) {
341
+ if (!STI. getFeatureBits ()[X86::FeatureNOPL] ) {
352
342
for (uint64_t i = 0 ; i < Count; ++i)
353
343
OW->write8 (0x90 );
354
344
return true ;
355
345
}
356
346
347
+ uint64_t MaxNopLength = STI.getFeatureBits ()[X86::ProcIntelSLM] ? 7 : 15 ;
348
+
357
349
// 15 is the longest single nop instruction. Emit as many 15-byte nops as
358
350
// needed, then emit a nop of the remaining length.
359
351
do {
@@ -377,14 +369,15 @@ namespace {
377
369
class ELFX86AsmBackend : public X86AsmBackend {
378
370
public:
379
371
uint8_t OSABI;
380
- ELFX86AsmBackend (const Target &T, uint8_t OSABI, StringRef CPU )
381
- : X86AsmBackend(T, CPU ), OSABI(OSABI) {}
372
+ ELFX86AsmBackend (const Target &T, uint8_t OSABI, const MCSubtargetInfo &STI )
373
+ : X86AsmBackend(T, STI ), OSABI(OSABI) {}
382
374
};
383
375
384
376
class ELFX86_32AsmBackend : public ELFX86AsmBackend {
385
377
public:
386
- ELFX86_32AsmBackend (const Target &T, uint8_t OSABI, StringRef CPU)
387
- : ELFX86AsmBackend(T, OSABI, CPU) {}
378
+ ELFX86_32AsmBackend (const Target &T, uint8_t OSABI,
379
+ const MCSubtargetInfo &STI)
380
+ : ELFX86AsmBackend(T, OSABI, STI) {}
388
381
389
382
std::unique_ptr<MCObjectWriter>
390
383
createObjectWriter (raw_pwrite_stream &OS) const override {
@@ -394,8 +387,9 @@ class ELFX86_32AsmBackend : public ELFX86AsmBackend {
394
387
395
388
class ELFX86_X32AsmBackend : public ELFX86AsmBackend {
396
389
public:
397
- ELFX86_X32AsmBackend (const Target &T, uint8_t OSABI, StringRef CPU)
398
- : ELFX86AsmBackend(T, OSABI, CPU) {}
390
+ ELFX86_X32AsmBackend (const Target &T, uint8_t OSABI,
391
+ const MCSubtargetInfo &STI)
392
+ : ELFX86AsmBackend(T, OSABI, STI) {}
399
393
400
394
std::unique_ptr<MCObjectWriter>
401
395
createObjectWriter (raw_pwrite_stream &OS) const override {
@@ -406,8 +400,9 @@ class ELFX86_X32AsmBackend : public ELFX86AsmBackend {
406
400
407
401
class ELFX86_IAMCUAsmBackend : public ELFX86AsmBackend {
408
402
public:
409
- ELFX86_IAMCUAsmBackend (const Target &T, uint8_t OSABI, StringRef CPU)
410
- : ELFX86AsmBackend(T, OSABI, CPU) {}
403
+ ELFX86_IAMCUAsmBackend (const Target &T, uint8_t OSABI,
404
+ const MCSubtargetInfo &STI)
405
+ : ELFX86AsmBackend(T, OSABI, STI) {}
411
406
412
407
std::unique_ptr<MCObjectWriter>
413
408
createObjectWriter (raw_pwrite_stream &OS) const override {
@@ -418,8 +413,9 @@ class ELFX86_IAMCUAsmBackend : public ELFX86AsmBackend {
418
413
419
414
class ELFX86_64AsmBackend : public ELFX86AsmBackend {
420
415
public:
421
- ELFX86_64AsmBackend (const Target &T, uint8_t OSABI, StringRef CPU)
422
- : ELFX86AsmBackend(T, OSABI, CPU) {}
416
+ ELFX86_64AsmBackend (const Target &T, uint8_t OSABI,
417
+ const MCSubtargetInfo &STI)
418
+ : ELFX86AsmBackend(T, OSABI, STI) {}
423
419
424
420
std::unique_ptr<MCObjectWriter>
425
421
createObjectWriter (raw_pwrite_stream &OS) const override {
@@ -431,8 +427,9 @@ class WindowsX86AsmBackend : public X86AsmBackend {
431
427
bool Is64Bit;
432
428
433
429
public:
434
- WindowsX86AsmBackend (const Target &T, bool is64Bit, StringRef CPU)
435
- : X86AsmBackend(T, CPU)
430
+ WindowsX86AsmBackend (const Target &T, bool is64Bit,
431
+ const MCSubtargetInfo &STI)
432
+ : X86AsmBackend(T, STI)
436
433
, Is64Bit(is64Bit) {
437
434
}
438
435
@@ -790,9 +787,9 @@ class DarwinX86AsmBackend : public X86AsmBackend {
790
787
}
791
788
792
789
public:
793
- DarwinX86AsmBackend (const Target &T, const MCRegisterInfo &MRI, StringRef CPU,
794
- bool Is64Bit)
795
- : X86AsmBackend(T, CPU ), MRI(MRI), Is64Bit(Is64Bit) {
790
+ DarwinX86AsmBackend (const Target &T, const MCRegisterInfo &MRI,
791
+ const MCSubtargetInfo &STI, bool Is64Bit)
792
+ : X86AsmBackend(T, STI ), MRI(MRI), Is64Bit(Is64Bit) {
796
793
memset (SavedRegs, 0 , sizeof (SavedRegs));
797
794
OffsetSize = Is64Bit ? 8 : 4 ;
798
795
MoveInstrSize = Is64Bit ? 3 : 2 ;
@@ -803,8 +800,8 @@ class DarwinX86AsmBackend : public X86AsmBackend {
803
800
class DarwinX86_32AsmBackend : public DarwinX86AsmBackend {
804
801
public:
805
802
DarwinX86_32AsmBackend (const Target &T, const MCRegisterInfo &MRI,
806
- StringRef CPU )
807
- : DarwinX86AsmBackend(T, MRI, CPU , false ) {}
803
+ const MCSubtargetInfo &STI )
804
+ : DarwinX86AsmBackend(T, MRI, STI , false ) {}
808
805
809
806
std::unique_ptr<MCObjectWriter>
810
807
createObjectWriter (raw_pwrite_stream &OS) const override {
@@ -824,8 +821,8 @@ class DarwinX86_64AsmBackend : public DarwinX86AsmBackend {
824
821
const MachO::CPUSubTypeX86 Subtype;
825
822
public:
826
823
DarwinX86_64AsmBackend (const Target &T, const MCRegisterInfo &MRI,
827
- StringRef CPU , MachO::CPUSubTypeX86 st)
828
- : DarwinX86AsmBackend(T, MRI, CPU , true ), Subtype(st) {}
824
+ const MCSubtargetInfo &STI , MachO::CPUSubTypeX86 st)
825
+ : DarwinX86AsmBackend(T, MRI, STI , true ), Subtype(st) {}
829
826
830
827
std::unique_ptr<MCObjectWriter>
831
828
createObjectWriter (raw_pwrite_stream &OS) const override {
@@ -847,41 +844,39 @@ MCAsmBackend *llvm::createX86_32AsmBackend(const Target &T,
847
844
const MCRegisterInfo &MRI,
848
845
const MCTargetOptions &Options) {
849
846
const Triple &TheTriple = STI.getTargetTriple ();
850
- StringRef CPU = STI.getCPU ();
851
847
if (TheTriple.isOSBinFormatMachO ())
852
- return new DarwinX86_32AsmBackend (T, MRI, CPU );
848
+ return new DarwinX86_32AsmBackend (T, MRI, STI );
853
849
854
850
if (TheTriple.isOSWindows () && TheTriple.isOSBinFormatCOFF ())
855
- return new WindowsX86AsmBackend (T, false , CPU );
851
+ return new WindowsX86AsmBackend (T, false , STI );
856
852
857
853
uint8_t OSABI = MCELFObjectTargetWriter::getOSABI (TheTriple.getOS ());
858
854
859
855
if (TheTriple.isOSIAMCU ())
860
- return new ELFX86_IAMCUAsmBackend (T, OSABI, CPU );
856
+ return new ELFX86_IAMCUAsmBackend (T, OSABI, STI );
861
857
862
- return new ELFX86_32AsmBackend (T, OSABI, CPU );
858
+ return new ELFX86_32AsmBackend (T, OSABI, STI );
863
859
}
864
860
865
861
MCAsmBackend *llvm::createX86_64AsmBackend (const Target &T,
866
862
const MCSubtargetInfo &STI,
867
863
const MCRegisterInfo &MRI,
868
864
const MCTargetOptions &Options) {
869
865
const Triple &TheTriple = STI.getTargetTriple ();
870
- StringRef CPU = STI.getCPU ();
871
866
if (TheTriple.isOSBinFormatMachO ()) {
872
867
MachO::CPUSubTypeX86 CS =
873
868
StringSwitch<MachO::CPUSubTypeX86>(TheTriple.getArchName ())
874
869
.Case (" x86_64h" , MachO::CPU_SUBTYPE_X86_64_H)
875
870
.Default (MachO::CPU_SUBTYPE_X86_64_ALL);
876
- return new DarwinX86_64AsmBackend (T, MRI, CPU , CS);
871
+ return new DarwinX86_64AsmBackend (T, MRI, STI , CS);
877
872
}
878
873
879
874
if (TheTriple.isOSWindows () && TheTriple.isOSBinFormatCOFF ())
880
- return new WindowsX86AsmBackend (T, true , CPU );
875
+ return new WindowsX86AsmBackend (T, true , STI );
881
876
882
877
uint8_t OSABI = MCELFObjectTargetWriter::getOSABI (TheTriple.getOS ());
883
878
884
879
if (TheTriple.getEnvironment () == Triple::GNUX32)
885
- return new ELFX86_X32AsmBackend (T, OSABI, CPU );
886
- return new ELFX86_64AsmBackend (T, OSABI, CPU );
880
+ return new ELFX86_X32AsmBackend (T, OSABI, STI );
881
+ return new ELFX86_64AsmBackend (T, OSABI, STI );
887
882
}
0 commit comments