From owner-svn-src-projects@FreeBSD.ORG Tue Dec 9 20:41:53 2014 Return-Path: Delivered-To: svn-src-projects@freebsd.org Received: from mx1.freebsd.org (mx1.freebsd.org [8.8.178.115]) (using TLSv1.2 with cipher AECDH-AES256-SHA (256/256 bits)) (No client certificate requested) by hub.freebsd.org (Postfix) with ESMTPS id 0DCFD31D; Tue, 9 Dec 2014 20:41:53 +0000 (UTC) Received: from svn.freebsd.org (svn.freebsd.org [IPv6:2001:1900:2254:2068::e6a:0]) (using TLSv1.2 with cipher ECDHE-RSA-AES256-GCM-SHA384 (256/256 bits)) (Client did not present a certificate) by mx1.freebsd.org (Postfix) with ESMTPS id D4EE3156; Tue, 9 Dec 2014 20:41:52 +0000 (UTC) Received: from svn.freebsd.org ([127.0.1.70]) by svn.freebsd.org (8.14.9/8.14.9) with ESMTP id sB9Kfqqu086897; Tue, 9 Dec 2014 20:41:52 GMT (envelope-from dim@FreeBSD.org) Received: (from dim@localhost) by svn.freebsd.org (8.14.9/8.14.9/Submit) id sB9KfqA0086745; Tue, 9 Dec 2014 20:41:52 GMT (envelope-from dim@FreeBSD.org) Message-Id: <201412092041.sB9KfqA0086745@svn.freebsd.org> X-Authentication-Warning: svn.freebsd.org: dim set sender to dim@FreeBSD.org using -f From: Dimitry Andric Date: Tue, 9 Dec 2014 20:41:52 +0000 (UTC) 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 X-SVN-Group: projects MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit X-BeenThere: svn-src-projects@freebsd.org X-Mailman-Version: 2.1.18-1 Precedence: list List-Id: "SVN commit messages for the src " projects" tree" List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , X-List-Received-Date: Tue, 09 Dec 2014 20:41:53 -0000 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; }