[NFC] Use isX86() instead of getArch()

Summary: This is a clean up for https://reviews.llvm.org/D72247.

Reviewers: MaskRay, craig.topper, jhenderson

Reviewed By: MaskRay

Subscribers: hiraditya, rupprecht, cfe-commits, llvm-commits

Tags: #clang, #llvm

Differential Revision: https://reviews.llvm.org/D72320
This commit is contained in:
Jim Lin 2020-01-07 17:32:39 +08:00
parent 4814b68b7a
commit ab1bcda851
11 changed files with 19 additions and 43 deletions

View File

@ -1146,10 +1146,7 @@ public:
/// 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 @@ public:
/// 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);
}

View File

@ -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) &&

View File

@ -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();

View File

@ -2378,10 +2378,7 @@ static void CreateMultiVersionResolverReturn(CodeGenModule &CGM,
void CodeGenFunction::EmitMultiVersionResolver(
llvm::Function *Resolver, ArrayRef<MultiVersionResolverOption> 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();

View File

@ -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;

View File

@ -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;

View File

@ -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");

View File

@ -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

View File

@ -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 {

View File

@ -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

View File

@ -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.