本文整理汇总了C++中llvm::Triple::getArch方法的典型用法代码示例。如果您正苦于以下问题:C++ Triple::getArch方法的具体用法?C++ Triple::getArch怎么用?C++ Triple::getArch使用的例子?那么, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在类llvm::Triple
的用法示例。
在下文中一共展示了Triple::getArch方法的15个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的C++代码示例。
示例1:
std::unique_ptr<ELFLinkingContext>
elf::createMipsLinkingContext(llvm::Triple triple) {
if (triple.getArch() == llvm::Triple::mips ||
triple.getArch() == llvm::Triple::mipsel ||
triple.getArch() == llvm::Triple::mips64 ||
triple.getArch() == llvm::Triple::mips64el)
return llvm::make_unique<MipsLinkingContext>(triple);
return nullptr;
}
示例2: addPlatformSearchDirs
void GnuLdDriver::addPlatformSearchDirs(ELFLinkingContext &ctx,
llvm::Triple &triple,
llvm::Triple &baseTriple) {
if (triple.getOS() == llvm::Triple::NetBSD &&
triple.getArch() == llvm::Triple::x86 &&
baseTriple.getArch() == llvm::Triple::x86_64) {
ctx.addSearchPath("=/usr/lib/i386");
return;
}
ctx.addSearchPath("=/usr/lib");
}
示例3: areCompatibleArchitectures
static bool areCompatibleArchitectures(const llvm::Triple &moduleTarget,
const llvm::Triple &ctxTarget) {
if (moduleTarget.getArch() == ctxTarget.getArch())
return true;
auto archPair = std::minmax(moduleTarget.getArch(), ctxTarget.getArch());
if (archPair == std::minmax(llvm::Triple::arm, llvm::Triple::thumb))
return true;
if (archPair == std::minmax(llvm::Triple::armeb, llvm::Triple::thumbeb))
return true;
return false;
}
示例4: getFilePaths
FreeBSD::FreeBSD(const Driver &D, const llvm::Triple &Triple,
const ArgList &Args)
: Generic_ELF(D, Triple, Args) {
// When targeting 32-bit platforms, look for '/usr/lib32/crt1.o' and fall
// back to '/usr/lib' if it doesn't exist.
if ((Triple.getArch() == llvm::Triple::x86 ||
Triple.getArch() == llvm::Triple::mips ||
Triple.getArch() == llvm::Triple::mipsel ||
Triple.getArch() == llvm::Triple::ppc) &&
D.getVFS().exists(getDriver().SysRoot + "/usr/lib32/crt1.o"))
getFilePaths().push_back(getDriver().SysRoot + "/usr/lib32");
else
getFilePaths().push_back(getDriver().SysRoot + "/usr/lib");
}
示例5: switch
static llvm::Optional<llvm::Triple::ArchType>
getArchType(const llvm::Triple &triple, StringRef value) {
switch (triple.getArch()) {
case llvm::Triple::x86:
case llvm::Triple::x86_64:
if (value == "elf_i386")
return llvm::Triple::x86;
if (value == "elf_x86_64")
return llvm::Triple::x86_64;
return llvm::None;
case llvm::Triple::mips:
case llvm::Triple::mipsel:
case llvm::Triple::mips64:
case llvm::Triple::mips64el:
return llvm::StringSwitch<llvm::Optional<llvm::Triple::ArchType>>(value)
.Cases("elf32btsmip", "elf32btsmipn32", llvm::Triple::mips)
.Cases("elf32ltsmip", "elf32ltsmipn32", llvm::Triple::mipsel)
.Case("elf64btsmip", llvm::Triple::mips64)
.Case("elf64ltsmip", llvm::Triple::mips64el)
.Default(llvm::None);
case llvm::Triple::aarch64:
if (value == "aarch64linux")
return llvm::Triple::aarch64;
return llvm::None;
case llvm::Triple::arm:
if (value == "armelf_linux_eabi")
return llvm::Triple::arm;
return llvm::None;
default:
return llvm::None;
}
}
示例6: switch
MyriadToolChain::MyriadToolChain(const Driver &D, const llvm::Triple &Triple,
const ArgList &Args)
: Generic_ELF(D, Triple, Args) {
// If a target of 'sparc-myriad-elf' is specified to clang, it wants to use
// 'sparc-myriad--elf' (note the unknown OS) as the canonical triple.
// This won't work to find gcc. Instead we give the installation detector an
// extra triple, which is preferable to further hacks of the logic that at
// present is based solely on getArch(). In particular, it would be wrong to
// choose the myriad installation when targeting a non-myriad sparc install.
switch (Triple.getArch()) {
default:
D.Diag(clang::diag::err_target_unsupported_arch)
<< Triple.getArchName() << "myriad";
case llvm::Triple::sparc:
case llvm::Triple::sparcel:
case llvm::Triple::shave:
GCCInstallation.init(Triple, Args, {"sparc-myriad-elf"});
}
if (GCCInstallation.isValid()) {
// This directory contains crt{i,n,begin,end}.o as well as libgcc.
// These files are tied to a particular version of gcc.
SmallString<128> CompilerSupportDir(GCCInstallation.getInstallPath());
addPathIfExists(D, CompilerSupportDir, getFilePaths());
}
// libstd++ and libc++ must both be found in this one place.
addPathIfExists(D, D.Dir + "/../sparc-myriad-elf/lib", getFilePaths());
}
示例7: CalculateRTTIMode
static ToolChain::RTTIMode CalculateRTTIMode(const ArgList &Args,
const llvm::Triple &Triple,
const Arg *CachedRTTIArg) {
// Explicit rtti/no-rtti args
if (CachedRTTIArg) {
if (CachedRTTIArg->getOption().matches(options::OPT_frtti))
return ToolChain::RM_EnabledExplicitly;
else
return ToolChain::RM_DisabledExplicitly;
}
// On Cheerp -frtti is disabled by default
if (Triple.getArch() == llvm::Triple::cheerp)
return ToolChain::RM_DisabledImplicitly;
// -frtti is default, except for the PS4 CPU.
if (!Triple.isPS4CPU())
return ToolChain::RM_EnabledImplicitly;
// On the PS4, turning on c++ exceptions turns on rtti.
// We're assuming that, if we see -fexceptions, rtti gets turned on.
Arg *Exceptions = Args.getLastArgNoClaim(
options::OPT_fcxx_exceptions, options::OPT_fno_cxx_exceptions,
options::OPT_fexceptions, options::OPT_fno_exceptions);
if (Exceptions &&
(Exceptions->getOption().matches(options::OPT_fexceptions) ||
Exceptions->getOption().matches(options::OPT_fcxx_exceptions)))
return ToolChain::RM_EnabledImplicitly;
return ToolChain::RM_DisabledImplicitly;
}
示例8: getARMTargetCPU
/// Returns the LLVM name of the target CPU to use given the provided
/// -mcpu argument and target triple.
static std::string getTargetCPU(const std::string &cpu,
const llvm::Triple &triple)
{
if (!cpu.empty())
{
if (cpu != "native")
return cpu;
// FIXME: Reject attempts to use -mcpu=native unless the target matches
// the host.
std::string hostCPU = llvm::sys::getHostCPUName();
if (!hostCPU.empty() && hostCPU != "generic")
return hostCPU;
}
switch (triple.getArch())
{
default:
// We don't know about the specifics of this platform, just return the
// empty string and let LLVM decide.
return cpu;
case llvm::Triple::x86:
case llvm::Triple::x86_64:
return getX86TargetCPU(triple);
case llvm::Triple::arm:
return getARMTargetCPU(triple);
}
}
示例9: getFilePaths
Solaris::Solaris(const Driver &D, const llvm::Triple &Triple,
const ArgList &Args)
: Generic_ELF(D, Triple, Args) {
GCCInstallation.init(Triple, Args);
path_list &Paths = getFilePaths();
if (GCCInstallation.isValid())
addPathIfExists(D, GCCInstallation.getInstallPath(), Paths);
addPathIfExists(D, getDriver().getInstalledDir(), Paths);
if (getDriver().getInstalledDir() != getDriver().Dir)
addPathIfExists(D, getDriver().Dir, Paths);
addPathIfExists(D, getDriver().SysRoot + getDriver().Dir + "/../lib", Paths);
std::string LibPath = "/usr/lib/";
switch (Triple.getArch()) {
case llvm::Triple::x86:
case llvm::Triple::sparc:
break;
case llvm::Triple::x86_64:
LibPath += "amd64/";
break;
case llvm::Triple::sparcv9:
LibPath += "sparcv9/";
break;
default:
llvm_unreachable("Unsupported architecture");
}
addPathIfExists(D, getDriver().SysRoot + LibPath, Paths);
}
示例10: switch
static llvm::Optional<llvm::Triple::ArchType>
getArchType(const llvm::Triple &triple, StringRef value) {
switch (triple.getArch()) {
case llvm::Triple::x86:
case llvm::Triple::x86_64:
if (value == "elf_i386")
return llvm::Triple::x86;
if (value == "elf_x86_64")
return llvm::Triple::x86_64;
return llvm::None;
case llvm::Triple::mipsel:
case llvm::Triple::mips64el:
if (value == "elf32ltsmip")
return llvm::Triple::mipsel;
if (value == "elf64ltsmip")
return llvm::Triple::mips64el;
return llvm::None;
case llvm::Triple::aarch64:
if (value == "aarch64linux")
return llvm::Triple::aarch64;
return llvm::None;
case llvm::Triple::arm:
if (value == "armelf_linux_eabi")
return llvm::Triple::arm;
return llvm::None;
default:
return llvm::None;
}
}
示例11: addMipsABI
/// Sanitizes the MIPS ABI in the feature string.
static void addMipsABI(const llvm::Triple &triple,
std::vector<std::string> &attrs) {
enum ABI { O32 = 1 << 0, N32 = 1 << 1, N64 = 1 << 2, EABI = 1 << 3 };
const bool is64Bit = triple.getArch() == llvm::Triple::mips64 ||
triple.getArch() == llvm::Triple::mips64el;
const uint32_t defaultABI = is64Bit ? N64 : O32;
uint32_t bits = defaultABI;
auto I = attrs.begin();
while (I != attrs.end()) {
std::string str = *I;
bool enabled = str[0] == '+';
std::string flag = (str[0] == '+' || str[0] == '-') ? str.substr(1) : str;
uint32_t newBit = 0;
if (flag == "o32") {
newBit = O32;
}
if (flag == "n32") {
newBit = N32;
}
if (flag == "n64") {
newBit = N64;
}
if (flag == "eabi") {
newBit = EABI;
}
if (newBit) {
I = attrs.erase(I);
if (enabled) {
bits |= newBit;
} else {
bits &= ~newBit;
}
} else {
++I;
}
}
switch (bits) {
case O32:
attrs.push_back("+o32");
break;
case N32:
attrs.push_back("+n32");
break;
case N64:
attrs.push_back("+n64");
break;
case EABI:
attrs.push_back("+eabi");
break;
default:
error(Loc(), "Only one ABI argument is supported");
fatal();
}
if (bits != defaultABI) {
attrs.push_back(is64Bit ? "-n64" : "-o32");
}
}
示例12: createTarget
static TargetHandlerPtr createTarget(llvm::Triple triple,
MipsLinkingContext &ctx) {
switch (triple.getArch()) {
case llvm::Triple::mipsel:
return TargetHandlerPtr(new MipsTargetHandler<Mips32ELType>(ctx));
case llvm::Triple::mips64el:
return TargetHandlerPtr(new MipsTargetHandler<Mips64ELType>(ctx));
default:
llvm_unreachable("Unhandled arch");
}
}
示例13: asmSemantic
Statement* asmSemantic(AsmStatement *s, Scope *sc)
{
if (sc->func && sc->func->isSafe())
s->error("inline assembler not allowed in @safe function %s", sc->func->toChars());
bool err = false;
llvm::Triple const t = global.params.targetTriple;
if (!(t.getArch() == llvm::Triple::x86 || t.getArch() == llvm::Triple::x86_64))
{
s->error("inline asm is not supported for the \"%s\" architecture",
t.getArchName().str().c_str());
err = true;
}
if (!global.params.useInlineAsm)
{
s->error("inline asm is not allowed when the -noasm switch is used");
err = true;
}
if (err)
fatal();
//puts(toChars());
sc->func->hasReturnExp |= 8;
// empty statement -- still do the above things because they might be expected?
if (!s->tokens)
return s;
if (!asmparser)
{
if (t.getArch() == llvm::Triple::x86)
asmparser = new AsmParserx8632::AsmParser;
else if (t.getArch() == llvm::Triple::x86_64)
asmparser = new AsmParserx8664::AsmParser;
}
asmparser->run(sc, s);
return s;
}
示例14: FilePath
/// NaCl Toolchain
NaClToolChain::NaClToolChain(const Driver &D, const llvm::Triple &Triple,
const ArgList &Args)
: Generic_ELF(D, Triple, Args) {
// Remove paths added by Generic_GCC. NaCl Toolchain cannot use the
// default paths, and must instead only use the paths provided
// with this toolchain based on architecture.
path_list &file_paths = getFilePaths();
path_list &prog_paths = getProgramPaths();
file_paths.clear();
prog_paths.clear();
// Path for library files (libc.a, ...)
std::string FilePath(getDriver().Dir + "/../");
// Path for tools (clang, ld, etc..)
std::string ProgPath(getDriver().Dir + "/../");
// Path for toolchain libraries (libgcc.a, ...)
std::string ToolPath(getDriver().ResourceDir + "/lib/");
switch (Triple.getArch()) {
case llvm::Triple::x86:
file_paths.push_back(FilePath + "x86_64-nacl/lib32");
file_paths.push_back(FilePath + "i686-nacl/usr/lib");
prog_paths.push_back(ProgPath + "x86_64-nacl/bin");
file_paths.push_back(ToolPath + "i686-nacl");
break;
case llvm::Triple::x86_64:
file_paths.push_back(FilePath + "x86_64-nacl/lib");
file_paths.push_back(FilePath + "x86_64-nacl/usr/lib");
prog_paths.push_back(ProgPath + "x86_64-nacl/bin");
file_paths.push_back(ToolPath + "x86_64-nacl");
break;
case llvm::Triple::arm:
file_paths.push_back(FilePath + "arm-nacl/lib");
file_paths.push_back(FilePath + "arm-nacl/usr/lib");
prog_paths.push_back(ProgPath + "arm-nacl/bin");
file_paths.push_back(ToolPath + "arm-nacl");
break;
case llvm::Triple::mipsel:
file_paths.push_back(FilePath + "mipsel-nacl/lib");
file_paths.push_back(FilePath + "mipsel-nacl/usr/lib");
prog_paths.push_back(ProgPath + "bin");
file_paths.push_back(ToolPath + "mipsel-nacl");
break;
default:
break;
}
NaClArmMacrosPath = GetFilePath("nacl-arm-macros.s");
}
示例15: getOSLibDir
static StringRef getOSLibDir(const llvm::Triple &Triple, const ArgList &Args) {
if (tools::isMipsArch(Triple.getArch())) {
if (Triple.isAndroid()) {
StringRef CPUName;
StringRef ABIName;
tools::mips::getMipsCPUAndABI(Args, Triple, CPUName, ABIName);
if (CPUName == "mips32r6")
return "libr6";
if (CPUName == "mips32r2")
return "libr2";
}
// lib32 directory has a special meaning on MIPS targets.
// It contains N32 ABI binaries. Use this folder if produce
// code for N32 ABI only.
if (tools::mips::hasMipsAbiArg(Args, "n32"))
return "lib32";
return Triple.isArch32Bit() ? "lib" : "lib64";
}
// It happens that only x86 and PPC use the 'lib32' variant of oslibdir, and
// using that variant while targeting other architectures causes problems
// because the libraries are laid out in shared system roots that can't cope
// with a 'lib32' library search path being considered. So we only enable
// them when we know we may need it.
//
// FIXME: This is a bit of a hack. We should really unify this code for
// reasoning about oslibdir spellings with the lib dir spellings in the
// GCCInstallationDetector, but that is a more significant refactoring.
if (Triple.getArch() == llvm::Triple::x86 ||
Triple.getArch() == llvm::Triple::ppc)
return "lib32";
if (Triple.getArch() == llvm::Triple::x86_64 &&
Triple.getEnvironment() == llvm::Triple::GNUX32)
return "libx32";
return Triple.isArch32Bit() ? "lib" : "lib64";
}