Skip to content

Commit 7768cca

Browse files
authored
Mips: Force 64bit subtarget feature to be set for ABI options (#157446)
Prepare to use this with HwMode. This is mostly code copied from x86. Mips has an exceptionally broken system where the target-abi option can be used to change the pointer size. i.e., you can mix and match 32-bit base triples with an explicit request to use 32-bit or 64-bit pointers such that you cannot rely on the triple reported pointer size. This hack manages to only work for codegen. The MC subtarget constructors do not have access to the target-abi name so those will continue to not have the appropriate feature set.
1 parent d4079cf commit 7768cca

File tree

1 file changed

+12
-2
lines changed

1 file changed

+12
-2
lines changed

llvm/lib/Target/Mips/MipsSubtarget.cpp

Lines changed: 12 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -245,10 +245,20 @@ CodeGenOptLevel MipsSubtarget::getOptLevelToEnablePostRAScheduler() const {
245245
MipsSubtarget &
246246
MipsSubtarget::initializeSubtargetDependencies(StringRef CPU, StringRef FS,
247247
const TargetMachine &TM) {
248-
StringRef CPUName = MIPS_MC::selectMipsCPU(TM.getTargetTriple(), CPU);
248+
const Triple &TT = TM.getTargetTriple();
249+
StringRef CPUName = MIPS_MC::selectMipsCPU(TT, CPU);
250+
251+
std::string FullFS;
252+
if (getABI().ArePtrs64bit()) {
253+
FullFS = "+ptr64";
254+
if (!FS.empty())
255+
FullFS = (Twine(FullFS) + "," + FS).str();
256+
} else {
257+
FullFS = FS.str();
258+
}
249259

250260
// Parse features string.
251-
ParseSubtargetFeatures(CPUName, /*TuneCPU*/ CPUName, FS);
261+
ParseSubtargetFeatures(CPUName, /*TuneCPU=*/CPUName, FullFS);
252262
// Initialize scheduling itinerary for the specified CPU.
253263
InstrItins = getInstrItineraryForCPU(CPUName);
254264

0 commit comments

Comments
 (0)