1 //===-- X86AsmBackend.cpp - X86 Assembler Backend -------------------------===//
3 // The LLVM Compiler Infrastructure
5 // This file is distributed under the University of Illinois Open Source
6 // License. See LICENSE.TXT for details.
8 //===----------------------------------------------------------------------===//
10 #include "llvm/Target/TargetAsmBackend.h"
12 #include "llvm/MC/MCSectionMachO.h"
13 #include "llvm/Target/TargetRegistry.h"
14 #include "llvm/Target/TargetAsmBackend.h"
19 class X86AsmBackend : public TargetAsmBackend {
21 X86AsmBackend(const Target &T)
22 : TargetAsmBackend(T) {}
25 class DarwinX86AsmBackend : public X86AsmBackend {
27 DarwinX86AsmBackend(const Target &T)
29 HasAbsolutizedSet = true;
30 HasScatteredSymbols = true;
34 class DarwinX86_32AsmBackend : public DarwinX86AsmBackend {
36 DarwinX86_32AsmBackend(const Target &T)
37 : DarwinX86AsmBackend(T) {}
40 class DarwinX86_64AsmBackend : public DarwinX86AsmBackend {
42 DarwinX86_64AsmBackend(const Target &T)
43 : DarwinX86AsmBackend(T) {
44 HasReliableSymbolDifference = true;
47 virtual bool doesSectionRequireSymbols(const MCSection &Section) const {
48 // Temporary labels in the string literals sections require symbols. The
49 // issue is that the x86_64 relocation format does not allow symbol +
50 // offset, and so the linker does not have enough information to resolve the
51 // access to the appropriate atom unless an external relocation is used. For
52 // non-cstring sections, we expect the compiler to use a non-temporary label
53 // for anything that could have an addend pointing outside the symbol.
55 // See <rdar://problem/4765733>.
56 const MCSectionMachO &SMO = static_cast<const MCSectionMachO&>(Section);
57 return SMO.getType() == MCSectionMachO::S_CSTRING_LITERALS;
63 TargetAsmBackend *llvm::createX86_32AsmBackend(const Target &T,
64 const std::string &TT) {
65 switch (Triple(TT).getOS()) {
67 return new DarwinX86_32AsmBackend(T);
69 return new X86AsmBackend(T);
73 TargetAsmBackend *llvm::createX86_64AsmBackend(const Target &T,
74 const std::string &TT) {
75 switch (Triple(TT).getOS()) {
77 return new DarwinX86_64AsmBackend(T);
79 return new X86AsmBackend(T);