Skip to content

Commit 45293b5

Browse files
authored
MIPS/Clang: handleTargetFeatures, add +fp64 if +msa and no other +-fp (llvm#92728)
Commit: d59bc6b Clang/MIPS: Add +fp64 if MSA and no explicit -mfp option (llvm#91949) added +fp64 for `clang`, while not for `clang -cc1`. So clang -cc1 -triple=mips -target-feature +msa -S will emit an asm source file without ".module fp=64".
1 parent 1664610 commit 45293b5

File tree

1 file changed

+13
-4
lines changed

1 file changed

+13
-4
lines changed

clang/lib/Basic/Targets/Mips.h

Lines changed: 13 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -324,6 +324,7 @@ class LLVM_LIBRARY_VISIBILITY MipsTargetInfo : public TargetInfo {
324324
FPMode = getDefaultFPMode();
325325
bool OddSpregGiven = false;
326326
bool StrictAlign = false;
327+
bool FpGiven = false;
327328

328329
for (const auto &Feature : Features) {
329330
if (Feature == "+single-float")
@@ -348,13 +349,16 @@ class LLVM_LIBRARY_VISIBILITY MipsTargetInfo : public TargetInfo {
348349
HasMSA = true;
349350
else if (Feature == "+nomadd4")
350351
DisableMadd4 = true;
351-
else if (Feature == "+fp64")
352+
else if (Feature == "+fp64") {
352353
FPMode = FP64;
353-
else if (Feature == "-fp64")
354+
FpGiven = true;
355+
} else if (Feature == "-fp64") {
354356
FPMode = FP32;
355-
else if (Feature == "+fpxx")
357+
FpGiven = true;
358+
} else if (Feature == "+fpxx") {
356359
FPMode = FPXX;
357-
else if (Feature == "+nan2008")
360+
FpGiven = true;
361+
} else if (Feature == "+nan2008")
358362
IsNan2008 = true;
359363
else if (Feature == "-nan2008")
360364
IsNan2008 = false;
@@ -381,6 +385,11 @@ class LLVM_LIBRARY_VISIBILITY MipsTargetInfo : public TargetInfo {
381385
if (StrictAlign)
382386
HasUnalignedAccess = false;
383387

388+
if (HasMSA && !FpGiven) {
389+
FPMode = FP64;
390+
Features.push_back("+fp64");
391+
}
392+
384393
setDataLayout();
385394

386395
return true;

0 commit comments

Comments
 (0)