mirror of
https://github.com/c64scene-ar/llvm-6502.git
synced 2025-07-26 05:25:47 +00:00
Add a new MC bit for NaCl (Native Client) mode. NaCl requires that certain
instructions are more aligned than the CPU requires, and adds some additional directives, to follow in future patches. Patch by David Meyer! git-svn-id: https://llvm.org/svn/llvm-project/llvm/trunk@139125 91177308-0d34-0410-b5e6-96231b3b80d8
This commit is contained in:
@@ -23,6 +23,9 @@ include "llvm/Target/Target.td"
|
|||||||
def ModeThumb : SubtargetFeature<"thumb-mode", "InThumbMode", "true",
|
def ModeThumb : SubtargetFeature<"thumb-mode", "InThumbMode", "true",
|
||||||
"Thumb mode">;
|
"Thumb mode">;
|
||||||
|
|
||||||
|
def ModeNaCl : SubtargetFeature<"nacl-mode", "InNaClMode", "true",
|
||||||
|
"Native client mode">;
|
||||||
|
|
||||||
//===----------------------------------------------------------------------===//
|
//===----------------------------------------------------------------------===//
|
||||||
// ARM Subtarget features.
|
// ARM Subtarget features.
|
||||||
//
|
//
|
||||||
|
@@ -209,6 +209,8 @@ def IsARM : Predicate<"!Subtarget->isThumb()">,
|
|||||||
AssemblerPredicate<"!ModeThumb">;
|
AssemblerPredicate<"!ModeThumb">;
|
||||||
def IsDarwin : Predicate<"Subtarget->isTargetDarwin()">;
|
def IsDarwin : Predicate<"Subtarget->isTargetDarwin()">;
|
||||||
def IsNotDarwin : Predicate<"!Subtarget->isTargetDarwin()">;
|
def IsNotDarwin : Predicate<"!Subtarget->isTargetDarwin()">;
|
||||||
|
def IsNaCl : Predicate<"Subtarget->isTargetNaCl()">,
|
||||||
|
AssemblerPredicate<"ModeNaCl">;
|
||||||
|
|
||||||
// FIXME: Eventually this will be just "hasV6T2Ops".
|
// FIXME: Eventually this will be just "hasV6T2Ops".
|
||||||
def UseMovt : Predicate<"Subtarget->useMovt()">;
|
def UseMovt : Predicate<"Subtarget->useMovt()">;
|
||||||
|
@@ -53,6 +53,7 @@ ARMSubtarget::ARMSubtarget(const std::string &TT, const std::string &CPU,
|
|||||||
, HasVMLxForwarding(false)
|
, HasVMLxForwarding(false)
|
||||||
, SlowFPBrcc(false)
|
, SlowFPBrcc(false)
|
||||||
, InThumbMode(false)
|
, InThumbMode(false)
|
||||||
|
, InNaClMode(false)
|
||||||
, HasThumb2(false)
|
, HasThumb2(false)
|
||||||
, NoARM(false)
|
, NoARM(false)
|
||||||
, PostRAScheduler(false)
|
, PostRAScheduler(false)
|
||||||
|
@@ -70,6 +70,9 @@ protected:
|
|||||||
/// InThumbMode - True if compiling for Thumb, false for ARM.
|
/// InThumbMode - True if compiling for Thumb, false for ARM.
|
||||||
bool InThumbMode;
|
bool InThumbMode;
|
||||||
|
|
||||||
|
/// InNaClMode - True if targeting Native Client
|
||||||
|
bool InNaClMode;
|
||||||
|
|
||||||
/// HasThumb2 - True if Thumb2 instructions are supported.
|
/// HasThumb2 - True if Thumb2 instructions are supported.
|
||||||
bool HasThumb2;
|
bool HasThumb2;
|
||||||
|
|
||||||
@@ -209,6 +212,9 @@ protected:
|
|||||||
const Triple &getTargetTriple() const { return TargetTriple; }
|
const Triple &getTargetTriple() const { return TargetTriple; }
|
||||||
|
|
||||||
bool isTargetDarwin() const { return TargetTriple.isOSDarwin(); }
|
bool isTargetDarwin() const { return TargetTriple.isOSDarwin(); }
|
||||||
|
bool isTargetNaCl() const {
|
||||||
|
return TargetTriple.getOS() == Triple::NativeClient;
|
||||||
|
}
|
||||||
bool isTargetELF() const { return !isTargetDarwin(); }
|
bool isTargetELF() const { return !isTargetDarwin(); }
|
||||||
|
|
||||||
bool isAPCS_ABI() const { return TargetABI == ARM_ABI_APCS; }
|
bool isAPCS_ABI() const { return TargetABI == ARM_ABI_APCS; }
|
||||||
|
@@ -86,6 +86,14 @@ std::string ARM_MC::ParseARMTriple(StringRef TT) {
|
|||||||
ARMArchFeature += ",+thumb-mode";
|
ARMArchFeature += ",+thumb-mode";
|
||||||
}
|
}
|
||||||
|
|
||||||
|
Triple TheTriple(TT);
|
||||||
|
if (TheTriple.getOS() == Triple::NativeClient) {
|
||||||
|
if (ARMArchFeature.empty())
|
||||||
|
ARMArchFeature = "+nacl-mode";
|
||||||
|
else
|
||||||
|
ARMArchFeature += ",+nacl-mode";
|
||||||
|
}
|
||||||
|
|
||||||
return ARMArchFeature;
|
return ARMArchFeature;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@@ -40,9 +40,16 @@ using namespace llvm;
|
|||||||
|
|
||||||
std::string X86_MC::ParseX86Triple(StringRef TT) {
|
std::string X86_MC::ParseX86Triple(StringRef TT) {
|
||||||
Triple TheTriple(TT);
|
Triple TheTriple(TT);
|
||||||
|
std::string FS;
|
||||||
if (TheTriple.getArch() == Triple::x86_64)
|
if (TheTriple.getArch() == Triple::x86_64)
|
||||||
return "+64bit-mode";
|
FS = "+64bit-mode";
|
||||||
return "-64bit-mode";
|
else
|
||||||
|
FS = "-64bit-mode";
|
||||||
|
if (TheTriple.getOS() == Triple::NativeClient)
|
||||||
|
FS += ",+nacl-mode";
|
||||||
|
else
|
||||||
|
FS += ",-nacl-mode";
|
||||||
|
return FS;
|
||||||
}
|
}
|
||||||
|
|
||||||
/// GetCpuIDAndInfo - Execute the specified cpuid and return the 4 values in the
|
/// GetCpuIDAndInfo - Execute the specified cpuid and return the 4 values in the
|
||||||
|
@@ -23,6 +23,9 @@ include "llvm/Target/Target.td"
|
|||||||
def Mode64Bit : SubtargetFeature<"64bit-mode", "In64BitMode", "true",
|
def Mode64Bit : SubtargetFeature<"64bit-mode", "In64BitMode", "true",
|
||||||
"64-bit mode (x86_64)">;
|
"64-bit mode (x86_64)">;
|
||||||
|
|
||||||
|
def ModeNaCl : SubtargetFeature<"nacl-mode", "InNaClMode", "true",
|
||||||
|
"Native Client mode">;
|
||||||
|
|
||||||
//===----------------------------------------------------------------------===//
|
//===----------------------------------------------------------------------===//
|
||||||
// X86 Subtarget features.
|
// X86 Subtarget features.
|
||||||
//===----------------------------------------------------------------------===//
|
//===----------------------------------------------------------------------===//
|
||||||
|
@@ -482,6 +482,14 @@ def In64BitMode : Predicate<"Subtarget->is64Bit()">,
|
|||||||
AssemblerPredicate<"Mode64Bit">;
|
AssemblerPredicate<"Mode64Bit">;
|
||||||
def IsWin64 : Predicate<"Subtarget->isTargetWin64()">;
|
def IsWin64 : Predicate<"Subtarget->isTargetWin64()">;
|
||||||
def NotWin64 : Predicate<"!Subtarget->isTargetWin64()">;
|
def NotWin64 : Predicate<"!Subtarget->isTargetWin64()">;
|
||||||
|
def IsNaCl : Predicate<"Subtarget->isTargetNaCl()">,
|
||||||
|
AssemblerPredicate<"ModeNaCl">;
|
||||||
|
def IsNaCl32 : Predicate<"Subtarget->isTargetNaCl32()">,
|
||||||
|
AssemblerPredicate<"ModeNaCl,!Mode64Bit">;
|
||||||
|
def IsNaCl64 : Predicate<"Subtarget->isTargetNaCl64()">,
|
||||||
|
AssemblerPredicate<"ModeNaCl,Mode64Bit">;
|
||||||
|
def NotNaCl : Predicate<"!Subtarget->isTargetNaCl()">,
|
||||||
|
AssemblerPredicate<"!ModeNaCl">;
|
||||||
def SmallCode : Predicate<"TM.getCodeModel() == CodeModel::Small">;
|
def SmallCode : Predicate<"TM.getCodeModel() == CodeModel::Small">;
|
||||||
def KernelCode : Predicate<"TM.getCodeModel() == CodeModel::Kernel">;
|
def KernelCode : Predicate<"TM.getCodeModel() == CodeModel::Kernel">;
|
||||||
def FarData : Predicate<"TM.getCodeModel() != CodeModel::Small &&"
|
def FarData : Predicate<"TM.getCodeModel() != CodeModel::Small &&"
|
||||||
|
@@ -260,7 +260,8 @@ X86Subtarget::X86Subtarget(const std::string &TT, const std::string &CPU,
|
|||||||
// FIXME: this is a known good value for Yonah. How about others?
|
// FIXME: this is a known good value for Yonah. How about others?
|
||||||
, MaxInlineSizeThreshold(128)
|
, MaxInlineSizeThreshold(128)
|
||||||
, TargetTriple(TT)
|
, TargetTriple(TT)
|
||||||
, In64BitMode(is64Bit) {
|
, In64BitMode(is64Bit)
|
||||||
|
, InNaClMode(false) {
|
||||||
// Determine default and user specified characteristics
|
// Determine default and user specified characteristics
|
||||||
if (!FS.empty() || !CPU.empty()) {
|
if (!FS.empty() || !CPU.empty()) {
|
||||||
std::string CPUName = CPU;
|
std::string CPUName = CPU;
|
||||||
@@ -306,6 +307,11 @@ X86Subtarget::X86Subtarget(const std::string &TT, const std::string &CPU,
|
|||||||
if (In64BitMode)
|
if (In64BitMode)
|
||||||
ToggleFeature(X86::Mode64Bit);
|
ToggleFeature(X86::Mode64Bit);
|
||||||
|
|
||||||
|
if (isTargetNaCl()) {
|
||||||
|
InNaClMode = true;
|
||||||
|
ToggleFeature(X86::ModeNaCl);
|
||||||
|
}
|
||||||
|
|
||||||
if (HasAVX)
|
if (HasAVX)
|
||||||
X86SSELevel = NoMMXSSE;
|
X86SSELevel = NoMMXSSE;
|
||||||
|
|
||||||
|
@@ -119,6 +119,9 @@ private:
|
|||||||
/// In64BitMode - True if compiling for 64-bit, false for 32-bit.
|
/// In64BitMode - True if compiling for 64-bit, false for 32-bit.
|
||||||
bool In64BitMode;
|
bool In64BitMode;
|
||||||
|
|
||||||
|
/// InNaClMode - True if compiling for Native Client target.
|
||||||
|
bool InNaClMode;
|
||||||
|
|
||||||
public:
|
public:
|
||||||
|
|
||||||
/// This constructor initializes the data members to match that
|
/// This constructor initializes the data members to match that
|
||||||
@@ -190,6 +193,11 @@ public:
|
|||||||
return !isTargetDarwin() && !isTargetWindows() && !isTargetCygMing();
|
return !isTargetDarwin() && !isTargetWindows() && !isTargetCygMing();
|
||||||
}
|
}
|
||||||
bool isTargetLinux() const { return TargetTriple.getOS() == Triple::Linux; }
|
bool isTargetLinux() const { return TargetTriple.getOS() == Triple::Linux; }
|
||||||
|
bool isTargetNaCl() const {
|
||||||
|
return TargetTriple.getOS() == Triple::NativeClient;
|
||||||
|
}
|
||||||
|
bool isTargetNaCl32() const { return isTargetNaCl() && !is64Bit(); }
|
||||||
|
bool isTargetNaCl64() const { return isTargetNaCl() && is64Bit(); }
|
||||||
|
|
||||||
bool isTargetWindows() const { return TargetTriple.getOS() == Triple::Win32; }
|
bool isTargetWindows() const { return TargetTriple.getOS() == Triple::Win32; }
|
||||||
bool isTargetMingw() const { return TargetTriple.getOS() == Triple::MinGW32; }
|
bool isTargetMingw() const { return TargetTriple.getOS() == Triple::MinGW32; }
|
||||||
|
Reference in New Issue
Block a user