Date: Tue, 9 Dec 2014 20:41:52 +0000 (UTC) From: Dimitry Andric <dim@FreeBSD.org> To: src-committers@freebsd.org, svn-src-projects@freebsd.org Subject: svn commit: r275654 - in projects/clang350-import/contrib/llvm: include/llvm/MC lib/Target/ARM/AsmParser Message-ID: <201412092041.sB9KfqA0086745@svn.freebsd.org>
next in thread | raw e-mail | index | archive | help
Author: dim Date: Tue Dec 9 20:41:51 2014 New Revision: 275654 URL: https://svnweb.freebsd.org/changeset/base/275654 Log: Pull in r223147, r223255 and r223390 from upstream llvm trunk (by Roman Divacky): Introduce CPUStringIsValid() into MCSubtargetInfo and use it for ARM .cpu parsing. Previously .cpu directive in ARM assembler didnt switch to the new CPU and therefore acted as a nop. This implemented real action for .cpu and eg. allows to assembler FreeBSD kernel with -integrated-as. Change the name to be in style. Add a FIXME as requested by Renato Golin. Modified: projects/clang350-import/contrib/llvm/include/llvm/MC/MCSubtargetInfo.h projects/clang350-import/contrib/llvm/lib/Target/ARM/AsmParser/ARMAsmParser.cpp Modified: projects/clang350-import/contrib/llvm/include/llvm/MC/MCSubtargetInfo.h ============================================================================== --- projects/clang350-import/contrib/llvm/include/llvm/MC/MCSubtargetInfo.h Tue Dec 9 20:36:07 2014 (r275653) +++ projects/clang350-import/contrib/llvm/include/llvm/MC/MCSubtargetInfo.h Tue Dec 9 20:41:51 2014 (r275654) @@ -132,6 +132,15 @@ public: /// Initialize an InstrItineraryData instance. void initInstrItins(InstrItineraryData &InstrItins) const; + + /// Check whether the CPU string is valid. + bool isCPUStringValid(StringRef CPU) { + auto Found = std::find_if(ProcDesc.begin(), ProcDesc.end(), + [=](const SubtargetFeatureKV &KV) { + return CPU == KV.Key; + }); + return Found != ProcDesc.end(); + } }; } // End llvm namespace Modified: projects/clang350-import/contrib/llvm/lib/Target/ARM/AsmParser/ARMAsmParser.cpp ============================================================================== --- projects/clang350-import/contrib/llvm/lib/Target/ARM/AsmParser/ARMAsmParser.cpp Tue Dec 9 20:36:07 2014 (r275653) +++ projects/clang350-import/contrib/llvm/lib/Target/ARM/AsmParser/ARMAsmParser.cpp Tue Dec 9 20:41:51 2014 (r275654) @@ -8618,6 +8618,20 @@ bool ARMAsmParser::parseDirectiveEabiAtt bool ARMAsmParser::parseDirectiveCPU(SMLoc L) { StringRef CPU = getParser().parseStringToEndOfStatement().trim(); getTargetStreamer().emitTextAttribute(ARMBuildAttrs::CPU_name, CPU); + + if (!STI.isCPUStringValid(CPU)) { + Error(L, "Unknown CPU name"); + return false; + } + + // FIXME: This switches the CPU features globally, therefore it might + // happen that code you would not expect to assemble will. For details + // see: http://llvm.org/bugs/show_bug.cgi?id=20757 + STI.InitMCProcessorInfo(CPU, ""); + STI.InitCPUSchedModel(CPU); + unsigned FB = ComputeAvailableFeatures(STI.getFeatureBits()); + setAvailableFeatures(FB); + return false; }
Want to link to this message? Use this URL: <https://mail-archive.FreeBSD.org/cgi/mid.cgi?201412092041.sB9KfqA0086745>