Deleted Added
sdiff udiff text old ( 234353 ) new ( 241430 )
full compact
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 {
69public:
70 X86AsmBackend(const Target &T)
71 : MCAsmBackend() {}
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
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;
330 ELFX86AsmBackend(const Target &T, uint8_t _OSABI)
331 : X86AsmBackend(T), 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:
343 ELFX86_32AsmBackend(const Target &T, uint8_t OSABI)
344 : ELFX86AsmBackend(T, OSABI) {}
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 ELFX86_64AsmBackend(const Target &T, uint8_t OSABI)
354 : ELFX86AsmBackend(T, OSABI) {}
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:
365 WindowsX86AsmBackend(const Target &T, bool is64Bit)
366 : X86AsmBackend(T)
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:
377 DarwinX86AsmBackend(const Target &T)
378 : X86AsmBackend(T) { }
379};
380
381class DarwinX86_32AsmBackend : public DarwinX86AsmBackend {
382public:
383 DarwinX86_32AsmBackend(const Target &T)
384 : DarwinX86AsmBackend(T) {}
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:
395 DarwinX86_64AsmBackend(const Target &T)
396 : DarwinX86AsmBackend(T) {
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
442MCAsmBackend *llvm::createX86_32AsmBackend(const Target &T, StringRef TT) {
443 Triple TheTriple(TT);
444
445 if (TheTriple.isOSDarwin() || TheTriple.getEnvironment() == Triple::MachO)
446 return new DarwinX86_32AsmBackend(T);
447
448 if (TheTriple.isOSWindows())
449 return new WindowsX86AsmBackend(T, false);
450
451 uint8_t OSABI = MCELFObjectTargetWriter::getOSABI(TheTriple.getOS());
452 return new ELFX86_32AsmBackend(T, OSABI);
453}
454
455MCAsmBackend *llvm::createX86_64AsmBackend(const Target &T, StringRef TT) {
456 Triple TheTriple(TT);
457
458 if (TheTriple.isOSDarwin() || TheTriple.getEnvironment() == Triple::MachO)
459 return new DarwinX86_64AsmBackend(T);
460
461 if (TheTriple.isOSWindows())
462 return new WindowsX86AsmBackend(T, true);
463
464 uint8_t OSABI = MCELFObjectTargetWriter::getOSABI(TheTriple.getOS());
465 return new ELFX86_64AsmBackend(T, OSABI);
466}