diff --git a/clang/include/clang/Basic/TargetInfo.h b/clang/include/clang/Basic/TargetInfo.h index a32b30f5b7e976..3a8e35524695c1 100644 --- a/clang/include/clang/Basic/TargetInfo.h +++ b/clang/include/clang/Basic/TargetInfo.h @@ -1146,10 +1146,7 @@ class TargetInfo : public virtual TransferrableTargetInfo, /// Identify whether this target supports multiversioning of functions, /// which requires support for cpu_supports and cpu_is functionality. - bool supportsMultiVersioning() const { - return getTriple().getArch() == llvm::Triple::x86 || - getTriple().getArch() == llvm::Triple::x86_64; - } + bool supportsMultiVersioning() const { return getTriple().isX86(); } /// Identify whether this target supports IFuncs. bool supportsIFunc() const { return getTriple().isOSBinFormatELF(); } @@ -1214,8 +1211,7 @@ class TargetInfo : public virtual TransferrableTargetInfo, /// Whether the target supports SEH __try. bool isSEHTrySupported() const { return getTriple().isOSWindows() && - (getTriple().getArch() == llvm::Triple::x86 || - getTriple().getArch() == llvm::Triple::x86_64 || + (getTriple().isX86() || getTriple().getArch() == llvm::Triple::aarch64); } diff --git a/clang/lib/AST/Mangle.cpp b/clang/lib/AST/Mangle.cpp index 32d466cb571807..e106b31f59f02d 100644 --- a/clang/lib/AST/Mangle.cpp +++ b/clang/lib/AST/Mangle.cpp @@ -63,9 +63,7 @@ static CCMangling getCallingConvMangling(const ASTContext &Context, const NamedDecl *ND) { const TargetInfo &TI = Context.getTargetInfo(); const llvm::Triple &Triple = TI.getTriple(); - if (!Triple.isOSWindows() || - !(Triple.getArch() == llvm::Triple::x86 || - Triple.getArch() == llvm::Triple::x86_64)) + if (!Triple.isOSWindows() || !Triple.isX86()) return CCM_Other; if (Context.getLangOpts().CPlusPlus && !isExternC(ND) && diff --git a/clang/lib/CodeGen/CGOpenMPRuntime.cpp b/clang/lib/CodeGen/CGOpenMPRuntime.cpp index b3b16befeea45a..b71756f2449fe6 100644 --- a/clang/lib/CodeGen/CGOpenMPRuntime.cpp +++ b/clang/lib/CodeGen/CGOpenMPRuntime.cpp @@ -10829,8 +10829,7 @@ void CGOpenMPRuntime::emitDeclareSimdFunction(const FunctionDecl *FD, ExprLoc = VLENExpr->getExprLoc(); } OMPDeclareSimdDeclAttr::BranchStateTy State = Attr->getBranchState(); - if (CGM.getTriple().getArch() == llvm::Triple::x86 || - CGM.getTriple().getArch() == llvm::Triple::x86_64) { + if (CGM.getTriple().isX86()) { emitX86DeclareSimdFunction(FD, Fn, VLENVal, ParamAttrs, State); } else if (CGM.getTriple().getArch() == llvm::Triple::aarch64) { unsigned VLEN = VLENVal.getExtValue(); diff --git a/clang/lib/CodeGen/CodeGenFunction.cpp b/clang/lib/CodeGen/CodeGenFunction.cpp index 448b70de9714fc..a717f43e3efdd9 100644 --- a/clang/lib/CodeGen/CodeGenFunction.cpp +++ b/clang/lib/CodeGen/CodeGenFunction.cpp @@ -2378,10 +2378,7 @@ static void CreateMultiVersionResolverReturn(CodeGenModule &CGM, void CodeGenFunction::EmitMultiVersionResolver( llvm::Function *Resolver, ArrayRef Options) { - assert((getContext().getTargetInfo().getTriple().getArch() == - llvm::Triple::x86 || - getContext().getTargetInfo().getTriple().getArch() == - llvm::Triple::x86_64) && + assert(getContext().getTargetInfo().getTriple().isX86() && "Only implemented for x86 targets"); bool SupportsIFunc = getContext().getTargetInfo().supportsIFunc(); diff --git a/clang/lib/Driver/ToolChains/Arch/X86.cpp b/clang/lib/Driver/ToolChains/Arch/X86.cpp index d2b97bf6ad7194..d1e0c8253b7998 100644 --- a/clang/lib/Driver/ToolChains/Arch/X86.cpp +++ b/clang/lib/Driver/ToolChains/Arch/X86.cpp @@ -63,8 +63,7 @@ const char *x86::getX86TargetCPU(const ArgList &Args, // Select the default CPU if none was given (or detection failed). - if (Triple.getArch() != llvm::Triple::x86_64 && - Triple.getArch() != llvm::Triple::x86) + if (!Triple.isX86()) return nullptr; // This routine is only handling x86 targets. bool Is64Bit = Triple.getArch() == llvm::Triple::x86_64; diff --git a/clang/lib/Driver/ToolChains/Clang.cpp b/clang/lib/Driver/ToolChains/Clang.cpp index e75dd6badc14e6..beca558ea71835 100644 --- a/clang/lib/Driver/ToolChains/Clang.cpp +++ b/clang/lib/Driver/ToolChains/Clang.cpp @@ -4433,8 +4433,7 @@ void Clang::ConstructJob(Compilation &C, const JobAction &JA, RenderFloatingPointOptions(TC, D, OFastEnabled, Args, CmdArgs); if (Arg *A = Args.getLastArg(options::OPT_LongDouble_Group)) { - if (TC.getArch() == llvm::Triple::x86 || - TC.getArch() == llvm::Triple::x86_64) + if (TC.getTriple().isX86()) A->render(Args, CmdArgs); else if ((TC.getArch() == llvm::Triple::ppc || TC.getTriple().isPPC64()) && (A->getOption().getID() != options::OPT_mlong_double_80)) @@ -5003,8 +5002,7 @@ void Clang::ConstructJob(Compilation &C, const JobAction &JA, llvm::Triple::ArchType Arch = TC.getArch(); if (Arg *A = Args.getLastArg(options::OPT_mfentry)) { - if (Arch == llvm::Triple::systemz || Arch == llvm::Triple::x86 || - Arch == llvm::Triple::x86_64) + if (Arch == llvm::Triple::systemz || TC.getTriple().isX86()) A->render(Args, CmdArgs); else D.Diag(diag::err_drv_unsupported_opt_for_target) @@ -6273,8 +6271,7 @@ void Clang::AddClangCLArgs(const ArgList &Args, types::ID InputType, } unsigned VolatileOptionID; - if (getToolChain().getArch() == llvm::Triple::x86_64 || - getToolChain().getArch() == llvm::Triple::x86) + if (getToolChain().getTriple().isX86()) VolatileOptionID = options::OPT__SLASH_volatile_ms; else VolatileOptionID = options::OPT__SLASH_volatile_iso; diff --git a/clang/lib/Driver/ToolChains/Darwin.cpp b/clang/lib/Driver/ToolChains/Darwin.cpp index a2ac532c015866..344a14fe1ea7ce 100644 --- a/clang/lib/Driver/ToolChains/Darwin.cpp +++ b/clang/lib/Driver/ToolChains/Darwin.cpp @@ -124,8 +124,7 @@ void darwin::Assembler::ConstructJob(Compilation &C, const JobAction &JA, AddMachOArch(Args, CmdArgs); // Use -force_cpusubtype_ALL on x86 by default. - if (getToolChain().getArch() == llvm::Triple::x86 || - getToolChain().getArch() == llvm::Triple::x86_64 || + if (getToolChain().getTriple().isX86() || Args.hasArg(options::OPT_force__cpusubtype__ALL)) CmdArgs.push_back("-force_cpusubtype_ALL"); @@ -1836,9 +1835,7 @@ void Darwin::AddDeploymentTarget(DerivedArgList &Args) const { DarwinEnvironmentKind Environment = OSTarget->getEnvironment(); // Recognize iOS targets with an x86 architecture as the iOS simulator. if (Environment == NativeEnvironment && Platform != MacOS && - OSTarget->canInferSimulatorFromArch() && - (getTriple().getArch() == llvm::Triple::x86 || - getTriple().getArch() == llvm::Triple::x86_64)) + OSTarget->canInferSimulatorFromArch() && getTriple().isX86()) Environment = Simulator; setTarget(Platform, Environment, Major, Minor, Micro); @@ -2234,8 +2231,7 @@ DerivedArgList *MachO::TranslateArgs(const DerivedArgList &Args, } } - if (getTriple().getArch() == llvm::Triple::x86 || - getTriple().getArch() == llvm::Triple::x86_64) + if (getTriple().isX86()) if (!Args.hasArgNoClaim(options::OPT_mtune_EQ)) DAL->AddJoinedArg(nullptr, Opts.getOption(options::OPT_mtune_EQ), "core2"); diff --git a/clang/lib/Sema/SemaExpr.cpp b/clang/lib/Sema/SemaExpr.cpp index 15e86ba8e8d5f9..61cd629646f60e 100644 --- a/clang/lib/Sema/SemaExpr.cpp +++ b/clang/lib/Sema/SemaExpr.cpp @@ -15359,8 +15359,7 @@ static bool funcHasParameterSizeMangling(Sema &S, FunctionDecl *FD) { // These manglings don't do anything on non-Windows or non-x86 platforms, so // we don't need parameter type sizes. const llvm::Triple &TT = S.Context.getTargetInfo().getTriple(); - if (!TT.isOSWindows() || (TT.getArch() != llvm::Triple::x86 && - TT.getArch() != llvm::Triple::x86_64)) + if (!TT.isOSWindows() || !TT.isX86()) return false; // If this is C++ and this isn't an extern "C" function, parameters do not diff --git a/llvm/lib/Analysis/TargetLibraryInfo.cpp b/llvm/lib/Analysis/TargetLibraryInfo.cpp index 80f3095599794d..c7238db43aab66 100644 --- a/llvm/lib/Analysis/TargetLibraryInfo.cpp +++ b/llvm/lib/Analysis/TargetLibraryInfo.cpp @@ -379,10 +379,8 @@ static void initialize(TargetLibraryInfoImpl &TLI, const Triple &T, case Triple::TvOS: case Triple::WatchOS: TLI.setUnavailable(LibFunc_exp10l); - if (!T.isWatchOS() && (T.isOSVersionLT(7, 0) || - (T.isOSVersionLT(9, 0) && - (T.getArch() == Triple::x86 || - T.getArch() == Triple::x86_64)))) { + if (!T.isWatchOS() && + (T.isOSVersionLT(7, 0) || (T.isOSVersionLT(9, 0) && T.isX86()))) { TLI.setUnavailable(LibFunc_exp10); TLI.setUnavailable(LibFunc_exp10f); } else { diff --git a/llvm/lib/MC/MCObjectFileInfo.cpp b/llvm/lib/MC/MCObjectFileInfo.cpp index 76784c7bb0d3a8..29fbda2be82b60 100644 --- a/llvm/lib/MC/MCObjectFileInfo.cpp +++ b/llvm/lib/MC/MCObjectFileInfo.cpp @@ -40,8 +40,7 @@ static bool useCompactUnwind(const Triple &T) { return true; // And the iOS simulator. - if (T.isiOS() && - (T.getArch() == Triple::x86_64 || T.getArch() == Triple::x86)) + if (T.isiOS() && T.isX86()) return true; return false; @@ -192,7 +191,7 @@ void MCObjectFileInfo::initMachOMCObjectFileInfo(const Triple &T) { Ctx->getMachOSection("__LD", "__compact_unwind", MachO::S_ATTR_DEBUG, SectionKind::getReadOnly()); - if (T.getArch() == Triple::x86_64 || T.getArch() == Triple::x86) + if (T.isX86()) CompactUnwindDwarfEHFrameOnly = 0x04000000; // UNWIND_X86_64_MODE_DWARF else if (T.getArch() == Triple::aarch64 || T.getArch() == Triple::aarch64_32) CompactUnwindDwarfEHFrameOnly = 0x03000000; // UNWIND_ARM64_MODE_DWARF diff --git a/llvm/tools/llvm-objdump/MachODump.cpp b/llvm/tools/llvm-objdump/MachODump.cpp index 629c6030e7167d..99426f8d5cd78a 100644 --- a/llvm/tools/llvm-objdump/MachODump.cpp +++ b/llvm/tools/llvm-objdump/MachODump.cpp @@ -7650,8 +7650,7 @@ static void DisassembleMachO(StringRef Filename, MachOObjectFile *MachOOF, } outs() << "\n"; } else { - unsigned int Arch = MachOOF->getArch(); - if (Arch == Triple::x86_64 || Arch == Triple::x86) { + if (MachOOF->getArchTriple().isX86()) { outs() << format("\t.byte 0x%02x #bad opcode\n", *(Bytes.data() + Index) & 0xff); Size = 1; // skip exactly one illegible byte and move on. @@ -7716,8 +7715,7 @@ static void DisassembleMachO(StringRef Filename, MachOObjectFile *MachOOF, IP->printInst(&Inst, PC, AnnotationsStr, *STI, outs()); outs() << "\n"; } else { - unsigned int Arch = MachOOF->getArch(); - if (Arch == Triple::x86_64 || Arch == Triple::x86) { + if (MachOOF->getArchTriple().isX86()) { outs() << format("\t.byte 0x%02x #bad opcode\n", *(Bytes.data() + Index) & 0xff); InstSize = 1; // skip exactly one illegible byte and move on.