mirror of
https://github.com/c64scene-ar/llvm-6502.git
synced 2025-02-01 02:33:44 +00:00
d6e59084d0
git-svn-id: https://llvm.org/svn/llvm-project/llvm/trunk@98583 91177308-0d34-0410-b5e6-96231b3b80d8
81 lines
2.5 KiB
C++
81 lines
2.5 KiB
C++
//===-- X86AsmBackend.cpp - X86 Assembler Backend -------------------------===//
|
|
//
|
|
// The LLVM Compiler Infrastructure
|
|
//
|
|
// This file is distributed under the University of Illinois Open Source
|
|
// License. See LICENSE.TXT for details.
|
|
//
|
|
//===----------------------------------------------------------------------===//
|
|
|
|
#include "llvm/Target/TargetAsmBackend.h"
|
|
#include "X86.h"
|
|
#include "llvm/MC/MCSectionMachO.h"
|
|
#include "llvm/Target/TargetRegistry.h"
|
|
#include "llvm/Target/TargetAsmBackend.h"
|
|
using namespace llvm;
|
|
|
|
namespace {
|
|
|
|
class X86AsmBackend : public TargetAsmBackend {
|
|
public:
|
|
X86AsmBackend(const Target &T)
|
|
: TargetAsmBackend(T) {}
|
|
};
|
|
|
|
class DarwinX86AsmBackend : public X86AsmBackend {
|
|
public:
|
|
DarwinX86AsmBackend(const Target &T)
|
|
: X86AsmBackend(T) {}
|
|
|
|
virtual bool hasAbsolutizedSet() const { return true; }
|
|
|
|
virtual bool hasScatteredSymbols() const { return true; }
|
|
};
|
|
|
|
class DarwinX86_32AsmBackend : public DarwinX86AsmBackend {
|
|
public:
|
|
DarwinX86_32AsmBackend(const Target &T)
|
|
: DarwinX86AsmBackend(T) {}
|
|
};
|
|
|
|
class DarwinX86_64AsmBackend : public DarwinX86AsmBackend {
|
|
public:
|
|
DarwinX86_64AsmBackend(const Target &T)
|
|
: DarwinX86AsmBackend(T) {}
|
|
|
|
virtual bool doesSectionRequireSymbols(const MCSection &Section) const {
|
|
// Temporary labels in the string literals sections require symbols. The
|
|
// issue is that the x86_64 relocation format does not allow symbol +
|
|
// offset, and so the linker does not have enough information to resolve the
|
|
// access to the appropriate atom unless an external relocation is used. For
|
|
// non-cstring sections, we expect the compiler to use a non-temporary label
|
|
// for anything that could have an addend pointing outside the symbol.
|
|
//
|
|
// See <rdar://problem/4765733>.
|
|
const MCSectionMachO &SMO = static_cast<const MCSectionMachO&>(Section);
|
|
return SMO.getType() == MCSectionMachO::S_CSTRING_LITERALS;
|
|
}
|
|
};
|
|
|
|
}
|
|
|
|
TargetAsmBackend *llvm::createX86_32AsmBackend(const Target &T,
|
|
const std::string &TT) {
|
|
switch (Triple(TT).getOS()) {
|
|
case Triple::Darwin:
|
|
return new DarwinX86_32AsmBackend(T);
|
|
default:
|
|
return new X86AsmBackend(T);
|
|
}
|
|
}
|
|
|
|
TargetAsmBackend *llvm::createX86_64AsmBackend(const Target &T,
|
|
const std::string &TT) {
|
|
switch (Triple(TT).getOS()) {
|
|
case Triple::Darwin:
|
|
return new DarwinX86_64AsmBackend(T);
|
|
default:
|
|
return new X86AsmBackend(T);
|
|
}
|
|
}
|