X86AsmBackend.cpp (234353) | X86AsmBackend.cpp (241430) |
---|---|
1//===-- X86AsmBackend.cpp - X86 Assembler Backend -------------------------===// 2// 3// The LLVM Compiler Infrastructure 4// 5// This file is distributed under the University of Illinois Open Source 6// License. See LICENSE.TXT for details. 7// 8//===----------------------------------------------------------------------===// --- 52 unchanged lines hidden (view full) --- 61class X86ELFObjectWriter : public MCELFObjectTargetWriter { 62public: 63 X86ELFObjectWriter(bool is64Bit, uint8_t OSABI, uint16_t EMachine, 64 bool HasRelocationAddend, bool foobar) 65 : MCELFObjectTargetWriter(is64Bit, OSABI, EMachine, HasRelocationAddend) {} 66}; 67 68class X86AsmBackend : public MCAsmBackend { | 1//===-- X86AsmBackend.cpp - X86 Assembler Backend -------------------------===// 2// 3// The LLVM Compiler Infrastructure 4// 5// This file is distributed under the University of Illinois Open Source 6// License. See LICENSE.TXT for details. 7// 8//===----------------------------------------------------------------------===// --- 52 unchanged lines hidden (view full) --- 61class X86ELFObjectWriter : public MCELFObjectTargetWriter { 62public: 63 X86ELFObjectWriter(bool is64Bit, uint8_t OSABI, uint16_t EMachine, 64 bool HasRelocationAddend, bool foobar) 65 : MCELFObjectTargetWriter(is64Bit, OSABI, EMachine, HasRelocationAddend) {} 66}; 67 68class X86AsmBackend : public MCAsmBackend { |
69 StringRef CPU; |
|
69public: | 70public: |
70 X86AsmBackend(const Target &T) 71 : MCAsmBackend() {} | 71 X86AsmBackend(const Target &T, StringRef _CPU) 72 : MCAsmBackend(), CPU(_CPU) {} |
72 73 unsigned getNumFixupKinds() const { 74 return X86::NumTargetFixupKinds; 75 } 76 77 const MCFixupKindInfo &getFixupKindInfo(MCFixupKind Kind) const { 78 const static MCFixupKindInfo Infos[X86::NumTargetFixupKinds] = { 79 { "reloc_riprel_4byte", 0, 4 * 8, MCFixupKindInfo::FKF_IsPCRel }, --- 220 unchanged lines hidden (view full) --- 300 // nopl 0L(%[re]ax,%[re]ax,1) 301 {0x0f, 0x1f, 0x84, 0x00, 0x00, 0x00, 0x00, 0x00}, 302 // nopw 0L(%[re]ax,%[re]ax,1) 303 {0x66, 0x0f, 0x1f, 0x84, 0x00, 0x00, 0x00, 0x00, 0x00}, 304 // nopw %cs:0L(%[re]ax,%[re]ax,1) 305 {0x66, 0x2e, 0x0f, 0x1f, 0x84, 0x00, 0x00, 0x00, 0x00, 0x00}, 306 }; 307 | 73 74 unsigned getNumFixupKinds() const { 75 return X86::NumTargetFixupKinds; 76 } 77 78 const MCFixupKindInfo &getFixupKindInfo(MCFixupKind Kind) const { 79 const static MCFixupKindInfo Infos[X86::NumTargetFixupKinds] = { 80 { "reloc_riprel_4byte", 0, 4 * 8, MCFixupKindInfo::FKF_IsPCRel }, --- 220 unchanged lines hidden (view full) --- 301 // nopl 0L(%[re]ax,%[re]ax,1) 302 {0x0f, 0x1f, 0x84, 0x00, 0x00, 0x00, 0x00, 0x00}, 303 // nopw 0L(%[re]ax,%[re]ax,1) 304 {0x66, 0x0f, 0x1f, 0x84, 0x00, 0x00, 0x00, 0x00, 0x00}, 305 // nopw %cs:0L(%[re]ax,%[re]ax,1) 306 {0x66, 0x2e, 0x0f, 0x1f, 0x84, 0x00, 0x00, 0x00, 0x00, 0x00}, 307 }; 308 |
309 // This CPU doesnt support long nops. If needed add more. 310 if (CPU == "geode") { 311 for (uint64_t i = 0; i < Count; ++i) 312 OW->Write8(0x90); 313 return true; 314 } 315 |
|
308 // Write an optimal sequence for the first 15 bytes. 309 const uint64_t OptimalCount = (Count < 16) ? Count : 15; 310 const uint64_t Prefixes = OptimalCount <= 10 ? 0 : OptimalCount - 10; 311 for (uint64_t i = 0, e = Prefixes; i != e; i++) 312 OW->Write8(0x66); 313 const uint64_t Rest = OptimalCount - Prefixes; 314 for (uint64_t i = 0, e = Rest; i != e; i++) 315 OW->Write8(Nops[Rest - 1][i]); --- 6 unchanged lines hidden (view full) --- 322} 323 324/* *** */ 325 326namespace { 327class ELFX86AsmBackend : public X86AsmBackend { 328public: 329 uint8_t OSABI; | 316 // Write an optimal sequence for the first 15 bytes. 317 const uint64_t OptimalCount = (Count < 16) ? Count : 15; 318 const uint64_t Prefixes = OptimalCount <= 10 ? 0 : OptimalCount - 10; 319 for (uint64_t i = 0, e = Prefixes; i != e; i++) 320 OW->Write8(0x66); 321 const uint64_t Rest = OptimalCount - Prefixes; 322 for (uint64_t i = 0, e = Rest; i != e; i++) 323 OW->Write8(Nops[Rest - 1][i]); --- 6 unchanged lines hidden (view full) --- 330} 331 332/* *** */ 333 334namespace { 335class ELFX86AsmBackend : public X86AsmBackend { 336public: 337 uint8_t OSABI; |
330 ELFX86AsmBackend(const Target &T, uint8_t _OSABI) 331 : X86AsmBackend(T), OSABI(_OSABI) { | 338 ELFX86AsmBackend(const Target &T, uint8_t _OSABI, StringRef CPU) 339 : X86AsmBackend(T, CPU), OSABI(_OSABI) { |
332 HasReliableSymbolDifference = true; 333 } 334 335 virtual bool doesSectionRequireSymbols(const MCSection &Section) const { 336 const MCSectionELF &ES = static_cast<const MCSectionELF&>(Section); 337 return ES.getFlags() & ELF::SHF_MERGE; 338 } 339}; 340 341class ELFX86_32AsmBackend : public ELFX86AsmBackend { 342public: | 340 HasReliableSymbolDifference = true; 341 } 342 343 virtual bool doesSectionRequireSymbols(const MCSection &Section) const { 344 const MCSectionELF &ES = static_cast<const MCSectionELF&>(Section); 345 return ES.getFlags() & ELF::SHF_MERGE; 346 } 347}; 348 349class ELFX86_32AsmBackend : public ELFX86AsmBackend { 350public: |
343 ELFX86_32AsmBackend(const Target &T, uint8_t OSABI) 344 : ELFX86AsmBackend(T, OSABI) {} | 351 ELFX86_32AsmBackend(const Target &T, uint8_t OSABI, StringRef CPU) 352 : ELFX86AsmBackend(T, OSABI, CPU) {} |
345 346 MCObjectWriter *createObjectWriter(raw_ostream &OS) const { 347 return createX86ELFObjectWriter(OS, /*Is64Bit*/ false, OSABI); 348 } 349}; 350 351class ELFX86_64AsmBackend : public ELFX86AsmBackend { 352public: | 353 354 MCObjectWriter *createObjectWriter(raw_ostream &OS) const { 355 return createX86ELFObjectWriter(OS, /*Is64Bit*/ false, OSABI); 356 } 357}; 358 359class ELFX86_64AsmBackend : public ELFX86AsmBackend { 360public: |
353 ELFX86_64AsmBackend(const Target &T, uint8_t OSABI) 354 : ELFX86AsmBackend(T, OSABI) {} | 361 ELFX86_64AsmBackend(const Target &T, uint8_t OSABI, StringRef CPU) 362 : ELFX86AsmBackend(T, OSABI, CPU) {} |
355 356 MCObjectWriter *createObjectWriter(raw_ostream &OS) const { 357 return createX86ELFObjectWriter(OS, /*Is64Bit*/ true, OSABI); 358 } 359}; 360 361class WindowsX86AsmBackend : public X86AsmBackend { 362 bool Is64Bit; 363 364public: | 363 364 MCObjectWriter *createObjectWriter(raw_ostream &OS) const { 365 return createX86ELFObjectWriter(OS, /*Is64Bit*/ true, OSABI); 366 } 367}; 368 369class WindowsX86AsmBackend : public X86AsmBackend { 370 bool Is64Bit; 371 372public: |
365 WindowsX86AsmBackend(const Target &T, bool is64Bit) 366 : X86AsmBackend(T) | 373 WindowsX86AsmBackend(const Target &T, bool is64Bit, StringRef CPU) 374 : X86AsmBackend(T, CPU) |
367 , Is64Bit(is64Bit) { 368 } 369 370 MCObjectWriter *createObjectWriter(raw_ostream &OS) const { 371 return createX86WinCOFFObjectWriter(OS, Is64Bit); 372 } 373}; 374 375class DarwinX86AsmBackend : public X86AsmBackend { 376public: | 375 , Is64Bit(is64Bit) { 376 } 377 378 MCObjectWriter *createObjectWriter(raw_ostream &OS) const { 379 return createX86WinCOFFObjectWriter(OS, Is64Bit); 380 } 381}; 382 383class DarwinX86AsmBackend : public X86AsmBackend { 384public: |
377 DarwinX86AsmBackend(const Target &T) 378 : X86AsmBackend(T) { } | 385 DarwinX86AsmBackend(const Target &T, StringRef CPU) 386 : X86AsmBackend(T, CPU) { } |
379}; 380 381class DarwinX86_32AsmBackend : public DarwinX86AsmBackend { 382public: | 387}; 388 389class DarwinX86_32AsmBackend : public DarwinX86AsmBackend { 390public: |
383 DarwinX86_32AsmBackend(const Target &T) 384 : DarwinX86AsmBackend(T) {} | 391 DarwinX86_32AsmBackend(const Target &T, StringRef CPU) 392 : DarwinX86AsmBackend(T, CPU) {} |
385 386 MCObjectWriter *createObjectWriter(raw_ostream &OS) const { 387 return createX86MachObjectWriter(OS, /*Is64Bit=*/false, 388 object::mach::CTM_i386, 389 object::mach::CSX86_ALL); 390 } 391}; 392 393class DarwinX86_64AsmBackend : public DarwinX86AsmBackend { 394public: | 393 394 MCObjectWriter *createObjectWriter(raw_ostream &OS) const { 395 return createX86MachObjectWriter(OS, /*Is64Bit=*/false, 396 object::mach::CTM_i386, 397 object::mach::CSX86_ALL); 398 } 399}; 400 401class DarwinX86_64AsmBackend : public DarwinX86AsmBackend { 402public: |
395 DarwinX86_64AsmBackend(const Target &T) 396 : DarwinX86AsmBackend(T) { | 403 DarwinX86_64AsmBackend(const Target &T, StringRef CPU) 404 : DarwinX86AsmBackend(T, CPU) { |
397 HasReliableSymbolDifference = true; 398 } 399 400 MCObjectWriter *createObjectWriter(raw_ostream &OS) const { 401 return createX86MachObjectWriter(OS, /*Is64Bit=*/true, 402 object::mach::CTM_x86_64, 403 object::mach::CSX86_ALL); 404 } --- 29 unchanged lines hidden (view full) --- 434 case MCSectionMachO::S_INTERPOSING: 435 return false; 436 } 437 } 438}; 439 440} // end anonymous namespace 441 | 405 HasReliableSymbolDifference = true; 406 } 407 408 MCObjectWriter *createObjectWriter(raw_ostream &OS) const { 409 return createX86MachObjectWriter(OS, /*Is64Bit=*/true, 410 object::mach::CTM_x86_64, 411 object::mach::CSX86_ALL); 412 } --- 29 unchanged lines hidden (view full) --- 442 case MCSectionMachO::S_INTERPOSING: 443 return false; 444 } 445 } 446}; 447 448} // end anonymous namespace 449 |
442MCAsmBackend *llvm::createX86_32AsmBackend(const Target &T, StringRef TT) { | 450MCAsmBackend *llvm::createX86_32AsmBackend(const Target &T, StringRef TT, StringRef CPU) { |
443 Triple TheTriple(TT); 444 445 if (TheTriple.isOSDarwin() || TheTriple.getEnvironment() == Triple::MachO) | 451 Triple TheTriple(TT); 452 453 if (TheTriple.isOSDarwin() || TheTriple.getEnvironment() == Triple::MachO) |
446 return new DarwinX86_32AsmBackend(T); | 454 return new DarwinX86_32AsmBackend(T, CPU); |
447 448 if (TheTriple.isOSWindows()) | 455 456 if (TheTriple.isOSWindows()) |
449 return new WindowsX86AsmBackend(T, false); | 457 return new WindowsX86AsmBackend(T, false, CPU); |
450 451 uint8_t OSABI = MCELFObjectTargetWriter::getOSABI(TheTriple.getOS()); | 458 459 uint8_t OSABI = MCELFObjectTargetWriter::getOSABI(TheTriple.getOS()); |
452 return new ELFX86_32AsmBackend(T, OSABI); | 460 return new ELFX86_32AsmBackend(T, OSABI, CPU); |
453} 454 | 461} 462 |
455MCAsmBackend *llvm::createX86_64AsmBackend(const Target &T, StringRef TT) { | 463MCAsmBackend *llvm::createX86_64AsmBackend(const Target &T, StringRef TT, StringRef CPU) { |
456 Triple TheTriple(TT); 457 458 if (TheTriple.isOSDarwin() || TheTriple.getEnvironment() == Triple::MachO) | 464 Triple TheTriple(TT); 465 466 if (TheTriple.isOSDarwin() || TheTriple.getEnvironment() == Triple::MachO) |
459 return new DarwinX86_64AsmBackend(T); | 467 return new DarwinX86_64AsmBackend(T, CPU); |
460 461 if (TheTriple.isOSWindows()) | 468 469 if (TheTriple.isOSWindows()) |
462 return new WindowsX86AsmBackend(T, true); | 470 return new WindowsX86AsmBackend(T, true, CPU); |
463 464 uint8_t OSABI = MCELFObjectTargetWriter::getOSABI(TheTriple.getOS()); | 471 472 uint8_t OSABI = MCELFObjectTargetWriter::getOSABI(TheTriple.getOS()); |
465 return new ELFX86_64AsmBackend(T, OSABI); | 473 return new ELFX86_64AsmBackend(T, OSABI, CPU); |
466} | 474} |