llvm.org GIT mirror llvm / 59b08cd
AArch64: diagnose unrecognized features in .cpu directive. We were silently ignoring any features we couldn't match up, which led to errors in an inline asm block missing the conventional "\n\t". git-svn-id: https://llvm.org/svn/llvm-project/llvm/trunk@303108 91177308-0d34-0410-b5e6-96231b3b80d8 Tim Northover 3 years ago
2 changed file(s) with 26 addition(s) and 2 deletion(s). Raw diff Collapse all Expand all
39033903 return false;
39043904 }
39053905
3906 static SMLoc incrementLoc(SMLoc L, int Offset) {
3907 return SMLoc::getFromPointer(L.getPointer() + Offset);
3908 }
3909
39063910 /// parseDirectiveCPU
39073911 /// ::= .cpu id
39083912 bool AArch64AsmParser::parseDirectiveCPU(SMLoc L) {
3909 SMLoc CPULoc = getLoc();
3913 SMLoc CurLoc = getLoc();
39103914
39113915 StringRef CPU, ExtensionString;
39123916 std::tie(CPU, ExtensionString) =
39223926 // FIXME This is using tablegen data, but should be moved to ARMTargetParser
39233927 // once that is tablegen'ed
39243928 if (!getSTI().isCPUStringValid(CPU)) {
3925 Error(CPULoc, "unknown CPU name");
3929 Error(CurLoc, "unknown CPU name");
39263930 return false;
39273931 }
39283932
39293933 MCSubtargetInfo &STI = copySTI();
39303934 STI.setDefaultFeatures(CPU, "");
3935 CurLoc = incrementLoc(CurLoc, CPU.size());
39313936
39323937 FeatureBitset Features = STI.getFeatureBits();
39333938 for (auto Name : RequestedExtensions) {
3939 // Advance source location past '+'.
3940 CurLoc = incrementLoc(CurLoc, 1);
3941
39343942 bool EnableFeature = true;
39353943
39363944 if (Name.startswith_lower("no")) {
39383946 Name = Name.substr(2);
39393947 }
39403948
3949 bool FoundExtension = false;
39413950 for (const auto &Extension : ExtensionMap) {
39423951 if (Extension.Name != Name)
39433952 continue;
39513960 uint64_t Features =
39523961 ComputeAvailableFeatures(STI.ToggleFeature(ToggleFeatures));
39533962 setAvailableFeatures(Features);
3963 FoundExtension = true;
39543964
39553965 break;
39563966 }
3967
3968 if (!FoundExtension)
3969 Error(CurLoc, "unsupported architectural extension");
3970
3971 CurLoc = incrementLoc(CurLoc, Name.size());
39573972 }
39583973 return false;
39593974 }
0 // RUN: not llvm-mc -triple aarch64-linux-gnu %s 2> %t > /dev/null
1 // RUN: FileCheck %s < %t
2
3 .cpu invalid
4 // CHECK: error: unknown CPU name
5
6 .cpu generic+wibble+nowobble
7 // CHECK: :[[@LINE-1]]:18: error: unsupported architectural extension
8 // CHECK: :[[@LINE-2]]:25: error: unsupported architectural extension