Skip to content

Commit 84f1926

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 c84f34b commit 84f1926

File tree

5 files changed

+18
-15
lines changed

5 files changed

+18
-15
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.getArch() == Triple::x86_64;
6465
IsWin64 = Is64Bit && TT.isOSWindows();
6566
IsUEFI64 = Is64Bit && TT.isUEFI();
6667

llvm/lib/Target/X86/X86TargetMachine.cpp

Lines changed: 6 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -131,7 +131,7 @@ static std::string computeDataLayout(const Triple &TT) {
131131

132132
Ret += DataLayout::getManglingComponent(TT);
133133
// X86 and x32 have 32 bit pointers.
134-
if (!TT.isArch64Bit() || TT.isX32())
134+
if (TT.getArch() != Triple::x86_64 || TT.isX32())
135135
Ret += "-p:32:32";
136136

137137
// Address spaces for 32 bit signed, 32 bit unsigned, and 64 bit pointers.
@@ -140,7 +140,7 @@ static std::string computeDataLayout(const Triple &TT) {
140140
// Some ABIs align 64 bit integers and doubles to 64 bits, others to 32.
141141
// 128 bit integers are not specified in the 32-bit ABIs but are used
142142
// internally for lowering f128, so we match the alignment to that.
143-
if (TT.isArch64Bit() || TT.isOSWindows())
143+
if (TT.getArch() == Triple::x86_64 || TT.isOSWindows())
144144
Ret += "-i64:64-i128:128";
145145
else if (TT.isOSIAMCU())
146146
Ret += "-i64:32-f64:32";
@@ -150,7 +150,8 @@ static std::string computeDataLayout(const Triple &TT) {
150150
// Some ABIs align long double to 128 bits, others to 32.
151151
if (TT.isOSIAMCU())
152152
; // No f80
153-
else if (TT.isArch64Bit() || TT.isOSDarwin() || TT.isWindowsMSVCEnvironment())
153+
else if (TT.getArch() == Triple::x86_64 || TT.isOSDarwin() ||
154+
TT.isWindowsMSVCEnvironment())
154155
Ret += "-f80:128";
155156
else
156157
Ret += "-f80:32";
@@ -159,13 +160,13 @@ static std::string computeDataLayout(const Triple &TT) {
159160
Ret += "-f128:32";
160161

161162
// The registers can hold 8, 16, 32 or, in x86-64, 64 bits.
162-
if (TT.isArch64Bit())
163+
if (TT.getArch() == Triple::x86_64)
163164
Ret += "-n8:16:32:64";
164165
else
165166
Ret += "-n8:16:32";
166167

167168
// The stack is aligned to 32 bits on some ABIs and 128 bits on others.
168-
if ((!TT.isArch64Bit() && TT.isOSWindows()) || TT.isOSIAMCU())
169+
if ((TT.getArch() != Triple::x86_64 && TT.isOSWindows()) || TT.isOSIAMCU())
169170
Ret += "-a:0:32-S32";
170171
else
171172
Ret += "-S128";

0 commit comments

Comments
 (0)