Skip to content

Commit a1b6e7f

Browse files
authored
[clang][LoongArch] Ensure target("lasx") implies LSX support (#153542)
Currently, `__attribute__((target("lasx")))` does not automatically enable LSX support, causing Clang to fail with `-mno-lsx`. Since LASX depends on LSX, enabling LASX should implicitly enable LSX to avoid clang error. Fixes #149512. Depends on #153541
1 parent 10d9e7b commit a1b6e7f

File tree

2 files changed

+3
-1
lines changed

2 files changed

+3
-1
lines changed

clang/lib/Basic/Targets/LoongArch.cpp

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -461,6 +461,8 @@ LoongArchTargetInfo::parseTargetAttr(StringRef Features) const {
461461

462462
case AttrFeatureKind::Feature:
463463
Ret.Features.push_back("+" + Value.str());
464+
if (Value == "lasx")
465+
Ret.Features.push_back("+lsx");
464466
break;
465467
}
466468
}

clang/test/CodeGen/LoongArch/targetattr-lasx.c

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -4,4 +4,4 @@ __attribute__((target("lasx")))
44
// CHECK: #[[ATTR0:[0-9]+]] {
55
void testlasx() {}
66

7-
// CHECK: attributes #[[ATTR0]] = { {{.*}}"target-features"="+64bit,+lasx,-lsx"{{.*}} }
7+
// CHECK: attributes #[[ATTR0]] = { {{.*}}"target-features"="+64bit,+lasx,+lsx"{{.*}} }

0 commit comments

Comments
 (0)