Skip to content

Commit 6cecbb8

Browse files
committed
X86: Avoid using isArch64Bit for 64-bit checks
Just directly check x86_64. isArch64Bit just adds extra steps around this.
1 parent fba55c8 commit 6cecbb8

File tree

5 files changed

+13
-11
lines changed

5 files changed

+13
-11
lines changed

llvm/lib/Target/X86/MCTargetDesc/X86AsmBackend.cpp

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1286,7 +1286,7 @@ class DarwinX86AsmBackend : public X86AsmBackend {
12861286
DarwinX86AsmBackend(const Target &T, const MCRegisterInfo &MRI,
12871287
const MCSubtargetInfo &STI)
12881288
: X86AsmBackend(T, STI), MRI(MRI), TT(STI.getTargetTriple()),
1289-
Is64Bit(TT.isArch64Bit()) {
1289+
Is64Bit(TT.getArch() == Triple::x86_64) {
12901290
memset(SavedRegs, 0, sizeof(SavedRegs));
12911291
OffsetSize = Is64Bit ? 8 : 4;
12921292
MoveInstrSize = Is64Bit ? 3 : 2;

llvm/lib/Target/X86/MCTargetDesc/X86MCTargetDesc.cpp

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -48,7 +48,7 @@ std::string X86_MC::ParseX86Triple(const Triple &TT) {
4848
std::string FS;
4949
// SSE2 should default to enabled in 64-bit mode, but can be turned off
5050
// explicitly.
51-
if (TT.isArch64Bit())
51+
if (TT.getArch() == Triple::x86_64)
5252
FS = "+64bit-mode,-32bit-mode,-16bit-mode,+sse2";
5353
else if (TT.getEnvironment() != Triple::CODE16)
5454
FS = "-64bit-mode,+32bit-mode,-16bit-mode";

llvm/lib/Target/X86/X86AsmPrinter.cpp

Lines changed: 4 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -194,7 +194,7 @@ void X86AsmPrinter::emitKCFITypeId(const MachineFunction &MF) {
194194
if (F.getParent()->getModuleFlag("kcfi-arity")) {
195195
// The ArityToRegMap assumes the 64-bit SysV ABI.
196196
[[maybe_unused]] const auto &Triple = MF.getTarget().getTargetTriple();
197-
assert(Triple.isArch64Bit() && !Triple.isOSWindows());
197+
assert(Triple.getArch() == Triple::x86_64 && !Triple.isOSWindows());
198198

199199
// Determine the function's arity (i.e., the number of arguments) at the ABI
200200
// level by counting the number of parameters that are passed
@@ -897,15 +897,16 @@ void X86AsmPrinter::emitStartOfAsmFile(Module &M) {
897897

898898
if (FeatureFlagsAnd) {
899899
// Emit a .note.gnu.property section with the flags.
900-
assert((TT.isArch32Bit() || TT.isArch64Bit()) &&
900+
assert((TT.isArch32Bit() || TT.getArch() == Triple::x86_64) &&
901901
"CFProtection used on invalid architecture!");
902902
MCSection *Cur = OutStreamer->getCurrentSectionOnly();
903903
MCSection *Nt = MMI->getContext().getELFSection(
904904
".note.gnu.property", ELF::SHT_NOTE, ELF::SHF_ALLOC);
905905
OutStreamer->switchSection(Nt);
906906

907907
// Emitting note header.
908-
const int WordSize = TT.isArch64Bit() && !TT.isX32() ? 8 : 4;
908+
const int WordSize =
909+
TT.getArch() == Triple::x86_64 && !TT.isX32() ? 8 : 4;
909910
emitAlignment(WordSize == 4 ? Align(4) : Align(8));
910911
OutStreamer->emitIntValue(4, 4 /*size*/); // data size for "GNU\0"
911912
OutStreamer->emitIntValue(8 + WordSize, 4 /*size*/); // Elf_Prop size

llvm/lib/Target/X86/X86RegisterInfo.cpp

Lines changed: 6 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -53,14 +53,15 @@ static cl::opt<bool>
5353
extern cl::opt<bool> X86EnableAPXForRelocation;
5454

5555
X86RegisterInfo::X86RegisterInfo(const Triple &TT)
56-
: X86GenRegisterInfo((TT.isArch64Bit() ? X86::RIP : X86::EIP),
57-
X86_MC::getDwarfRegFlavour(TT, false),
58-
X86_MC::getDwarfRegFlavour(TT, true),
59-
(TT.isArch64Bit() ? X86::RIP : X86::EIP)) {
56+
: X86GenRegisterInfo(
57+
(TT.getArch() == Triple::x86_64 ? X86::RIP : X86::EIP),
58+
X86_MC::getDwarfRegFlavour(TT, false),
59+
X86_MC::getDwarfRegFlavour(TT, true),
60+
(TT.getArch() == Triple::x86_64 ? X86::RIP : X86::EIP)) {
6061
X86_MC::initLLVMToSEHAndCVRegMapping(this);
6162

6263
// Cache some information.
63-
Is64Bit = TT.isArch64Bit();
64+
Is64Bit = TT.isX86_64();
6465
IsTarget64BitLP64 = Is64Bit && !TT.isX32();
6566
IsWin64 = Is64Bit && TT.isOSWindows();
6667
IsUEFI64 = Is64Bit && TT.isUEFI();

llvm/lib/TargetParser/TargetDataLayout.cpp

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -379,7 +379,7 @@ static std::string computeSystemZDataLayout(const Triple &TT) {
379379
}
380380

381381
static std::string computeX86DataLayout(const Triple &TT) {
382-
bool Is64Bit = TT.getArch() == Triple::x86_64;
382+
bool Is64Bit = TT.isX86_64();
383383

384384
// X86 is little endian
385385
std::string Ret = "e";

0 commit comments

Comments
 (0)