From nicholas at mxc.ca Mon Aug 9 02:20:20 2010 From: nicholas at mxc.ca (Nick Lewycky) Date: Mon, 09 Aug 2010 07:20:20 -0000 Subject: [llvm-commits] [llvm] r110564 - /llvm/trunk/lib/ExecutionEngine/JIT/JIT.cpp Message-ID: <20100809072020.4A8062A6C12C@llvm.org> Author: nicholas Date: Mon Aug 9 02:20:20 2010 New Revision: 110564 URL: http://llvm.org/viewvc/llvm-project?rev=110564&view=rev Log: Stop the JIT from refusing to work just because the program it was compiled into was built with -static. Modified: llvm/trunk/lib/ExecutionEngine/JIT/JIT.cpp Modified: llvm/trunk/lib/ExecutionEngine/JIT/JIT.cpp URL: http://llvm.org/viewvc/llvm-project/llvm/trunk/lib/ExecutionEngine/JIT/JIT.cpp?rev=110564&r1=110563&r2=110564&view=diff ============================================================================== --- llvm/trunk/lib/ExecutionEngine/JIT/JIT.cpp (original) +++ llvm/trunk/lib/ExecutionEngine/JIT/JIT.cpp Mon Aug 9 02:20:20 2010 @@ -219,11 +219,6 @@ StringRef MArch, StringRef MCPU, const SmallVectorImpl& MAttrs) { - // Make sure we can resolve symbols in the program as well. The zero arg - // to the function tells DynamicLibrary to load the program, not a library. - if (sys::DynamicLibrary::LoadLibraryPermanently(0, ErrorStr)) - return 0; - // Pick a target either via -march or by guessing the native arch. TargetMachine *TM = JIT::selectTarget(M, MArch, MCPU, MAttrs, ErrorStr); if (!TM || (ErrorStr && ErrorStr->length() > 0)) return 0; From geek4civic at gmail.com Mon Aug 9 02:24:58 2010 From: geek4civic at gmail.com (NAKAMURA Takumi) Date: Mon, 9 Aug 2010 16:24:58 +0900 Subject: [llvm-commits] [llvm] r110520 - in /llvm/trunk: test/BugPoint/crash-narrowfunctiontest.ll test/BugPoint/remove_arguments_test.ll tools/Makefile tools/bugpoint-passes/ tools/bugpoint-passes/TestPasses.cpp tools/bugpoint/TestPasses.cpp In-Reply-To: <20100807214809.6CD772A6C12C@llvm.org> References: <20100807214809.6CD772A6C12C@llvm.org> Message-ID: Rafael, It breaks mingw(self and cross-linux) builds. Would you like to suppress bugpoint-passes for Win32(s) for while? ...Takumi 2010/8/8 Rafael Espindola : > Author: rafael > Date: Sat Aug ?7 16:48:09 2010 > New Revision: 110520 > > URL: http://llvm.org/viewvc/llvm-project?rev=110520&view=rev > Log: > Move the bugpoint test passes to a plugin in preparation for having bugpoint > use opt. > > Added: > ? ?llvm/trunk/tools/bugpoint-passes/ > ? ?llvm/trunk/tools/bugpoint-passes/TestPasses.cpp > ? ? ?- copied, changed from r110518, llvm/trunk/tools/bugpoint/TestPasses.cpp > Removed: > ? ?llvm/trunk/tools/bugpoint/TestPasses.cpp > Modified: > ? ?llvm/trunk/test/BugPoint/crash-narrowfunctiontest.ll > ? ?llvm/trunk/test/BugPoint/remove_arguments_test.ll > ? ?llvm/trunk/tools/Makefile > > Modified: llvm/trunk/test/BugPoint/crash-narrowfunctiontest.ll > URL: http://llvm.org/viewvc/llvm-project/llvm/trunk/test/BugPoint/crash-narrowfunctiontest.ll?rev=110520&r1=110519&r2=110520&view=diff > ============================================================================== > --- llvm/trunk/test/BugPoint/crash-narrowfunctiontest.ll (original) > +++ llvm/trunk/test/BugPoint/crash-narrowfunctiontest.ll Sat Aug ?7 16:48:09 2010 > @@ -1,6 +1,7 @@ > ?; Test that bugpoint can narrow down the testcase to the important function > +; FIXME: This likely fails on windows > ?; > -; RUN: bugpoint %s -output-prefix %t -bugpoint-crashcalls -silence-passes > /dev/null > +; RUN: bugpoint -load %llvmlibsdir/BugpointPasses.so %s -output-prefix %t -bugpoint-crashcalls -silence-passes > /dev/null > > ?define i32 @foo() { ret i32 1 } > > > Modified: llvm/trunk/test/BugPoint/remove_arguments_test.ll > URL: http://llvm.org/viewvc/llvm-project/llvm/trunk/test/BugPoint/remove_arguments_test.ll?rev=110520&r1=110519&r2=110520&view=diff > ============================================================================== > --- llvm/trunk/test/BugPoint/remove_arguments_test.ll (original) > +++ llvm/trunk/test/BugPoint/remove_arguments_test.ll Sat Aug ?7 16:48:09 2010 > @@ -1,4 +1,5 @@ > -; RUN: bugpoint %s -output-prefix %t -bugpoint-crashcalls -silence-passes > +; FIXME: This likely fails on windows > +; RUN: bugpoint -load %llvmlibsdir/BugpointPasses.so %s -output-prefix %t -bugpoint-crashcalls -silence-passes > ?; RUN: llvm-dis %t-reduced-simplified.bc -o - | FileCheck %s > > ?; Test to make sure that arguments are removed from the function if they are > > Modified: llvm/trunk/tools/Makefile > URL: http://llvm.org/viewvc/llvm-project/llvm/trunk/tools/Makefile?rev=110520&r1=110519&r2=110520&view=diff > ============================================================================== > --- llvm/trunk/tools/Makefile (original) > +++ llvm/trunk/tools/Makefile Sat Aug ?7 16:48:09 2010 > @@ -20,7 +20,7 @@ > ? ? ? ? ? ? ? ? ?llc llvm-ranlib llvm-ar llvm-nm \ > ? ? ? ? ? ? ? ? ?llvm-ld llvm-prof llvm-link \ > ? ? ? ? ? ? ? ? ?lli llvm-extract llvm-mc \ > - ? ? ? ? ? ? ? ? bugpoint llvm-bcanalyzer llvm-stub \ > + ? ? ? ? ? ? ? ? bugpoint bugpoint-passes llvm-bcanalyzer llvm-stub \ > ? ? ? ? ? ? ? ? ?llvmc > > ?# Let users override the set of tools to build from the command line. > > Copied: llvm/trunk/tools/bugpoint-passes/TestPasses.cpp (from r110518, llvm/trunk/tools/bugpoint/TestPasses.cpp) > URL: http://llvm.org/viewvc/llvm-project/llvm/trunk/tools/bugpoint-passes/TestPasses.cpp?p2=llvm/trunk/tools/bugpoint-passes/TestPasses.cpp&p1=llvm/trunk/tools/bugpoint/TestPasses.cpp&r1=110518&r2=110520&rev=110520&view=diff > ============================================================================== > ? ?(empty) > > Removed: llvm/trunk/tools/bugpoint/TestPasses.cpp > URL: http://llvm.org/viewvc/llvm-project/llvm/trunk/tools/bugpoint/TestPasses.cpp?rev=110519&view=auto > ============================================================================== > --- llvm/trunk/tools/bugpoint/TestPasses.cpp (original) > +++ llvm/trunk/tools/bugpoint/TestPasses.cpp (removed) > @@ -1,75 +0,0 @@ > -//===- TestPasses.cpp - "buggy" passes used to test bugpoint --------------===// > -// > -// ? ? ? ? ? ? ? ? ? ? The LLVM Compiler Infrastructure > -// > -// This file is distributed under the University of Illinois Open Source > -// License. See LICENSE.TXT for details. > -// > -//===----------------------------------------------------------------------===// > -// > -// This file contains "buggy" passes that are used to test bugpoint, to check > -// that it is narrowing down testcases correctly. > -// > -//===----------------------------------------------------------------------===// > - > -#include "llvm/BasicBlock.h" > -#include "llvm/Constant.h" > -#include "llvm/Instructions.h" > -#include "llvm/Pass.h" > -#include "llvm/Type.h" > -#include "llvm/Support/InstVisitor.h" > - > -using namespace llvm; > - > -namespace { > - ?/// CrashOnCalls - This pass is used to test bugpoint. ?It intentionally > - ?/// crashes on any call instructions. > - ?class CrashOnCalls : public BasicBlockPass { > - ?public: > - ? ?static char ID; // Pass ID, replacement for typeid > - ? ?CrashOnCalls() : BasicBlockPass(ID) {} > - ?private: > - ? ?virtual void getAnalysisUsage(AnalysisUsage &AU) const { > - ? ? ?AU.setPreservesAll(); > - ? ?} > - > - ? ?bool runOnBasicBlock(BasicBlock &BB) { > - ? ? ?for (BasicBlock::iterator I = BB.begin(), E = BB.end(); I != E; ++I) > - ? ? ? ?if (isa(*I)) > - ? ? ? ? ?abort(); > - > - ? ? ?return false; > - ? ?} > - ?}; > - > - ?char CrashOnCalls::ID = 0; > - ?RegisterPass > - ?X("bugpoint-crashcalls", > - ? ?"BugPoint Test Pass - Intentionally crash on CallInsts"); > -} > - > -namespace { > - ?/// DeleteCalls - This pass is used to test bugpoint. ?It intentionally > - ?/// deletes some call instructions, "misoptimizing" the program. > - ?class DeleteCalls : public BasicBlockPass { > - ?public: > - ? ?static char ID; // Pass ID, replacement for typeid > - ? ?DeleteCalls() : BasicBlockPass(ID) {} > - ?private: > - ? ?bool runOnBasicBlock(BasicBlock &BB) { > - ? ? ?for (BasicBlock::iterator I = BB.begin(), E = BB.end(); I != E; ++I) > - ? ? ? ?if (CallInst *CI = dyn_cast(I)) { > - ? ? ? ? ?if (!CI->use_empty()) > - ? ? ? ? ? ?CI->replaceAllUsesWith(Constant::getNullValue(CI->getType())); > - ? ? ? ? ?CI->getParent()->getInstList().erase(CI); > - ? ? ? ? ?break; > - ? ? ? ?} > - ? ? ?return false; > - ? ?} > - ?}; > - > - ?char DeleteCalls::ID = 0; > - ?RegisterPass > - ?Y("bugpoint-deletecalls", > - ? ?"BugPoint Test Pass - Intentionally 'misoptimize' CallInsts"); > -} > > > _______________________________________________ > llvm-commits mailing list > llvm-commits at cs.uiuc.edu > http://lists.cs.uiuc.edu/mailman/listinfo/llvm-commits > From baldrick at free.fr Mon Aug 9 03:37:46 2010 From: baldrick at free.fr (Duncan Sands) Date: Mon, 09 Aug 2010 08:37:46 -0000 Subject: [llvm-commits] [dragonegg] r110565 - /dragonegg/trunk/extras/do_self_strap Message-ID: <20100809083746.36DFC2A6C12C@llvm.org> Author: baldrick Date: Mon Aug 9 03:37:45 2010 New Revision: 110565 URL: http://llvm.org/viewvc/llvm-project?rev=110565&view=rev Log: One of my buildbots has started running out of memory - presumably LLVM memory usage just shot up for some reason. Try to workaround this by having fewer parallel jobs. Modified: dragonegg/trunk/extras/do_self_strap Modified: dragonegg/trunk/extras/do_self_strap URL: http://llvm.org/viewvc/llvm-project/dragonegg/trunk/extras/do_self_strap?rev=110565&r1=110564&r2=110565&view=diff ============================================================================== --- dragonegg/trunk/extras/do_self_strap (original) +++ dragonegg/trunk/extras/do_self_strap Mon Aug 9 03:37:45 2010 @@ -57,7 +57,7 @@ --disable-threads --enable-debug-symbols $LLVM_OPTIONS" COMPARE="cmp --ignore-initial=16" # How to compare object files -MAKE="nice -n 20 make -j3 -l2" # How to run make +MAKE="nice -n 20 make -j2 -l1" # How to run make MAKE_INSTALL="nice -n 20 make install" # How to run make install From xerxes at zafena.se Mon Aug 9 07:49:00 2010 From: xerxes at zafena.se (=?ISO-8859-1?Q?Xerxes_R=E5nby?=) Date: Mon, 09 Aug 2010 14:49:00 +0200 Subject: [llvm-commits] [llvm] r110109 - in /llvm/trunk: autoconf/configure.ac cmake/config-ix.cmake configure include/llvm/Config/config.h.cmake include/llvm/Config/config.h.in include/llvm/Target/TargetSelect.h In-Reply-To: <20100803142618.283912A6C12C@llvm.org> References: <20100803142618.283912A6C12C@llvm.org> Message-ID: <4C5FF93C.1060604@zafena.se> Hi this change have reinstalled llvm pr4427 http://llvm.org/bugs/show_bug.cgi?id=4427 for example when compiling a project that uses llvm JIT on X86 then if X86 are defined this bug hits when calling InitializeNativeTargetAsmPrinter() the macro expands into LLVMInitializeAsmPrinter() that dont exist. instead of LLVMInitializeX86AsmPrinter() that do exist. Cheers Xerxes On 2010-08-03 16:26, Daniel Dunbar wrote: > Author: ddunbar > Date: Tue Aug 3 09:26:17 2010 > New Revision: 110109 > > URL: http://llvm.org/viewvc/llvm-project?rev=110109&view=rev > Log: > build: Add LLVM_NATIVE_ARCHNAME, which has the sensible value, without "Target" > appended. > > Modified: > llvm/trunk/autoconf/configure.ac > llvm/trunk/cmake/config-ix.cmake > llvm/trunk/configure > llvm/trunk/include/llvm/Config/config.h.cmake > llvm/trunk/include/llvm/Config/config.h.in > llvm/trunk/include/llvm/Target/TargetSelect.h > > Modified: llvm/trunk/autoconf/configure.ac > URL: http://llvm.org/viewvc/llvm-project/llvm/trunk/autoconf/configure.ac?rev=110109&r1=110108&r2=110109&view=diff > ============================================================================== > --- llvm/trunk/autoconf/configure.ac (original) > +++ llvm/trunk/autoconf/configure.ac Tue Aug 3 09:26:17 2010 > @@ -599,6 +599,8 @@ > for a_target in $TARGETS_TO_BUILD; do > if test "$a_target" = "$LLVM_NATIVE_ARCH"; then > LLVM_NATIVE_ARCHTARGET="${LLVM_NATIVE_ARCH}Target" > + AC_DEFINE_UNQUOTED(LLVM_NATIVE_ARCHNAME,$LLVM_NATIVE_ARCH, > + [Short LLVM architecture name for the native architecture, if available]) > AC_DEFINE_UNQUOTED(LLVM_NATIVE_ARCH,$LLVM_NATIVE_ARCHTARGET, > [LLVM architecture name for the native architecture, if available]) > fi > > Modified: llvm/trunk/cmake/config-ix.cmake > URL: http://llvm.org/viewvc/llvm-project/llvm/trunk/cmake/config-ix.cmake?rev=110109&r1=110108&r2=110109&view=diff > ============================================================================== > --- llvm/trunk/cmake/config-ix.cmake (original) > +++ llvm/trunk/cmake/config-ix.cmake Tue Aug 3 09:26:17 2010 > @@ -207,6 +207,7 @@ > endif () > > if (LLVM_NATIVE_ARCH) > + set(LLVM_NATIVE_ARCHNAME ${LLVM_NATIVE_ARCH}) > list(FIND LLVM_TARGETS_TO_BUILD ${LLVM_NATIVE_ARCH} NATIVE_ARCH_IDX) > if (NATIVE_ARCH_IDX EQUAL -1) > message(STATUS > > Modified: llvm/trunk/configure > URL: http://llvm.org/viewvc/llvm-project/llvm/trunk/configure?rev=110109&r1=110108&r2=110109&view=diff > ============================================================================== > --- llvm/trunk/configure (original) > +++ llvm/trunk/configure Tue Aug 3 09:26:17 2010 > @@ -5018,6 +5018,11 @@ > LLVM_NATIVE_ARCHTARGET="${LLVM_NATIVE_ARCH}Target" > > cat >>confdefs.h <<_ACEOF > +#define LLVM_NATIVE_ARCHNAME $LLVM_NATIVE_ARCH > +_ACEOF > + > + > +cat >>confdefs.h <<_ACEOF > #define LLVM_NATIVE_ARCH $LLVM_NATIVE_ARCHTARGET > _ACEOF > > @@ -11391,7 +11396,7 @@ > lt_dlunknown=0; lt_dlno_uscore=1; lt_dlneed_uscore=2 > lt_status=$lt_dlunknown > cat > conftest.$ac_ext < -#line 11394 "configure" > +#line 11399 "configure" > #include "confdefs.h" > > #if HAVE_DLFCN_H > > Modified: llvm/trunk/include/llvm/Config/config.h.cmake > URL: http://llvm.org/viewvc/llvm-project/llvm/trunk/include/llvm/Config/config.h.cmake?rev=110109&r1=110108&r2=110109&view=diff > ============================================================================== > --- llvm/trunk/include/llvm/Config/config.h.cmake (original) > +++ llvm/trunk/include/llvm/Config/config.h.cmake Tue Aug 3 09:26:17 2010 > @@ -625,3 +625,6 @@ > > /* Native LLVM architecture */ > #cmakedefine LLVM_NATIVE_ARCH ${LLVM_NATIVE_ARCH}Target > + > +/* Native LLVM architecture, short name */ > +#cmakedefine LLVM_NATIVE_ARCHNAME ${LLVM_NATIVE_ARCH} > > Modified: llvm/trunk/include/llvm/Config/config.h.in > URL: http://llvm.org/viewvc/llvm-project/llvm/trunk/include/llvm/Config/config.h.in?rev=110109&r1=110108&r2=110109&view=diff > ============================================================================== > --- llvm/trunk/include/llvm/Config/config.h.in (original) > +++ llvm/trunk/include/llvm/Config/config.h.in Tue Aug 3 09:26:17 2010 > @@ -500,6 +500,9 @@ > /* LLVM architecture name for the native architecture, if available */ > #undef LLVM_NATIVE_ARCH > > +/* Short LLVM architecture name for the native architecture, if available */ > +#undef LLVM_NATIVE_ARCHNAME > + > /* Define if this is Unixish platform */ > #undef LLVM_ON_UNIX > > > Modified: llvm/trunk/include/llvm/Target/TargetSelect.h > URL: http://llvm.org/viewvc/llvm-project/llvm/trunk/include/llvm/Target/TargetSelect.h?rev=110109&r1=110108&r2=110109&view=diff > ============================================================================== > --- llvm/trunk/include/llvm/Target/TargetSelect.h (original) > +++ llvm/trunk/include/llvm/Target/TargetSelect.h Tue Aug 3 09:26:17 2010 > @@ -30,13 +30,6 @@ > #define LLVM_ASM_PRINTER(TargetName) void LLVMInitialize##TargetName##AsmPrinter(); > #include "llvm/Config/AsmPrinters.def" > > - // FIXME: Workaround for unfortunate definition of LLVM_NATIVE_ARCH. > -#define LLVM_ASM_PRINTER(TargetName) \ > - static inline void LLVMInitialize##TargetName##TargetAsmPrinter() { \ > - LLVMInitialize##TargetName##AsmPrinter(); \ > - } > -#include "llvm/Config/AsmPrinters.def" > - > // Declare all of the available assembly parser initialization functions. > #define LLVM_ASM_PARSER(TargetName) void LLVMInitialize##TargetName##AsmParser(); > #include "llvm/Config/AsmParsers.def" > @@ -107,7 +100,7 @@ > /// It is legal for a client to make multiple calls to this function. > inline bool InitializeNativeTarget() { > // If we have a native target, initialize it to ensure it is linked in. > -#ifdef LLVM_NATIVE_ARCH > +#ifdef LLVM_NATIVE_ARCHNAME > #define DoInit2(TARG) \ > LLVMInitialize ## TARG ## Info (); \ > LLVMInitialize ## TARG () > @@ -129,7 +122,7 @@ > #define DoInit2(TARG) \ > LLVMInitialize ## TARG ## AsmPrinter (); > #define DoInit(T) DoInit2(T) > - DoInit(LLVM_NATIVE_ARCH); > + DoInit(LLVM_NATIVE_ARCHNAME); > return false; > #undef DoInit > #undef DoInit2 > > > _______________________________________________ > llvm-commits mailing list > llvm-commits at cs.uiuc.edu > http://lists.cs.uiuc.edu/mailman/listinfo/llvm-commits > From baldrick at free.fr Mon Aug 9 08:00:33 2010 From: baldrick at free.fr (Duncan Sands) Date: Mon, 09 Aug 2010 13:00:33 -0000 Subject: [llvm-commits] [dragonegg] r110572 - /dragonegg/trunk/extras/do_self_strap Message-ID: <20100809130033.B19922A6C12C@llvm.org> Author: baldrick Date: Mon Aug 9 08:00:33 2010 New Revision: 110572 URL: http://llvm.org/viewvc/llvm-project?rev=110572&view=rev Log: Revert the previous commit. The buildbot hardware is failing, which is hard to work around in software! Modified: dragonegg/trunk/extras/do_self_strap Modified: dragonegg/trunk/extras/do_self_strap URL: http://llvm.org/viewvc/llvm-project/dragonegg/trunk/extras/do_self_strap?rev=110572&r1=110571&r2=110572&view=diff ============================================================================== --- dragonegg/trunk/extras/do_self_strap (original) +++ dragonegg/trunk/extras/do_self_strap Mon Aug 9 08:00:33 2010 @@ -57,7 +57,7 @@ --disable-threads --enable-debug-symbols $LLVM_OPTIONS" COMPARE="cmp --ignore-initial=16" # How to compare object files -MAKE="nice -n 20 make -j2 -l1" # How to run make +MAKE="nice -n 20 make -j3 -l2" # How to run make MAKE_INSTALL="nice -n 20 make install" # How to run make install From rafael.espindola at gmail.com Mon Aug 9 08:24:00 2010 From: rafael.espindola at gmail.com (=?UTF-8?Q?Rafael_Esp=C3=ADndola?=) Date: Mon, 9 Aug 2010 09:24:00 -0400 Subject: [llvm-commits] [llvm] r110520 - in /llvm/trunk: test/BugPoint/crash-narrowfunctiontest.ll test/BugPoint/remove_arguments_test.ll tools/Makefile tools/bugpoint-passes/ tools/bugpoint-passes/TestPasses.cpp tools/bugpoint/TestPasses.cpp In-Reply-To: References: <20100807214809.6CD772A6C12C@llvm.org> Message-ID: On 9 August 2010 03:24, NAKAMURA Takumi wrote: > Rafael, > > It breaks mingw(self and cross-linux) builds. > Would you like to suppress bugpoint-passes for Win32(s) for while? Do you know what is the XFAIL line I have to add to disable this tests for windows? > ...Takumi Cheers, Rafael From geek4civic at gmail.com Mon Aug 9 08:52:08 2010 From: geek4civic at gmail.com (NAKAMURA Takumi) Date: Mon, 9 Aug 2010 22:52:08 +0900 Subject: [llvm-commits] [llvm] r110520 - in /llvm/trunk: test/BugPoint/crash-narrowfunctiontest.ll test/BugPoint/remove_arguments_test.ll tools/Makefile tools/bugpoint-passes/ tools/bugpoint-passes/TestPasses.cpp tools/bugpoint/TestPasses.cpp In-Reply-To: References: <20100807214809.6CD772A6C12C@llvm.org> Message-ID: Rafael, thank you to comment. 2010/8/9 Rafael Esp?ndola : >> It breaks mingw(self and cross-linux) builds. >> Would you like to suppress bugpoint-passes for Win32(s) for while? > > Do you know what is the XFAIL line I have to add to disable this tests > for windows? Not tests but building the directory tools/bugpoint-passes, I would like to say. Linking BugpointPasses.dll fails. FYI my local patch is; --- a/tools/Makefile +++ b/tools/Makefile @@ -55,4 +55,10 @@ ifeq ($(ENABLE_PIC),1) endif endif +ifneq (,$(filter $(HOST_OS), Cygwin MingW) + ifneq ($(ENABLE_SHARED), 1) + PARALLEL_DIRS := $(filter-out bugpoint-passes, $(PARALLEL_DIRS)) + endif +endif + include $(LEVEL)/Makefile.common ps. I have not yet succeeded running tests on mingw for lack ...Takumi From rafael.espindola at gmail.com Mon Aug 9 09:05:42 2010 From: rafael.espindola at gmail.com (Rafael Espindola) Date: Mon, 09 Aug 2010 14:05:42 -0000 Subject: [llvm-commits] [llvm] r110573 - /llvm/trunk/tools/Makefile Message-ID: <20100809140542.337FC2A6C12C@llvm.org> Author: rafael Date: Mon Aug 9 09:05:42 2010 New Revision: 110573 URL: http://llvm.org/viewvc/llvm-project?rev=110573&view=rev Log: Don't try to build a plugin on windows. Modified: llvm/trunk/tools/Makefile Modified: llvm/trunk/tools/Makefile URL: http://llvm.org/viewvc/llvm-project/llvm/trunk/tools/Makefile?rev=110573&r1=110572&r2=110573&view=diff ============================================================================== --- llvm/trunk/tools/Makefile (original) +++ llvm/trunk/tools/Makefile Mon Aug 9 09:05:42 2010 @@ -20,7 +20,7 @@ llc llvm-ranlib llvm-ar llvm-nm \ llvm-ld llvm-prof llvm-link \ lli llvm-extract llvm-mc \ - bugpoint bugpoint-passes llvm-bcanalyzer llvm-stub \ + bugpoint llvm-bcanalyzer llvm-stub \ llvmc # Let users override the set of tools to build from the command line. @@ -45,6 +45,8 @@ PARALLEL_DIRS += lto endif + PARALLEL_DIRS += bugpoint-passes + # The edis library is only supported if ARM and/or X86 are enabled, and if # LLVM is being built PIC on platforms that support dylibs. ifneq ($(DISABLE_EDIS),1) From espindola at google.com Mon Aug 9 09:07:55 2010 From: espindola at google.com (Rafael Espindola) Date: Mon, 9 Aug 2010 10:07:55 -0400 Subject: [llvm-commits] [llvm] r110520 - in /llvm/trunk: test/BugPoint/crash-narrowfunctiontest.ll test/BugPoint/remove_arguments_test.ll tools/Makefile tools/bugpoint-passes/ tools/bugpoint-passes/TestPasses.cpp tools/bugpoint/TestPasses.cpp In-Reply-To: References: <20100807214809.6CD772A6C12C@llvm.org> Message-ID: > Not tests but building the directory tools/bugpoint-passes, I would like to say. > Linking BugpointPasses.dll fails. Ah. It should be fixed now. Could you please test again? > > ...Takumi Thanks, -- Rafael ?vila de Esp?ndola From geek4civic at gmail.com Mon Aug 9 10:05:51 2010 From: geek4civic at gmail.com (NAKAMURA Takumi) Date: Tue, 10 Aug 2010 00:05:51 +0900 Subject: [llvm-commits] [llvm] r110520 - in /llvm/trunk: test/BugPoint/crash-narrowfunctiontest.ll test/BugPoint/remove_arguments_test.ll tools/Makefile tools/bugpoint-passes/ tools/bugpoint-passes/TestPasses.cpp tools/bugpoint/TestPasses.cpp In-Reply-To: References: <20100807214809.6CD772A6C12C@llvm.org> Message-ID: Rafael, I have confirmed r110573 succeeded build on mingw on ppc-fedora12. (excuse me not to confirm on mingw-self, too spend much time) Thank you arigato! ps. It may be re-enabled when Win32.DLL patches are applied. ...Takumi From rafael.espindola at gmail.com Mon Aug 9 10:14:06 2010 From: rafael.espindola at gmail.com (Rafael Espindola) Date: Mon, 09 Aug 2010 15:14:06 -0000 Subject: [llvm-commits] [llvm] r110574 - in /llvm/trunk/test/BugPoint: crash-narrowfunctiontest.ll remove_arguments_test.ll Message-ID: <20100809151406.824672A6C12C@llvm.org> Author: rafael Date: Mon Aug 9 10:14:06 2010 New Revision: 110574 URL: http://llvm.org/viewvc/llvm-project?rev=110574&view=rev Log: XFAIL for mingw that has no plugins. Modified: llvm/trunk/test/BugPoint/crash-narrowfunctiontest.ll llvm/trunk/test/BugPoint/remove_arguments_test.ll Modified: llvm/trunk/test/BugPoint/crash-narrowfunctiontest.ll URL: http://llvm.org/viewvc/llvm-project/llvm/trunk/test/BugPoint/crash-narrowfunctiontest.ll?rev=110574&r1=110573&r2=110574&view=diff ============================================================================== --- llvm/trunk/test/BugPoint/crash-narrowfunctiontest.ll (original) +++ llvm/trunk/test/BugPoint/crash-narrowfunctiontest.ll Mon Aug 9 10:14:06 2010 @@ -2,6 +2,7 @@ ; FIXME: This likely fails on windows ; ; RUN: bugpoint -load %llvmlibsdir/BugpointPasses%shlibext %s -output-prefix %t -bugpoint-crashcalls -silence-passes > /dev/null +; XFAIL: mingw define i32 @foo() { ret i32 1 } Modified: llvm/trunk/test/BugPoint/remove_arguments_test.ll URL: http://llvm.org/viewvc/llvm-project/llvm/trunk/test/BugPoint/remove_arguments_test.ll?rev=110574&r1=110573&r2=110574&view=diff ============================================================================== --- llvm/trunk/test/BugPoint/remove_arguments_test.ll (original) +++ llvm/trunk/test/BugPoint/remove_arguments_test.ll Mon Aug 9 10:14:06 2010 @@ -1,6 +1,7 @@ ; FIXME: This likely fails on windows ; RUN: bugpoint -load %llvmlibsdir/BugpointPasses%shlibext %s -output-prefix %t -bugpoint-crashcalls -silence-passes ; RUN: llvm-dis %t-reduced-simplified.bc -o - | FileCheck %s +; XFAIL: mingw ; Test to make sure that arguments are removed from the function if they are ; unnecessary. And clean up any types that that frees up too. From bigcheesegs at gmail.com Mon Aug 9 10:28:05 2010 From: bigcheesegs at gmail.com (Michael J. Spencer) Date: Mon, 09 Aug 2010 15:28:05 -0000 Subject: [llvm-commits] [llvm] r110575 - /llvm/trunk/lib/MC/MachObjectWriter.cpp Message-ID: <20100809152805.F2B872A6C12C@llvm.org> Author: mspencer Date: Mon Aug 9 10:28:05 2010 New Revision: 110575 URL: http://llvm.org/viewvc/llvm-project?rev=110575&view=rev Log: MC/MachO: Fix possible null pointer dereference. Discovered by Microsoft Visual Studio 2010 Code Analysis. Modified: llvm/trunk/lib/MC/MachObjectWriter.cpp Modified: llvm/trunk/lib/MC/MachObjectWriter.cpp URL: http://llvm.org/viewvc/llvm-project/llvm/trunk/lib/MC/MachObjectWriter.cpp?rev=110575&r1=110574&r2=110575&view=diff ============================================================================== --- llvm/trunk/lib/MC/MachObjectWriter.cpp (original) +++ llvm/trunk/lib/MC/MachObjectWriter.cpp Mon Aug 9 10:28:05 2010 @@ -835,7 +835,7 @@ // FIXME: Currently, these are never generated (see code below). I cannot // find a case where they are actually emitted. Type = RIT_Vanilla; - } else { + } else if (SD) { // Check whether we need an external or internal relocation. if (doesSymbolRequireExternRelocation(SD)) { IsExtern = 1; From geek4civic at gmail.com Mon Aug 9 11:18:31 2010 From: geek4civic at gmail.com (NAKAMURA Takumi) Date: Tue, 10 Aug 2010 01:18:31 +0900 Subject: [llvm-commits] [Patch Proposal] Makefile.rules: Simplify generating LLVMC_BUILTIN_PLUGIN Message-ID: Mikhail, Please take a look onto it. Thank you in advance. ...Takumi -------------- next part -------------- diff --git a/Makefile.rules b/Makefile.rules index 66666b4..056a0ea 100644 --- a/Makefile.rules +++ b/Makefile.rules @@ -238,58 +238,13 @@ ifneq ($(LLVMC_BUILTIN_PLUGINS),) USEDLIBS += $(patsubst %,plugin_llvmc_%.a,$(LLVMC_BUILTIN_PLUGINS)) -LLVMC_BUILTIN_PLUGIN_1 = $(word 1, $(LLVMC_BUILTIN_PLUGINS)) -LLVMC_BUILTIN_PLUGIN_2 = $(word 2, $(LLVMC_BUILTIN_PLUGINS)) -LLVMC_BUILTIN_PLUGIN_3 = $(word 3, $(LLVMC_BUILTIN_PLUGINS)) -LLVMC_BUILTIN_PLUGIN_4 = $(word 4, $(LLVMC_BUILTIN_PLUGINS)) -LLVMC_BUILTIN_PLUGIN_5 = $(word 5, $(LLVMC_BUILTIN_PLUGINS)) -LLVMC_BUILTIN_PLUGIN_6 = $(word 6, $(LLVMC_BUILTIN_PLUGINS)) -LLVMC_BUILTIN_PLUGIN_7 = $(word 7, $(LLVMC_BUILTIN_PLUGINS)) -LLVMC_BUILTIN_PLUGIN_8 = $(word 8, $(LLVMC_BUILTIN_PLUGINS)) -LLVMC_BUILTIN_PLUGIN_9 = $(word 9, $(LLVMC_BUILTIN_PLUGINS)) -LLVMC_BUILTIN_PLUGIN_10 = $(word 10, $(LLVMC_BUILTIN_PLUGINS)) - - -ifneq ($(LLVMC_BUILTIN_PLUGIN_1),) -CPP.Flags += -DLLVMC_BUILTIN_PLUGIN_1=$(LLVMC_BUILTIN_PLUGIN_1) -endif - -ifneq ($(LLVMC_BUILTIN_PLUGIN_2),) -CPP.Flags += -DLLVMC_BUILTIN_PLUGIN_2=$(LLVMC_BUILTIN_PLUGIN_2) -endif - -ifneq ($(LLVMC_BUILTIN_PLUGIN_3),) -CPP.Flags += -DLLVMC_BUILTIN_PLUGIN_3=$(LLVMC_BUILTIN_PLUGIN_3) -endif - -ifneq ($(LLVMC_BUILTIN_PLUGIN_4),) -CPP.Flags += -DLLVMC_BUILTIN_PLUGIN_4=$(LLVMC_BUILTIN_PLUGIN_4) -endif - -ifneq ($(LLVMC_BUILTIN_PLUGIN_5),) -CPP.Flags += -DLLVMC_BUILTIN_PLUGIN_5=$(LLVMC_BUILTIN_PLUGIN_5) -endif - -ifneq ($(LLVMC_BUILTIN_PLUGIN_6),) -CPP.Flags += -DLLVMC_BUILTIN_PLUGIN_5=$(LLVMC_BUILTIN_PLUGIN_6) -endif - -ifneq ($(LLVMC_BUILTIN_PLUGIN_7),) -CPP.Flags += -DLLVMC_BUILTIN_PLUGIN_5=$(LLVMC_BUILTIN_PLUGIN_7) -endif - -ifneq ($(LLVMC_BUILTIN_PLUGIN_8),) -CPP.Flags += -DLLVMC_BUILTIN_PLUGIN_5=$(LLVMC_BUILTIN_PLUGIN_8) -endif - -ifneq ($(LLVMC_BUILTIN_PLUGIN_9),) -CPP.Flags += -DLLVMC_BUILTIN_PLUGIN_5=$(LLVMC_BUILTIN_PLUGIN_9) -endif - -ifneq ($(LLVMC_BUILTIN_PLUGIN_10),) -CPP.Flags += -DLLVMC_BUILTIN_PLUGIN_5=$(LLVMC_BUILTIN_PLUGIN_10) -endif +LLVMC_BUILTIN_PLUGINS.pre := \ + $(patsubst %,-DLLVMC_BUILTIN_PLUGIN_%=, \ + 1 2 3 4 5 6 7 8 9 10) +CPP.Flags += \ + $(filter-out $(LLVMC_BUILTIN_PLUGINS.pre) $(LLVMC_BUILTIN_PLUGINS), \ + $(join $(LLVMC_BUILTIN_PLUGINS.pre), $(LLVMC_BUILTIN_PLUGINS))) endif From kalle.raiskila at nokia.com Mon Aug 9 11:33:01 2010 From: kalle.raiskila at nokia.com (Kalle Raiskila) Date: Mon, 09 Aug 2010 16:33:01 -0000 Subject: [llvm-commits] [llvm] r110576 - in /llvm/trunk: lib/Target/CellSPU/SPUISelLowering.cpp lib/Target/CellSPU/SPUISelLowering.h lib/Target/CellSPU/SPUInstrInfo.td lib/Target/CellSPU/SPUNodes.td lib/Target/CellSPU/SPURegisterInfo.cpp test/CodeGen/CellSPU/bigstack.ll test/CodeGen/CellSPU/v2f32.ll Message-ID: <20100809163301.235462A6C12C@llvm.org> Author: kraiskil Date: Mon Aug 9 11:33:00 2010 New Revision: 110576 URL: http://llvm.org/viewvc/llvm-project?rev=110576&view=rev Log: Have SPU handle halfvec stores aligned by 8 bytes. Modified: llvm/trunk/lib/Target/CellSPU/SPUISelLowering.cpp llvm/trunk/lib/Target/CellSPU/SPUISelLowering.h llvm/trunk/lib/Target/CellSPU/SPUInstrInfo.td llvm/trunk/lib/Target/CellSPU/SPUNodes.td llvm/trunk/lib/Target/CellSPU/SPURegisterInfo.cpp llvm/trunk/test/CodeGen/CellSPU/bigstack.ll llvm/trunk/test/CodeGen/CellSPU/v2f32.ll Modified: llvm/trunk/lib/Target/CellSPU/SPUISelLowering.cpp URL: http://llvm.org/viewvc/llvm-project/llvm/trunk/lib/Target/CellSPU/SPUISelLowering.cpp?rev=110576&r1=110575&r2=110576&view=diff ============================================================================== --- llvm/trunk/lib/Target/CellSPU/SPUISelLowering.cpp (original) +++ llvm/trunk/lib/Target/CellSPU/SPUISelLowering.cpp Mon Aug 9 11:33:00 2010 @@ -470,6 +470,9 @@ setOperationAction(ISD::FDIV, MVT::v4f32, Legal); + setOperationAction(ISD::STORE, MVT::v2i32, Custom); + setOperationAction(ISD::STORE, MVT::v2f32, Custom); + setShiftAmountType(MVT::i32); setBooleanContents(ZeroOrNegativeOneBooleanContent); @@ -518,6 +521,8 @@ node_names[(unsigned) SPUISD::ADD64_MARKER] = "SPUISD::ADD64_MARKER"; node_names[(unsigned) SPUISD::SUB64_MARKER] = "SPUISD::SUB64_MARKER"; node_names[(unsigned) SPUISD::MUL64_MARKER] = "SPUISD::MUL64_MARKER"; + node_names[(unsigned) SPUISD::HALF2VEC] = "SPUISD::HALF2VEC"; + node_names[(unsigned) SPUISD::VEC2HALF] = "SPUISD::VEC2HALF"; } std::map::iterator i = node_names.find(Opcode); @@ -738,12 +743,14 @@ EVT PtrVT = DAG.getTargetLoweringInfo().getPointerTy(); DebugLoc dl = Op.getDebugLoc(); unsigned alignment = SN->getAlignment(); + const bool isVec = VT.isVector(); + EVT eltTy = isVec ? VT.getVectorElementType(): VT; switch (SN->getAddressingMode()) { case ISD::UNINDEXED: { // The vector type we really want to load from the 16-byte chunk. EVT vecVT = EVT::getVectorVT(*DAG.getContext(), - VT, (128 / VT.getSizeInBits())); + eltTy, (128 / eltTy.getSizeInBits())); SDValue alignLoadVec; SDValue basePtr = SN->getBasePtr(); @@ -752,7 +759,6 @@ if (alignment == 16) { ConstantSDNode *CN; - // Special cases for a known aligned load to simplify the base pointer // and insertion byte: if (basePtr.getOpcode() == ISD::ADD @@ -776,6 +782,9 @@ insertEltOffs = DAG.getNode(SPUISD::IndirectAddr, dl, PtrVT, basePtr, DAG.getConstant(0, PtrVT)); + basePtr = DAG.getNode(SPUISD::IndirectAddr, dl, PtrVT, + basePtr, + DAG.getConstant(0, PtrVT)); } } else { // Unaligned load: must be more pessimistic about addressing modes: @@ -812,8 +821,8 @@ DAG.getConstant(0, PtrVT)); } - // Re-emit as a v16i8 vector load - alignLoadVec = DAG.getLoad(MVT::v16i8, dl, the_chain, basePtr, + // Load the memory to which to store. + alignLoadVec = DAG.getLoad(vecVT, dl, the_chain, basePtr, SN->getSrcValue(), SN->getSrcValueOffset(), SN->isVolatile(), SN->isNonTemporal(), 16); @@ -844,11 +853,19 @@ } #endif - SDValue insertEltOp = - DAG.getNode(SPUISD::SHUFFLE_MASK, dl, vecVT, insertEltOffs); - SDValue vectorizeOp = - DAG.getNode(ISD::SCALAR_TO_VECTOR, dl, vecVT, theValue); - + SDValue insertEltOp; + SDValue vectorizeOp; + if (isVec) + { + // FIXME: this works only if the vector is 64bit! + insertEltOp = DAG.getNode(SPUISD::SHUFFLE_MASK, dl, MVT::v2i64, insertEltOffs); + vectorizeOp = DAG.getNode(SPUISD::HALF2VEC, dl, vecVT, theValue); + } + else + { + insertEltOp = DAG.getNode(SPUISD::SHUFFLE_MASK, dl, vecVT, insertEltOffs); + vectorizeOp = DAG.getNode(ISD::SCALAR_TO_VECTOR, dl, vecVT, theValue); + } result = DAG.getNode(SPUISD::SHUFB, dl, vecVT, vectorizeOp, alignLoadVec, DAG.getNode(ISD::BIT_CONVERT, dl, Modified: llvm/trunk/lib/Target/CellSPU/SPUISelLowering.h URL: http://llvm.org/viewvc/llvm-project/llvm/trunk/lib/Target/CellSPU/SPUISelLowering.h?rev=110576&r1=110575&r2=110576&view=diff ============================================================================== --- llvm/trunk/lib/Target/CellSPU/SPUISelLowering.h (original) +++ llvm/trunk/lib/Target/CellSPU/SPUISelLowering.h Mon Aug 9 11:33:00 2010 @@ -54,6 +54,8 @@ ADD64_MARKER, ///< i64 addition marker SUB64_MARKER, ///< i64 subtraction marker MUL64_MARKER, ///< i64 multiply marker + HALF2VEC, ///< Promote 64 bit vector to 128 bits + VEC2HALF, ///< Extract first 64 bits from 128 bit vector LAST_SPUISD ///< Last user-defined instruction }; } Modified: llvm/trunk/lib/Target/CellSPU/SPUInstrInfo.td URL: http://llvm.org/viewvc/llvm-project/llvm/trunk/lib/Target/CellSPU/SPUInstrInfo.td?rev=110576&r1=110575&r2=110576&view=diff ============================================================================== --- llvm/trunk/lib/Target/CellSPU/SPUInstrInfo.td (original) +++ llvm/trunk/lib/Target/CellSPU/SPUInstrInfo.td Mon Aug 9 11:33:00 2010 @@ -1468,6 +1468,9 @@ class ORCvtVecGPRC: ORCvtForm<(outs GPRC:$rT), (ins VECREG:$rA)>; +class ORCvtVecVec: + ORCvtForm<(outs VECREG:$rT), (ins VECREG:$rA)>; + multiclass BitwiseOr { def v16i8: ORVecInst; @@ -1514,6 +1517,13 @@ def f32_v4f32: ORExtractElt; def f64_v2f64: ORExtractElt; + // half <-> full vector mappings + def v2i32_v4i32: ORCvtVecVec; + def v4i32_v2i32: ORCvtVecVec; + def v2f32_v4f32: ORCvtVecVec; + def v4f32_v2f32: ORCvtVecVec; + + // Conversion from vector to GPRC def i128_vec: ORCvtVecGPRC; @@ -1623,6 +1633,18 @@ def : Pat<(SPUvec2prefslot (v2f64 VECREG:$rA)), (ORf64_v2f64 VECREG:$rA)>; +// Conversions between 64 bit and 128 bit vectors. + +def : Pat<(v4i32 (SPUhalf2vec (v2i32 VECREG:$rA))), + (ORv4i32_v2i32 (v2i32 VECREG:$rA))>; +def : Pat<(v4f32 (SPUhalf2vec (v2f32 VECREG:$rA))), + (ORv4f32_v2f32 (v2f32 VECREG:$rA))>; + +def : Pat<(v2i32 (SPUvec2half (v4i32 VECREG:$rA))), + (ORv2i32_v4i32 VECREG:$rA)>; +def : Pat<(v2f32 (SPUvec2half (v4f32 VECREG:$rA))), + (ORv2f32_v4f32 VECREG:$rA)>; + // Load Register: This is an assembler alias for a bitwise OR of a register // against itself. It's here because it brings some clarity to assembly // language output. Modified: llvm/trunk/lib/Target/CellSPU/SPUNodes.td URL: http://llvm.org/viewvc/llvm-project/llvm/trunk/lib/Target/CellSPU/SPUNodes.td?rev=110576&r1=110575&r2=110576&view=diff ============================================================================== --- llvm/trunk/lib/Target/CellSPU/SPUNodes.td (original) +++ llvm/trunk/lib/Target/CellSPU/SPUNodes.td Mon Aug 9 11:33:00 2010 @@ -117,6 +117,12 @@ def SPU_vec_demote : SDTypeProfile<1, 1, []>; def SPUvec2prefslot: SDNode<"SPUISD::VEC2PREFSLOT", SPU_vec_demote, []>; +def SPU_half_2_vec : SDTypeProfile<1, 1, []>; +def SPUhalf2vec: SDNode<"SPUISD::HALF2VEC", SPU_half_2_vec, []>; + +def SPU_vec_2_half : SDTypeProfile<1, 1, []>; +def SPUvec2half: SDNode<"SPUISD::VEC2HALF", SPU_vec_2_half, []>; + // Address high and low components, used for [r+r] type addressing def SPUhi : SDNode<"SPUISD::Hi", SDTIntBinOp, []>; def SPUlo : SDNode<"SPUISD::Lo", SDTIntBinOp, []>; Modified: llvm/trunk/lib/Target/CellSPU/SPURegisterInfo.cpp URL: http://llvm.org/viewvc/llvm-project/llvm/trunk/lib/Target/CellSPU/SPURegisterInfo.cpp?rev=110576&r1=110575&r2=110576&view=diff ============================================================================== --- llvm/trunk/lib/Target/CellSPU/SPURegisterInfo.cpp (original) +++ llvm/trunk/lib/Target/CellSPU/SPURegisterInfo.cpp Mon Aug 9 11:33:00 2010 @@ -587,6 +587,7 @@ case SPU::LQDr32: return SPU::LQXr32; case SPU::LQDr128: return SPU::LQXr128; case SPU::LQDv16i8: return SPU::LQXv16i8; + case SPU::LQDv4i32: return SPU::LQXv4i32; case SPU::LQDv4f32: return SPU::LQXv4f32; case SPU::STQDr32: return SPU::STQXr32; case SPU::STQDr128: return SPU::STQXr128; Modified: llvm/trunk/test/CodeGen/CellSPU/bigstack.ll URL: http://llvm.org/viewvc/llvm-project/llvm/trunk/test/CodeGen/CellSPU/bigstack.ll?rev=110576&r1=110575&r2=110576&view=diff ============================================================================== --- llvm/trunk/test/CodeGen/CellSPU/bigstack.ll (original) +++ llvm/trunk/test/CodeGen/CellSPU/bigstack.ll Mon Aug 9 11:33:00 2010 @@ -1,7 +1,7 @@ ; RUN: llc < %s -march=cellspu -o %t1.s -; RUN: grep lqx %t1.s | count 4 -; RUN: grep il %t1.s | grep -v file | count 7 -; RUN: grep stqx %t1.s | count 2 +; RUN: grep lqx %t1.s | count 3 +; RUN: grep il %t1.s | grep -v file | count 5 +; RUN: grep stqx %t1.s | count 1 define i32 @bigstack() nounwind { entry: Modified: llvm/trunk/test/CodeGen/CellSPU/v2f32.ll URL: http://llvm.org/viewvc/llvm-project/llvm/trunk/test/CodeGen/CellSPU/v2f32.ll?rev=110576&r1=110575&r2=110576&view=diff ============================================================================== --- llvm/trunk/test/CodeGen/CellSPU/v2f32.ll (original) +++ llvm/trunk/test/CodeGen/CellSPU/v2f32.ll Mon Aug 9 11:33:00 2010 @@ -61,3 +61,15 @@ ret %vec %rv } +define void @test_unaligned_store() { +;CHECK: cdd $3, 8($3) +;CHECK: lqd +;CHECK: shufb +;CHECK: stqd + %data = alloca [4 x float], align 16 ; <[4 x float]*> [#uses=1] + %ptr = getelementptr [4 x float]* %data, i32 0, i32 2 ; [#uses=1] + %vptr = bitcast float* %ptr to <2 x float>* ; <[1 x <2 x float>]*> [#uses=1] + store <2 x float> undef, <2 x float>* %vptr + ret void +} + From baldrick at free.fr Mon Aug 9 11:44:56 2010 From: baldrick at free.fr (Duncan Sands) Date: Mon, 09 Aug 2010 16:44:56 -0000 Subject: [llvm-commits] [llvm] r110577 - /llvm/trunk/include/llvm/ADT/ValueMap.h Message-ID: <20100809164456.764AB2A6C12C@llvm.org> Author: baldrick Date: Mon Aug 9 11:44:56 2010 New Revision: 110577 URL: http://llvm.org/viewvc/llvm-project?rev=110577&view=rev Log: Remove the ValueMap operator=, which was wrong (it did't correct the Map pointers of any contained ValueMapCallbackVH's) and unused. Modified: llvm/trunk/include/llvm/ADT/ValueMap.h Modified: llvm/trunk/include/llvm/ADT/ValueMap.h URL: http://llvm.org/viewvc/llvm-project/llvm/trunk/include/llvm/ADT/ValueMap.h?rev=110577&r1=110576&r2=110577&view=diff ============================================================================== --- llvm/trunk/include/llvm/ADT/ValueMap.h (original) +++ llvm/trunk/include/llvm/ADT/ValueMap.h Mon Aug 9 11:44:56 2010 @@ -83,6 +83,7 @@ MapT Map; ExtraData Data; ValueMap(const ValueMap&); // DO NOT IMPLEMENT + ValueMap& operator=(const ValueMap&); // DO NOT IMPLEMENT public: typedef KeyT key_type; typedef ValueT mapped_type; @@ -160,12 +161,6 @@ return Map[Wrap(Key)]; } - ValueMap& operator=(const ValueMap& Other) { - Map = Other.Map; - Data = Other.Data; - return *this; - } - /// isPointerIntoBucketsArray - Return true if the specified pointer points /// somewhere into the ValueMap's array of buckets (i.e. either to a key or /// value in the ValueMap). From geek4civic at gmail.com Mon Aug 9 11:51:13 2010 From: geek4civic at gmail.com (NAKAMURA Takumi) Date: Tue, 10 Aug 2010 01:51:13 +0900 Subject: [llvm-commits] [Patch Proposal] PR6297 simplify RWMutex Message-ID: Hello everyone, We don't need to set the default value "PTHREAD_PROCESS_PRIVATE" for pthread_rwlock_init(3T). It also resolves PR6297. RWMutex.cpp and pthread on mingw http://llvm.org/bugs/show_bug.cgi?id=6297 I have checked on mingw(msysgit), fedora12-ppc, and centos5(x86-64) w/o regression. ...Takumi -------------- next part -------------- diff --git a/lib/System/RWMutex.cpp b/lib/System/RWMutex.cpp index 5faf220..5a33364 100644 --- a/lib/System/RWMutex.cpp +++ b/lib/System/RWMutex.cpp @@ -71,23 +71,8 @@ RWMutexImpl::RWMutexImpl() bzero(rwlock, sizeof(pthread_rwlock_t)); #endif - pthread_rwlockattr_t attr; - - // Initialize the rwlock attributes - int errorcode = pthread_rwlockattr_init(&attr); - assert(errorcode == 0); - -#if !defined(__FreeBSD__) && !defined(__OpenBSD__) && !defined(__NetBSD__) && !defined(__DragonFly__) - // Make it a process local rwlock - errorcode = pthread_rwlockattr_setpshared(&attr, PTHREAD_PROCESS_PRIVATE); -#endif - // Initialize the rwlock - errorcode = pthread_rwlock_init(rwlock, &attr); - assert(errorcode == 0); - - // Destroy the attributes - errorcode = pthread_rwlockattr_destroy(&attr); + int errorcode = pthread_rwlock_init(rwlock, NULL); assert(errorcode == 0); // Assign the data member From criswell at uiuc.edu Mon Aug 9 12:10:38 2010 From: criswell at uiuc.edu (John Criswell) Date: Mon, 09 Aug 2010 17:10:38 -0000 Subject: [llvm-commits] [poolalloc] r110578 - in /poolalloc/trunk: include/assistDS/Devirt.h lib/AssistDS/Devirt.cpp Message-ID: <20100809171038.37ABC2A6C12C@llvm.org> Author: criswell Date: Mon Aug 9 12:10:38 2010 New Revision: 110578 URL: http://llvm.org/viewvc/llvm-project?rev=110578&view=rev Log: Refactoring of Andrew Lenharth's devirtualization pass. This version works on user-space code and currently devirtualizes all indirect function calls which for which all function targets are known. Added: poolalloc/trunk/include/assistDS/Devirt.h poolalloc/trunk/lib/AssistDS/Devirt.cpp - copied, changed from r110449, poolalloc/trunk/lib/AssistDS/SVADevirt.cpp Added: poolalloc/trunk/include/assistDS/Devirt.h URL: http://llvm.org/viewvc/llvm-project/poolalloc/trunk/include/assistDS/Devirt.h?rev=110578&view=auto ============================================================================== --- poolalloc/trunk/include/assistDS/Devirt.h (added) +++ poolalloc/trunk/include/assistDS/Devirt.h Mon Aug 9 12:10:38 2010 @@ -0,0 +1,72 @@ +//===- Devirt.cpp - Devirtualize using the sig match intrinsic in llva ----===// +// +// The LLVM Compiler Infrastructure +// +// This file was developed by the LLVM research group and is distributed under +// the University of Illinois Open Source License. See LICENSE.TXT for details. +// +//===----------------------------------------------------------------------===// +// +// This file defines an LLVM transform that converts indirect function calls +// into direct function calls. +// +//===----------------------------------------------------------------------===// + +#include "dsa/CallTargets.h" + +#include "llvm/Constants.h" +#include "llvm/Transforms/IPO.h" +#include "llvm/Pass.h" +#include "llvm/Module.h" +#include "llvm/Function.h" +#include "llvm/Instructions.h" +#include "llvm/DerivedTypes.h" +#include "llvm/Support/InstVisitor.h" + +using namespace llvm; + +namespace llvm { + // + // Class: Devirtualize + // + // Description: + // This transform pass will look for indirect function calls and transform + // them into a switch statement that selects one of several direct function + // calls to execute. + // + class Devirtualize : public ModulePass, public InstVisitor { + private: + // Access to analysis pass which finds targets of indirect function calls + CallTargetFinder* CTF; + + // Worklist of call sites to transform + std::vector Worklist; + + protected: + void makeDirectCall (CallSite & CS); + Function* buildBounce (CallSite cs,std::vector& Targets); + + public: + static char ID; + Devirtualize() : ModulePass(&ID), CTF(0) {} + + virtual bool runOnModule(Module & M); + + virtual void getAnalysisUsage(AnalysisUsage &AU) const { + AU.addRequired(); + } + + // Visitor methods for analyzing instructions + //void visitInstruction(Instruction &I); + void visitCallSite(CallSite &CS); + void visitCallInst(CallInst &CI) { + CallSite CS(&CI); + visitCallSite(CS); + } + void visitInvokeInst(InvokeInst &II) { + CallSite CS(&II); + visitCallSite(CS); + } + }; +} + Copied: poolalloc/trunk/lib/AssistDS/Devirt.cpp (from r110449, poolalloc/trunk/lib/AssistDS/SVADevirt.cpp) URL: http://llvm.org/viewvc/llvm-project/poolalloc/trunk/lib/AssistDS/Devirt.cpp?p2=poolalloc/trunk/lib/AssistDS/Devirt.cpp&p1=poolalloc/trunk/lib/AssistDS/SVADevirt.cpp&r1=110449&r2=110578&rev=110578&view=diff ============================================================================== --- poolalloc/trunk/lib/AssistDS/SVADevirt.cpp (original) +++ poolalloc/trunk/lib/AssistDS/Devirt.cpp Mon Aug 9 12:10:38 2010 @@ -6,15 +6,11 @@ // the University of Illinois Open Source License. See LICENSE.TXT for details. // //===----------------------------------------------------------------------===// + #define DEBUG_TYPE "devirt" -#include "llvm/Constants.h" -#include "llvm/Transforms/IPO.h" -#include "dsa/CallTargets.h" -#include "llvm/Pass.h" -#include "llvm/Module.h" -#include "llvm/Function.h" -#include "llvm/Instructions.h" -#include "llvm/DerivedTypes.h" + +#include "assistDS/Devirt.h" + #include "llvm/Support/CommandLine.h" #include "llvm/ADT/Statistic.h" @@ -24,15 +20,23 @@ using namespace llvm; -#if 0 +// Pass statistics +STATISTIC(FuncAdded, "Number of bounce functions added"); +STATISTIC(CSConvert, "Number of call sites converted"); + +// Pass registration +RegisterPass +X ("devirt", "Devirtualize indirect function calls"); // // Function: castTo() // -// Description: // Given an LLVM value, insert a cast instruction to make it a given type. +// Description: +// Given an LLVM value, insert a cast instruction to make it a given type. // static inline Value * -castTo (Value * V, const Type * Ty, Instruction * InsertPt) { // +castTo (Value * V, const Type * Ty, std::string Name, Instruction * InsertPt) { + // // Don't bother creating a cast if it's already the correct type. // if (V->getType() == Ty) @@ -42,215 +46,259 @@ // If it's a constant, just create a constant expression. // if (Constant * C = dyn_cast(V)) { - Constant * CE = ConstantExpr::getCast (C, Ty); + Constant * CE = ConstantExpr::getZExtOrBitCast (C, Ty); return CE; } // // Otherwise, insert a cast instruction. // - return new CastInst::Create(V, Ty, "cast", InsertPt); + return CastInst::CreateZExtOrBitCast (V, Ty, Name, InsertPt); } -namespace { +// +// Method: buildBounce() +// +// Description: +// Replaces the given call site with a call to a bounce function. The +// bounce function compares the function pointer to one of the given +// target functions and calls the function directly if the pointer +// matches. +// +Function* +Devirtualize::buildBounce (CallSite CS, std::vector& Targets) { + // + // Update the statistics on the number of bounce functions added to the + // module. + // + ++FuncAdded; - static cl::opt - VirtualLimit("devirt-limit", cl::Hidden, cl::init(16), - cl::desc("Maximum number of callees to devirtualize at a call site")); - STATISTIC(FuncAdded, "Number of bounce functions added"); - STATISTIC(CSConvert, "Number of call sites converted"); - - - class Devirtualize : public ModulePass { - - - Function * IndirectFuncFail; - - std::map >, Function*> cache; - int fnum; - - // - // Method: buildBounce() - // - // Description: - // Replaces the given call site with a call to a bounce function. The - // bounce function compares the function pointer to one of the given - // target functions and calls the function directly if the pointer - // matches. - Function* buildBounce (CallSite cs, - std::vector& Targets, - Module& M) { - - Value* ptr = cs.getCalledValue(); - const FunctionType* OrigType = - cast(cast(ptr->getType())->getElementType());; - ++FuncAdded; - - std::vector< const Type *> TP(OrigType->param_begin(), OrigType->param_end()); - TP.insert(TP.begin(), ptr->getType()); - const FunctionType* NewTy = FunctionType::get(OrigType->getReturnType(), TP, false); - Function* F = new Function(NewTy, GlobalValue::InternalLinkage, "devirtbounce", &M); - std::map targets; - - F->arg_begin()->setName("funcPtr"); - std::vector fargs; - for(Function::arg_iterator ai = F->arg_begin(), ae = F->arg_end(); ai != ae; ++ai) - if (ai != F->arg_begin()) { - fargs.push_back(ai); - ai->setName("arg"); - } - - for (std::vector::iterator i = Targets.begin(), e = Targets.end(); - i != e; ++i) { - Function* FL = *i; - BasicBlock* BL = new BasicBlock(FL->getName(), F); - targets[FL] = BL; - - //Make call - Value* call = new CallInst(FL, fargs, "", BL); - - //return correctly - if (OrigType->getReturnType() == Type::VoidTy) - new ReturnInst(0, BL); - else - new ReturnInst(call, BL); - } - - // Create a set of tests that search for the correct function target - // and call it directly. If none of the target functions match, - // call pchk_ind_fail() to note the failure. - - // - // Create the failure basic block. Then, add the following: - // o the terminating instruction - // o the indirect call to the original function - // o a call to phck_ind_fail() - // - BasicBlock* tail = new BasicBlock("fail", F, &F->getEntryBlock()); - Instruction * InsertPt; -#if 0 - InsertPt = new UnreachableInst(tail); -#else - Value* p = F->arg_begin(); - Instruction * realCall = new CallInst (p, fargs, "", tail); - if (OrigType->getReturnType() == Type::VoidTy) - InsertPt = new ReturnInst(0, tail); - else - InsertPt = new ReturnInst(realCall, tail); -#endif - Value * FuncVoidPtr = castTo (p, - PointerType::get(Type::SByteTy), - realCall); - new CallInst (IndirectFuncFail, FuncVoidPtr, "", realCall); - - - // Create basic blocks for valid target functions - for (std::vector::iterator i = Targets.begin(), e = Targets.end(); - i != e; ++i) { - BasicBlock* TB = targets[*i]; - BasicBlock* newB = new BasicBlock("test." + (*i)->getName(), F, &F->getEntryBlock()); - SetCondInst* setcc = new SetCondInst(Instruction::SetEQ, *i, p, "sc", newB); - new BranchInst(TB, tail, setcc, newB); - tail = newB; - } - return F; - } + // + // Create a bounce function that has a function signature almost identical + // to the function being called. The only difference is that it will have + // an additional pointer argument at the beginning of its argument list that + // will be the function to call. + // + Value* ptr = CS.getCalledValue(); + const FunctionType* OrigType = + cast(cast(ptr->getType())->getElementType()); + + std::vector TP (OrigType->param_begin(), OrigType->param_end()); + TP.insert (TP.begin(), ptr->getType()); + const FunctionType* NewTy = FunctionType::get(OrigType->getReturnType(), TP, false); + Module * M = CS.getInstruction()->getParent()->getParent()->getParent(); + Function* F = Function::Create (NewTy, + GlobalValue::InternalLinkage, + "devirtbounce", + M); - public: - static char ID; - Devirtualize() : ModulePass(&ID) {} - - virtual bool runOnModule(Module &M) { - CallTargetFinder* CTF = &getAnalysis(); - - // Get references to functions that are needed in the module - Function* ams = M.getNamedFunction ("llva_assert_match_sig"); - if (!ams) - return false; - - IndirectFuncFail = M.getOrInsertFunction ("pchk_ind_fail", - Type::VoidTy, - PointerType::getUnqual(Type::Int8Ty), - NULL); - - std::set safecalls; - std::vector toDelete; - - for (Value::use_iterator ii = ams->use_begin(), ee = ams->use_end(); - ii != ee; ++ii) { - if (CallInst* CI = dyn_cast(*ii)) { - std::cerr << "Found safe call site in " - << CI->getParent()->getParent()->getName() << "\n"; - Value* V = CI->getOperand(1); - toDelete.push_back(CI); - do { - //V->dump(); - safecalls.insert(V); - if (CastInst* CV = dyn_cast(V)) - V = CV->getOperand(0); - else V = 0; - } while (V); - } - } - - for(std::set::iterator i = safecalls.begin(), e = safecalls.end(); - i != e; ++i) { - for (Value::use_iterator uii = (*i)->use_begin(), uie = (*i)->use_end(); - uii != uie; ++uii) { - CallSite cs = CallSite::get(*uii); - bool isSafeCall = cs.getInstruction() && - safecalls.find(cs.getCalledValue()) != safecalls.end(); - if (cs.getInstruction() && !cs.getCalledFunction() && - (isSafeCall || CTF->isComplete(cs))) { - std::vector Targets; - for (std::vector::iterator ii = CTF->begin(cs), ee = CTF->end(cs); - ii != ee; ++ii) - if (!isSafeCall || (*ii)->getType() == cs.getCalledValue()->getType()) - Targets.push_back(*ii); - - if (Targets.size() > 0) { - std::cerr << "Target count: " << Targets.size() << " in " << cs.getInstruction()->getParent()->getParent()->getName() << "\n"; - Function* NF = buildBounce(cs, Targets, M); - if (CallInst* ci = dyn_cast(cs.getInstruction())) { - ++CSConvert; - std::vector Par(ci->op_begin(), ci->op_end()); - CallInst* cn = CallInst::Create(NF, Par.begin(), Par.end(), - ci->getName() + ".dv", ci); - ci->replaceAllUsesWith(cn); - toDelete.push_back(ci); - } else if (InvokeInst* ci = dyn_cast(cs.getInstruction())) { - ++CSConvert; - std::vector Par(ci->op_begin(), ci->op_end()); - InvokeInst* cn = InvokeInst::Create(NF, ci->getNormalDest(), - ci->getUnwindDest(), - Par, ci->getName()+".dv", - ci); - ci->replaceAllUsesWith(cn); - toDelete.push_back(ci); - } - } else //Target size == 0 - std::cerr << "Call site found, but no Targets\n"; - } - } - } - - bool changed = false; - for (std::vector::iterator ii = toDelete.begin(), ee = toDelete.end(); - ii != ee; ++ii) { - changed = true; - (*ii)->eraseFromParent(); - } - return changed; + // + // Set the names of the arguments. Also, record the arguments in a vector + // for subsequence access. + // + F->arg_begin()->setName("funcPtr"); + std::vector fargs; + for(Function::arg_iterator ai = F->arg_begin(), ae = F->arg_end(); ai != ae; ++ai) + if (ai != F->arg_begin()) { + fargs.push_back(ai); + ai->setName("arg"); } - virtual void getAnalysisUsage(AnalysisUsage &AU) const { - AU.addRequired(); + // + // For each function target, create a basic block that will call that + // function directly. + // + std::map targets; + for (unsigned index = 0; index < Targets.size(); ++index) { + const Function* FL = Targets[index]; + + // Create the basic block for doing the direct call + BasicBlock* BL = BasicBlock::Create (M->getContext(), FL->getName(), F); + targets[FL] = BL; + + // Create the direct function call + Value* directCall = CallInst::Create ((Value *)FL, + fargs.begin(), + fargs.end(), + "", + BL); + + // Add the return instruction for the basic block + if (OrigType->getReturnType()->isVoidTy()) + ReturnInst::Create (M->getContext(), BL); + else + ReturnInst::Create (M->getContext(), directCall, BL); + } + + // + // Create a set of tests that search for the correct function target + // and call it directly. If none of the target functions match, + // abort (or make the result unreachable). + // + + // + // Create the failure basic block. This basic block should simply be an + // unreachable instruction. + // + BasicBlock* tail = BasicBlock::Create (M->getContext(), + "fail", + F, + &F->getEntryBlock()); + Instruction * InsertPt; + InsertPt = new UnreachableInst (M->getContext(), tail); + + // + // Create basic blocks for valid target functions. + // + for (unsigned index = 0; index < Targets.size(); ++index) { + const Function * Target = Targets[index]; + BasicBlock* TB = targets[Target]; + BasicBlock* newB = BasicBlock::Create (M->getContext(), + "test." + Target->getName(), + F, + &F->getEntryBlock()); + CmpInst * setcc = CmpInst::Create (Instruction::ICmp, + CmpInst::ICMP_EQ, + (Value *) Target, + &(*(F->arg_begin())), + "sc", + newB); + BranchInst::Create (TB, tail, setcc, newB); + tail = newB; + } + return F; +} + +// +// Method: makeDirectCall() +// +// Description: +// Transform the specified call site into a direct call. +// +// Inputs: +// CS - The call site to transform. +// +// Preconditions: +// 1) This method assumes that CS is an indirect call site. +// 2) This method assumes that a pointer to the CallTarget analysis pass has +// already been acquired by the class. +// +void +Devirtualize::makeDirectCall (CallSite & CS) { + // + // Find the targets of the indirect function call. + // + std::vector Targets; + Targets.insert (Targets.begin(), CTF->begin(CS), CTF->end(CS)); + + // + // Convert the call site if there were any function call targets found. + // + if (Targets.size() > 0) { + // + // Build a function which will implement a switch statement. The switch + // statement will determine which function target to call and call it. + // + Function* NF = buildBounce (CS, Targets); + + // + // Replace the original call with a call to the bounce function. + // + if (CallInst* CI = dyn_cast(CS.getInstruction())) { + std::vector Params (CI->op_begin(), CI->op_end()); + CallInst* CN = CallInst::Create (NF, + Params.begin(), + Params.end(), + CI->getName() + ".dv", + CI); + CI->replaceAllUsesWith(CN); + CI->eraseFromParent(); + } else if (InvokeInst* CI = dyn_cast(CS.getInstruction())) { + std::vector Params (CI->op_begin(), CI->op_end()); + InvokeInst* CN = InvokeInst::Create(NF, + CI->getNormalDest(), + CI->getUnwindDest(), + Params.begin(), + Params.end(), + CI->getName()+".dv", + CI); + CI->replaceAllUsesWith(CN); + CI->eraseFromParent(); } - }; + // + // Update the statistics on the number of transformed call sites. + // + ++CSConvert; + } + + return; +} + +// +// Method: visitCallSite() +// +// Description: +// Examine the specified call site. If it is an indirect call, mark it for +// transformation into a direct call. +// +void +Devirtualize::visitCallSite (CallSite &CS) { + // + // First, determine if this is a direct call. If so, then just ignore it. + // + Value * CalledValue = CS.getCalledValue(); + if (isa(CalledValue->stripPointerCasts())) + return; + + // + // Second, we will only transform those call sites which are complete (i.e., + // for which we know all of the call targets). + // + if (!(CTF->isComplete(CS))) + return; + + // + // This is an indirect call site. Put it in the worklist of call sites to + // transforms. + // + Worklist.push_back (CS.getInstruction()); + return; +} - RegisterPass X("devirt", "Devirtualization"); +// +// Method: runOnModule() +// +// Description: +// Entry point for this LLVM transform pass. Look for indirect function calls +// and turn them into direct function calls. +// +bool +Devirtualize::runOnModule (Module & M) { + // + // Get the targets of indirect function calls. + // + CTF = &getAnalysis(); + // + // Visit all of the call instructions in this function and record those that + // are indirect function calls. + // + visit (M); + + // + // Now go through and transform all of the indirect calls that we found that + // need transforming. + // + for (unsigned index = 0; index < Worklist.size(); ++index) { + // Autobots, transform (the call site)! + CallSite CS (Worklist[index]); + makeDirectCall (CS); + } + + // + // Conservatively assume that we've changed one or more call sites. + // + return true; } -#endif From evan.cheng at apple.com Mon Aug 9 12:16:10 2010 From: evan.cheng at apple.com (Evan Cheng) Date: Mon, 09 Aug 2010 17:16:10 -0000 Subject: [llvm-commits] [llvm] r110579 - /llvm/trunk/lib/Target/ARM/ARMTargetMachine.cpp Message-ID: <20100809171610.30F3A2A6C12C@llvm.org> Author: evancheng Date: Mon Aug 9 12:16:10 2010 New Revision: 110579 URL: http://llvm.org/viewvc/llvm-project?rev=110579&view=rev Log: Add an option to disable 32 -> 16-bit Thumb2 size reduction pass for experimentation. Modified: llvm/trunk/lib/Target/ARM/ARMTargetMachine.cpp Modified: llvm/trunk/lib/Target/ARM/ARMTargetMachine.cpp URL: http://llvm.org/viewvc/llvm-project/llvm/trunk/lib/Target/ARM/ARMTargetMachine.cpp?rev=110579&r1=110578&r2=110579&view=diff ============================================================================== --- llvm/trunk/lib/Target/ARM/ARMTargetMachine.cpp (original) +++ llvm/trunk/lib/Target/ARM/ARMTargetMachine.cpp Mon Aug 9 12:16:10 2010 @@ -16,11 +16,17 @@ #include "ARM.h" #include "llvm/PassManager.h" #include "llvm/CodeGen/Passes.h" +#include "llvm/Support/CommandLine.h" #include "llvm/Support/FormattedStream.h" #include "llvm/Target/TargetOptions.h" #include "llvm/Target/TargetRegistry.h" using namespace llvm; +static cl::opt +Prefer32BitThumbInstrs("prefer-32bit-thumb", + cl::desc("Prefer 32-bit Thumb instructions"), + cl::init(false)); + static MCAsmInfo *createMCAsmInfo(const Target &T, StringRef TT) { Triple TheTriple(TT); switch (TheTriple.getOS()) { @@ -31,7 +37,6 @@ } } - extern "C" void LLVMInitializeARMTarget() { // Register the target. RegisterTargetMachine X(TheARMTarget); @@ -138,7 +143,7 @@ bool ARMBaseTargetMachine::addPreEmitPass(PassManagerBase &PM, CodeGenOpt::Level OptLevel) { - if (Subtarget.isThumb2()) + if (!Prefer32BitThumbInstrs && Subtarget.isThumb2()) PM.add(createThumb2SizeReductionPass()); PM.add(createARMConstantIslandPass()); From geek4civic at gmail.com Mon Aug 9 12:23:06 2010 From: geek4civic at gmail.com (NAKAMURA Takumi) Date: Tue, 10 Aug 2010 02:23:06 +0900 Subject: [llvm-commits] [Patch Proposal] fix unittests on mingw Message-ID: Good midnight, everyone. Their patches make "make unittests" fine on mingw. * r110166-unittests-RDYNAMIC.diff.txt On cygwin/mingw, this redefines $RDYNAMIC and suppress $RPATH. TODO: it should be detected by autoconf. This enables exporting symbols from Executable.EXE. (eg. unittests/JIT) * r106620-unittests-mingw-EXPECT_DEATH.diff.txt gtest death test aborts with a desktop dialog on Windows 7. I had to suppress death tests on mingw. r84355-unittests-workaround-msvcrt.diff.txt This is workaround for PR6745 and PR7668. http://llvm.org/bugs/show_bug.cgi?id=6745 (When the issue is resolved, we can meet failure by this patch. Then we have to revert it.) ...oyasuminasai...Takumi -------------- next part -------------- diff --git a/unittests/Support/raw_ostream_test.cpp b/unittests/Support/raw_ostream_test.cpp index 2b797b4..1b280dd 100644 --- a/unittests/Support/raw_ostream_test.cpp +++ b/unittests/Support/raw_ostream_test.cpp @@ -66,7 +66,11 @@ TEST(raw_ostreamTest, Types_Buffered) { EXPECT_EQ("-257257257235709", printToString(-257257257235709LL)); // Double +#ifdef _WIN32 + EXPECT_EQ("1.100000e+000", printToString(1.1)); +#else EXPECT_EQ("1.100000e+00", printToString(1.1)); +#endif // void* EXPECT_EQ("0x0", printToString((void*) 0)); @@ -97,7 +101,11 @@ TEST(raw_ostreamTest, Types_Unbuffered) { EXPECT_EQ("-257257257235709", printToStringUnbuffered(-257257257235709LL)); // Double +#ifdef _WIN32 + EXPECT_EQ("1.100000e+000", printToStringUnbuffered(1.1)); +#else EXPECT_EQ("1.100000e+00", printToStringUnbuffered(1.1)); +#endif // void* EXPECT_EQ("0x0", printToStringUnbuffered((void*) 0)); -------------- next part -------------- diff --git a/utils/unittest/googletest/include/gtest/internal/gtest-port.h b/utils/unittest/googletest/include/gtest/internal/gtest-port.h index 9683271..a77d211 100644 --- a/utils/unittest/googletest/include/gtest/internal/gtest-port.h +++ b/utils/unittest/googletest/include/gtest/internal/gtest-port.h @@ -488,7 +488,7 @@ // pops up a dialog window that cannot be suppressed programmatically. #if (GTEST_OS_LINUX || GTEST_OS_MAC || GTEST_OS_CYGWIN || GTEST_OS_SOLARIS || \ (GTEST_OS_WINDOWS_DESKTOP && _MSC_VER >= 1400) || \ - GTEST_OS_WINDOWS_MINGW || GTEST_OS_AIX) + GTEST_OS_AIX) #define GTEST_HAS_DEATH_TEST 1 #include // NOLINT #endif -------------- next part -------------- diff --git a/Makefile.config.in b/Makefile.config.in index 5ebd803..13b8723 100644 --- a/Makefile.config.in +++ b/Makefile.config.in @@ -209,12 +209,20 @@ LLVMCC_OPTION := @LLVMCC_OPTION@ # object files. OBJ_ROOT := . +ifneq (,$(filter $(HOST_OS), Cygwin MingW)) + +RDYNAMIC := -Wl,--export-all-symbols + +else + # What to pass as rpath flag to g++ RPATH := @RPATH@ # What to pass as -rdynamic flag to g++ RDYNAMIC := @RDYNAMIC@ +endif + # These are options that can either be enabled here, or can be enabled on the # make command line (ie, make ENABLE_PROFILING=1): diff --git a/unittests/Makefile.unittest b/unittests/Makefile.unittest index 2a701a0..29da761 100644 --- a/unittests/Makefile.unittest +++ b/unittests/Makefile.unittest @@ -35,9 +35,11 @@ endif TESTLIBS = -lGoogleTest -lUnitTestMain ifeq ($(ENABLE_SHARED), 1) - # Add the absolute path to the dynamic library. This is ok because - # we'll never install unittests. - LD.Flags += $(RPATH) -Wl,$(LibDir) + ifneq (,$(RPATH)) + # Add the absolute path to the dynamic library. This is ok because + # we'll never install unittests. + LD.Flags += $(RPATH) -Wl,$(LibDir) + endif # Also set {DYLD,LD}_LIBRARY_PATH because OSX ignores the rpath most # of the time. Run.Shared := $(SHLIBPATH_VAR)="$(LibDir)$${$(SHLIBPATH_VAR):+:}$$$(SHLIBPATH_VAR)" From bruno.cardoso at gmail.com Mon Aug 9 13:03:43 2010 From: bruno.cardoso at gmail.com (Bruno Cardoso Lopes) Date: Mon, 09 Aug 2010 18:03:43 -0000 Subject: [llvm-commits] [llvm] r110580 - /llvm/trunk/lib/Target/X86/X86InstrSSE.td Message-ID: <20100809180343.47DDD2A6C12C@llvm.org> Author: bruno Date: Mon Aug 9 13:03:43 2010 New Revision: 110580 URL: http://llvm.org/viewvc/llvm-project?rev=110580&view=rev Log: Patterns to match vinsert, vbroadcast, vmovmask and vcvtdq2pd AVX intrinsics Modified: llvm/trunk/lib/Target/X86/X86InstrSSE.td Modified: llvm/trunk/lib/Target/X86/X86InstrSSE.td URL: http://llvm.org/viewvc/llvm-project/llvm/trunk/lib/Target/X86/X86InstrSSE.td?rev=110580&r1=110579&r2=110580&view=diff ============================================================================== --- llvm/trunk/lib/Target/X86/X86InstrSSE.td (original) +++ llvm/trunk/lib/Target/X86/X86InstrSSE.td Mon Aug 9 13:03:43 2010 @@ -3226,13 +3226,15 @@ // Convert Packed DW Integers to Packed Double FP let isAsmParserOnly = 1, Predicates = [HasAVX] in { def VCVTDQ2PDrm : S3SI<0xE6, MRMSrcMem, (outs VR128:$dst), (ins f128mem:$src), - "vcvtdq2pd\t{$src, $dst|$dst, $src}", []>, VEX; + "vcvtdq2pd\t{$src, $dst|$dst, $src}", []>, VEX; def VCVTDQ2PDrr : S3SI<0xE6, MRMSrcReg, (outs VR128:$dst), (ins VR128:$src), - "vcvtdq2pd\t{$src, $dst|$dst, $src}", []>, VEX; + "vcvtdq2pd\t{$src, $dst|$dst, $src}", []>, VEX; def VCVTDQ2PDYrm : S3SI<0xE6, MRMSrcMem, (outs VR256:$dst), (ins f128mem:$src), - "vcvtdq2pd\t{$src, $dst|$dst, $src}", []>, VEX; + "vcvtdq2pd\t{$src, $dst|$dst, $src}", []>, VEX; def VCVTDQ2PDYrr : S3SI<0xE6, MRMSrcReg, (outs VR256:$dst), (ins VR128:$src), - "vcvtdq2pd\t{$src, $dst|$dst, $src}", []>, VEX; + "vcvtdq2pd\t{$src, $dst|$dst, $src}", + [(set VR256:$dst, + (int_x86_avx_cvtdq2_pd_256 VR128:$src))]>, VEX; } def CVTDQ2PDrm : S3SI<0xE6, MRMSrcMem, (outs VR128:$dst), (ins f128mem:$src), @@ -5310,14 +5312,19 @@ // Load from memory and broadcast to all elements of the destination operand class avx_broadcast opc, string OpcodeStr, RegisterClass RC, - X86MemOperand x86memop> : + X86MemOperand x86memop, Intrinsic Int> : AVX8I, VEX; + !strconcat(OpcodeStr, "\t{$src, $dst|$dst, $src}"), + [(set RC:$dst, (Int addr:$src))]>, VEX; -def VBROADCASTSS : avx_broadcast<0x18, "vbroadcastss", VR128, f32mem>; -def VBROADCASTSSY : avx_broadcast<0x18, "vbroadcastss", VR256, f32mem>; -def VBROADCASTSD : avx_broadcast<0x19, "vbroadcastsd", VR256, f64mem>; -def VBROADCASTF128 : avx_broadcast<0x1A, "vbroadcastf128", VR256, f128mem>; +def VBROADCASTSS : avx_broadcast<0x18, "vbroadcastss", VR128, f32mem, + int_x86_avx_vbroadcastss>; +def VBROADCASTSSY : avx_broadcast<0x18, "vbroadcastss", VR256, f32mem, + int_x86_avx_vbroadcastss_256>; +def VBROADCASTSD : avx_broadcast<0x19, "vbroadcastsd", VR256, f64mem, + int_x86_avx_vbroadcast_sd_256>; +def VBROADCASTF128 : avx_broadcast<0x1A, "vbroadcastf128", VR256, f128mem, + int_x86_avx_vbroadcastf128_pd_256>; // Insert packed floating-point values def VINSERTF128rr : AVXAIi8<0x18, MRMSrcReg, (outs VR256:$dst), @@ -5340,27 +5347,42 @@ []>, VEX; // Conditional SIMD Packed Loads and Stores -multiclass avx_movmask_rm opc_rm, bits<8> opc_mr, string OpcodeStr> { +multiclass avx_movmask_rm opc_rm, bits<8> opc_mr, string OpcodeStr, + Intrinsic IntLd, Intrinsic IntLd256, + Intrinsic IntSt, Intrinsic IntSt256, + PatFrag pf128, PatFrag pf256> { def rm : AVX8I, VEX_4V; + [(set VR128:$dst, (IntLd addr:$src2, VR128:$src1))]>, + VEX_4V; def Yrm : AVX8I, VEX_4V; + [(set VR256:$dst, (IntLd256 addr:$src2, VR256:$src1))]>, + VEX_4V; def mr : AVX8I, VEX_4V; + [(IntSt addr:$dst, VR128:$src1, VR128:$src2)]>, VEX_4V; def Ymr : AVX8I, VEX_4V; + [(IntSt256 addr:$dst, VR256:$src1, VR256:$src2)]>, VEX_4V; } -defm VMASKMOVPS : avx_movmask_rm<0x2C, 0x2E, "vmaskmovps">; -defm VMASKMOVPD : avx_movmask_rm<0x2D, 0x2F, "vmaskmovpd">; +defm VMASKMOVPS : avx_movmask_rm<0x2C, 0x2E, "vmaskmovps", + int_x86_avx_maskload_ps, + int_x86_avx_maskload_ps_256, + int_x86_avx_maskstore_ps, + int_x86_avx_maskstore_ps_256, + memopv4f32, memopv8f32>; +defm VMASKMOVPD : avx_movmask_rm<0x2D, 0x2F, "vmaskmovpd", + int_x86_avx_maskload_pd, + int_x86_avx_maskload_pd_256, + int_x86_avx_maskstore_pd, + int_x86_avx_maskstore_pd_256, + memopv2f64, memopv4f64>; // Permute Floating-Point Values multiclass avx_permil opc_rm, bits<8> opc_rmi, string OpcodeStr, @@ -5422,6 +5444,23 @@ } // isAsmParserOnly +def : Pat<(int_x86_avx_vinsertf128_pd_256 VR256:$src1, VR128:$src2, imm:$src3), + (VINSERTF128rr VR256:$src1, VR128:$src2, imm:$src3)>; +def : Pat<(int_x86_avx_vinsertf128_ps_256 VR256:$src1, VR128:$src2, imm:$src3), + (VINSERTF128rr VR256:$src1, VR128:$src2, imm:$src3)>; +def : Pat<(int_x86_avx_vinsertf128_si_256 VR256:$src1, VR128:$src2, imm:$src3), + (VINSERTF128rr VR256:$src1, VR128:$src2, imm:$src3)>; + +def : Pat<(int_x86_avx_vextractf128_pd_256 VR256:$src1, imm:$src2), + (VEXTRACTF128rr VR256:$src1, imm:$src2)>; +def : Pat<(int_x86_avx_vextractf128_ps_256 VR256:$src1, imm:$src2), + (VEXTRACTF128rr VR256:$src1, imm:$src2)>; +def : Pat<(int_x86_avx_vextractf128_si_256 VR256:$src1, imm:$src2), + (VEXTRACTF128rr VR256:$src1, imm:$src2)>; + +def : Pat<(int_x86_avx_vbroadcastf128_ps_256 addr:$src), + (VBROADCASTF128 addr:$src)>; + def : Pat<(int_x86_avx_vperm2f128_ps_256 VR256:$src1, VR256:$src2, imm:$src3), (VPERM2F128rr VR256:$src1, VR256:$src2, imm:$src3)>; def : Pat<(int_x86_avx_vperm2f128_pd_256 VR256:$src1, VR256:$src2, imm:$src3), From espindola at google.com Mon Aug 9 13:05:36 2010 From: espindola at google.com (Rafael Espindola) Date: Mon, 9 Aug 2010 14:05:36 -0400 Subject: [llvm-commits] [patch] Add -mtriple to LTO Message-ID: The attached patch adds -mtriple to LTO. It also moves setting the command line options earlier and moves _codegenOptions to the only method where it is used. Is it OK? Cheers, -- Rafael ?vila de Esp?ndola -------------- next part -------------- A non-text attachment was scrubbed... Name: lto.patch Type: text/x-patch Size: 2879 bytes Desc: not available Url : http://lists.cs.uiuc.edu/pipermail/llvm-commits/attachments/20100809/cd57109e/attachment.bin From criswell at uiuc.edu Mon Aug 9 13:10:32 2010 From: criswell at uiuc.edu (John Criswell) Date: Mon, 09 Aug 2010 18:10:32 -0000 Subject: [llvm-commits] [poolalloc] r110581 - /poolalloc/trunk/lib/AssistDS/Devirt.cpp Message-ID: <20100809181032.865BA2A6C12C@llvm.org> Author: criswell Date: Mon Aug 9 13:10:32 2010 New Revision: 110581 URL: http://llvm.org/viewvc/llvm-project?rev=110581&view=rev Log: Added missing pass ID variable. Modified: poolalloc/trunk/lib/AssistDS/Devirt.cpp Modified: poolalloc/trunk/lib/AssistDS/Devirt.cpp URL: http://llvm.org/viewvc/llvm-project/poolalloc/trunk/lib/AssistDS/Devirt.cpp?rev=110581&r1=110580&r2=110581&view=diff ============================================================================== --- poolalloc/trunk/lib/AssistDS/Devirt.cpp (original) +++ poolalloc/trunk/lib/AssistDS/Devirt.cpp Mon Aug 9 13:10:32 2010 @@ -20,6 +20,9 @@ using namespace llvm; +// Pass ID variable +char Devirtualize::ID = 0; + // Pass statistics STATISTIC(FuncAdded, "Number of bounce functions added"); STATISTIC(CSConvert, "Number of call sites converted"); From dpatel at apple.com Mon Aug 9 13:17:14 2010 From: dpatel at apple.com (Devang Patel) Date: Mon, 9 Aug 2010 11:17:14 -0700 Subject: [llvm-commits] [patch] Add -mtriple to LTO In-Reply-To: References: Message-ID: <5E5FA155-D3DE-4A43-ACDA-3E842A1E30F8@apple.com> On Aug 9, 2010, at 11:05 AM, Rafael Espindola wrote: > The attached patch adds -mtriple to LTO. It also moves setting the > command line options earlier and moves _codegenOptions to the only > method where it is used. > > Is it OK? > ok > Cheers, > -- > Rafael ?vila de Esp?ndola > _______________________________________________ > llvm-commits mailing list > llvm-commits at cs.uiuc.edu > http://lists.cs.uiuc.edu/mailman/listinfo/llvm-commits From bruno.cardoso at gmail.com Mon Aug 9 13:20:15 2010 From: bruno.cardoso at gmail.com (Bruno Cardoso Lopes) Date: Mon, 09 Aug 2010 18:20:15 -0000 Subject: [llvm-commits] [llvm] r110582 - /llvm/trunk/lib/Target/X86/X86InstrSSE.td Message-ID: <20100809182015.1E9042A6C12C@llvm.org> Author: bruno Date: Mon Aug 9 13:20:14 2010 New Revision: 110582 URL: http://llvm.org/viewvc/llvm-project?rev=110582&view=rev Log: Memory version of vcvtdq2pd intrinsic Modified: llvm/trunk/lib/Target/X86/X86InstrSSE.td Modified: llvm/trunk/lib/Target/X86/X86InstrSSE.td URL: http://llvm.org/viewvc/llvm-project/llvm/trunk/lib/Target/X86/X86InstrSSE.td?rev=110582&r1=110581&r2=110582&view=diff ============================================================================== --- llvm/trunk/lib/Target/X86/X86InstrSSE.td (original) +++ llvm/trunk/lib/Target/X86/X86InstrSSE.td Mon Aug 9 13:20:14 2010 @@ -3230,7 +3230,9 @@ def VCVTDQ2PDrr : S3SI<0xE6, MRMSrcReg, (outs VR128:$dst), (ins VR128:$src), "vcvtdq2pd\t{$src, $dst|$dst, $src}", []>, VEX; def VCVTDQ2PDYrm : S3SI<0xE6, MRMSrcMem, (outs VR256:$dst), (ins f128mem:$src), - "vcvtdq2pd\t{$src, $dst|$dst, $src}", []>, VEX; + "vcvtdq2pd\t{$src, $dst|$dst, $src}", + [(set VR256:$dst, + (int_x86_avx_cvtdq2_pd_256 (memopv4i32 addr:$src)))]>, VEX; def VCVTDQ2PDYrr : S3SI<0xE6, MRMSrcReg, (outs VR256:$dst), (ins VR128:$src), "vcvtdq2pd\t{$src, $dst|$dst, $src}", [(set VR256:$dst, From nlewycky at google.com Mon Aug 9 13:20:22 2010 From: nlewycky at google.com (Nick Lewycky) Date: Mon, 9 Aug 2010 11:20:22 -0700 Subject: [llvm-commits] [patch] Add -mtriple to LTO In-Reply-To: References: Message-ID: I don't like how this works. I'd much rather expose getter+setter methods in the libLTO API and let the non-library program do its own flags processing, etc. It'd be great if the apple linker folks could also comment on this. @@ -405,12 +404,17 @@ bool LTOCodeGenerator::generateAssemblyCode(formatted_raw_ostream& out, /// Optimize merged modules using various IPO passes void LTOCodeGenerator::setCodeGenDebugOptions(const char* options) { + std::vector codegenOptions; Extra spaces On 9 August 2010 11:05, Rafael Espindola wrote: > The attached patch adds -mtriple to LTO. It also moves setting the > command line options earlier and moves _codegenOptions to the only > method where it is used. > > Is it OK? > > Cheers, > -- > Rafael ?vila de Esp?ndola > -------------- next part -------------- An HTML attachment was scrubbed... URL: http://lists.cs.uiuc.edu/pipermail/llvm-commits/attachments/20100809/6fb0c89d/attachment.html From isanbard at gmail.com Mon Aug 9 13:29:17 2010 From: isanbard at gmail.com (Bill Wendling) Date: Mon, 9 Aug 2010 11:29:17 -0700 Subject: [llvm-commits] [llvm] r110423 - in /llvm/trunk: include/llvm/CodeGen/Passes.h include/llvm/Target/TargetInstrInfo.h lib/CodeGen/LLVMTargetMachine.cpp lib/CodeGen/OptimizeCmps.cpp lib/Target/ARM/ARMBaseInstrInfo.cpp lib/Target/ARM/ARMBaseInstrInfo.h In-Reply-To: References: <20100806013249.25D8E2A6C12C@llvm.org> <0A7EB62A-044E-4166-B340-EEDA7CC5A25B@apple.com> Message-ID: <25245164-A0CD-4208-AFC9-5947C7481812@gmail.com> On Aug 6, 2010, at 10:27 PM, Chris Lattner wrote: > On Aug 6, 2010, at 6:10 PM, Evan Cheng wrote: > >> On Aug 6, 2010, at 2:24 PM, Chris Lattner wrote: >> >>> On Aug 5, 2010, at 6:32 PM, Bill Wendling wrote: >>> >>>> Author: void >>>> Date: Thu Aug 5 20:32:48 2010 >>>> New Revision: 110423 >>>> >>>> URL: http://llvm.org/viewvc/llvm-project?rev=110423&view=rev >>>> Log: >>>> Add the Optimize Compares pass (disabled by default). >>> >>> Why do we need an entire new pass to do this? Isn't this just a form of CSE? Why doesn't it go in the MachineCSE pass? >> >> I didn't think of it. That's an interesting idea. > > Ultimately it is never clear of course, but it is really nice to have fewer relatively-coarse grained passes than tons of fine grained ones. > I've been thinking about this. I don't think that this pass should be merged into the CSE pass. It's not really CSE. I *do* agree that this pass (and others, like OptimizeExts and others, should be combined into a single peephole pass. -bw From evan.cheng at apple.com Mon Aug 9 13:35:19 2010 From: evan.cheng at apple.com (Evan Cheng) Date: Mon, 09 Aug 2010 18:35:19 -0000 Subject: [llvm-commits] [llvm] r110584 - in /llvm/trunk/lib/Target/ARM: ARM.td ARMConstantIslandPass.cpp ARMSubtarget.h ARMTargetMachine.cpp Message-ID: <20100809183519.A234F2A6C12C@llvm.org> Author: evancheng Date: Mon Aug 9 13:35:19 2010 New Revision: 110584 URL: http://llvm.org/viewvc/llvm-project?rev=110584&view=rev Log: Change -prefer-32bit-thumb to attribute -mattr=+32bit instead to disable more 32-bit to 16-bit optimizations. Modified: llvm/trunk/lib/Target/ARM/ARM.td llvm/trunk/lib/Target/ARM/ARMConstantIslandPass.cpp llvm/trunk/lib/Target/ARM/ARMSubtarget.h llvm/trunk/lib/Target/ARM/ARMTargetMachine.cpp Modified: llvm/trunk/lib/Target/ARM/ARM.td URL: http://llvm.org/viewvc/llvm-project/llvm/trunk/lib/Target/ARM/ARM.td?rev=110584&r1=110583&r2=110584&view=diff ============================================================================== --- llvm/trunk/lib/Target/ARM/ARM.td (original) +++ llvm/trunk/lib/Target/ARM/ARM.td Mon Aug 9 13:35:19 2010 @@ -65,6 +65,9 @@ "true", "Use NEON for single precision FP">; +// Disable 32-bit to 16-bit narrowing for experimentation. +def FeaturePref32BitThumb : SubtargetFeature<"32bit", "Pref32BitThumb", "true", + "Prefer 32-bit Thumb instrs">; //===----------------------------------------------------------------------===// // ARM Processors supported. Modified: llvm/trunk/lib/Target/ARM/ARMConstantIslandPass.cpp URL: http://llvm.org/viewvc/llvm-project/llvm/trunk/lib/Target/ARM/ARMConstantIslandPass.cpp?rev=110584&r1=110583&r2=110584&view=diff ============================================================================== --- llvm/trunk/lib/Target/ARM/ARMConstantIslandPass.cpp (original) +++ llvm/trunk/lib/Target/ARM/ARMConstantIslandPass.cpp Mon Aug 9 13:35:19 2010 @@ -357,7 +357,7 @@ } // Shrink 32-bit Thumb2 branch, load, and store instructions. - if (isThumb2) + if (isThumb2 && !STI->prefers32BitThumb()) MadeChange |= OptimizeThumb2Instructions(MF); // After a while, this might be made debug-only, but it is not expensive. Modified: llvm/trunk/lib/Target/ARM/ARMSubtarget.h URL: http://llvm.org/viewvc/llvm-project/llvm/trunk/lib/Target/ARM/ARMSubtarget.h?rev=110584&r1=110583&r2=110584&view=diff ============================================================================== --- llvm/trunk/lib/Target/ARM/ARMSubtarget.h (original) +++ llvm/trunk/lib/Target/ARM/ARMSubtarget.h Mon Aug 9 13:35:19 2010 @@ -84,6 +84,10 @@ /// instructions. bool HasT2ExtractPack; + /// Pref32BitThumb - If true, codegen would prefer 32-bit Thumb instructions + /// over 16-bit ones. + bool Pref32BitThumb; + /// stackAlignment - The minimum alignment known to hold of the stack frame on /// entry to the function and which must be maintained by every function. unsigned stackAlignment; @@ -137,6 +141,7 @@ bool hasT2ExtractPack() const { return HasT2ExtractPack; } bool useVMLx() const {return hasVFP2() && !SlowVMLx; } bool isFPBrccSlow() const { return SlowFPBrcc; } + bool prefers32BitThumb() const { return Pref32BitThumb; } bool hasFP16() const { return HasFP16; } Modified: llvm/trunk/lib/Target/ARM/ARMTargetMachine.cpp URL: http://llvm.org/viewvc/llvm-project/llvm/trunk/lib/Target/ARM/ARMTargetMachine.cpp?rev=110584&r1=110583&r2=110584&view=diff ============================================================================== --- llvm/trunk/lib/Target/ARM/ARMTargetMachine.cpp (original) +++ llvm/trunk/lib/Target/ARM/ARMTargetMachine.cpp Mon Aug 9 13:35:19 2010 @@ -16,17 +16,11 @@ #include "ARM.h" #include "llvm/PassManager.h" #include "llvm/CodeGen/Passes.h" -#include "llvm/Support/CommandLine.h" #include "llvm/Support/FormattedStream.h" #include "llvm/Target/TargetOptions.h" #include "llvm/Target/TargetRegistry.h" using namespace llvm; -static cl::opt -Prefer32BitThumbInstrs("prefer-32bit-thumb", - cl::desc("Prefer 32-bit Thumb instructions"), - cl::init(false)); - static MCAsmInfo *createMCAsmInfo(const Target &T, StringRef TT) { Triple TheTriple(TT); switch (TheTriple.getOS()) { @@ -143,7 +137,7 @@ bool ARMBaseTargetMachine::addPreEmitPass(PassManagerBase &PM, CodeGenOpt::Level OptLevel) { - if (!Prefer32BitThumbInstrs && Subtarget.isThumb2()) + if (Subtarget.isThumb2() && !Subtarget.prefers32BitThumb()) PM.add(createThumb2SizeReductionPass()); PM.add(createARMConstantIslandPass()); From dpatel at apple.com Mon Aug 9 13:48:24 2010 From: dpatel at apple.com (Devang Patel) Date: Mon, 9 Aug 2010 11:48:24 -0700 Subject: [llvm-commits] [patch] Add -mtriple to LTO In-Reply-To: References: Message-ID: On Aug 9, 2010, at 11:20 AM, Nick Lewycky wrote: > I don't like how this works. I'd much rather expose getter+setter methods in the libLTO API and let the non-library program do its own flags processing, etc. I am not very enthusiastic to have getter+setter method for each flag. That said, getting rid of static is a good idea. BTW, libLTO user has access to llvm::Module so it can set/reset target triple. And libLTO checks module triple. As I understand, Rafael is looking for an override to aid debugging, not a end user knob. - Devang From dpatel at apple.com Mon Aug 9 13:51:29 2010 From: dpatel at apple.com (Devang Patel) Date: Mon, 09 Aug 2010 18:51:29 -0000 Subject: [llvm-commits] [llvm] r110586 - /llvm/trunk/lib/CodeGen/AsmPrinter/DwarfDebug.cpp Message-ID: <20100809185129.B228D2A6C12C@llvm.org> Author: dpatel Date: Mon Aug 9 13:51:29 2010 New Revision: 110586 URL: http://llvm.org/viewvc/llvm-project?rev=110586&view=rev Log: Rename a method. Modified: llvm/trunk/lib/CodeGen/AsmPrinter/DwarfDebug.cpp Modified: llvm/trunk/lib/CodeGen/AsmPrinter/DwarfDebug.cpp URL: http://llvm.org/viewvc/llvm-project/llvm/trunk/lib/CodeGen/AsmPrinter/DwarfDebug.cpp?rev=110586&r1=110585&r2=110586&view=diff ============================================================================== --- llvm/trunk/lib/CodeGen/AsmPrinter/DwarfDebug.cpp (original) +++ llvm/trunk/lib/CodeGen/AsmPrinter/DwarfDebug.cpp Mon Aug 9 13:51:29 2010 @@ -221,7 +221,7 @@ const MDNode *getInlinedAt() const { return InlinedAtLocation; } const MDNode *getScopeNode() const { return Desc; } const SmallVector &getScopes() { return Scopes; } - const SmallVector &getVariables() { return Variables; } + const SmallVector &getDbgVariables() { return Variables; } const SmallVector &getRanges() { return Ranges; } /// openInsnRange - This scope covers instruction range starting from MI. @@ -1725,7 +1725,7 @@ if (!ScopeDIE) return NULL; // Add variables to scope. - const SmallVector &Variables = Scope->getVariables(); + const SmallVector &Variables = Scope->getDbgVariables(); for (unsigned i = 0, N = Variables.size(); i < N; ++i) { DIE *VariableDIE = constructVariableDIE(Variables[i], Scope); if (VariableDIE) @@ -2060,7 +2060,7 @@ // Construct subprogram DIE and add variables DIEs. constructSubprogramDIE(SP); DIE *ScopeDIE = getCompileUnit(SP)->getDIE(SP); - const SmallVector &Variables = Scope->getVariables(); + const SmallVector &Variables = Scope->getDbgVariables(); for (unsigned i = 0, N = Variables.size(); i < N; ++i) { DIE *VariableDIE = constructVariableDIE(Variables[i], Scope); if (VariableDIE) From nlewycky at google.com Mon Aug 9 13:52:38 2010 From: nlewycky at google.com (Nick Lewycky) Date: Mon, 9 Aug 2010 11:52:38 -0700 Subject: [llvm-commits] [patch] Add -mtriple to LTO In-Reply-To: References: Message-ID: On 9 August 2010 11:48, Devang Patel wrote: > > On Aug 9, 2010, at 11:20 AM, Nick Lewycky wrote: > > > I don't like how this works. I'd much rather expose getter+setter methods > in the libLTO API and let the non-library program do its own flags > processing, etc. > > I am not very enthusiastic to have getter+setter method for each flag. That > said, getting rid of static is a good idea. > > BTW, libLTO user has access to llvm::Module so it can set/reset target > triple. And libLTO checks module triple. As I understand, Rafael is looking > for an override to aid debugging, not a end user knob. > Oh, if it's for debugging, then sure, making it a flag in setCodeGenDebugOptions is fine. I was imagining it would be a real end-user control intended to change the triple specified in the Module. > > - > Devang > > > -------------- next part -------------- An HTML attachment was scrubbed... URL: http://lists.cs.uiuc.edu/pipermail/llvm-commits/attachments/20100809/c85e2eb2/attachment.html From evan.cheng at apple.com Mon Aug 9 14:19:36 2010 From: evan.cheng at apple.com (Evan Cheng) Date: Mon, 09 Aug 2010 19:19:36 -0000 Subject: [llvm-commits] [llvm] r110587 - /llvm/trunk/lib/Target/ARM/ARMSubtarget.cpp Message-ID: <20100809191936.BFBCC2A6C12C@llvm.org> Author: evancheng Date: Mon Aug 9 14:19:36 2010 New Revision: 110587 URL: http://llvm.org/viewvc/llvm-project?rev=110587&view=rev Log: Explicitly initialize SlowFPBrcc and Pref32BitThumb to false. Modified: llvm/trunk/lib/Target/ARM/ARMSubtarget.cpp Modified: llvm/trunk/lib/Target/ARM/ARMSubtarget.cpp URL: http://llvm.org/viewvc/llvm-project/llvm/trunk/lib/Target/ARM/ARMSubtarget.cpp?rev=110587&r1=110586&r2=110587&view=diff ============================================================================== --- llvm/trunk/lib/Target/ARM/ARMSubtarget.cpp (original) +++ llvm/trunk/lib/Target/ARM/ARMSubtarget.cpp Mon Aug 9 14:19:36 2010 @@ -33,6 +33,7 @@ , ARMFPUType(None) , UseNEONForSinglePrecisionFP(false) , SlowVMLx(false) + , SlowFPBrcc(false) , IsThumb(isT) , ThumbMode(Thumb1) , PostRAScheduler(false) @@ -41,6 +42,7 @@ , HasFP16(false) , HasHardwareDivide(false) , HasT2ExtractPack(false) + , Pref32BitThumb(false) , stackAlignment(4) , CPUString("generic") , TargetType(isELF) // Default to ELF unless otherwise specified. From espindola at google.com Mon Aug 9 14:29:51 2010 From: espindola at google.com (Rafael Espindola) Date: Mon, 9 Aug 2010 15:29:51 -0400 Subject: [llvm-commits] [patch] Add -mtriple to LTO In-Reply-To: References: Message-ID: > BTW, libLTO user has access to llvm::Module so it can set/reset target triple. And libLTO checks module triple. As I understand, Rafael is looking for an override to aid debugging, not a end user knob. This is intended as a user visible thing. The user being the gold plugin being used in http://nativeclient.googlecode.com/svn/data/site/pnacl.pdf. So, getter/setter, flag or modify the module in the plugin? :-) > - > Devang Cheers, -- Rafael ?vila de Esp?ndola From dpatel at apple.com Mon Aug 9 14:52:31 2010 From: dpatel at apple.com (Devang Patel) Date: Mon, 9 Aug 2010 12:52:31 -0700 Subject: [llvm-commits] [patch] Add -mtriple to LTO In-Reply-To: References: Message-ID: <1AC2D728-2053-4AFA-AA00-59D104FE89F1@apple.com> On Aug 9, 2010, at 12:29 PM, Rafael Espindola wrote: >> BTW, libLTO user has access to llvm::Module so it can set/reset target triple. And libLTO checks module triple. As I understand, Rafael is looking for an override to aid debugging, not a end user knob. > > This is intended as a user visible thing. The user being the gold > plugin being used in > http://nativeclient.googlecode.com/svn/data/site/pnacl.pdf. > > So, getter/setter, flag or modify the module in the plugin? :-) Modifying module in plugin is my first preference. - Devang > >> - >> Devang > > Cheers, > -- > Rafael ?vila de Esp?ndola From espindola at google.com Mon Aug 9 15:00:23 2010 From: espindola at google.com (Rafael Espindola) Date: Mon, 9 Aug 2010 16:00:23 -0400 Subject: [llvm-commits] [patch] Add -mtriple to LTO In-Reply-To: <1AC2D728-2053-4AFA-AA00-59D104FE89F1@apple.com> References: <1AC2D728-2053-4AFA-AA00-59D104FE89F1@apple.com> Message-ID: >> So, getter/setter, flag or modify the module in the plugin? :-) > > Modifying module in plugin is my first preference. OK. Note that there is a lto_module_get_target_triple but not a setter. Can I just add one? > - > Devang Cheers, -- Rafael ?vila de Esp?ndola From criswell at uiuc.edu Mon Aug 9 15:14:34 2010 From: criswell at uiuc.edu (John Criswell) Date: Mon, 09 Aug 2010 20:14:34 -0000 Subject: [llvm-commits] [poolalloc] r110588 - /poolalloc/trunk/lib/AssistDS/Devirt.cpp Message-ID: <20100809201434.B83742A6C12C@llvm.org> Author: criswell Date: Mon Aug 9 15:14:34 2010 New Revision: 110588 URL: http://llvm.org/viewvc/llvm-project?rev=110588&view=rev Log: Fixed some minor problems that caused the devirtualizer to assert out or crash. Rewrote code that adds function arguments to look at the call site instead of at the function pointer type; the function pointer type could be varargs and have no parameters. Modified: poolalloc/trunk/lib/AssistDS/Devirt.cpp Modified: poolalloc/trunk/lib/AssistDS/Devirt.cpp URL: http://llvm.org/viewvc/llvm-project/poolalloc/trunk/lib/AssistDS/Devirt.cpp?rev=110588&r1=110587&r2=110588&view=diff ============================================================================== --- poolalloc/trunk/lib/AssistDS/Devirt.cpp (original) +++ poolalloc/trunk/lib/AssistDS/Devirt.cpp Mon Aug 9 15:14:34 2010 @@ -83,12 +83,15 @@ // will be the function to call. // Value* ptr = CS.getCalledValue(); - const FunctionType* OrigType = - cast(cast(ptr->getType())->getElementType()); - - std::vector TP (OrigType->param_begin(), OrigType->param_end()); + std::vector TP; TP.insert (TP.begin(), ptr->getType()); - const FunctionType* NewTy = FunctionType::get(OrigType->getReturnType(), TP, false); + for (CallSite::arg_iterator i = CS.arg_begin(); + i != CS.arg_end(); + ++i) { + TP.push_back ((*i)->getType()); + } + + const FunctionType* NewTy = FunctionType::get(CS.getType(), TP, false); Module * M = CS.getInstruction()->getParent()->getParent()->getParent(); Function* F = Function::Create (NewTy, GlobalValue::InternalLinkage, @@ -127,7 +130,7 @@ BL); // Add the return instruction for the basic block - if (OrigType->getReturnType()->isVoidTy()) + if (CS.getType()->isVoidTy()) ReturnInst::Create (M->getContext(), BL); else ReturnInst::Create (M->getContext(), directCall, BL); @@ -153,17 +156,24 @@ // // Create basic blocks for valid target functions. // + const Type * Int8Type = IntegerType::getInt8Ty(M->getContext()); + const Type * VoidPtrTy = PointerType::getUnqual(Int8Type); + Value * FArg = CastInst::CreateZExtOrBitCast (F->arg_begin(), + VoidPtrTy, + "", + F->getEntryBlock().getTerminator()); for (unsigned index = 0; index < Targets.size(); ++index) { - const Function * Target = Targets[index]; - BasicBlock* TB = targets[Target]; + BasicBlock* TB = targets[Targets[index]]; BasicBlock* newB = BasicBlock::Create (M->getContext(), - "test." + Target->getName(), + "test." + Targets[index]->getName(), F, &F->getEntryBlock()); + Value * Target = (Value *) Targets[index]; + Target = castTo (Target, VoidPtrTy, "", F->getEntryBlock().getTerminator()); CmpInst * setcc = CmpInst::Create (Instruction::ICmp, CmpInst::ICMP_EQ, - (Value *) Target, - &(*(F->arg_begin())), + Target, + FArg, "sc", newB); BranchInst::Create (TB, tail, setcc, newB); @@ -209,21 +219,23 @@ // if (CallInst* CI = dyn_cast(CS.getInstruction())) { std::vector Params (CI->op_begin(), CI->op_end()); + std::string name = CI->hasName() ? CI->getNameStr() + ".dv" : ""; CallInst* CN = CallInst::Create (NF, Params.begin(), Params.end(), - CI->getName() + ".dv", + name, CI); CI->replaceAllUsesWith(CN); CI->eraseFromParent(); } else if (InvokeInst* CI = dyn_cast(CS.getInstruction())) { std::vector Params (CI->op_begin(), CI->op_end()); + std::string name = CI->hasName() ? CI->getNameStr() + ".dv" : ""; InvokeInst* CN = InvokeInst::Create(NF, CI->getNormalDest(), CI->getUnwindDest(), Params.begin(), Params.end(), - CI->getName()+".dv", + name, CI); CI->replaceAllUsesWith(CN); CI->eraseFromParent(); From dpatel at apple.com Mon Aug 9 15:18:31 2010 From: dpatel at apple.com (Devang Patel) Date: Mon, 9 Aug 2010 13:18:31 -0700 Subject: [llvm-commits] [patch] Add -mtriple to LTO In-Reply-To: References: <1AC2D728-2053-4AFA-AA00-59D104FE89F1@apple.com> Message-ID: <6FF657A7-9BB4-40AD-963B-C76F5E4C5AC2@apple.com> On Aug 9, 2010, at 1:00 PM, Rafael Espindola wrote: >>> So, getter/setter, flag or modify the module in the plugin? :-) >> >> Modifying module in plugin is my first preference. > > OK. Note that there is a lto_module_get_target_triple but not a > setter. Can I just add one? sure > >> - >> Devang > > Cheers, > -- > Rafael ?vila de Esp?ndola From stoklund at 2pi.dk Mon Aug 9 15:19:16 2010 From: stoklund at 2pi.dk (Jakob Stoklund Olesen) Date: Mon, 09 Aug 2010 20:19:16 -0000 Subject: [llvm-commits] [llvm] r110589 - /llvm/trunk/lib/CodeGen/TwoAddressInstructionPass.cpp Message-ID: <20100809201916.E445D2A6C12C@llvm.org> Author: stoklund Date: Mon Aug 9 15:19:16 2010 New Revision: 110589 URL: http://llvm.org/viewvc/llvm-project?rev=110589&view=rev Log: A REG_SEQUENCE instruction may use the same register twice. If we are emitting COPY instructions for the REG_SEQUENCE, make sure the kill flag goes on the last COPY. Otherwise we may be using a killed register. Modified: llvm/trunk/lib/CodeGen/TwoAddressInstructionPass.cpp Modified: llvm/trunk/lib/CodeGen/TwoAddressInstructionPass.cpp URL: http://llvm.org/viewvc/llvm-project/llvm/trunk/lib/CodeGen/TwoAddressInstructionPass.cpp?rev=110589&r1=110588&r2=110589&view=diff ============================================================================== --- llvm/trunk/lib/CodeGen/TwoAddressInstructionPass.cpp (original) +++ llvm/trunk/lib/CodeGen/TwoAddressInstructionPass.cpp Mon Aug 9 15:19:16 2010 @@ -1446,7 +1446,17 @@ // // If the REG_SEQUENCE doesn't kill its source, keeping live variables // correctly up to date becomes very difficult. Insert a copy. - // + + // Defer any kill flag to the last operand using SrcReg. Otherwise, we + // might insert a COPY that uses SrcReg after is was killed. + if (isKill) + for (unsigned j = i + 2; j < e; j += 2) + if (MI->getOperand(j).getReg() == SrcReg) { + MI->getOperand(j).setIsKill(); + isKill = false; + break; + } + MachineBasicBlock::iterator InsertLoc = MI; MachineInstr *CopyMI = BuildMI(*MI->getParent(), InsertLoc, MI->getDebugLoc(), TII->get(TargetOpcode::COPY)) From dpatel at apple.com Mon Aug 9 15:20:05 2010 From: dpatel at apple.com (Devang Patel) Date: Mon, 09 Aug 2010 20:20:05 -0000 Subject: [llvm-commits] [llvm] r110590 - in /llvm/trunk/lib/CodeGen/AsmPrinter: DwarfDebug.cpp DwarfDebug.h Message-ID: <20100809202005.9F55C2A6C12C@llvm.org> Author: dpatel Date: Mon Aug 9 15:20:05 2010 New Revision: 110590 URL: http://llvm.org/viewvc/llvm-project?rev=110590&view=rev Log: It is ok, and convenient, to pass descriptors by value. Modified: llvm/trunk/lib/CodeGen/AsmPrinter/DwarfDebug.cpp llvm/trunk/lib/CodeGen/AsmPrinter/DwarfDebug.h Modified: llvm/trunk/lib/CodeGen/AsmPrinter/DwarfDebug.cpp URL: http://llvm.org/viewvc/llvm-project/llvm/trunk/lib/CodeGen/AsmPrinter/DwarfDebug.cpp?rev=110590&r1=110589&r2=110590&view=diff ============================================================================== --- llvm/trunk/lib/CodeGen/AsmPrinter/DwarfDebug.cpp (original) +++ llvm/trunk/lib/CodeGen/AsmPrinter/DwarfDebug.cpp Mon Aug 9 15:20:05 2010 @@ -435,14 +435,14 @@ /// addSourceLine - Add location information to specified debug information /// entry. -void DwarfDebug::addSourceLine(DIE *Die, const DIVariable *V) { +void DwarfDebug::addSourceLine(DIE *Die, const DIVariable V) { // Verify variable. - if (!V->Verify()) + if (!V.Verify()) return; - unsigned Line = V->getLineNumber(); - unsigned FileID = GetOrCreateSourceID(V->getContext().getDirectory(), - V->getContext().getFilename()); + unsigned Line = V.getLineNumber(); + unsigned FileID = GetOrCreateSourceID(V.getContext().getDirectory(), + V.getContext().getFilename()); assert(FileID && "Invalid file id"); addUInt(Die, dwarf::DW_AT_decl_file, 0, FileID); addUInt(Die, dwarf::DW_AT_decl_line, 0, Line); @@ -450,14 +450,14 @@ /// addSourceLine - Add location information to specified debug information /// entry. -void DwarfDebug::addSourceLine(DIE *Die, const DIGlobalVariable *G) { +void DwarfDebug::addSourceLine(DIE *Die, const DIGlobalVariable G) { // Verify global variable. - if (!G->Verify()) + if (!G.Verify()) return; - unsigned Line = G->getLineNumber(); - unsigned FileID = GetOrCreateSourceID(G->getContext().getDirectory(), - G->getContext().getFilename()); + unsigned Line = G.getLineNumber(); + unsigned FileID = GetOrCreateSourceID(G.getContext().getDirectory(), + G.getContext().getFilename()); assert(FileID && "Invalid file id"); addUInt(Die, dwarf::DW_AT_decl_file, 0, FileID); addUInt(Die, dwarf::DW_AT_decl_line, 0, Line); @@ -465,19 +465,19 @@ /// addSourceLine - Add location information to specified debug information /// entry. -void DwarfDebug::addSourceLine(DIE *Die, const DISubprogram *SP) { +void DwarfDebug::addSourceLine(DIE *Die, const DISubprogram SP) { // Verify subprogram. - if (!SP->Verify()) + if (!SP.Verify()) return; // If the line number is 0, don't add it. - if (SP->getLineNumber() == 0) + if (SP.getLineNumber() == 0) return; - unsigned Line = SP->getLineNumber(); - if (!SP->getContext().Verify()) + unsigned Line = SP.getLineNumber(); + if (!SP.getContext().Verify()) return; - unsigned FileID = GetOrCreateSourceID(SP->getDirectory(), - SP->getFilename()); + unsigned FileID = GetOrCreateSourceID(SP.getDirectory(), + SP.getFilename()); assert(FileID && "Invalid file id"); addUInt(Die, dwarf::DW_AT_decl_file, 0, FileID); addUInt(Die, dwarf::DW_AT_decl_line, 0, Line); @@ -485,16 +485,16 @@ /// addSourceLine - Add location information to specified debug information /// entry. -void DwarfDebug::addSourceLine(DIE *Die, const DIType *Ty) { +void DwarfDebug::addSourceLine(DIE *Die, const DIType Ty) { // Verify type. - if (!Ty->Verify()) + if (!Ty.Verify()) return; - unsigned Line = Ty->getLineNumber(); - if (!Ty->getContext().Verify()) + unsigned Line = Ty.getLineNumber(); + if (!Ty.getContext().Verify()) return; - unsigned FileID = GetOrCreateSourceID(Ty->getContext().getDirectory(), - Ty->getContext().getFilename()); + unsigned FileID = GetOrCreateSourceID(Ty.getContext().getDirectory(), + Ty.getContext().getFilename()); assert(FileID && "Invalid file id"); addUInt(Die, dwarf::DW_AT_decl_file, 0, FileID); addUInt(Die, dwarf::DW_AT_decl_line, 0, Line); @@ -502,14 +502,14 @@ /// addSourceLine - Add location information to specified debug information /// entry. -void DwarfDebug::addSourceLine(DIE *Die, const DINameSpace *NS) { +void DwarfDebug::addSourceLine(DIE *Die, const DINameSpace NS) { // Verify namespace. - if (!NS->Verify()) + if (!NS.Verify()) return; - unsigned Line = NS->getLineNumber(); - StringRef FN = NS->getFilename(); - StringRef Dir = NS->getDirectory(); + unsigned Line = NS.getLineNumber(); + StringRef FN = NS.getFilename(); + StringRef Dir = NS.getDirectory(); unsigned FileID = GetOrCreateSourceID(Dir, FN); assert(FileID && "Invalid file id"); @@ -966,7 +966,7 @@ // Add source line info if available and TyDesc is not a forward declaration. if (!DTy.isForwardDecl()) - addSourceLine(&Buffer, &DTy); + addSourceLine(&Buffer, DTy); } /// constructTypeDIE - Construct type DIE from DICompositeType. @@ -1040,7 +1040,7 @@ addType(ElemDie, DV.getType()); addUInt(ElemDie, dwarf::DW_AT_declaration, dwarf::DW_FORM_flag, 1); addUInt(ElemDie, dwarf::DW_AT_external, dwarf::DW_FORM_flag, 1); - addSourceLine(ElemDie, &DV); + addSourceLine(ElemDie, DV); } else if (Element.isDerivedType()) ElemDie = createMemberDIE(DIDerivedType(Element)); else @@ -1090,7 +1090,7 @@ // Add source line info if available. if (!CTy.isForwardDecl()) - addSourceLine(&Buffer, &CTy); + addSourceLine(&Buffer, CTy); } } @@ -1179,7 +1179,7 @@ addType(GVDie, GV.getType()); if (!GV.isLocalToUnit()) addUInt(GVDie, dwarf::DW_AT_external, dwarf::DW_FORM_flag, 1); - addSourceLine(GVDie, &GV); + addSourceLine(GVDie, GV); return GVDie; } @@ -1193,7 +1193,7 @@ addType(MemberDie, DT.getTypeDerivedFrom()); - addSourceLine(MemberDie, &DT); + addSourceLine(MemberDie, DT); DIEBlock *MemLocationDie = new (DIEValueAllocator) DIEBlock(); addUInt(MemLocationDie, 0, dwarf::DW_FORM_data1, dwarf::DW_OP_plus_uconst); @@ -1278,7 +1278,7 @@ addString(SPDie, dwarf::DW_AT_MIPS_linkage_name, dwarf::DW_FORM_string, getRealLinkageName(LinkageName)); - addSourceLine(SPDie, &SP); + addSourceLine(SPDie, SP); // Add prototyped tag, if C or ObjC. unsigned Lang = SP.getCompileUnit().getLanguage(); @@ -1591,7 +1591,7 @@ dwarf::DW_FORM_ref4, AbsDIE); else { addString(VariableDie, dwarf::DW_AT_name, dwarf::DW_FORM_string, Name); - addSourceLine(VariableDie, &VD); + addSourceLine(VariableDie, VD); // Add variable type. // FIXME: isBlockByrefVariable should be reformulated in terms of complex @@ -1796,7 +1796,7 @@ TheCU->insertDIE(NS, NDie); if (!NS.getName().empty()) addString(NDie, dwarf::DW_AT_name, dwarf::DW_FORM_string, NS.getName()); - addSourceLine(NDie, &NS); + addSourceLine(NDie, NS); addToContextOwner(NDie, NS.getContext()); return NDie; } Modified: llvm/trunk/lib/CodeGen/AsmPrinter/DwarfDebug.h URL: http://llvm.org/viewvc/llvm-project/llvm/trunk/lib/CodeGen/AsmPrinter/DwarfDebug.h?rev=110590&r1=110589&r2=110590&view=diff ============================================================================== --- llvm/trunk/lib/CodeGen/AsmPrinter/DwarfDebug.h (original) +++ llvm/trunk/lib/CodeGen/AsmPrinter/DwarfDebug.h Mon Aug 9 15:20:05 2010 @@ -338,11 +338,11 @@ /// addSourceLine - Add location information to specified debug information /// entry. - void addSourceLine(DIE *Die, const DIVariable *V); - void addSourceLine(DIE *Die, const DIGlobalVariable *G); - void addSourceLine(DIE *Die, const DISubprogram *SP); - void addSourceLine(DIE *Die, const DIType *Ty); - void addSourceLine(DIE *Die, const DINameSpace *NS); + void addSourceLine(DIE *Die, const DIVariable V); + void addSourceLine(DIE *Die, const DIGlobalVariable G); + void addSourceLine(DIE *Die, const DISubprogram SP); + void addSourceLine(DIE *Die, const DIType Ty); + void addSourceLine(DIE *Die, const DINameSpace NS); /// addAddress - Add an address attribute to a die based on the location /// provided. From ofv at wanadoo.es Mon Aug 9 15:33:09 2010 From: ofv at wanadoo.es (Oscar Fuentes) Date: Mon, 09 Aug 2010 20:33:09 -0000 Subject: [llvm-commits] [llvm] r110593 - /llvm/trunk/lib/Target/X86/CMakeLists.txt Message-ID: <20100809203309.278242A6C12C@llvm.org> Author: ofv Date: Mon Aug 9 15:33:08 2010 New Revision: 110593 URL: http://llvm.org/viewvc/llvm-project?rev=110593&view=rev Log: CMake: eliminated unnecessary target_link_libraries. Next time the build is broken due to wrong library dependencies, just try building again (if you are on some Unix and are building all LLVM targets) or ask someone to commit the regenerated LLVMLibDeps.cmake. Modified: llvm/trunk/lib/Target/X86/CMakeLists.txt Modified: llvm/trunk/lib/Target/X86/CMakeLists.txt URL: http://llvm.org/viewvc/llvm-project/llvm/trunk/lib/Target/X86/CMakeLists.txt?rev=110593&r1=110592&r2=110593&view=diff ============================================================================== --- llvm/trunk/lib/Target/X86/CMakeLists.txt (original) +++ llvm/trunk/lib/Target/X86/CMakeLists.txt Mon Aug 9 15:33:08 2010 @@ -50,4 +50,3 @@ add_llvm_target(X86CodeGen ${sources}) -target_link_libraries (LLVMX86CodeGen LLVMX86AsmPrinter LLVMSelectionDAG) From ofv at wanadoo.es Mon Aug 9 15:33:21 2010 From: ofv at wanadoo.es (Oscar Fuentes) Date: Mon, 09 Aug 2010 20:33:21 -0000 Subject: [llvm-commits] [llvm] r110594 - /llvm/trunk/cmake/modules/LLVMLibDeps.cmake Message-ID: <20100809203321.117D62A6C12D@llvm.org> Author: ofv Date: Mon Aug 9 15:33:20 2010 New Revision: 110594 URL: http://llvm.org/viewvc/llvm-project?rev=110594&view=rev Log: Update cmake library dependencies. Modified: llvm/trunk/cmake/modules/LLVMLibDeps.cmake Modified: llvm/trunk/cmake/modules/LLVMLibDeps.cmake URL: http://llvm.org/viewvc/llvm-project/llvm/trunk/cmake/modules/LLVMLibDeps.cmake?rev=110594&r1=110593&r2=110594&view=diff ============================================================================== --- llvm/trunk/cmake/modules/LLVMLibDeps.cmake (original) +++ llvm/trunk/cmake/modules/LLVMLibDeps.cmake Mon Aug 9 15:33:20 2010 @@ -1,8 +1,8 @@ -set(MSVC_LIB_DEPS_LLVMARMAsmParser LLVMARMCodeGen LLVMARMInfo LLVMMCParser LLVMSupport LLVMTarget) +set(MSVC_LIB_DEPS_LLVMARMAsmParser LLVMARMInfo LLVMMCParser LLVMSupport LLVMTarget) set(MSVC_LIB_DEPS_LLVMARMAsmPrinter LLVMMC LLVMSupport) set(MSVC_LIB_DEPS_LLVMARMCodeGen LLVMARMInfo LLVMAnalysis LLVMAsmPrinter LLVMCodeGen LLVMCore LLVMMC LLVMSelectionDAG LLVMSupport LLVMSystem LLVMTarget) set(MSVC_LIB_DEPS_LLVMARMInfo LLVMSupport) -set(MSVC_LIB_DEPS_LLVMAlphaAsmPrinter LLVMAlphaCodeGen LLVMAlphaInfo LLVMAsmPrinter LLVMCodeGen LLVMCore LLVMMC LLVMSupport LLVMTarget) +set(MSVC_LIB_DEPS_LLVMAlphaAsmPrinter LLVMAlphaInfo LLVMAsmPrinter LLVMCodeGen LLVMCore LLVMMC LLVMSupport LLVMTarget) set(MSVC_LIB_DEPS_LLVMAlphaCodeGen LLVMAlphaInfo LLVMCodeGen LLVMCore LLVMMC LLVMSelectionDAG LLVMSupport LLVMSystem LLVMTarget) set(MSVC_LIB_DEPS_LLVMAlphaInfo LLVMSupport) set(MSVC_LIB_DEPS_LLVMAnalysis LLVMCore LLVMSupport LLVMSystem LLVMTarget) @@ -11,12 +11,12 @@ set(MSVC_LIB_DEPS_LLVMAsmPrinter LLVMAnalysis LLVMCodeGen LLVMCore LLVMMC LLVMMCParser LLVMSupport LLVMSystem LLVMTarget) set(MSVC_LIB_DEPS_LLVMBitReader LLVMCore LLVMSupport) set(MSVC_LIB_DEPS_LLVMBitWriter LLVMCore LLVMSupport) -set(MSVC_LIB_DEPS_LLVMBlackfinAsmPrinter LLVMAsmPrinter LLVMBlackfinCodeGen LLVMBlackfinInfo LLVMCodeGen LLVMCore LLVMMC LLVMSupport LLVMTarget) +set(MSVC_LIB_DEPS_LLVMBlackfinAsmPrinter LLVMAsmPrinter LLVMBlackfinInfo LLVMCodeGen LLVMCore LLVMMC LLVMSupport LLVMTarget) set(MSVC_LIB_DEPS_LLVMBlackfinCodeGen LLVMBlackfinInfo LLVMCodeGen LLVMCore LLVMMC LLVMSelectionDAG LLVMSupport LLVMTarget) set(MSVC_LIB_DEPS_LLVMBlackfinInfo LLVMSupport) set(MSVC_LIB_DEPS_LLVMCBackend LLVMAnalysis LLVMCBackendInfo LLVMCodeGen LLVMCore LLVMMC LLVMScalarOpts LLVMSupport LLVMSystem LLVMTarget LLVMTransformUtils LLVMipa) set(MSVC_LIB_DEPS_LLVMCBackendInfo LLVMSupport) -set(MSVC_LIB_DEPS_LLVMCellSPUAsmPrinter LLVMAsmPrinter LLVMCellSPUCodeGen LLVMCellSPUInfo LLVMCodeGen LLVMCore LLVMMC LLVMSupport LLVMTarget) +set(MSVC_LIB_DEPS_LLVMCellSPUAsmPrinter LLVMAsmPrinter LLVMCellSPUInfo LLVMCodeGen LLVMCore LLVMMC LLVMSupport LLVMTarget) set(MSVC_LIB_DEPS_LLVMCellSPUCodeGen LLVMCellSPUInfo LLVMCodeGen LLVMCore LLVMMC LLVMSelectionDAG LLVMSupport LLVMTarget) set(MSVC_LIB_DEPS_LLVMCellSPUInfo LLVMSupport) set(MSVC_LIB_DEPS_LLVMCodeGen LLVMAnalysis LLVMCore LLVMMC LLVMScalarOpts LLVMSupport LLVMSystem LLVMTarget LLVMTransformUtils) @@ -37,26 +37,27 @@ set(MSVC_LIB_DEPS_LLVMMCParser LLVMMC LLVMSupport) set(MSVC_LIB_DEPS_LLVMMSIL LLVMAnalysis LLVMCodeGen LLVMCore LLVMMSILInfo LLVMScalarOpts LLVMSupport LLVMTarget LLVMTransformUtils LLVMipa) set(MSVC_LIB_DEPS_LLVMMSILInfo LLVMSupport) -set(MSVC_LIB_DEPS_LLVMMSP430AsmPrinter LLVMAsmPrinter LLVMCodeGen LLVMCore LLVMMC LLVMMSP430CodeGen LLVMMSP430Info LLVMSupport LLVMTarget) +set(MSVC_LIB_DEPS_LLVMMSP430AsmPrinter LLVMAsmPrinter LLVMCodeGen LLVMCore LLVMMC LLVMMSP430Info LLVMSupport LLVMTarget) set(MSVC_LIB_DEPS_LLVMMSP430CodeGen LLVMCodeGen LLVMCore LLVMMC LLVMMSP430Info LLVMSelectionDAG LLVMSupport LLVMSystem LLVMTarget) set(MSVC_LIB_DEPS_LLVMMSP430Info LLVMSupport) set(MSVC_LIB_DEPS_LLVMMipsAsmPrinter LLVMAsmPrinter LLVMCodeGen LLVMCore LLVMMC LLVMMipsCodeGen LLVMMipsInfo LLVMSupport LLVMTarget) set(MSVC_LIB_DEPS_LLVMMipsCodeGen LLVMCodeGen LLVMCore LLVMMC LLVMMipsInfo LLVMSelectionDAG LLVMSupport LLVMSystem LLVMTarget) set(MSVC_LIB_DEPS_LLVMMipsInfo LLVMSupport) +set(MSVC_LIB_DEPS_LLVMPIC16 LLVMAnalysis LLVMCodeGen LLVMCore LLVMMC LLVMPIC16CodeGen LLVMPIC16Info LLVMSelectionDAG LLVMSupport LLVMTarget) set(MSVC_LIB_DEPS_LLVMPIC16AsmPrinter LLVMAsmPrinter LLVMCodeGen LLVMCore LLVMMC LLVMPIC16CodeGen LLVMPIC16Info LLVMSupport LLVMTarget) set(MSVC_LIB_DEPS_LLVMPIC16CodeGen LLVMAnalysis LLVMCodeGen LLVMCore LLVMMC LLVMPIC16Info LLVMSelectionDAG LLVMSupport LLVMTarget) set(MSVC_LIB_DEPS_LLVMPIC16Info LLVMSupport) -set(MSVC_LIB_DEPS_LLVMPowerPCAsmPrinter LLVMAnalysis LLVMAsmPrinter LLVMCodeGen LLVMCore LLVMMC LLVMPowerPCCodeGen LLVMPowerPCInfo LLVMSupport LLVMTarget) +set(MSVC_LIB_DEPS_LLVMPowerPCAsmPrinter LLVMAnalysis LLVMAsmPrinter LLVMCodeGen LLVMCore LLVMMC LLVMPowerPCInfo LLVMSupport LLVMTarget) set(MSVC_LIB_DEPS_LLVMPowerPCCodeGen LLVMCodeGen LLVMCore LLVMMC LLVMPowerPCInfo LLVMSelectionDAG LLVMSupport LLVMSystem LLVMTarget) set(MSVC_LIB_DEPS_LLVMPowerPCInfo LLVMSupport) set(MSVC_LIB_DEPS_LLVMScalarOpts LLVMAnalysis LLVMCore LLVMInstCombine LLVMSupport LLVMSystem LLVMTarget LLVMTransformUtils) set(MSVC_LIB_DEPS_LLVMSelectionDAG LLVMAnalysis LLVMCodeGen LLVMCore LLVMMC LLVMSupport LLVMSystem LLVMTarget) -set(MSVC_LIB_DEPS_LLVMSparcAsmPrinter LLVMAsmPrinter LLVMCodeGen LLVMCore LLVMMC LLVMSparcCodeGen LLVMSparcInfo LLVMSupport LLVMTarget) +set(MSVC_LIB_DEPS_LLVMSparcAsmPrinter LLVMAsmPrinter LLVMCodeGen LLVMCore LLVMMC LLVMSparcInfo LLVMSupport LLVMTarget) set(MSVC_LIB_DEPS_LLVMSparcCodeGen LLVMCodeGen LLVMCore LLVMMC LLVMSelectionDAG LLVMSparcInfo LLVMSupport LLVMSystem LLVMTarget) set(MSVC_LIB_DEPS_LLVMSparcInfo LLVMSupport) set(MSVC_LIB_DEPS_LLVMSupport LLVMSystem) set(MSVC_LIB_DEPS_LLVMSystem ) -set(MSVC_LIB_DEPS_LLVMSystemZAsmPrinter LLVMAsmPrinter LLVMCodeGen LLVMCore LLVMMC LLVMSupport LLVMSystemZCodeGen LLVMSystemZInfo LLVMTarget) +set(MSVC_LIB_DEPS_LLVMSystemZAsmPrinter LLVMAsmPrinter LLVMCodeGen LLVMCore LLVMMC LLVMSupport LLVMSystemZInfo LLVMTarget) set(MSVC_LIB_DEPS_LLVMSystemZCodeGen LLVMCodeGen LLVMCore LLVMMC LLVMSelectionDAG LLVMSupport LLVMSystemZInfo LLVMTarget) set(MSVC_LIB_DEPS_LLVMSystemZInfo LLVMSupport) set(MSVC_LIB_DEPS_LLVMTarget LLVMCore LLVMMC LLVMSupport) @@ -66,7 +67,8 @@ set(MSVC_LIB_DEPS_LLVMX86CodeGen LLVMAnalysis LLVMAsmPrinter LLVMCodeGen LLVMCore LLVMMC LLVMSelectionDAG LLVMSupport LLVMSystem LLVMTarget LLVMX86AsmPrinter LLVMX86Info) set(MSVC_LIB_DEPS_LLVMX86Disassembler LLVMMC LLVMSupport LLVMX86Info) set(MSVC_LIB_DEPS_LLVMX86Info LLVMSupport) -set(MSVC_LIB_DEPS_LLVMXCoreAsmPrinter LLVMAsmPrinter LLVMCodeGen LLVMCore LLVMMC LLVMSupport LLVMTarget LLVMXCoreCodeGen LLVMXCoreInfo) +set(MSVC_LIB_DEPS_LLVMXCore LLVMCodeGen LLVMCore LLVMMC LLVMSelectionDAG LLVMSupport LLVMTarget LLVMXCoreCodeGen LLVMXCoreInfo) +set(MSVC_LIB_DEPS_LLVMXCoreAsmPrinter LLVMAsmPrinter LLVMCodeGen LLVMCore LLVMMC LLVMSupport LLVMTarget LLVMXCoreInfo) set(MSVC_LIB_DEPS_LLVMXCoreCodeGen LLVMCodeGen LLVMCore LLVMMC LLVMSelectionDAG LLVMSupport LLVMTarget LLVMXCoreInfo) set(MSVC_LIB_DEPS_LLVMXCoreInfo LLVMSupport) set(MSVC_LIB_DEPS_LLVMipa LLVMAnalysis LLVMCore LLVMSupport LLVMSystem) From eli.friedman at gmail.com Mon Aug 9 15:49:43 2010 From: eli.friedman at gmail.com (Eli Friedman) Date: Mon, 09 Aug 2010 20:49:43 -0000 Subject: [llvm-commits] [llvm] r110597 - in /llvm/trunk: lib/Transforms/InstCombine/InstCombineCalls.cpp test/Transforms/InstCombine/intrinsics.ll Message-ID: <20100809204943.A950E2A6C12C@llvm.org> Author: efriedma Date: Mon Aug 9 15:49:43 2010 New Revision: 110597 URL: http://llvm.org/viewvc/llvm-project?rev=110597&view=rev Log: PR7853: fix a silly mistake introduced in r101899, and add a test to make sure it doesn't regress again. Modified: llvm/trunk/lib/Transforms/InstCombine/InstCombineCalls.cpp llvm/trunk/test/Transforms/InstCombine/intrinsics.ll Modified: llvm/trunk/lib/Transforms/InstCombine/InstCombineCalls.cpp URL: http://llvm.org/viewvc/llvm-project/llvm/trunk/lib/Transforms/InstCombine/InstCombineCalls.cpp?rev=110597&r1=110596&r2=110597&view=diff ============================================================================== --- llvm/trunk/lib/Transforms/InstCombine/InstCombineCalls.cpp (original) +++ llvm/trunk/lib/Transforms/InstCombine/InstCombineCalls.cpp Mon Aug 9 15:49:43 2010 @@ -538,7 +538,7 @@ // X + 0 -> {X, false} if (RHS->isZero()) { Constant *V[] = { - UndefValue::get(II->getCalledValue()->getType()), + UndefValue::get(II->getArgOperand(0)->getType()), ConstantInt::getFalse(II->getContext()) }; Constant *Struct = ConstantStruct::get(II->getContext(), V, 2, false); Modified: llvm/trunk/test/Transforms/InstCombine/intrinsics.ll URL: http://llvm.org/viewvc/llvm-project/llvm/trunk/test/Transforms/InstCombine/intrinsics.ll?rev=110597&r1=110596&r2=110597&view=diff ============================================================================== --- llvm/trunk/test/Transforms/InstCombine/intrinsics.ll (original) +++ llvm/trunk/test/Transforms/InstCombine/intrinsics.ll Mon Aug 9 15:49:43 2010 @@ -10,16 +10,16 @@ declare i32 @llvm.ctpop.i32(i32) nounwind readnone declare i8 @llvm.ctlz.i8(i8) nounwind readnone -define i8 @test1(i8 %A, i8 %B) { +define i8 @uaddtest1(i8 %A, i8 %B) { %x = call %overflow.result @llvm.uadd.with.overflow.i8(i8 %A, i8 %B) %y = extractvalue %overflow.result %x, 0 ret i8 %y -; CHECK: @test1 +; CHECK: @uaddtest1 ; CHECK-NEXT: %y = add i8 %A, %B ; CHECK-NEXT: ret i8 %y } -define i8 @test2(i8 %A, i8 %B, i1* %overflowPtr) { +define i8 @uaddtest2(i8 %A, i8 %B, i1* %overflowPtr) { %and.A = and i8 %A, 127 %and.B = and i8 %B, 127 %x = call %overflow.result @llvm.uadd.with.overflow.i8(i8 %and.A, i8 %and.B) @@ -27,7 +27,7 @@ %z = extractvalue %overflow.result %x, 1 store i1 %z, i1* %overflowPtr ret i8 %y -; CHECK: @test2 +; CHECK: @uaddtest2 ; CHECK-NEXT: %and.A = and i8 %A, 127 ; CHECK-NEXT: %and.B = and i8 %B, 127 ; CHECK-NEXT: %1 = add nuw i8 %and.A, %and.B @@ -35,7 +35,7 @@ ; CHECK-NEXT: ret i8 %1 } -define i8 @test3(i8 %A, i8 %B, i1* %overflowPtr) { +define i8 @uaddtest3(i8 %A, i8 %B, i1* %overflowPtr) { %or.A = or i8 %A, -128 %or.B = or i8 %B, -128 %x = call %overflow.result @llvm.uadd.with.overflow.i8(i8 %or.A, i8 %or.B) @@ -43,7 +43,7 @@ %z = extractvalue %overflow.result %x, 1 store i1 %z, i1* %overflowPtr ret i8 %y -; CHECK: @test3 +; CHECK: @uaddtest3 ; CHECK-NEXT: %or.A = or i8 %A, -128 ; CHECK-NEXT: %or.B = or i8 %B, -128 ; CHECK-NEXT: %1 = add i8 %or.A, %or.B @@ -51,34 +51,44 @@ ; CHECK-NEXT: ret i8 %1 } -define i8 @test4(i8 %A, i1* %overflowPtr) { +define i8 @uaddtest4(i8 %A, i1* %overflowPtr) { %x = call %overflow.result @llvm.uadd.with.overflow.i8(i8 undef, i8 %A) %y = extractvalue %overflow.result %x, 0 %z = extractvalue %overflow.result %x, 1 store i1 %z, i1* %overflowPtr ret i8 %y -; CHECK: @test4 +; CHECK: @uaddtest4 ; CHECK-NEXT: ret i8 undef } -define i8 @test5(i8 %A, i1* %overflowPtr) { +define i8 @uaddtest5(i8 %A, i1* %overflowPtr) { + %x = call %overflow.result @llvm.uadd.with.overflow.i8(i8 0, i8 %A) + %y = extractvalue %overflow.result %x, 0 + %z = extractvalue %overflow.result %x, 1 + store i1 %z, i1* %overflowPtr + ret i8 %y +; CHECK: @uaddtest5 +; CHECK: ret i8 %A +} + +define i8 @umultest1(i8 %A, i1* %overflowPtr) { %x = call %overflow.result @llvm.umul.with.overflow.i8(i8 0, i8 %A) %y = extractvalue %overflow.result %x, 0 %z = extractvalue %overflow.result %x, 1 store i1 %z, i1* %overflowPtr ret i8 %y -; CHECK: @test5 +; CHECK: @umultest1 ; CHECK-NEXT: store i1 false, i1* %overflowPtr ; CHECK-NEXT: ret i8 0 } -define i8 @test6(i8 %A, i1* %overflowPtr) { +define i8 @umultest2(i8 %A, i1* %overflowPtr) { %x = call %overflow.result @llvm.umul.with.overflow.i8(i8 1, i8 %A) %y = extractvalue %overflow.result %x, 0 %z = extractvalue %overflow.result %x, 1 store i1 %z, i1* %overflowPtr ret i8 %y -; CHECK: @test6 +; CHECK: @umultest2 ; CHECK-NEXT: store i1 false, i1* %overflowPtr ; CHECK-NEXT: ret i8 %A } From resistor at mac.com Mon Aug 9 15:50:47 2010 From: resistor at mac.com (Owen Anderson) Date: Mon, 09 Aug 2010 20:50:47 -0000 Subject: [llvm-commits] [llvm] r110598 - /llvm/trunk/lib/Analysis/LazyValueInfo.cpp Message-ID: <20100809205047.1B2EB2A6C12C@llvm.org> Author: resistor Date: Mon Aug 9 15:50:46 2010 New Revision: 110598 URL: http://llvm.org/viewvc/llvm-project?rev=110598&view=rev Log: Add ConstantRange information to the debugging output. Modified: llvm/trunk/lib/Analysis/LazyValueInfo.cpp Modified: llvm/trunk/lib/Analysis/LazyValueInfo.cpp URL: http://llvm.org/viewvc/llvm-project/llvm/trunk/lib/Analysis/LazyValueInfo.cpp?rev=110598&r1=110597&r2=110598&view=diff ============================================================================== --- llvm/trunk/lib/Analysis/LazyValueInfo.cpp (original) +++ llvm/trunk/lib/Analysis/LazyValueInfo.cpp Mon Aug 9 15:50:46 2010 @@ -247,6 +247,9 @@ if (Val.isNotConstant()) return OS << "notconstant<" << *Val.getNotConstant() << '>'; + else if (Val.isConstantRange()) + return OS << "constantrange<" << Val.getConstantRange().getLower() << ", " + << Val.getConstantRange().getUpper() << '>'; return OS << "constant<" << *Val.getConstant() << '>'; } } From nlewycky at google.com Mon Aug 9 15:52:27 2010 From: nlewycky at google.com (Nick Lewycky) Date: Mon, 9 Aug 2010 13:52:27 -0700 Subject: [llvm-commits] [Patch Proposal] fix unittests on mingw In-Reply-To: References: Message-ID: Zhanyong, could you review these patches? On 9 August 2010 10:23, NAKAMURA Takumi wrote: > Good midnight, everyone. > > > Their patches make "make unittests" fine on mingw. > > > * r110166-unittests-RDYNAMIC.diff.txt > On cygwin/mingw, this redefines $RDYNAMIC and suppress $RPATH. > TODO: it should be detected by autoconf. > > This enables exporting symbols from Executable.EXE. > (eg. unittests/JIT) > > > * r106620-unittests-mingw-EXPECT_DEATH.diff.txt > gtest death test aborts with a desktop dialog on Windows 7. > I had to suppress death tests on mingw. > > > r84355-unittests-workaround-msvcrt.diff.txt > This is workaround for PR6745 and PR7668. > http://llvm.org/bugs/show_bug.cgi?id=6745 > (When the issue is resolved, we can meet failure by this patch. > Then we have to revert it.) > > > ...oyasuminasai...Takumi > > _______________________________________________ > llvm-commits mailing list > llvm-commits at cs.uiuc.edu > http://lists.cs.uiuc.edu/mailman/listinfo/llvm-commits > > -------------- next part -------------- An HTML attachment was scrubbed... URL: http://lists.cs.uiuc.edu/pipermail/llvm-commits/attachments/20100809/5119c5e6/attachment.html From dpatel at apple.com Mon Aug 9 16:01:39 2010 From: dpatel at apple.com (Devang Patel) Date: Mon, 09 Aug 2010 21:01:39 -0000 Subject: [llvm-commits] [llvm] r110600 - in /llvm/trunk/lib/CodeGen/AsmPrinter: DwarfDebug.cpp DwarfDebug.h Message-ID: <20100809210139.3D71F2A6C12C@llvm.org> Author: dpatel Date: Mon Aug 9 16:01:39 2010 New Revision: 110600 URL: http://llvm.org/viewvc/llvm-project?rev=110600&view=rev Log: Refactoring. Update DbgVarible to handle queries itself. Modified: llvm/trunk/lib/CodeGen/AsmPrinter/DwarfDebug.cpp llvm/trunk/lib/CodeGen/AsmPrinter/DwarfDebug.h Modified: llvm/trunk/lib/CodeGen/AsmPrinter/DwarfDebug.cpp URL: http://llvm.org/viewvc/llvm-project/llvm/trunk/lib/CodeGen/AsmPrinter/DwarfDebug.cpp?rev=110600&r1=110599&r2=110600&view=diff ============================================================================== --- llvm/trunk/lib/CodeGen/AsmPrinter/DwarfDebug.cpp (original) +++ llvm/trunk/lib/CodeGen/AsmPrinter/DwarfDebug.cpp Mon Aug 9 16:01:39 2010 @@ -180,6 +180,73 @@ DIE *getDIE() const { return TheDIE; } void setDotDebugLocOffset(unsigned O) { DotDebugLocOffset = O; } unsigned getDotDebugLocOffset() const { return DotDebugLocOffset; } + StringRef getName() const { return Var.getName(); } + unsigned getTag() const { return Var.getTag(); } + bool variableHasComplexAddress() const { + assert(Var.Verify() && "Invalid complex DbgVariable!"); + return Var.hasComplexAddress(); + } + bool isBlockByrefVariable() const { + assert(Var.Verify() && "Invalid complex DbgVariable!"); + return Var.isBlockByrefVariable(); + } + unsigned getNumAddrElements() const { + assert(Var.Verify() && "Invalid complex DbgVariable!"); + return Var.getNumAddrElements(); + } + uint64_t getAddrElement(unsigned i) const { + return Var.getAddrElement(i); + } + DIType getType() const { + DIType Ty = Var.getType(); + // FIXME: isBlockByrefVariable should be reformulated in terms of complex + // addresses instead. + if (Var.isBlockByrefVariable()) { + /* Byref variables, in Blocks, are declared by the programmer as + "SomeType VarName;", but the compiler creates a + __Block_byref_x_VarName struct, and gives the variable VarName + either the struct, or a pointer to the struct, as its type. This + is necessary for various behind-the-scenes things the compiler + needs to do with by-reference variables in blocks. + + However, as far as the original *programmer* is concerned, the + variable should still have type 'SomeType', as originally declared. + + The following function dives into the __Block_byref_x_VarName + struct to find the original type of the variable. This will be + passed back to the code generating the type for the Debug + Information Entry for the variable 'VarName'. 'VarName' will then + have the original type 'SomeType' in its debug information. + + The original type 'SomeType' will be the type of the field named + 'VarName' inside the __Block_byref_x_VarName struct. + + NOTE: In order for this to not completely fail on the debugger + side, the Debug Information Entry for the variable VarName needs to + have a DW_AT_location that tells the debugger how to unwind through + the pointers and __Block_byref_x_VarName struct to find the actual + value of the variable. The function addBlockByrefType does this. */ + DIType subType = Ty; + unsigned tag = Ty.getTag(); + + if (tag == dwarf::DW_TAG_pointer_type) { + DIDerivedType DTy = DIDerivedType(Ty); + subType = DTy.getTypeDerivedFrom(); + } + + DICompositeType blockStruct = DICompositeType(subType); + DIArray Elements = blockStruct.getTypeArray(); + + for (unsigned i = 0, N = Elements.getNumElements(); i < N; ++i) { + DIDescriptor Element = Elements.getElement(i); + DIDerivedType DT = DIDerivedType(Element); + if (getName() == DT.getName()) + return (DT.getTypeDerivedFrom()); + } + return Ty; + } + return Ty; + } }; //===----------------------------------------------------------------------===// @@ -517,55 +584,16 @@ addUInt(Die, dwarf::DW_AT_decl_line, 0, Line); } -/* Byref variables, in Blocks, are declared by the programmer as - "SomeType VarName;", but the compiler creates a - __Block_byref_x_VarName struct, and gives the variable VarName - either the struct, or a pointer to the struct, as its type. This - is necessary for various behind-the-scenes things the compiler - needs to do with by-reference variables in blocks. - - However, as far as the original *programmer* is concerned, the - variable should still have type 'SomeType', as originally declared. - - The following function dives into the __Block_byref_x_VarName - struct to find the original type of the variable. This will be - passed back to the code generating the type for the Debug - Information Entry for the variable 'VarName'. 'VarName' will then - have the original type 'SomeType' in its debug information. - - The original type 'SomeType' will be the type of the field named - 'VarName' inside the __Block_byref_x_VarName struct. - - NOTE: In order for this to not completely fail on the debugger - side, the Debug Information Entry for the variable VarName needs to - have a DW_AT_location that tells the debugger how to unwind through - the pointers and __Block_byref_x_VarName struct to find the actual - value of the variable. The function addBlockByrefType does this. */ - -/// Find the type the programmer originally declared the variable to be -/// and return that type. -/// -DIType DwarfDebug::getBlockByrefType(DIType Ty, std::string Name) { - - DIType subType = Ty; - unsigned tag = Ty.getTag(); - - if (tag == dwarf::DW_TAG_pointer_type) { - DIDerivedType DTy = DIDerivedType(Ty); - subType = DTy.getTypeDerivedFrom(); - } - - DICompositeType blockStruct = DICompositeType(subType); - DIArray Elements = blockStruct.getTypeArray(); - - for (unsigned i = 0, N = Elements.getNumElements(); i < N; ++i) { - DIDescriptor Element = Elements.getElement(i); - DIDerivedType DT = DIDerivedType(Element); - if (Name == DT.getName()) - return (DT.getTypeDerivedFrom()); - } - - return Ty; +/// addVariableAddress - Add DW_AT_location attribute for a DbgVariable. +void DwarfDebug::addVariableAddress(DbgVariable *&DV, DIE *Die, + unsigned Attribute, + const MachineLocation &Location) { + if (DV->variableHasComplexAddress()) + addComplexAddress(DV, Die, dwarf::DW_AT_location, Location); + else if (DV->isBlockByrefVariable()) + addBlockByrefAddress(DV, Die, dwarf::DW_AT_location, Location); + else + addAddress(Die, dwarf::DW_AT_location, Location); } /// addComplexAddress - Start with the address based on the location provided, @@ -576,8 +604,7 @@ void DwarfDebug::addComplexAddress(DbgVariable *&DV, DIE *Die, unsigned Attribute, const MachineLocation &Location) { - const DIVariable &VD = DV->getVariable(); - DIType Ty = VD.getType(); + DIType Ty = DV->getType(); // Decode the original location, and use that as the start of the byref // variable's location. @@ -604,12 +631,12 @@ addUInt(Block, 0, dwarf::DW_FORM_sdata, Location.getOffset()); } - for (unsigned i = 0, N = VD.getNumAddrElements(); i < N; ++i) { - uint64_t Element = VD.getAddrElement(i); + for (unsigned i = 0, N = DV->getNumAddrElements(); i < N; ++i) { + uint64_t Element = DV->getAddrElement(i); if (Element == DIFactory::OpPlus) { addUInt(Block, 0, dwarf::DW_FORM_data1, dwarf::DW_OP_plus_uconst); - addUInt(Block, 0, dwarf::DW_FORM_udata, VD.getAddrElement(++i)); + addUInt(Block, 0, dwarf::DW_FORM_udata, DV->getAddrElement(++i)); } else if (Element == DIFactory::OpDeref) { addUInt(Block, 0, dwarf::DW_FORM_data1, dwarf::DW_OP_deref); } else llvm_unreachable("unknown DIFactory Opcode"); @@ -682,13 +709,12 @@ void DwarfDebug::addBlockByrefAddress(DbgVariable *&DV, DIE *Die, unsigned Attribute, const MachineLocation &Location) { - const DIVariable &VD = DV->getVariable(); - DIType Ty = VD.getType(); + DIType Ty = DV->getType(); DIType TmpTy = Ty; unsigned Tag = Ty.getTag(); bool isPointer = false; - StringRef varName = VD.getName(); + StringRef varName = DV->getName(); if (Tag == dwarf::DW_TAG_pointer_type) { DIDerivedType DTy = DIDerivedType(Ty); @@ -1556,16 +1582,14 @@ /// constructVariableDIE - Construct a DIE for the given DbgVariable. DIE *DwarfDebug::constructVariableDIE(DbgVariable *DV, DbgScope *Scope) { - // Get the descriptor. - const DIVariable &VD = DV->getVariable(); - StringRef Name = VD.getName(); + StringRef Name = DV->getName(); if (Name.empty()) return NULL; // Translate tag to proper Dwarf tag. The result variable is dropped for // now. unsigned Tag; - switch (VD.getTag()) { + switch (DV->getTag()) { case dwarf::DW_TAG_return_variable: return NULL; case dwarf::DW_TAG_arg_variable: @@ -1591,18 +1615,13 @@ dwarf::DW_FORM_ref4, AbsDIE); else { addString(VariableDie, dwarf::DW_AT_name, dwarf::DW_FORM_string, Name); - addSourceLine(VariableDie, VD); + addSourceLine(VariableDie, DV->getVariable()); // Add variable type. - // FIXME: isBlockByrefVariable should be reformulated in terms of complex - // addresses instead. - if (VD.isBlockByrefVariable()) - addType(VariableDie, getBlockByrefType(VD.getType(), Name)); - else - addType(VariableDie, VD.getType()); + addType(VariableDie, DV->getType()); } - if (Tag == dwarf::DW_TAG_formal_parameter && VD.getType().isArtificial()) + if (Tag == dwarf::DW_TAG_formal_parameter && DV->getType().isArtificial()) addUInt(VariableDie, dwarf::DW_AT_artificial, dwarf::DW_FORM_flag, 1); if (Scope->isAbstractScope()) { @@ -1666,13 +1685,7 @@ if (findVariableFrameIndex(DV, &FI)) { int Offset = RI->getFrameIndexReference(*Asm->MF, FI, FrameReg); Location.set(FrameReg, Offset); - - if (VD.hasComplexAddress()) - addComplexAddress(DV, VariableDie, dwarf::DW_AT_location, Location); - else if (VD.isBlockByrefVariable()) - addBlockByrefAddress(DV, VariableDie, dwarf::DW_AT_location, Location); - else - addAddress(VariableDie, dwarf::DW_AT_location, Location); + addVariableAddress(DV, VariableDie, dwarf::DW_AT_location, Location); } DV->setDIE(VariableDie); return VariableDie; Modified: llvm/trunk/lib/CodeGen/AsmPrinter/DwarfDebug.h URL: http://llvm.org/viewvc/llvm-project/llvm/trunk/lib/CodeGen/AsmPrinter/DwarfDebug.h?rev=110600&r1=110599&r2=110600&view=diff ============================================================================== --- llvm/trunk/lib/CodeGen/AsmPrinter/DwarfDebug.h (original) +++ llvm/trunk/lib/CodeGen/AsmPrinter/DwarfDebug.h Mon Aug 9 16:01:39 2010 @@ -376,6 +376,10 @@ void addBlockByrefAddress(DbgVariable *&DV, DIE *Die, unsigned Attribute, const MachineLocation &Location); + /// addVariableAddress - Add DW_AT_location attribute for a DbgVariable. + void addVariableAddress(DbgVariable *&DV, DIE *Die, unsigned Attribute, + const MachineLocation &Location); + /// addToContextOwner - Add Die into the list of its context owner's children. void addToContextOwner(DIE *Die, DIDescriptor Context); @@ -560,12 +564,6 @@ /// construct SubprogramDIE - Construct subprogram DIE. void constructSubprogramDIE(const MDNode *N); - // FIXME: This should go away in favor of complex addresses. - /// Find the type the programmer originally declared the variable to be - /// and return that type. Obsolete, use GetComplexAddrType instead. - /// - DIType getBlockByrefType(DIType Ty, std::string Name); - /// recordSourceLine - Register a source line with debug info. Returns the /// unique label that was emitted and which provides correspondence to /// the source line list. From nicholas at mxc.ca Mon Aug 9 16:03:28 2010 From: nicholas at mxc.ca (Nick Lewycky) Date: Mon, 09 Aug 2010 21:03:28 -0000 Subject: [llvm-commits] [llvm] r110601 - /llvm/trunk/lib/Transforms/IPO/MergeFunctions.cpp Message-ID: <20100809210329.0163E2A6C12C@llvm.org> Author: nicholas Date: Mon Aug 9 16:03:28 2010 New Revision: 110601 URL: http://llvm.org/viewvc/llvm-project?rev=110601&view=rev Log: Fix a use after free error caught by the valgrind builders. Modified: llvm/trunk/lib/Transforms/IPO/MergeFunctions.cpp Modified: llvm/trunk/lib/Transforms/IPO/MergeFunctions.cpp URL: http://llvm.org/viewvc/llvm-project/llvm/trunk/lib/Transforms/IPO/MergeFunctions.cpp?rev=110601&r1=110600&r2=110601&view=diff ============================================================================== --- llvm/trunk/lib/Transforms/IPO/MergeFunctions.cpp (original) +++ llvm/trunk/lib/Transforms/IPO/MergeFunctions.cpp Mon Aug 9 16:03:28 2010 @@ -559,7 +559,7 @@ } /// MergeTwoFunctions - Merge two equivalent functions. Upon completion, -/// FnVec[j] should never be visited again. +/// FnVec[j] is deleted but not removed from the vector. void MergeFunctions::MergeTwoFunctions(std::vector &FnVec, unsigned i, unsigned j) const { Function *F = FnVec[i]; @@ -580,10 +580,12 @@ H->takeName(F); F->replaceAllUsesWith(H); + unsigned MaxAlignment = std::max(G->getAlignment(), H->getAlignment()); + WriteThunk(F, G); WriteThunk(F, H); - F->setAlignment(std::max(G->getAlignment(), H->getAlignment())); + F->setAlignment(MaxAlignment); F->setLinkage(GlobalValue::InternalLinkage); } else { WriteThunk(F, G); From rafael.espindola at gmail.com Mon Aug 9 16:09:46 2010 From: rafael.espindola at gmail.com (Rafael Espindola) Date: Mon, 09 Aug 2010 21:09:46 -0000 Subject: [llvm-commits] [llvm] r110604 - in /llvm/trunk: include/llvm-c/lto.h tools/gold/gold-plugin.cpp tools/lto/LTOModule.cpp tools/lto/LTOModule.h tools/lto/lto.cpp tools/lto/lto.exports Message-ID: <20100809210946.E86F82A6C12C@llvm.org> Author: rafael Date: Mon Aug 9 16:09:46 2010 New Revision: 110604 URL: http://llvm.org/viewvc/llvm-project?rev=110604&view=rev Log: Make it possible to set the target triple and expose that with an option in the gold plugin. Modified: llvm/trunk/include/llvm-c/lto.h llvm/trunk/tools/gold/gold-plugin.cpp llvm/trunk/tools/lto/LTOModule.cpp llvm/trunk/tools/lto/LTOModule.h llvm/trunk/tools/lto/lto.cpp llvm/trunk/tools/lto/lto.exports Modified: llvm/trunk/include/llvm-c/lto.h URL: http://llvm.org/viewvc/llvm-project/llvm/trunk/include/llvm-c/lto.h?rev=110604&r1=110603&r2=110604&view=diff ============================================================================== --- llvm/trunk/include/llvm-c/lto.h (original) +++ llvm/trunk/include/llvm-c/lto.h Mon Aug 9 16:09:46 2010 @@ -135,6 +135,12 @@ extern const char* lto_module_get_target_triple(lto_module_t mod); +/** + * Sets triple string with which the object will be codegened. + */ +extern void +lto_module_set_target_triple(lto_module_t mod, const char *triple); + /** * Returns the number of symbols in the object module. Modified: llvm/trunk/tools/gold/gold-plugin.cpp URL: http://llvm.org/viewvc/llvm-project/llvm/trunk/tools/gold/gold-plugin.cpp?rev=110604&r1=110603&r2=110604&view=diff ============================================================================== --- llvm/trunk/tools/gold/gold-plugin.cpp (original) +++ llvm/trunk/tools/gold/gold-plugin.cpp Mon Aug 9 16:09:46 2010 @@ -68,6 +68,7 @@ static std::string as_path; static std::vector pass_through; static std::string extra_library_path; + static std::string triple; // Additional options to pass into the code generator. // Note: This array will contain all plugin options which are not claimed // as plugin exclusive to pass to the code generator. @@ -95,6 +96,8 @@ } else if (opt.startswith("pass-through=")) { llvm::StringRef item = opt.substr(strlen("pass-through=")); pass_through.push_back(item.str()); + } else if (opt == "mtriple=") { + triple = opt.substr(strlen("mtriple=")); } else if (opt == "emit-llvm") { generate_bc_file = BC_ONLY; } else if (opt == "also-emit-llvm") { @@ -270,6 +273,10 @@ lto_get_error_message()); return LDPS_ERR; } + + if (!options::triple.empty()) + lto_module_set_target_triple(cf.M, options::triple.c_str()); + cf.handle = file->handle; unsigned sym_count = lto_module_get_num_symbols(cf.M); cf.syms.reserve(sym_count); Modified: llvm/trunk/tools/lto/LTOModule.cpp URL: http://llvm.org/viewvc/llvm-project/llvm/trunk/tools/lto/LTOModule.cpp?rev=110604&r1=110603&r2=110604&view=diff ============================================================================== --- llvm/trunk/tools/lto/LTOModule.cpp (original) +++ llvm/trunk/tools/lto/LTOModule.cpp Mon Aug 9 16:09:46 2010 @@ -153,6 +153,11 @@ return _module->getTargetTriple().c_str(); } +void LTOModule::setTargetTriple(const char *triple) +{ + _module->setTargetTriple(triple); +} + void LTOModule::addDefinedFunctionSymbol(Function* f, Mangler &mangler) { // add to list of defined symbols Modified: llvm/trunk/tools/lto/LTOModule.h URL: http://llvm.org/viewvc/llvm-project/llvm/trunk/tools/lto/LTOModule.h?rev=110604&r1=110603&r2=110604&view=diff ============================================================================== --- llvm/trunk/tools/lto/LTOModule.h (original) +++ llvm/trunk/tools/lto/LTOModule.h Mon Aug 9 16:09:46 2010 @@ -55,6 +55,7 @@ std::string& errMsg); const char* getTargetTriple(); + void setTargetTriple(const char*); uint32_t getSymbolCount(); lto_symbol_attributes getSymbolAttributes(uint32_t index); const char* getSymbolName(uint32_t index); Modified: llvm/trunk/tools/lto/lto.cpp URL: http://llvm.org/viewvc/llvm-project/llvm/trunk/tools/lto/lto.cpp?rev=110604&r1=110603&r2=110604&view=diff ============================================================================== --- llvm/trunk/tools/lto/lto.cpp (original) +++ llvm/trunk/tools/lto/lto.cpp Mon Aug 9 16:09:46 2010 @@ -120,6 +120,14 @@ return mod->getTargetTriple(); } +// +// sets triple string with which the object will be codegened. +// +void lto_module_set_target_triple(lto_module_t mod, const char *triple) +{ + return mod->setTargetTriple(triple); +} + // // returns the number of symbols in the object module Modified: llvm/trunk/tools/lto/lto.exports URL: http://llvm.org/viewvc/llvm-project/llvm/trunk/tools/lto/lto.exports?rev=110604&r1=110603&r2=110604&view=diff ============================================================================== --- llvm/trunk/tools/lto/lto.exports (original) +++ llvm/trunk/tools/lto/lto.exports Mon Aug 9 16:09:46 2010 @@ -6,6 +6,7 @@ lto_module_get_symbol_attribute lto_module_get_symbol_name lto_module_get_target_triple +lto_module_set_target_triple lto_module_is_object_file lto_module_is_object_file_for_target lto_module_is_object_file_in_memory From bruno.cardoso at gmail.com Mon Aug 9 16:24:59 2010 From: bruno.cardoso at gmail.com (Bruno Cardoso Lopes) Date: Mon, 09 Aug 2010 21:24:59 -0000 Subject: [llvm-commits] [llvm] r110605 - /llvm/trunk/lib/Target/X86/X86InstrSSE.td Message-ID: <20100809212459.E6D932A6C12C@llvm.org> Author: bruno Date: Mon Aug 9 16:24:59 2010 New Revision: 110605 URL: http://llvm.org/viewvc/llvm-project?rev=110605&view=rev Log: Add patterns to AVX conversions instructions. Do that instead of declaring more intructions whenever is possible, more coming Modified: llvm/trunk/lib/Target/X86/X86InstrSSE.td Modified: llvm/trunk/lib/Target/X86/X86InstrSSE.td URL: http://llvm.org/viewvc/llvm-project/llvm/trunk/lib/Target/X86/X86InstrSSE.td?rev=110605&r1=110604&r2=110605&view=diff ============================================================================== --- llvm/trunk/lib/Target/X86/X86InstrSSE.td (original) +++ llvm/trunk/lib/Target/X86/X86InstrSSE.td Mon Aug 9 16:24:59 2010 @@ -751,10 +751,10 @@ defm VCVTSS2SI64 : sse12_cvt_s<0x2D, FR32, GR64, undef, f32mem, load, "cvtss2si\t{$src, $dst|$dst, $src}">, XS, VEX, VEX_W; -defm VCVTDQ2PS : sse12_cvt_p<0x5B, VR128, VR128, undef, f128mem, load, +defm VCVTDQ2PS : sse12_cvt_p<0x5B, VR128, VR128, undef, i128mem, load, "cvtdq2ps\t{$src, $dst|$dst, $src}", SSEPackedSingle>, TB, VEX; -defm VCVTDQ2PSY : sse12_cvt_p<0x5B, VR256, VR256, undef, f256mem, load, +defm VCVTDQ2PSY : sse12_cvt_p<0x5B, VR256, VR256, undef, i256mem, load, "cvtdq2ps\t{$src, $dst|$dst, $src}", SSEPackedSingle>, TB, VEX; } @@ -763,7 +763,7 @@ "cvtss2si{l}\t{$src, $dst|$dst, $src}">, XS; defm CVTSS2SI64 : sse12_cvt_s<0x2D, FR32, GR64, undef, f32mem, load /*dummy*/, "cvtss2si{q}\t{$src, $dst|$dst, $src}">, XS, REX_W; -defm CVTDQ2PS : sse12_cvt_p<0x5B, VR128, VR128, undef, f128mem, load /*dummy*/, +defm CVTDQ2PS : sse12_cvt_p<0x5B, VR128, VR128, undef, i128mem, load /*dummy*/, "cvtdq2ps\t{$src, $dst|$dst, $src}", SSEPackedSingle>, TB; /* PD SSE3 form is avaiable */ } @@ -894,6 +894,7 @@ (bitconvert (memopv2i64 addr:$src))))]>, XS, Requires<[HasSSE2]>; + // Convert packed single/double fp to doubleword let isAsmParserOnly = 1 in { def VCVTPS2DQrr : VPDI<0x5B, MRMSrcReg, (outs VR128:$dst), (ins VR128:$src), @@ -1117,6 +1118,14 @@ [(set VR128:$dst, (int_x86_sse2_cvtpd2ps (memop addr:$src)))]>; +// AVX 256-bit register conversion intrinsics +// FIXME: Migrate SSE conversion intrinsics matching to use patterns as below +// whenever possible to avoid declaring two versions of each one. +def : Pat<(int_x86_avx_cvtdq2_ps_256 VR256:$src), + (VCVTDQ2PSYrr VR256:$src)>; +def : Pat<(int_x86_avx_cvtdq2_ps_256 (memopv8i32 addr:$src)), + (VCVTDQ2PSYrm addr:$src)>; + //===----------------------------------------------------------------------===// // SSE 1 & 2 - Compare Instructions //===----------------------------------------------------------------------===// @@ -3230,13 +3239,9 @@ def VCVTDQ2PDrr : S3SI<0xE6, MRMSrcReg, (outs VR128:$dst), (ins VR128:$src), "vcvtdq2pd\t{$src, $dst|$dst, $src}", []>, VEX; def VCVTDQ2PDYrm : S3SI<0xE6, MRMSrcMem, (outs VR256:$dst), (ins f128mem:$src), - "vcvtdq2pd\t{$src, $dst|$dst, $src}", - [(set VR256:$dst, - (int_x86_avx_cvtdq2_pd_256 (memopv4i32 addr:$src)))]>, VEX; + "vcvtdq2pd\t{$src, $dst|$dst, $src}", []>, VEX; def VCVTDQ2PDYrr : S3SI<0xE6, MRMSrcReg, (outs VR256:$dst), (ins VR128:$src), - "vcvtdq2pd\t{$src, $dst|$dst, $src}", - [(set VR256:$dst, - (int_x86_avx_cvtdq2_pd_256 VR128:$src))]>, VEX; + "vcvtdq2pd\t{$src, $dst|$dst, $src}", []>, VEX; } def CVTDQ2PDrm : S3SI<0xE6, MRMSrcMem, (outs VR128:$dst), (ins f128mem:$src), @@ -3244,6 +3249,12 @@ def CVTDQ2PDrr : S3SI<0xE6, MRMSrcReg, (outs VR128:$dst), (ins VR128:$src), "cvtdq2pd\t{$src, $dst|$dst, $src}", []>; +// AVX 256-bit register conversion intrinsics +def : Pat<(int_x86_avx_cvtdq2_pd_256 VR128:$src), + (VCVTDQ2PDYrr VR128:$src)>; +def : Pat<(int_x86_avx_cvtdq2_pd_256 (memopv4i32 addr:$src)), + (VCVTDQ2PDYrm addr:$src)>; + //===---------------------------------------------------------------------===// // SSE3 - Move Instructions //===---------------------------------------------------------------------===// From criswell at uiuc.edu Mon Aug 9 16:27:42 2010 From: criswell at uiuc.edu (John Criswell) Date: Mon, 09 Aug 2010 21:27:42 -0000 Subject: [llvm-commits] [poolalloc] r110606 - in /poolalloc/trunk: include/assistDS/Devirt.h lib/AssistDS/Devirt.cpp Message-ID: <20100809212742.5DD592A6C12C@llvm.org> Author: criswell Date: Mon Aug 9 16:27:42 2010 New Revision: 110606 URL: http://llvm.org/viewvc/llvm-project?rev=110606&view=rev Log: Refactored parts of the buildBounce() method so that it properly adds an entry basic block to do initial casting and then comparison basic blocks that actually handle the function selection and dispatch. Modified: poolalloc/trunk/include/assistDS/Devirt.h poolalloc/trunk/lib/AssistDS/Devirt.cpp Modified: poolalloc/trunk/include/assistDS/Devirt.h URL: http://llvm.org/viewvc/llvm-project/poolalloc/trunk/include/assistDS/Devirt.h?rev=110606&r1=110605&r2=110606&view=diff ============================================================================== --- poolalloc/trunk/include/assistDS/Devirt.h (original) +++ poolalloc/trunk/include/assistDS/Devirt.h Mon Aug 9 16:27:42 2010 @@ -22,6 +22,7 @@ #include "llvm/Instructions.h" #include "llvm/DerivedTypes.h" #include "llvm/Support/InstVisitor.h" +#include "llvm/Target/TargetData.h" using namespace llvm; @@ -39,6 +40,9 @@ // Access to analysis pass which finds targets of indirect function calls CallTargetFinder* CTF; + // Access to the target data analysis pass + TargetData * TD; + // Worklist of call sites to transform std::vector Worklist; @@ -54,6 +58,7 @@ virtual void getAnalysisUsage(AnalysisUsage &AU) const { AU.addRequired(); + AU.addRequired(); } // Visitor methods for analyzing instructions Modified: poolalloc/trunk/lib/AssistDS/Devirt.cpp URL: http://llvm.org/viewvc/llvm-project/poolalloc/trunk/lib/AssistDS/Devirt.cpp?rev=110606&r1=110605&r2=110606&view=diff ============================================================================== --- poolalloc/trunk/lib/AssistDS/Devirt.cpp (original) +++ poolalloc/trunk/lib/AssistDS/Devirt.cpp Mon Aug 9 16:27:42 2010 @@ -32,6 +32,21 @@ X ("devirt", "Devirtualize indirect function calls"); // +// Function: getVoidPtrType() +// +// Description: +// Return a pointer to the LLVM type for a void pointer. +// +// Return value: +// A pointer to an LLVM type for the void pointer. +// +static inline +PointerType * getVoidPtrType (LLVMContext & C) { + const Type * Int8Type = IntegerType::getInt8Ty(C); + return PointerType::getUnqual(Int8Type); +} + +// // Function: castTo() // // Description: @@ -111,6 +126,12 @@ } // + // Create an entry basic block for the function. All it should do is perform + // some cast instructions and branch to the first comparison basic block. + // + BasicBlock* entryBB = BasicBlock::Create (M->getContext(), "entry", F); + + // // For each function target, create a basic block that will call that // function directly. // @@ -137,48 +158,70 @@ } // - // Create a set of tests that search for the correct function target - // and call it directly. If none of the target functions match, - // abort (or make the result unreachable). + // Create a failure basic block. This basic block should simply be an + // unreachable instruction. // + BasicBlock * failBB = BasicBlock::Create (M->getContext(), + "fail", + F); + new UnreachableInst (M->getContext(), failBB); // - // Create the failure basic block. This basic block should simply be an - // unreachable instruction. + // Setup the entry basic block. For now, just have it call the failure + // basic block. We'll change the basic block to which it branches later. // - BasicBlock* tail = BasicBlock::Create (M->getContext(), - "fail", - F, - &F->getEntryBlock()); - Instruction * InsertPt; - InsertPt = new UnreachableInst (M->getContext(), tail); - - // - // Create basic blocks for valid target functions. - // - const Type * Int8Type = IntegerType::getInt8Ty(M->getContext()); - const Type * VoidPtrTy = PointerType::getUnqual(Int8Type); - Value * FArg = CastInst::CreateZExtOrBitCast (F->arg_begin(), - VoidPtrTy, - "", - F->getEntryBlock().getTerminator()); + BranchInst * InsertPt = BranchInst::Create (failBB, entryBB); + + // + // Create basic blocks which will test the value of the incoming function + // pointer and branch to the appropriate basic block to call the function. + // + const Type * VoidPtrType = getVoidPtrType (M->getContext()); + Value * FArg = castTo (F->arg_begin(), VoidPtrType, "", InsertPt); + BasicBlock * tailBB = failBB; for (unsigned index = 0; index < Targets.size(); ++index) { + // + // Cast the function pointer to an integer. This can go in the entry + // block. + // + Value * TargetInt = castTo ((Value *)(Targets[index]), + VoidPtrType, + "", + InsertPt); + + // + // Create a new basic block that compares the function pointer to the + // function target. If the function pointer matches, we'll branch to the + // basic block performing the direct call for that function; otherwise, + // we'll branch to the next function call target. + // BasicBlock* TB = targets[Targets[index]]; BasicBlock* newB = BasicBlock::Create (M->getContext(), "test." + Targets[index]->getName(), - F, - &F->getEntryBlock()); - Value * Target = (Value *) Targets[index]; - Target = castTo (Target, VoidPtrTy, "", F->getEntryBlock().getTerminator()); + F); CmpInst * setcc = CmpInst::Create (Instruction::ICmp, CmpInst::ICMP_EQ, - Target, + TargetInt, FArg, "sc", newB); - BranchInst::Create (TB, tail, setcc, newB); - tail = newB; + BranchInst::Create (TB, tailBB, setcc, newB); + + // + // Make this newly created basic block the next block that will be reached + // when the next comparison will need to be done. + // + tailBB = newB; } + + // + // Make the entry basic block branch to the first comparison basic block. + // + InsertPt->setUnconditionalDest (tailBB); + + // + // Return the newly created bounce function. + // return F; } @@ -296,6 +339,11 @@ CTF = &getAnalysis(); // + // Get information on the target system. + // + // + TD = &getAnalysis(); + // Visit all of the call instructions in this function and record those that // are indirect function calls. // From dpatel at apple.com Mon Aug 9 16:39:25 2010 From: dpatel at apple.com (Devang Patel) Date: Mon, 09 Aug 2010 21:39:25 -0000 Subject: [llvm-commits] [llvm] r110607 - in /llvm/trunk: include/llvm/Analysis/DebugInfo.h lib/Analysis/DebugInfo.cpp lib/CodeGen/AsmPrinter/DwarfDebug.cpp Message-ID: <20100809213925.2CF2A2A6C12C@llvm.org> Author: dpatel Date: Mon Aug 9 16:39:24 2010 New Revision: 110607 URL: http://llvm.org/viewvc/llvm-project?rev=110607&view=rev Log: Refactor. Modified: llvm/trunk/include/llvm/Analysis/DebugInfo.h llvm/trunk/lib/Analysis/DebugInfo.cpp llvm/trunk/lib/CodeGen/AsmPrinter/DwarfDebug.cpp Modified: llvm/trunk/include/llvm/Analysis/DebugInfo.h URL: http://llvm.org/viewvc/llvm-project/llvm/trunk/include/llvm/Analysis/DebugInfo.h?rev=110607&r1=110606&r2=110607&view=diff ============================================================================== --- llvm/trunk/include/llvm/Analysis/DebugInfo.h (original) +++ llvm/trunk/include/llvm/Analysis/DebugInfo.h Mon Aug 9 16:39:24 2010 @@ -62,6 +62,7 @@ } GlobalVariable *getGlobalVariableField(unsigned Elt) const; + Constant *getConstantField(unsigned Elt) const; Function *getFunctionField(unsigned Elt) const; public: @@ -447,6 +448,7 @@ unsigned isDefinition() const { return getUnsignedField(10); } GlobalVariable *getGlobal() const { return getGlobalVariableField(11); } + Constant *getConstant() const { return getConstantField(11); } /// Verify - Verify that a global variable descriptor is well formed. bool Verify() const; @@ -696,6 +698,15 @@ unsigned LineNo, DIType Ty, bool isLocalToUnit, bool isDefinition, llvm::GlobalVariable *GV); + /// CreateGlobalVariable - Create a new descriptor for the specified constant. + DIGlobalVariable + CreateGlobalVariable(DIDescriptor Context, StringRef Name, + StringRef DisplayName, + StringRef LinkageName, + DIFile F, + unsigned LineNo, DIType Ty, bool isLocalToUnit, + bool isDefinition, llvm::Constant *C); + /// CreateVariable - Create a new descriptor for the specified variable. DIVariable CreateVariable(unsigned Tag, DIDescriptor Context, StringRef Name, Modified: llvm/trunk/lib/Analysis/DebugInfo.cpp URL: http://llvm.org/viewvc/llvm-project/llvm/trunk/lib/Analysis/DebugInfo.cpp?rev=110607&r1=110606&r2=110607&view=diff ============================================================================== --- llvm/trunk/lib/Analysis/DebugInfo.cpp (original) +++ llvm/trunk/lib/Analysis/DebugInfo.cpp Mon Aug 9 16:39:24 2010 @@ -89,6 +89,15 @@ return 0; } +Constant *DIDescriptor::getConstantField(unsigned Elt) const { + if (DbgNode == 0) + return 0; + + if (Elt < DbgNode->getNumOperands()) + return dyn_cast_or_null(DbgNode->getOperand(Elt)); + return 0; +} + Function *DIDescriptor::getFunctionField(unsigned Elt) const { if (DbgNode == 0) return 0; @@ -341,7 +350,7 @@ if (!Ty.Verify()) return false; - if (!getGlobal()) + if (!getGlobal() && !getConstant()) return false; return true; @@ -1060,6 +1069,38 @@ return DIGlobalVariable(Node); } +/// CreateGlobalVariable - Create a new descriptor for the specified constant. +DIGlobalVariable +DIFactory::CreateGlobalVariable(DIDescriptor Context, StringRef Name, + StringRef DisplayName, + StringRef LinkageName, + DIFile F, + unsigned LineNo, DIType Ty,bool isLocalToUnit, + bool isDefinition, llvm::Constant *Val) { + Value *Elts[] = { + GetTagConstant(dwarf::DW_TAG_variable), + llvm::Constant::getNullValue(Type::getInt32Ty(VMContext)), + Context, + MDString::get(VMContext, Name), + MDString::get(VMContext, DisplayName), + MDString::get(VMContext, LinkageName), + F, + ConstantInt::get(Type::getInt32Ty(VMContext), LineNo), + Ty, + ConstantInt::get(Type::getInt1Ty(VMContext), isLocalToUnit), + ConstantInt::get(Type::getInt1Ty(VMContext), isDefinition), + Val + }; + + Value *const *Vs = &Elts[0]; + MDNode *Node = MDNode::get(VMContext,Vs, 12); + + // Create a named metadata so that we do not lose this mdnode. + NamedMDNode *NMD = M.getOrInsertNamedMetadata("llvm.dbg.gv"); + NMD->addOperand(Node); + + return DIGlobalVariable(Node); +} /// CreateVariable - Create a new descriptor for the specified variable. DIVariable DIFactory::CreateVariable(unsigned Tag, DIDescriptor Context, Modified: llvm/trunk/lib/CodeGen/AsmPrinter/DwarfDebug.cpp URL: http://llvm.org/viewvc/llvm-project/llvm/trunk/lib/CodeGen/AsmPrinter/DwarfDebug.cpp?rev=110607&r1=110606&r2=110607&view=diff ============================================================================== --- llvm/trunk/lib/CodeGen/AsmPrinter/DwarfDebug.cpp (original) +++ llvm/trunk/lib/CodeGen/AsmPrinter/DwarfDebug.cpp Mon Aug 9 16:39:24 2010 @@ -1190,7 +1190,7 @@ DIE *DwarfDebug::createGlobalVariableDIE(const DIGlobalVariable &GV) { // If the global variable was optmized out then no need to create debug info // entry. - if (!GV.getGlobal()) return NULL; + if (!GV.Verify()) return NULL; if (GV.getDisplayName().empty()) return NULL; DIE *GVDie = new DIE(dwarf::DW_TAG_variable); @@ -1908,6 +1908,10 @@ // Add to context owner. DIDescriptor GVContext = DI_GV.getContext(); + DIEBlock *Block = new (DIEValueAllocator) DIEBlock(); + addUInt(Block, 0, dwarf::DW_FORM_data1, dwarf::DW_OP_addr); + addLabel(Block, 0, dwarf::DW_FORM_udata, + Asm->Mang->getSymbol(DI_GV.getGlobal())); // Do not create specification DIE if context is either compile unit // or a subprogram. if (DI_GV.isDefinition() && !GVContext.isCompileUnit() && @@ -1917,18 +1921,10 @@ DIE *VariableSpecDIE = new DIE(dwarf::DW_TAG_variable); addDIEEntry(VariableSpecDIE, dwarf::DW_AT_specification, dwarf::DW_FORM_ref4, VariableDie); - DIEBlock *Block = new (DIEValueAllocator) DIEBlock(); - addUInt(Block, 0, dwarf::DW_FORM_data1, dwarf::DW_OP_addr); - addLabel(Block, 0, dwarf::DW_FORM_udata, - Asm->Mang->getSymbol(DI_GV.getGlobal())); addBlock(VariableSpecDIE, dwarf::DW_AT_location, 0, Block); addUInt(VariableDie, dwarf::DW_AT_declaration, dwarf::DW_FORM_flag, 1); TheCU->addDie(VariableSpecDIE); } else { - DIEBlock *Block = new (DIEValueAllocator) DIEBlock(); - addUInt(Block, 0, dwarf::DW_FORM_data1, dwarf::DW_OP_addr); - addLabel(Block, 0, dwarf::DW_FORM_udata, - Asm->Mang->getSymbol(DI_GV.getGlobal())); addBlock(VariableDie, dwarf::DW_AT_location, 0, Block); } addToContextOwner(VariableDie, GVContext); From wan at google.com Mon Aug 9 16:40:09 2010 From: wan at google.com (=?UTF-8?B?WmhhbnlvbmcgV2FuICjOu3gueCB4KQ==?=) Date: Mon, 9 Aug 2010 14:40:09 -0700 Subject: [llvm-commits] [Patch Proposal] fix unittests on mingw In-Reply-To: References: Message-ID: On Mon, Aug 9, 2010 at 1:52 PM, Nick Lewycky wrote: > Zhanyong, could you review these patches? > > On 9 August 2010 10:23, NAKAMURA Takumi wrote: >> >> Good midnight, everyone. >> >> >> Their patches make "make unittests" fine on mingw. >> >> >> * r110166-unittests-RDYNAMIC.diff.txt >> On cygwin/mingw, this redefines $RDYNAMIC and suppress $RPATH. >> TODO: it should be detected by autoconf. >> >> This enables exporting symbols from Executable.EXE. >> (eg. unittests/JIT) This one is about autotools. Chandler is infinitely better than I am as the reviewer. >> * r106620-unittests-mingw-EXPECT_DEATH.diff.txt >> gtest death test aborts with a desktop dialog on Windows 7. >> I had to suppress death tests on mingw. This change is actually about Haiku. What am I missing? >> r84355-unittests-workaround-msvcrt.diff.txt >> This is workaround for PR6745 and PR7668. >> http://llvm.org/bugs/show_bug.cgi?id=6745 >> (When the issue is resolved, we can meet failure by this patch. >> Then we have to revert it.) This looks good. >> >> >> ...oyasuminasai...Takumi >> >> _______________________________________________ >> llvm-commits mailing list >> llvm-commits at cs.uiuc.edu >> http://lists.cs.uiuc.edu/mailman/listinfo/llvm-commits >> > > -- Zhanyong From echristo at apple.com Mon Aug 9 16:50:24 2010 From: echristo at apple.com (Eric Christopher) Date: Mon, 9 Aug 2010 14:50:24 -0700 Subject: [llvm-commits] [llvm] r110109 - in /llvm/trunk: autoconf/configure.ac cmake/config-ix.cmake configure include/llvm/Config/config.h.cmake include/llvm/Config/config.h.in include/llvm/Target/TargetSelect.h In-Reply-To: <4C5FF93C.1060604@zafena.se> References: <20100803142618.283912A6C12C@llvm.org> <4C5FF93C.1060604@zafena.se> Message-ID: <1314961B-1D9D-4F8B-B077-E9C047066E51@apple.com> On Aug 9, 2010, at 5:49 AM, Xerxes R?nby wrote: > Hi this change have reinstalled llvm pr4427 > http://llvm.org/bugs/show_bug.cgi?id=4427 > > for example when compiling a project that uses llvm JIT on X86 then if > X86 are defined this bug hits when calling > > InitializeNativeTargetAsmPrinter() > > the macro expands into > LLVMInitializeAsmPrinter() that dont exist. > instead of > LLVMInitializeX86AsmPrinter() that do exist. > I've taken the thread to the new bug we've opened for it. -eric From bruno.cardoso at gmail.com Mon Aug 9 16:51:57 2010 From: bruno.cardoso at gmail.com (Bruno Cardoso Lopes) Date: Mon, 09 Aug 2010 21:51:57 -0000 Subject: [llvm-commits] [llvm] r110608 - /llvm/trunk/lib/Target/X86/X86InstrSSE.td Message-ID: <20100809215157.230DE2A6C12C@llvm.org> Author: bruno Date: Mon Aug 9 16:51:56 2010 New Revision: 110608 URL: http://llvm.org/viewvc/llvm-project?rev=110608&view=rev Log: Add VCVTPD2PS, VCVTPS2DQ, VCVTPS2PDY, VCVTTPD2DQY, VCVTTPS2DQ and VCVTPD2DQ 256-bit conversion intrinsics Modified: llvm/trunk/lib/Target/X86/X86InstrSSE.td Modified: llvm/trunk/lib/Target/X86/X86InstrSSE.td URL: http://llvm.org/viewvc/llvm-project/llvm/trunk/lib/Target/X86/X86InstrSSE.td?rev=110608&r1=110607&r2=110608&view=diff ============================================================================== --- llvm/trunk/lib/Target/X86/X86InstrSSE.td (original) +++ llvm/trunk/lib/Target/X86/X86InstrSSE.td Mon Aug 9 16:51:56 2010 @@ -1126,6 +1126,31 @@ def : Pat<(int_x86_avx_cvtdq2_ps_256 (memopv8i32 addr:$src)), (VCVTDQ2PSYrm addr:$src)>; +def : Pat<(int_x86_avx_cvt_pd2_ps_256 VR256:$src), + (VCVTPD2PSYrr VR256:$src)>; +def : Pat<(int_x86_avx_cvt_pd2_ps_256 (memopv4f64 addr:$src)), + (VCVTPD2PSYrm addr:$src)>; + +def : Pat<(int_x86_avx_cvt_ps2dq_256 VR256:$src), + (VCVTPS2DQYrr VR256:$src)>; +def : Pat<(int_x86_avx_cvt_ps2dq_256 (memopv8f32 addr:$src)), + (VCVTPS2DQYrm addr:$src)>; + +def : Pat<(int_x86_avx_cvt_ps2_pd_256 VR128:$src), + (VCVTPS2PDYrr VR128:$src)>; +def : Pat<(int_x86_avx_cvt_ps2_pd_256 (memopv4f32 addr:$src)), + (VCVTPS2PDYrm addr:$src)>; + +def : Pat<(int_x86_avx_cvtt_pd2dq_256 VR256:$src), + (VCVTTPD2DQYrr VR256:$src)>; +def : Pat<(int_x86_avx_cvtt_pd2dq_256 (memopv4f64 addr:$src)), + (VCVTTPD2DQYrm addr:$src)>; + +def : Pat<(int_x86_avx_cvtt_ps2dq_256 VR256:$src), + (VCVTTPS2DQYrr VR256:$src)>; +def : Pat<(int_x86_avx_cvtt_ps2dq_256 (memopv8f32 addr:$src)), + (VCVTTPS2DQYrm addr:$src)>; + //===----------------------------------------------------------------------===// // SSE 1 & 2 - Compare Instructions //===----------------------------------------------------------------------===// @@ -3255,6 +3280,11 @@ def : Pat<(int_x86_avx_cvtdq2_pd_256 (memopv4i32 addr:$src)), (VCVTDQ2PDYrm addr:$src)>; +def : Pat<(int_x86_avx_cvt_pd2dq_256 VR256:$src), + (VCVTPD2DQYrr VR256:$src)>; +def : Pat<(int_x86_avx_cvt_pd2dq_256 (memopv4f64 addr:$src)), + (VCVTPD2DQYrm addr:$src)>; + //===---------------------------------------------------------------------===// // SSE3 - Move Instructions //===---------------------------------------------------------------------===// From wdietz2 at illinois.edu Mon Aug 9 17:19:22 2010 From: wdietz2 at illinois.edu (Will Dietz) Date: Mon, 9 Aug 2010 17:19:22 -0500 Subject: [llvm-commits] [llvm] r110564 - /llvm/trunk/lib/ExecutionEngine/JIT/JIT.cpp In-Reply-To: <20100809072020.4A8062A6C12C@llvm.org> References: <20100809072020.4A8062A6C12C@llvm.org> Message-ID: On Mon, Aug 9, 2010 at 2:20 AM, Nick Lewycky wrote: > Author: nicholas > Date: Mon Aug ?9 02:20:20 2010 > New Revision: 110564 > > URL: http://llvm.org/viewvc/llvm-project?rev=110564&view=rev > Log: > Stop the JIT from refusing to work just because the program it was compiled into > was built with -static. > This change breaks looking up symbols defined in the program itself, at least here it does. Perhaps the right fix is to make reinstate the call removed in this commit, but don't abort/return if it fails? ~Will From wendling at apple.com Mon Aug 9 17:23:59 2010 From: wendling at apple.com (Bill Wendling) Date: Mon, 9 Aug 2010 15:23:59 -0700 Subject: [llvm-commits] [llvm] r110590 - in /llvm/trunk/lib/CodeGen/AsmPrinter: DwarfDebug.cpp DwarfDebug.h In-Reply-To: <20100809202005.9F55C2A6C12C@llvm.org> References: <20100809202005.9F55C2A6C12C@llvm.org> Message-ID: <9587A5EB-550D-46FE-B94B-BDCB20A6B493@apple.com> On Aug 9, 2010, at 1:20 PM, Devang Patel wrote: > Author: dpatel > Date: Mon Aug 9 15:20:05 2010 > New Revision: 110590 > > URL: http://llvm.org/viewvc/llvm-project?rev=110590&view=rev > Log: > It is ok, and convenient, to pass descriptors by value. Why not by reference? -bw From evan.cheng at apple.com Mon Aug 9 17:32:45 2010 From: evan.cheng at apple.com (Evan Cheng) Date: Mon, 09 Aug 2010 22:32:45 -0000 Subject: [llvm-commits] [llvm] r110614 - /llvm/trunk/lib/Target/ARM/ARMBaseRegisterInfo.cpp Message-ID: <20100809223245.2D65A2A6C12C@llvm.org> Author: evancheng Date: Mon Aug 9 17:32:45 2010 New Revision: 110614 URL: http://llvm.org/viewvc/llvm-project?rev=110614&view=rev Log: ARMBaseRegisterInfo::hasFP() has been broken for a while now. :-( This will always be false before PEI: (DisableFramePointerElim(MF) && MFI->adjustsStack()) Which means it's going to make r11 available as a general purpose register even if -disable-fp-elim is specified. It's working on Darwin only because r7 is always reserved. But it's obviously broken for other targets. Modified: llvm/trunk/lib/Target/ARM/ARMBaseRegisterInfo.cpp Modified: llvm/trunk/lib/Target/ARM/ARMBaseRegisterInfo.cpp URL: http://llvm.org/viewvc/llvm-project/llvm/trunk/lib/Target/ARM/ARMBaseRegisterInfo.cpp?rev=110614&r1=110613&r2=110614&view=diff ============================================================================== --- llvm/trunk/lib/Target/ARM/ARMBaseRegisterInfo.cpp (original) +++ llvm/trunk/lib/Target/ARM/ARMBaseRegisterInfo.cpp Mon Aug 9 17:32:45 2010 @@ -611,7 +611,8 @@ /// bool ARMBaseRegisterInfo::hasFP(const MachineFunction &MF) const { const MachineFrameInfo *MFI = MF.getFrameInfo(); - return ((DisableFramePointerElim(MF) && MFI->adjustsStack())|| + // Always eliminate non-leaf frame pointers. + return ((DisableFramePointerElim(MF) && MFI->hasCalls()) || needsStackRealignment(MF) || MFI->hasVarSizedObjects() || MFI->isFrameAddressTaken()); From enderby at apple.com Mon Aug 9 17:52:14 2010 From: enderby at apple.com (Kevin Enderby) Date: Mon, 09 Aug 2010 22:52:14 -0000 Subject: [llvm-commits] [llvm] r110617 - in /llvm/trunk: include/llvm/MC/MCContext.h include/llvm/MC/MCDwarf.h lib/MC/MCContext.cpp lib/MC/MCMachOStreamer.cpp Message-ID: <20100809225214.9B1982A6C12C@llvm.org> Author: enderby Date: Mon Aug 9 17:52:14 2010 New Revision: 110617 URL: http://llvm.org/viewvc/llvm-project?rev=110617&view=rev Log: Next bit of support for the dwarf .file directive. This patch takes the previously collected info from the .file directives and outputs the encoded bytes for it. For now this is only in the Mach-O streamer but at some point will move to a more generic place. Modified: llvm/trunk/include/llvm/MC/MCContext.h llvm/trunk/include/llvm/MC/MCDwarf.h llvm/trunk/lib/MC/MCContext.cpp llvm/trunk/lib/MC/MCMachOStreamer.cpp Modified: llvm/trunk/include/llvm/MC/MCContext.h URL: http://llvm.org/viewvc/llvm-project/llvm/trunk/include/llvm/MC/MCContext.h?rev=110617&r1=110616&r2=110617&view=diff ============================================================================== --- llvm/trunk/include/llvm/MC/MCContext.h (original) +++ llvm/trunk/include/llvm/MC/MCContext.h Mon Aug 9 17:52:14 2010 @@ -151,6 +151,9 @@ const std::vector &getMCDwarfFiles() { return MCDwarfFiles; } + const std::vector &getMCDwarfDirs() { + return MCDwarfDirs; + } /// @} Modified: llvm/trunk/include/llvm/MC/MCDwarf.h URL: http://llvm.org/viewvc/llvm-project/llvm/trunk/include/llvm/MC/MCDwarf.h?rev=110617&r1=110616&r2=110617&view=diff ============================================================================== --- llvm/trunk/include/llvm/MC/MCDwarf.h (original) +++ llvm/trunk/include/llvm/MC/MCDwarf.h Mon Aug 9 17:52:14 2010 @@ -46,6 +46,10 @@ /// getName - Get the base name of this MCDwarfFile. StringRef getName() const { return Name; } + /// getDirIndex - Get the dirIndex of this MCDwarfFile. + unsigned getDirIndex() const { return DirIndex; } + + /// print - Print the value to the stream \arg OS. void print(raw_ostream &OS) const; Modified: llvm/trunk/lib/MC/MCContext.cpp URL: http://llvm.org/viewvc/llvm-project/llvm/trunk/lib/MC/MCContext.cpp?rev=110617&r1=110616&r2=110617&view=diff ============================================================================== --- llvm/trunk/lib/MC/MCContext.cpp (original) +++ llvm/trunk/lib/MC/MCContext.cpp Mon Aug 9 17:52:14 2010 @@ -222,7 +222,7 @@ } else { StringRef Directory = Slash.first; Name = Slash.second; - for (DirIndex = 1; DirIndex < MCDwarfDirs.size(); DirIndex++) { + for (DirIndex = 0; DirIndex < MCDwarfDirs.size(); DirIndex++) { if (Directory == MCDwarfDirs[DirIndex]) break; } @@ -231,6 +231,11 @@ memcpy(Buf, Directory.data(), Directory.size()); MCDwarfDirs.push_back(StringRef(Buf, Directory.size())); } + // The DirIndex is one based, as DirIndex of 0 is used for FileNames with + // no directories. MCDwarfDirs[] is unlike MCDwarfFiles[] in that the + // directory names are stored at MCDwarfDirs[DirIndex-1] where FileNames are + // stored at MCDwarfFiles[FileNumber].Name . + DirIndex++; } // Now make the MCDwarfFile entry and place it in the slot in the MCDwarfFiles Modified: llvm/trunk/lib/MC/MCMachOStreamer.cpp URL: http://llvm.org/viewvc/llvm-project/llvm/trunk/lib/MC/MCMachOStreamer.cpp?rev=110617&r1=110616&r2=110617&view=diff ============================================================================== --- llvm/trunk/lib/MC/MCMachOStreamer.cpp (original) +++ llvm/trunk/lib/MC/MCMachOStreamer.cpp Mon Aug 9 17:52:14 2010 @@ -18,6 +18,8 @@ #include "llvm/MC/MCSection.h" #include "llvm/MC/MCSymbol.h" #include "llvm/MC/MCMachOSymbolFlags.h" +#include "llvm/MC/MCSectionMachO.h" +#include "llvm/MC/MCDwarf.h" #include "llvm/Support/ErrorHandling.h" #include "llvm/Support/raw_ostream.h" #include "llvm/Target/TargetAsmBackend.h" @@ -30,6 +32,10 @@ private: void EmitInstToFragment(const MCInst &Inst); void EmitInstToData(const MCInst &Inst); + // FIXME: These will likely moved to a better place. + const MCExpr * MakeStartMinusEndExpr(MCSymbol *Start, MCSymbol *End, + int IntVal); + void EmitDwarfFileTable(void); public: MCMachOStreamer(MCContext &Context, TargetAsmBackend &TAB, @@ -424,7 +430,156 @@ EmitInstToFragment(Inst); } +// +// This helper routine returns an expression of End - Start + IntVal for use +// by EmitDwarfFileTable() below. +// +const MCExpr * MCMachOStreamer::MakeStartMinusEndExpr(MCSymbol *Start, + MCSymbol *End, + int IntVal) { + MCSymbolRefExpr::VariantKind Variant = MCSymbolRefExpr::VK_None; + const MCExpr *Res = + MCSymbolRefExpr::Create(End, Variant, getContext()); + const MCExpr *RHS = + MCSymbolRefExpr::Create(Start, Variant, getContext()); + const MCExpr *Res1 = + MCBinaryExpr::Create(MCBinaryExpr::Sub, Res, RHS,getContext()); + const MCExpr *Res2 = + MCConstantExpr::Create(IntVal, getContext()); + const MCExpr *Res3 = + MCBinaryExpr::Create(MCBinaryExpr::Sub, Res1, Res2, getContext()); + return Res3; +} + +// +// This emits the Dwarf file (and eventually the line) table. +// +void MCMachOStreamer::EmitDwarfFileTable(void) { + // For now make sure we don't put out the Dwarf file table if no .file + // directives were seen. + const std::vector &MCDwarfFiles = + getContext().getMCDwarfFiles(); + if (MCDwarfFiles.size() == 0) + return; + + // This is the Mach-O section, for ELF it is the .debug_line section. + SwitchSection(getContext().getMachOSection("__DWARF", "__debug_line", + MCSectionMachO::S_ATTR_DEBUG, + 0, SectionKind::getDataRelLocal())); + + // Create a symbol at the beginning of this section. + MCSymbol *LineStartSym = getContext().CreateTempSymbol(); + // Set the value of the symbol, as we are at the start of the section. + EmitLabel(LineStartSym); + + // Create a symbol for the end of the section (to be set when we get there). + MCSymbol *LineEndSym = getContext().CreateTempSymbol(); + + // The first 4 bytes is the total length of the information for this + // compilation unit (not including these 4 bytes for the length). + EmitValue(MakeStartMinusEndExpr(LineStartSym, LineEndSym, 4), 4, 0); + + // Next 2 bytes is the Version, which is Dwarf 2. + EmitIntValue(2, 2); + + // Create a symbol for the end of the prologue (to be set when we get there). + MCSymbol *ProEndSym = getContext().CreateTempSymbol(); // Lprologue_end + + // Length of the prologue, is the next 4 bytes. Which is the start of the + // section to the end of the prologue. Not including the 4 bytes for the + // total length, the 2 bytes for the version, and these 4 bytes for the + // length of the prologue. + EmitValue(MakeStartMinusEndExpr(LineStartSym, ProEndSym, (4 + 2 + 4)), 4, 0); + + // Parameters of the state machine, are next. + // Define the architecture-dependent minimum instruction length (in + // bytes). This value should be rather too small than too big. */ + // DWARF2_LINE_MIN_INSN_LENGTH + EmitIntValue(1, 1); + // Flag that indicates the initial value of the is_stmt_start flag. + // DWARF2_LINE_DEFAULT_IS_STMT + EmitIntValue(1, 1); + // Minimum line offset in a special line info. opcode. This value + // was chosen to give a reasonable range of values. */ + // DWARF2_LINE_BASE + EmitIntValue(-5, 1); + // Range of line offsets in a special line info. opcode. + // DWARF2_LINE_RANGE + EmitIntValue(14, 1); + // First special line opcode - leave room for the standard opcodes. + // DWARF2_LINE_OPCODE_BASE + EmitIntValue(13, 1); + + // Standard opcode lengths + EmitIntValue(0, 1); // length of DW_LNS_copy + EmitIntValue(1, 1); // length of DW_LNS_advance_pc + EmitIntValue(1, 1); // length of DW_LNS_advance_line + EmitIntValue(1, 1); // length of DW_LNS_set_file + EmitIntValue(1, 1); // length of DW_LNS_set_column + EmitIntValue(0, 1); // length of DW_LNS_negate_stmt + EmitIntValue(0, 1); // length of DW_LNS_set_basic_block + EmitIntValue(0, 1); // length of DW_LNS_const_add_pc + EmitIntValue(1, 1); // length of DW_LNS_fixed_advance_pc + EmitIntValue(0, 1); // length of DW_LNS_set_prologue_end + EmitIntValue(0, 1); // length of DW_LNS_set_epilogue_begin + EmitIntValue(1, 1); // DW_LNS_set_isa + + // Put out the directory and file tables. + + // First the directory table. + const std::vector &MCDwarfDirs = + getContext().getMCDwarfDirs(); + for (unsigned i = 0; i < MCDwarfDirs.size(); i++) { + EmitBytes(MCDwarfDirs[i], 0); // the DirectoryName + EmitBytes(StringRef("\0", 1), 0); // the null termination of the string + } + EmitIntValue(0, 1); // Terminate the directory list + + // Second the file table. + for (unsigned i = 1; i < MCDwarfFiles.size(); i++) { + EmitBytes(MCDwarfFiles[i]->getName(), 0); // FileName + EmitBytes(StringRef("\0", 1), 0); // the null termination of the string + // FIXME the Directory number should be a .uleb128 not a .byte + EmitIntValue(MCDwarfFiles[i]->getDirIndex(), 1); + EmitIntValue(0, 1); // last modification timestamp (always 0) + EmitIntValue(0, 1); // filesize (always 0) + } + EmitIntValue(0, 1); // Terminate the file list + + // This is the end of the prologue, so set the value of the symbol at the + // end of the prologue (that was used in a previous expression). + EmitLabel(ProEndSym); + + // TODO: This is the point where the line tables would be emitted. + + // If there are no line tables emited then we emit: + // The following DW_LNE_set_address sequence to set the address to zero + // TODO test for 32-bit or 64-bit output + // This is the sequence for 32-bit code + EmitIntValue(0, 1); + EmitIntValue(5, 1); + EmitIntValue(2, 1); + EmitIntValue(0, 1); + EmitIntValue(0, 1); + EmitIntValue(0, 1); + EmitIntValue(0, 1); + + // Lastly emit the DW_LNE_end_sequence which consists of 3 bytes '00 01 01' + // (00 is the code for extended opcodes, followed by a ULEB128 length of the + // extended opcode (01), and the DW_LNE_end_sequence (01). + EmitIntValue(0, 1); // DW_LNS_extended_op + EmitIntValue(1, 1); // ULEB128 length of the extended opcode + EmitIntValue(1, 1); // DW_LNE_end_sequence + + // This is the end of the section, so set the value of the symbol at the end + // of this section (that was used in a previous expression). + EmitLabel(LineEndSym); +} + void MCMachOStreamer::Finish() { + // Dump out the dwarf file and directory tables (soon to include line table) + EmitDwarfFileTable(); + // We have to set the fragment atom associations so we can relax properly for // Mach-O. From echristo at apple.com Mon Aug 9 17:52:47 2010 From: echristo at apple.com (Eric Christopher) Date: Mon, 09 Aug 2010 22:52:47 -0000 Subject: [llvm-commits] [llvm] r110618 - /llvm/trunk/lib/Target/X86/X86InstrInfo.td Message-ID: <20100809225247.77B512A6C12C@llvm.org> Author: echristo Date: Mon Aug 9 17:52:47 2010 New Revision: 110618 URL: http://llvm.org/viewvc/llvm-project?rev=110618&view=rev Log: Wording. Modified: llvm/trunk/lib/Target/X86/X86InstrInfo.td Modified: llvm/trunk/lib/Target/X86/X86InstrInfo.td URL: http://llvm.org/viewvc/llvm-project/llvm/trunk/lib/Target/X86/X86InstrInfo.td?rev=110618&r1=110617&r2=110618&view=diff ============================================================================== --- llvm/trunk/lib/Target/X86/X86InstrInfo.td (original) +++ llvm/trunk/lib/Target/X86/X86InstrInfo.td Mon Aug 9 17:52:47 2010 @@ -1169,7 +1169,7 @@ // Extra precision multiplication -// AL is really implied by AX, by the registers in Defs must match the +// AL is really implied by AX, but the registers in Defs must match the // SDNode results (i8, i32). let Defs = [AL,EFLAGS,AX], Uses = [AL] in def MUL8r : I<0xF6, MRM4r, (outs), (ins GR8:$src), "mul{b}\t$src", From bob.wilson at apple.com Mon Aug 9 18:01:20 2010 From: bob.wilson at apple.com (Bob Wilson) Date: Mon, 09 Aug 2010 23:01:20 -0000 Subject: [llvm-commits] [llvm-gcc-4.2] r110619 - /llvm-gcc-4.2/trunk/gcc/config/arm/arm.h Message-ID: <20100809230120.E688D2A6C12C@llvm.org> Author: bwilson Date: Mon Aug 9 18:01:20 2010 New Revision: 110619 URL: http://llvm.org/viewvc/llvm-project?rev=110619&view=rev Log: Set "vfp2" feature when using vfp but not vfp3. Radar 8284120. Modified: llvm-gcc-4.2/trunk/gcc/config/arm/arm.h Modified: llvm-gcc-4.2/trunk/gcc/config/arm/arm.h URL: http://llvm.org/viewvc/llvm-project/llvm-gcc-4.2/trunk/gcc/config/arm/arm.h?rev=110619&r1=110618&r2=110619&view=diff ============================================================================== --- llvm-gcc-4.2/trunk/gcc/config/arm/arm.h (original) +++ llvm-gcc-4.2/trunk/gcc/config/arm/arm.h Mon Aug 9 18:01:20 2010 @@ -3503,8 +3503,13 @@ } \ if (TARGET_VFP3) \ F.AddFeature("vfp3"); \ - else \ + else { \ F.AddFeature("vfp3", false); \ + if (TARGET_VFP) \ + F.AddFeature("vfp2"); \ + else \ + F.AddFeature("vfp2", false); \ + } \ if (TARGET_NEON) \ F.AddFeature("neon"); \ else \ From dpatel at apple.com Mon Aug 9 18:26:07 2010 From: dpatel at apple.com (Devang Patel) Date: Mon, 09 Aug 2010 23:26:07 -0000 Subject: [llvm-commits] [llvm] r110621 - in /llvm/trunk/lib/CodeGen/AsmPrinter: DwarfDebug.cpp DwarfDebug.h Message-ID: <20100809232607.1EE462A6C12C@llvm.org> Author: dpatel Date: Mon Aug 9 18:26:06 2010 New Revision: 110621 URL: http://llvm.org/viewvc/llvm-project?rev=110621&view=rev Log: Simplify. Avoid redundant checks. Modified: llvm/trunk/lib/CodeGen/AsmPrinter/DwarfDebug.cpp llvm/trunk/lib/CodeGen/AsmPrinter/DwarfDebug.h Modified: llvm/trunk/lib/CodeGen/AsmPrinter/DwarfDebug.cpp URL: http://llvm.org/viewvc/llvm-project/llvm/trunk/lib/CodeGen/AsmPrinter/DwarfDebug.cpp?rev=110621&r1=110620&r2=110621&view=diff ============================================================================== --- llvm/trunk/lib/CodeGen/AsmPrinter/DwarfDebug.cpp (original) +++ llvm/trunk/lib/CodeGen/AsmPrinter/DwarfDebug.cpp Mon Aug 9 18:26:06 2010 @@ -1186,30 +1186,6 @@ return LinkageName; } -/// createGlobalVariableDIE - Create new DIE using GV. -DIE *DwarfDebug::createGlobalVariableDIE(const DIGlobalVariable &GV) { - // If the global variable was optmized out then no need to create debug info - // entry. - if (!GV.Verify()) return NULL; - if (GV.getDisplayName().empty()) return NULL; - - DIE *GVDie = new DIE(dwarf::DW_TAG_variable); - addString(GVDie, dwarf::DW_AT_name, dwarf::DW_FORM_string, - GV.getDisplayName()); - - StringRef LinkageName = GV.getLinkageName(); - if (!LinkageName.empty()) - addString(GVDie, dwarf::DW_AT_MIPS_linkage_name, dwarf::DW_FORM_string, - getRealLinkageName(LinkageName)); - - addType(GVDie, GV.getType()); - if (!GV.isLocalToUnit()) - addUInt(GVDie, dwarf::DW_AT_external, dwarf::DW_FORM_flag, 1); - addSourceLine(GVDie, GV); - - return GVDie; -} - /// createMemberDIE - Create new member DIE. DIE *DwarfDebug::createMemberDIE(const DIDerivedType &DT) { DIE *MemberDie = new DIE(DT.getTag()); @@ -1888,57 +1864,68 @@ /// constructGlobalVariableDIE - Construct global variable DIE. void DwarfDebug::constructGlobalVariableDIE(const MDNode *N) { - DIGlobalVariable DI_GV(N); + DIGlobalVariable GV(N); // If debug information is malformed then ignore it. - if (DI_GV.Verify() == false) + if (GV.Verify() == false) return; // Check for pre-existence. CompileUnit *TheCU = getCompileUnit(N); - if (TheCU->getDIE(DI_GV)) + if (TheCU->getDIE(GV)) return; - DIE *VariableDie = createGlobalVariableDIE(DI_GV); - if (!VariableDie) - return; + DIType GTy = GV.getType(); + DIE *VariableDIE = new DIE(dwarf::DW_TAG_variable); + // Add name. + addString(VariableDIE, dwarf::DW_AT_name, dwarf::DW_FORM_string, + GV.getDisplayName()); + StringRef LinkageName = GV.getLinkageName(); + if (!LinkageName.empty()) + addString(VariableDIE, dwarf::DW_AT_MIPS_linkage_name, dwarf::DW_FORM_string, + getRealLinkageName(LinkageName)); + // Add type. + addType(VariableDIE, GTy); + if (GTy.isCompositeType() && !GTy.getName().empty() + && !GTy.isForwardDecl()) { + DIEEntry *Entry = TheCU->getDIEEntry(GTy); + assert(Entry && "Missing global type!"); + TheCU->addGlobalType(GTy.getName(), Entry->getEntry()); + } + // Add scoping info. + if (!GV.isLocalToUnit()) { + addUInt(VariableDIE, dwarf::DW_AT_external, dwarf::DW_FORM_flag, 1); + // Expose as global. + TheCU->addGlobal(GV.getName(), VariableDIE); + } + // Add line number info. + addSourceLine(VariableDIE, GV); // Add to map. - TheCU->insertDIE(N, VariableDie); - + TheCU->insertDIE(N, VariableDIE); // Add to context owner. - DIDescriptor GVContext = DI_GV.getContext(); + DIDescriptor GVContext = GV.getContext(); + addToContextOwner(VariableDIE, GVContext); + // Add location. DIEBlock *Block = new (DIEValueAllocator) DIEBlock(); addUInt(Block, 0, dwarf::DW_FORM_data1, dwarf::DW_OP_addr); addLabel(Block, 0, dwarf::DW_FORM_udata, - Asm->Mang->getSymbol(DI_GV.getGlobal())); + Asm->Mang->getSymbol(GV.getGlobal())); // Do not create specification DIE if context is either compile unit // or a subprogram. - if (DI_GV.isDefinition() && !GVContext.isCompileUnit() && - !GVContext.isFile() && - !isSubprogramContext(GVContext)) { + if (GV.isDefinition() && !GVContext.isCompileUnit() && + !GVContext.isFile() && !isSubprogramContext(GVContext)) { // Create specification DIE. DIE *VariableSpecDIE = new DIE(dwarf::DW_TAG_variable); addDIEEntry(VariableSpecDIE, dwarf::DW_AT_specification, - dwarf::DW_FORM_ref4, VariableDie); + dwarf::DW_FORM_ref4, VariableDIE); addBlock(VariableSpecDIE, dwarf::DW_AT_location, 0, Block); - addUInt(VariableDie, dwarf::DW_AT_declaration, dwarf::DW_FORM_flag, 1); + addUInt(VariableDIE, dwarf::DW_AT_declaration, dwarf::DW_FORM_flag, 1); TheCU->addDie(VariableSpecDIE); } else { - addBlock(VariableDie, dwarf::DW_AT_location, 0, Block); + addBlock(VariableDIE, dwarf::DW_AT_location, 0, Block); } - addToContextOwner(VariableDie, GVContext); - // Expose as global. FIXME - need to check external flag. - TheCU->addGlobal(DI_GV.getName(), VariableDie); - - DIType GTy = DI_GV.getType(); - if (GTy.isCompositeType() && !GTy.getName().empty() - && !GTy.isForwardDecl()) { - DIEEntry *Entry = TheCU->getDIEEntry(GTy); - assert(Entry && "Missing global type!"); - TheCU->addGlobalType(GTy.getName(), Entry->getEntry()); - } return; } Modified: llvm/trunk/lib/CodeGen/AsmPrinter/DwarfDebug.h URL: http://llvm.org/viewvc/llvm-project/llvm/trunk/lib/CodeGen/AsmPrinter/DwarfDebug.h?rev=110621&r1=110620&r2=110621&view=diff ============================================================================== --- llvm/trunk/lib/CodeGen/AsmPrinter/DwarfDebug.h (original) +++ llvm/trunk/lib/CodeGen/AsmPrinter/DwarfDebug.h Mon Aug 9 18:26:06 2010 @@ -418,9 +418,6 @@ /// constructEnumTypeDIE - Construct enum type DIE from DIEnumerator. DIE *constructEnumTypeDIE(DIEnumerator ETy); - /// createGlobalVariableDIE - Create new DIE using GV. - DIE *createGlobalVariableDIE(const DIGlobalVariable &GV); - /// createMemberDIE - Create new member DIE. DIE *createMemberDIE(const DIDerivedType &DT); From dpatel at apple.com Mon Aug 9 18:28:52 2010 From: dpatel at apple.com (Devang Patel) Date: Mon, 09 Aug 2010 23:28:52 -0000 Subject: [llvm-commits] [llvm] r110623 - in /llvm/trunk/lib/CodeGen/AsmPrinter: DwarfDebug.cpp DwarfDebug.h Message-ID: <20100809232852.ECD2D2A6C12C@llvm.org> Author: dpatel Date: Mon Aug 9 18:28:52 2010 New Revision: 110623 URL: http://llvm.org/viewvc/llvm-project?rev=110623&view=rev Log: Undo accidental commit. Modified: llvm/trunk/lib/CodeGen/AsmPrinter/DwarfDebug.cpp llvm/trunk/lib/CodeGen/AsmPrinter/DwarfDebug.h Modified: llvm/trunk/lib/CodeGen/AsmPrinter/DwarfDebug.cpp URL: http://llvm.org/viewvc/llvm-project/llvm/trunk/lib/CodeGen/AsmPrinter/DwarfDebug.cpp?rev=110623&r1=110622&r2=110623&view=diff ============================================================================== --- llvm/trunk/lib/CodeGen/AsmPrinter/DwarfDebug.cpp (original) +++ llvm/trunk/lib/CodeGen/AsmPrinter/DwarfDebug.cpp Mon Aug 9 18:28:52 2010 @@ -1186,6 +1186,30 @@ return LinkageName; } +/// createGlobalVariableDIE - Create new DIE using GV. +DIE *DwarfDebug::createGlobalVariableDIE(const DIGlobalVariable &GV) { + // If the global variable was optmized out then no need to create debug info + // entry. + if (!GV.Verify()) return NULL; + if (GV.getDisplayName().empty()) return NULL; + + DIE *GVDie = new DIE(dwarf::DW_TAG_variable); + addString(GVDie, dwarf::DW_AT_name, dwarf::DW_FORM_string, + GV.getDisplayName()); + + StringRef LinkageName = GV.getLinkageName(); + if (!LinkageName.empty()) + addString(GVDie, dwarf::DW_AT_MIPS_linkage_name, dwarf::DW_FORM_string, + getRealLinkageName(LinkageName)); + + addType(GVDie, GV.getType()); + if (!GV.isLocalToUnit()) + addUInt(GVDie, dwarf::DW_AT_external, dwarf::DW_FORM_flag, 1); + addSourceLine(GVDie, GV); + + return GVDie; +} + /// createMemberDIE - Create new member DIE. DIE *DwarfDebug::createMemberDIE(const DIDerivedType &DT) { DIE *MemberDie = new DIE(DT.getTag()); @@ -1864,68 +1888,57 @@ /// constructGlobalVariableDIE - Construct global variable DIE. void DwarfDebug::constructGlobalVariableDIE(const MDNode *N) { - DIGlobalVariable GV(N); + DIGlobalVariable DI_GV(N); // If debug information is malformed then ignore it. - if (GV.Verify() == false) + if (DI_GV.Verify() == false) return; // Check for pre-existence. CompileUnit *TheCU = getCompileUnit(N); - if (TheCU->getDIE(GV)) + if (TheCU->getDIE(DI_GV)) return; - DIType GTy = GV.getType(); - DIE *VariableDIE = new DIE(dwarf::DW_TAG_variable); + DIE *VariableDie = createGlobalVariableDIE(DI_GV); + if (!VariableDie) + return; - // Add name. - addString(VariableDIE, dwarf::DW_AT_name, dwarf::DW_FORM_string, - GV.getDisplayName()); - StringRef LinkageName = GV.getLinkageName(); - if (!LinkageName.empty()) - addString(VariableDIE, dwarf::DW_AT_MIPS_linkage_name, dwarf::DW_FORM_string, - getRealLinkageName(LinkageName)); - // Add type. - addType(VariableDIE, GTy); - if (GTy.isCompositeType() && !GTy.getName().empty() - && !GTy.isForwardDecl()) { - DIEEntry *Entry = TheCU->getDIEEntry(GTy); - assert(Entry && "Missing global type!"); - TheCU->addGlobalType(GTy.getName(), Entry->getEntry()); - } - // Add scoping info. - if (!GV.isLocalToUnit()) { - addUInt(VariableDIE, dwarf::DW_AT_external, dwarf::DW_FORM_flag, 1); - // Expose as global. - TheCU->addGlobal(GV.getName(), VariableDIE); - } - // Add line number info. - addSourceLine(VariableDIE, GV); // Add to map. - TheCU->insertDIE(N, VariableDIE); + TheCU->insertDIE(N, VariableDie); + // Add to context owner. - DIDescriptor GVContext = GV.getContext(); - addToContextOwner(VariableDIE, GVContext); - // Add location. + DIDescriptor GVContext = DI_GV.getContext(); DIEBlock *Block = new (DIEValueAllocator) DIEBlock(); addUInt(Block, 0, dwarf::DW_FORM_data1, dwarf::DW_OP_addr); addLabel(Block, 0, dwarf::DW_FORM_udata, - Asm->Mang->getSymbol(GV.getGlobal())); + Asm->Mang->getSymbol(DI_GV.getGlobal())); // Do not create specification DIE if context is either compile unit // or a subprogram. - if (GV.isDefinition() && !GVContext.isCompileUnit() && - !GVContext.isFile() && !isSubprogramContext(GVContext)) { + if (DI_GV.isDefinition() && !GVContext.isCompileUnit() && + !GVContext.isFile() && + !isSubprogramContext(GVContext)) { // Create specification DIE. DIE *VariableSpecDIE = new DIE(dwarf::DW_TAG_variable); addDIEEntry(VariableSpecDIE, dwarf::DW_AT_specification, - dwarf::DW_FORM_ref4, VariableDIE); + dwarf::DW_FORM_ref4, VariableDie); addBlock(VariableSpecDIE, dwarf::DW_AT_location, 0, Block); - addUInt(VariableDIE, dwarf::DW_AT_declaration, dwarf::DW_FORM_flag, 1); + addUInt(VariableDie, dwarf::DW_AT_declaration, dwarf::DW_FORM_flag, 1); TheCU->addDie(VariableSpecDIE); } else { - addBlock(VariableDIE, dwarf::DW_AT_location, 0, Block); + addBlock(VariableDie, dwarf::DW_AT_location, 0, Block); } + addToContextOwner(VariableDie, GVContext); + // Expose as global. FIXME - need to check external flag. + TheCU->addGlobal(DI_GV.getName(), VariableDie); + + DIType GTy = DI_GV.getType(); + if (GTy.isCompositeType() && !GTy.getName().empty() + && !GTy.isForwardDecl()) { + DIEEntry *Entry = TheCU->getDIEEntry(GTy); + assert(Entry && "Missing global type!"); + TheCU->addGlobalType(GTy.getName(), Entry->getEntry()); + } return; } Modified: llvm/trunk/lib/CodeGen/AsmPrinter/DwarfDebug.h URL: http://llvm.org/viewvc/llvm-project/llvm/trunk/lib/CodeGen/AsmPrinter/DwarfDebug.h?rev=110623&r1=110622&r2=110623&view=diff ============================================================================== --- llvm/trunk/lib/CodeGen/AsmPrinter/DwarfDebug.h (original) +++ llvm/trunk/lib/CodeGen/AsmPrinter/DwarfDebug.h Mon Aug 9 18:28:52 2010 @@ -418,6 +418,9 @@ /// constructEnumTypeDIE - Construct enum type DIE from DIEnumerator. DIE *constructEnumTypeDIE(DIEnumerator ETy); + /// createGlobalVariableDIE - Create new DIE using GV. + DIE *createGlobalVariableDIE(const DIGlobalVariable &GV); + /// createMemberDIE - Create new member DIE. DIE *createMemberDIE(const DIDerivedType &DT); From isanbard at gmail.com Mon Aug 9 18:59:04 2010 From: isanbard at gmail.com (Bill Wendling) Date: Mon, 09 Aug 2010 23:59:04 -0000 Subject: [llvm-commits] [llvm] r110627 - in /llvm/trunk: include/llvm/CodeGen/Passes.h lib/CodeGen/LLVMTargetMachine.cpp lib/CodeGen/OptimizeCmps.cpp lib/CodeGen/OptimizeExts.cpp lib/CodeGen/PeepholeOptimizer.cpp Message-ID: <20100809235904.C7CAD2A6C12C@llvm.org> Author: void Date: Mon Aug 9 18:59:04 2010 New Revision: 110627 URL: http://llvm.org/viewvc/llvm-project?rev=110627&view=rev Log: Merge the OptimizeExts and OptimizeCmps passes into one PeepholeOptimizer pass. This pass should expand with all of the small, fine-grained optimization passes to reduce compile time and increase happiment. Added: llvm/trunk/lib/CodeGen/PeepholeOptimizer.cpp Removed: llvm/trunk/lib/CodeGen/OptimizeCmps.cpp llvm/trunk/lib/CodeGen/OptimizeExts.cpp Modified: llvm/trunk/include/llvm/CodeGen/Passes.h llvm/trunk/lib/CodeGen/LLVMTargetMachine.cpp Modified: llvm/trunk/include/llvm/CodeGen/Passes.h URL: http://llvm.org/viewvc/llvm-project/llvm/trunk/include/llvm/CodeGen/Passes.h?rev=110627&r1=110626&r2=110627&view=diff ============================================================================== --- llvm/trunk/include/llvm/CodeGen/Passes.h (original) +++ llvm/trunk/include/llvm/CodeGen/Passes.h Mon Aug 9 18:59:04 2010 @@ -172,18 +172,14 @@ /// instructions. FunctionPass *createMachineSinkingPass(); - /// createOptimizeExtsPass - This pass performs sign / zero extension - /// optimization by increasing uses of extended values. - FunctionPass *createOptimizeExtsPass(); + /// createPeepholeOptimizerPass - This pass performs peephole optimizations - + /// like extension and comparison eliminations. + FunctionPass *createPeepholeOptimizerPass(); /// createOptimizePHIsPass - This pass optimizes machine instruction PHIs /// to take advantage of opportunities created during DAG legalization. FunctionPass *createOptimizePHIsPass(); - /// createOptimizeCmpsPass - This pass performs redundant comparison removal - /// optimization. - FunctionPass *createOptimizeCmpsPass(); - /// createStackSlotColoringPass - This pass performs stack slot coloring. FunctionPass *createStackSlotColoringPass(bool); Modified: llvm/trunk/lib/CodeGen/LLVMTargetMachine.cpp URL: http://llvm.org/viewvc/llvm-project/llvm/trunk/lib/CodeGen/LLVMTargetMachine.cpp?rev=110627&r1=110626&r2=110627&view=diff ============================================================================== --- llvm/trunk/lib/CodeGen/LLVMTargetMachine.cpp (original) +++ llvm/trunk/lib/CodeGen/LLVMTargetMachine.cpp Mon Aug 9 18:59:04 2010 @@ -353,8 +353,7 @@ PM.add(createDeadMachineInstructionElimPass()); printAndVerify(PM, "After codegen DCE pass"); - PM.add(createOptimizeExtsPass()); - PM.add(createOptimizeCmpsPass()); + PM.add(createPeepholeOptimizerPass()); if (!DisableMachineLICM) PM.add(createMachineLICMPass()); PM.add(createMachineCSEPass()); Removed: llvm/trunk/lib/CodeGen/OptimizeCmps.cpp URL: http://llvm.org/viewvc/llvm-project/llvm/trunk/lib/CodeGen/OptimizeCmps.cpp?rev=110626&view=auto ============================================================================== --- llvm/trunk/lib/CodeGen/OptimizeCmps.cpp (original) +++ llvm/trunk/lib/CodeGen/OptimizeCmps.cpp (removed) @@ -1,112 +0,0 @@ -//===-- OptimizeCmps.cpp - Optimize comparison instrs ---------------------===// -// -// The LLVM Compiler Infrastructure -// -// This file is distributed under the University of Illinois Open Source -// License. See LICENSE.TXT for details. -// -//===----------------------------------------------------------------------===// -// -// This pass performs optimization of comparison instructions. For instance, in -// this code: -// -// sub r1, 1 -// cmp r1, 0 -// bz L1 -// -// If the "sub" instruction all ready sets (or could be modified to set) the -// same flag that the "cmp" instruction sets and that "bz" uses, then we can -// eliminate the "cmp" instruction. -// -//===----------------------------------------------------------------------===// - -#define DEBUG_TYPE "opt-compares" -#include "llvm/CodeGen/Passes.h" -#include "llvm/CodeGen/MachineFunctionPass.h" -#include "llvm/CodeGen/MachineInstrBuilder.h" -#include "llvm/CodeGen/MachineRegisterInfo.h" -#include "llvm/Target/TargetInstrInfo.h" -#include "llvm/Target/TargetRegisterInfo.h" -#include "llvm/Support/CommandLine.h" -#include "llvm/ADT/Statistic.h" -using namespace llvm; - -STATISTIC(NumEliminated, "Number of compares eliminated"); - -static cl::opt -EnableOptCmps("enable-optimize-cmps", cl::init(false), cl::Hidden); - -namespace { - class OptimizeCmps : public MachineFunctionPass { - const TargetMachine *TM; - const TargetInstrInfo *TII; - MachineRegisterInfo *MRI; - - bool OptimizeCmpInstr(MachineInstr *MI, MachineBasicBlock *MBB); - - public: - static char ID; // Pass identification - OptimizeCmps() : MachineFunctionPass(ID) {} - - virtual bool runOnMachineFunction(MachineFunction &MF); - - virtual void getAnalysisUsage(AnalysisUsage &AU) const { - AU.setPreservesCFG(); - MachineFunctionPass::getAnalysisUsage(AU); - } - }; -} - -char OptimizeCmps::ID = 0; -INITIALIZE_PASS(OptimizeCmps, "opt-cmps", - "Optimize comparison instrs", false, false); - -FunctionPass *llvm::createOptimizeCmpsPass() { return new OptimizeCmps(); } - -/// OptimizeCmpInstr - If the instruction is a compare and the previous -/// instruction it's comparing against all ready sets (or could be modified to -/// set) the same flag as the compare, then we can remove the comparison and use -/// the flag from the previous instruction. -bool OptimizeCmps::OptimizeCmpInstr(MachineInstr *MI, MachineBasicBlock *MBB) { - // If this instruction is a comparison against zero and isn't comparing a - // physical register, we can try to optimize it. - unsigned SrcReg; - int CmpValue; - if (!TII->AnalyzeCompare(MI, SrcReg, CmpValue) || - TargetRegisterInfo::isPhysicalRegister(SrcReg) || CmpValue != 0) - return false; - - MachineRegisterInfo::def_iterator DI = MRI->def_begin(SrcReg); - if (llvm::next(DI) != MRI->def_end()) - // Only support one definition. - return false; - - // Attempt to convert the defining instruction to set the "zero" flag. - if (TII->ConvertToSetZeroFlag(&*DI, MI)) { - ++NumEliminated; - return true; - } - - return false; -} - -bool OptimizeCmps::runOnMachineFunction(MachineFunction &MF) { - TM = &MF.getTarget(); - TII = TM->getInstrInfo(); - MRI = &MF.getRegInfo(); - - if (!EnableOptCmps) return false; - - bool Changed = false; - for (MachineFunction::iterator I = MF.begin(), E = MF.end(); I != E; ++I) { - MachineBasicBlock *MBB = &*I; - for (MachineBasicBlock::iterator - MII = MBB->begin(), ME = MBB->end(); MII != ME; ) { - MachineInstr *MI = &*MII++; - if (MI->getDesc().isCompare()) - Changed |= OptimizeCmpInstr(MI, MBB); - } - } - - return Changed; -} Removed: llvm/trunk/lib/CodeGen/OptimizeExts.cpp URL: http://llvm.org/viewvc/llvm-project/llvm/trunk/lib/CodeGen/OptimizeExts.cpp?rev=110626&view=auto ============================================================================== --- llvm/trunk/lib/CodeGen/OptimizeExts.cpp (original) +++ llvm/trunk/lib/CodeGen/OptimizeExts.cpp (removed) @@ -1,221 +0,0 @@ -//===-- OptimizeExts.cpp - Optimize sign / zero extension instrs -----===// -// -// The LLVM Compiler Infrastructure -// -// This file is distributed under the University of Illinois Open Source -// License. See LICENSE.TXT for details. -// -//===----------------------------------------------------------------------===// -// -// This pass performs optimization of sign / zero extension instructions. It -// may be extended to handle other instructions of similar property. -// -// On some targets, some instructions, e.g. X86 sign / zero extension, may -// leave the source value in the lower part of the result. This pass will -// replace (some) uses of the pre-extension value with uses of the sub-register -// of the results. -// -//===----------------------------------------------------------------------===// - -#define DEBUG_TYPE "ext-opt" -#include "llvm/CodeGen/Passes.h" -#include "llvm/CodeGen/MachineDominators.h" -#include "llvm/CodeGen/MachineInstrBuilder.h" -#include "llvm/CodeGen/MachineRegisterInfo.h" -#include "llvm/Target/TargetInstrInfo.h" -#include "llvm/Target/TargetRegisterInfo.h" -#include "llvm/Support/CommandLine.h" -#include "llvm/ADT/SmallPtrSet.h" -#include "llvm/ADT/Statistic.h" -using namespace llvm; - -static cl::opt Aggressive("aggressive-ext-opt", cl::Hidden, - cl::desc("Aggressive extension optimization")); - -STATISTIC(NumReuse, "Number of extension results reused"); - -namespace { - class OptimizeExts : public MachineFunctionPass { - const TargetMachine *TM; - const TargetInstrInfo *TII; - MachineRegisterInfo *MRI; - MachineDominatorTree *DT; // Machine dominator tree - - public: - static char ID; // Pass identification - OptimizeExts() : MachineFunctionPass(ID) {} - - virtual bool runOnMachineFunction(MachineFunction &MF); - - virtual void getAnalysisUsage(AnalysisUsage &AU) const { - AU.setPreservesCFG(); - MachineFunctionPass::getAnalysisUsage(AU); - if (Aggressive) { - AU.addRequired(); - AU.addPreserved(); - } - } - - private: - bool OptimizeInstr(MachineInstr *MI, MachineBasicBlock *MBB, - SmallPtrSet &LocalMIs); - }; -} - -char OptimizeExts::ID = 0; -INITIALIZE_PASS(OptimizeExts, "opt-exts", - "Optimize sign / zero extensions", false, false); - -FunctionPass *llvm::createOptimizeExtsPass() { return new OptimizeExts(); } - -/// OptimizeInstr - If instruction is a copy-like instruction, i.e. it reads -/// a single register and writes a single register and it does not modify -/// the source, and if the source value is preserved as a sub-register of -/// the result, then replace all reachable uses of the source with the subreg -/// of the result. -/// Do not generate an EXTRACT that is used only in a debug use, as this -/// changes the code. Since this code does not currently share EXTRACTs, just -/// ignore all debug uses. -bool OptimizeExts::OptimizeInstr(MachineInstr *MI, MachineBasicBlock *MBB, - SmallPtrSet &LocalMIs) { - LocalMIs.insert(MI); - - unsigned SrcReg, DstReg, SubIdx; - if (!TII->isCoalescableExtInstr(*MI, SrcReg, DstReg, SubIdx)) - return false; - - if (TargetRegisterInfo::isPhysicalRegister(DstReg) || - TargetRegisterInfo::isPhysicalRegister(SrcReg)) - return false; - - MachineRegisterInfo::use_nodbg_iterator UI = MRI->use_nodbg_begin(SrcReg); - if (++UI == MRI->use_nodbg_end()) - // No other uses. - return false; - - // Ok, the source has other uses. See if we can replace the other uses - // with use of the result of the extension. - SmallPtrSet ReachedBBs; - UI = MRI->use_nodbg_begin(DstReg); - for (MachineRegisterInfo::use_nodbg_iterator UE = MRI->use_nodbg_end(); - UI != UE; ++UI) - ReachedBBs.insert(UI->getParent()); - - bool ExtendLife = true; - // Uses that are in the same BB of uses of the result of the instruction. - SmallVector Uses; - // Uses that the result of the instruction can reach. - SmallVector ExtendedUses; - - UI = MRI->use_nodbg_begin(SrcReg); - for (MachineRegisterInfo::use_nodbg_iterator UE = MRI->use_nodbg_end(); - UI != UE; ++UI) { - MachineOperand &UseMO = UI.getOperand(); - MachineInstr *UseMI = &*UI; - if (UseMI == MI) - continue; - if (UseMI->isPHI()) { - ExtendLife = false; - continue; - } - - // It's an error to translate this: - // - // %reg1025 = %reg1024 - // ... - // %reg1026 = SUBREG_TO_REG 0, %reg1024, 4 - // - // into this: - // - // %reg1025 = %reg1024 - // ... - // %reg1027 = COPY %reg1025:4 - // %reg1026 = SUBREG_TO_REG 0, %reg1027, 4 - // - // The problem here is that SUBREG_TO_REG is there to assert that an - // implicit zext occurs. It doesn't insert a zext instruction. If we allow - // the COPY here, it will give us the value after the , not the - // original value of %reg1024 before . - if (UseMI->getOpcode() == TargetOpcode::SUBREG_TO_REG) - continue; - - MachineBasicBlock *UseMBB = UseMI->getParent(); - if (UseMBB == MBB) { - // Local uses that come after the extension. - if (!LocalMIs.count(UseMI)) - Uses.push_back(&UseMO); - } else if (ReachedBBs.count(UseMBB)) - // Non-local uses where the result of extension is used. Always replace - // these unless it's a PHI. - Uses.push_back(&UseMO); - else if (Aggressive && DT->dominates(MBB, UseMBB)) - // We may want to extend live range of the extension result in order to - // replace these uses. - ExtendedUses.push_back(&UseMO); - else { - // Both will be live out of the def MBB anyway. Don't extend live range of - // the extension result. - ExtendLife = false; - break; - } - } - - if (ExtendLife && !ExtendedUses.empty()) - // Ok, we'll extend the liveness of the extension result. - std::copy(ExtendedUses.begin(), ExtendedUses.end(), - std::back_inserter(Uses)); - - // Now replace all uses. - bool Changed = false; - if (!Uses.empty()) { - SmallPtrSet PHIBBs; - // Look for PHI uses of the extended result, we don't want to extend the - // liveness of a PHI input. It breaks all kinds of assumptions down - // stream. A PHI use is expected to be the kill of its source values. - UI = MRI->use_nodbg_begin(DstReg); - for (MachineRegisterInfo::use_nodbg_iterator UE = MRI->use_nodbg_end(); - UI != UE; ++UI) - if (UI->isPHI()) - PHIBBs.insert(UI->getParent()); - - const TargetRegisterClass *RC = MRI->getRegClass(SrcReg); - for (unsigned i = 0, e = Uses.size(); i != e; ++i) { - MachineOperand *UseMO = Uses[i]; - MachineInstr *UseMI = UseMO->getParent(); - MachineBasicBlock *UseMBB = UseMI->getParent(); - if (PHIBBs.count(UseMBB)) - continue; - unsigned NewVR = MRI->createVirtualRegister(RC); - BuildMI(*UseMBB, UseMI, UseMI->getDebugLoc(), - TII->get(TargetOpcode::COPY), NewVR) - .addReg(DstReg, 0, SubIdx); - UseMO->setReg(NewVR); - ++NumReuse; - Changed = true; - } - } - - return Changed; -} - -bool OptimizeExts::runOnMachineFunction(MachineFunction &MF) { - TM = &MF.getTarget(); - TII = TM->getInstrInfo(); - MRI = &MF.getRegInfo(); - DT = Aggressive ? &getAnalysis() : 0; - - bool Changed = false; - - SmallPtrSet LocalMIs; - for (MachineFunction::iterator I = MF.begin(), E = MF.end(); I != E; ++I) { - MachineBasicBlock *MBB = &*I; - LocalMIs.clear(); - for (MachineBasicBlock::iterator MII = I->begin(), ME = I->end(); MII != ME; - ++MII) { - MachineInstr *MI = &*MII; - Changed |= OptimizeInstr(MI, MBB, LocalMIs); - } - } - - return Changed; -} Added: llvm/trunk/lib/CodeGen/PeepholeOptimizer.cpp URL: http://llvm.org/viewvc/llvm-project/llvm/trunk/lib/CodeGen/PeepholeOptimizer.cpp?rev=110627&view=auto ============================================================================== --- llvm/trunk/lib/CodeGen/PeepholeOptimizer.cpp (added) +++ llvm/trunk/lib/CodeGen/PeepholeOptimizer.cpp Mon Aug 9 18:59:04 2010 @@ -0,0 +1,293 @@ +//===-- PeepholeOptimizer.cpp - Peephole Optimizations --------------------===// +// +// The LLVM Compiler Infrastructure +// +// This file is distributed under the University of Illinois Open Source +// License. See LICENSE.TXT for details. +// +//===----------------------------------------------------------------------===// +// +// Perform peephole optimizations on the machine code: +// +// - Optimize Extensions +// +// Optimization of sign / zero extension instructions. It may be extended to +// handle other instructions with similar properties. +// +// On some targets, some instructions, e.g. X86 sign / zero extension, may +// leave the source value in the lower part of the result. This optimization +// will replace some uses of the pre-extension value with uses of the +// sub-register of the results. +// +// - Optimize Comparisons +// +// Optimization of comparison instructions. For instance, in this code: +// +// sub r1, 1 +// cmp r1, 0 +// bz L1 +// +// If the "sub" instruction all ready sets (or could be modified to set) the +// same flag that the "cmp" instruction sets and that "bz" uses, then we can +// eliminate the "cmp" instruction. +// +//===----------------------------------------------------------------------===// + +#define DEBUG_TYPE "peephole-opt" +#include "llvm/CodeGen/Passes.h" +#include "llvm/CodeGen/MachineDominators.h" +#include "llvm/CodeGen/MachineInstrBuilder.h" +#include "llvm/CodeGen/MachineRegisterInfo.h" +#include "llvm/Target/TargetInstrInfo.h" +#include "llvm/Target/TargetRegisterInfo.h" +#include "llvm/Support/CommandLine.h" +#include "llvm/ADT/SmallPtrSet.h" +#include "llvm/ADT/Statistic.h" +using namespace llvm; + +// Optimize Extensions +static cl::opt +Aggressive("aggressive-ext-opt", cl::Hidden, + cl::desc("Aggressive extension optimization")); + +STATISTIC(NumReuse, "Number of extension results reused"); + +// Optimize Comparisons +static cl::opt +EnableOptCmps("enable-optimize-cmps", cl::init(false), cl::Hidden); + +STATISTIC(NumEliminated, "Number of compares eliminated"); + +namespace { + class PeepholeOptimizer : public MachineFunctionPass { + const TargetMachine *TM; + const TargetInstrInfo *TII; + MachineRegisterInfo *MRI; + MachineDominatorTree *DT; // Machine dominator tree + + public: + static char ID; // Pass identification + PeepholeOptimizer() : MachineFunctionPass(ID) {} + + virtual bool runOnMachineFunction(MachineFunction &MF); + + virtual void getAnalysisUsage(AnalysisUsage &AU) const { + AU.setPreservesCFG(); + MachineFunctionPass::getAnalysisUsage(AU); + if (Aggressive) { + AU.addRequired(); + AU.addPreserved(); + } + } + + private: + bool OptimizeCmpInstr(MachineInstr *MI, MachineBasicBlock *MBB); + bool OptimizeExtInstr(MachineInstr *MI, MachineBasicBlock *MBB, + SmallPtrSet &LocalMIs); + }; +} + +char PeepholeOptimizer::ID = 0; +INITIALIZE_PASS(PeepholeOptimizer, "peephole-opts", + "Peephole Optimizations", false, false); + +FunctionPass *llvm::createPeepholeOptimizerPass() { + return new PeepholeOptimizer(); +} + +/// OptimizeExtInstr - If instruction is a copy-like instruction, i.e. it reads +/// a single register and writes a single register and it does not modify the +/// source, and if the source value is preserved as a sub-register of the +/// result, then replace all reachable uses of the source with the subreg of the +/// result. +/// +/// Do not generate an EXTRACT that is used only in a debug use, as this changes +/// the code. Since this code does not currently share EXTRACTs, just ignore all +/// debug uses. +bool PeepholeOptimizer:: +OptimizeExtInstr(MachineInstr *MI, MachineBasicBlock *MBB, + SmallPtrSet &LocalMIs) { + LocalMIs.insert(MI); + + unsigned SrcReg, DstReg, SubIdx; + if (!TII->isCoalescableExtInstr(*MI, SrcReg, DstReg, SubIdx)) + return false; + + if (TargetRegisterInfo::isPhysicalRegister(DstReg) || + TargetRegisterInfo::isPhysicalRegister(SrcReg)) + return false; + + MachineRegisterInfo::use_nodbg_iterator UI = MRI->use_nodbg_begin(SrcReg); + if (++UI == MRI->use_nodbg_end()) + // No other uses. + return false; + + // The source has other uses. See if we can replace the other uses with use of + // the result of the extension. + SmallPtrSet ReachedBBs; + UI = MRI->use_nodbg_begin(DstReg); + for (MachineRegisterInfo::use_nodbg_iterator UE = MRI->use_nodbg_end(); + UI != UE; ++UI) + ReachedBBs.insert(UI->getParent()); + + // Uses that are in the same BB of uses of the result of the instruction. + SmallVector Uses; + + // Uses that the result of the instruction can reach. + SmallVector ExtendedUses; + + bool ExtendLife = true; + UI = MRI->use_nodbg_begin(SrcReg); + for (MachineRegisterInfo::use_nodbg_iterator UE = MRI->use_nodbg_end(); + UI != UE; ++UI) { + MachineOperand &UseMO = UI.getOperand(); + MachineInstr *UseMI = &*UI; + if (UseMI == MI) + continue; + + if (UseMI->isPHI()) { + ExtendLife = false; + continue; + } + + // It's an error to translate this: + // + // %reg1025 = %reg1024 + // ... + // %reg1026 = SUBREG_TO_REG 0, %reg1024, 4 + // + // into this: + // + // %reg1025 = %reg1024 + // ... + // %reg1027 = COPY %reg1025:4 + // %reg1026 = SUBREG_TO_REG 0, %reg1027, 4 + // + // The problem here is that SUBREG_TO_REG is there to assert that an + // implicit zext occurs. It doesn't insert a zext instruction. If we allow + // the COPY here, it will give us the value after the , not the + // original value of %reg1024 before . + if (UseMI->getOpcode() == TargetOpcode::SUBREG_TO_REG) + continue; + + MachineBasicBlock *UseMBB = UseMI->getParent(); + if (UseMBB == MBB) { + // Local uses that come after the extension. + if (!LocalMIs.count(UseMI)) + Uses.push_back(&UseMO); + } else if (ReachedBBs.count(UseMBB)) { + // Non-local uses where the result of the extension is used. Always + // replace these unless it's a PHI. + Uses.push_back(&UseMO); + } else if (Aggressive && DT->dominates(MBB, UseMBB)) { + // We may want to extend the live range of the extension result in order + // to replace these uses. + ExtendedUses.push_back(&UseMO); + } else { + // Both will be live out of the def MBB anyway. Don't extend live range of + // the extension result. + ExtendLife = false; + break; + } + } + + if (ExtendLife && !ExtendedUses.empty()) + // Extend the liveness of the extension result. + std::copy(ExtendedUses.begin(), ExtendedUses.end(), + std::back_inserter(Uses)); + + // Now replace all uses. + bool Changed = false; + if (!Uses.empty()) { + SmallPtrSet PHIBBs; + + // Look for PHI uses of the extended result, we don't want to extend the + // liveness of a PHI input. It breaks all kinds of assumptions down + // stream. A PHI use is expected to be the kill of its source values. + UI = MRI->use_nodbg_begin(DstReg); + for (MachineRegisterInfo::use_nodbg_iterator + UE = MRI->use_nodbg_end(); UI != UE; ++UI) + if (UI->isPHI()) + PHIBBs.insert(UI->getParent()); + + const TargetRegisterClass *RC = MRI->getRegClass(SrcReg); + for (unsigned i = 0, e = Uses.size(); i != e; ++i) { + MachineOperand *UseMO = Uses[i]; + MachineInstr *UseMI = UseMO->getParent(); + MachineBasicBlock *UseMBB = UseMI->getParent(); + if (PHIBBs.count(UseMBB)) + continue; + + unsigned NewVR = MRI->createVirtualRegister(RC); + BuildMI(*UseMBB, UseMI, UseMI->getDebugLoc(), + TII->get(TargetOpcode::COPY), NewVR) + .addReg(DstReg, 0, SubIdx); + + UseMO->setReg(NewVR); + ++NumReuse; + Changed = true; + } + } + + return Changed; +} + +/// OptimizeCmpInstr - If the instruction is a compare and the previous +/// instruction it's comparing against all ready sets (or could be modified to +/// set) the same flag as the compare, then we can remove the comparison and use +/// the flag from the previous instruction. +bool PeepholeOptimizer::OptimizeCmpInstr(MachineInstr *MI, + MachineBasicBlock *MBB) { + if (!EnableOptCmps) return false; + + // If this instruction is a comparison against zero and isn't comparing a + // physical register, we can try to optimize it. + unsigned SrcReg; + int CmpValue; + if (!TII->AnalyzeCompare(MI, SrcReg, CmpValue) || + TargetRegisterInfo::isPhysicalRegister(SrcReg) || CmpValue != 0) + return false; + + MachineRegisterInfo::def_iterator DI = MRI->def_begin(SrcReg); + if (llvm::next(DI) != MRI->def_end()) + // Only support one definition. + return false; + + // Attempt to convert the defining instruction to set the "zero" flag. + if (TII->ConvertToSetZeroFlag(&*DI, MI)) { + ++NumEliminated; + return true; + } + + return false; +} + +bool PeepholeOptimizer::runOnMachineFunction(MachineFunction &MF) { + TM = &MF.getTarget(); + TII = TM->getInstrInfo(); + MRI = &MF.getRegInfo(); + DT = Aggressive ? &getAnalysis() : 0; + + bool Changed = false; + + SmallPtrSet LocalMIs; + for (MachineFunction::iterator I = MF.begin(), E = MF.end(); I != E; ++I) { + MachineBasicBlock *MBB = &*I; + LocalMIs.clear(); + + for (MachineBasicBlock::iterator + MII = I->begin(), ME = I->end(); MII != ME; ) { + MachineInstr *MI = &*MII; + + if (MI->getDesc().isCompare()) { + ++MII; // The iterator may become invalid if the compare is deleted. + Changed |= OptimizeCmpInstr(MI, MBB); + } else { + Changed |= OptimizeExtInstr(MI, MBB, LocalMIs); + ++MII; + } + } + } + + return Changed; +} From bruno.cardoso at gmail.com Mon Aug 9 19:00:22 2010 From: bruno.cardoso at gmail.com (Bruno Cardoso Lopes) Date: Tue, 10 Aug 2010 00:00:22 -0000 Subject: [llvm-commits] [llvm] r110628 - /llvm/trunk/include/llvm/IntrinsicsX86.td Message-ID: <20100810000022.6EC7E2A6C12C@llvm.org> Author: bruno Date: Mon Aug 9 19:00:22 2010 New Revision: 110628 URL: http://llvm.org/viewvc/llvm-project?rev=110628&view=rev Log: Fix the last argument type of AVX vblend intrinsics Modified: llvm/trunk/include/llvm/IntrinsicsX86.td Modified: llvm/trunk/include/llvm/IntrinsicsX86.td URL: http://llvm.org/viewvc/llvm-project/llvm/trunk/include/llvm/IntrinsicsX86.td?rev=110628&r1=110627&r2=110628&view=diff ============================================================================== --- llvm/trunk/include/llvm/IntrinsicsX86.td (original) +++ llvm/trunk/include/llvm/IntrinsicsX86.td Mon Aug 9 19:00:22 2010 @@ -1089,10 +1089,10 @@ let TargetPrefix = "x86" in { // All intrinsics start with "llvm.x86.". def int_x86_avx_blend_pd_256 : GCCBuiltin<"__builtin_ia32_blendpd256">, Intrinsic<[llvm_v4f64_ty], [llvm_v4f64_ty, - llvm_v4f64_ty, llvm_i8_ty], [IntrNoMem]>; + llvm_v4f64_ty, llvm_i32_ty], [IntrNoMem]>; def int_x86_avx_blend_ps_256 : GCCBuiltin<"__builtin_ia32_blendps256">, Intrinsic<[llvm_v8f32_ty], [llvm_v8f32_ty, - llvm_v8f32_ty, llvm_i8_ty], [IntrNoMem]>; + llvm_v8f32_ty, llvm_i32_ty], [IntrNoMem]>; def int_x86_avx_blendv_pd_256 : GCCBuiltin<"__builtin_ia32_blendvpd256">, Intrinsic<[llvm_v4f64_ty], [llvm_v4f64_ty, llvm_v4f64_ty, llvm_v4f64_ty], [IntrNoMem]>; From bruno.cardoso at gmail.com Mon Aug 9 19:02:05 2010 From: bruno.cardoso at gmail.com (Bruno Cardoso Lopes) Date: Tue, 10 Aug 2010 00:02:05 -0000 Subject: [llvm-commits] [llvm] r110630 - /llvm/trunk/lib/Target/X86/X86InstrSSE.td Message-ID: <20100810000205.81AE82A6C12C@llvm.org> Author: bruno Date: Mon Aug 9 19:02:05 2010 New Revision: 110630 URL: http://llvm.org/viewvc/llvm-project?rev=110630&view=rev Log: Add matching patterns for vblend AVX intrinsics Modified: llvm/trunk/lib/Target/X86/X86InstrSSE.td Modified: llvm/trunk/lib/Target/X86/X86InstrSSE.td URL: http://llvm.org/viewvc/llvm-project/llvm/trunk/lib/Target/X86/X86InstrSSE.td?rev=110630&r1=110629&r2=110630&view=diff ============================================================================== --- llvm/trunk/lib/Target/X86/X86InstrSSE.td (original) +++ llvm/trunk/lib/Target/X86/X86InstrSSE.td Mon Aug 9 19:02:05 2010 @@ -4822,12 +4822,10 @@ VR128, memopv16i8, i128mem, 0>, VEX_4V; defm VBLENDPD : SS41I_binop_rmi_int<0x0D, "vblendpd", int_x86_sse41_blendpd, VR128, memopv16i8, i128mem, 0>, VEX_4V; - let Pattern = [] in { - defm VBLENDPSY : SS41I_binop_rmi_int<0x0C, "vblendps", int_x86_sse41_blendps, - VR256, memopv32i8, i256mem, 0>, VEX_4V; - defm VBLENDPDY : SS41I_binop_rmi_int<0x0D, "vblendpd", int_x86_sse41_blendpd, - VR256, memopv32i8, i256mem, 0>, VEX_4V; - } + defm VBLENDPSY : SS41I_binop_rmi_int<0x0C, "vblendps", + int_x86_avx_blend_ps_256, VR256, memopv32i8, i256mem, 0>, VEX_4V; + defm VBLENDPDY : SS41I_binop_rmi_int<0x0D, "vblendpd", + int_x86_avx_blend_pd_256, VR256, memopv32i8, i256mem, 0>, VEX_4V; defm VPBLENDW : SS41I_binop_rmi_int<0x0E, "vpblendw", int_x86_sse41_pblendw, VR128, memopv16i8, i128mem, 0>, VEX_4V; defm VMPSADBW : SS41I_binop_rmi_int<0x42, "vmpsadbw", int_x86_sse41_mpsadbw, @@ -4888,13 +4886,10 @@ memopv16i8, int_x86_sse41_blendvps>; defm VPBLENDVB : SS41I_quaternary_int_avx<0x4C, "vpblendvb", VR128, i128mem, memopv16i8, int_x86_sse41_pblendvb>; - -let Pattern = [] in { // FIXME: implement 256 intrinsics here. defm VBLENDVPDY : SS41I_quaternary_int_avx<0x4B, "vblendvpd", VR256, i256mem, - memopv32i8, int_x86_sse41_blendvpd>; + memopv32i8, int_x86_avx_blendv_pd_256>; defm VBLENDVPSY : SS41I_quaternary_int_avx<0x4A, "vblendvps", VR256, i256mem, - memopv32i8, int_x86_sse41_blendvps>; -} + memopv32i8, int_x86_avx_blendv_ps_256>; /// SS41I_ternary_int - SSE 4.1 ternary operator let Uses = [XMM0], Constraints = "$src1 = $dst" in { From stoklund at 2pi.dk Mon Aug 9 19:02:26 2010 From: stoklund at 2pi.dk (Jakob Stoklund Olesen) Date: Tue, 10 Aug 2010 00:02:26 -0000 Subject: [llvm-commits] [llvm] r110631 - in /llvm/trunk: include/llvm/CodeGen/CalcSpillWeights.h include/llvm/CodeGen/LiveInterval.h include/llvm/CodeGen/LiveIntervalAnalysis.h lib/CodeGen/CalcSpillWeights.cpp lib/CodeGen/LiveInterval.cpp lib/CodeGen/SimpleRegisterCoalescing.cpp lib/CodeGen/SimpleRegisterCoalescing.h Message-ID: <20100810000226.7D9972A6C12C@llvm.org> Author: stoklund Date: Mon Aug 9 19:02:26 2010 New Revision: 110631 URL: http://llvm.org/viewvc/llvm-project?rev=110631&view=rev Log: Transpose the calculation of spill weights such that we are calculating one register at a time. This turns out to be slightly faster than iterating over instructions, but more importantly, it allows us to compute spill weights for new registers created after the spill weight pass has run. Also compute the allocation hint at the same time as the spill weight. This allows us to use the spill weight as a cost metric for copies, and choose the most profitable hint if there is more than one possibility. The new hints provide a very small (< 0.1%) but universal code size improvement. Modified: llvm/trunk/include/llvm/CodeGen/CalcSpillWeights.h llvm/trunk/include/llvm/CodeGen/LiveInterval.h llvm/trunk/include/llvm/CodeGen/LiveIntervalAnalysis.h llvm/trunk/lib/CodeGen/CalcSpillWeights.cpp llvm/trunk/lib/CodeGen/LiveInterval.cpp llvm/trunk/lib/CodeGen/SimpleRegisterCoalescing.cpp llvm/trunk/lib/CodeGen/SimpleRegisterCoalescing.h Modified: llvm/trunk/include/llvm/CodeGen/CalcSpillWeights.h URL: http://llvm.org/viewvc/llvm-project/llvm/trunk/include/llvm/CodeGen/CalcSpillWeights.h?rev=110631&r1=110630&r2=110631&view=diff ============================================================================== --- llvm/trunk/include/llvm/CodeGen/CalcSpillWeights.h (original) +++ llvm/trunk/include/llvm/CodeGen/CalcSpillWeights.h Mon Aug 9 19:02:26 2010 @@ -12,10 +12,35 @@ #define LLVM_CODEGEN_CALCSPILLWEIGHTS_H #include "llvm/CodeGen/MachineFunctionPass.h" +#include "llvm/ADT/DenseMap.h" namespace llvm { class LiveInterval; + class LiveIntervals; + class MachineLoopInfo; + + /// VirtRegAuxInfo - Calculate auxiliary information for a virtual + /// register such as its spill weight and allocation hint. + class VirtRegAuxInfo { + MachineFunction &mf_; + LiveIntervals &lis_; + MachineLoopInfo &loops_; + DenseMap hint_; + public: + VirtRegAuxInfo(MachineFunction &mf, LiveIntervals &lis, + MachineLoopInfo &loops) : + mf_(mf), lis_(lis), loops_(loops) {} + + /// CalculateRegClass - recompute the register class for li from its uses. + /// Since the register class can affect the allocation hint, this function + /// should be called before CalculateWeightAndHint if both are called. + void CalculateRegClass(LiveInterval &li); + + /// CalculateWeightAndHint - (re)compute li's spill weight and allocation + /// hint. + void CalculateWeightAndHint(LiveInterval &li); + }; /// CalculateSpillWeights - Compute spill weights for all virtual register /// live intervals. @@ -27,7 +52,7 @@ virtual void getAnalysisUsage(AnalysisUsage &au) const; - virtual bool runOnMachineFunction(MachineFunction &fn); + virtual bool runOnMachineFunction(MachineFunction &fn); private: /// Returns true if the given live interval is zero length. Modified: llvm/trunk/include/llvm/CodeGen/LiveInterval.h URL: http://llvm.org/viewvc/llvm-project/llvm/trunk/include/llvm/CodeGen/LiveInterval.h?rev=110631&r1=110630&r2=110631&view=diff ============================================================================== --- llvm/trunk/include/llvm/CodeGen/LiveInterval.h (original) +++ llvm/trunk/include/llvm/CodeGen/LiveInterval.h Mon Aug 9 19:02:26 2010 @@ -520,6 +520,15 @@ /// unsigned getSize() const; + /// Returns true if the live interval is zero length, i.e. no live ranges + /// span instructions. It doesn't pay to spill such an interval. + bool isZeroLength() const { + for (const_iterator i = begin(), e = end(); i != e; ++i) + if (i->end.getPrevIndex() > i->start) + return false; + return true; + } + /// isSpillable - Can this interval be spilled? bool isSpillable() const { return weight != HUGE_VALF; Modified: llvm/trunk/include/llvm/CodeGen/LiveIntervalAnalysis.h URL: http://llvm.org/viewvc/llvm-project/llvm/trunk/include/llvm/CodeGen/LiveIntervalAnalysis.h?rev=110631&r1=110630&r2=110631&view=diff ============================================================================== --- llvm/trunk/include/llvm/CodeGen/LiveIntervalAnalysis.h (original) +++ llvm/trunk/include/llvm/CodeGen/LiveIntervalAnalysis.h Mon Aug 9 19:02:26 2010 @@ -105,6 +105,12 @@ return r2iMap_.count(reg); } + /// isAllocatable - is the physical register reg allocatable in the current + /// function? + bool isAllocatable(unsigned reg) const { + return allocatableRegs_.test(reg); + } + /// getScaledIntervalSize - get the size of an interval in "units," /// where every function is composed of one thousand units. This /// measure scales properly with empty index slots in the function. Modified: llvm/trunk/lib/CodeGen/CalcSpillWeights.cpp URL: http://llvm.org/viewvc/llvm-project/llvm/trunk/lib/CodeGen/CalcSpillWeights.cpp?rev=110631&r1=110630&r2=110631&view=diff ============================================================================== --- llvm/trunk/lib/CodeGen/CalcSpillWeights.cpp (original) +++ llvm/trunk/lib/CodeGen/CalcSpillWeights.cpp Mon Aug 9 19:02:26 2010 @@ -41,107 +41,136 @@ << "********** Function: " << fn.getFunction()->getName() << '\n'); - LiveIntervals *lis = &getAnalysis(); - MachineLoopInfo *loopInfo = &getAnalysis(); - MachineRegisterInfo *mri = &fn.getRegInfo(); - - SmallSet processed; - for (MachineFunction::iterator mbbi = fn.begin(), mbbe = fn.end(); - mbbi != mbbe; ++mbbi) { - MachineBasicBlock* mbb = mbbi; - SlotIndex mbbEnd = lis->getMBBEndIdx(mbb); - MachineLoop* loop = loopInfo->getLoopFor(mbb); - unsigned loopDepth = loop ? loop->getLoopDepth() : 0; - bool isExiting = loop ? loop->isLoopExiting(mbb) : false; - - for (MachineBasicBlock::const_iterator mii = mbb->begin(), mie = mbb->end(); - mii != mie; ++mii) { - const MachineInstr *mi = mii; - if (mi->isIdentityCopy() || mi->isImplicitDef() || mi->isDebugValue()) - continue; - - for (unsigned i = 0, e = mi->getNumOperands(); i != e; ++i) { - const MachineOperand &mopi = mi->getOperand(i); - if (!mopi.isReg() || mopi.getReg() == 0) - continue; - unsigned reg = mopi.getReg(); - if (!TargetRegisterInfo::isVirtualRegister(mopi.getReg())) - continue; - // Multiple uses of reg by the same instruction. It should not - // contribute to spill weight again. - if (!processed.insert(reg)) - continue; - - bool hasDef = mopi.isDef(); - bool hasUse = !hasDef; - for (unsigned j = i+1; j != e; ++j) { - const MachineOperand &mopj = mi->getOperand(j); - if (!mopj.isReg() || mopj.getReg() != reg) - continue; - hasDef |= mopj.isDef(); - hasUse |= mopj.isUse(); - if (hasDef && hasUse) - break; - } - - LiveInterval ®Int = lis->getInterval(reg); - float weight = lis->getSpillWeight(hasDef, hasUse, loopDepth); - if (hasDef && isExiting) { - // Looks like this is a loop count variable update. - SlotIndex defIdx = lis->getInstructionIndex(mi).getDefIndex(); - const LiveRange *dlr = - lis->getInterval(reg).getLiveRangeContaining(defIdx); - if (dlr->end >= mbbEnd) - weight *= 3.0F; - } - regInt.weight += weight; - } - processed.clear(); - } + LiveIntervals &lis = getAnalysis(); + VirtRegAuxInfo vrai(fn, lis, getAnalysis()); + for (LiveIntervals::iterator I = lis.begin(), E = lis.end(); I != E; ++I) { + LiveInterval &li = *I->second; + if (TargetRegisterInfo::isVirtualRegister(li.reg)) + vrai.CalculateWeightAndHint(li); } + return false; +} - for (LiveIntervals::iterator I = lis->begin(), E = lis->end(); I != E; ++I) { - LiveInterval &li = *I->second; - if (TargetRegisterInfo::isVirtualRegister(li.reg)) { - // If the live interval length is essentially zero, i.e. in every live - // range the use follows def immediately, it doesn't make sense to spill - // it and hope it will be easier to allocate for this li. - if (isZeroLengthInterval(&li)) { - li.weight = HUGE_VALF; - continue; - } - - bool isLoad = false; - SmallVector spillIs; - if (lis->isReMaterializable(li, spillIs, isLoad)) { - // If all of the definitions of the interval are re-materializable, - // it is a preferred candidate for spilling. If none of the defs are - // loads, then it's potentially very cheap to re-materialize. - // FIXME: this gets much more complicated once we support non-trivial - // re-materialization. - if (isLoad) - li.weight *= 0.9F; - else - li.weight *= 0.5F; - } - - // Slightly prefer live interval that has been assigned a preferred reg. - std::pair Hint = mri->getRegAllocationHint(li.reg); - if (Hint.first || Hint.second) - li.weight *= 1.01F; +// Return the preferred allocation register for reg, given a COPY instruction. +static unsigned copyHint(const MachineInstr *mi, unsigned reg, + const TargetRegisterInfo &tri, + const MachineRegisterInfo &mri) { + unsigned sub, hreg, hsub; + if (mi->getOperand(0).getReg() == reg) { + sub = mi->getOperand(0).getSubReg(); + hreg = mi->getOperand(1).getReg(); + hsub = mi->getOperand(1).getSubReg(); + } else { + sub = mi->getOperand(1).getSubReg(); + hreg = mi->getOperand(0).getReg(); + hsub = mi->getOperand(0).getSubReg(); + } + + if (!hreg) + return 0; + + if (TargetRegisterInfo::isVirtualRegister(hreg)) + return sub == hsub ? hreg : 0; + + const TargetRegisterClass *rc = mri.getRegClass(reg); + + // Only allow physreg hints in rc. + if (sub == 0) + return rc->contains(hreg) ? hreg : 0; + + // reg:sub should match the physreg hreg. + return tri.getMatchingSuperReg(hreg, sub, rc); +} - lis->normalizeSpillWeight(li); +void VirtRegAuxInfo::CalculateWeightAndHint(LiveInterval &li) { + MachineRegisterInfo &mri = mf_.getRegInfo(); + const TargetRegisterInfo &tri = *mf_.getTarget().getRegisterInfo(); + MachineBasicBlock *mbb = 0; + MachineLoop *loop = 0; + unsigned loopDepth = 0; + bool isExiting = false; + float totalWeight = 0; + SmallPtrSet visited; + + // Find the best physreg hist and the best virtreg hint. + float bestPhys = 0, bestVirt = 0; + unsigned hintPhys = 0, hintVirt = 0; + + // Don't recompute a target specific hint. + bool noHint = mri.getRegAllocationHint(li.reg).first != 0; + + for (MachineRegisterInfo::reg_iterator I = mri.reg_begin(li.reg); + MachineInstr *mi = I.skipInstruction();) { + if (mi->isIdentityCopy() || mi->isImplicitDef() || mi->isDebugValue()) + continue; + if (!visited.insert(mi)) + continue; + + // Get loop info for mi. + if (mi->getParent() != mbb) { + mbb = mi->getParent(); + loop = loops_.getLoopFor(mbb); + loopDepth = loop ? loop->getLoopDepth() : 0; + isExiting = loop ? loop->isLoopExiting(mbb) : false; + } + + // Calculate instr weight. + bool reads, writes; + tie(reads, writes) = mi->readsWritesVirtualRegister(li.reg); + float weight = LiveIntervals::getSpillWeight(writes, reads, loopDepth); + + // Give extra weight to what looks like a loop induction variable update. + if (writes && isExiting && lis_.isLiveOutOfMBB(li, mbb)) + weight *= 3; + + totalWeight += weight; + + // Get allocation hints from copies. + if (noHint || !mi->isCopy()) + continue; + unsigned hint = copyHint(mi, li.reg, tri, mri); + if (!hint) + continue; + float hweight = hint_[hint] += weight; + if (TargetRegisterInfo::isPhysicalRegister(hint)) { + if (hweight > bestPhys && lis_.isAllocatable(hint)) + bestPhys = hweight, hintPhys = hint; + } else { + if (hweight > bestVirt) + bestVirt = hweight, hintVirt = hint; } } - - return false; -} -/// Returns true if the given live interval is zero length. -bool CalculateSpillWeights::isZeroLengthInterval(LiveInterval *li) const { - for (LiveInterval::Ranges::const_iterator - i = li->ranges.begin(), e = li->ranges.end(); i != e; ++i) - if (i->end.getPrevIndex() > i->start) - return false; - return true; + hint_.clear(); + + // Always prefer the physreg hint. + if (unsigned hint = hintPhys ? hintPhys : hintVirt) { + mri.setRegAllocationHint(li.reg, 0, hint); + // Weakly boost the spill weifght of hinted registers. + totalWeight *= 1.01F; + } + + // Mark li as unspillable if all live ranges are tiny. + if (li.isZeroLength()) { + li.markNotSpillable(); + return; + } + + // If all of the definitions of the interval are re-materializable, + // it is a preferred candidate for spilling. If none of the defs are + // loads, then it's potentially very cheap to re-materialize. + // FIXME: this gets much more complicated once we support non-trivial + // re-materialization. + bool isLoad = false; + SmallVector spillIs; + if (lis_.isReMaterializable(li, spillIs, isLoad)) { + if (isLoad) + totalWeight *= 0.9F; + else + totalWeight *= 0.5F; + } + + li.weight = totalWeight; + lis_.normalizeSpillWeight(li); } + Modified: llvm/trunk/lib/CodeGen/LiveInterval.cpp URL: http://llvm.org/viewvc/llvm-project/llvm/trunk/lib/CodeGen/LiveInterval.cpp?rev=110631&r1=110630&r2=110631&view=diff ============================================================================== --- llvm/trunk/lib/CodeGen/LiveInterval.cpp (original) +++ llvm/trunk/lib/CodeGen/LiveInterval.cpp Mon Aug 9 19:02:26 2010 @@ -515,18 +515,6 @@ } ComputeJoinedWeight(Other); - - // Update regalloc hint if currently there isn't one. - if (TargetRegisterInfo::isVirtualRegister(reg) && - TargetRegisterInfo::isVirtualRegister(Other.reg)) { - std::pair Hint = MRI->getRegAllocationHint(reg); - if (Hint.first == 0 && Hint.second == 0) { - std::pair OtherHint = - MRI->getRegAllocationHint(Other.reg); - if (OtherHint.first || OtherHint.second) - MRI->setRegAllocationHint(reg, OtherHint.first, OtherHint.second); - } - } } /// MergeRangesInAsValue - Merge all of the intervals in RHS into this live Modified: llvm/trunk/lib/CodeGen/SimpleRegisterCoalescing.cpp URL: http://llvm.org/viewvc/llvm-project/llvm/trunk/lib/CodeGen/SimpleRegisterCoalescing.cpp?rev=110631&r1=110630&r2=110631&view=diff ============================================================================== --- llvm/trunk/lib/CodeGen/SimpleRegisterCoalescing.cpp (original) +++ llvm/trunk/lib/CodeGen/SimpleRegisterCoalescing.cpp Mon Aug 9 19:02:26 2010 @@ -1044,7 +1044,7 @@ if (CP.isPhys()) { DEBUG(dbgs() <<" with physreg %" << tri_->getName(CP.getDstReg()) << "\n"); // Only coalesce to allocatable physreg. - if (!allocatableRegs_[CP.getDstReg()]) { + if (!li_->isAllocatable(CP.getDstReg())) { DEBUG(dbgs() << "\tRegister is an unallocatable physreg.\n"); return false; // Not coalescable. } @@ -1093,7 +1093,6 @@ // happens. if (li_->hasInterval(CP.getDstReg()) && li_->getInterval(CP.getDstReg()).ranges.size() > 1000) { - mri_->setRegAllocationHint(CP.getSrcReg(), 0, CP.getDstReg()); ++numAborts; DEBUG(dbgs() << "\tPhysical register live interval too complicated, abort!\n"); @@ -1112,7 +1111,6 @@ ReMaterializeTrivialDef(JoinVInt, CP.getDstReg(), 0, CopyMI)) return true; - mri_->setRegAllocationHint(CP.getSrcReg(), 0, CP.getDstReg()); ++numAborts; DEBUG(dbgs() << "\tMay tie down a physical register, abort!\n"); Again = true; // May be possible to coalesce later. @@ -1693,7 +1691,6 @@ << "********** Function: " << ((Value*)mf_->getFunction())->getName() << '\n'); - allocatableRegs_ = tri_->getAllocatableSet(fn); for (TargetRegisterInfo::regclass_iterator I = tri_->regclass_begin(), E = tri_->regclass_end(); I != E; ++I) allocatableRCRegs_.insert(std::make_pair(*I, Modified: llvm/trunk/lib/CodeGen/SimpleRegisterCoalescing.h URL: http://llvm.org/viewvc/llvm-project/llvm/trunk/lib/CodeGen/SimpleRegisterCoalescing.h?rev=110631&r1=110630&r2=110631&view=diff ============================================================================== --- llvm/trunk/lib/CodeGen/SimpleRegisterCoalescing.h (original) +++ llvm/trunk/lib/CodeGen/SimpleRegisterCoalescing.h Mon Aug 9 19:02:26 2010 @@ -47,7 +47,6 @@ const MachineLoopInfo* loopInfo; AliasAnalysis *AA; - BitVector allocatableRegs_; DenseMap allocatableRCRegs_; /// JoinedCopies - Keep track of copies eliminated due to coalescing. From bob.wilson at apple.com Mon Aug 9 19:11:13 2010 From: bob.wilson at apple.com (Bob Wilson) Date: Tue, 10 Aug 2010 00:11:13 -0000 Subject: [llvm-commits] [llvm-gcc-4.2] r110632 - /llvm-gcc-4.2/trunk/gcc/llvm-convert.cpp Message-ID: <20100810001113.BF9CC2A6C12C@llvm.org> Author: bwilson Date: Mon Aug 9 19:11:13 2010 New Revision: 110632 URL: http://llvm.org/viewvc/llvm-project?rev=110632&view=rev Log: Change EmitASM_EXPR to record the original type of an asm input, before the special case of treating small structs and unions as integers. If the operand has a matching constraint and it is tied to one of the outputs (for which small aggregates are not treated as integers), use that original type to compare against the output operand. Radar 8288710. Modified: llvm-gcc-4.2/trunk/gcc/llvm-convert.cpp Modified: llvm-gcc-4.2/trunk/gcc/llvm-convert.cpp URL: http://llvm.org/viewvc/llvm-project/llvm-gcc-4.2/trunk/gcc/llvm-convert.cpp?rev=110632&r1=110631&r2=110632&view=diff ============================================================================== --- llvm-gcc-4.2/trunk/gcc/llvm-convert.cpp (original) +++ llvm-gcc-4.2/trunk/gcc/llvm-convert.cpp Mon Aug 9 19:11:13 2010 @@ -4856,6 +4856,7 @@ const Type *LLVMTy = ConvertType(type); Value *Op = 0; + const Type *OpTy = LLVMTy; if (LLVMTy->isSingleValueType()) { if (TREE_CODE(Val)==ADDR_EXPR && TREE_CODE(TREE_OPERAND(Val,0))==LABEL_DECL) { @@ -4884,10 +4885,10 @@ // Otherwise, emit our value as a lvalue. isIndirect = true; Op = LV.Ptr; + OpTy = Op->getType(); } } - const Type *OpTy = Op->getType(); // If this input operand is matching an output operand, e.g. '0', check if // this is something that llvm supports. If the operand types are // different, then emit an error if 1) one of the types is not integer or @@ -4946,13 +4947,12 @@ OTyBits-OpTyBits); Op = Builder.CreateLShr(Op, ShAmt); } - OpTy = Op->getType(); } } } CallOps.push_back(Op); - CallArgTypes.push_back(OpTy); + CallArgTypes.push_back(Op->getType()); } else { // Memory operand. lang_hooks.mark_addressable(TREE_VALUE(Input)); isIndirect = true; From bruno.cardoso at gmail.com Mon Aug 9 19:13:21 2010 From: bruno.cardoso at gmail.com (Bruno Cardoso Lopes) Date: Tue, 10 Aug 2010 00:13:21 -0000 Subject: [llvm-commits] [llvm] r110633 - /llvm/trunk/lib/Target/X86/X86InstrSSE.td Message-ID: <20100810001321.322D92A6C12C@llvm.org> Author: bruno Date: Mon Aug 9 19:13:20 2010 New Revision: 110633 URL: http://llvm.org/viewvc/llvm-project?rev=110633&view=rev Log: Patterns to match AVX cmp instructions Modified: llvm/trunk/lib/Target/X86/X86InstrSSE.td Modified: llvm/trunk/lib/Target/X86/X86InstrSSE.td URL: http://llvm.org/viewvc/llvm-project/llvm/trunk/lib/Target/X86/X86InstrSSE.td?rev=110633&r1=110632&r2=110633&view=diff ============================================================================== --- llvm/trunk/lib/Target/X86/X86InstrSSE.td (original) +++ llvm/trunk/lib/Target/X86/X86InstrSSE.td Mon Aug 9 19:13:20 2010 @@ -1320,16 +1320,14 @@ "cmp${cc}pd\t{$src, $src1, $dst|$dst, $src1, $src}", "cmppd\t{$src2, $src, $src1, $dst|$dst, $src1, $src, $src2}", SSEPackedDouble>, OpSize, VEX_4V; - let Pattern = [] in { - defm VCMPPSY : sse12_cmp_packed, VEX_4V; - defm VCMPPDY : sse12_cmp_packed, OpSize, VEX_4V; - } + defm VCMPPSY : sse12_cmp_packed, VEX_4V; + defm VCMPPDY : sse12_cmp_packed, OpSize, VEX_4V; } let Constraints = "$src1 = $dst" in { defm CMPPS : sse12_cmp_packed References: <20100809202005.9F55C2A6C12C@llvm.org> <9587A5EB-550D-46FE-B94B-BDCB20A6B493@apple.com> Message-ID: <81977B77-34D5-4558-9A21-B393405FED87@apple.com> On Aug 9, 2010, at 3:23 PM, Bill Wendling wrote: > On Aug 9, 2010, at 1:20 PM, Devang Patel wrote: > >> Author: dpatel >> Date: Mon Aug 9 15:20:05 2010 >> New Revision: 110590 >> >> URL: http://llvm.org/viewvc/llvm-project?rev=110590&view=rev >> Log: >> It is ok, and convenient, to pass descriptors by value. > > Why not by reference? Because passing by value is more efficient for these simple value types. Devang, the patch looks good to me, but please remove the const from things like this: +void DwarfDebug::addSourceLine(DIE *Die, const DIVariable V) { You seem to have made a large mechanical change, please tidy up. -Chris From clattner at apple.com Mon Aug 9 19:23:48 2010 From: clattner at apple.com (Chris Lattner) Date: Mon, 9 Aug 2010 17:23:48 -0700 Subject: [llvm-commits] [llvm] r110584 - in /llvm/trunk/lib/Target/ARM: ARM.td ARMConstantIslandPass.cpp ARMSubtarget.h ARMTargetMachine.cpp In-Reply-To: <20100809183519.A234F2A6C12C@llvm.org> References: <20100809183519.A234F2A6C12C@llvm.org> Message-ID: On Aug 9, 2010, at 11:35 AM, Evan Cheng wrote: > Author: evancheng > Date: Mon Aug 9 13:35:19 2010 > New Revision: 110584 > > URL: http://llvm.org/viewvc/llvm-project?rev=110584&view=rev > Log: > Change -prefer-32bit-thumb to attribute -mattr=+32bit instead to disable more 32-bit to 16-bit optimizations. Why does this make sense to be a -mattr? This seems like a policy choice, not a CPU attribute. Policy decisions should be cl::opt's. -Chris From clattner at apple.com Mon Aug 9 19:24:23 2010 From: clattner at apple.com (Chris Lattner) Date: Mon, 9 Aug 2010 17:24:23 -0700 Subject: [llvm-commits] [llvm] r110576 - in /llvm/trunk: lib/Target/CellSPU/SPUISelLowering.cpp lib/Target/CellSPU/SPUISelLowering.h lib/Target/CellSPU/SPUInstrInfo.td lib/Target/CellSPU/SPUNodes.td lib/Target/CellSPU/SPURegisterInfo.cpp test/CodeGen/CellSPU/bigstack.ll test/CodeGen/CellSPU/v2f32.ll In-Reply-To: <20100809163301.235462A6C12C@llvm.org> References: <20100809163301.235462A6C12C@llvm.org> Message-ID: <25685170-45BA-47F0-AF9D-0D0600748145@apple.com> On Aug 9, 2010, at 9:33 AM, Kalle Raiskila wrote: > Author: kraiskil > Date: Mon Aug 9 11:33:00 2010 > New Revision: 110576 > > URL: http://llvm.org/viewvc/llvm-project?rev=110576&view=rev > Log: > Have SPU handle halfvec stores aligned by 8 bytes. Kalle, Again, what's going on here? Why isn't type legalization doing its job? -Chris From sabre at nondot.org Mon Aug 9 19:34:06 2010 From: sabre at nondot.org (Chris Lattner) Date: Tue, 10 Aug 2010 00:34:06 -0000 Subject: [llvm-commits] [llvm] r110636 - /llvm/trunk/lib/System/RWMutex.cpp Message-ID: <20100810003406.B36D02A6C12E@llvm.org> Author: lattner Date: Mon Aug 9 19:34:06 2010 New Revision: 110636 URL: http://llvm.org/viewvc/llvm-project?rev=110636&view=rev Log: remove code setting rw locks to PTHREAD_PROCESS_PRIVATE, which is the default. Patch by NAKAMURA Takumi! Modified: llvm/trunk/lib/System/RWMutex.cpp Modified: llvm/trunk/lib/System/RWMutex.cpp URL: http://llvm.org/viewvc/llvm-project/llvm/trunk/lib/System/RWMutex.cpp?rev=110636&r1=110635&r2=110636&view=diff ============================================================================== --- llvm/trunk/lib/System/RWMutex.cpp (original) +++ llvm/trunk/lib/System/RWMutex.cpp Mon Aug 9 19:34:06 2010 @@ -71,23 +71,8 @@ bzero(rwlock, sizeof(pthread_rwlock_t)); #endif - pthread_rwlockattr_t attr; - - // Initialize the rwlock attributes - int errorcode = pthread_rwlockattr_init(&attr); - assert(errorcode == 0); - -#if !defined(__FreeBSD__) && !defined(__OpenBSD__) && !defined(__NetBSD__) && !defined(__DragonFly__) - // Make it a process local rwlock - errorcode = pthread_rwlockattr_setpshared(&attr, PTHREAD_PROCESS_PRIVATE); -#endif - // Initialize the rwlock - errorcode = pthread_rwlock_init(rwlock, &attr); - assert(errorcode == 0); - - // Destroy the attributes - errorcode = pthread_rwlockattr_destroy(&attr); + int errorcode = pthread_rwlock_init(rwlock, NULL); assert(errorcode == 0); // Assign the data member From clattner at apple.com Mon Aug 9 19:34:38 2010 From: clattner at apple.com (Chris Lattner) Date: Mon, 9 Aug 2010 17:34:38 -0700 Subject: [llvm-commits] [Patch Proposal] PR6297 simplify RWMutex In-Reply-To: References: Message-ID: Looks great, applied in r110636, thanks! On Aug 9, 2010, at 9:51 AM, NAKAMURA Takumi wrote: > Hello everyone, > > We don't need to set the default value "PTHREAD_PROCESS_PRIVATE" for > pthread_rwlock_init(3T). > > It also resolves PR6297. > RWMutex.cpp and pthread on mingw > http://llvm.org/bugs/show_bug.cgi?id=6297 > > I have checked on mingw(msysgit), fedora12-ppc, and centos5(x86-64) > w/o regression. > > > ...Takumi > _______________________________________________ > llvm-commits mailing list > llvm-commits at cs.uiuc.edu > http://lists.cs.uiuc.edu/mailman/listinfo/llvm-commits From gohman at apple.com Mon Aug 9 20:03:35 2010 From: gohman at apple.com (Dan Gohman) Date: Tue, 10 Aug 2010 01:03:35 -0000 Subject: [llvm-commits] [llvm] r110638 - /llvm/trunk/utils/lit/lit/TestRunner.py Message-ID: <20100810010335.140DD2A6C12C@llvm.org> Author: djg Date: Mon Aug 9 20:03:34 2010 New Revision: 110638 URL: http://llvm.org/viewvc/llvm-project?rev=110638&view=rev Log: Expand uses of python 2.6's "A if B else C" syntax into regular if-else statements, to hopefully support older pythons (PR7850). Modified: llvm/trunk/utils/lit/lit/TestRunner.py Modified: llvm/trunk/utils/lit/lit/TestRunner.py URL: http://llvm.org/viewvc/llvm-project/llvm/trunk/utils/lit/lit/TestRunner.py?rev=110638&r1=110637&r2=110638&view=diff ============================================================================== --- llvm/trunk/utils/lit/lit/TestRunner.py (original) +++ llvm/trunk/utils/lit/lit/TestRunner.py Mon Aug 9 20:03:34 2010 @@ -520,10 +520,16 @@ out,err,exitCode = res if isXFail: ok = exitCode != 0 or err - status = Test.XFAIL if ok else Test.XPASS + if ok: + status = Test.XFAIL + else: + status = Test.XPASS else: ok = exitCode == 0 and not err - status = Test.PASS if ok else Test.FAIL + if ok: + status = Test.PASS + else: + status = Test.FAIL if ok: return (status,'') @@ -560,10 +566,16 @@ out,err,exitCode = res if isXFail: ok = exitCode != 0 - status = Test.XFAIL if ok else Test.XPASS + if ok: + status = Test.XFAIL + else: + status = Test.XPASS else: ok = exitCode == 0 - status = Test.PASS if ok else Test.FAIL + if ok: + status = Test.PASS + else: + status = Test.FAIL if ok: return (status,'') From isanbard at gmail.com Mon Aug 9 20:27:41 2010 From: isanbard at gmail.com (Bill Wendling) Date: Tue, 10 Aug 2010 01:27:41 -0000 Subject: [llvm-commits] [test-suite] r110639 - /test-suite/trunk/Makefile.programs Message-ID: <20100810012741.251A52A6C12C@llvm.org> Author: void Date: Mon Aug 9 20:27:40 2010 New Revision: 110639 URL: http://llvm.org/viewvc/llvm-project?rev=110639&view=rev Log: Enable comparison optimizations for nightly beta tests for ARM. Modified: test-suite/trunk/Makefile.programs Modified: test-suite/trunk/Makefile.programs URL: http://llvm.org/viewvc/llvm-project/test-suite/trunk/Makefile.programs?rev=110639&r1=110638&r2=110639&view=diff ============================================================================== --- test-suite/trunk/Makefile.programs (original) +++ test-suite/trunk/Makefile.programs Mon Aug 9 20:27:40 2010 @@ -267,7 +267,8 @@ LLCBETAOPTION := -enable-sparc-v9-insts endif ifeq ($(ARCH),ARM) -LLCBETAOPTION := -arm-code-placement +LLCBETAOPTION := -enable-optimize-cmps +#LLCBETAOPTION := -arm-code-placement endif ifeq ($(ARCH),THUMB) LLCBETAOPTION := -arm-code-placement From dpatel at apple.com Mon Aug 9 20:37:23 2010 From: dpatel at apple.com (Devang Patel) Date: Tue, 10 Aug 2010 01:37:23 -0000 Subject: [llvm-commits] [llvm] r110642 - in /llvm/trunk/lib/CodeGen/AsmPrinter: DwarfDebug.cpp DwarfDebug.h Message-ID: <20100810013724.02B612A6C12C@llvm.org> Author: dpatel Date: Mon Aug 9 20:37:23 2010 New Revision: 110642 URL: http://llvm.org/viewvc/llvm-project?rev=110642&view=rev Log: Do not include file static variable in pubnames list. Refactor and simplify code to avoid redundant checks. Modified: llvm/trunk/lib/CodeGen/AsmPrinter/DwarfDebug.cpp llvm/trunk/lib/CodeGen/AsmPrinter/DwarfDebug.h Modified: llvm/trunk/lib/CodeGen/AsmPrinter/DwarfDebug.cpp URL: http://llvm.org/viewvc/llvm-project/llvm/trunk/lib/CodeGen/AsmPrinter/DwarfDebug.cpp?rev=110642&r1=110641&r2=110642&view=diff ============================================================================== --- llvm/trunk/lib/CodeGen/AsmPrinter/DwarfDebug.cpp (original) +++ llvm/trunk/lib/CodeGen/AsmPrinter/DwarfDebug.cpp Mon Aug 9 20:37:23 2010 @@ -1186,30 +1186,6 @@ return LinkageName; } -/// createGlobalVariableDIE - Create new DIE using GV. -DIE *DwarfDebug::createGlobalVariableDIE(const DIGlobalVariable &GV) { - // If the global variable was optmized out then no need to create debug info - // entry. - if (!GV.Verify()) return NULL; - if (GV.getDisplayName().empty()) return NULL; - - DIE *GVDie = new DIE(dwarf::DW_TAG_variable); - addString(GVDie, dwarf::DW_AT_name, dwarf::DW_FORM_string, - GV.getDisplayName()); - - StringRef LinkageName = GV.getLinkageName(); - if (!LinkageName.empty()) - addString(GVDie, dwarf::DW_AT_MIPS_linkage_name, dwarf::DW_FORM_string, - getRealLinkageName(LinkageName)); - - addType(GVDie, GV.getType()); - if (!GV.isLocalToUnit()) - addUInt(GVDie, dwarf::DW_AT_external, dwarf::DW_FORM_flag, 1); - addSourceLine(GVDie, GV); - - return GVDie; -} - /// createMemberDIE - Create new member DIE. DIE *DwarfDebug::createMemberDIE(const DIDerivedType &DT) { DIE *MemberDie = new DIE(DT.getTag()); @@ -1888,57 +1864,68 @@ /// constructGlobalVariableDIE - Construct global variable DIE. void DwarfDebug::constructGlobalVariableDIE(const MDNode *N) { - DIGlobalVariable DI_GV(N); + DIGlobalVariable GV(N); // If debug information is malformed then ignore it. - if (DI_GV.Verify() == false) + if (GV.Verify() == false) return; // Check for pre-existence. CompileUnit *TheCU = getCompileUnit(N); - if (TheCU->getDIE(DI_GV)) + if (TheCU->getDIE(GV)) return; - DIE *VariableDie = createGlobalVariableDIE(DI_GV); - if (!VariableDie) - return; + DIType GTy = GV.getType(); + DIE *VariableDIE = new DIE(dwarf::DW_TAG_variable); + // Add name. + addString(VariableDIE, dwarf::DW_AT_name, dwarf::DW_FORM_string, + GV.getDisplayName()); + StringRef LinkageName = GV.getLinkageName(); + if (!LinkageName.empty()) + addString(VariableDIE, dwarf::DW_AT_MIPS_linkage_name, dwarf::DW_FORM_string, + getRealLinkageName(LinkageName)); + // Add type. + addType(VariableDIE, GTy); + if (GTy.isCompositeType() && !GTy.getName().empty() + && !GTy.isForwardDecl()) { + DIEEntry *Entry = TheCU->getDIEEntry(GTy); + assert(Entry && "Missing global type!"); + TheCU->addGlobalType(GTy.getName(), Entry->getEntry()); + } + // Add scoping info. + if (!GV.isLocalToUnit()) { + addUInt(VariableDIE, dwarf::DW_AT_external, dwarf::DW_FORM_flag, 1); + // Expose as global. + TheCU->addGlobal(GV.getName(), VariableDIE); + } + // Add line number info. + addSourceLine(VariableDIE, GV); // Add to map. - TheCU->insertDIE(N, VariableDie); - + TheCU->insertDIE(N, VariableDIE); // Add to context owner. - DIDescriptor GVContext = DI_GV.getContext(); + DIDescriptor GVContext = GV.getContext(); + addToContextOwner(VariableDIE, GVContext); + // Add location. DIEBlock *Block = new (DIEValueAllocator) DIEBlock(); addUInt(Block, 0, dwarf::DW_FORM_data1, dwarf::DW_OP_addr); addLabel(Block, 0, dwarf::DW_FORM_udata, - Asm->Mang->getSymbol(DI_GV.getGlobal())); + Asm->Mang->getSymbol(GV.getGlobal())); // Do not create specification DIE if context is either compile unit // or a subprogram. - if (DI_GV.isDefinition() && !GVContext.isCompileUnit() && - !GVContext.isFile() && - !isSubprogramContext(GVContext)) { + if (GV.isDefinition() && !GVContext.isCompileUnit() && + !GVContext.isFile() && !isSubprogramContext(GVContext)) { // Create specification DIE. DIE *VariableSpecDIE = new DIE(dwarf::DW_TAG_variable); addDIEEntry(VariableSpecDIE, dwarf::DW_AT_specification, - dwarf::DW_FORM_ref4, VariableDie); + dwarf::DW_FORM_ref4, VariableDIE); addBlock(VariableSpecDIE, dwarf::DW_AT_location, 0, Block); - addUInt(VariableDie, dwarf::DW_AT_declaration, dwarf::DW_FORM_flag, 1); + addUInt(VariableDIE, dwarf::DW_AT_declaration, dwarf::DW_FORM_flag, 1); TheCU->addDie(VariableSpecDIE); } else { - addBlock(VariableDie, dwarf::DW_AT_location, 0, Block); + addBlock(VariableDIE, dwarf::DW_AT_location, 0, Block); } - addToContextOwner(VariableDie, GVContext); - // Expose as global. FIXME - need to check external flag. - TheCU->addGlobal(DI_GV.getName(), VariableDie); - - DIType GTy = DI_GV.getType(); - if (GTy.isCompositeType() && !GTy.getName().empty() - && !GTy.isForwardDecl()) { - DIEEntry *Entry = TheCU->getDIEEntry(GTy); - assert(Entry && "Missing global type!"); - TheCU->addGlobalType(GTy.getName(), Entry->getEntry()); - } return; } Modified: llvm/trunk/lib/CodeGen/AsmPrinter/DwarfDebug.h URL: http://llvm.org/viewvc/llvm-project/llvm/trunk/lib/CodeGen/AsmPrinter/DwarfDebug.h?rev=110642&r1=110641&r2=110642&view=diff ============================================================================== --- llvm/trunk/lib/CodeGen/AsmPrinter/DwarfDebug.h (original) +++ llvm/trunk/lib/CodeGen/AsmPrinter/DwarfDebug.h Mon Aug 9 20:37:23 2010 @@ -418,9 +418,6 @@ /// constructEnumTypeDIE - Construct enum type DIE from DIEnumerator. DIE *constructEnumTypeDIE(DIEnumerator ETy); - /// createGlobalVariableDIE - Create new DIE using GV. - DIE *createGlobalVariableDIE(const DIGlobalVariable &GV); - /// createMemberDIE - Create new member DIE. DIE *createMemberDIE(const DIDerivedType &DT); From bruno.cardoso at gmail.com Mon Aug 9 20:40:05 2010 From: bruno.cardoso at gmail.com (Bruno Cardoso Lopes) Date: Tue, 10 Aug 2010 01:40:05 -0000 Subject: [llvm-commits] [llvm] r110643 - /llvm/trunk/include/llvm/IntrinsicsX86.td Message-ID: <20100810014005.C6E152A6C12C@llvm.org> Author: bruno Date: Mon Aug 9 20:40:05 2010 New Revision: 110643 URL: http://llvm.org/viewvc/llvm-project?rev=110643&view=rev Log: Use i32 instead of i8 for dot product intrinsic Modified: llvm/trunk/include/llvm/IntrinsicsX86.td Modified: llvm/trunk/include/llvm/IntrinsicsX86.td URL: http://llvm.org/viewvc/llvm-project/llvm/trunk/include/llvm/IntrinsicsX86.td?rev=110643&r1=110642&r2=110643&view=diff ============================================================================== --- llvm/trunk/include/llvm/IntrinsicsX86.td (original) +++ llvm/trunk/include/llvm/IntrinsicsX86.td Mon Aug 9 20:40:05 2010 @@ -1105,7 +1105,7 @@ let TargetPrefix = "x86" in { // All intrinsics start with "llvm.x86.". def int_x86_avx_dp_ps_256 : GCCBuiltin<"__builtin_ia32_dpps256">, Intrinsic<[llvm_v8f32_ty], [llvm_v8f32_ty, - llvm_v8f32_ty, llvm_i8_ty], [IntrNoMem]>; + llvm_v8f32_ty, llvm_i32_ty], [IntrNoMem]>; } // Vector shuffle From bruno.cardoso at gmail.com Mon Aug 9 20:43:16 2010 From: bruno.cardoso at gmail.com (Bruno Cardoso Lopes) Date: Tue, 10 Aug 2010 01:43:16 -0000 Subject: [llvm-commits] [llvm] r110645 - in /llvm/trunk/lib/Target/X86: X86ISelLowering.cpp X86InstrSSE.td Message-ID: <20100810014316.9821B2A6C12C@llvm.org> Author: bruno Date: Mon Aug 9 20:43:16 2010 New Revision: 110645 URL: http://llvm.org/viewvc/llvm-project?rev=110645&view=rev Log: Support AVX 256-bit load and store intrinsics Modified: llvm/trunk/lib/Target/X86/X86ISelLowering.cpp llvm/trunk/lib/Target/X86/X86InstrSSE.td Modified: llvm/trunk/lib/Target/X86/X86ISelLowering.cpp URL: http://llvm.org/viewvc/llvm-project/llvm/trunk/lib/Target/X86/X86ISelLowering.cpp?rev=110645&r1=110644&r2=110645&view=diff ============================================================================== --- llvm/trunk/lib/Target/X86/X86ISelLowering.cpp (original) +++ llvm/trunk/lib/Target/X86/X86ISelLowering.cpp Mon Aug 9 20:43:16 2010 @@ -871,6 +871,7 @@ addRegisterClass(MVT::v4f64, X86::VR256RegisterClass); addRegisterClass(MVT::v8i32, X86::VR256RegisterClass); addRegisterClass(MVT::v4i64, X86::VR256RegisterClass); + addRegisterClass(MVT::v32i8, X86::VR256RegisterClass); setOperationAction(ISD::LOAD, MVT::v8f32, Legal); setOperationAction(ISD::LOAD, MVT::v8i32, Legal); Modified: llvm/trunk/lib/Target/X86/X86InstrSSE.td URL: http://llvm.org/viewvc/llvm-project/llvm/trunk/lib/Target/X86/X86InstrSSE.td?rev=110645&r1=110644&r2=110645&view=diff ============================================================================== --- llvm/trunk/lib/Target/X86/X86InstrSSE.td (original) +++ llvm/trunk/lib/Target/X86/X86InstrSSE.td Mon Aug 9 20:43:16 2010 @@ -340,6 +340,15 @@ "movupd\t{$src, $dst|$dst, $src}", [(store (v4f64 VR256:$src), addr:$dst)]>, VEX; } + +def : Pat<(int_x86_avx_loadu_ps_256 addr:$src), (VMOVUPSYrm addr:$src)>; +def : Pat<(int_x86_avx_storeu_ps_256 addr:$dst, VR256:$src), + (VMOVUPSYmr addr:$dst, VR256:$src)>; + +def : Pat<(int_x86_avx_loadu_pd_256 addr:$src), (VMOVUPDYrm addr:$src)>; +def : Pat<(int_x86_avx_storeu_pd_256 addr:$dst, VR256:$src), + (VMOVUPDYmr addr:$dst, VR256:$src)>; + def MOVAPSmr : PSI<0x29, MRMDestMem, (outs), (ins f128mem:$dst, VR128:$src), "movaps\t{$src, $dst|$dst, $src}", [(alignedstore (v4f32 VR128:$src), addr:$dst)]>; @@ -2291,6 +2300,10 @@ } // ExeDomain = SSEPackedInt +def : Pat<(int_x86_avx_loadu_dq_256 addr:$src), (VMOVDQUYrm addr:$src)>; +def : Pat<(int_x86_avx_storeu_dq_256 addr:$dst, VR256:$src), + (VMOVDQUYmr addr:$dst, VR256:$src)>; + //===---------------------------------------------------------------------===// // SSE2 - Packed Integer Arithmetic Instructions //===---------------------------------------------------------------------===// @@ -3348,10 +3361,11 @@ // Move Unaligned Integer let isAsmParserOnly = 1, Predicates = [HasAVX] in { def VLDDQUrm : S3DI<0xF0, MRMSrcMem, (outs VR128:$dst), (ins i128mem:$src), - "vlddqu\t{$src, $dst|$dst, $src}", - [(set VR128:$dst, (int_x86_sse3_ldu_dq addr:$src))]>, VEX; + "vlddqu\t{$src, $dst|$dst, $src}", + [(set VR128:$dst, (int_x86_sse3_ldu_dq addr:$src))]>, VEX; def VLDDQUYrm : S3DI<0xF0, MRMSrcMem, (outs VR256:$dst), (ins i256mem:$src), - "vlddqu\t{$src, $dst|$dst, $src}", []>, VEX; + "vlddqu\t{$src, $dst|$dst, $src}", + [(set VR256:$dst, (int_x86_avx_ldu_dq_256 addr:$src))]>, VEX; } def LDDQUrm : S3DI<0xF0, MRMSrcMem, (outs VR128:$dst), (ins i128mem:$src), "lddqu\t{$src, $dst|$dst, $src}", @@ -4833,9 +4847,8 @@ VR128, memopv16i8, i128mem, 0>, VEX_4V; defm VDPPD : SS41I_binop_rmi_int<0x41, "vdppd", int_x86_sse41_dppd, VR128, memopv16i8, i128mem, 0>, VEX_4V; - let Pattern = [] in - defm VDPPSY : SS41I_binop_rmi_int<0x40, "vdpps", int_x86_sse41_dpps, - VR256, memopv32i8, i256mem, 0>, VEX_4V; + defm VDPPSY : SS41I_binop_rmi_int<0x40, "vdpps", int_x86_avx_dp_ps_256, + VR256, memopv32i8, i256mem, 0>, VEX_4V; } let Constraints = "$src1 = $dst" in { From bruno.cardoso at gmail.com Mon Aug 9 21:25:35 2010 From: bruno.cardoso at gmail.com (Bruno Cardoso Lopes) Date: Tue, 10 Aug 2010 02:25:35 -0000 Subject: [llvm-commits] [llvm] r110647 - /llvm/trunk/include/llvm/IntrinsicsX86.td Message-ID: <20100810022535.5DF842A6C12C@llvm.org> Author: bruno Date: Mon Aug 9 21:25:35 2010 New Revision: 110647 URL: http://llvm.org/viewvc/llvm-project?rev=110647&view=rev Log: Remove replicate intrinsics, clang will generate shufflevector for those. The shuffles can't be matched by x86 codegen yet, but will soon Modified: llvm/trunk/include/llvm/IntrinsicsX86.td Modified: llvm/trunk/include/llvm/IntrinsicsX86.td URL: http://llvm.org/viewvc/llvm-project/llvm/trunk/include/llvm/IntrinsicsX86.td?rev=110647&r1=110646&r2=110647&view=diff ============================================================================== --- llvm/trunk/include/llvm/IntrinsicsX86.td (original) +++ llvm/trunk/include/llvm/IntrinsicsX86.td Mon Aug 9 21:25:35 2010 @@ -1186,16 +1186,6 @@ Intrinsic<[llvm_v2f64_ty], [llvm_v4f64_ty], [IntrNoMem]>; } -// Vector replicate -let TargetPrefix = "x86" in { // All intrinsics start with "llvm.x86.". - def int_x86_avx_movshdup_256 : GCCBuiltin<"__builtin_ia32_movshdup256">, - Intrinsic<[llvm_v8f32_ty], [llvm_v8f32_ty], [IntrNoMem]>; - def int_x86_avx_movsldup_256 : GCCBuiltin<"__builtin_ia32_movsldup256">, - Intrinsic<[llvm_v8f32_ty], [llvm_v8f32_ty], [IntrNoMem]>; - def int_x86_avx_movddup_256 : GCCBuiltin<"__builtin_ia32_movddup256">, - Intrinsic<[llvm_v4f64_ty], [llvm_v4f64_ty], [IntrNoMem]>; -} - // Vector unpack and interleave let TargetPrefix = "x86" in { // All intrinsics start with "llvm.x86.". def int_x86_avx_unpckh_pd_256 : GCCBuiltin<"__builtin_ia32_unpckhpd256">, From espindola at google.com Mon Aug 9 21:32:51 2010 From: espindola at google.com (Rafael Espindola) Date: Mon, 9 Aug 2010 22:32:51 -0400 Subject: [llvm-commits] [patch] Don't link as many parts of llvm into bugpoint Message-ID: The attached patch is mostly a request for comments. On a debug build it reduces bugpoint from 68 MB to 34 MB. The difference is not free: *) The std-compile-opts and std-link-opts are gone. *) Passes now have to be listed with the -pass option. I think I can get those back with some more refactoring, but would like some opinions first. Do you think the patch is OK? Do you think it is OK if I manage to keep the current command line interface? The main reason for this is that since bugpoint is a tool for hunting bugs in llvm, it is nice for it to not be linked with every single LLVM pass. Specially if the only thing it does with most of those passes is collect their names :-) Cheers, -- Rafael ?vila de Esp?ndola -------------- next part -------------- A non-text attachment was scrubbed... Name: bugpoint.patch Type: text/x-patch Size: 3633 bytes Desc: not available Url : http://lists.cs.uiuc.edu/pipermail/llvm-commits/attachments/20100809/0f78f6bc/attachment.bin From bruno.cardoso at gmail.com Mon Aug 9 21:34:56 2010 From: bruno.cardoso at gmail.com (Bruno Cardoso Lopes) Date: Tue, 10 Aug 2010 02:34:56 -0000 Subject: [llvm-commits] [llvm] r110648 - /llvm/trunk/lib/Target/X86/X86InstrSSE.td Message-ID: <20100810023456.447D52A6C12C@llvm.org> Author: bruno Date: Mon Aug 9 21:34:56 2010 New Revision: 110648 URL: http://llvm.org/viewvc/llvm-project?rev=110648&view=rev Log: Add AVX movmsk 256-bit intrinsics Modified: llvm/trunk/lib/Target/X86/X86InstrSSE.td Modified: llvm/trunk/lib/Target/X86/X86InstrSSE.td URL: http://llvm.org/viewvc/llvm-project/llvm/trunk/lib/Target/X86/X86InstrSSE.td?rev=110648&r1=110647&r2=110648&view=diff ============================================================================== --- llvm/trunk/lib/Target/X86/X86InstrSSE.td (original) +++ llvm/trunk/lib/Target/X86/X86InstrSSE.td Mon Aug 9 21:34:56 2010 @@ -1491,20 +1491,18 @@ defm VMOVMSKPD : sse12_extr_sign_mask, OpSize, VEX; + defm VMOVMSKPSY : sse12_extr_sign_mask, VEX; + defm VMOVMSKPDY : sse12_extr_sign_mask, OpSize, + VEX; - // FIXME: merge with multiclass above when the intrinsics come. + // Assembler Only def VMOVMSKPSr64r : PI<0x50, MRMSrcReg, (outs GR64:$dst), (ins VR128:$src), "movmskps\t{$src, $dst|$dst, $src}", [], SSEPackedSingle>, VEX; def VMOVMSKPDr64r : PI<0x50, MRMSrcReg, (outs GR64:$dst), (ins VR128:$src), "movmskpd\t{$src, $dst|$dst, $src}", [], SSEPackedDouble>, OpSize, VEX; - - def VMOVMSKPSYrr : PI<0x50, MRMSrcReg, (outs GR32:$dst), (ins VR256:$src), - "movmskps\t{$src, $dst|$dst, $src}", [], SSEPackedSingle>, VEX; - def VMOVMSKPDYrr : PI<0x50, MRMSrcReg, (outs GR32:$dst), (ins VR256:$src), - "movmskpd\t{$src, $dst|$dst, $src}", [], SSEPackedDouble>, OpSize, - VEX; - def VMOVMSKPSYr64r : PI<0x50, MRMSrcReg, (outs GR64:$dst), (ins VR256:$src), "movmskps\t{$src, $dst|$dst, $src}", [], SSEPackedSingle>, VEX; def VMOVMSKPDYr64r : PI<0x50, MRMSrcReg, (outs GR64:$dst), (ins VR256:$src), From evan.cheng at apple.com Mon Aug 9 21:39:45 2010 From: evan.cheng at apple.com (Evan Cheng) Date: Tue, 10 Aug 2010 02:39:45 -0000 Subject: [llvm-commits] [llvm] r110649 - /llvm/trunk/lib/CodeGen/SelectionDAG/ScheduleDAGSDNodes.cpp Message-ID: <20100810023945.2CBE52A6C12C@llvm.org> Author: evancheng Date: Mon Aug 9 21:39:45 2010 New Revision: 110649 URL: http://llvm.org/viewvc/llvm-project?rev=110649&view=rev Log: Add missing null check reported by Amaury Pouly. Modified: llvm/trunk/lib/CodeGen/SelectionDAG/ScheduleDAGSDNodes.cpp Modified: llvm/trunk/lib/CodeGen/SelectionDAG/ScheduleDAGSDNodes.cpp URL: http://llvm.org/viewvc/llvm-project/llvm/trunk/lib/CodeGen/SelectionDAG/ScheduleDAGSDNodes.cpp?rev=110649&r1=110648&r2=110649&view=diff ============================================================================== --- llvm/trunk/lib/CodeGen/SelectionDAG/ScheduleDAGSDNodes.cpp (original) +++ llvm/trunk/lib/CodeGen/SelectionDAG/ScheduleDAGSDNodes.cpp Mon Aug 9 21:39:45 2010 @@ -59,8 +59,9 @@ SUnits.back().OrigNode = &SUnits.back(); SUnit *SU = &SUnits.back(); const TargetLowering &TLI = DAG->getTargetLoweringInfo(); - if (N->isMachineOpcode() && - N->getMachineOpcode() == TargetOpcode::IMPLICIT_DEF) + if (!N || + (N->isMachineOpcode() && + N->getMachineOpcode() == TargetOpcode::IMPLICIT_DEF)) SU->SchedulingPref = Sched::None; else SU->SchedulingPref = TLI.getSchedulingPreference(N); From bruno.cardoso at gmail.com Mon Aug 9 21:49:24 2010 From: bruno.cardoso at gmail.com (Bruno Cardoso Lopes) Date: Tue, 10 Aug 2010 02:49:24 -0000 Subject: [llvm-commits] [llvm] r110650 - /llvm/trunk/lib/Target/X86/X86InstrSSE.td Message-ID: <20100810024924.D5C0D2A6C12C@llvm.org> Author: bruno Date: Mon Aug 9 21:49:24 2010 New Revision: 110650 URL: http://llvm.org/viewvc/llvm-project?rev=110650&view=rev Log: Add AVX movnt{pd,ps,dq} 256-bit intrinsics Modified: llvm/trunk/lib/Target/X86/X86InstrSSE.td Modified: llvm/trunk/lib/Target/X86/X86InstrSSE.td URL: http://llvm.org/viewvc/llvm-project/llvm/trunk/lib/Target/X86/X86InstrSSE.td?rev=110650&r1=110649&r2=110650&view=diff ============================================================================== --- llvm/trunk/lib/Target/X86/X86InstrSSE.td (original) +++ llvm/trunk/lib/Target/X86/X86InstrSSE.td Mon Aug 9 21:49:24 2010 @@ -2099,6 +2099,13 @@ } } +def : Pat<(int_x86_avx_movnt_dq_256 addr:$dst, VR256:$src), + (VMOVNTDQYmr addr:$dst, VR256:$src)>; +def : Pat<(int_x86_avx_movnt_pd_256 addr:$dst, VR256:$src), + (VMOVNTPDYmr addr:$dst, VR256:$src)>; +def : Pat<(int_x86_avx_movnt_ps_256 addr:$dst, VR256:$src), + (VMOVNTPSYmr addr:$dst, VR256:$src)>; + def MOVNTPSmr_Int : PSI<0x2B, MRMDestMem, (outs), (ins i128mem:$dst, VR128:$src), "movntps\t{$src, $dst|$dst, $src}", [(int_x86_sse_movnt_ps addr:$dst, VR128:$src)]>; From geek4civic at gmail.com Mon Aug 9 21:51:02 2010 From: geek4civic at gmail.com (NAKAMURA Takumi) Date: Tue, 10 Aug 2010 11:51:02 +0900 Subject: [llvm-commits] [llvm] r110638 - /llvm/trunk/utils/lit/lit/TestRunner.py In-Reply-To: <20100810010335.140DD2A6C12C@llvm.org> References: <20100810010335.140DD2A6C12C@llvm.org> Message-ID: I have confirmed it on CentOS5/x86-64 and closed the PR. http://llvm.org/bugs/show_bug.cgi?id=7850 Thank you! ...Takumi 2010/8/10 Dan Gohman : > Author: djg > Date: Mon Aug ?9 20:03:34 2010 > New Revision: 110638 > > URL: http://llvm.org/viewvc/llvm-project?rev=110638&view=rev > Log: > Expand uses of python 2.6's "A if B else C" syntax into regular > if-else statements, to hopefully support older pythons (PR7850). > > Modified: > ? ?llvm/trunk/utils/lit/lit/TestRunner.py > > Modified: llvm/trunk/utils/lit/lit/TestRunner.py > URL: http://llvm.org/viewvc/llvm-project/llvm/trunk/utils/lit/lit/TestRunner.py?rev=110638&r1=110637&r2=110638&view=diff > ============================================================================== > --- llvm/trunk/utils/lit/lit/TestRunner.py (original) > +++ llvm/trunk/utils/lit/lit/TestRunner.py Mon Aug ?9 20:03:34 2010 > @@ -520,10 +520,16 @@ > ? ? out,err,exitCode = res > ? ? if isXFail: > ? ? ? ? ok = exitCode != 0 or err > - ? ? ? ?status = Test.XFAIL if ok else Test.XPASS > + ? ? ? ?if ok: > + ? ? ? ? ? ?status = Test.XFAIL > + ? ? ? ?else: > + ? ? ? ? ? ?status = Test.XPASS > ? ? else: > ? ? ? ? ok = exitCode == 0 and not err > - ? ? ? ?status = Test.PASS if ok else Test.FAIL > + ? ? ? ?if ok: > + ? ? ? ? ? ?status = Test.PASS > + ? ? ? ?else: > + ? ? ? ? ? ?status = Test.FAIL > > ? ? if ok: > ? ? ? ? return (status,'') > @@ -560,10 +566,16 @@ > ? ? out,err,exitCode = res > ? ? if isXFail: > ? ? ? ? ok = exitCode != 0 > - ? ? ? ?status = Test.XFAIL if ok else Test.XPASS > + ? ? ? ?if ok: > + ? ? ? ? ? ?status = Test.XFAIL > + ? ? ? ?else: > + ? ? ? ? ? ?status = Test.XPASS > ? ? else: > ? ? ? ? ok = exitCode == 0 > - ? ? ? ?status = Test.PASS if ok else Test.FAIL > + ? ? ? ?if ok: > + ? ? ? ? ? ?status = Test.PASS > + ? ? ? ?else: > + ? ? ? ? ? ?status = Test.FAIL > > ? ? if ok: > ? ? ? ? return (status,'') > > > _______________________________________________ > llvm-commits mailing list > llvm-commits at cs.uiuc.edu > http://lists.cs.uiuc.edu/mailman/listinfo/llvm-commits > From deeppatel1987 at gmail.com Mon Aug 9 21:56:21 2010 From: deeppatel1987 at gmail.com (Sandeep Patel) Date: Tue, 10 Aug 2010 02:56:21 +0000 Subject: [llvm-commits] [patch] Don't link as many parts of llvm into bugpoint In-Reply-To: References: Message-ID: If this and the previous patches related to plugins break bugpoint on MinGW, please revert them. I'd like for my users to be able to reduce bugs for me. deep On Tue, Aug 10, 2010 at 2:32 AM, Rafael Espindola wrote: > The attached patch is mostly a request for comments. On a debug build > it reduces bugpoint from 68 MB to 34 MB. The difference is not free: > > *) The std-compile-opts and std-link-opts are gone. > *) Passes now have to be listed with the -pass option. > > I think I can get those back with some more refactoring, but would > like some opinions first. Do you think the patch is OK? Do you think > it is OK if I manage to keep the current command line interface? The > main reason for this is that since bugpoint is a tool for hunting bugs > in llvm, it is nice for it to not be linked with every single LLVM > pass. Specially if the only thing it does with most of those passes is > collect their names :-) > > Cheers, > -- > Rafael ?vila de Esp?ndola > > _______________________________________________ > llvm-commits mailing list > llvm-commits at cs.uiuc.edu > http://lists.cs.uiuc.edu/mailman/listinfo/llvm-commits > > From espindola at google.com Mon Aug 9 22:05:41 2010 From: espindola at google.com (Rafael Espindola) Date: Mon, 9 Aug 2010 23:05:41 -0400 Subject: [llvm-commits] [patch] Don't link as many parts of llvm into bugpoint In-Reply-To: References: Message-ID: On 9 August 2010 22:56, Sandeep Patel wrote: > If this and the previous patches related to plugins break bugpoint on > MinGW, please revert them. I'd like for my users to be able to reduce > bugs for me. They don't. The plugin patch brakes bugpoint's own tests since the broken passes it uses are now in a plugin. That was considered a better solution than adding those passes to opt. I did post a patch that would add them to opt instead. If you prefer that you can try to convince others that it was better. > deep Cheers, -- Rafael ?vila de Esp?ndola From pichet2000 at gmail.com Mon Aug 9 22:58:19 2010 From: pichet2000 at gmail.com (Francois Pichet) Date: Mon, 9 Aug 2010 23:58:19 -0400 Subject: [llvm-commits] [llvm] r110627 - in /llvm/trunk: include/llvm/CodeGen/Passes.h lib/CodeGen/LLVMTargetMachine.cpp lib/CodeGen/OptimizeCmps.cpp lib/CodeGen/OptimizeExts.cpp lib/CodeGen/PeepholeOptimizer.cpp In-Reply-To: <20100809235904.C7CAD2A6C12C@llvm.org> References: <20100809235904.C7CAD2A6C12C@llvm.org> Message-ID: This break CMake ( at least on Windows) Please add PeepholeOptimizer.cpp and remove OptimizeCmps.cpp, OptimizeExts.cpp from llvm/trunk/lib/CodeGen/CMakeLists.txt On Mon, Aug 9, 2010 at 7:59 PM, Bill Wendling wrote: > Author: void > Date: Mon Aug ?9 18:59:04 2010 > New Revision: 110627 > > URL: http://llvm.org/viewvc/llvm-project?rev=110627&view=rev > Log: > Merge the OptimizeExts and OptimizeCmps passes into one PeepholeOptimizer > pass. This pass should expand with all of the small, fine-grained optimization > passes to reduce compile time and increase happiment. > > Added: > ? ?llvm/trunk/lib/CodeGen/PeepholeOptimizer.cpp > Removed: > ? ?llvm/trunk/lib/CodeGen/OptimizeCmps.cpp > ? ?llvm/trunk/lib/CodeGen/OptimizeExts.cpp > Modified: > ? ?llvm/trunk/include/llvm/CodeGen/Passes.h > ? ?llvm/trunk/lib/CodeGen/LLVMTargetMachine.cpp > > Modified: llvm/trunk/include/llvm/CodeGen/Passes.h > URL: http://llvm.org/viewvc/llvm-project/llvm/trunk/include/llvm/CodeGen/Passes.h?rev=110627&r1=110626&r2=110627&view=diff > ============================================================================== > --- llvm/trunk/include/llvm/CodeGen/Passes.h (original) > +++ llvm/trunk/include/llvm/CodeGen/Passes.h Mon Aug ?9 18:59:04 2010 > @@ -172,18 +172,14 @@ > ? /// instructions. > ? FunctionPass *createMachineSinkingPass(); > > - ?/// createOptimizeExtsPass - This pass performs sign / zero extension > - ?/// optimization by increasing uses of extended values. > - ?FunctionPass *createOptimizeExtsPass(); > + ?/// createPeepholeOptimizerPass - This pass performs peephole optimizations - > + ?/// like extension and comparison eliminations. > + ?FunctionPass *createPeepholeOptimizerPass(); > > ? /// createOptimizePHIsPass - This pass optimizes machine instruction PHIs > ? /// to take advantage of opportunities created during DAG legalization. > ? FunctionPass *createOptimizePHIsPass(); > > - ?/// createOptimizeCmpsPass - This pass performs redundant comparison removal > - ?/// optimization. > - ?FunctionPass *createOptimizeCmpsPass(); > - > ? /// createStackSlotColoringPass - This pass performs stack slot coloring. > ? FunctionPass *createStackSlotColoringPass(bool); > > > Modified: llvm/trunk/lib/CodeGen/LLVMTargetMachine.cpp > URL: http://llvm.org/viewvc/llvm-project/llvm/trunk/lib/CodeGen/LLVMTargetMachine.cpp?rev=110627&r1=110626&r2=110627&view=diff > ============================================================================== > --- llvm/trunk/lib/CodeGen/LLVMTargetMachine.cpp (original) > +++ llvm/trunk/lib/CodeGen/LLVMTargetMachine.cpp Mon Aug ?9 18:59:04 2010 > @@ -353,8 +353,7 @@ > ? ? PM.add(createDeadMachineInstructionElimPass()); > ? ? printAndVerify(PM, "After codegen DCE pass"); > > - ? ?PM.add(createOptimizeExtsPass()); > - ? ?PM.add(createOptimizeCmpsPass()); > + ? ?PM.add(createPeepholeOptimizerPass()); > ? ? if (!DisableMachineLICM) > ? ? ? PM.add(createMachineLICMPass()); > ? ? PM.add(createMachineCSEPass()); > > Removed: llvm/trunk/lib/CodeGen/OptimizeCmps.cpp > URL: http://llvm.org/viewvc/llvm-project/llvm/trunk/lib/CodeGen/OptimizeCmps.cpp?rev=110626&view=auto > ============================================================================== > --- llvm/trunk/lib/CodeGen/OptimizeCmps.cpp (original) > +++ llvm/trunk/lib/CodeGen/OptimizeCmps.cpp (removed) > @@ -1,112 +0,0 @@ > -//===-- OptimizeCmps.cpp - Optimize comparison instrs ---------------------===// > -// > -// ? ? ? ? ? ? ? ? ? ? The LLVM Compiler Infrastructure > -// > -// This file is distributed under the University of Illinois Open Source > -// License. See LICENSE.TXT for details. > -// > -//===----------------------------------------------------------------------===// > -// > -// This pass performs optimization of comparison instructions. For instance, in > -// this code: > -// > -// ? ? sub r1, 1 > -// ? ? cmp r1, 0 > -// ? ? bz ?L1 > -// > -// If the "sub" instruction all ready sets (or could be modified to set) the > -// same flag that the "cmp" instruction sets and that "bz" uses, then we can > -// eliminate the "cmp" instruction. > -// > -//===----------------------------------------------------------------------===// > - > -#define DEBUG_TYPE "opt-compares" > -#include "llvm/CodeGen/Passes.h" > -#include "llvm/CodeGen/MachineFunctionPass.h" > -#include "llvm/CodeGen/MachineInstrBuilder.h" > -#include "llvm/CodeGen/MachineRegisterInfo.h" > -#include "llvm/Target/TargetInstrInfo.h" > -#include "llvm/Target/TargetRegisterInfo.h" > -#include "llvm/Support/CommandLine.h" > -#include "llvm/ADT/Statistic.h" > -using namespace llvm; > - > -STATISTIC(NumEliminated, "Number of compares eliminated"); > - > -static cl::opt > -EnableOptCmps("enable-optimize-cmps", cl::init(false), cl::Hidden); > - > -namespace { > - ?class OptimizeCmps : public MachineFunctionPass { > - ? ?const TargetMachine ? *TM; > - ? ?const TargetInstrInfo *TII; > - ? ?MachineRegisterInfo ? *MRI; > - > - ? ?bool OptimizeCmpInstr(MachineInstr *MI, MachineBasicBlock *MBB); > - > - ?public: > - ? ?static char ID; // Pass identification > - ? ?OptimizeCmps() : MachineFunctionPass(ID) {} > - > - ? ?virtual bool runOnMachineFunction(MachineFunction &MF); > - > - ? ?virtual void getAnalysisUsage(AnalysisUsage &AU) const { > - ? ? ?AU.setPreservesCFG(); > - ? ? ?MachineFunctionPass::getAnalysisUsage(AU); > - ? ?} > - ?}; > -} > - > -char OptimizeCmps::ID = 0; > -INITIALIZE_PASS(OptimizeCmps, "opt-cmps", > - ? ? ? ? ? ? ? ?"Optimize comparison instrs", false, false); > - > -FunctionPass *llvm::createOptimizeCmpsPass() { return new OptimizeCmps(); } > - > -/// OptimizeCmpInstr - If the instruction is a compare and the previous > -/// instruction it's comparing against all ready sets (or could be modified to > -/// set) the same flag as the compare, then we can remove the comparison and use > -/// the flag from the previous instruction. > -bool OptimizeCmps::OptimizeCmpInstr(MachineInstr *MI, MachineBasicBlock *MBB) { > - ?// If this instruction is a comparison against zero and isn't comparing a > - ?// physical register, we can try to optimize it. > - ?unsigned SrcReg; > - ?int CmpValue; > - ?if (!TII->AnalyzeCompare(MI, SrcReg, CmpValue) || > - ? ? ?TargetRegisterInfo::isPhysicalRegister(SrcReg) || CmpValue != 0) > - ? ?return false; > - > - ?MachineRegisterInfo::def_iterator DI = MRI->def_begin(SrcReg); > - ?if (llvm::next(DI) != MRI->def_end()) > - ? ?// Only support one definition. > - ? ?return false; > - > - ?// Attempt to convert the defining instruction to set the "zero" flag. > - ?if (TII->ConvertToSetZeroFlag(&*DI, MI)) { > - ? ?++NumEliminated; > - ? ?return true; > - ?} > - > - ?return false; > -} > - > -bool OptimizeCmps::runOnMachineFunction(MachineFunction &MF) { > - ?TM = &MF.getTarget(); > - ?TII = TM->getInstrInfo(); > - ?MRI = &MF.getRegInfo(); > - > - ?if (!EnableOptCmps) return false; > - > - ?bool Changed = false; > - ?for (MachineFunction::iterator I = MF.begin(), E = MF.end(); I != E; ++I) { > - ? ?MachineBasicBlock *MBB = &*I; > - ? ?for (MachineBasicBlock::iterator > - ? ? ? ? ? MII = MBB->begin(), ME = MBB->end(); MII != ME; ) { > - ? ? ?MachineInstr *MI = &*MII++; > - ? ? ?if (MI->getDesc().isCompare()) > - ? ? ? ?Changed |= OptimizeCmpInstr(MI, MBB); > - ? ?} > - ?} > - > - ?return Changed; > -} > > Removed: llvm/trunk/lib/CodeGen/OptimizeExts.cpp > URL: http://llvm.org/viewvc/llvm-project/llvm/trunk/lib/CodeGen/OptimizeExts.cpp?rev=110626&view=auto > ============================================================================== > --- llvm/trunk/lib/CodeGen/OptimizeExts.cpp (original) > +++ llvm/trunk/lib/CodeGen/OptimizeExts.cpp (removed) > @@ -1,221 +0,0 @@ > -//===-- OptimizeExts.cpp - Optimize sign / zero extension instrs -----===// > -// > -// ? ? ? ? ? ? ? ? ? ? The LLVM Compiler Infrastructure > -// > -// This file is distributed under the University of Illinois Open Source > -// License. See LICENSE.TXT for details. > -// > -//===----------------------------------------------------------------------===// > -// > -// This pass performs optimization of sign / zero extension instructions. It > -// may be extended to handle other instructions of similar property. > -// > -// On some targets, some instructions, e.g. X86 sign / zero extension, may > -// leave the source value in the lower part of the result. This pass will > -// replace (some) uses of the pre-extension value with uses of the sub-register > -// of the results. > -// > -//===----------------------------------------------------------------------===// > - > -#define DEBUG_TYPE "ext-opt" > -#include "llvm/CodeGen/Passes.h" > -#include "llvm/CodeGen/MachineDominators.h" > -#include "llvm/CodeGen/MachineInstrBuilder.h" > -#include "llvm/CodeGen/MachineRegisterInfo.h" > -#include "llvm/Target/TargetInstrInfo.h" > -#include "llvm/Target/TargetRegisterInfo.h" > -#include "llvm/Support/CommandLine.h" > -#include "llvm/ADT/SmallPtrSet.h" > -#include "llvm/ADT/Statistic.h" > -using namespace llvm; > - > -static cl::opt Aggressive("aggressive-ext-opt", cl::Hidden, > - ? ? ? ? ? ? ? ? ? ? ? ? ? ? ? ?cl::desc("Aggressive extension optimization")); > - > -STATISTIC(NumReuse, "Number of extension results reused"); > - > -namespace { > - ?class OptimizeExts : public MachineFunctionPass { > - ? ?const TargetMachine ? *TM; > - ? ?const TargetInstrInfo *TII; > - ? ?MachineRegisterInfo *MRI; > - ? ?MachineDominatorTree *DT; ? // Machine dominator tree > - > - ?public: > - ? ?static char ID; // Pass identification > - ? ?OptimizeExts() : MachineFunctionPass(ID) {} > - > - ? ?virtual bool runOnMachineFunction(MachineFunction &MF); > - > - ? ?virtual void getAnalysisUsage(AnalysisUsage &AU) const { > - ? ? ?AU.setPreservesCFG(); > - ? ? ?MachineFunctionPass::getAnalysisUsage(AU); > - ? ? ?if (Aggressive) { > - ? ? ? ?AU.addRequired(); > - ? ? ? ?AU.addPreserved(); > - ? ? ?} > - ? ?} > - > - ?private: > - ? ?bool OptimizeInstr(MachineInstr *MI, MachineBasicBlock *MBB, > - ? ? ? ? ? ? ? ? ? ? ? SmallPtrSet &LocalMIs); > - ?}; > -} > - > -char OptimizeExts::ID = 0; > -INITIALIZE_PASS(OptimizeExts, "opt-exts", > - ? ? ? ? ? ? ? ?"Optimize sign / zero extensions", false, false); > - > -FunctionPass *llvm::createOptimizeExtsPass() { return new OptimizeExts(); } > - > -/// OptimizeInstr - If instruction is a copy-like instruction, i.e. it reads > -/// a single register and writes a single register and it does not modify > -/// the source, and if the source value is preserved as a sub-register of > -/// the result, then replace all reachable uses of the source with the subreg > -/// of the result. > -/// Do not generate an EXTRACT that is used only in a debug use, as this > -/// changes the code. ?Since this code does not currently share EXTRACTs, just > -/// ignore all debug uses. > -bool OptimizeExts::OptimizeInstr(MachineInstr *MI, MachineBasicBlock *MBB, > - ? ? ? ? ? ? ? ? ? ? ? ? ? ? ? ? SmallPtrSet &LocalMIs) { > - ?LocalMIs.insert(MI); > - > - ?unsigned SrcReg, DstReg, SubIdx; > - ?if (!TII->isCoalescableExtInstr(*MI, SrcReg, DstReg, SubIdx)) > - ? ?return false; > - > - ?if (TargetRegisterInfo::isPhysicalRegister(DstReg) || > - ? ? ?TargetRegisterInfo::isPhysicalRegister(SrcReg)) > - ? ?return false; > - > - ?MachineRegisterInfo::use_nodbg_iterator UI = MRI->use_nodbg_begin(SrcReg); > - ?if (++UI == MRI->use_nodbg_end()) > - ? ?// No other uses. > - ? ?return false; > - > - ?// Ok, the source has other uses. See if we can replace the other uses > - ?// with use of the result of the extension. > - ?SmallPtrSet ReachedBBs; > - ?UI = MRI->use_nodbg_begin(DstReg); > - ?for (MachineRegisterInfo::use_nodbg_iterator UE = MRI->use_nodbg_end(); > - ? ? ? UI != UE; ++UI) > - ? ?ReachedBBs.insert(UI->getParent()); > - > - ?bool ExtendLife = true; > - ?// Uses that are in the same BB of uses of the result of the instruction. > - ?SmallVector Uses; > - ?// Uses that the result of the instruction can reach. > - ?SmallVector ExtendedUses; > - > - ?UI = MRI->use_nodbg_begin(SrcReg); > - ?for (MachineRegisterInfo::use_nodbg_iterator UE = MRI->use_nodbg_end(); > - ? ? ? UI != UE; ++UI) { > - ? ?MachineOperand &UseMO = UI.getOperand(); > - ? ?MachineInstr *UseMI = &*UI; > - ? ?if (UseMI == MI) > - ? ? ?continue; > - ? ?if (UseMI->isPHI()) { > - ? ? ?ExtendLife = false; > - ? ? ?continue; > - ? ?} > - > - ? ?// It's an error to translate this: > - ? ?// > - ? ?// ? ?%reg1025 = %reg1024 > - ? ?// ? ? ... > - ? ?// ? ?%reg1026 = SUBREG_TO_REG 0, %reg1024, 4 > - ? ?// > - ? ?// into this: > - ? ?// > - ? ?// ? ?%reg1025 = %reg1024 > - ? ?// ? ? ... > - ? ?// ? ?%reg1027 = COPY %reg1025:4 > - ? ?// ? ?%reg1026 = SUBREG_TO_REG 0, %reg1027, 4 > - ? ?// > - ? ?// The problem here is that SUBREG_TO_REG is there to assert that an > - ? ?// implicit zext occurs. It doesn't insert a zext instruction. If we allow > - ? ?// the COPY here, it will give us the value after the , not the > - ? ?// original value of %reg1024 before . > - ? ?if (UseMI->getOpcode() == TargetOpcode::SUBREG_TO_REG) > - ? ? ?continue; > - > - ? ?MachineBasicBlock *UseMBB = UseMI->getParent(); > - ? ?if (UseMBB == MBB) { > - ? ? ?// Local uses that come after the extension. > - ? ? ?if (!LocalMIs.count(UseMI)) > - ? ? ? ?Uses.push_back(&UseMO); > - ? ?} else if (ReachedBBs.count(UseMBB)) > - ? ? ?// Non-local uses where the result of extension is used. Always replace > - ? ? ?// these unless it's a PHI. > - ? ? ?Uses.push_back(&UseMO); > - ? ?else if (Aggressive && DT->dominates(MBB, UseMBB)) > - ? ? ?// We may want to extend live range of the extension result in order to > - ? ? ?// replace these uses. > - ? ? ?ExtendedUses.push_back(&UseMO); > - ? ?else { > - ? ? ?// Both will be live out of the def MBB anyway. Don't extend live range of > - ? ? ?// the extension result. > - ? ? ?ExtendLife = false; > - ? ? ?break; > - ? ?} > - ?} > - > - ?if (ExtendLife && !ExtendedUses.empty()) > - ? ?// Ok, we'll extend the liveness of the extension result. > - ? ?std::copy(ExtendedUses.begin(), ExtendedUses.end(), > - ? ? ? ? ? ? ?std::back_inserter(Uses)); > - > - ?// Now replace all uses. > - ?bool Changed = false; > - ?if (!Uses.empty()) { > - ? ?SmallPtrSet PHIBBs; > - ? ?// Look for PHI uses of the extended result, we don't want to extend the > - ? ?// liveness of a PHI input. It breaks all kinds of assumptions down > - ? ?// stream. A PHI use is expected to be the kill of its source values. > - ? ?UI = MRI->use_nodbg_begin(DstReg); > - ? ?for (MachineRegisterInfo::use_nodbg_iterator UE = MRI->use_nodbg_end(); > - ? ? ? ? UI != UE; ++UI) > - ? ? ?if (UI->isPHI()) > - ? ? ? ?PHIBBs.insert(UI->getParent()); > - > - ? ?const TargetRegisterClass *RC = MRI->getRegClass(SrcReg); > - ? ?for (unsigned i = 0, e = Uses.size(); i != e; ++i) { > - ? ? ?MachineOperand *UseMO = Uses[i]; > - ? ? ?MachineInstr *UseMI = UseMO->getParent(); > - ? ? ?MachineBasicBlock *UseMBB = UseMI->getParent(); > - ? ? ?if (PHIBBs.count(UseMBB)) > - ? ? ? ?continue; > - ? ? ?unsigned NewVR = MRI->createVirtualRegister(RC); > - ? ? ?BuildMI(*UseMBB, UseMI, UseMI->getDebugLoc(), > - ? ? ? ? ? ? ?TII->get(TargetOpcode::COPY), NewVR) > - ? ? ? ?.addReg(DstReg, 0, SubIdx); > - ? ? ?UseMO->setReg(NewVR); > - ? ? ?++NumReuse; > - ? ? ?Changed = true; > - ? ?} > - ?} > - > - ?return Changed; > -} > - > -bool OptimizeExts::runOnMachineFunction(MachineFunction &MF) { > - ?TM = &MF.getTarget(); > - ?TII = TM->getInstrInfo(); > - ?MRI = &MF.getRegInfo(); > - ?DT = Aggressive ? &getAnalysis() : 0; > - > - ?bool Changed = false; > - > - ?SmallPtrSet LocalMIs; > - ?for (MachineFunction::iterator I = MF.begin(), E = MF.end(); I != E; ++I) { > - ? ?MachineBasicBlock *MBB = &*I; > - ? ?LocalMIs.clear(); > - ? ?for (MachineBasicBlock::iterator MII = I->begin(), ME = I->end(); MII != ME; > - ? ? ? ? ++MII) { > - ? ? ?MachineInstr *MI = &*MII; > - ? ? ?Changed |= OptimizeInstr(MI, MBB, LocalMIs); > - ? ?} > - ?} > - > - ?return Changed; > -} > > Added: llvm/trunk/lib/CodeGen/PeepholeOptimizer.cpp > URL: http://llvm.org/viewvc/llvm-project/llvm/trunk/lib/CodeGen/PeepholeOptimizer.cpp?rev=110627&view=auto > ============================================================================== > --- llvm/trunk/lib/CodeGen/PeepholeOptimizer.cpp (added) > +++ llvm/trunk/lib/CodeGen/PeepholeOptimizer.cpp Mon Aug ?9 18:59:04 2010 > @@ -0,0 +1,293 @@ > +//===-- PeepholeOptimizer.cpp - Peephole Optimizations --------------------===// > +// > +// ? ? ? ? ? ? ? ? ? ? The LLVM Compiler Infrastructure > +// > +// This file is distributed under the University of Illinois Open Source > +// License. See LICENSE.TXT for details. > +// > +//===----------------------------------------------------------------------===// > +// > +// Perform peephole optimizations on the machine code: > +// > +// - Optimize Extensions > +// > +// ? ? Optimization of sign / zero extension instructions. It may be extended to > +// ? ? handle other instructions with similar properties. > +// > +// ? ? On some targets, some instructions, e.g. X86 sign / zero extension, may > +// ? ? leave the source value in the lower part of the result. This optimization > +// ? ? will replace some uses of the pre-extension value with uses of the > +// ? ? sub-register of the results. > +// > +// - Optimize Comparisons > +// > +// ? ? Optimization of comparison instructions. For instance, in this code: > +// > +// ? ? ? sub r1, 1 > +// ? ? ? cmp r1, 0 > +// ? ? ? bz ?L1 > +// > +// ? ? If the "sub" instruction all ready sets (or could be modified to set) the > +// ? ? same flag that the "cmp" instruction sets and that "bz" uses, then we can > +// ? ? eliminate the "cmp" instruction. > +// > +//===----------------------------------------------------------------------===// > + > +#define DEBUG_TYPE "peephole-opt" > +#include "llvm/CodeGen/Passes.h" > +#include "llvm/CodeGen/MachineDominators.h" > +#include "llvm/CodeGen/MachineInstrBuilder.h" > +#include "llvm/CodeGen/MachineRegisterInfo.h" > +#include "llvm/Target/TargetInstrInfo.h" > +#include "llvm/Target/TargetRegisterInfo.h" > +#include "llvm/Support/CommandLine.h" > +#include "llvm/ADT/SmallPtrSet.h" > +#include "llvm/ADT/Statistic.h" > +using namespace llvm; > + > +// Optimize Extensions > +static cl::opt > +Aggressive("aggressive-ext-opt", cl::Hidden, > + ? ? ? ? ? cl::desc("Aggressive extension optimization")); > + > +STATISTIC(NumReuse, "Number of extension results reused"); > + > +// Optimize Comparisons > +static cl::opt > +EnableOptCmps("enable-optimize-cmps", cl::init(false), cl::Hidden); > + > +STATISTIC(NumEliminated, "Number of compares eliminated"); > + > +namespace { > + ?class PeepholeOptimizer : public MachineFunctionPass { > + ? ?const TargetMachine ? *TM; > + ? ?const TargetInstrInfo *TII; > + ? ?MachineRegisterInfo ? *MRI; > + ? ?MachineDominatorTree ?*DT; ?// Machine dominator tree > + > + ?public: > + ? ?static char ID; // Pass identification > + ? ?PeepholeOptimizer() : MachineFunctionPass(ID) {} > + > + ? ?virtual bool runOnMachineFunction(MachineFunction &MF); > + > + ? ?virtual void getAnalysisUsage(AnalysisUsage &AU) const { > + ? ? ?AU.setPreservesCFG(); > + ? ? ?MachineFunctionPass::getAnalysisUsage(AU); > + ? ? ?if (Aggressive) { > + ? ? ? ?AU.addRequired(); > + ? ? ? ?AU.addPreserved(); > + ? ? ?} > + ? ?} > + > + ?private: > + ? ?bool OptimizeCmpInstr(MachineInstr *MI, MachineBasicBlock *MBB); > + ? ?bool OptimizeExtInstr(MachineInstr *MI, MachineBasicBlock *MBB, > + ? ? ? ? ? ? ? ? ? ? ? ? ?SmallPtrSet &LocalMIs); > + ?}; > +} > + > +char PeepholeOptimizer::ID = 0; > +INITIALIZE_PASS(PeepholeOptimizer, "peephole-opts", > + ? ? ? ? ? ? ? ?"Peephole Optimizations", false, false); > + > +FunctionPass *llvm::createPeepholeOptimizerPass() { > + ?return new PeepholeOptimizer(); > +} > + > +/// OptimizeExtInstr - If instruction is a copy-like instruction, i.e. it reads > +/// a single register and writes a single register and it does not modify the > +/// source, and if the source value is preserved as a sub-register of the > +/// result, then replace all reachable uses of the source with the subreg of the > +/// result. > +/// > +/// Do not generate an EXTRACT that is used only in a debug use, as this changes > +/// the code. Since this code does not currently share EXTRACTs, just ignore all > +/// debug uses. > +bool PeepholeOptimizer:: > +OptimizeExtInstr(MachineInstr *MI, MachineBasicBlock *MBB, > + ? ? ? ? ? ? ? ? SmallPtrSet &LocalMIs) { > + ?LocalMIs.insert(MI); > + > + ?unsigned SrcReg, DstReg, SubIdx; > + ?if (!TII->isCoalescableExtInstr(*MI, SrcReg, DstReg, SubIdx)) > + ? ?return false; > + > + ?if (TargetRegisterInfo::isPhysicalRegister(DstReg) || > + ? ? ?TargetRegisterInfo::isPhysicalRegister(SrcReg)) > + ? ?return false; > + > + ?MachineRegisterInfo::use_nodbg_iterator UI = MRI->use_nodbg_begin(SrcReg); > + ?if (++UI == MRI->use_nodbg_end()) > + ? ?// No other uses. > + ? ?return false; > + > + ?// The source has other uses. See if we can replace the other uses with use of > + ?// the result of the extension. > + ?SmallPtrSet ReachedBBs; > + ?UI = MRI->use_nodbg_begin(DstReg); > + ?for (MachineRegisterInfo::use_nodbg_iterator UE = MRI->use_nodbg_end(); > + ? ? ? UI != UE; ++UI) > + ? ?ReachedBBs.insert(UI->getParent()); > + > + ?// Uses that are in the same BB of uses of the result of the instruction. > + ?SmallVector Uses; > + > + ?// Uses that the result of the instruction can reach. > + ?SmallVector ExtendedUses; > + > + ?bool ExtendLife = true; > + ?UI = MRI->use_nodbg_begin(SrcReg); > + ?for (MachineRegisterInfo::use_nodbg_iterator UE = MRI->use_nodbg_end(); > + ? ? ? UI != UE; ++UI) { > + ? ?MachineOperand &UseMO = UI.getOperand(); > + ? ?MachineInstr *UseMI = &*UI; > + ? ?if (UseMI == MI) > + ? ? ?continue; > + > + ? ?if (UseMI->isPHI()) { > + ? ? ?ExtendLife = false; > + ? ? ?continue; > + ? ?} > + > + ? ?// It's an error to translate this: > + ? ?// > + ? ?// ? ?%reg1025 = %reg1024 > + ? ?// ? ? ... > + ? ?// ? ?%reg1026 = SUBREG_TO_REG 0, %reg1024, 4 > + ? ?// > + ? ?// into this: > + ? ?// > + ? ?// ? ?%reg1025 = %reg1024 > + ? ?// ? ? ... > + ? ?// ? ?%reg1027 = COPY %reg1025:4 > + ? ?// ? ?%reg1026 = SUBREG_TO_REG 0, %reg1027, 4 > + ? ?// > + ? ?// The problem here is that SUBREG_TO_REG is there to assert that an > + ? ?// implicit zext occurs. It doesn't insert a zext instruction. If we allow > + ? ?// the COPY here, it will give us the value after the , not the > + ? ?// original value of %reg1024 before . > + ? ?if (UseMI->getOpcode() == TargetOpcode::SUBREG_TO_REG) > + ? ? ?continue; > + > + ? ?MachineBasicBlock *UseMBB = UseMI->getParent(); > + ? ?if (UseMBB == MBB) { > + ? ? ?// Local uses that come after the extension. > + ? ? ?if (!LocalMIs.count(UseMI)) > + ? ? ? ?Uses.push_back(&UseMO); > + ? ?} else if (ReachedBBs.count(UseMBB)) { > + ? ? ?// Non-local uses where the result of the extension is used. Always > + ? ? ?// replace these unless it's a PHI. > + ? ? ?Uses.push_back(&UseMO); > + ? ?} else if (Aggressive && DT->dominates(MBB, UseMBB)) { > + ? ? ?// We may want to extend the live range of the extension result in order > + ? ? ?// to replace these uses. > + ? ? ?ExtendedUses.push_back(&UseMO); > + ? ?} else { > + ? ? ?// Both will be live out of the def MBB anyway. Don't extend live range of > + ? ? ?// the extension result. > + ? ? ?ExtendLife = false; > + ? ? ?break; > + ? ?} > + ?} > + > + ?if (ExtendLife && !ExtendedUses.empty()) > + ? ?// Extend the liveness of the extension result. > + ? ?std::copy(ExtendedUses.begin(), ExtendedUses.end(), > + ? ? ? ? ? ? ?std::back_inserter(Uses)); > + > + ?// Now replace all uses. > + ?bool Changed = false; > + ?if (!Uses.empty()) { > + ? ?SmallPtrSet PHIBBs; > + > + ? ?// Look for PHI uses of the extended result, we don't want to extend the > + ? ?// liveness of a PHI input. It breaks all kinds of assumptions down > + ? ?// stream. A PHI use is expected to be the kill of its source values. > + ? ?UI = MRI->use_nodbg_begin(DstReg); > + ? ?for (MachineRegisterInfo::use_nodbg_iterator > + ? ? ? ? ? UE = MRI->use_nodbg_end(); UI != UE; ++UI) > + ? ? ?if (UI->isPHI()) > + ? ? ? ?PHIBBs.insert(UI->getParent()); > + > + ? ?const TargetRegisterClass *RC = MRI->getRegClass(SrcReg); > + ? ?for (unsigned i = 0, e = Uses.size(); i != e; ++i) { > + ? ? ?MachineOperand *UseMO = Uses[i]; > + ? ? ?MachineInstr *UseMI = UseMO->getParent(); > + ? ? ?MachineBasicBlock *UseMBB = UseMI->getParent(); > + ? ? ?if (PHIBBs.count(UseMBB)) > + ? ? ? ?continue; > + > + ? ? ?unsigned NewVR = MRI->createVirtualRegister(RC); > + ? ? ?BuildMI(*UseMBB, UseMI, UseMI->getDebugLoc(), > + ? ? ? ? ? ? ?TII->get(TargetOpcode::COPY), NewVR) > + ? ? ? ?.addReg(DstReg, 0, SubIdx); > + > + ? ? ?UseMO->setReg(NewVR); > + ? ? ?++NumReuse; > + ? ? ?Changed = true; > + ? ?} > + ?} > + > + ?return Changed; > +} > + > +/// OptimizeCmpInstr - If the instruction is a compare and the previous > +/// instruction it's comparing against all ready sets (or could be modified to > +/// set) the same flag as the compare, then we can remove the comparison and use > +/// the flag from the previous instruction. > +bool PeepholeOptimizer::OptimizeCmpInstr(MachineInstr *MI, > + ? ? ? ? ? ? ? ? ? ? ? ? ? ? ? ? ? ? ? ? MachineBasicBlock *MBB) { > + ?if (!EnableOptCmps) return false; > + > + ?// If this instruction is a comparison against zero and isn't comparing a > + ?// physical register, we can try to optimize it. > + ?unsigned SrcReg; > + ?int CmpValue; > + ?if (!TII->AnalyzeCompare(MI, SrcReg, CmpValue) || > + ? ? ?TargetRegisterInfo::isPhysicalRegister(SrcReg) || CmpValue != 0) > + ? ?return false; > + > + ?MachineRegisterInfo::def_iterator DI = MRI->def_begin(SrcReg); > + ?if (llvm::next(DI) != MRI->def_end()) > + ? ?// Only support one definition. > + ? ?return false; > + > + ?// Attempt to convert the defining instruction to set the "zero" flag. > + ?if (TII->ConvertToSetZeroFlag(&*DI, MI)) { > + ? ?++NumEliminated; > + ? ?return true; > + ?} > + > + ?return false; > +} > + > +bool PeepholeOptimizer::runOnMachineFunction(MachineFunction &MF) { > + ?TM ?= &MF.getTarget(); > + ?TII = TM->getInstrInfo(); > + ?MRI = &MF.getRegInfo(); > + ?DT ?= Aggressive ? &getAnalysis() : 0; > + > + ?bool Changed = false; > + > + ?SmallPtrSet LocalMIs; > + ?for (MachineFunction::iterator I = MF.begin(), E = MF.end(); I != E; ++I) { > + ? ?MachineBasicBlock *MBB = &*I; > + ? ?LocalMIs.clear(); > + > + ? ?for (MachineBasicBlock::iterator > + ? ? ? ? ? MII = I->begin(), ME = I->end(); MII != ME; ) { > + ? ? ?MachineInstr *MI = &*MII; > + > + ? ? ?if (MI->getDesc().isCompare()) { > + ? ? ? ?++MII; // The iterator may become invalid if the compare is deleted. > + ? ? ? ?Changed |= OptimizeCmpInstr(MI, MBB); > + ? ? ?} else { > + ? ? ? ?Changed |= OptimizeExtInstr(MI, MBB, LocalMIs); > + ? ? ? ?++MII; > + ? ? ?} > + ? ?} > + ?} > + > + ?return Changed; > +} > > > _______________________________________________ > llvm-commits mailing list > llvm-commits at cs.uiuc.edu > http://lists.cs.uiuc.edu/mailman/listinfo/llvm-commits > From dpatel at apple.com Mon Aug 9 23:09:06 2010 From: dpatel at apple.com (Devang Patel) Date: Tue, 10 Aug 2010 04:09:06 -0000 Subject: [llvm-commits] [llvm] r110652 - in /llvm/trunk/lib/CodeGen/AsmPrinter: DwarfDebug.cpp DwarfDebug.h Message-ID: <20100810040906.7DBFF2A6C12C@llvm.org> Author: dpatel Date: Mon Aug 9 23:09:06 2010 New Revision: 110652 URL: http://llvm.org/viewvc/llvm-project?rev=110652&view=rev Log: Drop "const". It does not add value here. Modified: llvm/trunk/lib/CodeGen/AsmPrinter/DwarfDebug.cpp llvm/trunk/lib/CodeGen/AsmPrinter/DwarfDebug.h Modified: llvm/trunk/lib/CodeGen/AsmPrinter/DwarfDebug.cpp URL: http://llvm.org/viewvc/llvm-project/llvm/trunk/lib/CodeGen/AsmPrinter/DwarfDebug.cpp?rev=110652&r1=110651&r2=110652&view=diff ============================================================================== --- llvm/trunk/lib/CodeGen/AsmPrinter/DwarfDebug.cpp (original) +++ llvm/trunk/lib/CodeGen/AsmPrinter/DwarfDebug.cpp Mon Aug 9 23:09:06 2010 @@ -502,7 +502,7 @@ /// addSourceLine - Add location information to specified debug information /// entry. -void DwarfDebug::addSourceLine(DIE *Die, const DIVariable V) { +void DwarfDebug::addSourceLine(DIE *Die, DIVariable V) { // Verify variable. if (!V.Verify()) return; @@ -517,7 +517,7 @@ /// addSourceLine - Add location information to specified debug information /// entry. -void DwarfDebug::addSourceLine(DIE *Die, const DIGlobalVariable G) { +void DwarfDebug::addSourceLine(DIE *Die, DIGlobalVariable G) { // Verify global variable. if (!G.Verify()) return; @@ -532,7 +532,7 @@ /// addSourceLine - Add location information to specified debug information /// entry. -void DwarfDebug::addSourceLine(DIE *Die, const DISubprogram SP) { +void DwarfDebug::addSourceLine(DIE *Die, DISubprogram SP) { // Verify subprogram. if (!SP.Verify()) return; @@ -552,7 +552,7 @@ /// addSourceLine - Add location information to specified debug information /// entry. -void DwarfDebug::addSourceLine(DIE *Die, const DIType Ty) { +void DwarfDebug::addSourceLine(DIE *Die, DIType Ty) { // Verify type. if (!Ty.Verify()) return; @@ -569,7 +569,7 @@ /// addSourceLine - Add location information to specified debug information /// entry. -void DwarfDebug::addSourceLine(DIE *Die, const DINameSpace NS) { +void DwarfDebug::addSourceLine(DIE *Die, DINameSpace NS) { // Verify namespace. if (!NS.Verify()) return; Modified: llvm/trunk/lib/CodeGen/AsmPrinter/DwarfDebug.h URL: http://llvm.org/viewvc/llvm-project/llvm/trunk/lib/CodeGen/AsmPrinter/DwarfDebug.h?rev=110652&r1=110651&r2=110652&view=diff ============================================================================== --- llvm/trunk/lib/CodeGen/AsmPrinter/DwarfDebug.h (original) +++ llvm/trunk/lib/CodeGen/AsmPrinter/DwarfDebug.h Mon Aug 9 23:09:06 2010 @@ -338,11 +338,11 @@ /// addSourceLine - Add location information to specified debug information /// entry. - void addSourceLine(DIE *Die, const DIVariable V); - void addSourceLine(DIE *Die, const DIGlobalVariable G); - void addSourceLine(DIE *Die, const DISubprogram SP); - void addSourceLine(DIE *Die, const DIType Ty); - void addSourceLine(DIE *Die, const DINameSpace NS); + void addSourceLine(DIE *Die, DIVariable V); + void addSourceLine(DIE *Die, DIGlobalVariable G); + void addSourceLine(DIE *Die, DISubprogram SP); + void addSourceLine(DIE *Die, DIType Ty); + void addSourceLine(DIE *Die, DINameSpace NS); /// addAddress - Add an address attribute to a die based on the location /// provided. From dpatel at apple.com Mon Aug 9 23:11:20 2010 From: dpatel at apple.com (Devang Patel) Date: Mon, 9 Aug 2010 21:11:20 -0700 Subject: [llvm-commits] [llvm] r110590 - in /llvm/trunk/lib/CodeGen/AsmPrinter: DwarfDebug.cpp DwarfDebug.h In-Reply-To: <81977B77-34D5-4558-9A21-B393405FED87@apple.com> References: <20100809202005.9F55C2A6C12C@llvm.org> <9587A5EB-550D-46FE-B94B-BDCB20A6B493@apple.com> <81977B77-34D5-4558-9A21-B393405FED87@apple.com> Message-ID: <357B54A6-6AC6-44A6-A7DD-DA3DC57FD0E2@apple.com> On Aug 9, 2010, at 5:20 PM, Chris Lattner wrote: > > On Aug 9, 2010, at 3:23 PM, Bill Wendling wrote: > >> On Aug 9, 2010, at 1:20 PM, Devang Patel wrote: >> >>> Author: dpatel >>> Date: Mon Aug 9 15:20:05 2010 >>> New Revision: 110590 >>> >>> URL: http://llvm.org/viewvc/llvm-project?rev=110590&view=rev >>> Log: >>> It is ok, and convenient, to pass descriptors by value. >> >> Why not by reference? > > Because passing by value is more efficient for these simple value types. > > Devang, the patch looks good to me, but please remove the const from things like this: > > +void DwarfDebug::addSourceLine(DIE *Die, const DIVariable V) { > > You seem to have made a large mechanical change, please tidy up. Yup. done. More on the way. - Devang From dpatel at apple.com Mon Aug 9 23:12:17 2010 From: dpatel at apple.com (Devang Patel) Date: Tue, 10 Aug 2010 04:12:17 -0000 Subject: [llvm-commits] [llvm] r110653 - in /llvm/trunk/lib/CodeGen/AsmPrinter: DwarfDebug.cpp DwarfDebug.h Message-ID: <20100810041217.A773A2A6C12C@llvm.org> Author: dpatel Date: Mon Aug 9 23:12:17 2010 New Revision: 110653 URL: http://llvm.org/viewvc/llvm-project?rev=110653&view=rev Log: Simplify. Modified: llvm/trunk/lib/CodeGen/AsmPrinter/DwarfDebug.cpp llvm/trunk/lib/CodeGen/AsmPrinter/DwarfDebug.h Modified: llvm/trunk/lib/CodeGen/AsmPrinter/DwarfDebug.cpp URL: http://llvm.org/viewvc/llvm-project/llvm/trunk/lib/CodeGen/AsmPrinter/DwarfDebug.cpp?rev=110653&r1=110652&r2=110653&view=diff ============================================================================== --- llvm/trunk/lib/CodeGen/AsmPrinter/DwarfDebug.cpp (original) +++ llvm/trunk/lib/CodeGen/AsmPrinter/DwarfDebug.cpp Mon Aug 9 23:12:17 2010 @@ -1187,7 +1187,7 @@ } /// createMemberDIE - Create new member DIE. -DIE *DwarfDebug::createMemberDIE(const DIDerivedType &DT) { +DIE *DwarfDebug::createMemberDIE(DIDerivedType DT) { DIE *MemberDie = new DIE(DT.getTag()); StringRef Name = DT.getName(); if (!Name.empty()) @@ -1264,7 +1264,7 @@ } /// createSubprogramDIE - Create new DIE using SP. -DIE *DwarfDebug::createSubprogramDIE(const DISubprogram &SP, bool MakeDecl) { +DIE *DwarfDebug::createSubprogramDIE(DISubprogram SP, bool MakeDecl) { CompileUnit *SPCU = getCompileUnit(SP); DIE *SPDie = SPCU->getDIE(SP); if (SPDie) Modified: llvm/trunk/lib/CodeGen/AsmPrinter/DwarfDebug.h URL: http://llvm.org/viewvc/llvm-project/llvm/trunk/lib/CodeGen/AsmPrinter/DwarfDebug.h?rev=110653&r1=110652&r2=110653&view=diff ============================================================================== --- llvm/trunk/lib/CodeGen/AsmPrinter/DwarfDebug.h (original) +++ llvm/trunk/lib/CodeGen/AsmPrinter/DwarfDebug.h Mon Aug 9 23:12:17 2010 @@ -419,10 +419,10 @@ DIE *constructEnumTypeDIE(DIEnumerator ETy); /// createMemberDIE - Create new member DIE. - DIE *createMemberDIE(const DIDerivedType &DT); + DIE *createMemberDIE(DIDerivedType DT); /// createSubprogramDIE - Create new DIE using SP. - DIE *createSubprogramDIE(const DISubprogram &SP, bool MakeDecl = false); + DIE *createSubprogramDIE(DISubprogram SP, bool MakeDecl = false); /// getOrCreateDbgScope - Create DbgScope for the scope. DbgScope *getOrCreateDbgScope(const MDNode *Scope, const MDNode *InlinedAt); From isanbard at gmail.com Tue Aug 10 00:16:06 2010 From: isanbard at gmail.com (Bill Wendling) Date: Tue, 10 Aug 2010 05:16:06 -0000 Subject: [llvm-commits] [llvm] r110654 - /llvm/trunk/lib/CodeGen/CMakeLists.txt Message-ID: <20100810051606.7C8E02A6C12C@llvm.org> Author: void Date: Tue Aug 10 00:16:06 2010 New Revision: 110654 URL: http://llvm.org/viewvc/llvm-project?rev=110654&view=rev Log: Update CMake...sorry for the breakage. Modified: llvm/trunk/lib/CodeGen/CMakeLists.txt Modified: llvm/trunk/lib/CodeGen/CMakeLists.txt URL: http://llvm.org/viewvc/llvm-project/llvm/trunk/lib/CodeGen/CMakeLists.txt?rev=110654&r1=110653&r2=110654&view=diff ============================================================================== --- llvm/trunk/lib/CodeGen/CMakeLists.txt (original) +++ llvm/trunk/lib/CodeGen/CMakeLists.txt Tue Aug 10 00:16:06 2010 @@ -42,11 +42,10 @@ MachineVerifier.cpp ObjectCodeEmitter.cpp OcamlGC.cpp - OptimizeCmps.cpp - OptimizeExts.cpp OptimizePHIs.cpp PHIElimination.cpp Passes.cpp + PeepholeOptimizer.cpp PostRAHazardRecognizer.cpp PostRASchedulerList.cpp PreAllocSplitting.cpp From isanbard at gmail.com Tue Aug 10 00:16:53 2010 From: isanbard at gmail.com (Bill Wendling) Date: Mon, 9 Aug 2010 22:16:53 -0700 Subject: [llvm-commits] [llvm] r110627 - in /llvm/trunk: include/llvm/CodeGen/Passes.h lib/CodeGen/LLVMTargetMachine.cpp lib/CodeGen/OptimizeCmps.cpp lib/CodeGen/OptimizeExts.cpp lib/CodeGen/PeepholeOptimizer.cpp In-Reply-To: References: <20100809235904.C7CAD2A6C12C@llvm.org> Message-ID: <38654C9D-E0F9-4B17-A547-71AE69837E4B@gmail.com> Done. Sorry for the breakage. -bw On Aug 9, 2010, at 8:58 PM, Francois Pichet wrote: > This break CMake ( at least on Windows) > Please add PeepholeOptimizer.cpp and remove OptimizeCmps.cpp, > OptimizeExts.cpp from llvm/trunk/lib/CodeGen/CMakeLists.txt > > On Mon, Aug 9, 2010 at 7:59 PM, Bill Wendling wrote: >> Author: void >> Date: Mon Aug 9 18:59:04 2010 >> New Revision: 110627 >> >> URL: http://llvm.org/viewvc/llvm-project?rev=110627&view=rev >> Log: >> Merge the OptimizeExts and OptimizeCmps passes into one PeepholeOptimizer >> pass. This pass should expand with all of the small, fine-grained optimization >> passes to reduce compile time and increase happiment. >> >> Added: >> llvm/trunk/lib/CodeGen/PeepholeOptimizer.cpp >> Removed: >> llvm/trunk/lib/CodeGen/OptimizeCmps.cpp >> llvm/trunk/lib/CodeGen/OptimizeExts.cpp >> Modified: >> llvm/trunk/include/llvm/CodeGen/Passes.h >> llvm/trunk/lib/CodeGen/LLVMTargetMachine.cpp >> >> Modified: llvm/trunk/include/llvm/CodeGen/Passes.h >> URL: http://llvm.org/viewvc/llvm-project/llvm/trunk/include/llvm/CodeGen/Passes.h?rev=110627&r1=110626&r2=110627&view=diff >> ============================================================================== >> --- llvm/trunk/include/llvm/CodeGen/Passes.h (original) >> +++ llvm/trunk/include/llvm/CodeGen/Passes.h Mon Aug 9 18:59:04 2010 >> @@ -172,18 +172,14 @@ >> /// instructions. >> FunctionPass *createMachineSinkingPass(); >> >> - /// createOptimizeExtsPass - This pass performs sign / zero extension >> - /// optimization by increasing uses of extended values. >> - FunctionPass *createOptimizeExtsPass(); >> + /// createPeepholeOptimizerPass - This pass performs peephole optimizations - >> + /// like extension and comparison eliminations. >> + FunctionPass *createPeepholeOptimizerPass(); >> >> /// createOptimizePHIsPass - This pass optimizes machine instruction PHIs >> /// to take advantage of opportunities created during DAG legalization. >> FunctionPass *createOptimizePHIsPass(); >> >> - /// createOptimizeCmpsPass - This pass performs redundant comparison removal >> - /// optimization. >> - FunctionPass *createOptimizeCmpsPass(); >> - >> /// createStackSlotColoringPass - This pass performs stack slot coloring. >> FunctionPass *createStackSlotColoringPass(bool); >> >> >> Modified: llvm/trunk/lib/CodeGen/LLVMTargetMachine.cpp >> URL: http://llvm.org/viewvc/llvm-project/llvm/trunk/lib/CodeGen/LLVMTargetMachine.cpp?rev=110627&r1=110626&r2=110627&view=diff >> ============================================================================== >> --- llvm/trunk/lib/CodeGen/LLVMTargetMachine.cpp (original) >> +++ llvm/trunk/lib/CodeGen/LLVMTargetMachine.cpp Mon Aug 9 18:59:04 2010 >> @@ -353,8 +353,7 @@ >> PM.add(createDeadMachineInstructionElimPass()); >> printAndVerify(PM, "After codegen DCE pass"); >> >> - PM.add(createOptimizeExtsPass()); >> - PM.add(createOptimizeCmpsPass()); >> + PM.add(createPeepholeOptimizerPass()); >> if (!DisableMachineLICM) >> PM.add(createMachineLICMPass()); >> PM.add(createMachineCSEPass()); >> >> Removed: llvm/trunk/lib/CodeGen/OptimizeCmps.cpp >> URL: http://llvm.org/viewvc/llvm-project/llvm/trunk/lib/CodeGen/OptimizeCmps.cpp?rev=110626&view=auto >> ============================================================================== >> --- llvm/trunk/lib/CodeGen/OptimizeCmps.cpp (original) >> +++ llvm/trunk/lib/CodeGen/OptimizeCmps.cpp (removed) >> @@ -1,112 +0,0 @@ >> -//===-- OptimizeCmps.cpp - Optimize comparison instrs ---------------------===// >> -// >> -// The LLVM Compiler Infrastructure >> -// >> -// This file is distributed under the University of Illinois Open Source >> -// License. See LICENSE.TXT for details. >> -// >> -//===----------------------------------------------------------------------===// >> -// >> -// This pass performs optimization of comparison instructions. For instance, in >> -// this code: >> -// >> -// sub r1, 1 >> -// cmp r1, 0 >> -// bz L1 >> -// >> -// If the "sub" instruction all ready sets (or could be modified to set) the >> -// same flag that the "cmp" instruction sets and that "bz" uses, then we can >> -// eliminate the "cmp" instruction. >> -// >> -//===----------------------------------------------------------------------===// >> - >> -#define DEBUG_TYPE "opt-compares" >> -#include "llvm/CodeGen/Passes.h" >> -#include "llvm/CodeGen/MachineFunctionPass.h" >> -#include "llvm/CodeGen/MachineInstrBuilder.h" >> -#include "llvm/CodeGen/MachineRegisterInfo.h" >> -#include "llvm/Target/TargetInstrInfo.h" >> -#include "llvm/Target/TargetRegisterInfo.h" >> -#include "llvm/Support/CommandLine.h" >> -#include "llvm/ADT/Statistic.h" >> -using namespace llvm; >> - >> -STATISTIC(NumEliminated, "Number of compares eliminated"); >> - >> -static cl::opt >> -EnableOptCmps("enable-optimize-cmps", cl::init(false), cl::Hidden); >> - >> -namespace { >> - class OptimizeCmps : public MachineFunctionPass { >> - const TargetMachine *TM; >> - const TargetInstrInfo *TII; >> - MachineRegisterInfo *MRI; >> - >> - bool OptimizeCmpInstr(MachineInstr *MI, MachineBasicBlock *MBB); >> - >> - public: >> - static char ID; // Pass identification >> - OptimizeCmps() : MachineFunctionPass(ID) {} >> - >> - virtual bool runOnMachineFunction(MachineFunction &MF); >> - >> - virtual void getAnalysisUsage(AnalysisUsage &AU) const { >> - AU.setPreservesCFG(); >> - MachineFunctionPass::getAnalysisUsage(AU); >> - } >> - }; >> -} >> - >> -char OptimizeCmps::ID = 0; >> -INITIALIZE_PASS(OptimizeCmps, "opt-cmps", >> - "Optimize comparison instrs", false, false); >> - >> -FunctionPass *llvm::createOptimizeCmpsPass() { return new OptimizeCmps(); } >> - >> -/// OptimizeCmpInstr - If the instruction is a compare and the previous >> -/// instruction it's comparing against all ready sets (or could be modified to >> -/// set) the same flag as the compare, then we can remove the comparison and use >> -/// the flag from the previous instruction. >> -bool OptimizeCmps::OptimizeCmpInstr(MachineInstr *MI, MachineBasicBlock *MBB) { >> - // If this instruction is a comparison against zero and isn't comparing a >> - // physical register, we can try to optimize it. >> - unsigned SrcReg; >> - int CmpValue; >> - if (!TII->AnalyzeCompare(MI, SrcReg, CmpValue) || >> - TargetRegisterInfo::isPhysicalRegister(SrcReg) || CmpValue != 0) >> - return false; >> - >> - MachineRegisterInfo::def_iterator DI = MRI->def_begin(SrcReg); >> - if (llvm::next(DI) != MRI->def_end()) >> - // Only support one definition. >> - return false; >> - >> - // Attempt to convert the defining instruction to set the "zero" flag. >> - if (TII->ConvertToSetZeroFlag(&*DI, MI)) { >> - ++NumEliminated; >> - return true; >> - } >> - >> - return false; >> -} >> - >> -bool OptimizeCmps::runOnMachineFunction(MachineFunction &MF) { >> - TM = &MF.getTarget(); >> - TII = TM->getInstrInfo(); >> - MRI = &MF.getRegInfo(); >> - >> - if (!EnableOptCmps) return false; >> - >> - bool Changed = false; >> - for (MachineFunction::iterator I = MF.begin(), E = MF.end(); I != E; ++I) { >> - MachineBasicBlock *MBB = &*I; >> - for (MachineBasicBlock::iterator >> - MII = MBB->begin(), ME = MBB->end(); MII != ME; ) { >> - MachineInstr *MI = &*MII++; >> - if (MI->getDesc().isCompare()) >> - Changed |= OptimizeCmpInstr(MI, MBB); >> - } >> - } >> - >> - return Changed; >> -} >> >> Removed: llvm/trunk/lib/CodeGen/OptimizeExts.cpp >> URL: http://llvm.org/viewvc/llvm-project/llvm/trunk/lib/CodeGen/OptimizeExts.cpp?rev=110626&view=auto >> ============================================================================== >> --- llvm/trunk/lib/CodeGen/OptimizeExts.cpp (original) >> +++ llvm/trunk/lib/CodeGen/OptimizeExts.cpp (removed) >> @@ -1,221 +0,0 @@ >> -//===-- OptimizeExts.cpp - Optimize sign / zero extension instrs -----===// >> -// >> -// The LLVM Compiler Infrastructure >> -// >> -// This file is distributed under the University of Illinois Open Source >> -// License. See LICENSE.TXT for details. >> -// >> -//===----------------------------------------------------------------------===// >> -// >> -// This pass performs optimization of sign / zero extension instructions. It >> -// may be extended to handle other instructions of similar property. >> -// >> -// On some targets, some instructions, e.g. X86 sign / zero extension, may >> -// leave the source value in the lower part of the result. This pass will >> -// replace (some) uses of the pre-extension value with uses of the sub-register >> -// of the results. >> -// >> -//===----------------------------------------------------------------------===// >> - >> -#define DEBUG_TYPE "ext-opt" >> -#include "llvm/CodeGen/Passes.h" >> -#include "llvm/CodeGen/MachineDominators.h" >> -#include "llvm/CodeGen/MachineInstrBuilder.h" >> -#include "llvm/CodeGen/MachineRegisterInfo.h" >> -#include "llvm/Target/TargetInstrInfo.h" >> -#include "llvm/Target/TargetRegisterInfo.h" >> -#include "llvm/Support/CommandLine.h" >> -#include "llvm/ADT/SmallPtrSet.h" >> -#include "llvm/ADT/Statistic.h" >> -using namespace llvm; >> - >> -static cl::opt Aggressive("aggressive-ext-opt", cl::Hidden, >> - cl::desc("Aggressive extension optimization")); >> - >> -STATISTIC(NumReuse, "Number of extension results reused"); >> - >> -namespace { >> - class OptimizeExts : public MachineFunctionPass { >> - const TargetMachine *TM; >> - const TargetInstrInfo *TII; >> - MachineRegisterInfo *MRI; >> - MachineDominatorTree *DT; // Machine dominator tree >> - >> - public: >> - static char ID; // Pass identification >> - OptimizeExts() : MachineFunctionPass(ID) {} >> - >> - virtual bool runOnMachineFunction(MachineFunction &MF); >> - >> - virtual void getAnalysisUsage(AnalysisUsage &AU) const { >> - AU.setPreservesCFG(); >> - MachineFunctionPass::getAnalysisUsage(AU); >> - if (Aggressive) { >> - AU.addRequired(); >> - AU.addPreserved(); >> - } >> - } >> - >> - private: >> - bool OptimizeInstr(MachineInstr *MI, MachineBasicBlock *MBB, >> - SmallPtrSet &LocalMIs); >> - }; >> -} >> - >> -char OptimizeExts::ID = 0; >> -INITIALIZE_PASS(OptimizeExts, "opt-exts", >> - "Optimize sign / zero extensions", false, false); >> - >> -FunctionPass *llvm::createOptimizeExtsPass() { return new OptimizeExts(); } >> - >> -/// OptimizeInstr - If instruction is a copy-like instruction, i.e. it reads >> -/// a single register and writes a single register and it does not modify >> -/// the source, and if the source value is preserved as a sub-register of >> -/// the result, then replace all reachable uses of the source with the subreg >> -/// of the result. >> -/// Do not generate an EXTRACT that is used only in a debug use, as this >> -/// changes the code. Since this code does not currently share EXTRACTs, just >> -/// ignore all debug uses. >> -bool OptimizeExts::OptimizeInstr(MachineInstr *MI, MachineBasicBlock *MBB, >> - SmallPtrSet &LocalMIs) { >> - LocalMIs.insert(MI); >> - >> - unsigned SrcReg, DstReg, SubIdx; >> - if (!TII->isCoalescableExtInstr(*MI, SrcReg, DstReg, SubIdx)) >> - return false; >> - >> - if (TargetRegisterInfo::isPhysicalRegister(DstReg) || >> - TargetRegisterInfo::isPhysicalRegister(SrcReg)) >> - return false; >> - >> - MachineRegisterInfo::use_nodbg_iterator UI = MRI->use_nodbg_begin(SrcReg); >> - if (++UI == MRI->use_nodbg_end()) >> - // No other uses. >> - return false; >> - >> - // Ok, the source has other uses. See if we can replace the other uses >> - // with use of the result of the extension. >> - SmallPtrSet ReachedBBs; >> - UI = MRI->use_nodbg_begin(DstReg); >> - for (MachineRegisterInfo::use_nodbg_iterator UE = MRI->use_nodbg_end(); >> - UI != UE; ++UI) >> - ReachedBBs.insert(UI->getParent()); >> - >> - bool ExtendLife = true; >> - // Uses that are in the same BB of uses of the result of the instruction. >> - SmallVector Uses; >> - // Uses that the result of the instruction can reach. >> - SmallVector ExtendedUses; >> - >> - UI = MRI->use_nodbg_begin(SrcReg); >> - for (MachineRegisterInfo::use_nodbg_iterator UE = MRI->use_nodbg_end(); >> - UI != UE; ++UI) { >> - MachineOperand &UseMO = UI.getOperand(); >> - MachineInstr *UseMI = &*UI; >> - if (UseMI == MI) >> - continue; >> - if (UseMI->isPHI()) { >> - ExtendLife = false; >> - continue; >> - } >> - >> - // It's an error to translate this: >> - // >> - // %reg1025 = %reg1024 >> - // ... >> - // %reg1026 = SUBREG_TO_REG 0, %reg1024, 4 >> - // >> - // into this: >> - // >> - // %reg1025 = %reg1024 >> - // ... >> - // %reg1027 = COPY %reg1025:4 >> - // %reg1026 = SUBREG_TO_REG 0, %reg1027, 4 >> - // >> - // The problem here is that SUBREG_TO_REG is there to assert that an >> - // implicit zext occurs. It doesn't insert a zext instruction. If we allow >> - // the COPY here, it will give us the value after the , not the >> - // original value of %reg1024 before . >> - if (UseMI->getOpcode() == TargetOpcode::SUBREG_TO_REG) >> - continue; >> - >> - MachineBasicBlock *UseMBB = UseMI->getParent(); >> - if (UseMBB == MBB) { >> - // Local uses that come after the extension. >> - if (!LocalMIs.count(UseMI)) >> - Uses.push_back(&UseMO); >> - } else if (ReachedBBs.count(UseMBB)) >> - // Non-local uses where the result of extension is used. Always replace >> - // these unless it's a PHI. >> - Uses.push_back(&UseMO); >> - else if (Aggressive && DT->dominates(MBB, UseMBB)) >> - // We may want to extend live range of the extension result in order to >> - // replace these uses. >> - ExtendedUses.push_back(&UseMO); >> - else { >> - // Both will be live out of the def MBB anyway. Don't extend live range of >> - // the extension result. >> - ExtendLife = false; >> - break; >> - } >> - } >> - >> - if (ExtendLife && !ExtendedUses.empty()) >> - // Ok, we'll extend the liveness of the extension result. >> - std::copy(ExtendedUses.begin(), ExtendedUses.end(), >> - std::back_inserter(Uses)); >> - >> - // Now replace all uses. >> - bool Changed = false; >> - if (!Uses.empty()) { >> - SmallPtrSet PHIBBs; >> - // Look for PHI uses of the extended result, we don't want to extend the >> - // liveness of a PHI input. It breaks all kinds of assumptions down >> - // stream. A PHI use is expected to be the kill of its source values. >> - UI = MRI->use_nodbg_begin(DstReg); >> - for (MachineRegisterInfo::use_nodbg_iterator UE = MRI->use_nodbg_end(); >> - UI != UE; ++UI) >> - if (UI->isPHI()) >> - PHIBBs.insert(UI->getParent()); >> - >> - const TargetRegisterClass *RC = MRI->getRegClass(SrcReg); >> - for (unsigned i = 0, e = Uses.size(); i != e; ++i) { >> - MachineOperand *UseMO = Uses[i]; >> - MachineInstr *UseMI = UseMO->getParent(); >> - MachineBasicBlock *UseMBB = UseMI->getParent(); >> - if (PHIBBs.count(UseMBB)) >> - continue; >> - unsigned NewVR = MRI->createVirtualRegister(RC); >> - BuildMI(*UseMBB, UseMI, UseMI->getDebugLoc(), >> - TII->get(TargetOpcode::COPY), NewVR) >> - .addReg(DstReg, 0, SubIdx); >> - UseMO->setReg(NewVR); >> - ++NumReuse; >> - Changed = true; >> - } >> - } >> - >> - return Changed; >> -} >> - >> -bool OptimizeExts::runOnMachineFunction(MachineFunction &MF) { >> - TM = &MF.getTarget(); >> - TII = TM->getInstrInfo(); >> - MRI = &MF.getRegInfo(); >> - DT = Aggressive ? &getAnalysis() : 0; >> - >> - bool Changed = false; >> - >> - SmallPtrSet LocalMIs; >> - for (MachineFunction::iterator I = MF.begin(), E = MF.end(); I != E; ++I) { >> - MachineBasicBlock *MBB = &*I; >> - LocalMIs.clear(); >> - for (MachineBasicBlock::iterator MII = I->begin(), ME = I->end(); MII != ME; >> - ++MII) { >> - MachineInstr *MI = &*MII; >> - Changed |= OptimizeInstr(MI, MBB, LocalMIs); >> - } >> - } >> - >> - return Changed; >> -} >> >> Added: llvm/trunk/lib/CodeGen/PeepholeOptimizer.cpp >> URL: http://llvm.org/viewvc/llvm-project/llvm/trunk/lib/CodeGen/PeepholeOptimizer.cpp?rev=110627&view=auto >> ============================================================================== >> --- llvm/trunk/lib/CodeGen/PeepholeOptimizer.cpp (added) >> +++ llvm/trunk/lib/CodeGen/PeepholeOptimizer.cpp Mon Aug 9 18:59:04 2010 >> @@ -0,0 +1,293 @@ >> +//===-- PeepholeOptimizer.cpp - Peephole Optimizations --------------------===// >> +// >> +// The LLVM Compiler Infrastructure >> +// >> +// This file is distributed under the University of Illinois Open Source >> +// License. See LICENSE.TXT for details. >> +// >> +//===----------------------------------------------------------------------===// >> +// >> +// Perform peephole optimizations on the machine code: >> +// >> +// - Optimize Extensions >> +// >> +// Optimization of sign / zero extension instructions. It may be extended to >> +// handle other instructions with similar properties. >> +// >> +// On some targets, some instructions, e.g. X86 sign / zero extension, may >> +// leave the source value in the lower part of the result. This optimization >> +// will replace some uses of the pre-extension value with uses of the >> +// sub-register of the results. >> +// >> +// - Optimize Comparisons >> +// >> +// Optimization of comparison instructions. For instance, in this code: >> +// >> +// sub r1, 1 >> +// cmp r1, 0 >> +// bz L1 >> +// >> +// If the "sub" instruction all ready sets (or could be modified to set) the >> +// same flag that the "cmp" instruction sets and that "bz" uses, then we can >> +// eliminate the "cmp" instruction. >> +// >> +//===----------------------------------------------------------------------===// >> + >> +#define DEBUG_TYPE "peephole-opt" >> +#include "llvm/CodeGen/Passes.h" >> +#include "llvm/CodeGen/MachineDominators.h" >> +#include "llvm/CodeGen/MachineInstrBuilder.h" >> +#include "llvm/CodeGen/MachineRegisterInfo.h" >> +#include "llvm/Target/TargetInstrInfo.h" >> +#include "llvm/Target/TargetRegisterInfo.h" >> +#include "llvm/Support/CommandLine.h" >> +#include "llvm/ADT/SmallPtrSet.h" >> +#include "llvm/ADT/Statistic.h" >> +using namespace llvm; >> + >> +// Optimize Extensions >> +static cl::opt >> +Aggressive("aggressive-ext-opt", cl::Hidden, >> + cl::desc("Aggressive extension optimization")); >> + >> +STATISTIC(NumReuse, "Number of extension results reused"); >> + >> +// Optimize Comparisons >> +static cl::opt >> +EnableOptCmps("enable-optimize-cmps", cl::init(false), cl::Hidden); >> + >> +STATISTIC(NumEliminated, "Number of compares eliminated"); >> + >> +namespace { >> + class PeepholeOptimizer : public MachineFunctionPass { >> + const TargetMachine *TM; >> + const TargetInstrInfo *TII; >> + MachineRegisterInfo *MRI; >> + MachineDominatorTree *DT; // Machine dominator tree >> + >> + public: >> + static char ID; // Pass identification >> + PeepholeOptimizer() : MachineFunctionPass(ID) {} >> + >> + virtual bool runOnMachineFunction(MachineFunction &MF); >> + >> + virtual void getAnalysisUsage(AnalysisUsage &AU) const { >> + AU.setPreservesCFG(); >> + MachineFunctionPass::getAnalysisUsage(AU); >> + if (Aggressive) { >> + AU.addRequired(); >> + AU.addPreserved(); >> + } >> + } >> + >> + private: >> + bool OptimizeCmpInstr(MachineInstr *MI, MachineBasicBlock *MBB); >> + bool OptimizeExtInstr(MachineInstr *MI, MachineBasicBlock *MBB, >> + SmallPtrSet &LocalMIs); >> + }; >> +} >> + >> +char PeepholeOptimizer::ID = 0; >> +INITIALIZE_PASS(PeepholeOptimizer, "peephole-opts", >> + "Peephole Optimizations", false, false); >> + >> +FunctionPass *llvm::createPeepholeOptimizerPass() { >> + return new PeepholeOptimizer(); >> +} >> + >> +/// OptimizeExtInstr - If instruction is a copy-like instruction, i.e. it reads >> +/// a single register and writes a single register and it does not modify the >> +/// source, and if the source value is preserved as a sub-register of the >> +/// result, then replace all reachable uses of the source with the subreg of the >> +/// result. >> +/// >> +/// Do not generate an EXTRACT that is used only in a debug use, as this changes >> +/// the code. Since this code does not currently share EXTRACTs, just ignore all >> +/// debug uses. >> +bool PeepholeOptimizer:: >> +OptimizeExtInstr(MachineInstr *MI, MachineBasicBlock *MBB, >> + SmallPtrSet &LocalMIs) { >> + LocalMIs.insert(MI); >> + >> + unsigned SrcReg, DstReg, SubIdx; >> + if (!TII->isCoalescableExtInstr(*MI, SrcReg, DstReg, SubIdx)) >> + return false; >> + >> + if (TargetRegisterInfo::isPhysicalRegister(DstReg) || >> + TargetRegisterInfo::isPhysicalRegister(SrcReg)) >> + return false; >> + >> + MachineRegisterInfo::use_nodbg_iterator UI = MRI->use_nodbg_begin(SrcReg); >> + if (++UI == MRI->use_nodbg_end()) >> + // No other uses. >> + return false; >> + >> + // The source has other uses. See if we can replace the other uses with use of >> + // the result of the extension. >> + SmallPtrSet ReachedBBs; >> + UI = MRI->use_nodbg_begin(DstReg); >> + for (MachineRegisterInfo::use_nodbg_iterator UE = MRI->use_nodbg_end(); >> + UI != UE; ++UI) >> + ReachedBBs.insert(UI->getParent()); >> + >> + // Uses that are in the same BB of uses of the result of the instruction. >> + SmallVector Uses; >> + >> + // Uses that the result of the instruction can reach. >> + SmallVector ExtendedUses; >> + >> + bool ExtendLife = true; >> + UI = MRI->use_nodbg_begin(SrcReg); >> + for (MachineRegisterInfo::use_nodbg_iterator UE = MRI->use_nodbg_end(); >> + UI != UE; ++UI) { >> + MachineOperand &UseMO = UI.getOperand(); >> + MachineInstr *UseMI = &*UI; >> + if (UseMI == MI) >> + continue; >> + >> + if (UseMI->isPHI()) { >> + ExtendLife = false; >> + continue; >> + } >> + >> + // It's an error to translate this: >> + // >> + // %reg1025 = %reg1024 >> + // ... >> + // %reg1026 = SUBREG_TO_REG 0, %reg1024, 4 >> + // >> + // into this: >> + // >> + // %reg1025 = %reg1024 >> + // ... >> + // %reg1027 = COPY %reg1025:4 >> + // %reg1026 = SUBREG_TO_REG 0, %reg1027, 4 >> + // >> + // The problem here is that SUBREG_TO_REG is there to assert that an >> + // implicit zext occurs. It doesn't insert a zext instruction. If we allow >> + // the COPY here, it will give us the value after the , not the >> + // original value of %reg1024 before . >> + if (UseMI->getOpcode() == TargetOpcode::SUBREG_TO_REG) >> + continue; >> + >> + MachineBasicBlock *UseMBB = UseMI->getParent(); >> + if (UseMBB == MBB) { >> + // Local uses that come after the extension. >> + if (!LocalMIs.count(UseMI)) >> + Uses.push_back(&UseMO); >> + } else if (ReachedBBs.count(UseMBB)) { >> + // Non-local uses where the result of the extension is used. Always >> + // replace these unless it's a PHI. >> + Uses.push_back(&UseMO); >> + } else if (Aggressive && DT->dominates(MBB, UseMBB)) { >> + // We may want to extend the live range of the extension result in order >> + // to replace these uses. >> + ExtendedUses.push_back(&UseMO); >> + } else { >> + // Both will be live out of the def MBB anyway. Don't extend live range of >> + // the extension result. >> + ExtendLife = false; >> + break; >> + } >> + } >> + >> + if (ExtendLife && !ExtendedUses.empty()) >> + // Extend the liveness of the extension result. >> + std::copy(ExtendedUses.begin(), ExtendedUses.end(), >> + std::back_inserter(Uses)); >> + >> + // Now replace all uses. >> + bool Changed = false; >> + if (!Uses.empty()) { >> + SmallPtrSet PHIBBs; >> + >> + // Look for PHI uses of the extended result, we don't want to extend the >> + // liveness of a PHI input. It breaks all kinds of assumptions down >> + // stream. A PHI use is expected to be the kill of its source values. >> + UI = MRI->use_nodbg_begin(DstReg); >> + for (MachineRegisterInfo::use_nodbg_iterator >> + UE = MRI->use_nodbg_end(); UI != UE; ++UI) >> + if (UI->isPHI()) >> + PHIBBs.insert(UI->getParent()); >> + >> + const TargetRegisterClass *RC = MRI->getRegClass(SrcReg); >> + for (unsigned i = 0, e = Uses.size(); i != e; ++i) { >> + MachineOperand *UseMO = Uses[i]; >> + MachineInstr *UseMI = UseMO->getParent(); >> + MachineBasicBlock *UseMBB = UseMI->getParent(); >> + if (PHIBBs.count(UseMBB)) >> + continue; >> + >> + unsigned NewVR = MRI->createVirtualRegister(RC); >> + BuildMI(*UseMBB, UseMI, UseMI->getDebugLoc(), >> + TII->get(TargetOpcode::COPY), NewVR) >> + .addReg(DstReg, 0, SubIdx); >> + >> + UseMO->setReg(NewVR); >> + ++NumReuse; >> + Changed = true; >> + } >> + } >> + >> + return Changed; >> +} >> + >> +/// OptimizeCmpInstr - If the instruction is a compare and the previous >> +/// instruction it's comparing against all ready sets (or could be modified to >> +/// set) the same flag as the compare, then we can remove the comparison and use >> +/// the flag from the previous instruction. >> +bool PeepholeOptimizer::OptimizeCmpInstr(MachineInstr *MI, >> + MachineBasicBlock *MBB) { >> + if (!EnableOptCmps) return false; >> + >> + // If this instruction is a comparison against zero and isn't comparing a >> + // physical register, we can try to optimize it. >> + unsigned SrcReg; >> + int CmpValue; >> + if (!TII->AnalyzeCompare(MI, SrcReg, CmpValue) || >> + TargetRegisterInfo::isPhysicalRegister(SrcReg) || CmpValue != 0) >> + return false; >> + >> + MachineRegisterInfo::def_iterator DI = MRI->def_begin(SrcReg); >> + if (llvm::next(DI) != MRI->def_end()) >> + // Only support one definition. >> + return false; >> + >> + // Attempt to convert the defining instruction to set the "zero" flag. >> + if (TII->ConvertToSetZeroFlag(&*DI, MI)) { >> + ++NumEliminated; >> + return true; >> + } >> + >> + return false; >> +} >> + >> +bool PeepholeOptimizer::runOnMachineFunction(MachineFunction &MF) { >> + TM = &MF.getTarget(); >> + TII = TM->getInstrInfo(); >> + MRI = &MF.getRegInfo(); >> + DT = Aggressive ? &getAnalysis() : 0; >> + >> + bool Changed = false; >> + >> + SmallPtrSet LocalMIs; >> + for (MachineFunction::iterator I = MF.begin(), E = MF.end(); I != E; ++I) { >> + MachineBasicBlock *MBB = &*I; >> + LocalMIs.clear(); >> + >> + for (MachineBasicBlock::iterator >> + MII = I->begin(), ME = I->end(); MII != ME; ) { >> + MachineInstr *MI = &*MII; >> + >> + if (MI->getDesc().isCompare()) { >> + ++MII; // The iterator may become invalid if the compare is deleted. >> + Changed |= OptimizeCmpInstr(MI, MBB); >> + } else { >> + Changed |= OptimizeExtInstr(MI, MBB, LocalMIs); >> + ++MII; >> + } >> + } >> + } >> + >> + return Changed; >> +} >> >> >> _______________________________________________ >> llvm-commits mailing list >> llvm-commits at cs.uiuc.edu >> http://lists.cs.uiuc.edu/mailman/listinfo/llvm-commits >> From evan.cheng at apple.com Tue Aug 10 01:26:49 2010 From: evan.cheng at apple.com (Evan Cheng) Date: Tue, 10 Aug 2010 06:26:49 -0000 Subject: [llvm-commits] [llvm] r110655 - in /llvm/trunk: lib/Target/ARM/ARMBaseRegisterInfo.cpp lib/Target/ARM/ARMISelLowering.cpp lib/Target/ARM/ARMMachineFunctionInfo.h lib/Target/ARM/ARMRegisterInfo.td lib/Target/ARM/Thumb1RegisterInfo.cpp test/CodeGen/Thumb/large-stack.ll Message-ID: <20100810062649.9AD922A6C12C@llvm.org> Author: evancheng Date: Tue Aug 10 01:26:49 2010 New Revision: 110655 URL: http://llvm.org/viewvc/llvm-project?rev=110655&view=rev Log: Fix ARM hasFP() semantics. It should return true whenever FP register is reserved, not available for general allocation. This eliminates all the extra checks for Darwin. This change also fixes the use of FP to access frame indices in leaf functions and cleaned up some confusing code in epilogue emission. Modified: llvm/trunk/lib/Target/ARM/ARMBaseRegisterInfo.cpp llvm/trunk/lib/Target/ARM/ARMISelLowering.cpp llvm/trunk/lib/Target/ARM/ARMMachineFunctionInfo.h llvm/trunk/lib/Target/ARM/ARMRegisterInfo.td llvm/trunk/lib/Target/ARM/Thumb1RegisterInfo.cpp llvm/trunk/test/CodeGen/Thumb/large-stack.ll Modified: llvm/trunk/lib/Target/ARM/ARMBaseRegisterInfo.cpp URL: http://llvm.org/viewvc/llvm-project/llvm/trunk/lib/Target/ARM/ARMBaseRegisterInfo.cpp?rev=110655&r1=110654&r2=110655&view=diff ============================================================================== --- llvm/trunk/lib/Target/ARM/ARMBaseRegisterInfo.cpp (original) +++ llvm/trunk/lib/Target/ARM/ARMBaseRegisterInfo.cpp Tue Aug 10 01:26:49 2010 @@ -177,7 +177,7 @@ Reserved.set(ARM::SP); Reserved.set(ARM::PC); Reserved.set(ARM::FPSCR); - if (STI.isTargetDarwin() || hasFP(MF)) + if (hasFP(MF)) Reserved.set(FramePtr); // Some targets reserve R9. if (STI.isR9Reserved()) @@ -194,7 +194,7 @@ return true; case ARM::R7: case ARM::R11: - if (FramePtr == Reg && (STI.isTargetDarwin() || hasFP(MF))) + if (FramePtr == Reg && hasFP(MF)) return true; break; case ARM::R9: @@ -511,7 +511,7 @@ return std::make_pair(RC->allocation_order_begin(MF), RC->allocation_order_end(MF)); - if (!STI.isTargetDarwin() && !hasFP(MF)) { + if (!hasFP(MF)) { if (!STI.isR9Reserved()) return std::make_pair(GPREven1, GPREven1 + (sizeof(GPREven1)/sizeof(unsigned))); @@ -540,7 +540,7 @@ return std::make_pair(RC->allocation_order_begin(MF), RC->allocation_order_end(MF)); - if (!STI.isTargetDarwin() && !hasFP(MF)) { + if (!hasFP(MF)) { if (!STI.isR9Reserved()) return std::make_pair(GPROdd1, GPROdd1 + (sizeof(GPROdd1)/sizeof(unsigned))); @@ -610,6 +610,10 @@ /// or if frame pointer elimination is disabled. /// bool ARMBaseRegisterInfo::hasFP(const MachineFunction &MF) const { + // Mac OS X requires FP not to be clobbered for backtracing purpose. + if (STI.isTargetDarwin()) + return true; + const MachineFrameInfo *MFI = MF.getFrameInfo(); // Always eliminate non-leaf frame pointers. return ((DisableFramePointerElim(MF) && MFI->hasCalls()) || @@ -683,6 +687,7 @@ /// instructions will require a scratch register during their expansion later. unsigned ARMBaseRegisterInfo::estimateRSStackSizeLimit(MachineFunction &MF) const { + const ARMFunctionInfo *AFI = MF.getInfo(); unsigned Limit = (1 << 12) - 1; for (MachineFunction::iterator BB = MF.begin(),E = MF.end(); BB != E; ++BB) { for (MachineBasicBlock::iterator I = BB->begin(), E = BB->end(); @@ -708,7 +713,10 @@ Limit = std::min(Limit, ((1U << 8) - 1) * 4); break; case ARMII::AddrModeT2_i12: - if (hasFP(MF)) Limit = std::min(Limit, (1U << 8) - 1); + // i12 supports only positive offset so these will be converted to + // i8 opcodes. See llvm::rewriteT2FrameIndex. + if (hasFP(MF) && AFI->hasStackFrame()) + Limit = std::min(Limit, (1U << 8) - 1); break; case ARMII::AddrMode6: // Addressing mode 6 (load/store) instructions can't encode an @@ -860,8 +868,9 @@ // and which instructions will need a scratch register for them. Is it // worth the effort and added fragility? bool BigStack = - (RS && (estimateStackSize(MF) + (hasFP(MF) ? 4:0) >= - estimateRSStackSizeLimit(MF))) + (RS && + (estimateStackSize(MF) + ((hasFP(MF) && AFI->hasStackFrame()) ? 4:0) >= + estimateRSStackSizeLimit(MF))) || MFI->hasVarSizedObjects() || (MFI->adjustsStack() && !canSimplifyCallFramePseudos(MF)); @@ -881,9 +890,7 @@ ExtraCSSpill = true; } - // Darwin ABI requires FP to point to the stack slot that contains the - // previous FP. - if (STI.isTargetDarwin() || hasFP(MF)) { + if (hasFP(MF)) { MF.getRegInfo().setPhysRegUsed(FramePtr); NumGPRSpills++; } @@ -976,7 +983,7 @@ unsigned ARMBaseRegisterInfo::getFrameRegister(const MachineFunction &MF) const { - if (STI.isTargetDarwin() || hasFP(MF)) + if (hasFP(MF)) return FramePtr; return ARM::SP; } @@ -1546,7 +1553,8 @@ // Otherwise, if this is not Darwin, all the callee-saved registers go // into spill area 1, including the FP in R11. In either case, it is // now safe to emit this assignment. - if (STI.isTargetDarwin() || hasFP(MF)) { + bool HasFP = hasFP(MF); + if (HasFP) { unsigned ADDriOpc = !AFI->isThumbFunction() ? ARM::ADDri : ARM::t2ADDri; MachineInstrBuilder MIB = BuildMI(MBB, MBBI, dl, TII.get(ADDriOpc), FramePtr) @@ -1565,7 +1573,7 @@ unsigned DPRCSOffset = NumBytes - (GPRCS1Size + GPRCS2Size + DPRCSSize); unsigned GPRCS2Offset = DPRCSOffset + DPRCSSize; unsigned GPRCS1Offset = GPRCS2Offset + GPRCS2Size; - if (STI.isTargetDarwin() || hasFP(MF)) + if (HasFP) AFI->setFramePtrSpillOffset(MFI->getObjectOffset(FramePtrSpillFI) + NumBytes); AFI->setGPRCalleeSavedArea1Offset(GPRCS1Offset); @@ -1577,11 +1585,14 @@ if (NumBytes) { // Adjust SP after all the callee-save spills. emitSPUpdate(isARM, MBB, MBBI, dl, TII, -NumBytes); + if (HasFP) + AFI->setShouldRestoreSPFromFP(true); } if (STI.isTargetELF() && hasFP(MF)) { MFI->setOffsetAdjustment(MFI->getOffsetAdjustment() - AFI->getFramePtrSpillOffset()); + AFI->setShouldRestoreSPFromFP(true); } AFI->setGPRCalleeSavedArea1Size(GPRCS1Size); @@ -1614,6 +1625,8 @@ BuildMI(MBB, MBBI, dl, TII.get(ARM::tMOVtgpr2gpr), ARM::SP) .addReg(ARM::R4, RegState::Kill); } + + AFI->setShouldRestoreSPFromFP(true); } } @@ -1669,34 +1682,25 @@ AFI->getGPRCalleeSavedArea2Size() + AFI->getDPRCalleeSavedAreaSize()); - // Darwin ABI requires FP to point to the stack slot that contains the - // previous FP. - bool HasFP = hasFP(MF); - if ((STI.isTargetDarwin() && NumBytes) || HasFP) { + // Reset SP based on frame pointer only if the stack frame extends beyond + // frame pointer stack slot or target is ELF and the function has FP. + if (AFI->shouldRestoreSPFromFP()) { NumBytes = AFI->getFramePtrSpillOffset() - NumBytes; - // Reset SP based on frame pointer only if the stack frame extends beyond - // frame pointer stack slot or target is ELF and the function has FP. - if (HasFP || - AFI->getGPRCalleeSavedArea2Size() || - AFI->getDPRCalleeSavedAreaSize() || - AFI->getDPRCalleeSavedAreaOffset()) { - if (NumBytes) { - if (isARM) - emitARMRegPlusImmediate(MBB, MBBI, dl, ARM::SP, FramePtr, -NumBytes, - ARMCC::AL, 0, TII); - else - emitT2RegPlusImmediate(MBB, MBBI, dl, ARM::SP, FramePtr, -NumBytes, - ARMCC::AL, 0, TII); - } else { - // Thumb2 or ARM. - if (isARM) - BuildMI(MBB, MBBI, dl, TII.get(ARM::MOVr), ARM::SP) - .addReg(FramePtr) - .addImm((unsigned)ARMCC::AL).addReg(0).addReg(0); - else - BuildMI(MBB, MBBI, dl, TII.get(ARM::tMOVgpr2gpr), ARM::SP) - .addReg(FramePtr); - } + if (NumBytes) { + if (isARM) + emitARMRegPlusImmediate(MBB, MBBI, dl, ARM::SP, FramePtr, -NumBytes, + ARMCC::AL, 0, TII); + else + emitT2RegPlusImmediate(MBB, MBBI, dl, ARM::SP, FramePtr, -NumBytes, + ARMCC::AL, 0, TII); + } else { + // Thumb2 or ARM. + if (isARM) + BuildMI(MBB, MBBI, dl, TII.get(ARM::MOVr), ARM::SP) + .addReg(FramePtr).addImm((unsigned)ARMCC::AL).addReg(0).addReg(0); + else + BuildMI(MBB, MBBI, dl, TII.get(ARM::tMOVgpr2gpr), ARM::SP) + .addReg(FramePtr); } } else if (NumBytes) emitSPUpdate(isARM, MBB, MBBI, dl, TII, NumBytes); Modified: llvm/trunk/lib/Target/ARM/ARMISelLowering.cpp URL: http://llvm.org/viewvc/llvm-project/llvm/trunk/lib/Target/ARM/ARMISelLowering.cpp?rev=110655&r1=110654&r2=110655&view=diff ============================================================================== --- llvm/trunk/lib/Target/ARM/ARMISelLowering.cpp (original) +++ llvm/trunk/lib/Target/ARM/ARMISelLowering.cpp Tue Aug 10 01:26:49 2010 @@ -742,14 +742,15 @@ unsigned ARMTargetLowering::getRegPressureLimit(const TargetRegisterClass *RC, MachineFunction &MF) const { - unsigned FPDiff = RegInfo->hasFP(MF) ? 1 : 0; switch (RC->getID()) { default: return 0; case ARM::tGPRRegClassID: - return 5 - FPDiff; - case ARM::GPRRegClassID: - return 10 - FPDiff - (Subtarget->isR9Reserved() ? 1 : 0); + return RegInfo->hasFP(MF) ? 4 : 5; + case ARM::GPRRegClassID: { + unsigned FP = RegInfo->hasFP(MF) ? 1 : 0; + return 10 - FP - (Subtarget->isR9Reserved() ? 1 : 0); + } case ARM::SPRRegClassID: // Currently not used as 'rep' register class. case ARM::DPRRegClassID: return 32 - 10; Modified: llvm/trunk/lib/Target/ARM/ARMMachineFunctionInfo.h URL: http://llvm.org/viewvc/llvm-project/llvm/trunk/lib/Target/ARM/ARMMachineFunctionInfo.h?rev=110655&r1=110654&r2=110655&view=diff ============================================================================== --- llvm/trunk/lib/Target/ARM/ARMMachineFunctionInfo.h (original) +++ llvm/trunk/lib/Target/ARM/ARMMachineFunctionInfo.h Tue Aug 10 01:26:49 2010 @@ -43,6 +43,10 @@ /// processFunctionBeforeCalleeSavedScan(). bool HasStackFrame; + /// RestoreSPFromFP - True if epilogue should restore SP from FP. Set by + /// emitPrologue. + bool RestoreSPFromFP; + /// LRSpilledForFarJump - True if the LR register has been for spilled to /// enable far jump. bool LRSpilledForFarJump; @@ -95,7 +99,7 @@ ARMFunctionInfo() : isThumb(false), hasThumb2(false), - VarArgsRegSaveSize(0), HasStackFrame(false), + VarArgsRegSaveSize(0), HasStackFrame(false), RestoreSPFromFP(false), LRSpilledForFarJump(false), FramePtrSpillOffset(0), GPRCS1Offset(0), GPRCS2Offset(0), DPRCSOffset(0), GPRCS1Size(0), GPRCS2Size(0), DPRCSSize(0), @@ -106,7 +110,7 @@ explicit ARMFunctionInfo(MachineFunction &MF) : isThumb(MF.getTarget().getSubtarget().isThumb()), hasThumb2(MF.getTarget().getSubtarget().hasThumb2()), - VarArgsRegSaveSize(0), HasStackFrame(false), + VarArgsRegSaveSize(0), HasStackFrame(false), RestoreSPFromFP(false), LRSpilledForFarJump(false), FramePtrSpillOffset(0), GPRCS1Offset(0), GPRCS2Offset(0), DPRCSOffset(0), GPRCS1Size(0), GPRCS2Size(0), DPRCSSize(0), @@ -125,6 +129,9 @@ bool hasStackFrame() const { return HasStackFrame; } void setHasStackFrame(bool s) { HasStackFrame = s; } + bool shouldRestoreSPFromFP() const { return RestoreSPFromFP; } + void setShouldRestoreSPFromFP(bool s) { RestoreSPFromFP = s; } + bool isLRSpilledForFarJump() const { return LRSpilledForFarJump; } void setLRIsSpilledForFarJump(bool s) { LRSpilledForFarJump = s; } Modified: llvm/trunk/lib/Target/ARM/ARMRegisterInfo.td URL: http://llvm.org/viewvc/llvm-project/llvm/trunk/lib/Target/ARM/ARMRegisterInfo.td?rev=110655&r1=110654&r2=110655&view=diff ============================================================================== --- llvm/trunk/lib/Target/ARM/ARMRegisterInfo.td (original) +++ llvm/trunk/lib/Target/ARM/ARMRegisterInfo.td Tue Aug 10 01:26:49 2010 @@ -294,8 +294,7 @@ if (Subtarget.isThumb1Only()) { I = THUMB_GPR_AO + (sizeof(THUMB_GPR_AO)/sizeof(unsigned)); - // Mac OS X requires FP not to be clobbered for backtracing purpose. - return (Subtarget.isTargetDarwin() || RI->hasFP(MF)) ? I-1 : I; + return RI->hasFP(MF) ? I-1 : I; } if (Subtarget.isTargetDarwin()) { @@ -312,8 +311,7 @@ I = ARM_GPR_AO_1 + (sizeof(ARM_GPR_AO_1)/sizeof(unsigned)); } - // Mac OS X requires FP not to be clobbered for backtracing purpose. - return (Subtarget.isTargetDarwin() || RI->hasFP(MF)) ? I-1 : I; + return RI->hasFP(MF) ? I-1 : I; } }]; } @@ -403,8 +401,7 @@ if (Subtarget.isThumb1Only()) { I = THUMB_rGPRAO + (sizeof(THUMB_rGPRAO)/sizeof(unsigned)); - // Mac OS X requires FP not to be clobbered for backtracing purpose. - return (Subtarget.isTargetDarwin() || RI->hasFP(MF)) ? I-1 : I; + return RI->hasFP(MF) ? I-1 : I; } if (Subtarget.isTargetDarwin()) { @@ -421,8 +418,7 @@ I = ARM_rGPRAO_1 + (sizeof(ARM_rGPRAO_1)/sizeof(unsigned)); } - // Mac OS X requires FP not to be clobbered for backtracing purpose. - return (Subtarget.isTargetDarwin() || RI->hasFP(MF)) ? I-1 : I; + return RI->hasFP(MF) ? I-1 : I; } }]; } @@ -449,11 +445,9 @@ tGPRClass::allocation_order_end(const MachineFunction &MF) const { const TargetMachine &TM = MF.getTarget(); const TargetRegisterInfo *RI = TM.getRegisterInfo(); - const ARMSubtarget &Subtarget = TM.getSubtarget(); tGPRClass::iterator I = THUMB_tGPR_AO + (sizeof(THUMB_tGPR_AO)/sizeof(unsigned)); - // Mac OS X requires FP not to be clobbered for backtracing purpose. - return (Subtarget.isTargetDarwin() || RI->hasFP(MF)) ? I-1 : I; + return RI->hasFP(MF) ? I-1 : I; } }]; } Modified: llvm/trunk/lib/Target/ARM/Thumb1RegisterInfo.cpp URL: http://llvm.org/viewvc/llvm-project/llvm/trunk/lib/Target/ARM/Thumb1RegisterInfo.cpp?rev=110655&r1=110654&r2=110655&view=diff ============================================================================== --- llvm/trunk/lib/Target/ARM/Thumb1RegisterInfo.cpp (original) +++ llvm/trunk/lib/Target/ARM/Thumb1RegisterInfo.cpp Tue Aug 10 01:26:49 2010 @@ -742,11 +742,11 @@ dl = MBBI->getDebugLoc(); } - // Darwin ABI requires FP to point to the stack slot that contains the - // previous FP. - if (STI.isTargetDarwin() || hasFP(MF)) { + // Adjust FP so it point to the stack slot that contains the previous FP. + if (hasFP(MF)) { BuildMI(MBB, MBBI, dl, TII.get(ARM::tADDrSPi), FramePtr) .addFrameIndex(FramePtrSpillFI).addImm(0); + AFI->setShouldRestoreSPFromFP(true); } // Determine starting offsets of spill areas. @@ -764,10 +764,9 @@ emitSPUpdate(MBB, MBBI, TII, dl, *this, -NumBytes); } - if (STI.isTargetELF() && hasFP(MF)) { + if (STI.isTargetELF() && hasFP(MF)) MFI->setOffsetAdjustment(MFI->getOffsetAdjustment() - AFI->getFramePtrSpillOffset()); - } AFI->setGPRCalleeSavedArea1Size(GPRCS1Size); AFI->setGPRCalleeSavedArea2Size(GPRCS2Size); @@ -828,7 +827,7 @@ AFI->getGPRCalleeSavedArea2Size() + AFI->getDPRCalleeSavedAreaSize()); - if (hasFP(MF)) { + if (AFI->shouldRestoreSPFromFP()) { NumBytes = AFI->getFramePtrSpillOffset() - NumBytes; // Reset SP based on frame pointer only if the stack frame extends beyond // frame pointer stack slot or target is ELF and the function has FP. Modified: llvm/trunk/test/CodeGen/Thumb/large-stack.ll URL: http://llvm.org/viewvc/llvm-project/llvm/trunk/test/CodeGen/Thumb/large-stack.ll?rev=110655&r1=110654&r2=110655&view=diff ============================================================================== --- llvm/trunk/test/CodeGen/Thumb/large-stack.ll (original) +++ llvm/trunk/test/CodeGen/Thumb/large-stack.ll Tue Aug 10 01:26:49 2010 @@ -1,20 +1,35 @@ -; RUN: llc < %s -march=thumb | grep {ldr.*LCP} | count 5 +; RUN: llc < %s -mtriple=thumb-apple-darwin | FileCheck %s define void @test1() { +; CHECK: test1: +; CHECK: sub sp, #256 +; CHECK: add sp, #256 %tmp = alloca [ 64 x i32 ] , align 4 ret void } define void @test2() { +; CHECK: test2: +; CHECK: ldr r0, LCPI +; CHECK: add sp, r0 +; CHECK: mov sp, r7 +; CHECK: sub sp, #4 %tmp = alloca [ 4168 x i8 ] , align 4 ret void } define i32 @test3() { - %retval = alloca i32, align 4 - %tmp = alloca i32, align 4 - %a = alloca [805306369 x i8], align 16 - store i32 0, i32* %tmp - %tmp1 = load i32* %tmp - ret i32 %tmp1 +; CHECK: test3: +; CHECK: ldr r1, LCPI +; CHECK: add sp, r1 +; CHECK: ldr r1, LCPI +; CHECK: add r1, sp +; CHECK: mov sp, r7 +; CHECK: sub sp, #4 + %retval = alloca i32, align 4 + %tmp = alloca i32, align 4 + %a = alloca [805306369 x i8], align 16 + store i32 0, i32* %tmp + %tmp1 = load i32* %tmp + ret i32 %tmp1 } From dpatel at apple.com Tue Aug 10 01:36:37 2010 From: dpatel at apple.com (Devang Patel) Date: Mon, 9 Aug 2010 23:36:37 -0700 Subject: [llvm-commits] [llvm] r110607 - in /llvm/trunk: include/llvm/Analysis/DebugInfo.h lib/Analysis/DebugInfo.cpp lib/CodeGen/AsmPrinter/DwarfDebug.cpp In-Reply-To: <20100809213925.2CF2A2A6C12C@llvm.org> References: <20100809213925.2CF2A2A6C12C@llvm.org> Message-ID: <450C0BEB-546F-461F-9444-23146EEE9CFC@apple.com> This check-in also included DebugInfo.h changes. Update DIGlobalVariable to handle Constant. On Aug 9, 2010, at 2:39 PM, Devang Patel wrote: > Author: dpatel > Date: Mon Aug 9 16:39:24 2010 > New Revision: 110607 > > URL: http://llvm.org/viewvc/llvm-project?rev=110607&view=rev > Log: > Refactor. > > Modified: > llvm/trunk/include/llvm/Analysis/DebugInfo.h > llvm/trunk/lib/Analysis/DebugInfo.cpp > llvm/trunk/lib/CodeGen/AsmPrinter/DwarfDebug.cpp > > Modified: llvm/trunk/include/llvm/Analysis/DebugInfo.h > URL: http://llvm.org/viewvc/llvm-project/llvm/trunk/include/llvm/Analysis/DebugInfo.h?rev=110607&r1=110606&r2=110607&view=diff > ============================================================================== > --- llvm/trunk/include/llvm/Analysis/DebugInfo.h (original) > +++ llvm/trunk/include/llvm/Analysis/DebugInfo.h Mon Aug 9 16:39:24 2010 > @@ -62,6 +62,7 @@ > } > > GlobalVariable *getGlobalVariableField(unsigned Elt) const; > + Constant *getConstantField(unsigned Elt) const; > Function *getFunctionField(unsigned Elt) const; > > public: > @@ -447,6 +448,7 @@ > unsigned isDefinition() const { return getUnsignedField(10); } > > GlobalVariable *getGlobal() const { return getGlobalVariableField(11); } > + Constant *getConstant() const { return getConstantField(11); } > > /// Verify - Verify that a global variable descriptor is well formed. > bool Verify() const; > @@ -696,6 +698,15 @@ > unsigned LineNo, DIType Ty, bool isLocalToUnit, > bool isDefinition, llvm::GlobalVariable *GV); > > + /// CreateGlobalVariable - Create a new descriptor for the specified constant. > + DIGlobalVariable > + CreateGlobalVariable(DIDescriptor Context, StringRef Name, > + StringRef DisplayName, > + StringRef LinkageName, > + DIFile F, > + unsigned LineNo, DIType Ty, bool isLocalToUnit, > + bool isDefinition, llvm::Constant *C); > + > /// CreateVariable - Create a new descriptor for the specified variable. > DIVariable CreateVariable(unsigned Tag, DIDescriptor Context, > StringRef Name, > > Modified: llvm/trunk/lib/Analysis/DebugInfo.cpp > URL: http://llvm.org/viewvc/llvm-project/llvm/trunk/lib/Analysis/DebugInfo.cpp?rev=110607&r1=110606&r2=110607&view=diff > ============================================================================== > --- llvm/trunk/lib/Analysis/DebugInfo.cpp (original) > +++ llvm/trunk/lib/Analysis/DebugInfo.cpp Mon Aug 9 16:39:24 2010 > @@ -89,6 +89,15 @@ > return 0; > } > > +Constant *DIDescriptor::getConstantField(unsigned Elt) const { > + if (DbgNode == 0) > + return 0; > + > + if (Elt < DbgNode->getNumOperands()) > + return dyn_cast_or_null(DbgNode->getOperand(Elt)); > + return 0; > +} > + > Function *DIDescriptor::getFunctionField(unsigned Elt) const { > if (DbgNode == 0) > return 0; > @@ -341,7 +350,7 @@ > if (!Ty.Verify()) > return false; > > - if (!getGlobal()) > + if (!getGlobal() && !getConstant()) > return false; > > return true; > @@ -1060,6 +1069,38 @@ > return DIGlobalVariable(Node); > } > > +/// CreateGlobalVariable - Create a new descriptor for the specified constant. > +DIGlobalVariable > +DIFactory::CreateGlobalVariable(DIDescriptor Context, StringRef Name, > + StringRef DisplayName, > + StringRef LinkageName, > + DIFile F, > + unsigned LineNo, DIType Ty,bool isLocalToUnit, > + bool isDefinition, llvm::Constant *Val) { > + Value *Elts[] = { > + GetTagConstant(dwarf::DW_TAG_variable), > + llvm::Constant::getNullValue(Type::getInt32Ty(VMContext)), > + Context, > + MDString::get(VMContext, Name), > + MDString::get(VMContext, DisplayName), > + MDString::get(VMContext, LinkageName), > + F, > + ConstantInt::get(Type::getInt32Ty(VMContext), LineNo), > + Ty, > + ConstantInt::get(Type::getInt1Ty(VMContext), isLocalToUnit), > + ConstantInt::get(Type::getInt1Ty(VMContext), isDefinition), > + Val > + }; > + > + Value *const *Vs = &Elts[0]; > + MDNode *Node = MDNode::get(VMContext,Vs, 12); > + > + // Create a named metadata so that we do not lose this mdnode. > + NamedMDNode *NMD = M.getOrInsertNamedMetadata("llvm.dbg.gv"); > + NMD->addOperand(Node); > + > + return DIGlobalVariable(Node); > +} > > /// CreateVariable - Create a new descriptor for the specified variable. > DIVariable DIFactory::CreateVariable(unsigned Tag, DIDescriptor Context, > > Modified: llvm/trunk/lib/CodeGen/AsmPrinter/DwarfDebug.cpp > URL: http://llvm.org/viewvc/llvm-project/llvm/trunk/lib/CodeGen/AsmPrinter/DwarfDebug.cpp?rev=110607&r1=110606&r2=110607&view=diff > ============================================================================== > --- llvm/trunk/lib/CodeGen/AsmPrinter/DwarfDebug.cpp (original) > +++ llvm/trunk/lib/CodeGen/AsmPrinter/DwarfDebug.cpp Mon Aug 9 16:39:24 2010 > @@ -1190,7 +1190,7 @@ > DIE *DwarfDebug::createGlobalVariableDIE(const DIGlobalVariable &GV) { > // If the global variable was optmized out then no need to create debug info > // entry. > - if (!GV.getGlobal()) return NULL; > + if (!GV.Verify()) return NULL; > if (GV.getDisplayName().empty()) return NULL; > > DIE *GVDie = new DIE(dwarf::DW_TAG_variable); > @@ -1908,6 +1908,10 @@ > > // Add to context owner. > DIDescriptor GVContext = DI_GV.getContext(); > + DIEBlock *Block = new (DIEValueAllocator) DIEBlock(); > + addUInt(Block, 0, dwarf::DW_FORM_data1, dwarf::DW_OP_addr); > + addLabel(Block, 0, dwarf::DW_FORM_udata, > + Asm->Mang->getSymbol(DI_GV.getGlobal())); > // Do not create specification DIE if context is either compile unit > // or a subprogram. > if (DI_GV.isDefinition() && !GVContext.isCompileUnit() && > @@ -1917,18 +1921,10 @@ > DIE *VariableSpecDIE = new DIE(dwarf::DW_TAG_variable); > addDIEEntry(VariableSpecDIE, dwarf::DW_AT_specification, > dwarf::DW_FORM_ref4, VariableDie); > - DIEBlock *Block = new (DIEValueAllocator) DIEBlock(); > - addUInt(Block, 0, dwarf::DW_FORM_data1, dwarf::DW_OP_addr); > - addLabel(Block, 0, dwarf::DW_FORM_udata, > - Asm->Mang->getSymbol(DI_GV.getGlobal())); > addBlock(VariableSpecDIE, dwarf::DW_AT_location, 0, Block); > addUInt(VariableDie, dwarf::DW_AT_declaration, dwarf::DW_FORM_flag, 1); > TheCU->addDie(VariableSpecDIE); > } else { > - DIEBlock *Block = new (DIEValueAllocator) DIEBlock(); > - addUInt(Block, 0, dwarf::DW_FORM_data1, dwarf::DW_OP_addr); > - addLabel(Block, 0, dwarf::DW_FORM_udata, > - Asm->Mang->getSymbol(DI_GV.getGlobal())); > addBlock(VariableDie, dwarf::DW_AT_location, 0, Block); > } > addToContextOwner(VariableDie, GVContext); > > > _______________________________________________ > llvm-commits mailing list > llvm-commits at cs.uiuc.edu > http://lists.cs.uiuc.edu/mailman/listinfo/llvm-commits - Devang From dpatel at apple.com Tue Aug 10 02:11:13 2010 From: dpatel at apple.com (Devang Patel) Date: Tue, 10 Aug 2010 07:11:13 -0000 Subject: [llvm-commits] [llvm] r110656 - in /llvm/trunk: lib/Analysis/DebugInfo.cpp lib/CodeGen/AsmPrinter/DwarfDebug.cpp test/CodeGen/X86/2010-08-10-DbgConstant.ll Message-ID: <20100810071113.93BAA2A6C12C@llvm.org> Author: dpatel Date: Tue Aug 10 02:11:13 2010 New Revision: 110656 URL: http://llvm.org/viewvc/llvm-project?rev=110656&view=rev Log: Handle TAG_constant for integers. Added: llvm/trunk/test/CodeGen/X86/2010-08-10-DbgConstant.ll Modified: llvm/trunk/lib/Analysis/DebugInfo.cpp llvm/trunk/lib/CodeGen/AsmPrinter/DwarfDebug.cpp Modified: llvm/trunk/lib/Analysis/DebugInfo.cpp URL: http://llvm.org/viewvc/llvm-project/llvm/trunk/lib/Analysis/DebugInfo.cpp?rev=110656&r1=110655&r2=110656&view=diff ============================================================================== --- llvm/trunk/lib/Analysis/DebugInfo.cpp (original) +++ llvm/trunk/lib/Analysis/DebugInfo.cpp Tue Aug 10 02:11:13 2010 @@ -186,7 +186,8 @@ /// isGlobalVariable - Return true if the specified tag is legal for /// DIGlobalVariable. bool DIDescriptor::isGlobalVariable() const { - return DbgNode && getTag() == dwarf::DW_TAG_variable; + return DbgNode && (getTag() == dwarf::DW_TAG_variable || + getTag() == dwarf::DW_TAG_constant); } /// isGlobal - Return true if the specified tag is legal for DIGlobal. @@ -1078,7 +1079,7 @@ unsigned LineNo, DIType Ty,bool isLocalToUnit, bool isDefinition, llvm::Constant *Val) { Value *Elts[] = { - GetTagConstant(dwarf::DW_TAG_variable), + GetTagConstant(dwarf::DW_TAG_constant), llvm::Constant::getNullValue(Type::getInt32Ty(VMContext)), Context, MDString::get(VMContext, Name), Modified: llvm/trunk/lib/CodeGen/AsmPrinter/DwarfDebug.cpp URL: http://llvm.org/viewvc/llvm-project/llvm/trunk/lib/CodeGen/AsmPrinter/DwarfDebug.cpp?rev=110656&r1=110655&r2=110656&view=diff ============================================================================== --- llvm/trunk/lib/CodeGen/AsmPrinter/DwarfDebug.cpp (original) +++ llvm/trunk/lib/CodeGen/AsmPrinter/DwarfDebug.cpp Tue Aug 10 02:11:13 2010 @@ -1876,13 +1876,15 @@ return; DIType GTy = GV.getType(); - DIE *VariableDIE = new DIE(dwarf::DW_TAG_variable); + DIE *VariableDIE = new DIE(GV.getTag()); + + bool isGlobalVariable = GV.getGlobal() != NULL; // Add name. addString(VariableDIE, dwarf::DW_AT_name, dwarf::DW_FORM_string, GV.getDisplayName()); StringRef LinkageName = GV.getLinkageName(); - if (!LinkageName.empty()) + if (!LinkageName.empty() && isGlobalVariable) addString(VariableDIE, dwarf::DW_AT_MIPS_linkage_name, dwarf::DW_FORM_string, getRealLinkageName(LinkageName)); // Add type. @@ -1907,25 +1909,40 @@ DIDescriptor GVContext = GV.getContext(); addToContextOwner(VariableDIE, GVContext); // Add location. - DIEBlock *Block = new (DIEValueAllocator) DIEBlock(); - addUInt(Block, 0, dwarf::DW_FORM_data1, dwarf::DW_OP_addr); - addLabel(Block, 0, dwarf::DW_FORM_udata, - Asm->Mang->getSymbol(GV.getGlobal())); - // Do not create specification DIE if context is either compile unit - // or a subprogram. - if (GV.isDefinition() && !GVContext.isCompileUnit() && - !GVContext.isFile() && !isSubprogramContext(GVContext)) { - // Create specification DIE. - DIE *VariableSpecDIE = new DIE(dwarf::DW_TAG_variable); - addDIEEntry(VariableSpecDIE, dwarf::DW_AT_specification, - dwarf::DW_FORM_ref4, VariableDIE); - addBlock(VariableSpecDIE, dwarf::DW_AT_location, 0, Block); - addUInt(VariableDIE, dwarf::DW_AT_declaration, dwarf::DW_FORM_flag, 1); - TheCU->addDie(VariableSpecDIE); - } else { - addBlock(VariableDIE, dwarf::DW_AT_location, 0, Block); + if (isGlobalVariable) { + DIEBlock *Block = new (DIEValueAllocator) DIEBlock(); + addUInt(Block, 0, dwarf::DW_FORM_data1, dwarf::DW_OP_addr); + addLabel(Block, 0, dwarf::DW_FORM_udata, + Asm->Mang->getSymbol(GV.getGlobal())); + // Do not create specification DIE if context is either compile unit + // or a subprogram. + if (GV.isDefinition() && !GVContext.isCompileUnit() && + !GVContext.isFile() && !isSubprogramContext(GVContext)) { + // Create specification DIE. + DIE *VariableSpecDIE = new DIE(dwarf::DW_TAG_variable); + addDIEEntry(VariableSpecDIE, dwarf::DW_AT_specification, + dwarf::DW_FORM_ref4, VariableDIE); + addBlock(VariableSpecDIE, dwarf::DW_AT_location, 0, Block); + addUInt(VariableDIE, dwarf::DW_AT_declaration, dwarf::DW_FORM_flag, 1); + TheCU->addDie(VariableSpecDIE); + } else { + addBlock(VariableDIE, dwarf::DW_AT_location, 0, Block); + } + } else if (Constant *C = GV.getConstant()) { + if (ConstantInt *CI = dyn_cast(C)) { + DIBasicType BTy(GTy); + if (BTy.Verify()) { + unsigned Encoding = BTy.getEncoding(); + if (Encoding == dwarf::DW_ATE_unsigned || + Encoding == dwarf::DW_ATE_unsigned_char) + addUInt(VariableDIE, dwarf::DW_AT_const_value, dwarf::DW_FORM_udata, + CI->getZExtValue()); + else + addSInt(VariableDIE, dwarf::DW_AT_const_value, dwarf::DW_FORM_sdata, + CI->getSExtValue()); + } + } } - return; } Added: llvm/trunk/test/CodeGen/X86/2010-08-10-DbgConstant.ll URL: http://llvm.org/viewvc/llvm-project/llvm/trunk/test/CodeGen/X86/2010-08-10-DbgConstant.ll?rev=110656&view=auto ============================================================================== --- llvm/trunk/test/CodeGen/X86/2010-08-10-DbgConstant.ll (added) +++ llvm/trunk/test/CodeGen/X86/2010-08-10-DbgConstant.ll Tue Aug 10 02:11:13 2010 @@ -0,0 +1,25 @@ +; RUN: llc -O0 < %s | FileCheck %s +; CHECK: DW_TAG_constant +; CHECK-NEXT: ascii "ro" ## DW_AT_name + +define void @foo() nounwind ssp { +entry: + call void @bar(i32 201), !dbg !8 + ret void, !dbg !8 +} + +declare void @bar(i32) + +!llvm.dbg.sp = !{!0} +!llvm.dbg.gv = !{!5} + +!0 = metadata !{i32 524334, i32 0, metadata !1, metadata !"foo", metadata !"foo", metadata !"foo", metadata !1, i32 3, metadata !3, i1 false, i1 true, i32 0, i32 0, null, i1 false, i1 false, void ()* @foo} ; [ DW_TAG_subprogram ] +!1 = metadata !{i32 524329, metadata !"/tmp/l.c", metadata !"/Volumes/Lalgate/clean/D", metadata !2} ; [ DW_TAG_file_type ] +!2 = metadata !{i32 524305, i32 0, i32 12, metadata !"/tmp/l.c", metadata !"/Volumes/Lalgate/clean/D", metadata !"clang 2.8", i1 true, i1 false, metadata !"", i32 0} ; [ DW_TAG_compile_unit ] +!3 = metadata !{i32 524309, metadata !1, metadata !"", metadata !1, i32 0, i64 0, i64 0, i64 0, i32 0, null, metadata !4, i32 0, null} ; [ DW_TAG_subroutine_type ] +!4 = metadata !{null} +!5 = metadata !{i32 524327, i32 0, metadata !1, metadata !"ro", metadata !"ro", metadata !"ro", metadata !1, i32 1, metadata !6, i1 true, i1 true, i32 201} ; [ DW_TAG_constant ] +!6 = metadata !{i32 524326, metadata !1, metadata !"", metadata !1, i32 0, i64 0, i64 0, i64 0, i32 0, metadata !7} ; [ DW_TAG_const_type ] +!7 = metadata !{i32 524324, metadata !1, metadata !"unsigned int", metadata !1, i32 0, i64 32, i64 32, i64 0, i32 0, i32 7} ; [ DW_TAG_base_type ] +!8 = metadata !{i32 3, i32 14, metadata !9, null} +!9 = metadata !{i32 524299, metadata !0, i32 3, i32 12, metadata !1, i32 0} ; [ DW_TAG_lexical_block ] From isanbard at gmail.com Tue Aug 10 02:18:53 2010 From: isanbard at gmail.com (Bill Wendling) Date: Tue, 10 Aug 2010 07:18:53 -0000 Subject: [llvm-commits] [llvm-gcc-4.2] r110657 - /llvm-gcc-4.2/trunk/gcc/testsuite/g++.apple/weak-1.C Message-ID: <20100810071853.8C5DF2A6C12C@llvm.org> Author: void Date: Tue Aug 10 02:18:53 2010 New Revision: 110657 URL: http://llvm.org/viewvc/llvm-project?rev=110657&view=rev Log: Correct whitespace checking. Modified: llvm-gcc-4.2/trunk/gcc/testsuite/g++.apple/weak-1.C Modified: llvm-gcc-4.2/trunk/gcc/testsuite/g++.apple/weak-1.C URL: http://llvm.org/viewvc/llvm-project/llvm-gcc-4.2/trunk/gcc/testsuite/g%2B%2B.apple/weak-1.C?rev=110657&r1=110656&r2=110657&view=diff ============================================================================== --- llvm-gcc-4.2/trunk/gcc/testsuite/g++.apple/weak-1.C (original) +++ llvm-gcc-4.2/trunk/gcc/testsuite/g++.apple/weak-1.C Tue Aug 10 02:18:53 2010 @@ -1,7 +1,9 @@ /* APPLE LOCAL file weak types 5954418 */ /* { dg-do compile } */ -/* { dg-final { scan-assembler "weak_definition __ZTI1B" } } */ -/* { dg-final { scan-assembler "weak_definition __ZTI1A" } } */ +/* LLVM LOCAL begin - Whitespace */ +/* { dg-final { scan-assembler "weak_definition\[ \t]+__ZTI1B" } } */ +/* { dg-final { scan-assembler "weak_definition\[ \t]+__ZTI1A" } } */ +/* LLVM LOCAL end - Whitespace */ /* Radar 5954418 */ #define WEAK __attribute__ ((weak)) From isanbard at gmail.com Tue Aug 10 02:19:33 2010 From: isanbard at gmail.com (Bill Wendling) Date: Tue, 10 Aug 2010 07:19:33 -0000 Subject: [llvm-commits] [llvm-gcc-4.2] r110658 - /llvm-gcc-4.2/trunk/gcc/testsuite/g++.apple/block-5988451.C Message-ID: <20100810071933.E61042A6C12C@llvm.org> Author: void Date: Tue Aug 10 02:19:33 2010 New Revision: 110658 URL: http://llvm.org/viewvc/llvm-project?rev=110658&view=rev Log: Update to current blocks. Modified: llvm-gcc-4.2/trunk/gcc/testsuite/g++.apple/block-5988451.C Modified: llvm-gcc-4.2/trunk/gcc/testsuite/g++.apple/block-5988451.C URL: http://llvm.org/viewvc/llvm-project/llvm-gcc-4.2/trunk/gcc/testsuite/g%2B%2B.apple/block-5988451.C?rev=110658&r1=110657&r2=110658&view=diff ============================================================================== --- llvm-gcc-4.2/trunk/gcc/testsuite/g++.apple/block-5988451.C (original) +++ llvm-gcc-4.2/trunk/gcc/testsuite/g++.apple/block-5988451.C Tue Aug 10 02:19:33 2010 @@ -6,15 +6,11 @@ typedef struct dispatch_queue_s *dispatch_queue_t; typedef struct dispatch_item_s *dispatch_item_t; -typedef void (^dispatch_block_t)(dispatch_item_t item); +dispatch_item_t dispatch_call(dispatch_queue_t queue, + dispatch_legacy_block_t work, + dispatch_legacy_block_t completion); -void dispatch_call(dispatch_queue_t queue, - dispatch_block_t work, - dispatch_block_t completion, - void* context, - dispatch_item_t *item); - -void dispatch_apply_wait(dispatch_block_t work, +void dispatch_apply_wait(dispatch_legacy_block_t work, unsigned iterations, void *context); @@ -34,15 +30,14 @@ { dispatch_queue_t queue; - dispatch_call(queue, + dispatch_call(queue, /* { dg-warning "deprecated" } */ ^(dispatch_item_t item) { dispatch_apply_wait(^(dispatch_item_t item) { [NSValue valueWithPointer:self]; }, 10,NULL); }, - ^(dispatch_item_t item) {NSLog(@"test");}, - NULL, NULL); + ^(dispatch_item_t item) {NSLog(@"test");}); /* { dg-warning "deprecated" } */ } From isanbard at gmail.com Tue Aug 10 02:19:57 2010 From: isanbard at gmail.com (Bill Wendling) Date: Tue, 10 Aug 2010 07:19:57 -0000 Subject: [llvm-commits] [llvm-gcc-4.2] r110659 - /llvm-gcc-4.2/trunk/gcc/testsuite/g++.apple/guard-1.h Message-ID: <20100810071957.97D112A6C12C@llvm.org> Author: void Date: Tue Aug 10 02:19:57 2010 New Revision: 110659 URL: http://llvm.org/viewvc/llvm-project?rev=110659&view=rev Log: Remove unneeded header file. Modified: llvm-gcc-4.2/trunk/gcc/testsuite/g++.apple/guard-1.h Modified: llvm-gcc-4.2/trunk/gcc/testsuite/g++.apple/guard-1.h URL: http://llvm.org/viewvc/llvm-project/llvm-gcc-4.2/trunk/gcc/testsuite/g%2B%2B.apple/guard-1.h?rev=110659&r1=110658&r2=110659&view=diff ============================================================================== --- llvm-gcc-4.2/trunk/gcc/testsuite/g++.apple/guard-1.h (original) +++ llvm-gcc-4.2/trunk/gcc/testsuite/g++.apple/guard-1.h Tue Aug 10 02:19:57 2010 @@ -1,7 +1,5 @@ /* APPLE LOCAL file Radar 4539933 */ -#include - extern int result; class A From isanbard at gmail.com Tue Aug 10 02:46:03 2010 From: isanbard at gmail.com (Bill Wendling) Date: Tue, 10 Aug 2010 07:46:03 -0000 Subject: [llvm-commits] [llvm-gcc-4.2] r110661 - /llvm-gcc-4.2/trunk/gcc/testsuite/lib/gcc-dg.exp Message-ID: <20100810074603.912472A6C12D@llvm.org> Author: void Date: Tue Aug 10 02:46:03 2010 New Revision: 110661 URL: http://llvm.org/viewvc/llvm-project?rev=110661&view=rev Log: Only run dwarf debug tests. Modified: llvm-gcc-4.2/trunk/gcc/testsuite/lib/gcc-dg.exp Modified: llvm-gcc-4.2/trunk/gcc/testsuite/lib/gcc-dg.exp URL: http://llvm.org/viewvc/llvm-project/llvm-gcc-4.2/trunk/gcc/testsuite/lib/gcc-dg.exp?rev=110661&r1=110660&r2=110661&view=diff ============================================================================== --- llvm-gcc-4.2/trunk/gcc/testsuite/lib/gcc-dg.exp (original) +++ llvm-gcc-4.2/trunk/gcc/testsuite/lib/gcc-dg.exp Tue Aug 10 02:46:03 2010 @@ -260,7 +260,8 @@ if ![info exists DEBUG_TORTURE_OPTIONS] { set DEBUG_TORTURE_OPTIONS "" - foreach type {-gdwarf-2 -gstabs -gstabs+ -gxcoff -gxcoff+ -gcoff} { + # LLVM LOCAL - Don't run -gstabs, -gstabs+, -gxcoff, -gxcoff+, or -gcoff + foreach type {-gdwarf-2} { set comp_output [$target_compile \ "$srcdir/$subdir/$trivial" "trivial.S" assembly \ "additional_flags=$type"] From isanbard at gmail.com Tue Aug 10 02:46:23 2010 From: isanbard at gmail.com (Bill Wendling) Date: Tue, 10 Aug 2010 07:46:23 -0000 Subject: [llvm-commits] [llvm-gcc-4.2] r110662 - /llvm-gcc-4.2/trunk/gcc/testsuite/g++.dg/abi/key2.C Message-ID: <20100810074623.F049A2A6C12D@llvm.org> Author: void Date: Tue Aug 10 02:46:23 2010 New Revision: 110662 URL: http://llvm.org/viewvc/llvm-project?rev=110662&view=rev Log: Fix spacing, but the strings still do not match. Modified: llvm-gcc-4.2/trunk/gcc/testsuite/g++.dg/abi/key2.C Modified: llvm-gcc-4.2/trunk/gcc/testsuite/g++.dg/abi/key2.C URL: http://llvm.org/viewvc/llvm-project/llvm-gcc-4.2/trunk/gcc/testsuite/g%2B%2B.dg/abi/key2.C?rev=110662&r1=110661&r2=110662&view=diff ============================================================================== --- llvm-gcc-4.2/trunk/gcc/testsuite/g++.dg/abi/key2.C (original) +++ llvm-gcc-4.2/trunk/gcc/testsuite/g++.dg/abi/key2.C Tue Aug 10 02:46:23 2010 @@ -3,12 +3,13 @@ // { dg-do compile { target *-*-darwin* } } // LLVM LOCAL begin rearrange tests to check current syntax -// { dg-final { scan-assembler " .section __DATA,__const_coal,coalesced\\n .globl __ZTV1f\\n .weak_definition __ZTV1f\\n" } } -// { dg-final { scan-assembler " .section __TEXT,__const_coal,coalesced\\n .globl __ZTS1f\\n .weak_definition __ZTS1f\\n" } } +// { dg-final { scan-assembler ".section\[ \t]+__DATA,__const_coal,coalesced\\n\[ \t]+.globl\[ \t]+__ZTV1f\\n\[ \t]+.weak_definition\[ \t]+__ZTV1f\\n" } } +// { dg-final { scan-assembler ".section\[ \t]+__TEXT,__const_coal,coalesced\\n\[ \t]+.globl\[ \t]+__ZTS1f\\n\[ \t]+.weak_definition\[ \t]+__ZTS1f\\n" } } + // With llvm ZTI1f is in the right place, but the ordering is different // so the .section directive is not needed. Do the best we can. // (It belongs in the same place as ZTV1f.) -// { dg-final { scan-assembler ".globl __ZTI1f\\n .weak_definition __ZTI1f\\n" } } +// { dg-final { scan-assembler ".globl\[ \t]+__ZTI1f\\n\[ \t]+.weak_definition\[ \t]+__ZTI1f\\n" } } // LLVM LOCAL end class f From grosser at fim.uni-passau.de Tue Aug 10 02:57:34 2010 From: grosser at fim.uni-passau.de (Tobias Grosser) Date: Tue, 10 Aug 2010 09:57:34 +0200 Subject: [llvm-commits] [patch] Don't link as many parts of llvm into bugpoint In-Reply-To: <355_1281407631_4C60BA8F_355_28788_1_AANLkTinq+w9vAvjdqF7dusNkoR55xHL8OgdM66rRxM7g@mail.gmail.com> References: <355_1281407631_4C60BA8F_355_28788_1_AANLkTinq+w9vAvjdqF7dusNkoR55xHL8OgdM66rRxM7g@mail.gmail.com> Message-ID: <4C61066E.2010704@fim.uni-passau.de> On 08/10/2010 04:32 AM, Rafael Espindola wrote: > The attached patch is mostly a request for comments. On a debug build > it reduces bugpoint from 68 MB to 34 MB. The difference is not free: > > *) The std-compile-opts and std-link-opts are gone. > *) Passes now have to be listed with the -pass option. > > I think I can get those back with some more refactoring, but would > like some opinions first. Do you think the patch is OK? Do you think > it is OK if I manage to keep the current command line interface? The > main reason for this is that since bugpoint is a tool for hunting bugs > in llvm, it is nice for it to not be linked with every single LLVM > pass. Specially if the only thing it does with most of those passes is > collect their names :-) > > Cheers, Just from my point of view I love to be able to use the same command line for opt and bugpoint. If opt fails with a bug I just replace "opt" with "bugpoint" in the command line. As I sometimes use the -std-compile-opts flag, it would be inconvenient to have to replace it manually. Maybe there is an easy way to get the -std-compile-opts support back without having to link to all those other libraries? By the way, bugpoint always gives me an error if I leave the "-o" option in the command line. It would be nice if it could just ignore it with a warning. Like this I really just need to replace "opt" with "bugpoint". Thanks for you ongoing great work on bugpoint. Tobi From grosser at fim.uni-passau.de Tue Aug 10 04:54:29 2010 From: grosser at fim.uni-passau.de (Tobias Grosser) Date: Tue, 10 Aug 2010 09:54:29 -0000 Subject: [llvm-commits] [llvm] r110664 - /llvm/trunk/test/CodeGen/X86/2010-08-10-DbgConstant.ll Message-ID: <20100810095429.E5F462A6C12C@llvm.org> Author: grosser Date: Tue Aug 10 04:54:29 2010 New Revision: 110664 URL: http://llvm.org/viewvc/llvm-project?rev=110664&view=rev Log: Fix failing testcase. Those look like typos to me. Modified: llvm/trunk/test/CodeGen/X86/2010-08-10-DbgConstant.ll Modified: llvm/trunk/test/CodeGen/X86/2010-08-10-DbgConstant.ll URL: http://llvm.org/viewvc/llvm-project/llvm/trunk/test/CodeGen/X86/2010-08-10-DbgConstant.ll?rev=110664&r1=110663&r2=110664&view=diff ============================================================================== --- llvm/trunk/test/CodeGen/X86/2010-08-10-DbgConstant.ll (original) +++ llvm/trunk/test/CodeGen/X86/2010-08-10-DbgConstant.ll Tue Aug 10 04:54:29 2010 @@ -1,6 +1,6 @@ ; RUN: llc -O0 < %s | FileCheck %s ; CHECK: DW_TAG_constant -; CHECK-NEXT: ascii "ro" ## DW_AT_name +; CHECK-NEXT: .ascii "ro" # DW_AT_name define void @foo() nounwind ssp { entry: From grosser at fim.uni-passau.de Tue Aug 10 04:54:35 2010 From: grosser at fim.uni-passau.de (Tobias Grosser) Date: Tue, 10 Aug 2010 09:54:35 -0000 Subject: [llvm-commits] [llvm] r110665 - in /llvm/trunk: lib/Analysis/RegionInfo.cpp test/Analysis/RegionInfo/20100809_bb_not_in_domtree.ll Message-ID: <20100810095435.A3D442A6C12D@llvm.org> Author: grosser Date: Tue Aug 10 04:54:35 2010 New Revision: 110665 URL: http://llvm.org/viewvc/llvm-project?rev=110665&view=rev Log: RegionInfo: Do not assert if a BB is not part of the dominance tree. Added: llvm/trunk/test/Analysis/RegionInfo/20100809_bb_not_in_domtree.ll Modified: llvm/trunk/lib/Analysis/RegionInfo.cpp Modified: llvm/trunk/lib/Analysis/RegionInfo.cpp URL: http://llvm.org/viewvc/llvm-project/llvm/trunk/lib/Analysis/RegionInfo.cpp?rev=110665&r1=110664&r2=110665&view=diff ============================================================================== --- llvm/trunk/lib/Analysis/RegionInfo.cpp (original) +++ llvm/trunk/lib/Analysis/RegionInfo.cpp Tue Aug 10 04:54:35 2010 @@ -136,14 +136,16 @@ return false; for (pred_iterator PI = pred_begin(entry), PE = pred_end(entry); PI != PE; - ++PI) - if (!contains(*PI)) { + ++PI) { + BasicBlock *Pred = *PI; + if (DT->getNode(Pred) && !contains(Pred)) { if (found) { isSimple = false; break; } found = true; } + } found = false; Added: llvm/trunk/test/Analysis/RegionInfo/20100809_bb_not_in_domtree.ll URL: http://llvm.org/viewvc/llvm-project/llvm/trunk/test/Analysis/RegionInfo/20100809_bb_not_in_domtree.ll?rev=110665&view=auto ============================================================================== --- llvm/trunk/test/Analysis/RegionInfo/20100809_bb_not_in_domtree.ll (added) +++ llvm/trunk/test/Analysis/RegionInfo/20100809_bb_not_in_domtree.ll Tue Aug 10 04:54:35 2010 @@ -0,0 +1,20 @@ +; RUN: opt -regions %s +define i32 @main() nounwind { +entry: + br label %for.cond + +test: + br label %for.cond + +for.cond: ; preds = %for.inc, %entry + br i1 true, label %for.body, label %for.end + +for.body: ; preds = %for.cond + br label %for.inc + +for.inc: ; preds = %for.body + br label %for.cond + +for.end: ; preds = %for.cond + ret i32 0 +} From chandlerc at gmail.com Tue Aug 10 05:39:25 2010 From: chandlerc at gmail.com (Chandler Carruth) Date: Tue, 10 Aug 2010 10:39:25 -0000 Subject: [llvm-commits] [llvm] r110667 - /llvm/trunk/lib/System/RWMutex.cpp Message-ID: <20100810103925.BD6942A6C12C@llvm.org> Author: chandlerc Date: Tue Aug 10 05:39:25 2010 New Revision: 110667 URL: http://llvm.org/viewvc/llvm-project?rev=110667&view=rev Log: Mark this variable as used. Modified: llvm/trunk/lib/System/RWMutex.cpp Modified: llvm/trunk/lib/System/RWMutex.cpp URL: http://llvm.org/viewvc/llvm-project/llvm/trunk/lib/System/RWMutex.cpp?rev=110667&r1=110666&r2=110667&view=diff ============================================================================== --- llvm/trunk/lib/System/RWMutex.cpp (original) +++ llvm/trunk/lib/System/RWMutex.cpp Tue Aug 10 05:39:25 2010 @@ -73,6 +73,7 @@ // Initialize the rwlock int errorcode = pthread_rwlock_init(rwlock, NULL); + (void)errorcode; assert(errorcode == 0); // Assign the data member From xerxes at zafena.se Tue Aug 10 05:45:08 2010 From: xerxes at zafena.se (=?ISO-8859-1?Q?Xerxes_R=E5nby?=) Date: Tue, 10 Aug 2010 12:45:08 +0200 Subject: [llvm-commits] [patch] pr7852 - Make LLVM robust to #define ARCH pollution by removing fragile macros. Message-ID: <4C612DB4.9050908@zafena.se> patch: http://llvm.org/bugs/attachment.cgi?id=5357 Remove use of fragile macros to define native target init function names in include/llvm/Target/TargetSelect.h and llvm/include/llvm-c/Target.h Instead of using macros the native target init function names are resolved at config.h generation time by setting three new defines. /* LLVM name for the native Target init function, if available */ #cmakedefine LLVM_NATIVE_TARGET LLVMInitialize${LLVM_NATIVE_ARCH}Target /* LLVM name for the native TargetInfo init function, if available */ #cmakedefine LLVM_NATIVE_TARGETINFO LLVMInitialize${LLVM_NATIVE_ARCH}TargetInfo /* LLVM name for the native AsmPrinter init function, if available */ #cmakedefine LLVM_NATIVE_ASMPRINTER LLVMInitialize${LLVM_NATIVE_ARCH}AsmPrinter Updated include/llvm/Target/TargetSelect.h and llvm/include/llvm-c/Target.h use the new defines. Changed LLVM_NATIVE_ARCH define to actually contain the ${LLVM_NATIVE_ARCH} value. I have tested this patch using cmake and configure. I need help regenerating the configure using autotools 2.60 since i have changed autoconf/configure.ac. Cheers Xerxes From Kalle.Raiskila at nokia.com Tue Aug 10 05:53:11 2010 From: Kalle.Raiskila at nokia.com (Kalle.Raiskila at nokia.com) Date: Tue, 10 Aug 2010 12:53:11 +0200 Subject: [llvm-commits] [llvm] r110576 - in /llvm/trunk: lib/Target/CellSPU/SPUISelLowering.cpp lib/Target/CellSPU/SPUISelLowering.h lib/Target/CellSPU/SPUInstrInfo.td lib/Target/CellSPU/SPUNodes.td lib/Target/CellSPU/SPURegisterInfo.cpp test/CodeGen/CellSP... In-Reply-To: <25685170-45BA-47F0-AF9D-0D0600748145@apple.com> References: <20100809163301.235462A6C12C@llvm.org> <25685170-45BA-47F0-AF9D-0D0600748145@apple.com> Message-ID: <1281437591.1796.146.camel@LLVMbuilder.research.nokia.com> On Tue, 2010-08-10 at 02:24 +0200, Chris Lattner wrote: > On Aug 9, 2010, at 9:33 AM, Kalle Raiskila wrote: > > > Author: kraiskil > > Date: Mon Aug 9 11:33:00 2010 > > New Revision: 110576 > > > > URL: http://llvm.org/viewvc/llvm-project?rev=110576&view=rev > > Log: > > Have SPU handle halfvec stores aligned by 8 bytes. > > Kalle, > > Again, what's going on here? Why isn't type legalization doing its job? Good question. With the 8byte memory accesses I was just copying the functionality of the 4, 2, and 1 byte accesses. (16 bytes being the granularity of the memory access). I thought they must be implemented as they are for a reason. Experimenting a little shows that promoting v2i32 works rather nicely, *if* v2i32 is not a "legal" type (i.e. there is no register class added for v2i32). When it is a legal type, all sorts of asserts trigger when trying to expand operations on that type. The reason it is legal (currently, in the SPU backend) is that a) it was like that when I found it :) b) to the best of my understanding, v2i32 has to be legal if it is to be used in return values and function parameters. So: what is the reason i32 (and f32, and so on) are treated separately, as if there were separate instructions/registers for that type, as opposed to just being promoted to v4i32, v4f32 and so on? And: is there a way of passing illegal types of arguments (such as i32 etc.) to functions? If the parameter passing and promotion are possible, I see no reason at all to separately treat half (quarter) full vectors. thanks, kalle P.s. sorry for not replying to the previous mail with essentially the same question: I (hope I) have now removed the relevant bug from my mail filter... From isanbard at gmail.com Tue Aug 10 06:06:16 2010 From: isanbard at gmail.com (Bill Wendling) Date: Tue, 10 Aug 2010 11:06:16 -0000 Subject: [llvm-commits] [llvm-gcc-4.2] r110668 - /llvm-gcc-4.2/trunk/gcc/testsuite/gcc.apple/block-ivar.c Message-ID: <20100810110616.9ACDE2A6C12C@llvm.org> Author: void Date: Tue Aug 10 06:06:16 2010 New Revision: 110668 URL: http://llvm.org/viewvc/llvm-project?rev=110668&view=rev Log: Remove all ready declared function declaration. Modified: llvm-gcc-4.2/trunk/gcc/testsuite/gcc.apple/block-ivar.c Modified: llvm-gcc-4.2/trunk/gcc/testsuite/gcc.apple/block-ivar.c URL: http://llvm.org/viewvc/llvm-project/llvm-gcc-4.2/trunk/gcc/testsuite/gcc.apple/block-ivar.c?rev=110668&r1=110667&r2=110668&view=diff ============================================================================== --- llvm-gcc-4.2/trunk/gcc/testsuite/gcc.apple/block-ivar.c (original) +++ llvm-gcc-4.2/trunk/gcc/testsuite/gcc.apple/block-ivar.c Tue Aug 10 06:06:16 2010 @@ -5,8 +5,6 @@ #import -void *Block_copy(const void *aBlock); - @interface TestObject : NSObject { @public int refcount; From isanbard at gmail.com Tue Aug 10 06:08:19 2010 From: isanbard at gmail.com (Bill Wendling) Date: Tue, 10 Aug 2010 11:08:19 -0000 Subject: [llvm-commits] [llvm-gcc-4.2] r110669 - in /llvm-gcc-4.2/trunk/gcc/testsuite/gcc.apple: block-blocks-test-8.c block-copy-attrib-err.c block-copy-destroy.c block-encoding.c uninit-test-1.c Message-ID: <20100810110819.D0E3D2A6C12C@llvm.org> Author: void Date: Tue Aug 10 06:08:19 2010 New Revision: 110669 URL: http://llvm.org/viewvc/llvm-project?rev=110669&view=rev Log: Add darwin x86_64 to options list. Modified: llvm-gcc-4.2/trunk/gcc/testsuite/gcc.apple/block-blocks-test-8.c llvm-gcc-4.2/trunk/gcc/testsuite/gcc.apple/block-copy-attrib-err.c llvm-gcc-4.2/trunk/gcc/testsuite/gcc.apple/block-copy-destroy.c llvm-gcc-4.2/trunk/gcc/testsuite/gcc.apple/block-encoding.c llvm-gcc-4.2/trunk/gcc/testsuite/gcc.apple/uninit-test-1.c Modified: llvm-gcc-4.2/trunk/gcc/testsuite/gcc.apple/block-blocks-test-8.c URL: http://llvm.org/viewvc/llvm-project/llvm-gcc-4.2/trunk/gcc/testsuite/gcc.apple/block-blocks-test-8.c?rev=110669&r1=110668&r2=110669&view=diff ============================================================================== --- llvm-gcc-4.2/trunk/gcc/testsuite/gcc.apple/block-blocks-test-8.c (original) +++ llvm-gcc-4.2/trunk/gcc/testsuite/gcc.apple/block-blocks-test-8.c Tue Aug 10 06:08:19 2010 @@ -1,7 +1,8 @@ /* APPLE LOCAL file radar 5932809 */ /* Test the __byreg runtime features. */ -/* { dg-options "-mmacosx-version-min=10.5 -ObjC -framework Foundation" { target i?86-*-darwin* } } */ -/* { dg-do run { target i?86-*-darwin* } } */ +/* LLVM LOCAL add x86_64 Darwin */ +/* { dg-options "-mmacosx-version-min=10.5 -ObjC -framework Foundation" { target i?86-*-darwin* x86_64-*-darwin* } } */ +/* { dg-do run { target i?86-*-darwin* x86_64-*-darwin* } } */ /* { dg-require-effective-target ilp32 } */ #import Modified: llvm-gcc-4.2/trunk/gcc/testsuite/gcc.apple/block-copy-attrib-err.c URL: http://llvm.org/viewvc/llvm-project/llvm-gcc-4.2/trunk/gcc/testsuite/gcc.apple/block-copy-attrib-err.c?rev=110669&r1=110668&r2=110669&view=diff ============================================================================== --- llvm-gcc-4.2/trunk/gcc/testsuite/gcc.apple/block-copy-attrib-err.c (original) +++ llvm-gcc-4.2/trunk/gcc/testsuite/gcc.apple/block-copy-attrib-err.c Tue Aug 10 06:08:19 2010 @@ -1,11 +1,12 @@ /* APPLE LOCAL file radar 6379842 - blocks */ /* { dg-do compile } */ -/* { dg-options "-ObjC -fblocks -m64 -fobjc-gc-only" { target powerpc*-*-darwin* i?86*-*-darwin* } } */ +/* LLVM LOCAL add x86_64 Darwin */ +/* { dg-options "-ObjC -fblocks -m64 -fobjc-gc-only" { target powerpc*-*-darwin* i?86*-*-darwin* x86_64-*-darwin* } } */ /* { dg-options "-ObjC -fblocks -fobjc-gc-only" {target arm*-*-darwin* } } */ @interface Thing {} - at property void(^someBlock)(void); /* { dg-warning "\\'copy\\' attribute must be specified for the block property" } */ + at property void(^someBlock)(void); /* { dg-warning "\\'copy\\' attribute must be specified for the block property" } */ @property(copy) void(^OK)(void); Modified: llvm-gcc-4.2/trunk/gcc/testsuite/gcc.apple/block-copy-destroy.c URL: http://llvm.org/viewvc/llvm-project/llvm-gcc-4.2/trunk/gcc/testsuite/gcc.apple/block-copy-destroy.c?rev=110669&r1=110668&r2=110669&view=diff ============================================================================== --- llvm-gcc-4.2/trunk/gcc/testsuite/gcc.apple/block-copy-destroy.c (original) +++ llvm-gcc-4.2/trunk/gcc/testsuite/gcc.apple/block-copy-destroy.c Tue Aug 10 06:08:19 2010 @@ -1,7 +1,7 @@ /* APPLE LOCAL file 5782740 - blocks */ /* Test generation of copy/destroy helper function. */ /* { dg-do compile } */ -/* { dg-options "-mmacosx-version-min=10.5 -ObjC -fblocks" { target powerpc*-*-darwin* i?86*-*-darwin* } } */ +/* { dg-options "-mmacosx-version-min=10.5 -ObjC -fblocks" { target powerpc*-*-darwin* i?86*-*-darwin* x86_64-*-darwin* } } */ /* { dg-options "-iphoneos-version-min=4.0 -ObjC -fblocks" { target arm*-*-darwin* } } */ #import Modified: llvm-gcc-4.2/trunk/gcc/testsuite/gcc.apple/block-encoding.c URL: http://llvm.org/viewvc/llvm-project/llvm-gcc-4.2/trunk/gcc/testsuite/gcc.apple/block-encoding.c?rev=110669&r1=110668&r2=110669&view=diff ============================================================================== --- llvm-gcc-4.2/trunk/gcc/testsuite/gcc.apple/block-encoding.c (original) +++ llvm-gcc-4.2/trunk/gcc/testsuite/gcc.apple/block-encoding.c Tue Aug 10 06:08:19 2010 @@ -1,7 +1,8 @@ /* APPLE LOCAL file radar 5849129 */ /* Test for encoding of a block pointer as '@'. */ /* { dg-do compile } */ -/* { dg-options "-mmacosx-version-min=10.5 -ObjC" { target powerpc*-*-darwin* i?86*-*-darwin* } } */ +/* LLVM LOCAL add x86_64 Darwin */ +/* { dg-options "-mmacosx-version-min=10.5 -ObjC" { target powerpc*-*-darwin* i?86*-*-darwin* x86_64-*-darwin* } } */ /* { dg-options "-iphoneos-version-min=4.0 -ObjC" { target arm*-*-darwin* } } */ #import Modified: llvm-gcc-4.2/trunk/gcc/testsuite/gcc.apple/uninit-test-1.c URL: http://llvm.org/viewvc/llvm-project/llvm-gcc-4.2/trunk/gcc/testsuite/gcc.apple/uninit-test-1.c?rev=110669&r1=110668&r2=110669&view=diff ============================================================================== --- llvm-gcc-4.2/trunk/gcc/testsuite/gcc.apple/uninit-test-1.c (original) +++ llvm-gcc-4.2/trunk/gcc/testsuite/gcc.apple/uninit-test-1.c Tue Aug 10 06:08:19 2010 @@ -1,6 +1,7 @@ /* Radar 4964532 */ /* { dg-do compile } */ -/* { dg-options "-O2 -gdwarf-2 -dA -mmacosx-version-min=10.4 -m32" { target powerpc*-*-darwin* i?86*-*-darwin* } } */ +/* LLVM LOCAL add x86_64 Darwin */ +/* { dg-options "-O2 -gdwarf-2 -dA -mmacosx-version-min=10.4 -m32" { target powerpc*-*-darwin* i?86*-*-darwin* x86_64-*-darwin* } } */ /* { dg-options "-O2 -gdwarf-2 -dA" { target arm*-*-darwin* } } */ /* { dg-final { scan-assembler "DW_OP_APPLE_uninit" } } */ #include From isanbard at gmail.com Tue Aug 10 06:09:16 2010 From: isanbard at gmail.com (Bill Wendling) Date: Tue, 10 Aug 2010 11:09:16 -0000 Subject: [llvm-commits] [llvm-gcc-4.2] r110670 - in /llvm-gcc-4.2/trunk/gcc/testsuite/gcc.apple: block-debug-1.c block-debug-2.c block-pointer.c debug-inlined-section.c Message-ID: <20100810110916.2D21F2A6C12C@llvm.org> Author: void Date: Tue Aug 10 06:09:15 2010 New Revision: 110670 URL: http://llvm.org/viewvc/llvm-project?rev=110670&view=rev Log: Add -fverbose-asm flag. Modified: llvm-gcc-4.2/trunk/gcc/testsuite/gcc.apple/block-debug-1.c llvm-gcc-4.2/trunk/gcc/testsuite/gcc.apple/block-debug-2.c llvm-gcc-4.2/trunk/gcc/testsuite/gcc.apple/block-pointer.c llvm-gcc-4.2/trunk/gcc/testsuite/gcc.apple/debug-inlined-section.c Modified: llvm-gcc-4.2/trunk/gcc/testsuite/gcc.apple/block-debug-1.c URL: http://llvm.org/viewvc/llvm-project/llvm-gcc-4.2/trunk/gcc/testsuite/gcc.apple/block-debug-1.c?rev=110670&r1=110669&r2=110670&view=diff ============================================================================== --- llvm-gcc-4.2/trunk/gcc/testsuite/gcc.apple/block-debug-1.c (original) +++ llvm-gcc-4.2/trunk/gcc/testsuite/gcc.apple/block-debug-1.c Tue Aug 10 06:09:15 2010 @@ -3,7 +3,8 @@ member that is a pointer to a block. */ /* { dg-do compile } */ -/* { dg-options "-g -O0 -fblocks -dA" } */ +/* LLVM LOCAL -fverbose-asm */ +/* { dg-options "-g -O0 -fblocks -dA -fverbose-asm" } */ /* { dg-final { scan-assembler "__block_descriptor.*DW_AT_name" } } */ /* { dg-final { scan-assembler "__block_literal_generic.*DW_AT_name" } } */ Modified: llvm-gcc-4.2/trunk/gcc/testsuite/gcc.apple/block-debug-2.c URL: http://llvm.org/viewvc/llvm-project/llvm-gcc-4.2/trunk/gcc/testsuite/gcc.apple/block-debug-2.c?rev=110670&r1=110669&r2=110670&view=diff ============================================================================== --- llvm-gcc-4.2/trunk/gcc/testsuite/gcc.apple/block-debug-2.c (original) +++ llvm-gcc-4.2/trunk/gcc/testsuite/gcc.apple/block-debug-2.c Tue Aug 10 06:09:15 2010 @@ -3,7 +3,8 @@ to a block. */ /* { dg-do compile } */ -/* { dg-options "-g -O0 -fblocks -dA" } */ +/* LLVM LOCAL -fverbose-asm */ +/* { dg-options "-g -O0 -fblocks -dA -fverbose-asm" } */ /* { dg-final { scan-assembler "__block_descriptor.*DW_AT_name" } } */ /* { dg-final { scan-assembler "__block_literal_generic.*DW_AT_name" } } */ Modified: llvm-gcc-4.2/trunk/gcc/testsuite/gcc.apple/block-pointer.c URL: http://llvm.org/viewvc/llvm-project/llvm-gcc-4.2/trunk/gcc/testsuite/gcc.apple/block-pointer.c?rev=110670&r1=110669&r2=110670&view=diff ============================================================================== --- llvm-gcc-4.2/trunk/gcc/testsuite/gcc.apple/block-pointer.c (original) +++ llvm-gcc-4.2/trunk/gcc/testsuite/gcc.apple/block-pointer.c Tue Aug 10 06:09:15 2010 @@ -1,6 +1,7 @@ /* APPLE LOCAL file - testcase for Radar 5811943 */ /* { dg-do compile } */ -/* { dg-options "-g -O0 -fblocks -dA" } */ +/* LLVM LOCAL -fverbose-asm */ +/* { dg-options "-g -O0 -fblocks -dA -fverbose-asm" } */ /* { dg-final { scan-assembler "DW_AT_APPLE_block" } } */ #include Modified: llvm-gcc-4.2/trunk/gcc/testsuite/gcc.apple/debug-inlined-section.c URL: http://llvm.org/viewvc/llvm-project/llvm-gcc-4.2/trunk/gcc/testsuite/gcc.apple/debug-inlined-section.c?rev=110670&r1=110669&r2=110670&view=diff ============================================================================== --- llvm-gcc-4.2/trunk/gcc/testsuite/gcc.apple/debug-inlined-section.c (original) +++ llvm-gcc-4.2/trunk/gcc/testsuite/gcc.apple/debug-inlined-section.c Tue Aug 10 06:09:15 2010 @@ -1,6 +1,7 @@ /* APPLE LOCAL file, Radar 6275985 */ /* { dg-do compile { target *-*-darwin* } } */ -/* { dg-options "-g -dA -save-temps -mmacosx-version-min=10.6" } */ +/* LLVM LOCAL -fverbose-asm */ +/* { dg-options "-g -dA -save-temps -mmacosx-version-min=10.6 -fverbose-asm" } */ /* { dg-final { scan-assembler "__debug_inlined" } } */ /* { dg-final { scan-assembler "\[#;@]\[ \t]+MIPS linkage name: \"getData\"" } } */ /* { dg-final { scan-assembler "\[#;@]\[ \t]+Function name: \"getData\"" } } */ From isanbard at gmail.com Tue Aug 10 06:09:39 2010 From: isanbard at gmail.com (Bill Wendling) Date: Tue, 10 Aug 2010 11:09:39 -0000 Subject: [llvm-commits] [llvm-gcc-4.2] r110671 - /llvm-gcc-4.2/trunk/gcc/testsuite/gcc.apple/block-5988451.c Message-ID: <20100810110939.D06632A6C12C@llvm.org> Author: void Date: Tue Aug 10 06:09:39 2010 New Revision: 110671 URL: http://llvm.org/viewvc/llvm-project?rev=110671&view=rev Log: Adjust testcase to match current apis. Modified: llvm-gcc-4.2/trunk/gcc/testsuite/gcc.apple/block-5988451.c Modified: llvm-gcc-4.2/trunk/gcc/testsuite/gcc.apple/block-5988451.c URL: http://llvm.org/viewvc/llvm-project/llvm-gcc-4.2/trunk/gcc/testsuite/gcc.apple/block-5988451.c?rev=110671&r1=110670&r2=110671&view=diff ============================================================================== --- llvm-gcc-4.2/trunk/gcc/testsuite/gcc.apple/block-5988451.c (original) +++ llvm-gcc-4.2/trunk/gcc/testsuite/gcc.apple/block-5988451.c Tue Aug 10 06:09:39 2010 @@ -6,17 +6,13 @@ typedef struct dispatch_queue_s *dispatch_queue_t; typedef struct dispatch_item_s *dispatch_item_t; -typedef void (^dispatch_block_t)(dispatch_item_t item); - void dispatch_call(dispatch_queue_t queue, - dispatch_block_t work, - dispatch_block_t completion, - void* context, - dispatch_item_t *item); - -void dispatch_apply_wait(dispatch_block_t work, - unsigned iterations, - void *context); + dispatch_legacy_block_t work, + dispatch_legacy_block_t completion); + +void dispatch_apply_wait(dispatch_legacy_block_t work, + unsigned iterations, + void *context); @@ -34,15 +30,14 @@ { dispatch_queue_t queue; - dispatch_call(queue, + dispatch_call(queue, /* { dg-warning "deprecated" } */ ^(dispatch_item_t item) { dispatch_apply_wait(^(dispatch_item_t item) { [NSValue valueWithPointer:self]; }, 10,NULL); }, - ^(dispatch_item_t item) {NSLog(@"test");}, - NULL, NULL); + ^(dispatch_item_t item) {NSLog(@"test");}); /* { dg-warning "deprecated" } */ } From isanbard at gmail.com Tue Aug 10 06:10:32 2010 From: isanbard at gmail.com (Bill Wendling) Date: Tue, 10 Aug 2010 11:10:32 -0000 Subject: [llvm-commits] [llvm-gcc-4.2] r110672 - /llvm-gcc-4.2/trunk/gcc/testsuite/gcc.apple/5490617.c Message-ID: <20100810111032.2EBC02A6C12C@llvm.org> Author: void Date: Tue Aug 10 06:10:32 2010 New Revision: 110672 URL: http://llvm.org/viewvc/llvm-project?rev=110672&view=rev Log: llvm emits the symbol into the bss section with a .zerofill directive. The symbol has the correct linkage and section via nm. Modified: llvm-gcc-4.2/trunk/gcc/testsuite/gcc.apple/5490617.c Modified: llvm-gcc-4.2/trunk/gcc/testsuite/gcc.apple/5490617.c URL: http://llvm.org/viewvc/llvm-project/llvm-gcc-4.2/trunk/gcc/testsuite/gcc.apple/5490617.c?rev=110672&r1=110671&r2=110672&view=diff ============================================================================== --- llvm-gcc-4.2/trunk/gcc/testsuite/gcc.apple/5490617.c (original) +++ llvm-gcc-4.2/trunk/gcc/testsuite/gcc.apple/5490617.c Tue Aug 10 06:10:32 2010 @@ -4,4 +4,4 @@ char *my_endbss_static = _my_endbss; /* LLVM LOCAL allow different spacing */ -/* { dg-final { scan-assembler ".lcomm( |\t)__my_endbss" } } */ +/* { dg-final { scan-assembler ".zerofill\[ \t]+__DATA,__bss,__my_endbss" } } */ From grosser at fim.uni-passau.de Tue Aug 10 06:10:51 2010 From: grosser at fim.uni-passau.de (Tobias Grosser) Date: Tue, 10 Aug 2010 13:10:51 +0200 Subject: [llvm-commits] [llvm] r110664 - /llvm/trunk/test/CodeGen/X86/2010-08-10-DbgConstant.ll In-Reply-To: <355_1281434179_4C612243_355_31249_1_20100810095429.E5F462A6C12C@llvm.org> References: <355_1281434179_4C612243_355_31249_1_20100810095429.E5F462A6C12C@llvm.org> Message-ID: <4C6133BB.4010106@fim.uni-passau.de> On 08/10/2010 11:54 AM, Tobias Grosser wrote: > Author: grosser > Date: Tue Aug 10 04:54:29 2010 > New Revision: 110664 > > URL: http://llvm.org/viewvc/llvm-project?rev=110664&view=rev > Log: > Fix failing testcase. > > Those look like typos to me. I was wrong. Now just different builders fail. There are some architectures that generate ## DW_AT_NAME and others that generate # DW_AT_NAME A patch that would accept both is attached. However I am not sure, if it is correct. @Devang: Could you check this. Tobi -------------- next part -------------- A non-text attachment was scrubbed... Name: 0001-Fix-test-case-finally.patch Type: text/x-diff Size: 869 bytes Desc: not available Url : http://lists.cs.uiuc.edu/pipermail/llvm-commits/attachments/20100810/fa6a6ffd/attachment.bin From isanbard at gmail.com Tue Aug 10 06:11:17 2010 From: isanbard at gmail.com (Bill Wendling) Date: Tue, 10 Aug 2010 11:11:17 -0000 Subject: [llvm-commits] [llvm-gcc-4.2] r110673 - in /llvm-gcc-4.2/trunk/gcc/testsuite/gcc.apple: 5597292.c block-stabs.c i386-nodebug-attr.c Message-ID: <20100810111117.5F6492A6C12C@llvm.org> Author: void Date: Tue Aug 10 06:11:17 2010 New Revision: 110673 URL: http://llvm.org/viewvc/llvm-project?rev=110673&view=rev Log: Disable: no stabs. Modified: llvm-gcc-4.2/trunk/gcc/testsuite/gcc.apple/5597292.c llvm-gcc-4.2/trunk/gcc/testsuite/gcc.apple/block-stabs.c llvm-gcc-4.2/trunk/gcc/testsuite/gcc.apple/i386-nodebug-attr.c Modified: llvm-gcc-4.2/trunk/gcc/testsuite/gcc.apple/5597292.c URL: http://llvm.org/viewvc/llvm-project/llvm-gcc-4.2/trunk/gcc/testsuite/gcc.apple/5597292.c?rev=110673&r1=110672&r2=110673&view=diff ============================================================================== --- llvm-gcc-4.2/trunk/gcc/testsuite/gcc.apple/5597292.c (original) +++ llvm-gcc-4.2/trunk/gcc/testsuite/gcc.apple/5597292.c Tue Aug 10 06:11:17 2010 @@ -1,6 +1,8 @@ /* APPLE LOCAL file 5597292 */ /* { dg-do compile } */ /* { dg-options "-static -O0 -gstabs+" } */ +/* LLVM LOCAL test not applicable (no stabs) */ +/* { dg-require-fdump "" } */ void * foo(unsigned int size) { union { Modified: llvm-gcc-4.2/trunk/gcc/testsuite/gcc.apple/block-stabs.c URL: http://llvm.org/viewvc/llvm-project/llvm-gcc-4.2/trunk/gcc/testsuite/gcc.apple/block-stabs.c?rev=110673&r1=110672&r2=110673&view=diff ============================================================================== --- llvm-gcc-4.2/trunk/gcc/testsuite/gcc.apple/block-stabs.c (original) +++ llvm-gcc-4.2/trunk/gcc/testsuite/gcc.apple/block-stabs.c Tue Aug 10 06:11:17 2010 @@ -1,6 +1,8 @@ /* APPLE LOCAL file blocks stabs 6034272 */ /* { dg-do compile } */ /* { dg-options "-gstabs" } */ +/* LLVM LOCAL test not applicable (no stabs) */ +/* { dg-require-fdump "" } */ void foo() { void (^x)(void) = ^{ foo(); }; Modified: llvm-gcc-4.2/trunk/gcc/testsuite/gcc.apple/i386-nodebug-attr.c URL: http://llvm.org/viewvc/llvm-project/llvm-gcc-4.2/trunk/gcc/testsuite/gcc.apple/i386-nodebug-attr.c?rev=110673&r1=110672&r2=110673&view=diff ============================================================================== --- llvm-gcc-4.2/trunk/gcc/testsuite/gcc.apple/i386-nodebug-attr.c (original) +++ llvm-gcc-4.2/trunk/gcc/testsuite/gcc.apple/i386-nodebug-attr.c Tue Aug 10 06:11:17 2010 @@ -1,6 +1,8 @@ /* APPLE LOCAL begin radar 4152603 */ /* { dg-do compile { target i?86-*-* x86_64-*-* } } */ /* { dg-options "-gstabs+ -gused -msse2" } */ +/* LLVM LOCAL test not applicable (no stabs) */ +/* { dg-require-fdump "" } */ /* Test that no header file information for xmmintrin.h is generated. */ #include "xmmintrin.h" From isanbard at gmail.com Tue Aug 10 06:11:52 2010 From: isanbard at gmail.com (Bill Wendling) Date: Tue, 10 Aug 2010 11:11:52 -0000 Subject: [llvm-commits] [llvm-gcc-4.2] r110674 - in /llvm-gcc-4.2/trunk/gcc/testsuite/gcc.c-torture/compile: 20050122-2.c 920415-1.c pr21728.c Message-ID: <20100810111152.704F02A6C12C@llvm.org> Author: void Date: Tue Aug 10 06:11:52 2010 New Revision: 110674 URL: http://llvm.org/viewvc/llvm-project?rev=110674&view=rev Log: Disable: no nested functions. Modified: llvm-gcc-4.2/trunk/gcc/testsuite/gcc.c-torture/compile/20050122-2.c llvm-gcc-4.2/trunk/gcc/testsuite/gcc.c-torture/compile/920415-1.c llvm-gcc-4.2/trunk/gcc/testsuite/gcc.c-torture/compile/pr21728.c Modified: llvm-gcc-4.2/trunk/gcc/testsuite/gcc.c-torture/compile/20050122-2.c URL: http://llvm.org/viewvc/llvm-project/llvm-gcc-4.2/trunk/gcc/testsuite/gcc.c-torture/compile/20050122-2.c?rev=110674&r1=110673&r2=110674&view=diff ============================================================================== --- llvm-gcc-4.2/trunk/gcc/testsuite/gcc.c-torture/compile/20050122-2.c (original) +++ llvm-gcc-4.2/trunk/gcc/testsuite/gcc.c-torture/compile/20050122-2.c Tue Aug 10 06:11:52 2010 @@ -1,5 +1,7 @@ /* APPLE LOCAL testsuite nested functions */ /* { dg-options "-fnested-functions" } */ +/* LLVM LOCAL no nested functions */ +/* { dg-require-fdump "" } */ /* Related to PR 19484. */ extern void foo (void) __attribute__((noreturn)); int n; Modified: llvm-gcc-4.2/trunk/gcc/testsuite/gcc.c-torture/compile/920415-1.c URL: http://llvm.org/viewvc/llvm-project/llvm-gcc-4.2/trunk/gcc/testsuite/gcc.c-torture/compile/920415-1.c?rev=110674&r1=110673&r2=110674&view=diff ============================================================================== --- llvm-gcc-4.2/trunk/gcc/testsuite/gcc.c-torture/compile/920415-1.c (original) +++ llvm-gcc-4.2/trunk/gcc/testsuite/gcc.c-torture/compile/920415-1.c Tue Aug 10 06:11:52 2010 @@ -1,8 +1,8 @@ /* APPLE LOCAL begin testsuite nested functions */ /* { dg-options "-fnested-functions" } */ /* APPLE LOCAL end testsuite nested functions */ -/* LLVM LOCAL 8251263 */ -/* { dg-xfail-if "" { *-*-darwin* } { "*" } { "" } } */ +/* LLVM LOCAL no nested functions 8251263 */ +/* { dg-require-fdump "" } */ extern void abort (void); extern void exit (int); Modified: llvm-gcc-4.2/trunk/gcc/testsuite/gcc.c-torture/compile/pr21728.c URL: http://llvm.org/viewvc/llvm-project/llvm-gcc-4.2/trunk/gcc/testsuite/gcc.c-torture/compile/pr21728.c?rev=110674&r1=110673&r2=110674&view=diff ============================================================================== --- llvm-gcc-4.2/trunk/gcc/testsuite/gcc.c-torture/compile/pr21728.c (original) +++ llvm-gcc-4.2/trunk/gcc/testsuite/gcc.c-torture/compile/pr21728.c Tue Aug 10 06:11:52 2010 @@ -1,5 +1,7 @@ /* APPLE LOCAL testsuite nested functions */ /* { dg-options "-fnested-functions" } */ +/* LLVM LOCAL no nested functions */ +/* { dg-require-fdump "" } */ int main (void) { __label__ l1; From isanbard at gmail.com Tue Aug 10 06:12:10 2010 From: isanbard at gmail.com (Bill Wendling) Date: Tue, 10 Aug 2010 11:12:10 -0000 Subject: [llvm-commits] [llvm-gcc-4.2] r110675 - /llvm-gcc-4.2/trunk/gcc/testsuite/gcc.apple/block-blocks-test-1.c Message-ID: <20100810111210.441352A6C12C@llvm.org> Author: void Date: Tue Aug 10 06:12:10 2010 New Revision: 110675 URL: http://llvm.org/viewvc/llvm-project?rev=110675&view=rev Log: Warnings are now errors. Modified: llvm-gcc-4.2/trunk/gcc/testsuite/gcc.apple/block-blocks-test-1.c Modified: llvm-gcc-4.2/trunk/gcc/testsuite/gcc.apple/block-blocks-test-1.c URL: http://llvm.org/viewvc/llvm-project/llvm-gcc-4.2/trunk/gcc/testsuite/gcc.apple/block-blocks-test-1.c?rev=110675&r1=110674&r2=110675&view=diff ============================================================================== --- llvm-gcc-4.2/trunk/gcc/testsuite/gcc.apple/block-blocks-test-1.c (original) +++ llvm-gcc-4.2/trunk/gcc/testsuite/gcc.apple/block-blocks-test-1.c Tue Aug 10 06:12:10 2010 @@ -2,14 +2,14 @@ /* { dg-options "-fblocks" } */ /* { dg-do compile } */ -__block int X; /* { dg-warning "__block attribute is only allowed on local variables - ignored" } */ +__block int X; /* { dg-error "__block attribute on \\'X\\' not allowed, only allowed on local variables" } */ -int foo(__block int param) { /* { dg-warning "__block attribute can be specified on variables only - ignored" } */ +int foo(__block int param) { /* { dg-error "__block attribute can be specified on variables only" } */ __block int OK = 1; - extern __block double extern_var; /* { dg-warning "__block attribute is only allowed on local variables - ignored" } */ + extern __block double extern_var; /* { dg-error "__block attribute on \\'extern_var\\' not allowed, only allowed on local variables" } */ if (X) { - static __block char * pch; /* { dg-warning "__block attribute is only allowed on local variables - ignored" } */ + static __block char * pch; /* { dg-error "__block attribute on \\'pch\\' not allowed, only allowed on local variables" } */ } return OK - 1; } From xerxes at zafena.se Tue Aug 10 07:33:48 2010 From: xerxes at zafena.se (=?ISO-8859-1?Q?Xerxes_R=E5nby?=) Date: Tue, 10 Aug 2010 14:33:48 +0200 Subject: [llvm-commits] [patch] pr7852 - Make LLVM robust to #define ARCH pollution by removing fragile macros. In-Reply-To: <4C612DB4.9050908@zafena.se> References: <4C612DB4.9050908@zafena.se> Message-ID: <4C61472C.3010205@zafena.se> On 2010-08-10 12:45, Xerxes R?nby wrote: > patch: http://llvm.org/bugs/attachment.cgi?id=5357 > > Remove use of fragile macros to define native target init function names in > include/llvm/Target/TargetSelect.h and llvm/include/llvm-c/Target.h > > Instead of using macros the native target init function names are > resolved at config.h generation time by setting three new defines. > /* LLVM name for the native Target init function, if available */ > #cmakedefine LLVM_NATIVE_TARGET LLVMInitialize${LLVM_NATIVE_ARCH}Target > > /* LLVM name for the native TargetInfo init function, if available */ > #cmakedefine LLVM_NATIVE_TARGETINFO > LLVMInitialize${LLVM_NATIVE_ARCH}TargetInfo > > /* LLVM name for the native AsmPrinter init function, if available */ > #cmakedefine LLVM_NATIVE_ASMPRINTER > LLVMInitialize${LLVM_NATIVE_ARCH}AsmPrinter > > Updated include/llvm/Target/TargetSelect.h and > llvm/include/llvm-c/Target.h use the new defines. > > Changed LLVM_NATIVE_ARCH define to actually contain the > ${LLVM_NATIVE_ARCH} value. > > I have tested this patch using cmake and configure. > I need help regenerating the configure using autotools 2.60 since i have > changed autoconf/configure.ac. > > Cheers > Xerxes > Updated patch to include changes to llvm/cmake/config-ix.cmake LLVM_NATIVE_ARCHNAME are removed since it got replaced by LLVM_NATIVE_ARCH. Cheers Xerxes -------------- next part -------------- A non-text attachment was scrubbed... Name: 10aug-v4-llvm-config-no-arch-macro.patch Type: text/x-patch Size: 8431 bytes Desc: not available Url : http://lists.cs.uiuc.edu/pipermail/llvm-commits/attachments/20100810/d17302f0/attachment.bin From foldr at codedgers.com Tue Aug 10 09:49:17 2010 From: foldr at codedgers.com (Mikhail Glushenkov) Date: Tue, 10 Aug 2010 16:49:17 +0200 Subject: [llvm-commits] [Patch Proposal] Makefile.rules: Simplify generating LLVMC_BUILTIN_PLUGIN In-Reply-To: References: Message-ID: <20100810144917.GA2760@localhost.localdomain> Hi, On Tue, Aug 10, 2010 at 01:18:31AM +0900, NAKAMURA Takumi wrote: > Mikhail, > > Please take a look onto it. > Thank you in advance. > > ...Takumi I've applied your patch, but I'm currently removing dynamic plugins from llvmc, so all of the -DBUILTIN_LLVMC_PLUGIN stuff will be gone soon. Thanks anyway! -- () ascii ribbon campaign - against html e-mail /\ www.asciiribbon.org - against proprietary attachments From foldr at codedgers.com Tue Aug 10 09:49:25 2010 From: foldr at codedgers.com (Mikhail Glushenkov) Date: Tue, 10 Aug 2010 14:49:25 -0000 Subject: [llvm-commits] [llvm] r110679 - /llvm/trunk/include/llvm/Support/CommandLine.h Message-ID: <20100810144925.262B52A6C12C@llvm.org> Author: foldr Date: Tue Aug 10 09:49:24 2010 New Revision: 110679 URL: http://llvm.org/viewvc/llvm-project?rev=110679&view=rev Log: Trailing whitespace. Modified: llvm/trunk/include/llvm/Support/CommandLine.h Modified: llvm/trunk/include/llvm/Support/CommandLine.h URL: http://llvm.org/viewvc/llvm-project/llvm/trunk/include/llvm/Support/CommandLine.h?rev=110679&r1=110678&r2=110679&view=diff ============================================================================== --- llvm/trunk/include/llvm/Support/CommandLine.h (original) +++ llvm/trunk/include/llvm/Support/CommandLine.h Tue Aug 10 09:49:24 2010 @@ -31,7 +31,7 @@ #include namespace llvm { - + /// cl Namespace - This namespace contains all of the command line option /// processing machinery. It is intentionally a short name to make qualified /// usage concise. @@ -788,7 +788,7 @@ DataType &getValue() { check(); return *Location; } const DataType &getValue() const { check(); return *Location; } - + operator DataType() const { return this->getValue(); } }; From foldr at codedgers.com Tue Aug 10 09:49:29 2010 From: foldr at codedgers.com (Mikhail Glushenkov) Date: Tue, 10 Aug 2010 14:49:29 -0000 Subject: [llvm-commits] [llvm] r110680 - /llvm/trunk/Makefile.rules Message-ID: <20100810144929.705102A6C12D@llvm.org> Author: foldr Date: Tue Aug 10 09:49:29 2010 New Revision: 110680 URL: http://llvm.org/viewvc/llvm-project?rev=110680&view=rev Log: Simplify generating LLVMC_BUILTIN_PLUGIN. Patch by NAKAMURA Takumi! Modified: llvm/trunk/Makefile.rules Modified: llvm/trunk/Makefile.rules URL: http://llvm.org/viewvc/llvm-project/llvm/trunk/Makefile.rules?rev=110680&r1=110679&r2=110680&view=diff ============================================================================== --- llvm/trunk/Makefile.rules (original) +++ llvm/trunk/Makefile.rules Tue Aug 10 09:49:29 2010 @@ -238,58 +238,13 @@ USEDLIBS += $(patsubst %,plugin_llvmc_%.a,$(LLVMC_BUILTIN_PLUGINS)) -LLVMC_BUILTIN_PLUGIN_1 = $(word 1, $(LLVMC_BUILTIN_PLUGINS)) -LLVMC_BUILTIN_PLUGIN_2 = $(word 2, $(LLVMC_BUILTIN_PLUGINS)) -LLVMC_BUILTIN_PLUGIN_3 = $(word 3, $(LLVMC_BUILTIN_PLUGINS)) -LLVMC_BUILTIN_PLUGIN_4 = $(word 4, $(LLVMC_BUILTIN_PLUGINS)) -LLVMC_BUILTIN_PLUGIN_5 = $(word 5, $(LLVMC_BUILTIN_PLUGINS)) -LLVMC_BUILTIN_PLUGIN_6 = $(word 6, $(LLVMC_BUILTIN_PLUGINS)) -LLVMC_BUILTIN_PLUGIN_7 = $(word 7, $(LLVMC_BUILTIN_PLUGINS)) -LLVMC_BUILTIN_PLUGIN_8 = $(word 8, $(LLVMC_BUILTIN_PLUGINS)) -LLVMC_BUILTIN_PLUGIN_9 = $(word 9, $(LLVMC_BUILTIN_PLUGINS)) -LLVMC_BUILTIN_PLUGIN_10 = $(word 10, $(LLVMC_BUILTIN_PLUGINS)) - - -ifneq ($(LLVMC_BUILTIN_PLUGIN_1),) -CPP.Flags += -DLLVMC_BUILTIN_PLUGIN_1=$(LLVMC_BUILTIN_PLUGIN_1) -endif - -ifneq ($(LLVMC_BUILTIN_PLUGIN_2),) -CPP.Flags += -DLLVMC_BUILTIN_PLUGIN_2=$(LLVMC_BUILTIN_PLUGIN_2) -endif - -ifneq ($(LLVMC_BUILTIN_PLUGIN_3),) -CPP.Flags += -DLLVMC_BUILTIN_PLUGIN_3=$(LLVMC_BUILTIN_PLUGIN_3) -endif - -ifneq ($(LLVMC_BUILTIN_PLUGIN_4),) -CPP.Flags += -DLLVMC_BUILTIN_PLUGIN_4=$(LLVMC_BUILTIN_PLUGIN_4) -endif - -ifneq ($(LLVMC_BUILTIN_PLUGIN_5),) -CPP.Flags += -DLLVMC_BUILTIN_PLUGIN_5=$(LLVMC_BUILTIN_PLUGIN_5) -endif - -ifneq ($(LLVMC_BUILTIN_PLUGIN_6),) -CPP.Flags += -DLLVMC_BUILTIN_PLUGIN_5=$(LLVMC_BUILTIN_PLUGIN_6) -endif - -ifneq ($(LLVMC_BUILTIN_PLUGIN_7),) -CPP.Flags += -DLLVMC_BUILTIN_PLUGIN_5=$(LLVMC_BUILTIN_PLUGIN_7) -endif - -ifneq ($(LLVMC_BUILTIN_PLUGIN_8),) -CPP.Flags += -DLLVMC_BUILTIN_PLUGIN_5=$(LLVMC_BUILTIN_PLUGIN_8) -endif - -ifneq ($(LLVMC_BUILTIN_PLUGIN_9),) -CPP.Flags += -DLLVMC_BUILTIN_PLUGIN_5=$(LLVMC_BUILTIN_PLUGIN_9) -endif - -ifneq ($(LLVMC_BUILTIN_PLUGIN_10),) -CPP.Flags += -DLLVMC_BUILTIN_PLUGIN_5=$(LLVMC_BUILTIN_PLUGIN_10) -endif - +LLVMC_BUILTIN_PLUGINS.pre := \ + $(patsubst %,-DLLVMC_BUILTIN_PLUGIN_%=, \ + 1 2 3 4 5 6 7 8 9 10) + +CPP.Flags += \ + $(filter-out $(LLVMC_BUILTIN_PLUGINS.pre) $(LLVMC_BUILTIN_PLUGINS), \ + $(join $(LLVMC_BUILTIN_PLUGINS.pre), $(LLVMC_BUILTIN_PLUGINS))) endif From espindola at google.com Tue Aug 10 09:50:57 2010 From: espindola at google.com (Rafael Espindola) Date: Tue, 10 Aug 2010 10:50:57 -0400 Subject: [llvm-commits] [patch] Don't link as many parts of llvm into bugpoint In-Reply-To: <4C61066E.2010704@fim.uni-passau.de> References: <355_1281407631_4C60BA8F_355_28788_1_AANLkTinq+w9vAvjdqF7dusNkoR55xHL8OgdM66rRxM7g@mail.gmail.com> <4C61066E.2010704@fim.uni-passau.de> Message-ID: > Just from my point of view I love to be able to use the same command > line for opt and bugpoint. If opt fails with a bug I just replace "opt" > with "bugpoint" in the command line. > As I sometimes use the -std-compile-opts flag, it would be inconvenient > to have to replace it manually. Maybe there is an easy way to get the > -std-compile-opts support back without having to link to all those other > libraries? I think I can refactor things so that it is possible to just get a pass list without linking in the code for all those passes. How to get a list of all passes that are available is a bit harder. My current idea is to just run opt and ask it to print it. > By the way, bugpoint always gives me an error if I leave the "-o" option > in the command line. It would be nice if it could just ignore it with a > warning. Like this I really just need to replace "opt" with "bugpoint". I see. I have normally used bugpoint for some very strange problems (bootstrap being broken) so I usually didn't care to much about the interface. I will try to keep the current one. > Thanks for you ongoing great work on bugpoint. > > Tobi Cheers, -- Rafael ?vila de Esp?ndola From daniel at zuster.org Tue Aug 10 10:19:37 2010 From: daniel at zuster.org (Daniel Dunbar) Date: Tue, 10 Aug 2010 08:19:37 -0700 Subject: [llvm-commits] [llvm] r110575 - /llvm/trunk/lib/MC/MachObjectWriter.cpp In-Reply-To: <20100809152805.F2B872A6C12C@llvm.org> References: <20100809152805.F2B872A6C12C@llvm.org> Message-ID: Hi Michael, On Mon, Aug 9, 2010 at 8:28 AM, Michael J. Spencer wrote: > Author: mspencer > Date: Mon Aug ?9 10:28:05 2010 > New Revision: 110575 > > URL: http://llvm.org/viewvc/llvm-project?rev=110575&view=rev > Log: > MC/MachO: Fix possible null pointer dereference. This isn't right, there is no possible null pointer dereference (it is implied by the absolute check). Please drop this condition, the code made more sense before. - Daniel > Discovered by Microsoft Visual Studio 2010 Code Analysis. > > Modified: > ? ?llvm/trunk/lib/MC/MachObjectWriter.cpp > > Modified: llvm/trunk/lib/MC/MachObjectWriter.cpp > URL: http://llvm.org/viewvc/llvm-project/llvm/trunk/lib/MC/MachObjectWriter.cpp?rev=110575&r1=110574&r2=110575&view=diff > ============================================================================== > --- llvm/trunk/lib/MC/MachObjectWriter.cpp (original) > +++ llvm/trunk/lib/MC/MachObjectWriter.cpp Mon Aug ?9 10:28:05 2010 > @@ -835,7 +835,7 @@ > ? ? ? // FIXME: Currently, these are never generated (see code below). I cannot > ? ? ? // find a case where they are actually emitted. > ? ? ? Type = RIT_Vanilla; > - ? ?} else { > + ? ?} else if (SD) { > ? ? ? // Check whether we need an external or internal relocation. > ? ? ? if (doesSymbolRequireExternRelocation(SD)) { > ? ? ? ? IsExtern = 1; > > > _______________________________________________ > llvm-commits mailing list > llvm-commits at cs.uiuc.edu > http://lists.cs.uiuc.edu/mailman/listinfo/llvm-commits > From rafael.espindola at gmail.com Tue Aug 10 10:46:11 2010 From: rafael.espindola at gmail.com (Rafael Espindola) Date: Tue, 10 Aug 2010 15:46:11 -0000 Subject: [llvm-commits] [llvm] r110682 - in /llvm/trunk/tools/bugpoint: BugDriver.h CrashDebugger.cpp ExtractFunction.cpp Message-ID: <20100810154611.BD5072A6C12C@llvm.org> Author: rafael Date: Tue Aug 10 10:46:11 2010 New Revision: 110682 URL: http://llvm.org/viewvc/llvm-project?rev=110682&view=rev Log: Use RunPassesOn as in the rest of bugpoint. Modified: llvm/trunk/tools/bugpoint/BugDriver.h llvm/trunk/tools/bugpoint/CrashDebugger.cpp llvm/trunk/tools/bugpoint/ExtractFunction.cpp Modified: llvm/trunk/tools/bugpoint/BugDriver.h URL: http://llvm.org/viewvc/llvm-project/llvm/trunk/tools/bugpoint/BugDriver.h?rev=110682&r1=110681&r2=110682&view=diff ============================================================================== --- llvm/trunk/tools/bugpoint/BugDriver.h (original) +++ llvm/trunk/tools/bugpoint/BugDriver.h Tue Aug 10 10:46:11 2010 @@ -214,8 +214,7 @@ /// series of cleanup passes (ADCE and SimplifyCFG) to eliminate any code /// which depends on the value. The modified module is then returned. /// - Module *deleteInstructionFromProgram(const Instruction *I, unsigned Simp) - const; + Module *deleteInstructionFromProgram(const Instruction *I, unsigned Simp); /// performFinalCleanups - This method clones the current Program and performs /// a series of cleanups intended to get rid of extra cruft on the module. If Modified: llvm/trunk/tools/bugpoint/CrashDebugger.cpp URL: http://llvm.org/viewvc/llvm-project/llvm/trunk/tools/bugpoint/CrashDebugger.cpp?rev=110682&r1=110681&r2=110682&view=diff ============================================================================== --- llvm/trunk/tools/bugpoint/CrashDebugger.cpp (original) +++ llvm/trunk/tools/bugpoint/CrashDebugger.cpp Tue Aug 10 10:46:11 2010 @@ -312,17 +312,24 @@ // a "persistent mapping" by turning basic blocks into pairs. // This won't work well if blocks are unnamed, but that is just the risk we // have to take. - std::vector > BlockInfo; + std::vector > BlockInfo; for (SmallPtrSet::iterator I = Blocks.begin(), E = Blocks.end(); I != E; ++I) - BlockInfo.push_back(std::make_pair((*I)->getParent(), (*I)->getName())); + BlockInfo.push_back(std::make_pair((*I)->getParent()->getName(), + (*I)->getName())); // Now run the CFG simplify pass on the function... - PassManager Passes; - Passes.add(createCFGSimplificationPass()); - Passes.add(createVerifierPass()); - Passes.run(*M); + std::vector Passes; + Passes.push_back("simplifycfg"); + Passes.push_back("verify"); + Module *New = BD.runPassesOn(M, Passes); + delete M; + if (!New) { + errs() << "simplifycfg failed!\n"; + exit(1); + } + M = New; // Try running on the hacked up program... if (TestFn(BD, M)) { @@ -331,8 +338,10 @@ // Make sure to use basic block pointers that point into the now-current // module, and that they don't include any deleted blocks. BBs.clear(); + const ValueSymbolTable &GST = M->getValueSymbolTable(); for (unsigned i = 0, e = BlockInfo.size(); i != e; ++i) { - ValueSymbolTable &ST = BlockInfo[i].first->getValueSymbolTable(); + Function *F = cast(GST.lookup(BlockInfo[i].first)); + ValueSymbolTable &ST = F->getValueSymbolTable(); Value* V = ST.lookup(BlockInfo[i].second); if (V && V->getType() == Type::getLabelTy(V->getContext())) BBs.push_back(cast(V)); Modified: llvm/trunk/tools/bugpoint/ExtractFunction.cpp URL: http://llvm.org/viewvc/llvm-project/llvm/trunk/tools/bugpoint/ExtractFunction.cpp?rev=110682&r1=110681&r2=110682&view=diff ============================================================================== --- llvm/trunk/tools/bugpoint/ExtractFunction.cpp (original) +++ llvm/trunk/tools/bugpoint/ExtractFunction.cpp Tue Aug 10 10:46:11 2010 @@ -55,13 +55,14 @@ /// depends on the value. The modified module is then returned. /// Module *BugDriver::deleteInstructionFromProgram(const Instruction *I, - unsigned Simplification) const { - Module *Result = CloneModule(Program); + unsigned Simplification) { + // FIXME, use vmap? + Module *Clone = CloneModule(Program); const BasicBlock *PBB = I->getParent(); const Function *PF = PBB->getParent(); - Module::iterator RFI = Result->begin(); // Get iterator to corresponding fn + Module::iterator RFI = Clone->begin(); // Get iterator to corresponding fn std::advance(RFI, std::distance(PF->getParent()->begin(), Module::const_iterator(PF))); @@ -79,24 +80,23 @@ // Remove the instruction from the program. TheInst->getParent()->getInstList().erase(TheInst); - - //writeProgramToFile("current.bc", Result); - // Spiff up the output a little bit. - PassManager Passes; - // Make sure that the appropriate target data is always used... - Passes.add(new TargetData(Result)); + std::vector Passes; - /// FIXME: If this used runPasses() like the methods below, we could get rid - /// of the -disable-* options! + /// Can we get rid of the -disable-* options? if (Simplification > 1 && !NoDCE) - Passes.add(createDeadCodeEliminationPass()); + Passes.push_back("dce"); if (Simplification && !DisableSimplifyCFG) - Passes.add(createCFGSimplificationPass()); // Delete dead control flow + Passes.push_back("simplifycfg"); // Delete dead control flow - Passes.add(createVerifierPass()); - Passes.run(*Result); - return Result; + Passes.push_back("verify"); + Module *New = runPassesOn(Clone, Passes); + delete Clone; + if (!New) { + errs() << "Instruction removal failed. Sorry. :( Please report a bug!\n"; + exit(1); + } + return New; } /// performFinalCleanups - This method clones the current Program and performs From bigcheesegs at gmail.com Tue Aug 10 11:00:50 2010 From: bigcheesegs at gmail.com (Michael J. Spencer) Date: Tue, 10 Aug 2010 16:00:50 -0000 Subject: [llvm-commits] [llvm] r110683 - /llvm/trunk/lib/MC/MachObjectWriter.cpp Message-ID: <20100810160050.0F88F2A6C12C@llvm.org> Author: mspencer Date: Tue Aug 10 11:00:49 2010 New Revision: 110683 URL: http://llvm.org/viewvc/llvm-project?rev=110683&view=rev Log: Revert "MC/MachO: Fix possible null pointer dereference." This reverts commit 110575. Target.isAbsolute() is true if SD would be null. Modified: llvm/trunk/lib/MC/MachObjectWriter.cpp Modified: llvm/trunk/lib/MC/MachObjectWriter.cpp URL: http://llvm.org/viewvc/llvm-project/llvm/trunk/lib/MC/MachObjectWriter.cpp?rev=110683&r1=110682&r2=110683&view=diff ============================================================================== --- llvm/trunk/lib/MC/MachObjectWriter.cpp (original) +++ llvm/trunk/lib/MC/MachObjectWriter.cpp Tue Aug 10 11:00:49 2010 @@ -835,7 +835,7 @@ // FIXME: Currently, these are never generated (see code below). I cannot // find a case where they are actually emitted. Type = RIT_Vanilla; - } else if (SD) { + } else { // Check whether we need an external or internal relocation. if (doesSymbolRequireExternRelocation(SD)) { IsExtern = 1; From bigcheesegs at gmail.com Tue Aug 10 11:03:37 2010 From: bigcheesegs at gmail.com (Michael Spencer) Date: Tue, 10 Aug 2010 12:03:37 -0400 Subject: [llvm-commits] [llvm] r110575 - /llvm/trunk/lib/MC/MachObjectWriter.cpp In-Reply-To: References: <20100809152805.F2B872A6C12C@llvm.org> Message-ID: On Tue, Aug 10, 2010 at 11:19 AM, Daniel Dunbar wrote: > Hi Michael, > > On Mon, Aug 9, 2010 at 8:28 AM, Michael J. Spencer > wrote: >> Author: mspencer >> Date: Mon Aug ?9 10:28:05 2010 >> New Revision: 110575 >> >> URL: http://llvm.org/viewvc/llvm-project?rev=110575&view=rev >> Log: >> MC/MachO: Fix possible null pointer dereference. > > This isn't right, there is no possible null pointer dereference (it is > implied by the absolute check). Please drop this condition, the code > made more sense before. > > ?- Daniel Sorry about that. I should have checked isAbsolute(). Reverted in 110683. >> Discovered by Microsoft Visual Studio 2010 Code Analysis. >> >> Modified: >> ? ?llvm/trunk/lib/MC/MachObjectWriter.cpp >> >> Modified: llvm/trunk/lib/MC/MachObjectWriter.cpp >> URL: http://llvm.org/viewvc/llvm-project/llvm/trunk/lib/MC/MachObjectWriter.cpp?rev=110575&r1=110574&r2=110575&view=diff >> ============================================================================== >> --- llvm/trunk/lib/MC/MachObjectWriter.cpp (original) >> +++ llvm/trunk/lib/MC/MachObjectWriter.cpp Mon Aug ?9 10:28:05 2010 >> @@ -835,7 +835,7 @@ >> ? ? ? // FIXME: Currently, these are never generated (see code below). I cannot >> ? ? ? // find a case where they are actually emitted. >> ? ? ? Type = RIT_Vanilla; >> - ? ?} else { >> + ? ?} else if (SD) { >> ? ? ? // Check whether we need an external or internal relocation. >> ? ? ? if (doesSymbolRequireExternRelocation(SD)) { >> ? ? ? ? IsExtern = 1; >> >> >> _______________________________________________ >> llvm-commits mailing list >> llvm-commits at cs.uiuc.edu >> http://lists.cs.uiuc.edu/mailman/listinfo/llvm-commits >> > From rafael.espindola at gmail.com Tue Aug 10 11:32:15 2010 From: rafael.espindola at gmail.com (Rafael Espindola) Date: Tue, 10 Aug 2010 16:32:15 -0000 Subject: [llvm-commits] [llvm] r110684 - /llvm/trunk/tools/gold/gold-plugin.cpp Message-ID: <20100810163215.AB8F62A6C12C@llvm.org> Author: rafael Date: Tue Aug 10 11:32:15 2010 New Revision: 110684 URL: http://llvm.org/viewvc/llvm-project?rev=110684&view=rev Log: Fix silly bug. Modified: llvm/trunk/tools/gold/gold-plugin.cpp Modified: llvm/trunk/tools/gold/gold-plugin.cpp URL: http://llvm.org/viewvc/llvm-project/llvm/trunk/tools/gold/gold-plugin.cpp?rev=110684&r1=110683&r2=110684&view=diff ============================================================================== --- llvm/trunk/tools/gold/gold-plugin.cpp (original) +++ llvm/trunk/tools/gold/gold-plugin.cpp Tue Aug 10 11:32:15 2010 @@ -96,7 +96,7 @@ } else if (opt.startswith("pass-through=")) { llvm::StringRef item = opt.substr(strlen("pass-through=")); pass_through.push_back(item.str()); - } else if (opt == "mtriple=") { + } else if (opt.startswith("mtriple=")) { triple = opt.substr(strlen("mtriple=")); } else if (opt == "emit-llvm") { generate_bc_file = BC_ONLY; From stoklund at 2pi.dk Tue Aug 10 11:48:24 2010 From: stoklund at 2pi.dk (Jakob Stoklund Olesen) Date: Tue, 10 Aug 2010 16:48:24 -0000 Subject: [llvm-commits] [llvm] r110685 - /llvm/trunk/test/CodeGen/X86/2010-08-10-DbgConstant.ll Message-ID: <20100810164824.78E0A2A6C12C@llvm.org> Author: stoklund Date: Tue Aug 10 11:48:24 2010 New Revision: 110685 URL: http://llvm.org/viewvc/llvm-project?rev=110685&view=rev Log: Fix test for more architectures. Patch by Tobias Grosser. Modified: llvm/trunk/test/CodeGen/X86/2010-08-10-DbgConstant.ll Modified: llvm/trunk/test/CodeGen/X86/2010-08-10-DbgConstant.ll URL: http://llvm.org/viewvc/llvm-project/llvm/trunk/test/CodeGen/X86/2010-08-10-DbgConstant.ll?rev=110685&r1=110684&r2=110685&view=diff ============================================================================== --- llvm/trunk/test/CodeGen/X86/2010-08-10-DbgConstant.ll (original) +++ llvm/trunk/test/CodeGen/X86/2010-08-10-DbgConstant.ll Tue Aug 10 11:48:24 2010 @@ -1,6 +1,6 @@ ; RUN: llc -O0 < %s | FileCheck %s ; CHECK: DW_TAG_constant -; CHECK-NEXT: .ascii "ro" # DW_AT_name +; CHECK-NEXT: ascii "ro" #{{#?}} DW_AT_name define void @foo() nounwind ssp { entry: From stoklund at 2pi.dk Tue Aug 10 11:50:54 2010 From: stoklund at 2pi.dk (Jakob Stoklund Olesen) Date: Tue, 10 Aug 2010 09:50:54 -0700 Subject: [llvm-commits] [llvm] r110664 - /llvm/trunk/test/CodeGen/X86/2010-08-10-DbgConstant.ll In-Reply-To: <4C6133BB.4010106@fim.uni-passau.de> References: <355_1281434179_4C612243_355_31249_1_20100810095429.E5F462A6C12C@llvm.org> <4C6133BB.4010106@fim.uni-passau.de> Message-ID: On Aug 10, 2010, at 4:10 AM, Tobias Grosser wrote: > On 08/10/2010 11:54 AM, Tobias Grosser wrote: >> Author: grosser >> Date: Tue Aug 10 04:54:29 2010 >> New Revision: 110664 >> >> URL: http://llvm.org/viewvc/llvm-project?rev=110664&view=rev >> Log: >> Fix failing testcase. >> >> Those look like typos to me. > > I was wrong. Now just different builders fail. > > There are some architectures that generate > > ## DW_AT_NAME > > and others that generate > > # DW_AT_NAME > > A patch that would accept both is attached. However I am not sure, if it is correct. Committed as r110685. It was just differences in asm syntax which is not what was being tested, and so safe to ignore. From stoklund at 2pi.dk Tue Aug 10 12:07:22 2010 From: stoklund at 2pi.dk (Jakob Stoklund Olesen) Date: Tue, 10 Aug 2010 17:07:22 -0000 Subject: [llvm-commits] [llvm] r110686 - in /llvm/trunk: include/llvm/CodeGen/CalcSpillWeights.h lib/CodeGen/SplitKit.cpp lib/CodeGen/SplitKit.h Message-ID: <20100810170722.7B4252A6C12C@llvm.org> Author: stoklund Date: Tue Aug 10 12:07:22 2010 New Revision: 110686 URL: http://llvm.org/viewvc/llvm-project?rev=110686&view=rev Log: Recalculate the spill weight and allocation hint for virtual registers created during live range splitting. Modified: llvm/trunk/include/llvm/CodeGen/CalcSpillWeights.h llvm/trunk/lib/CodeGen/SplitKit.cpp llvm/trunk/lib/CodeGen/SplitKit.h Modified: llvm/trunk/include/llvm/CodeGen/CalcSpillWeights.h URL: http://llvm.org/viewvc/llvm-project/llvm/trunk/include/llvm/CodeGen/CalcSpillWeights.h?rev=110686&r1=110685&r2=110686&view=diff ============================================================================== --- llvm/trunk/include/llvm/CodeGen/CalcSpillWeights.h (original) +++ llvm/trunk/include/llvm/CodeGen/CalcSpillWeights.h Tue Aug 10 12:07:22 2010 @@ -25,11 +25,11 @@ class VirtRegAuxInfo { MachineFunction &mf_; LiveIntervals &lis_; - MachineLoopInfo &loops_; + const MachineLoopInfo &loops_; DenseMap hint_; public: VirtRegAuxInfo(MachineFunction &mf, LiveIntervals &lis, - MachineLoopInfo &loops) : + const MachineLoopInfo &loops) : mf_(mf), lis_(lis), loops_(loops) {} /// CalculateRegClass - recompute the register class for li from its uses. Modified: llvm/trunk/lib/CodeGen/SplitKit.cpp URL: http://llvm.org/viewvc/llvm-project/llvm/trunk/lib/CodeGen/SplitKit.cpp?rev=110686&r1=110685&r2=110686&view=diff ============================================================================== --- llvm/trunk/lib/CodeGen/SplitKit.cpp (original) +++ llvm/trunk/lib/CodeGen/SplitKit.cpp Tue Aug 10 12:07:22 2010 @@ -15,6 +15,7 @@ #define DEBUG_TYPE "splitter" #include "SplitKit.h" #include "VirtRegMap.h" +#include "llvm/CodeGen/CalcSpillWeights.h" #include "llvm/CodeGen/LiveIntervalAnalysis.h" #include "llvm/CodeGen/MachineFunctionPass.h" #include "llvm/CodeGen/MachineInstrBuilder.h" @@ -566,8 +567,12 @@ intervals_.push_back(dupli_); } - // FIXME: *Calculate spill weights, allocation hints, and register classes for - // firstInterval.. + // Calculate spill weight and allocation hints for new intervals. + VirtRegAuxInfo vrai(vrm_.getMachineFunction(), lis_, sa_.loops_); + for (unsigned i = firstInterval, e = intervals_.size(); i != e; ++i) { + LiveInterval &li = *intervals_[i]; + vrai.CalculateWeightAndHint(li); + } } Modified: llvm/trunk/lib/CodeGen/SplitKit.h URL: http://llvm.org/viewvc/llvm-project/llvm/trunk/lib/CodeGen/SplitKit.h?rev=110686&r1=110685&r2=110686&view=diff ============================================================================== --- llvm/trunk/lib/CodeGen/SplitKit.h (original) +++ llvm/trunk/lib/CodeGen/SplitKit.h Tue Aug 10 12:07:22 2010 @@ -31,11 +31,13 @@ /// SplitAnalysis - Analyze a LiveInterval, looking for live range splitting /// opportunities. class SplitAnalysis { +public: const MachineFunction &mf_; const LiveIntervals &lis_; const MachineLoopInfo &loops_; const TargetInstrInfo &tii_; +private: // Current live interval. const LiveInterval *curli_; From bob.wilson at apple.com Tue Aug 10 12:12:16 2010 From: bob.wilson at apple.com (Bob Wilson) Date: Tue, 10 Aug 2010 10:12:16 -0700 Subject: [llvm-commits] [llvm] r110576 - in /llvm/trunk: lib/Target/CellSPU/SPUISelLowering.cpp lib/Target/CellSPU/SPUISelLowering.h lib/Target/CellSPU/SPUInstrInfo.td lib/Target/CellSPU/SPUNodes.td lib/Target/CellSPU/SPURegisterInfo.cpp test/CodeGen/CellSP... In-Reply-To: <1281437591.1796.146.camel@LLVMbuilder.research.nokia.com> References: <20100809163301.235462A6C12C@llvm.org> <25685170-45BA-47F0-AF9D-0D0600748145@apple.com> <1281437591.1796.146.camel@LLVMbuilder.research.nokia.com> Message-ID: On Aug 10, 2010, at 3:53 AM, Kalle.Raiskila at nokia.com wrote: > On Tue, 2010-08-10 at 02:24 +0200, Chris Lattner wrote: >> On Aug 9, 2010, at 9:33 AM, Kalle Raiskila wrote: >> >>> Author: kraiskil >>> Date: Mon Aug 9 11:33:00 2010 >>> New Revision: 110576 >>> >>> URL: http://llvm.org/viewvc/llvm-project?rev=110576&view=rev >>> Log: >>> Have SPU handle halfvec stores aligned by 8 bytes. >> >> Kalle, >> >> Again, what's going on here? Why isn't type legalization doing its job? > > Good question. With the 8byte memory accesses I was just copying the > functionality of the 4, 2, and 1 byte accesses. (16 bytes being the > granularity of the memory access). I thought they must be implemented as > they are for a reason. > > Experimenting a little shows that promoting v2i32 works rather nicely, > *if* v2i32 is not a "legal" type (i.e. there is no register class added > for v2i32). When it is a legal type, all sorts of asserts trigger when > trying to expand operations on that type. The reason it is legal > (currently, in the SPU backend) is that > a) it was like that when I found it :) > b) to the best of my understanding, v2i32 has to be legal if it is to be > used in return values and function parameters. The types of return values and function parameters are also legalized. If you pass an argument with a non-legal type, it should be promoted or expanded to make it legal. For example, if i32 is legal but v2i32 is not, you may have v2i32 argument and return types in the LLVM IR, but then legalize those to pairs of i32 values for codegen. > > So: what is the reason i32 (and f32, and so on) are treated separately, > as if there were separate instructions/registers for that type, as > opposed to just being promoted to v4i32, v4f32 and so on? > And: is there a way of passing illegal types of arguments (such as i32 > etc.) to functions? I don't understand either of those questions, possibly because I don't know much about SPU. The legal types for your target should correspond to the values that can be held in a register and that can be handled directly by the instruction set. I would assume that i32 and f32 are treated separately as legal types because you have registers to hold those values. If not, i.e., if SPU only has vector registers, then perhaps you should make v4i32, v4f32, etc. legal and try to promote scalar values to vector types. If simple scalar types are not legal, you may have some problems, for example, as you mention with argument passing. But, if your target doesn't have any scalar 32-bit registers, passing i32 arguments is going to be a pretty "interesting" regardless.... > > If the parameter passing and promotion are possible, I see no reason at > all to separately treat half (quarter) full vectors. > > > thanks, > kalle > > P.s. sorry for not replying to the previous mail with essentially the > same question: I (hope I) have now removed the relevant bug from my mail > filter... > > > _______________________________________________ > llvm-commits mailing list > llvm-commits at cs.uiuc.edu > http://lists.cs.uiuc.edu/mailman/listinfo/llvm-commits From bob.wilson at apple.com Tue Aug 10 12:13:59 2010 From: bob.wilson at apple.com (Bob Wilson) Date: Tue, 10 Aug 2010 17:13:59 -0000 Subject: [llvm-commits] [llvm] r110687 - /llvm/trunk/utils/buildit/GNUmakefile Message-ID: <20100810171359.12B472A6C12C@llvm.org> Author: bwilson Date: Tue Aug 10 12:13:58 2010 New Revision: 110687 URL: http://llvm.org/viewvc/llvm-project?rev=110687&view=rev Log: Install llvmCore_Sim to the simulator SDK directory. Radar 8282845. Modified: llvm/trunk/utils/buildit/GNUmakefile Modified: llvm/trunk/utils/buildit/GNUmakefile URL: http://llvm.org/viewvc/llvm-project/llvm/trunk/utils/buildit/GNUmakefile?rev=110687&r1=110686&r2=110687&view=diff ============================================================================== --- llvm/trunk/utils/buildit/GNUmakefile (original) +++ llvm/trunk/utils/buildit/GNUmakefile Tue Aug 10 12:13:58 2010 @@ -78,7 +78,7 @@ # (e.g., tblgen), so set it here. EmbeddedSim: export MACOSX_DEPLOYMENT_TARGET=`sw_vers -productVersion`; \ - $(MAKE) IOS_SIM_BUILD=yes PREFIX=/usr install + $(MAKE) IOS_SIM_BUILD=yes PREFIX=$(SDKROOT)/usr install # installhdrs does nothing, because the headers aren't useful until # the compiler is installed. From grosbach at apple.com Tue Aug 10 12:21:06 2010 From: grosbach at apple.com (Jim Grosbach) Date: Tue, 10 Aug 2010 17:21:06 -0000 Subject: [llvm-commits] [llvm-gcc-4.2] r110689 - in /llvm-gcc-4.2/trunk/gcc: objc/objc-act.c testsuite/objc.dg/qualified-id-property.m Message-ID: <20100810172106.7DA8C2A6C12C@llvm.org> Author: grosbach Date: Tue Aug 10 12:21:06 2010 New Revision: 110689 URL: http://llvm.org/viewvc/llvm-project?rev=110689&view=rev Log: Properly handle building a property setter name for a protocol. This fixes a compiler ICE. Patch by Fariborz Jahanian. rdar://8287791 Added: llvm-gcc-4.2/trunk/gcc/testsuite/objc.dg/qualified-id-property.m Modified: llvm-gcc-4.2/trunk/gcc/objc/objc-act.c Modified: llvm-gcc-4.2/trunk/gcc/objc/objc-act.c URL: http://llvm.org/viewvc/llvm-project/llvm-gcc-4.2/trunk/gcc/objc/objc-act.c?rev=110689&r1=110688&r2=110689&view=diff ============================================================================== --- llvm-gcc-4.2/trunk/gcc/objc/objc-act.c (original) +++ llvm-gcc-4.2/trunk/gcc/objc/objc-act.c Tue Aug 10 12:21:06 2010 @@ -1935,6 +1935,23 @@ && CLASS_SUPER_NAME (implementation_template)) class = lookup_interface (CLASS_SUPER_NAME (implementation_template)); } + /* APPLE LOCAL begin radar 8290584 */ + else { + /* receiver could be of type id find property in + protocol list. */ + tree rprotos = (TYPE_HAS_OBJC_INFO (TREE_TYPE (rtype)) + ? TYPE_OBJC_PROTOCOL_LIST (TREE_TYPE (rtype)) + : NULL_TREE); + if (rprotos) { + x = lookup_property_in_protocol_list (rprotos, property_ident); + if (x) { + return PROPERTY_SETTER_NAME (x) ? + IDENTIFIER_POINTER (PROPERTY_SETTER_NAME (x)) : + objc_build_property_setter_name(property_ident, true); + } + } + } + /* APPLE LOCAL end radar 8290584 */ } else { Added: llvm-gcc-4.2/trunk/gcc/testsuite/objc.dg/qualified-id-property.m URL: http://llvm.org/viewvc/llvm-project/llvm-gcc-4.2/trunk/gcc/testsuite/objc.dg/qualified-id-property.m?rev=110689&view=auto ============================================================================== --- llvm-gcc-4.2/trunk/gcc/testsuite/objc.dg/qualified-id-property.m (added) +++ llvm-gcc-4.2/trunk/gcc/testsuite/objc.dg/qualified-id-property.m Tue Aug 10 12:21:06 2010 @@ -0,0 +1,19 @@ +/* APPLE LOCAL file 8290584 */ +/* { dg-do compile } */ + + at protocol NetworkLoading + at property (assign, getter=isLoading) int loading; + at end + +extern id GMMApp; + + at interface I +- (void) Meth; + at end + + at implementation I +- (void) Meth { + GMMApp.loading = 0; +} + + at end From daniel at zuster.org Tue Aug 10 12:38:52 2010 From: daniel at zuster.org (Daniel Dunbar) Date: Tue, 10 Aug 2010 17:38:52 -0000 Subject: [llvm-commits] [llvm] r110692 - in /llvm/trunk: lib/MC/MCParser/AsmParser.cpp test/MC/AsmParser/macros.s Message-ID: <20100810173852.AE7FD2A6C12C@llvm.org> Author: ddunbar Date: Tue Aug 10 12:38:52 2010 New Revision: 110692 URL: http://llvm.org/viewvc/llvm-project?rev=110692&view=rev Log: MC/AsmParser: Fix a bug in macro argument parsing, which was dropping parentheses from argument lists. Modified: llvm/trunk/lib/MC/MCParser/AsmParser.cpp llvm/trunk/test/MC/AsmParser/macros.s Modified: llvm/trunk/lib/MC/MCParser/AsmParser.cpp URL: http://llvm.org/viewvc/llvm-project/llvm/trunk/lib/MC/MCParser/AsmParser.cpp?rev=110692&r1=110691&r2=110692&view=diff ============================================================================== --- llvm/trunk/lib/MC/MCParser/AsmParser.cpp (original) +++ llvm/trunk/lib/MC/MCParser/AsmParser.cpp Tue Aug 10 12:38:52 2010 @@ -1032,12 +1032,14 @@ // list. if (ParenLevel == 0 && Lexer.is(AsmToken::Comma)) { MacroArguments.push_back(std::vector()); - } else if (Lexer.is(AsmToken::LParen)) { - ++ParenLevel; - } else if (Lexer.is(AsmToken::RParen)) { - if (ParenLevel) - --ParenLevel; } else { + // Adjust the current parentheses level. + if (Lexer.is(AsmToken::LParen)) + ++ParenLevel; + else if (Lexer.is(AsmToken::RParen) && ParenLevel) + --ParenLevel; + + // Append the token to the current argument list. MacroArguments.back().push_back(getTok()); } Lex(); Modified: llvm/trunk/test/MC/AsmParser/macros.s URL: http://llvm.org/viewvc/llvm-project/llvm/trunk/test/MC/AsmParser/macros.s?rev=110692&r1=110691&r2=110692&view=diff ============================================================================== --- llvm/trunk/test/MC/AsmParser/macros.s (original) +++ llvm/trunk/test/MC/AsmParser/macros.s Tue Aug 10 12:38:52 2010 @@ -30,3 +30,10 @@ // CHECK: .globl "1 23 $3 2" test3 1,2 3 + +.macro test4 +.globl "$0 -- $1" +.endmacro + +// CHECK: .globl "ab)(,) -- (cd)" +test4 a b)(,),(cd) From espindola at google.com Tue Aug 10 12:42:23 2010 From: espindola at google.com (Rafael Espindola) Date: Tue, 10 Aug 2010 13:42:23 -0400 Subject: [llvm-commits] [patch][libLTO/gold] Make it possible to set the flags passed to the assembler Message-ID: The attached patch makes it possible to pass extra flags to the assembler. The gnu assembler needs extra flags like * --32/--64 to select x86 or x86-64 * -mfpu on arm to select which fp instructions are available I could just implement this logic in libLTO, but since a similar logic exists in clang that didn't look like the right approach. One day I should implement a use-gold-plugin option in clang and it would be nice for clang to be able to just pass those flags to libLTO. Cheers, -- Rafael ?vila de Esp?ndola -------------- next part -------------- A non-text attachment was scrubbed... Name: as-flags.patch Type: text/x-patch Size: 4885 bytes Desc: not available Url : http://lists.cs.uiuc.edu/pipermail/llvm-commits/attachments/20100810/07dd3433/attachment.bin From echristo at apple.com Tue Aug 10 12:54:01 2010 From: echristo at apple.com (Eric Christopher) Date: Tue, 10 Aug 2010 10:54:01 -0700 Subject: [llvm-commits] [patch] pr7852 - Make LLVM robust to #define ARCH pollution by removing fragile macros. In-Reply-To: <4C612DB4.9050908@zafena.se> References: <4C612DB4.9050908@zafena.se> Message-ID: On Aug 10, 2010, at 3:45 AM, Xerxes R?nby wrote: > patch: http://llvm.org/bugs/attachment.cgi?id=5357 > > Remove use of fragile macros to define native target init function names in > include/llvm/Target/TargetSelect.h and llvm/include/llvm-c/Target.h As I mentioned in the bug I don't think this is a problem on our end, but that ffi is being really unfriendly. I have brought it up with those guys and they're talking about it on the ffi-discuss list. This could happen with anyone defining any arbitrary string - it's not outrageous that I would want to use FOOX86 or FOOARM as a define for my project. It's even more understandable when it's LLVM_FOOX86 and LLVM_FOOARM. Let's hold off for a few days and see which way the ffi discussion is going to go for now. -eric From isanbard at gmail.com Tue Aug 10 13:30:27 2010 From: isanbard at gmail.com (Bill Wendling) Date: Tue, 10 Aug 2010 18:30:27 -0000 Subject: [llvm-commits] [www] r110699 - /www/trunk/index.html Message-ID: <20100810183027.673262A6C12C@llvm.org> Author: void Date: Tue Aug 10 13:30:27 2010 New Revision: 110699 URL: http://llvm.org/viewvc/llvm-project?rev=110699&view=rev Log: Update with 2.8 release schedule. Modified: www/trunk/index.html Modified: www/trunk/index.html URL: http://llvm.org/viewvc/llvm-project/www/trunk/index.html?rev=110699&r1=110698&r2=110699&view=diff ============================================================================== --- www/trunk/index.html (original) +++ www/trunk/index.html Tue Aug 10 13:30:27 2010 @@ -130,8 +130,17 @@
Upcoming Releases
-

LLVM 2.8 release:

-Information coming soon. +

The LLVM 2.8 release schedule has been announced:

+ +
    +
  • 9/3— Branching
  • +
  • 9/6 — Pre-release 1, testing begins
  • +
  • 9/12 — Pre-release 1 testing ends
  • +
  • 9/20 — Pre-release 2 testing begins
  • +
  • 9/26 — Pre-release 2 testing ends
  • +
  • 9/29 — Release!
  • +
+

From isanbard at gmail.com Tue Aug 10 13:31:04 2010 From: isanbard at gmail.com (Bill Wendling) Date: Tue, 10 Aug 2010 18:31:04 -0000 Subject: [llvm-commits] [www] r110700 - /www/trunk/index.html Message-ID: <20100810183104.6CC272A6C12C@llvm.org> Author: void Date: Tue Aug 10 13:31:04 2010 New Revision: 110700 URL: http://llvm.org/viewvc/llvm-project?rev=110700&view=rev Log: Minor adjustment. Modified: www/trunk/index.html Modified: www/trunk/index.html URL: http://llvm.org/viewvc/llvm-project/www/trunk/index.html?rev=110700&r1=110699&r2=110700&view=diff ============================================================================== --- www/trunk/index.html (original) +++ www/trunk/index.html Tue Aug 10 13:31:04 2010 @@ -134,7 +134,7 @@
  • 9/3— Branching
  • -
  • 9/6 — Pre-release 1, testing begins
  • +
  • 9/6 — Pre-release 1 testing begins
  • 9/12 — Pre-release 1 testing ends
  • 9/20 — Pre-release 2 testing begins
  • 9/26 — Pre-release 2 testing ends
  • From daniel at zuster.org Tue Aug 10 13:32:02 2010 From: daniel at zuster.org (Daniel Dunbar) Date: Tue, 10 Aug 2010 18:32:02 -0000 Subject: [llvm-commits] [llvm] r110701 - in /llvm/trunk: lib/Target/ARM/ARMBaseRegisterInfo.cpp lib/Target/ARM/ARMISelLowering.cpp lib/Target/ARM/ARMMachineFunctionInfo.h lib/Target/ARM/ARMRegisterInfo.td lib/Target/ARM/Thumb1RegisterInfo.cpp test/CodeGen/Thumb/large-stack.ll Message-ID: <20100810183203.04D622A6C12C@llvm.org> Author: ddunbar Date: Tue Aug 10 13:32:02 2010 New Revision: 110701 URL: http://llvm.org/viewvc/llvm-project?rev=110701&view=rev Log: Revert r110655, "Fix ARM hasFP() semantics. It should return true whenever FP register is", it breaks a couple test-suite tests. Modified: llvm/trunk/lib/Target/ARM/ARMBaseRegisterInfo.cpp llvm/trunk/lib/Target/ARM/ARMISelLowering.cpp llvm/trunk/lib/Target/ARM/ARMMachineFunctionInfo.h llvm/trunk/lib/Target/ARM/ARMRegisterInfo.td llvm/trunk/lib/Target/ARM/Thumb1RegisterInfo.cpp llvm/trunk/test/CodeGen/Thumb/large-stack.ll Modified: llvm/trunk/lib/Target/ARM/ARMBaseRegisterInfo.cpp URL: http://llvm.org/viewvc/llvm-project/llvm/trunk/lib/Target/ARM/ARMBaseRegisterInfo.cpp?rev=110701&r1=110700&r2=110701&view=diff ============================================================================== --- llvm/trunk/lib/Target/ARM/ARMBaseRegisterInfo.cpp (original) +++ llvm/trunk/lib/Target/ARM/ARMBaseRegisterInfo.cpp Tue Aug 10 13:32:02 2010 @@ -177,7 +177,7 @@ Reserved.set(ARM::SP); Reserved.set(ARM::PC); Reserved.set(ARM::FPSCR); - if (hasFP(MF)) + if (STI.isTargetDarwin() || hasFP(MF)) Reserved.set(FramePtr); // Some targets reserve R9. if (STI.isR9Reserved()) @@ -194,7 +194,7 @@ return true; case ARM::R7: case ARM::R11: - if (FramePtr == Reg && hasFP(MF)) + if (FramePtr == Reg && (STI.isTargetDarwin() || hasFP(MF))) return true; break; case ARM::R9: @@ -511,7 +511,7 @@ return std::make_pair(RC->allocation_order_begin(MF), RC->allocation_order_end(MF)); - if (!hasFP(MF)) { + if (!STI.isTargetDarwin() && !hasFP(MF)) { if (!STI.isR9Reserved()) return std::make_pair(GPREven1, GPREven1 + (sizeof(GPREven1)/sizeof(unsigned))); @@ -540,7 +540,7 @@ return std::make_pair(RC->allocation_order_begin(MF), RC->allocation_order_end(MF)); - if (!hasFP(MF)) { + if (!STI.isTargetDarwin() && !hasFP(MF)) { if (!STI.isR9Reserved()) return std::make_pair(GPROdd1, GPROdd1 + (sizeof(GPROdd1)/sizeof(unsigned))); @@ -610,10 +610,6 @@ /// or if frame pointer elimination is disabled. /// bool ARMBaseRegisterInfo::hasFP(const MachineFunction &MF) const { - // Mac OS X requires FP not to be clobbered for backtracing purpose. - if (STI.isTargetDarwin()) - return true; - const MachineFrameInfo *MFI = MF.getFrameInfo(); // Always eliminate non-leaf frame pointers. return ((DisableFramePointerElim(MF) && MFI->hasCalls()) || @@ -687,7 +683,6 @@ /// instructions will require a scratch register during their expansion later. unsigned ARMBaseRegisterInfo::estimateRSStackSizeLimit(MachineFunction &MF) const { - const ARMFunctionInfo *AFI = MF.getInfo(); unsigned Limit = (1 << 12) - 1; for (MachineFunction::iterator BB = MF.begin(),E = MF.end(); BB != E; ++BB) { for (MachineBasicBlock::iterator I = BB->begin(), E = BB->end(); @@ -713,10 +708,7 @@ Limit = std::min(Limit, ((1U << 8) - 1) * 4); break; case ARMII::AddrModeT2_i12: - // i12 supports only positive offset so these will be converted to - // i8 opcodes. See llvm::rewriteT2FrameIndex. - if (hasFP(MF) && AFI->hasStackFrame()) - Limit = std::min(Limit, (1U << 8) - 1); + if (hasFP(MF)) Limit = std::min(Limit, (1U << 8) - 1); break; case ARMII::AddrMode6: // Addressing mode 6 (load/store) instructions can't encode an @@ -868,9 +860,8 @@ // and which instructions will need a scratch register for them. Is it // worth the effort and added fragility? bool BigStack = - (RS && - (estimateStackSize(MF) + ((hasFP(MF) && AFI->hasStackFrame()) ? 4:0) >= - estimateRSStackSizeLimit(MF))) + (RS && (estimateStackSize(MF) + (hasFP(MF) ? 4:0) >= + estimateRSStackSizeLimit(MF))) || MFI->hasVarSizedObjects() || (MFI->adjustsStack() && !canSimplifyCallFramePseudos(MF)); @@ -890,7 +881,9 @@ ExtraCSSpill = true; } - if (hasFP(MF)) { + // Darwin ABI requires FP to point to the stack slot that contains the + // previous FP. + if (STI.isTargetDarwin() || hasFP(MF)) { MF.getRegInfo().setPhysRegUsed(FramePtr); NumGPRSpills++; } @@ -983,7 +976,7 @@ unsigned ARMBaseRegisterInfo::getFrameRegister(const MachineFunction &MF) const { - if (hasFP(MF)) + if (STI.isTargetDarwin() || hasFP(MF)) return FramePtr; return ARM::SP; } @@ -1553,8 +1546,7 @@ // Otherwise, if this is not Darwin, all the callee-saved registers go // into spill area 1, including the FP in R11. In either case, it is // now safe to emit this assignment. - bool HasFP = hasFP(MF); - if (HasFP) { + if (STI.isTargetDarwin() || hasFP(MF)) { unsigned ADDriOpc = !AFI->isThumbFunction() ? ARM::ADDri : ARM::t2ADDri; MachineInstrBuilder MIB = BuildMI(MBB, MBBI, dl, TII.get(ADDriOpc), FramePtr) @@ -1573,7 +1565,7 @@ unsigned DPRCSOffset = NumBytes - (GPRCS1Size + GPRCS2Size + DPRCSSize); unsigned GPRCS2Offset = DPRCSOffset + DPRCSSize; unsigned GPRCS1Offset = GPRCS2Offset + GPRCS2Size; - if (HasFP) + if (STI.isTargetDarwin() || hasFP(MF)) AFI->setFramePtrSpillOffset(MFI->getObjectOffset(FramePtrSpillFI) + NumBytes); AFI->setGPRCalleeSavedArea1Offset(GPRCS1Offset); @@ -1585,14 +1577,11 @@ if (NumBytes) { // Adjust SP after all the callee-save spills. emitSPUpdate(isARM, MBB, MBBI, dl, TII, -NumBytes); - if (HasFP) - AFI->setShouldRestoreSPFromFP(true); } if (STI.isTargetELF() && hasFP(MF)) { MFI->setOffsetAdjustment(MFI->getOffsetAdjustment() - AFI->getFramePtrSpillOffset()); - AFI->setShouldRestoreSPFromFP(true); } AFI->setGPRCalleeSavedArea1Size(GPRCS1Size); @@ -1625,8 +1614,6 @@ BuildMI(MBB, MBBI, dl, TII.get(ARM::tMOVtgpr2gpr), ARM::SP) .addReg(ARM::R4, RegState::Kill); } - - AFI->setShouldRestoreSPFromFP(true); } } @@ -1682,25 +1669,34 @@ AFI->getGPRCalleeSavedArea2Size() + AFI->getDPRCalleeSavedAreaSize()); - // Reset SP based on frame pointer only if the stack frame extends beyond - // frame pointer stack slot or target is ELF and the function has FP. - if (AFI->shouldRestoreSPFromFP()) { + // Darwin ABI requires FP to point to the stack slot that contains the + // previous FP. + bool HasFP = hasFP(MF); + if ((STI.isTargetDarwin() && NumBytes) || HasFP) { NumBytes = AFI->getFramePtrSpillOffset() - NumBytes; - if (NumBytes) { - if (isARM) - emitARMRegPlusImmediate(MBB, MBBI, dl, ARM::SP, FramePtr, -NumBytes, - ARMCC::AL, 0, TII); - else - emitT2RegPlusImmediate(MBB, MBBI, dl, ARM::SP, FramePtr, -NumBytes, - ARMCC::AL, 0, TII); - } else { - // Thumb2 or ARM. - if (isARM) - BuildMI(MBB, MBBI, dl, TII.get(ARM::MOVr), ARM::SP) - .addReg(FramePtr).addImm((unsigned)ARMCC::AL).addReg(0).addReg(0); - else - BuildMI(MBB, MBBI, dl, TII.get(ARM::tMOVgpr2gpr), ARM::SP) - .addReg(FramePtr); + // Reset SP based on frame pointer only if the stack frame extends beyond + // frame pointer stack slot or target is ELF and the function has FP. + if (HasFP || + AFI->getGPRCalleeSavedArea2Size() || + AFI->getDPRCalleeSavedAreaSize() || + AFI->getDPRCalleeSavedAreaOffset()) { + if (NumBytes) { + if (isARM) + emitARMRegPlusImmediate(MBB, MBBI, dl, ARM::SP, FramePtr, -NumBytes, + ARMCC::AL, 0, TII); + else + emitT2RegPlusImmediate(MBB, MBBI, dl, ARM::SP, FramePtr, -NumBytes, + ARMCC::AL, 0, TII); + } else { + // Thumb2 or ARM. + if (isARM) + BuildMI(MBB, MBBI, dl, TII.get(ARM::MOVr), ARM::SP) + .addReg(FramePtr) + .addImm((unsigned)ARMCC::AL).addReg(0).addReg(0); + else + BuildMI(MBB, MBBI, dl, TII.get(ARM::tMOVgpr2gpr), ARM::SP) + .addReg(FramePtr); + } } } else if (NumBytes) emitSPUpdate(isARM, MBB, MBBI, dl, TII, NumBytes); Modified: llvm/trunk/lib/Target/ARM/ARMISelLowering.cpp URL: http://llvm.org/viewvc/llvm-project/llvm/trunk/lib/Target/ARM/ARMISelLowering.cpp?rev=110701&r1=110700&r2=110701&view=diff ============================================================================== --- llvm/trunk/lib/Target/ARM/ARMISelLowering.cpp (original) +++ llvm/trunk/lib/Target/ARM/ARMISelLowering.cpp Tue Aug 10 13:32:02 2010 @@ -742,15 +742,14 @@ unsigned ARMTargetLowering::getRegPressureLimit(const TargetRegisterClass *RC, MachineFunction &MF) const { + unsigned FPDiff = RegInfo->hasFP(MF) ? 1 : 0; switch (RC->getID()) { default: return 0; case ARM::tGPRRegClassID: - return RegInfo->hasFP(MF) ? 4 : 5; - case ARM::GPRRegClassID: { - unsigned FP = RegInfo->hasFP(MF) ? 1 : 0; - return 10 - FP - (Subtarget->isR9Reserved() ? 1 : 0); - } + return 5 - FPDiff; + case ARM::GPRRegClassID: + return 10 - FPDiff - (Subtarget->isR9Reserved() ? 1 : 0); case ARM::SPRRegClassID: // Currently not used as 'rep' register class. case ARM::DPRRegClassID: return 32 - 10; Modified: llvm/trunk/lib/Target/ARM/ARMMachineFunctionInfo.h URL: http://llvm.org/viewvc/llvm-project/llvm/trunk/lib/Target/ARM/ARMMachineFunctionInfo.h?rev=110701&r1=110700&r2=110701&view=diff ============================================================================== --- llvm/trunk/lib/Target/ARM/ARMMachineFunctionInfo.h (original) +++ llvm/trunk/lib/Target/ARM/ARMMachineFunctionInfo.h Tue Aug 10 13:32:02 2010 @@ -43,10 +43,6 @@ /// processFunctionBeforeCalleeSavedScan(). bool HasStackFrame; - /// RestoreSPFromFP - True if epilogue should restore SP from FP. Set by - /// emitPrologue. - bool RestoreSPFromFP; - /// LRSpilledForFarJump - True if the LR register has been for spilled to /// enable far jump. bool LRSpilledForFarJump; @@ -99,7 +95,7 @@ ARMFunctionInfo() : isThumb(false), hasThumb2(false), - VarArgsRegSaveSize(0), HasStackFrame(false), RestoreSPFromFP(false), + VarArgsRegSaveSize(0), HasStackFrame(false), LRSpilledForFarJump(false), FramePtrSpillOffset(0), GPRCS1Offset(0), GPRCS2Offset(0), DPRCSOffset(0), GPRCS1Size(0), GPRCS2Size(0), DPRCSSize(0), @@ -110,7 +106,7 @@ explicit ARMFunctionInfo(MachineFunction &MF) : isThumb(MF.getTarget().getSubtarget().isThumb()), hasThumb2(MF.getTarget().getSubtarget().hasThumb2()), - VarArgsRegSaveSize(0), HasStackFrame(false), RestoreSPFromFP(false), + VarArgsRegSaveSize(0), HasStackFrame(false), LRSpilledForFarJump(false), FramePtrSpillOffset(0), GPRCS1Offset(0), GPRCS2Offset(0), DPRCSOffset(0), GPRCS1Size(0), GPRCS2Size(0), DPRCSSize(0), @@ -129,9 +125,6 @@ bool hasStackFrame() const { return HasStackFrame; } void setHasStackFrame(bool s) { HasStackFrame = s; } - bool shouldRestoreSPFromFP() const { return RestoreSPFromFP; } - void setShouldRestoreSPFromFP(bool s) { RestoreSPFromFP = s; } - bool isLRSpilledForFarJump() const { return LRSpilledForFarJump; } void setLRIsSpilledForFarJump(bool s) { LRSpilledForFarJump = s; } Modified: llvm/trunk/lib/Target/ARM/ARMRegisterInfo.td URL: http://llvm.org/viewvc/llvm-project/llvm/trunk/lib/Target/ARM/ARMRegisterInfo.td?rev=110701&r1=110700&r2=110701&view=diff ============================================================================== --- llvm/trunk/lib/Target/ARM/ARMRegisterInfo.td (original) +++ llvm/trunk/lib/Target/ARM/ARMRegisterInfo.td Tue Aug 10 13:32:02 2010 @@ -294,7 +294,8 @@ if (Subtarget.isThumb1Only()) { I = THUMB_GPR_AO + (sizeof(THUMB_GPR_AO)/sizeof(unsigned)); - return RI->hasFP(MF) ? I-1 : I; + // Mac OS X requires FP not to be clobbered for backtracing purpose. + return (Subtarget.isTargetDarwin() || RI->hasFP(MF)) ? I-1 : I; } if (Subtarget.isTargetDarwin()) { @@ -311,7 +312,8 @@ I = ARM_GPR_AO_1 + (sizeof(ARM_GPR_AO_1)/sizeof(unsigned)); } - return RI->hasFP(MF) ? I-1 : I; + // Mac OS X requires FP not to be clobbered for backtracing purpose. + return (Subtarget.isTargetDarwin() || RI->hasFP(MF)) ? I-1 : I; } }]; } @@ -401,7 +403,8 @@ if (Subtarget.isThumb1Only()) { I = THUMB_rGPRAO + (sizeof(THUMB_rGPRAO)/sizeof(unsigned)); - return RI->hasFP(MF) ? I-1 : I; + // Mac OS X requires FP not to be clobbered for backtracing purpose. + return (Subtarget.isTargetDarwin() || RI->hasFP(MF)) ? I-1 : I; } if (Subtarget.isTargetDarwin()) { @@ -418,7 +421,8 @@ I = ARM_rGPRAO_1 + (sizeof(ARM_rGPRAO_1)/sizeof(unsigned)); } - return RI->hasFP(MF) ? I-1 : I; + // Mac OS X requires FP not to be clobbered for backtracing purpose. + return (Subtarget.isTargetDarwin() || RI->hasFP(MF)) ? I-1 : I; } }]; } @@ -445,9 +449,11 @@ tGPRClass::allocation_order_end(const MachineFunction &MF) const { const TargetMachine &TM = MF.getTarget(); const TargetRegisterInfo *RI = TM.getRegisterInfo(); + const ARMSubtarget &Subtarget = TM.getSubtarget(); tGPRClass::iterator I = THUMB_tGPR_AO + (sizeof(THUMB_tGPR_AO)/sizeof(unsigned)); - return RI->hasFP(MF) ? I-1 : I; + // Mac OS X requires FP not to be clobbered for backtracing purpose. + return (Subtarget.isTargetDarwin() || RI->hasFP(MF)) ? I-1 : I; } }]; } Modified: llvm/trunk/lib/Target/ARM/Thumb1RegisterInfo.cpp URL: http://llvm.org/viewvc/llvm-project/llvm/trunk/lib/Target/ARM/Thumb1RegisterInfo.cpp?rev=110701&r1=110700&r2=110701&view=diff ============================================================================== --- llvm/trunk/lib/Target/ARM/Thumb1RegisterInfo.cpp (original) +++ llvm/trunk/lib/Target/ARM/Thumb1RegisterInfo.cpp Tue Aug 10 13:32:02 2010 @@ -742,11 +742,11 @@ dl = MBBI->getDebugLoc(); } - // Adjust FP so it point to the stack slot that contains the previous FP. - if (hasFP(MF)) { + // Darwin ABI requires FP to point to the stack slot that contains the + // previous FP. + if (STI.isTargetDarwin() || hasFP(MF)) { BuildMI(MBB, MBBI, dl, TII.get(ARM::tADDrSPi), FramePtr) .addFrameIndex(FramePtrSpillFI).addImm(0); - AFI->setShouldRestoreSPFromFP(true); } // Determine starting offsets of spill areas. @@ -764,9 +764,10 @@ emitSPUpdate(MBB, MBBI, TII, dl, *this, -NumBytes); } - if (STI.isTargetELF() && hasFP(MF)) + if (STI.isTargetELF() && hasFP(MF)) { MFI->setOffsetAdjustment(MFI->getOffsetAdjustment() - AFI->getFramePtrSpillOffset()); + } AFI->setGPRCalleeSavedArea1Size(GPRCS1Size); AFI->setGPRCalleeSavedArea2Size(GPRCS2Size); @@ -827,7 +828,7 @@ AFI->getGPRCalleeSavedArea2Size() + AFI->getDPRCalleeSavedAreaSize()); - if (AFI->shouldRestoreSPFromFP()) { + if (hasFP(MF)) { NumBytes = AFI->getFramePtrSpillOffset() - NumBytes; // Reset SP based on frame pointer only if the stack frame extends beyond // frame pointer stack slot or target is ELF and the function has FP. Modified: llvm/trunk/test/CodeGen/Thumb/large-stack.ll URL: http://llvm.org/viewvc/llvm-project/llvm/trunk/test/CodeGen/Thumb/large-stack.ll?rev=110701&r1=110700&r2=110701&view=diff ============================================================================== --- llvm/trunk/test/CodeGen/Thumb/large-stack.ll (original) +++ llvm/trunk/test/CodeGen/Thumb/large-stack.ll Tue Aug 10 13:32:02 2010 @@ -1,35 +1,20 @@ -; RUN: llc < %s -mtriple=thumb-apple-darwin | FileCheck %s +; RUN: llc < %s -march=thumb | grep {ldr.*LCP} | count 5 define void @test1() { -; CHECK: test1: -; CHECK: sub sp, #256 -; CHECK: add sp, #256 %tmp = alloca [ 64 x i32 ] , align 4 ret void } define void @test2() { -; CHECK: test2: -; CHECK: ldr r0, LCPI -; CHECK: add sp, r0 -; CHECK: mov sp, r7 -; CHECK: sub sp, #4 %tmp = alloca [ 4168 x i8 ] , align 4 ret void } define i32 @test3() { -; CHECK: test3: -; CHECK: ldr r1, LCPI -; CHECK: add sp, r1 -; CHECK: ldr r1, LCPI -; CHECK: add r1, sp -; CHECK: mov sp, r7 -; CHECK: sub sp, #4 - %retval = alloca i32, align 4 - %tmp = alloca i32, align 4 - %a = alloca [805306369 x i8], align 16 - store i32 0, i32* %tmp - %tmp1 = load i32* %tmp - ret i32 %tmp1 + %retval = alloca i32, align 4 + %tmp = alloca i32, align 4 + %a = alloca [805306369 x i8], align 16 + store i32 0, i32* %tmp + %tmp1 = load i32* %tmp + ret i32 %tmp1 } From stoklund at 2pi.dk Tue Aug 10 13:37:41 2010 From: stoklund at 2pi.dk (Jakob Stoklund Olesen) Date: Tue, 10 Aug 2010 18:37:41 -0000 Subject: [llvm-commits] [llvm] r110703 - in /llvm/trunk: include/llvm/CodeGen/CalcSpillWeights.h include/llvm/Target/TargetInstrDesc.h lib/CodeGen/CalcSpillWeights.cpp lib/CodeGen/SplitKit.cpp Message-ID: <20100810183741.2CC222A6C12C@llvm.org> Author: stoklund Date: Tue Aug 10 13:37:40 2010 New Revision: 110703 URL: http://llvm.org/viewvc/llvm-project?rev=110703&view=rev Log: Implement register class inflation. When splitting a live range, the new registers have fewer uses and the permissible register class may be less constrained. Recompute the register class constraint from the uses of new registers created for a split. This may let them be allocated from a larger set, possibly avoiding a spill. Modified: llvm/trunk/include/llvm/CodeGen/CalcSpillWeights.h llvm/trunk/include/llvm/Target/TargetInstrDesc.h llvm/trunk/lib/CodeGen/CalcSpillWeights.cpp llvm/trunk/lib/CodeGen/SplitKit.cpp Modified: llvm/trunk/include/llvm/CodeGen/CalcSpillWeights.h URL: http://llvm.org/viewvc/llvm-project/llvm/trunk/include/llvm/CodeGen/CalcSpillWeights.h?rev=110703&r1=110702&r2=110703&view=diff ============================================================================== --- llvm/trunk/include/llvm/CodeGen/CalcSpillWeights.h (original) +++ llvm/trunk/include/llvm/CodeGen/CalcSpillWeights.h Tue Aug 10 13:37:40 2010 @@ -32,10 +32,10 @@ const MachineLoopInfo &loops) : mf_(mf), lis_(lis), loops_(loops) {} - /// CalculateRegClass - recompute the register class for li from its uses. + /// CalculateRegClass - recompute the register class for reg from its uses. /// Since the register class can affect the allocation hint, this function /// should be called before CalculateWeightAndHint if both are called. - void CalculateRegClass(LiveInterval &li); + void CalculateRegClass(unsigned reg); /// CalculateWeightAndHint - (re)compute li's spill weight and allocation /// hint. Modified: llvm/trunk/include/llvm/Target/TargetInstrDesc.h URL: http://llvm.org/viewvc/llvm-project/llvm/trunk/include/llvm/Target/TargetInstrDesc.h?rev=110703&r1=110702&r2=110703&view=diff ============================================================================== --- llvm/trunk/include/llvm/Target/TargetInstrDesc.h (original) +++ llvm/trunk/include/llvm/Target/TargetInstrDesc.h Tue Aug 10 13:37:40 2010 @@ -152,6 +152,12 @@ return -1; } + /// getRegClass - Returns the register class constraint for OpNum, or NULL. + const TargetRegisterClass *getRegClass(unsigned OpNum, + const TargetRegisterInfo *TRI) const { + return OpNum < NumOperands ? OpInfo[OpNum].getRegClass(TRI) : 0; + } + /// getOpcode - Return the opcode number for this descriptor. unsigned getOpcode() const { return Opcode; Modified: llvm/trunk/lib/CodeGen/CalcSpillWeights.cpp URL: http://llvm.org/viewvc/llvm-project/llvm/trunk/lib/CodeGen/CalcSpillWeights.cpp?rev=110703&r1=110702&r2=110703&view=diff ============================================================================== --- llvm/trunk/lib/CodeGen/CalcSpillWeights.cpp (original) +++ llvm/trunk/lib/CodeGen/CalcSpillWeights.cpp Tue Aug 10 13:37:40 2010 @@ -174,3 +174,44 @@ lis_.normalizeSpillWeight(li); } +void VirtRegAuxInfo::CalculateRegClass(unsigned reg) { + MachineRegisterInfo &mri = mf_.getRegInfo(); + const TargetRegisterInfo *tri = mf_.getTarget().getRegisterInfo(); + const TargetRegisterClass *orc = mri.getRegClass(reg); + SmallPtrSet rcs; + + for (MachineRegisterInfo::reg_nodbg_iterator I = mri.reg_nodbg_begin(reg), + E = mri.reg_nodbg_end(); I != E; ++I) + if (const TargetRegisterClass *rc = + I->getDesc().getRegClass(I.getOperandNo(), tri)) + rcs.insert(rc); + + // If we found no regclass constraints, just leave reg as is. + // In theory, we could inflate to the largest superclass of reg's existing + // class, but that might not be legal for the current cpu setting. + // This could happen if reg is only used by COPY instructions, so we may need + // to improve on this. + if (rcs.empty()) { + DEBUG(dbgs() << "Not inflating unconstrained" << orc->getName() << ":%reg" + << reg << ".\n"); + return; + } + + // Compute the intersection of all classes in rcs. + // This ought to be independent of iteration order, but if the target register + // classes don't form a proper algebra, it is possible to get different + // results. The solution is to make sure the intersection of any two register + // classes is also a register class or the null set. + const TargetRegisterClass *rc = 0; + for (SmallPtrSet::iterator I = rcs.begin(), + E = rcs.end(); I != E; ++I) { + rc = rc ? getCommonSubClass(rc, *I) : *I; + assert(rc && "Incompatible regclass constraints found"); + } + + if (rc == orc) + return; + DEBUG(dbgs() << "Inflating " << orc->getName() << ":%reg" << reg << " to " + << rc->getName() <<".\n"); + mri.setRegClass(reg, rc); +} Modified: llvm/trunk/lib/CodeGen/SplitKit.cpp URL: http://llvm.org/viewvc/llvm-project/llvm/trunk/lib/CodeGen/SplitKit.cpp?rev=110703&r1=110702&r2=110703&view=diff ============================================================================== --- llvm/trunk/lib/CodeGen/SplitKit.cpp (original) +++ llvm/trunk/lib/CodeGen/SplitKit.cpp Tue Aug 10 13:37:40 2010 @@ -571,6 +571,7 @@ VirtRegAuxInfo vrai(vrm_.getMachineFunction(), lis_, sa_.loops_); for (unsigned i = firstInterval, e = intervals_.size(); i != e; ++i) { LiveInterval &li = *intervals_[i]; + vrai.CalculateRegClass(li.reg); vrai.CalculateWeightAndHint(li); } } From rafael.espindola at gmail.com Tue Aug 10 13:55:09 2010 From: rafael.espindola at gmail.com (Rafael Espindola) Date: Tue, 10 Aug 2010 18:55:09 -0000 Subject: [llvm-commits] [llvm] r110705 - in /llvm/trunk: include/llvm-c/lto.h tools/gold/gold-plugin.cpp tools/lto/LTOCodeGenerator.cpp tools/lto/LTOCodeGenerator.h tools/lto/lto.cpp Message-ID: <20100810185509.A71942A6C12C@llvm.org> Author: rafael Date: Tue Aug 10 13:55:09 2010 New Revision: 110705 URL: http://llvm.org/viewvc/llvm-project?rev=110705&view=rev Log: Make it possible to set the flags passed to the assembler. Nick, please review. Modified: llvm/trunk/include/llvm-c/lto.h llvm/trunk/tools/gold/gold-plugin.cpp llvm/trunk/tools/lto/LTOCodeGenerator.cpp llvm/trunk/tools/lto/LTOCodeGenerator.h llvm/trunk/tools/lto/lto.cpp Modified: llvm/trunk/include/llvm-c/lto.h URL: http://llvm.org/viewvc/llvm-project/llvm/trunk/include/llvm-c/lto.h?rev=110705&r1=110704&r2=110705&view=diff ============================================================================== --- llvm/trunk/include/llvm-c/lto.h (original) +++ llvm/trunk/include/llvm-c/lto.h Tue Aug 10 13:55:09 2010 @@ -220,6 +220,12 @@ extern void lto_codegen_set_assembler_path(lto_code_gen_t cg, const char* path); +/** + * Sets extra arguments that libLTO should pass to the assembler. + */ +extern void +lto_codegen_set_assembler_args(lto_code_gen_t cg, const char **args, + int nargs); /** * Adds to a list of all global symbols that must exist in the final Modified: llvm/trunk/tools/gold/gold-plugin.cpp URL: http://llvm.org/viewvc/llvm-project/llvm/trunk/tools/gold/gold-plugin.cpp?rev=110705&r1=110704&r2=110705&view=diff ============================================================================== --- llvm/trunk/tools/gold/gold-plugin.cpp (original) +++ llvm/trunk/tools/gold/gold-plugin.cpp Tue Aug 10 13:55:09 2010 @@ -66,6 +66,7 @@ static generate_bc generate_bc_file = BC_NO; static std::string bc_path; static std::string as_path; + static std::vector as_args; static std::vector pass_through; static std::string extra_library_path; static std::string triple; @@ -91,6 +92,9 @@ } else { as_path = opt.substr(strlen("as=")); } + } else if (opt.startswith("as-arg=")) { + llvm::StringRef item = opt.substr(strlen("as-arg=")); + as_args.push_back(item.str()); } else if (opt.startswith("extra-library-path=")) { extra_library_path = opt.substr(strlen("extra_library_path=")); } else if (opt.startswith("pass-through=")) { @@ -401,6 +405,14 @@ sys::Path p = sys::Program::FindProgramByName(options::as_path); lto_codegen_set_assembler_path(cg, p.c_str()); } + if (!options::as_args.empty()) { + std::vector as_args_p; + for (std::vector::iterator I = options::as_args.begin(), + E = options::as_args.end(); I != E; ++I) { + as_args_p.push_back(I->c_str()); + } + lto_codegen_set_assembler_args(cg, &as_args_p[0], as_args_p.size()); + } // Pass through extra options to the code generator. if (!options::extra.empty()) { for (std::vector::iterator it = options::extra.begin(); Modified: llvm/trunk/tools/lto/LTOCodeGenerator.cpp URL: http://llvm.org/viewvc/llvm-project/llvm/trunk/tools/lto/LTOCodeGenerator.cpp?rev=110705&r1=110704&r2=110705&view=diff ============================================================================== --- llvm/trunk/tools/lto/LTOCodeGenerator.cpp (original) +++ llvm/trunk/tools/lto/LTOCodeGenerator.cpp Tue Aug 10 13:55:09 2010 @@ -126,6 +126,14 @@ _assemblerPath = new sys::Path(path); } +void LTOCodeGenerator::setAssemblerArgs(const char** args, int nargs) +{ + for (int i = 0; i < nargs; ++i) { + const char *arg = args[i]; + _assemblerArgs.push_back(arg); + } +} + void LTOCodeGenerator::addMustPreserveSymbol(const char* sym) { _mustPreserveSymbols[sym] = 1; @@ -257,6 +265,11 @@ args.push_back("-c"); args.push_back("-x"); args.push_back("assembler"); + } else { + for (std::vector::iterator I = _assemblerArgs.begin(), + E = _assemblerArgs.end(); I != E; ++I) { + args.push_back(I->c_str()); + } } args.push_back("-o"); args.push_back(objPath.c_str()); Modified: llvm/trunk/tools/lto/LTOCodeGenerator.h URL: http://llvm.org/viewvc/llvm-project/llvm/trunk/tools/lto/LTOCodeGenerator.h?rev=110705&r1=110704&r2=110705&view=diff ============================================================================== --- llvm/trunk/tools/lto/LTOCodeGenerator.h (original) +++ llvm/trunk/tools/lto/LTOCodeGenerator.h Tue Aug 10 13:55:09 2010 @@ -37,6 +37,7 @@ bool setDebugInfo(lto_debug_model, std::string& errMsg); bool setCodePICModel(lto_codegen_model, std::string& errMsg); void setAssemblerPath(const char* path); + void setAssemblerArgs(const char** args, int nargs); void addMustPreserveSymbol(const char* sym); bool writeMergedModules(const char* path, std::string& errMsg); @@ -62,6 +63,7 @@ llvm::MemoryBuffer* _nativeObjectFile; std::vector _codegenOptions; llvm::sys::Path* _assemblerPath; + std::vector _assemblerArgs; }; #endif // LTO_CODE_GENERATOR_H Modified: llvm/trunk/tools/lto/lto.cpp URL: http://llvm.org/viewvc/llvm-project/llvm/trunk/tools/lto/lto.cpp?rev=110705&r1=110704&r2=110705&view=diff ============================================================================== --- llvm/trunk/tools/lto/lto.cpp (original) +++ llvm/trunk/tools/lto/lto.cpp Tue Aug 10 13:55:09 2010 @@ -218,6 +218,16 @@ cg->setAssemblerPath(path); } + +// +// sets extra arguments that libLTO should pass to the assembler +// +void lto_codegen_set_assembler_args(lto_code_gen_t cg, const char** args, + int nargs) +{ + cg->setAssemblerArgs(args, nargs); +} + // // adds to a list of all global symbols that must exist in the final // generated code. If a function is not listed there, it might be From evan.cheng at apple.com Tue Aug 10 14:30:20 2010 From: evan.cheng at apple.com (Evan Cheng) Date: Tue, 10 Aug 2010 19:30:20 -0000 Subject: [llvm-commits] [llvm] r110707 - in /llvm/trunk: lib/Target/ARM/ARMBaseRegisterInfo.cpp lib/Target/ARM/ARMISelLowering.cpp lib/Target/ARM/ARMMachineFunctionInfo.h lib/Target/ARM/ARMRegisterInfo.td lib/Target/ARM/Thumb1RegisterInfo.cpp test/CodeGen/Thumb/large-stack.ll test/CodeGen/Thumb2/2010-08-10-VarSizedAllocaBug.ll Message-ID: <20100810193020.344B92A6C12C@llvm.org> Author: evancheng Date: Tue Aug 10 14:30:19 2010 New Revision: 110707 URL: http://llvm.org/viewvc/llvm-project?rev=110707&view=rev Log: Re-apply r110655 with fixes. Epilogue must restore sp from fp if the function stack frame has a var-sized object. Also added a test case to check for the added benefit of this patch: it's optimizing away the unnecessary restore of sp from fp for some non-leaf functions. Added: llvm/trunk/test/CodeGen/Thumb2/2010-08-10-VarSizedAllocaBug.ll Modified: llvm/trunk/lib/Target/ARM/ARMBaseRegisterInfo.cpp llvm/trunk/lib/Target/ARM/ARMISelLowering.cpp llvm/trunk/lib/Target/ARM/ARMMachineFunctionInfo.h llvm/trunk/lib/Target/ARM/ARMRegisterInfo.td llvm/trunk/lib/Target/ARM/Thumb1RegisterInfo.cpp llvm/trunk/test/CodeGen/Thumb/large-stack.ll Modified: llvm/trunk/lib/Target/ARM/ARMBaseRegisterInfo.cpp URL: http://llvm.org/viewvc/llvm-project/llvm/trunk/lib/Target/ARM/ARMBaseRegisterInfo.cpp?rev=110707&r1=110706&r2=110707&view=diff ============================================================================== --- llvm/trunk/lib/Target/ARM/ARMBaseRegisterInfo.cpp (original) +++ llvm/trunk/lib/Target/ARM/ARMBaseRegisterInfo.cpp Tue Aug 10 14:30:19 2010 @@ -177,7 +177,7 @@ Reserved.set(ARM::SP); Reserved.set(ARM::PC); Reserved.set(ARM::FPSCR); - if (STI.isTargetDarwin() || hasFP(MF)) + if (hasFP(MF)) Reserved.set(FramePtr); // Some targets reserve R9. if (STI.isR9Reserved()) @@ -194,7 +194,7 @@ return true; case ARM::R7: case ARM::R11: - if (FramePtr == Reg && (STI.isTargetDarwin() || hasFP(MF))) + if (FramePtr == Reg && hasFP(MF)) return true; break; case ARM::R9: @@ -511,7 +511,7 @@ return std::make_pair(RC->allocation_order_begin(MF), RC->allocation_order_end(MF)); - if (!STI.isTargetDarwin() && !hasFP(MF)) { + if (!hasFP(MF)) { if (!STI.isR9Reserved()) return std::make_pair(GPREven1, GPREven1 + (sizeof(GPREven1)/sizeof(unsigned))); @@ -540,7 +540,7 @@ return std::make_pair(RC->allocation_order_begin(MF), RC->allocation_order_end(MF)); - if (!STI.isTargetDarwin() && !hasFP(MF)) { + if (!hasFP(MF)) { if (!STI.isR9Reserved()) return std::make_pair(GPROdd1, GPROdd1 + (sizeof(GPROdd1)/sizeof(unsigned))); @@ -610,6 +610,10 @@ /// or if frame pointer elimination is disabled. /// bool ARMBaseRegisterInfo::hasFP(const MachineFunction &MF) const { + // Mac OS X requires FP not to be clobbered for backtracing purpose. + if (STI.isTargetDarwin()) + return true; + const MachineFrameInfo *MFI = MF.getFrameInfo(); // Always eliminate non-leaf frame pointers. return ((DisableFramePointerElim(MF) && MFI->hasCalls()) || @@ -683,6 +687,7 @@ /// instructions will require a scratch register during their expansion later. unsigned ARMBaseRegisterInfo::estimateRSStackSizeLimit(MachineFunction &MF) const { + const ARMFunctionInfo *AFI = MF.getInfo(); unsigned Limit = (1 << 12) - 1; for (MachineFunction::iterator BB = MF.begin(),E = MF.end(); BB != E; ++BB) { for (MachineBasicBlock::iterator I = BB->begin(), E = BB->end(); @@ -708,7 +713,10 @@ Limit = std::min(Limit, ((1U << 8) - 1) * 4); break; case ARMII::AddrModeT2_i12: - if (hasFP(MF)) Limit = std::min(Limit, (1U << 8) - 1); + // i12 supports only positive offset so these will be converted to + // i8 opcodes. See llvm::rewriteT2FrameIndex. + if (hasFP(MF) && AFI->hasStackFrame()) + Limit = std::min(Limit, (1U << 8) - 1); break; case ARMII::AddrMode6: // Addressing mode 6 (load/store) instructions can't encode an @@ -860,8 +868,9 @@ // and which instructions will need a scratch register for them. Is it // worth the effort and added fragility? bool BigStack = - (RS && (estimateStackSize(MF) + (hasFP(MF) ? 4:0) >= - estimateRSStackSizeLimit(MF))) + (RS && + (estimateStackSize(MF) + ((hasFP(MF) && AFI->hasStackFrame()) ? 4:0) >= + estimateRSStackSizeLimit(MF))) || MFI->hasVarSizedObjects() || (MFI->adjustsStack() && !canSimplifyCallFramePseudos(MF)); @@ -881,9 +890,7 @@ ExtraCSSpill = true; } - // Darwin ABI requires FP to point to the stack slot that contains the - // previous FP. - if (STI.isTargetDarwin() || hasFP(MF)) { + if (hasFP(MF)) { MF.getRegInfo().setPhysRegUsed(FramePtr); NumGPRSpills++; } @@ -976,7 +983,7 @@ unsigned ARMBaseRegisterInfo::getFrameRegister(const MachineFunction &MF) const { - if (STI.isTargetDarwin() || hasFP(MF)) + if (hasFP(MF)) return FramePtr; return ARM::SP; } @@ -1546,7 +1553,8 @@ // Otherwise, if this is not Darwin, all the callee-saved registers go // into spill area 1, including the FP in R11. In either case, it is // now safe to emit this assignment. - if (STI.isTargetDarwin() || hasFP(MF)) { + bool HasFP = hasFP(MF); + if (HasFP) { unsigned ADDriOpc = !AFI->isThumbFunction() ? ARM::ADDri : ARM::t2ADDri; MachineInstrBuilder MIB = BuildMI(MBB, MBBI, dl, TII.get(ADDriOpc), FramePtr) @@ -1565,7 +1573,7 @@ unsigned DPRCSOffset = NumBytes - (GPRCS1Size + GPRCS2Size + DPRCSSize); unsigned GPRCS2Offset = DPRCSOffset + DPRCSSize; unsigned GPRCS1Offset = GPRCS2Offset + GPRCS2Size; - if (STI.isTargetDarwin() || hasFP(MF)) + if (HasFP) AFI->setFramePtrSpillOffset(MFI->getObjectOffset(FramePtrSpillFI) + NumBytes); AFI->setGPRCalleeSavedArea1Offset(GPRCS1Offset); @@ -1577,11 +1585,14 @@ if (NumBytes) { // Adjust SP after all the callee-save spills. emitSPUpdate(isARM, MBB, MBBI, dl, TII, -NumBytes); + if (HasFP) + AFI->setShouldRestoreSPFromFP(true); } if (STI.isTargetELF() && hasFP(MF)) { MFI->setOffsetAdjustment(MFI->getOffsetAdjustment() - AFI->getFramePtrSpillOffset()); + AFI->setShouldRestoreSPFromFP(true); } AFI->setGPRCalleeSavedArea1Size(GPRCS1Size); @@ -1614,7 +1625,14 @@ BuildMI(MBB, MBBI, dl, TII.get(ARM::tMOVtgpr2gpr), ARM::SP) .addReg(ARM::R4, RegState::Kill); } + + AFI->setShouldRestoreSPFromFP(true); } + + // If the frame has variable sized objects then the epilogue must restore + // the sp from fp. + if (!AFI->shouldRestoreSPFromFP() && MFI->hasVarSizedObjects()) + AFI->setShouldRestoreSPFromFP(true); } static bool isCalleeSavedRegister(unsigned Reg, const unsigned *CSRegs) { @@ -1669,34 +1687,25 @@ AFI->getGPRCalleeSavedArea2Size() + AFI->getDPRCalleeSavedAreaSize()); - // Darwin ABI requires FP to point to the stack slot that contains the - // previous FP. - bool HasFP = hasFP(MF); - if ((STI.isTargetDarwin() && NumBytes) || HasFP) { + // Reset SP based on frame pointer only if the stack frame extends beyond + // frame pointer stack slot or target is ELF and the function has FP. + if (AFI->shouldRestoreSPFromFP()) { NumBytes = AFI->getFramePtrSpillOffset() - NumBytes; - // Reset SP based on frame pointer only if the stack frame extends beyond - // frame pointer stack slot or target is ELF and the function has FP. - if (HasFP || - AFI->getGPRCalleeSavedArea2Size() || - AFI->getDPRCalleeSavedAreaSize() || - AFI->getDPRCalleeSavedAreaOffset()) { - if (NumBytes) { - if (isARM) - emitARMRegPlusImmediate(MBB, MBBI, dl, ARM::SP, FramePtr, -NumBytes, - ARMCC::AL, 0, TII); - else - emitT2RegPlusImmediate(MBB, MBBI, dl, ARM::SP, FramePtr, -NumBytes, - ARMCC::AL, 0, TII); - } else { - // Thumb2 or ARM. - if (isARM) - BuildMI(MBB, MBBI, dl, TII.get(ARM::MOVr), ARM::SP) - .addReg(FramePtr) - .addImm((unsigned)ARMCC::AL).addReg(0).addReg(0); - else - BuildMI(MBB, MBBI, dl, TII.get(ARM::tMOVgpr2gpr), ARM::SP) - .addReg(FramePtr); - } + if (NumBytes) { + if (isARM) + emitARMRegPlusImmediate(MBB, MBBI, dl, ARM::SP, FramePtr, -NumBytes, + ARMCC::AL, 0, TII); + else + emitT2RegPlusImmediate(MBB, MBBI, dl, ARM::SP, FramePtr, -NumBytes, + ARMCC::AL, 0, TII); + } else { + // Thumb2 or ARM. + if (isARM) + BuildMI(MBB, MBBI, dl, TII.get(ARM::MOVr), ARM::SP) + .addReg(FramePtr).addImm((unsigned)ARMCC::AL).addReg(0).addReg(0); + else + BuildMI(MBB, MBBI, dl, TII.get(ARM::tMOVgpr2gpr), ARM::SP) + .addReg(FramePtr); } } else if (NumBytes) emitSPUpdate(isARM, MBB, MBBI, dl, TII, NumBytes); Modified: llvm/trunk/lib/Target/ARM/ARMISelLowering.cpp URL: http://llvm.org/viewvc/llvm-project/llvm/trunk/lib/Target/ARM/ARMISelLowering.cpp?rev=110707&r1=110706&r2=110707&view=diff ============================================================================== --- llvm/trunk/lib/Target/ARM/ARMISelLowering.cpp (original) +++ llvm/trunk/lib/Target/ARM/ARMISelLowering.cpp Tue Aug 10 14:30:19 2010 @@ -742,14 +742,15 @@ unsigned ARMTargetLowering::getRegPressureLimit(const TargetRegisterClass *RC, MachineFunction &MF) const { - unsigned FPDiff = RegInfo->hasFP(MF) ? 1 : 0; switch (RC->getID()) { default: return 0; case ARM::tGPRRegClassID: - return 5 - FPDiff; - case ARM::GPRRegClassID: - return 10 - FPDiff - (Subtarget->isR9Reserved() ? 1 : 0); + return RegInfo->hasFP(MF) ? 4 : 5; + case ARM::GPRRegClassID: { + unsigned FP = RegInfo->hasFP(MF) ? 1 : 0; + return 10 - FP - (Subtarget->isR9Reserved() ? 1 : 0); + } case ARM::SPRRegClassID: // Currently not used as 'rep' register class. case ARM::DPRRegClassID: return 32 - 10; Modified: llvm/trunk/lib/Target/ARM/ARMMachineFunctionInfo.h URL: http://llvm.org/viewvc/llvm-project/llvm/trunk/lib/Target/ARM/ARMMachineFunctionInfo.h?rev=110707&r1=110706&r2=110707&view=diff ============================================================================== --- llvm/trunk/lib/Target/ARM/ARMMachineFunctionInfo.h (original) +++ llvm/trunk/lib/Target/ARM/ARMMachineFunctionInfo.h Tue Aug 10 14:30:19 2010 @@ -43,6 +43,10 @@ /// processFunctionBeforeCalleeSavedScan(). bool HasStackFrame; + /// RestoreSPFromFP - True if epilogue should restore SP from FP. Set by + /// emitPrologue. + bool RestoreSPFromFP; + /// LRSpilledForFarJump - True if the LR register has been for spilled to /// enable far jump. bool LRSpilledForFarJump; @@ -95,7 +99,7 @@ ARMFunctionInfo() : isThumb(false), hasThumb2(false), - VarArgsRegSaveSize(0), HasStackFrame(false), + VarArgsRegSaveSize(0), HasStackFrame(false), RestoreSPFromFP(false), LRSpilledForFarJump(false), FramePtrSpillOffset(0), GPRCS1Offset(0), GPRCS2Offset(0), DPRCSOffset(0), GPRCS1Size(0), GPRCS2Size(0), DPRCSSize(0), @@ -106,7 +110,7 @@ explicit ARMFunctionInfo(MachineFunction &MF) : isThumb(MF.getTarget().getSubtarget().isThumb()), hasThumb2(MF.getTarget().getSubtarget().hasThumb2()), - VarArgsRegSaveSize(0), HasStackFrame(false), + VarArgsRegSaveSize(0), HasStackFrame(false), RestoreSPFromFP(false), LRSpilledForFarJump(false), FramePtrSpillOffset(0), GPRCS1Offset(0), GPRCS2Offset(0), DPRCSOffset(0), GPRCS1Size(0), GPRCS2Size(0), DPRCSSize(0), @@ -125,6 +129,9 @@ bool hasStackFrame() const { return HasStackFrame; } void setHasStackFrame(bool s) { HasStackFrame = s; } + bool shouldRestoreSPFromFP() const { return RestoreSPFromFP; } + void setShouldRestoreSPFromFP(bool s) { RestoreSPFromFP = s; } + bool isLRSpilledForFarJump() const { return LRSpilledForFarJump; } void setLRIsSpilledForFarJump(bool s) { LRSpilledForFarJump = s; } Modified: llvm/trunk/lib/Target/ARM/ARMRegisterInfo.td URL: http://llvm.org/viewvc/llvm-project/llvm/trunk/lib/Target/ARM/ARMRegisterInfo.td?rev=110707&r1=110706&r2=110707&view=diff ============================================================================== --- llvm/trunk/lib/Target/ARM/ARMRegisterInfo.td (original) +++ llvm/trunk/lib/Target/ARM/ARMRegisterInfo.td Tue Aug 10 14:30:19 2010 @@ -294,8 +294,7 @@ if (Subtarget.isThumb1Only()) { I = THUMB_GPR_AO + (sizeof(THUMB_GPR_AO)/sizeof(unsigned)); - // Mac OS X requires FP not to be clobbered for backtracing purpose. - return (Subtarget.isTargetDarwin() || RI->hasFP(MF)) ? I-1 : I; + return RI->hasFP(MF) ? I-1 : I; } if (Subtarget.isTargetDarwin()) { @@ -312,8 +311,7 @@ I = ARM_GPR_AO_1 + (sizeof(ARM_GPR_AO_1)/sizeof(unsigned)); } - // Mac OS X requires FP not to be clobbered for backtracing purpose. - return (Subtarget.isTargetDarwin() || RI->hasFP(MF)) ? I-1 : I; + return RI->hasFP(MF) ? I-1 : I; } }]; } @@ -403,8 +401,7 @@ if (Subtarget.isThumb1Only()) { I = THUMB_rGPRAO + (sizeof(THUMB_rGPRAO)/sizeof(unsigned)); - // Mac OS X requires FP not to be clobbered for backtracing purpose. - return (Subtarget.isTargetDarwin() || RI->hasFP(MF)) ? I-1 : I; + return RI->hasFP(MF) ? I-1 : I; } if (Subtarget.isTargetDarwin()) { @@ -421,8 +418,7 @@ I = ARM_rGPRAO_1 + (sizeof(ARM_rGPRAO_1)/sizeof(unsigned)); } - // Mac OS X requires FP not to be clobbered for backtracing purpose. - return (Subtarget.isTargetDarwin() || RI->hasFP(MF)) ? I-1 : I; + return RI->hasFP(MF) ? I-1 : I; } }]; } @@ -449,11 +445,9 @@ tGPRClass::allocation_order_end(const MachineFunction &MF) const { const TargetMachine &TM = MF.getTarget(); const TargetRegisterInfo *RI = TM.getRegisterInfo(); - const ARMSubtarget &Subtarget = TM.getSubtarget(); tGPRClass::iterator I = THUMB_tGPR_AO + (sizeof(THUMB_tGPR_AO)/sizeof(unsigned)); - // Mac OS X requires FP not to be clobbered for backtracing purpose. - return (Subtarget.isTargetDarwin() || RI->hasFP(MF)) ? I-1 : I; + return RI->hasFP(MF) ? I-1 : I; } }]; } Modified: llvm/trunk/lib/Target/ARM/Thumb1RegisterInfo.cpp URL: http://llvm.org/viewvc/llvm-project/llvm/trunk/lib/Target/ARM/Thumb1RegisterInfo.cpp?rev=110707&r1=110706&r2=110707&view=diff ============================================================================== --- llvm/trunk/lib/Target/ARM/Thumb1RegisterInfo.cpp (original) +++ llvm/trunk/lib/Target/ARM/Thumb1RegisterInfo.cpp Tue Aug 10 14:30:19 2010 @@ -742,11 +742,11 @@ dl = MBBI->getDebugLoc(); } - // Darwin ABI requires FP to point to the stack slot that contains the - // previous FP. - if (STI.isTargetDarwin() || hasFP(MF)) { + // Adjust FP so it point to the stack slot that contains the previous FP. + if (hasFP(MF)) { BuildMI(MBB, MBBI, dl, TII.get(ARM::tADDrSPi), FramePtr) .addFrameIndex(FramePtrSpillFI).addImm(0); + AFI->setShouldRestoreSPFromFP(true); } // Determine starting offsets of spill areas. @@ -764,10 +764,9 @@ emitSPUpdate(MBB, MBBI, TII, dl, *this, -NumBytes); } - if (STI.isTargetELF() && hasFP(MF)) { + if (STI.isTargetELF() && hasFP(MF)) MFI->setOffsetAdjustment(MFI->getOffsetAdjustment() - AFI->getFramePtrSpillOffset()); - } AFI->setGPRCalleeSavedArea1Size(GPRCS1Size); AFI->setGPRCalleeSavedArea2Size(GPRCS2Size); @@ -828,7 +827,7 @@ AFI->getGPRCalleeSavedArea2Size() + AFI->getDPRCalleeSavedAreaSize()); - if (hasFP(MF)) { + if (AFI->shouldRestoreSPFromFP()) { NumBytes = AFI->getFramePtrSpillOffset() - NumBytes; // Reset SP based on frame pointer only if the stack frame extends beyond // frame pointer stack slot or target is ELF and the function has FP. Modified: llvm/trunk/test/CodeGen/Thumb/large-stack.ll URL: http://llvm.org/viewvc/llvm-project/llvm/trunk/test/CodeGen/Thumb/large-stack.ll?rev=110707&r1=110706&r2=110707&view=diff ============================================================================== --- llvm/trunk/test/CodeGen/Thumb/large-stack.ll (original) +++ llvm/trunk/test/CodeGen/Thumb/large-stack.ll Tue Aug 10 14:30:19 2010 @@ -1,20 +1,35 @@ -; RUN: llc < %s -march=thumb | grep {ldr.*LCP} | count 5 +; RUN: llc < %s -mtriple=thumb-apple-darwin | FileCheck %s define void @test1() { +; CHECK: test1: +; CHECK: sub sp, #256 +; CHECK: add sp, #256 %tmp = alloca [ 64 x i32 ] , align 4 ret void } define void @test2() { +; CHECK: test2: +; CHECK: ldr r0, LCPI +; CHECK: add sp, r0 +; CHECK: mov sp, r7 +; CHECK: sub sp, #4 %tmp = alloca [ 4168 x i8 ] , align 4 ret void } define i32 @test3() { - %retval = alloca i32, align 4 - %tmp = alloca i32, align 4 - %a = alloca [805306369 x i8], align 16 - store i32 0, i32* %tmp - %tmp1 = load i32* %tmp - ret i32 %tmp1 +; CHECK: test3: +; CHECK: ldr r1, LCPI +; CHECK: add sp, r1 +; CHECK: ldr r1, LCPI +; CHECK: add r1, sp +; CHECK: mov sp, r7 +; CHECK: sub sp, #4 + %retval = alloca i32, align 4 + %tmp = alloca i32, align 4 + %a = alloca [805306369 x i8], align 16 + store i32 0, i32* %tmp + %tmp1 = load i32* %tmp + ret i32 %tmp1 } Added: llvm/trunk/test/CodeGen/Thumb2/2010-08-10-VarSizedAllocaBug.ll URL: http://llvm.org/viewvc/llvm-project/llvm/trunk/test/CodeGen/Thumb2/2010-08-10-VarSizedAllocaBug.ll?rev=110707&view=auto ============================================================================== --- llvm/trunk/test/CodeGen/Thumb2/2010-08-10-VarSizedAllocaBug.ll (added) +++ llvm/trunk/test/CodeGen/Thumb2/2010-08-10-VarSizedAllocaBug.ll Tue Aug 10 14:30:19 2010 @@ -0,0 +1,53 @@ +; RUN: llc < %s -mtriple=thumbv7-apple-darwin -mcpu=cortex-a8 -O3 | FileCheck %s + + at .str = private constant [4 x i8] c"%d\0A\00", align 4 ; <[4 x i8]*> [#uses=1] + +define internal fastcc i32 @Callee(i32 %i) nounwind { +entry: +; CHECK: Callee: + %0 = icmp eq i32 %i, 0 ; [#uses=1] + br i1 %0, label %bb2, label %bb + +bb: ; preds = %entry + %1 = alloca [1000 x i8], align 4 ; <[1000 x i8]*> [#uses=1] + %.sub = getelementptr inbounds [1000 x i8]* %1, i32 0, i32 0 ; [#uses=2] + %2 = call i32 (i8*, i32, i32, i8*, ...)* @__sprintf_chk(i8* %.sub, i32 0, i32 1000, i8* getelementptr inbounds ([4 x i8]* @.str, i32 0, i32 0), i32 %i) nounwind ; [#uses=0] + %3 = load i8* %.sub, align 4 ; [#uses=1] + %4 = sext i8 %3 to i32 ; [#uses=1] + ret i32 %4 + +bb2: ; preds = %entry +; Must restore sp from fp here +; CHECK: mov sp, r7 +; CHECK: sub sp, #8 +; CHECK: pop + ret i32 0 +} + +declare i32 @__sprintf_chk(i8*, i32, i32, i8*, ...) nounwind + +define i32 @main() nounwind { +; CHECK: main: +bb.nph: + br label %bb + +bb: ; preds = %bb, %bb.nph + %0 = phi i32 [ 0, %bb.nph ], [ %3, %bb ] ; [#uses=2] + %j.01 = phi i32 [ 0, %bb.nph ], [ %2, %bb ] ; [#uses=1] + %1 = tail call fastcc i32 @Callee(i32 %0) nounwind ; [#uses=1] + %2 = add nsw i32 %1, %j.01 ; [#uses=2] + %3 = add nsw i32 %0, 1 ; [#uses=2] + %exitcond = icmp eq i32 %3, 10000 ; [#uses=1] + br i1 %exitcond, label %bb2, label %bb + +bb2: ; preds = %bb +; No need to restore sp from fp here. +; CHECK: printf +; CHECK-NOT: mov sp, r7 +; CHECK-NOT: sub sp, #12 +; CHECK: pop + %4 = tail call i32 (i8*, ...)* @printf(i8* getelementptr inbounds ([4 x i8]* @.str, i32 0, i32 0), i32 %2) nounwind ; [#uses=0] + ret i32 0 +} + +declare i32 @printf(i8* nocapture, ...) nounwind From evan.cheng at apple.com Tue Aug 10 14:36:22 2010 From: evan.cheng at apple.com (Evan Cheng) Date: Tue, 10 Aug 2010 19:36:22 -0000 Subject: [llvm-commits] [llvm] r110710 - in /llvm/trunk/lib/Target/ARM: ARMISelLowering.cpp ARMInstrThumb.td ARMInstrThumb2.td Message-ID: <20100810193622.B38232A6C12C@llvm.org> Author: evancheng Date: Tue Aug 10 14:36:22 2010 New Revision: 110710 URL: http://llvm.org/viewvc/llvm-project?rev=110710&view=rev Log: Delete some unused instructions. Modified: llvm/trunk/lib/Target/ARM/ARMISelLowering.cpp llvm/trunk/lib/Target/ARM/ARMInstrThumb.td llvm/trunk/lib/Target/ARM/ARMInstrThumb2.td Modified: llvm/trunk/lib/Target/ARM/ARMISelLowering.cpp URL: http://llvm.org/viewvc/llvm-project/llvm/trunk/lib/Target/ARM/ARMISelLowering.cpp?rev=110710&r1=110709&r2=110710&view=diff ============================================================================== --- llvm/trunk/lib/Target/ARM/ARMISelLowering.cpp (original) +++ llvm/trunk/lib/Target/ARM/ARMISelLowering.cpp Tue Aug 10 14:36:22 2010 @@ -4095,78 +4095,6 @@ MI->eraseFromParent(); // The pseudo instruction is gone now. return BB; } - - case ARM::tANDsp: - case ARM::tADDspr_: - case ARM::tSUBspi_: - case ARM::t2SUBrSPi_: - case ARM::t2SUBrSPi12_: - case ARM::t2SUBrSPs_: { - MachineFunction *MF = BB->getParent(); - unsigned DstReg = MI->getOperand(0).getReg(); - unsigned SrcReg = MI->getOperand(1).getReg(); - bool DstIsDead = MI->getOperand(0).isDead(); - bool SrcIsKill = MI->getOperand(1).isKill(); - - if (SrcReg != ARM::SP) { - // Copy the source to SP from virtual register. - const TargetRegisterClass *RC = MF->getRegInfo().getRegClass(SrcReg); - unsigned CopyOpc = (RC == ARM::tGPRRegisterClass) - ? ARM::tMOVtgpr2gpr : ARM::tMOVgpr2gpr; - BuildMI(*BB, MI, dl, TII->get(CopyOpc), ARM::SP) - .addReg(SrcReg, getKillRegState(SrcIsKill)); - } - - unsigned OpOpc = 0; - bool NeedPred = false, NeedCC = false, NeedOp3 = false; - switch (MI->getOpcode()) { - default: - llvm_unreachable("Unexpected pseudo instruction!"); - case ARM::tANDsp: - OpOpc = ARM::tAND; - NeedPred = true; - break; - case ARM::tADDspr_: - OpOpc = ARM::tADDspr; - break; - case ARM::tSUBspi_: - OpOpc = ARM::tSUBspi; - break; - case ARM::t2SUBrSPi_: - OpOpc = ARM::t2SUBrSPi; - NeedPred = true; NeedCC = true; - break; - case ARM::t2SUBrSPi12_: - OpOpc = ARM::t2SUBrSPi12; - NeedPred = true; - break; - case ARM::t2SUBrSPs_: - OpOpc = ARM::t2SUBrSPs; - NeedPred = true; NeedCC = true; NeedOp3 = true; - break; - } - MachineInstrBuilder MIB = BuildMI(*BB, MI, dl, TII->get(OpOpc), ARM::SP); - if (OpOpc == ARM::tAND) - AddDefaultT1CC(MIB); - MIB.addReg(ARM::SP); - MIB.addOperand(MI->getOperand(2)); - if (NeedOp3) - MIB.addOperand(MI->getOperand(3)); - if (NeedPred) - AddDefaultPred(MIB); - if (NeedCC) - AddDefaultCC(MIB); - - // Copy the result from SP to virtual register. - const TargetRegisterClass *RC = MF->getRegInfo().getRegClass(DstReg); - unsigned CopyOpc = (RC == ARM::tGPRRegisterClass) - ? ARM::tMOVgpr2tgpr : ARM::tMOVgpr2gpr; - BuildMI(*BB, MI, dl, TII->get(CopyOpc)) - .addReg(DstReg, getDefRegState(true) | getDeadRegState(DstIsDead)) - .addReg(ARM::SP); - MI->eraseFromParent(); // The pseudo instruction is gone now. - return BB; - } } } Modified: llvm/trunk/lib/Target/ARM/ARMInstrThumb.td URL: http://llvm.org/viewvc/llvm-project/llvm/trunk/lib/Target/ARM/ARMInstrThumb.td?rev=110710&r1=110709&r2=110710&view=diff ============================================================================== --- llvm/trunk/lib/Target/ARM/ARMInstrThumb.td (original) +++ llvm/trunk/lib/Target/ARM/ARMInstrThumb.td Tue Aug 10 14:36:22 2010 @@ -251,19 +251,6 @@ let Inst{2-0} = 0b101; } -// Pseudo instruction that will expand into a tSUBspi + a copy. -let usesCustomInserter = 1 in { // Expanded after instruction selection. -def tSUBspi_ : PseudoInst<(outs GPR:$dst), (ins GPR:$lhs, t_imm_s4:$rhs), - NoItinerary, "${:comment} sub\t$dst, $rhs", []>; - -def tADDspr_ : PseudoInst<(outs GPR:$dst), (ins GPR:$lhs, GPR:$rhs), - NoItinerary, "${:comment} add\t$dst, $rhs", []>; - -let Defs = [CPSR] in -def tANDsp : PseudoInst<(outs tGPR:$dst), (ins tGPR:$lhs, tGPR:$rhs), - NoItinerary, "${:comment} and\t$dst, $rhs", []>; -} // usesCustomInserter - //===----------------------------------------------------------------------===// // Control Flow Instructions. // Modified: llvm/trunk/lib/Target/ARM/ARMInstrThumb2.td URL: http://llvm.org/viewvc/llvm-project/llvm/trunk/lib/Target/ARM/ARMInstrThumb2.td?rev=110710&r1=110709&r2=110710&view=diff ============================================================================== --- llvm/trunk/lib/Target/ARM/ARMInstrThumb2.td (original) +++ llvm/trunk/lib/Target/ARM/ARMInstrThumb2.td Tue Aug 10 14:36:22 2010 @@ -888,20 +888,6 @@ let Inst{7-4} = 0b1111; } -// Pseudo instruction that will expand into a t2SUBrSPi + a copy. -// FIXME: Now that we have rGPR, do we need these pseudos? It seems -// that the coalescer will now properly know how to do the right -// thing without them. -let usesCustomInserter = 1 in { // Expanded after instruction selection. -def t2SUBrSPi_ : PseudoInst<(outs GPR:$dst), (ins GPR:$sp, t2_so_imm:$imm), - NoItinerary, "${:comment} sub.w\t$dst, $sp, $imm", []>; -def t2SUBrSPi12_ : PseudoInst<(outs GPR:$dst), (ins GPR:$sp, imm0_4095:$imm), - NoItinerary, "${:comment} subw\t$dst, $sp, $imm", []>; -def t2SUBrSPs_ : PseudoInst<(outs GPR:$dst), (ins GPR:$sp, t2_so_reg:$rhs), - NoItinerary, "${:comment} sub\t$dst, $sp, $rhs", []>; -} // usesCustomInserter - - //===----------------------------------------------------------------------===// // Load / store Instructions. // From daniel at zuster.org Tue Aug 10 14:36:25 2010 From: daniel at zuster.org (Daniel Dunbar) Date: Tue, 10 Aug 2010 19:36:25 -0000 Subject: [llvm-commits] [llvm] r110711 - /llvm/trunk/test/lit.cfg Message-ID: <20100810193625.EE7182A6C12D@llvm.org> Author: ddunbar Date: Tue Aug 10 14:36:25 2010 New Revision: 110711 URL: http://llvm.org/viewvc/llvm-project?rev=110711&view=rev Log: tests: Don't error out if HOME isn't present in t the environment. Modified: llvm/trunk/test/lit.cfg Modified: llvm/trunk/test/lit.cfg URL: http://llvm.org/viewvc/llvm-project/llvm/trunk/test/lit.cfg?rev=110711&r1=110710&r2=110711&view=diff ============================================================================== --- llvm/trunk/test/lit.cfg (original) +++ llvm/trunk/test/lit.cfg Tue Aug 10 14:36:25 2010 @@ -46,7 +46,8 @@ config.environment['PATH'] = path # Propogate 'HOME' through the environment. -config.environment['HOME'] = os.environ['HOME'] +if 'HOME' in os.environ: + config.environment['HOME'] = os.environ['HOME'] # Propogate LLVM_SRC_ROOT into the environment. config.environment['LLVM_SRC_ROOT'] = getattr(config, 'llvm_src_root', '') From dpatel at apple.com Tue Aug 10 15:01:20 2010 From: dpatel at apple.com (Devang Patel) Date: Tue, 10 Aug 2010 20:01:20 -0000 Subject: [llvm-commits] [llvm] r110712 - in /llvm/trunk/lib: Analysis/DebugInfo.cpp CodeGen/AsmPrinter/DwarfDebug.cpp Message-ID: <20100810200120.38BC82A6C12C@llvm.org> Author: dpatel Date: Tue Aug 10 15:01:20 2010 New Revision: 110712 URL: http://llvm.org/viewvc/llvm-project?rev=110712&view=rev Log: Do not forget debug info for enums. Use named mdnode to keep track of these types. Modified: llvm/trunk/lib/Analysis/DebugInfo.cpp llvm/trunk/lib/CodeGen/AsmPrinter/DwarfDebug.cpp Modified: llvm/trunk/lib/Analysis/DebugInfo.cpp URL: http://llvm.org/viewvc/llvm-project/llvm/trunk/lib/Analysis/DebugInfo.cpp?rev=110712&r1=110711&r2=110712&view=diff ============================================================================== --- llvm/trunk/lib/Analysis/DebugInfo.cpp (original) +++ llvm/trunk/lib/Analysis/DebugInfo.cpp Tue Aug 10 15:01:20 2010 @@ -923,7 +923,14 @@ ConstantInt::get(Type::getInt32Ty(VMContext), RuntimeLang), ContainingType }; - return DICompositeType(MDNode::get(VMContext, &Elts[0], 13)); + + MDNode *Node = MDNode::get(VMContext, &Elts[0], 13); + // Create a named metadata so that we do not lose this enum info. + if (Tag == dwarf::DW_TAG_enumeration_type) { + NamedMDNode *NMD = M.getOrInsertNamedMetadata("llvm.dbg.enum"); + NMD->addOperand(Node); + } + return DICompositeType(Node); } @@ -955,7 +962,13 @@ Elements, ConstantInt::get(Type::getInt32Ty(VMContext), RuntimeLang) }; - return DICompositeType(MDNode::get(VMContext, &Elts[0], 12)); + MDNode *Node = MDNode::get(VMContext, &Elts[0], 12); + // Create a named metadata so that we do not lose this enum info. + if (Tag == dwarf::DW_TAG_enumeration_type) { + NamedMDNode *NMD = M.getOrInsertNamedMetadata("llvm.dbg.enum"); + NMD->addOperand(Node); + } + return DICompositeType(Node); } Modified: llvm/trunk/lib/CodeGen/AsmPrinter/DwarfDebug.cpp URL: http://llvm.org/viewvc/llvm-project/llvm/trunk/lib/CodeGen/AsmPrinter/DwarfDebug.cpp?rev=110712&r1=110711&r2=110712&view=diff ============================================================================== --- llvm/trunk/lib/CodeGen/AsmPrinter/DwarfDebug.cpp (original) +++ llvm/trunk/lib/CodeGen/AsmPrinter/DwarfDebug.cpp Tue Aug 10 15:01:20 2010 @@ -2019,6 +2019,11 @@ E = DbgFinder.global_variable_end(); I != E; ++I) constructGlobalVariableDIE(*I); + //getOrCreateTypeDIE + if (NamedMDNode *NMD = M->getNamedMetadata("llvm.dbg.enum")) + for (unsigned i = 0, e = NMD->getNumOperands(); i != e; ++i) + getOrCreateTypeDIE(DIType(NMD->getOperand(i))); + // Prime section data. SectionMap.insert(Asm->getObjFileLowering().getTextSection()); From resistor at mac.com Tue Aug 10 15:03:09 2010 From: resistor at mac.com (Owen Anderson) Date: Tue, 10 Aug 2010 20:03:09 -0000 Subject: [llvm-commits] [llvm] r110714 - /llvm/trunk/lib/Analysis/LazyValueInfo.cpp Message-ID: <20100810200309.9C6AB2A6C12C@llvm.org> Author: resistor Date: Tue Aug 10 15:03:09 2010 New Revision: 110714 URL: http://llvm.org/viewvc/llvm-project?rev=110714&view=rev Log: Switch over to using ConstantRange to track integral values. Modified: llvm/trunk/lib/Analysis/LazyValueInfo.cpp Modified: llvm/trunk/lib/Analysis/LazyValueInfo.cpp URL: http://llvm.org/viewvc/llvm-project/llvm/trunk/lib/Analysis/LazyValueInfo.cpp?rev=110714&r1=110713&r2=110714&view=diff ============================================================================== --- llvm/trunk/lib/Analysis/LazyValueInfo.cpp (original) +++ llvm/trunk/lib/Analysis/LazyValueInfo.cpp Tue Aug 10 15:03:09 2010 @@ -77,12 +77,18 @@ static LVILatticeVal get(Constant *C) { LVILatticeVal Res; - Res.markConstant(C); + if (ConstantInt *CI = dyn_cast(C)) + Res.markConstantRange(ConstantRange(CI->getValue(), CI->getValue()+1)); + else if (!isa(C)) + Res.markConstant(C); return Res; } static LVILatticeVal getNot(Constant *C) { LVILatticeVal Res; - Res.markNotConstant(C); + if (ConstantInt *CI = dyn_cast(C)) + Res.markConstantRange(ConstantRange(CI->getValue()+1, CI->getValue())); + else + Res.markNotConstant(C); return Res; } @@ -154,8 +160,6 @@ if (NewR.isEmptySet()) return markOverdefined(); - assert(Range.contains(NewR) && - "Marking constant range with non-subset range!"); bool changed = Range == NewR; Range = NewR; return changed; @@ -202,8 +206,8 @@ if (RHS.isConstantRange()) { if (isConstantRange()) { - ConstantRange NewR = Range.intersectWith(RHS.getConstantRange()); - if (NewR.isEmptySet()) + ConstantRange NewR = Range.unionWith(RHS.getConstantRange()); + if (NewR.isFullSet()) return markOverdefined(); else return markConstantRange(NewR); @@ -498,7 +502,7 @@ // it is. if (BI->getCondition() == Val) return LVILatticeVal::get(ConstantInt::get( - Type::getInt1Ty(Val->getContext()), isTrueDest)); + Type::getInt1Ty(Val->getContext()), isTrueDest)); // If the condition of the branch is an equality comparison, we may be // able to infer the value. @@ -679,6 +683,11 @@ if (Result.isConstant()) return Result.getConstant(); + else if (Result.isConstantRange()) { + ConstantRange CR = Result.getConstantRange(); + if (const APInt *SingleVal = CR.getSingleElement()) + return ConstantInt::get(V->getContext(), *SingleVal); + } return 0; } @@ -699,6 +708,34 @@ return Unknown; } + if (Result.isConstantRange()) { + ConstantInt *CI = cast(C); + ConstantRange CR = Result.getConstantRange(); + if (Pred == ICmpInst::ICMP_EQ) { + if (!CR.contains(CI->getValue())) + return False; + + if (CR.isSingleElement() && CR.contains(CI->getValue())) + return True; + } else if (Pred == ICmpInst::ICMP_NE) { + if (!CR.contains(CI->getValue())) + return True; + + if (CR.isSingleElement() && CR.contains(CI->getValue())) + return False; + } + + // Handle more complex predicates. + ConstantRange RHS(CI->getValue(), CI->getValue()+1); + ConstantRange TrueValues = ConstantRange::makeICmpRegion(Pred, RHS); + if (CR.intersectWith(TrueValues).isEmptySet()) + return False; + else if (CR.intersectWith(TrueValues) == CR) + return True; + + return Unknown; + } + if (Result.isNotConstant()) { // If this is an equality comparison, we can try to fold it knowing that // "V != C1". From dpatel at apple.com Tue Aug 10 15:22:50 2010 From: dpatel at apple.com (Devang Patel) Date: Tue, 10 Aug 2010 20:22:50 -0000 Subject: [llvm-commits] [llvm] r110717 - in /llvm/trunk: include/llvm/Analysis/DebugInfo.h lib/Analysis/DebugInfo.cpp Message-ID: <20100810202250.2B7A52A6C12C@llvm.org> Author: dpatel Date: Tue Aug 10 15:22:49 2010 New Revision: 110717 URL: http://llvm.org/viewvc/llvm-project?rev=110717&view=rev Log: Add missing argument. CreateCompositeTypeEx() users, please verify. Modified: llvm/trunk/include/llvm/Analysis/DebugInfo.h llvm/trunk/lib/Analysis/DebugInfo.cpp Modified: llvm/trunk/include/llvm/Analysis/DebugInfo.h URL: http://llvm.org/viewvc/llvm-project/llvm/trunk/include/llvm/Analysis/DebugInfo.h?rev=110717&r1=110716&r2=110717&view=diff ============================================================================== --- llvm/trunk/include/llvm/Analysis/DebugInfo.h (original) +++ llvm/trunk/include/llvm/Analysis/DebugInfo.h Tue Aug 10 15:22:49 2010 @@ -668,7 +668,8 @@ unsigned Flags, DIType DerivedFrom, DIArray Elements, - unsigned RunTimeLang = 0); + unsigned RunTimeLang = 0, + MDNode *ContainingType = 0); /// CreateSubprogram - Create a new descriptor for the specified subprogram. /// See comments in DISubprogram for descriptions of these fields. Modified: llvm/trunk/lib/Analysis/DebugInfo.cpp URL: http://llvm.org/viewvc/llvm-project/llvm/trunk/lib/Analysis/DebugInfo.cpp?rev=110717&r1=110716&r2=110717&view=diff ============================================================================== --- llvm/trunk/lib/Analysis/DebugInfo.cpp (original) +++ llvm/trunk/lib/Analysis/DebugInfo.cpp Tue Aug 10 15:22:49 2010 @@ -946,8 +946,8 @@ unsigned Flags, DIType DerivedFrom, DIArray Elements, - unsigned RuntimeLang) { - + unsigned RuntimeLang, + MDNode *ContainingType) { Value *Elts[] = { GetTagConstant(Tag), Context, @@ -960,9 +960,10 @@ ConstantInt::get(Type::getInt32Ty(VMContext), Flags), DerivedFrom, Elements, - ConstantInt::get(Type::getInt32Ty(VMContext), RuntimeLang) + ConstantInt::get(Type::getInt32Ty(VMContext), RuntimeLang), + ContainingType }; - MDNode *Node = MDNode::get(VMContext, &Elts[0], 12); + MDNode *Node = MDNode::get(VMContext, &Elts[0], 13); // Create a named metadata so that we do not lose this enum info. if (Tag == dwarf::DW_TAG_enumeration_type) { NamedMDNode *NMD = M.getOrInsertNamedMetadata("llvm.dbg.enum"); From isanbard at gmail.com Tue Aug 10 15:23:02 2010 From: isanbard at gmail.com (Bill Wendling) Date: Tue, 10 Aug 2010 20:23:02 -0000 Subject: [llvm-commits] [llvm] r110718 - /llvm/trunk/lib/CodeGen/PeepholeOptimizer.cpp Message-ID: <20100810202302.6529E2A6C12C@llvm.org> Author: void Date: Tue Aug 10 15:23:02 2010 New Revision: 110718 URL: http://llvm.org/viewvc/llvm-project?rev=110718&view=rev Log: Turn optimize cmps on by default so that we can get some testing by the nightly ARM testers. Modified: llvm/trunk/lib/CodeGen/PeepholeOptimizer.cpp Modified: llvm/trunk/lib/CodeGen/PeepholeOptimizer.cpp URL: http://llvm.org/viewvc/llvm-project/llvm/trunk/lib/CodeGen/PeepholeOptimizer.cpp?rev=110718&r1=110717&r2=110718&view=diff ============================================================================== --- llvm/trunk/lib/CodeGen/PeepholeOptimizer.cpp (original) +++ llvm/trunk/lib/CodeGen/PeepholeOptimizer.cpp Tue Aug 10 15:23:02 2010 @@ -54,7 +54,7 @@ // Optimize Comparisons static cl::opt -EnableOptCmps("enable-optimize-cmps", cl::init(false), cl::Hidden); +EnableOptCmps("enable-optimize-cmps", cl::init(true), cl::Hidden); STATISTIC(NumEliminated, "Number of compares eliminated"); From stoklund at 2pi.dk Tue Aug 10 15:45:01 2010 From: stoklund at 2pi.dk (Jakob Stoklund Olesen) Date: Tue, 10 Aug 2010 20:45:01 -0000 Subject: [llvm-commits] [llvm] r110720 - /llvm/trunk/lib/CodeGen/SplitKit.cpp Message-ID: <20100810204501.EE88A2A6C12C@llvm.org> Author: stoklund Date: Tue Aug 10 15:45:01 2010 New Revision: 110720 URL: http://llvm.org/viewvc/llvm-project?rev=110720&view=rev Log: More debug spew Modified: llvm/trunk/lib/CodeGen/SplitKit.cpp Modified: llvm/trunk/lib/CodeGen/SplitKit.cpp URL: http://llvm.org/viewvc/llvm-project/llvm/trunk/lib/CodeGen/SplitKit.cpp?rev=110720&r1=110719&r2=110720&view=diff ============================================================================== --- llvm/trunk/lib/CodeGen/SplitKit.cpp (original) +++ llvm/trunk/lib/CodeGen/SplitKit.cpp Tue Aug 10 15:45:01 2010 @@ -573,6 +573,8 @@ LiveInterval &li = *intervals_[i]; vrai.CalculateRegClass(li.reg); vrai.CalculateWeightAndHint(li); + DEBUG(dbgs() << "new intv " << mri_.getRegClass(li.reg)->getName() << ":" + << li << '\n'); } } From stoklund at 2pi.dk Tue Aug 10 15:45:07 2010 From: stoklund at 2pi.dk (Jakob Stoklund Olesen) Date: Tue, 10 Aug 2010 20:45:07 -0000 Subject: [llvm-commits] [llvm] r110721 - /llvm/trunk/lib/CodeGen/InlineSpiller.cpp Message-ID: <20100810204507.CEE8A2A6C12D@llvm.org> Author: stoklund Date: Tue Aug 10 15:45:07 2010 New Revision: 110721 URL: http://llvm.org/viewvc/llvm-project?rev=110721&view=rev Log: Avoid editing the current live interval during remat. The live interval may be used for a spill slot as well, and that spill slot could be shared by split registers. We cannot shrink it, even if we know the current register won't need the spill slot in that range. Modified: llvm/trunk/lib/CodeGen/InlineSpiller.cpp Modified: llvm/trunk/lib/CodeGen/InlineSpiller.cpp URL: http://llvm.org/viewvc/llvm-project/llvm/trunk/lib/CodeGen/InlineSpiller.cpp?rev=110721&r1=110720&r2=110721&view=diff ============================================================================== --- llvm/trunk/lib/CodeGen/InlineSpiller.cpp (original) +++ llvm/trunk/lib/CodeGen/InlineSpiller.cpp Tue Aug 10 15:45:07 2010 @@ -270,7 +270,7 @@ lis_.RemoveMachineInstrFromMaps(DefMI); vrm_.RemoveMachineInstrFromMaps(DefMI); DefMI->eraseFromParent(); - li_->removeValNo(VNI); + VNI->setIsDefAccurate(false); anyRemoved = true; } @@ -286,8 +286,8 @@ MachineBasicBlock::iterator NextMI = MI; ++NextMI; if (NextMI != MI->getParent()->end() && !lis_.isNotInMIMap(NextMI)) { - SlotIndex NearIdx = lis_.getInstructionIndex(NextMI); - if (li_->liveAt(NearIdx)) + VNInfo *VNI = li_->getVNInfoAt(lis_.getInstructionIndex(NextMI)); + if (VNI && (VNI->hasPHIKill() || usedValues_.count(VNI))) continue; } DEBUG(dbgs() << "Removing debug info due to remat:" << "\t" << *MI); From gohman at apple.com Tue Aug 10 15:49:33 2010 From: gohman at apple.com (Dan Gohman) Date: Tue, 10 Aug 2010 20:49:33 -0000 Subject: [llvm-commits] [llvm] r110726 - /llvm/trunk/lib/CodeGen/PeepholeOptimizer.cpp Message-ID: <20100810204933.4E9642A6C12C@llvm.org> Author: djg Date: Tue Aug 10 15:49:33 2010 New Revision: 110726 URL: http://llvm.org/viewvc/llvm-project?rev=110726&view=rev Log: Revert r110718; it broke clang-i386-darwin9. Modified: llvm/trunk/lib/CodeGen/PeepholeOptimizer.cpp Modified: llvm/trunk/lib/CodeGen/PeepholeOptimizer.cpp URL: http://llvm.org/viewvc/llvm-project/llvm/trunk/lib/CodeGen/PeepholeOptimizer.cpp?rev=110726&r1=110725&r2=110726&view=diff ============================================================================== --- llvm/trunk/lib/CodeGen/PeepholeOptimizer.cpp (original) +++ llvm/trunk/lib/CodeGen/PeepholeOptimizer.cpp Tue Aug 10 15:49:33 2010 @@ -54,7 +54,7 @@ // Optimize Comparisons static cl::opt -EnableOptCmps("enable-optimize-cmps", cl::init(true), cl::Hidden); +EnableOptCmps("enable-optimize-cmps", cl::init(false), cl::Hidden); STATISTIC(NumEliminated, "Number of compares eliminated"); From grosbach at apple.com Tue Aug 10 15:50:53 2010 From: grosbach at apple.com (Jim Grosbach) Date: Tue, 10 Aug 2010 20:50:53 -0000 Subject: [llvm-commits] [llvm-gcc-4.2] r110727 - /llvm-gcc-4.2/trunk/gcc/objc/ChangeLog.apple Message-ID: <20100810205053.CE2372A6C12C@llvm.org> Author: grosbach Date: Tue Aug 10 15:50:53 2010 New Revision: 110727 URL: http://llvm.org/viewvc/llvm-project?rev=110727&view=rev Log: add changelog entry for 8290584 Modified: llvm-gcc-4.2/trunk/gcc/objc/ChangeLog.apple Modified: llvm-gcc-4.2/trunk/gcc/objc/ChangeLog.apple URL: http://llvm.org/viewvc/llvm-project/llvm-gcc-4.2/trunk/gcc/objc/ChangeLog.apple?rev=110727&r1=110726&r2=110727&view=diff ============================================================================== --- llvm-gcc-4.2/trunk/gcc/objc/ChangeLog.apple (original) +++ llvm-gcc-4.2/trunk/gcc/objc/ChangeLog.apple Tue Aug 10 15:50:53 2010 @@ -1,3 +1,11 @@ +2010-07-10 Fariborz Jahanian + + Radar 8290584 + * objc-act.c (objc_resolve_build_property_setter_name): Lookup + property name in the receiver's protocol list when it is of + qualified id type. + * objc.dg/qualified-id-property.m: New + 2010-04-02 Fariborz Jahanian Radar 7591784 From stoklund at 2pi.dk Tue Aug 10 16:16:16 2010 From: stoklund at 2pi.dk (Jakob Stoklund Olesen) Date: Tue, 10 Aug 2010 21:16:16 -0000 Subject: [llvm-commits] [llvm] r110730 - /llvm/trunk/lib/CodeGen/CalcSpillWeights.cpp Message-ID: <20100810211616.F342A2A6C12C@llvm.org> Author: stoklund Date: Tue Aug 10 16:16:16 2010 New Revision: 110730 URL: http://llvm.org/viewvc/llvm-project?rev=110730&view=rev Log: Give up on register class recalculation when the register is used with subreg operands. We don't currently have a hook to provide "the largest super class of A where all registers' getSubReg(subidx) is valid and in B". Modified: llvm/trunk/lib/CodeGen/CalcSpillWeights.cpp Modified: llvm/trunk/lib/CodeGen/CalcSpillWeights.cpp URL: http://llvm.org/viewvc/llvm-project/llvm/trunk/lib/CodeGen/CalcSpillWeights.cpp?rev=110730&r1=110729&r2=110730&view=diff ============================================================================== --- llvm/trunk/lib/CodeGen/CalcSpillWeights.cpp (original) +++ llvm/trunk/lib/CodeGen/CalcSpillWeights.cpp Tue Aug 10 16:16:16 2010 @@ -181,10 +181,19 @@ SmallPtrSet rcs; for (MachineRegisterInfo::reg_nodbg_iterator I = mri.reg_nodbg_begin(reg), - E = mri.reg_nodbg_end(); I != E; ++I) + E = mri.reg_nodbg_end(); I != E; ++I) { + // The targets don't have accurate enough regclass descriptions that we can + // handle subregs. We need something similar to + // TRI::getMatchingSuperRegClass, but returning a super class instead of a + // sub class. + if (I.getOperand().getSubReg()) { + DEBUG(dbgs() << "Cannot handle subregs: " << I.getOperand() << '\n'); + return; + } if (const TargetRegisterClass *rc = I->getDesc().getRegClass(I.getOperandNo(), tri)) rcs.insert(rc); + } // If we found no regclass constraints, just leave reg as is. // In theory, we could inflate to the largest superclass of reg's existing From isanbard at gmail.com Tue Aug 10 16:38:12 2010 From: isanbard at gmail.com (Bill Wendling) Date: Tue, 10 Aug 2010 21:38:12 -0000 Subject: [llvm-commits] [llvm] r110733 - in /llvm/trunk/lib: CodeGen/PeepholeOptimizer.cpp Target/ARM/ARMBaseInstrInfo.cpp Message-ID: <20100810213812.149D42A6C12C@llvm.org> Author: void Date: Tue Aug 10 16:38:11 2010 New Revision: 110733 URL: http://llvm.org/viewvc/llvm-project?rev=110733&view=rev Log: Turn optimize compares back on with fix. We needed to test that a machine op was a register before checking if it was defined. Modified: llvm/trunk/lib/CodeGen/PeepholeOptimizer.cpp llvm/trunk/lib/Target/ARM/ARMBaseInstrInfo.cpp Modified: llvm/trunk/lib/CodeGen/PeepholeOptimizer.cpp URL: http://llvm.org/viewvc/llvm-project/llvm/trunk/lib/CodeGen/PeepholeOptimizer.cpp?rev=110733&r1=110732&r2=110733&view=diff ============================================================================== --- llvm/trunk/lib/CodeGen/PeepholeOptimizer.cpp (original) +++ llvm/trunk/lib/CodeGen/PeepholeOptimizer.cpp Tue Aug 10 16:38:11 2010 @@ -54,7 +54,7 @@ // Optimize Comparisons static cl::opt -EnableOptCmps("enable-optimize-cmps", cl::init(false), cl::Hidden); +EnableOptCmps("enable-optimize-cmps", cl::init(true), cl::Hidden); STATISTIC(NumEliminated, "Number of compares eliminated"); Modified: llvm/trunk/lib/Target/ARM/ARMBaseInstrInfo.cpp URL: http://llvm.org/viewvc/llvm-project/llvm/trunk/lib/Target/ARM/ARMBaseInstrInfo.cpp?rev=110733&r1=110732&r2=110733&view=diff ============================================================================== --- llvm/trunk/lib/Target/ARM/ARMBaseInstrInfo.cpp (original) +++ llvm/trunk/lib/Target/ARM/ARMBaseInstrInfo.cpp Tue Aug 10 16:38:11 2010 @@ -1386,7 +1386,7 @@ for (unsigned IO = 0, EO = Instr.getNumOperands(); IO != EO; ++IO) { const MachineOperand &MO = Instr.getOperand(IO); - if (!MO.isDef() || !MO.isReg()) continue; + if (!MO.isReg() || !MO.isDef()) continue; // This instruction modifies CPSR before the one we want to change. We // can't do this transformation. From natebegeman at mac.com Tue Aug 10 16:38:12 2010 From: natebegeman at mac.com (Nate Begeman) Date: Tue, 10 Aug 2010 21:38:12 -0000 Subject: [llvm-commits] [llvm] r110734 - /llvm/trunk/lib/Transforms/InstCombine/InstCombineVectorOps.cpp Message-ID: <20100810213813.042492A6C12D@llvm.org> Author: sampo Date: Tue Aug 10 16:38:12 2010 New Revision: 110734 URL: http://llvm.org/viewvc/llvm-project?rev=110734&view=rev Log: Add the minimal amount of smarts necessary to instcombine of shufflevectors to recognize patterns generated by clang for transpose of a matrix in generic vectors. This is made of two parts: 1) Propagating vector extracts of hi/lo half into their users 2) Recognizing an insertion of even elements followed by the odd elements as an unpack. Testcase to come, but this shrinks the # of shuffle instructions generated on x86 from ~40 to the minimal 8. Modified: llvm/trunk/lib/Transforms/InstCombine/InstCombineVectorOps.cpp Modified: llvm/trunk/lib/Transforms/InstCombine/InstCombineVectorOps.cpp URL: http://llvm.org/viewvc/llvm-project/llvm/trunk/lib/Transforms/InstCombine/InstCombineVectorOps.cpp?rev=110734&r1=110733&r2=110734&view=diff ============================================================================== --- llvm/trunk/lib/Transforms/InstCombine/InstCombineVectorOps.cpp (original) +++ llvm/trunk/lib/Transforms/InstCombine/InstCombineVectorOps.cpp Tue Aug 10 16:38:12 2010 @@ -448,10 +448,8 @@ if (isa(SVI.getOperand(2))) return ReplaceInstUsesWith(SVI, UndefValue::get(SVI.getType())); - unsigned VWidth = cast(SVI.getType())->getNumElements(); - - if (VWidth != cast(LHS->getType())->getNumElements()) - return 0; + unsigned VWidth = Mask.size(); + unsigned LHSWidth = cast(LHS->getType())->getNumElements(); APInt UndefElts(VWidth, 0); APInt AllOnesEltMask(APInt::getAllOnesValue(VWidth)); @@ -464,14 +462,12 @@ // Canonicalize shuffle(x ,x,mask) -> shuffle(x, undef,mask') // Canonicalize shuffle(undef,x,mask) -> shuffle(x, undef,mask'). if (LHS == RHS || isa(LHS)) { - if (isa(LHS) && LHS == RHS) { - // shuffle(undef,undef,mask) -> undef. - return ReplaceInstUsesWith(SVI, LHS); - } + if (isa(LHS) && LHS == RHS) + return ReplaceInstUsesWith(SVI, UndefValue::get(SVI.getType())); // Remap any references to RHS to use LHS. std::vector Elts; - for (unsigned i = 0, e = Mask.size(); i != e; ++i) { + for (unsigned i = 0, e = LHSWidth; i != VWidth; ++i) { if (Mask[i] >= 2*e) Elts.push_back(UndefValue::get(Type::getInt32Ty(SVI.getContext()))); else { @@ -495,67 +491,148 @@ } // Analyze the shuffle, are the LHS or RHS and identity shuffles? - bool isLHSID = true, isRHSID = true; - - for (unsigned i = 0, e = Mask.size(); i != e; ++i) { - if (Mask[i] >= e*2) continue; // Ignore undef values. - // Is this an identity shuffle of the LHS value? - isLHSID &= (Mask[i] == i); + if (VWidth == LHSWidth) { + bool isLHSID = true, isRHSID = true; - // Is this an identity shuffle of the RHS value? - isRHSID &= (Mask[i]-e == i); + for (unsigned i = 0, e = Mask.size(); i != e; ++i) { + if (Mask[i] >= e*2) continue; // Ignore undef values. + // Is this an identity shuffle of the LHS value? + isLHSID &= (Mask[i] == i); + + // Is this an identity shuffle of the RHS value? + isRHSID &= (Mask[i]-e == i); + } + + // Eliminate identity shuffles. + if (isLHSID) return ReplaceInstUsesWith(SVI, LHS); + if (isRHSID) return ReplaceInstUsesWith(SVI, RHS); } - // Eliminate identity shuffles. - if (isLHSID) return ReplaceInstUsesWith(SVI, LHS); - if (isRHSID) return ReplaceInstUsesWith(SVI, RHS); - - // If the LHS is a shufflevector itself, see if we can combine it with this - // one without producing an unusual shuffle. Here we are really conservative: - // we are absolutely afraid of producing a shuffle mask not in the input - // program, because the code gen may not be smart enough to turn a merged - // shuffle into two specific shuffles: it may produce worse code. As such, - // we only merge two shuffles if the result is one of the two input shuffle - // masks. In this case, merging the shuffles just removes one instruction, - // which we know is safe. This is good for things like turning: - // (splat(splat)) -> splat. - if (ShuffleVectorInst *LHSSVI = dyn_cast(LHS)) { - if (isa(RHS)) { - std::vector LHSMask = getShuffleMask(LHSSVI); - - if (LHSMask.size() == Mask.size()) { - std::vector NewMask; - for (unsigned i = 0, e = Mask.size(); i != e; ++i) - if (Mask[i] >= e) - NewMask.push_back(2*e); - else - NewMask.push_back(LHSMask[Mask[i]]); - - // If the result mask is equal to the src shuffle or this - // shuffle mask, do the replacement. - if (NewMask == LHSMask || NewMask == Mask) { - unsigned LHSInNElts = - cast(LHSSVI->getOperand(0)->getType())-> - getNumElements(); - std::vector Elts; - for (unsigned i = 0, e = NewMask.size(); i != e; ++i) { - if (NewMask[i] >= LHSInNElts*2) { - Elts.push_back(UndefValue::get( - Type::getInt32Ty(SVI.getContext()))); - } else { - Elts.push_back(ConstantInt::get( - Type::getInt32Ty(SVI.getContext()), - NewMask[i])); - } - } - return new ShuffleVectorInst(LHSSVI->getOperand(0), - LHSSVI->getOperand(1), - ConstantVector::get(Elts)); - } + // Check for a handful of important shuffle(shuffle()) combinations. + ShuffleVectorInst *LSVI = dyn_cast(LHS); + if (!LSVI) + return MadeChange ? &SVI : 0; + + LHS = LSVI->getOperand(0); + std::vector LHSMask = getShuffleMask(LSVI); + unsigned LHSInNElts = cast(LHS->getType())->getNumElements(); + + // If lhs is identity, propagate + bool isLHSLoExtract = true, isLHSHiExtract = true; + for (unsigned i = 0, e = LHSMask.size(); i != e; ++i) { + if (LHSMask[i] >= LHSInNElts*2) continue; // Ignore undef values; + isLHSLoExtract &= (LHSMask[i] == i); + isLHSHiExtract &= (LHSMask[i] == i+(LHSInNElts/2)); + } + if ((isLHSLoExtract || isLHSHiExtract) && + (isa(RHS) || (LHSWidth == LHSInNElts))) { + std::vector Elts; + for (unsigned i = 0, e = VWidth; i != e; ++i) { + if (Mask[i] >= 2*LHSWidth) + Elts.push_back(UndefValue::get(Type::getInt32Ty(SVI.getContext()))); + else + Elts.push_back(ConstantInt::get(Type::getInt32Ty(SVI.getContext()), + LHSMask[Mask[i]])); + } + if (isa(RHS)) + RHS = UndefValue::get(LHS->getType()); + return new ShuffleVectorInst(LHS, RHS, ConstantVector::get(Elts)); + } + + // If svi + lhs forms a full unpack, merge it. This allows llvm to emit + // efficient code for matrix transposes written with generic vector ops. + if ((LHSMask.size() == Mask.size()) && isPowerOf2_32(Mask.size()) && + (Mask.size() > 1)) { + bool isUnpackLo = true, isUnpackHi = true; + // check lhs mask for <0, u, 1, u .. >; + for (unsigned i = 0, e = LHSMask.size(); i != e; ++i) { + if (LHSMask[i] >= 2*e) continue; + isUnpackLo &= (LHSMask[i] == (i/2)); + isUnpackHi &= (LHSMask[i] == (i/2) + (e/2)); + } + for (unsigned i = 0, e = Mask.size(); i != e && (isUnpackLo || isUnpackHi); + i += 2) { + isUnpackLo &= (Mask[i] == i) && (Mask[i+1] == (i/2)+e); + isUnpackHi &= (Mask[i] == i) && (Mask[i+1] == (i/2)+e+(e/2)); + } + if (isUnpackLo || isUnpackHi) { + std::vector Elts; + for (unsigned i = 0, e = Mask.size(); i != e; ++i) { + if (Mask[i] >= 2*e) + Elts.push_back(UndefValue::get(Type::getInt32Ty(SVI.getContext()))); + else if (Mask[i] >= e) + Elts.push_back(ConstantInt::get(Type::getInt32Ty(SVI.getContext()), + Mask[i])); + else + Elts.push_back(ConstantInt::get(Type::getInt32Ty(SVI.getContext()), + LHSMask[Mask[i]])); } + return new ShuffleVectorInst(LHS, RHS, ConstantVector::get(Elts)); + } + } + + // If rhs is shuffle + identity, propagate. + if (ShuffleVectorInst *RSVI = dyn_cast(RHS)) { + std::vector RHSMask = getShuffleMask(RSVI); + unsigned RHSInNElts = + cast(RSVI->getOperand(0)->getType())->getNumElements(); + + // If rhs is identity, propagate + bool isRHSLoExtract = true, isRHSHiExtract = true; + for (unsigned i = 0, e = RHSMask.size(); i != e; ++i) { + if (RHSMask[i] >= RHSInNElts*2) continue; // Ignore undef values; + isRHSLoExtract &= (RHSMask[i] == i); + isRHSHiExtract &= (RHSMask[i] == i+(RHSInNElts/2)); + } + if ((isRHSLoExtract || isRHSHiExtract) && (LHSWidth == RHSInNElts)) { + std::vector Elts; + for (unsigned i = 0, e = VWidth; i != e; ++i) { + if (Mask[i] >= 2*LHSWidth) + Elts.push_back(UndefValue::get(Type::getInt32Ty(SVI.getContext()))); + else if (Mask[i] < LHSWidth) + Elts.push_back(ConstantInt::get(Type::getInt32Ty(SVI.getContext()), + Mask[i])); + else + Elts.push_back(ConstantInt::get(Type::getInt32Ty(SVI.getContext()), + RHSMask[Mask[i]-LHSWidth]+LHSWidth)); + } + SVI.setOperand(1, RSVI->getOperand(0)); + SVI.setOperand(2, ConstantVector::get(Elts)); + return &SVI; } } + // Be extremely conservative when merging shufflevector instructions. It is + // difficult for the code generator to recognize a merged shuffle, which + // usually leads to worse code from merging a shuffle. + if (!isa(RHS)) + return MadeChange ? &SVI : 0; + + // If the merged shuffle mask is one of the two input shuffle masks, which + // just removes one instruction. This should handle splat(splat) -> splat. + if (LHSMask.size() == Mask.size()) { + std::vector NewMask; + for (unsigned i = 0, e = Mask.size(); i != e; ++i) + if (Mask[i] >= e) + NewMask.push_back(2*e); + else + NewMask.push_back(LHSMask[Mask[i]]); + + // If the result mask is equal to the src shuffle or this shuffle mask, + // do the replacement. + if (NewMask == LHSMask || NewMask == Mask) { + std::vector Elts; + for (unsigned i = 0, e = NewMask.size(); i != e; ++i) { + if (NewMask[i] >= LHSInNElts*2) { + Elts.push_back(UndefValue::get(Type::getInt32Ty(SVI.getContext()))); + } else { + Elts.push_back(ConstantInt::get(Type::getInt32Ty(SVI.getContext()), + NewMask[i])); + } + } + return new ShuffleVectorInst(LHS, LSVI->getOperand(1), + ConstantVector::get(Elts)); + } + } return MadeChange ? &SVI : 0; } - From sabre at nondot.org Tue Aug 10 16:45:38 2010 From: sabre at nondot.org (Chris Lattner) Date: Tue, 10 Aug 2010 21:45:38 -0000 Subject: [llvm-commits] [llvm] r110735 - /llvm/trunk/examples/BrainF/BrainF.cpp Message-ID: <20100810214538.3FD102A6C12C@llvm.org> Author: lattner Date: Tue Aug 10 16:45:38 2010 New Revision: 110735 URL: http://llvm.org/viewvc/llvm-project?rev=110735&view=rev Log: upgrade to use new intrinsics, patch by Dan Hipschman! Modified: llvm/trunk/examples/BrainF/BrainF.cpp Modified: llvm/trunk/examples/BrainF/BrainF.cpp URL: http://llvm.org/viewvc/llvm-project/llvm/trunk/examples/BrainF/BrainF.cpp?rev=110735&r1=110734&r2=110735&view=diff ============================================================================== --- llvm/trunk/examples/BrainF/BrainF.cpp (original) +++ llvm/trunk/examples/BrainF/BrainF.cpp Tue Aug 10 16:45:38 2010 @@ -54,10 +54,10 @@ //Function prototypes - //declare void @llvm.memset.i32(i8 *, i8, i32, i32) - const Type *Tys[] = { Type::getInt32Ty(C) }; + //declare void @llvm.memset.p0i8.i32(i8 *, i8, i32, i32, i1) + const Type *Tys[] = { Type::getInt8PtrTy(C), Type::getInt32Ty(C) }; Function *memset_func = Intrinsic::getDeclaration(module, Intrinsic::memset, - Tys, 1); + Tys, 2); //declare i32 @getchar() getchar_func = cast(module-> @@ -88,13 +88,14 @@ NULL, "arr"); BB->getInstList().push_back(cast(ptr_arr)); - //call void @llvm.memset.i32(i8 *%arr, i8 0, i32 %d, i32 1) + //call void @llvm.memset.p0i8.i32(i8 *%arr, i8 0, i32 %d, i32 1, i1 0) { Value *memset_params[] = { ptr_arr, ConstantInt::get(C, APInt(8, 0)), val_mem, - ConstantInt::get(C, APInt(32, 1)) + ConstantInt::get(C, APInt(32, 1)), + ConstantInt::get(C, APInt(1, 0)) }; CallInst *memset_call = builder-> From natebegeman at mac.com Tue Aug 10 16:58:00 2010 From: natebegeman at mac.com (Nate Begeman) Date: Tue, 10 Aug 2010 21:58:00 -0000 Subject: [llvm-commits] [llvm] r110737 - /llvm/trunk/test/Transforms/InstCombine/vec_shuffle.ll Message-ID: <20100810215800.8B9782A6C12C@llvm.org> Author: sampo Date: Tue Aug 10 16:58:00 2010 New Revision: 110737 URL: http://llvm.org/viewvc/llvm-project?rev=110737&view=rev Log: Add test for recent instcombine vector shuffle enhancement Modified: llvm/trunk/test/Transforms/InstCombine/vec_shuffle.ll Modified: llvm/trunk/test/Transforms/InstCombine/vec_shuffle.ll URL: http://llvm.org/viewvc/llvm-project/llvm/trunk/test/Transforms/InstCombine/vec_shuffle.ll?rev=110737&r1=110736&r2=110737&view=diff ============================================================================== --- llvm/trunk/test/Transforms/InstCombine/vec_shuffle.ll (original) +++ llvm/trunk/test/Transforms/InstCombine/vec_shuffle.ll Tue Aug 10 16:58:00 2010 @@ -87,3 +87,32 @@ %tmp9 = shufflevector <4 x i8> %tmp7, <4 x i8> undef, <4 x i32> < i32 3, i32 1, i32 2, i32 0 > ; <<4 x i8>> [#uses=1] ret <4 x i8> %tmp9 } + +; Test fold of hi/lo vector halves +; Test fold of unpack operation +define void @test10(<16 x i8>* %out, <16 x i8> %r, <16 x i8> %g, <16 x i8> %b, <16 x i8> %a) nounwind ssp { +; CHECK: @test10 +; CHECK-NEXT: shufflevector +; CHECK-NEXT: shufflevector +; CHECK-NEXT: store +; CHECK-NEXT: getelementptr +; CHECK-NEXT: store +; CHECK-NEXT: ret + %tmp1 = shufflevector <16 x i8> %r, <16 x i8> undef, <8 x i32> ; <<8 x i8>> [#uses=1] + %tmp3 = shufflevector <8 x i8> %tmp1, <8 x i8> undef, <16 x i32> ; <<16 x i8>> [#uses=1] + %tmp4 = shufflevector <16 x i8> undef, <16 x i8> %tmp3, <16 x i32> ; <<16 x i8>> [#uses=1] + %tmp6 = shufflevector <16 x i8> %b, <16 x i8> undef, <8 x i32> ; <<8 x i8>> [#uses=1] + %tmp8 = shufflevector <8 x i8> %tmp6, <8 x i8> undef, <16 x i32> ; <<16 x i8>> [#uses=1] + %tmp9 = shufflevector <16 x i8> %tmp4, <16 x i8> %tmp8, <16 x i32> ; <<16 x i8>> [#uses=1] + %tmp11 = shufflevector <16 x i8> %r, <16 x i8> undef, <8 x i32> ; <<8 x i8>> [#uses=1] + %tmp13 = shufflevector <8 x i8> %tmp11, <8 x i8> undef, <16 x i32> ; <<16 x i8>> [#uses=1] + %tmp14 = shufflevector <16 x i8> undef, <16 x i8> %tmp13, <16 x i32> ; <<16 x i8>> [#uses=1] + %tmp16 = shufflevector <16 x i8> %b, <16 x i8> undef, <8 x i32> ; <<8 x i8>> [#uses=1] + %tmp18 = shufflevector <8 x i8> %tmp16, <8 x i8> undef, <16 x i32> ; <<16 x i8>> [#uses=1] + %tmp19 = shufflevector <16 x i8> %tmp14, <16 x i8> %tmp18, <16 x i32> ; <<16 x i8>> [#uses=1] + %arrayidx = getelementptr inbounds <16 x i8>* %out, i64 0 ; <<16 x i8>*> [#uses=1] + store <16 x i8> %tmp9, <16 x i8>* %arrayidx + %arrayidx24 = getelementptr inbounds <16 x i8>* %out, i64 1 ; <<16 x i8>*> [#uses=1] + store <16 x i8> %tmp19, <16 x i8>* %arrayidx24 + ret void +} From isanbard at gmail.com Tue Aug 10 17:16:05 2010 From: isanbard at gmail.com (Bill Wendling) Date: Tue, 10 Aug 2010 22:16:05 -0000 Subject: [llvm-commits] [llvm] r110739 - /llvm/trunk/test/CodeGen/ARM/lsr-on-unrolled-loops.ll Message-ID: <20100810221605.913D22A6C12C@llvm.org> Author: void Date: Tue Aug 10 17:16:05 2010 New Revision: 110739 URL: http://llvm.org/viewvc/llvm-project?rev=110739&view=rev Log: The optimize comparisons pass removes the "cmp" instruction this is checking for. Modified: llvm/trunk/test/CodeGen/ARM/lsr-on-unrolled-loops.ll Modified: llvm/trunk/test/CodeGen/ARM/lsr-on-unrolled-loops.ll URL: http://llvm.org/viewvc/llvm-project/llvm/trunk/test/CodeGen/ARM/lsr-on-unrolled-loops.ll?rev=110739&r1=110738&r2=110739&view=diff ============================================================================== --- llvm/trunk/test/CodeGen/ARM/lsr-on-unrolled-loops.ll (original) +++ llvm/trunk/test/CodeGen/ARM/lsr-on-unrolled-loops.ll Tue Aug 10 17:16:05 2010 @@ -629,7 +629,6 @@ ; CHECK: @ %bb24 ; CHECK-NEXT: @ in Loop: Header=BB1_1 Depth=1 ; CHECK-NEXT: sub{{.*}} [[REGISTER:r[0-9]+]], #1 -; CHECK-NEXT: cmp{{.*}} [[REGISTER]], #0 ; CHECK-NEXT: bne.w %92 = icmp eq i32 %tmp81, %indvar78 ; [#uses=1] From resistor at mac.com Tue Aug 10 18:20:01 2010 From: resistor at mac.com (Owen Anderson) Date: Tue, 10 Aug 2010 23:20:01 -0000 Subject: [llvm-commits] [llvm] r110742 - /llvm/trunk/lib/Analysis/LazyValueInfo.cpp Message-ID: <20100810232001.B01F22A6C12C@llvm.org> Author: resistor Date: Tue Aug 10 18:20:01 2010 New Revision: 110742 URL: http://llvm.org/viewvc/llvm-project?rev=110742&view=rev Log: Now that we're using ConstantRange to represent potential values, make use of that represenation to create constraints from comparisons other than eq/neq. Modified: llvm/trunk/lib/Analysis/LazyValueInfo.cpp Modified: llvm/trunk/lib/Analysis/LazyValueInfo.cpp URL: http://llvm.org/viewvc/llvm-project/llvm/trunk/lib/Analysis/LazyValueInfo.cpp?rev=110742&r1=110741&r2=110742&view=diff ============================================================================== --- llvm/trunk/lib/Analysis/LazyValueInfo.cpp (original) +++ llvm/trunk/lib/Analysis/LazyValueInfo.cpp Tue Aug 10 18:20:01 2010 @@ -91,6 +91,11 @@ Res.markNotConstant(C); return Res; } + static LVILatticeVal getRange(ConstantRange CR) { + LVILatticeVal Res; + Res.markConstantRange(CR); + return Res; + } bool isUndefined() const { return Tag == undefined; } bool isConstant() const { return Tag == constant; } @@ -507,13 +512,35 @@ // If the condition of the branch is an equality comparison, we may be // able to infer the value. if (ICmpInst *ICI = dyn_cast(BI->getCondition())) - if (ICI->isEquality() && ICI->getOperand(0) == Val && - isa(ICI->getOperand(1))) { - // We know that V has the RHS constant if this is a true SETEQ or - // false SETNE. - if (isTrueDest == (ICI->getPredicate() == ICmpInst::ICMP_EQ)) - return LVILatticeVal::get(cast(ICI->getOperand(1))); - return LVILatticeVal::getNot(cast(ICI->getOperand(1))); + if (ICI->getOperand(0) == Val && isa(ICI->getOperand(1))) { + if (ICI->isEquality()) { + // We know that V has the RHS constant if this is a true SETEQ or + // false SETNE. + if (isTrueDest == (ICI->getPredicate() == ICmpInst::ICMP_EQ)) + return LVILatticeVal::get(cast(ICI->getOperand(1))); + return LVILatticeVal::getNot(cast(ICI->getOperand(1))); + } else if (ConstantInt *CI = + dyn_cast(ICI->getOperand(1))) { + + // Calculate the range of values that would satisfy the comparison. + ConstantRange CmpRange(CI->getValue(), CI->getValue()+1); + ConstantRange TrueValues = + ConstantRange::makeICmpRegion(ICI->getPredicate(), CmpRange); + + // If we're interested in the false dest, invert the condition. + if (!isTrueDest) TrueValues = TrueValues.inverse(); + + // Figure out the possible values of the query BEFORE this branch. + LVILatticeVal InBlock = getBlockValue(BBFrom); + if (!InBlock.isConstantRange()) return InBlock; + + // Find all potential values that satisfy both the input and output + // conditions. + ConstantRange PossibleValues = + TrueValues.intersectWith(InBlock.getConstantRange()); + + return LVILatticeVal::getRange(PossibleValues); + } } } } @@ -730,7 +757,7 @@ ConstantRange TrueValues = ConstantRange::makeICmpRegion(Pred, RHS); if (CR.intersectWith(TrueValues).isEmptySet()) return False; - else if (CR.intersectWith(TrueValues) == CR) + else if (TrueValues.contains(CR)) return True; return Unknown; From bruno.cardoso at gmail.com Tue Aug 10 18:25:42 2010 From: bruno.cardoso at gmail.com (Bruno Cardoso Lopes) Date: Tue, 10 Aug 2010 23:25:42 -0000 Subject: [llvm-commits] [llvm] r110744 - in /llvm/trunk/lib/Target/X86: X86ISelLowering.cpp X86ISelLowering.h X86InstrFragmentsSIMD.td X86InstrSSE.td Message-ID: <20100810232543.211462A6C12C@llvm.org> Author: bruno Date: Tue Aug 10 18:25:42 2010 New Revision: 110744 URL: http://llvm.org/viewvc/llvm-project?rev=110744&view=rev Log: Add AVX matching patterns to Packed Bit Test intrinsics. Apply the same approach of SSE4.1 ptest intrinsics but create a new x86 node "testp" since AVX introduces vtest{ps}{pd} instructions which set ZF and CF depending on sign bit AND and ANDN of packed floating-point sources. This is slightly different from what the "ptest" does. Tests comming with the other 256 intrinsics tests. Modified: llvm/trunk/lib/Target/X86/X86ISelLowering.cpp llvm/trunk/lib/Target/X86/X86ISelLowering.h llvm/trunk/lib/Target/X86/X86InstrFragmentsSIMD.td llvm/trunk/lib/Target/X86/X86InstrSSE.td Modified: llvm/trunk/lib/Target/X86/X86ISelLowering.cpp URL: http://llvm.org/viewvc/llvm-project/llvm/trunk/lib/Target/X86/X86ISelLowering.cpp?rev=110744&r1=110743&r2=110744&view=diff ============================================================================== --- llvm/trunk/lib/Target/X86/X86ISelLowering.cpp (original) +++ llvm/trunk/lib/Target/X86/X86ISelLowering.cpp Tue Aug 10 18:25:42 2010 @@ -6987,24 +6987,58 @@ DAG.getConstant(X86CC, MVT::i8), Cond); return DAG.getNode(ISD::ZERO_EXTEND, dl, MVT::i32, SetCC); } - // ptest intrinsics. The intrinsic these come from are designed to return - // an integer value, not just an instruction so lower it to the ptest - // pattern and a setcc for the result. + // ptest and testp intrinsics. The intrinsic these come from are designed to + // return an integer value, not just an instruction so lower it to the ptest + // or testp pattern and a setcc for the result. case Intrinsic::x86_sse41_ptestz: case Intrinsic::x86_sse41_ptestc: - case Intrinsic::x86_sse41_ptestnzc:{ + case Intrinsic::x86_sse41_ptestnzc: + case Intrinsic::x86_avx_ptestz_256: + case Intrinsic::x86_avx_ptestc_256: + case Intrinsic::x86_avx_ptestnzc_256: + case Intrinsic::x86_avx_vtestz_ps: + case Intrinsic::x86_avx_vtestc_ps: + case Intrinsic::x86_avx_vtestnzc_ps: + case Intrinsic::x86_avx_vtestz_pd: + case Intrinsic::x86_avx_vtestc_pd: + case Intrinsic::x86_avx_vtestnzc_pd: + case Intrinsic::x86_avx_vtestz_ps_256: + case Intrinsic::x86_avx_vtestc_ps_256: + case Intrinsic::x86_avx_vtestnzc_ps_256: + case Intrinsic::x86_avx_vtestz_pd_256: + case Intrinsic::x86_avx_vtestc_pd_256: + case Intrinsic::x86_avx_vtestnzc_pd_256: { + bool IsTestPacked = false; unsigned X86CC = 0; switch (IntNo) { default: llvm_unreachable("Bad fallthrough in Intrinsic lowering."); + case Intrinsic::x86_avx_vtestz_ps: + case Intrinsic::x86_avx_vtestz_pd: + case Intrinsic::x86_avx_vtestz_ps_256: + case Intrinsic::x86_avx_vtestz_pd_256: + IsTestPacked = true; // Fallthrough case Intrinsic::x86_sse41_ptestz: + case Intrinsic::x86_avx_ptestz_256: // ZF = 1 X86CC = X86::COND_E; break; + case Intrinsic::x86_avx_vtestc_ps: + case Intrinsic::x86_avx_vtestc_pd: + case Intrinsic::x86_avx_vtestc_ps_256: + case Intrinsic::x86_avx_vtestc_pd_256: + IsTestPacked = true; // Fallthrough case Intrinsic::x86_sse41_ptestc: + case Intrinsic::x86_avx_ptestc_256: // CF = 1 X86CC = X86::COND_B; break; + case Intrinsic::x86_avx_vtestnzc_ps: + case Intrinsic::x86_avx_vtestnzc_pd: + case Intrinsic::x86_avx_vtestnzc_ps_256: + case Intrinsic::x86_avx_vtestnzc_pd_256: + IsTestPacked = true; // Fallthrough case Intrinsic::x86_sse41_ptestnzc: + case Intrinsic::x86_avx_ptestnzc_256: // ZF and CF = 0 X86CC = X86::COND_A; break; @@ -7012,7 +7046,8 @@ SDValue LHS = Op.getOperand(1); SDValue RHS = Op.getOperand(2); - SDValue Test = DAG.getNode(X86ISD::PTEST, dl, MVT::i32, LHS, RHS); + unsigned TestOpc = IsTestPacked ? X86ISD::TESTP : X86ISD::PTEST; + SDValue Test = DAG.getNode(TestOpc, dl, MVT::i32, LHS, RHS); SDValue CC = DAG.getConstant(X86CC, MVT::i8); SDValue SetCC = DAG.getNode(X86ISD::SETCC, dl, MVT::i8, CC, Test); return DAG.getNode(ISD::ZERO_EXTEND, dl, MVT::i32, SetCC); @@ -8033,6 +8068,7 @@ case X86ISD::AND: return "X86ISD::AND"; case X86ISD::MUL_IMM: return "X86ISD::MUL_IMM"; case X86ISD::PTEST: return "X86ISD::PTEST"; + case X86ISD::TESTP: return "X86ISD::TESTP"; case X86ISD::VASTART_SAVE_XMM_REGS: return "X86ISD::VASTART_SAVE_XMM_REGS"; case X86ISD::MINGW_ALLOCA: return "X86ISD::MINGW_ALLOCA"; } Modified: llvm/trunk/lib/Target/X86/X86ISelLowering.h URL: http://llvm.org/viewvc/llvm-project/llvm/trunk/lib/Target/X86/X86ISelLowering.h?rev=110744&r1=110743&r2=110744&view=diff ============================================================================== --- llvm/trunk/lib/Target/X86/X86ISelLowering.h (original) +++ llvm/trunk/lib/Target/X86/X86ISelLowering.h Tue Aug 10 18:25:42 2010 @@ -248,6 +248,9 @@ // PTEST - Vector bitwise comparisons PTEST, + // TESTP - Vector packed fp sign bitwise comparisons + TESTP, + // VASTART_SAVE_XMM_REGS - Save xmm argument registers to the stack, // according to %al. An operator is needed so that this can be expanded // with control flow. Modified: llvm/trunk/lib/Target/X86/X86InstrFragmentsSIMD.td URL: http://llvm.org/viewvc/llvm-project/llvm/trunk/lib/Target/X86/X86InstrFragmentsSIMD.td?rev=110744&r1=110743&r2=110744&view=diff ============================================================================== --- llvm/trunk/lib/Target/X86/X86InstrFragmentsSIMD.td (original) +++ llvm/trunk/lib/Target/X86/X86InstrFragmentsSIMD.td Tue Aug 10 18:25:42 2010 @@ -117,9 +117,10 @@ def X86pcmpgtq : SDNode<"X86ISD::PCMPGTQ", SDTIntBinOp>; def SDTX86CmpPTest : SDTypeProfile<1, 2, [SDTCisVT<0, i32>, - SDTCisVT<1, v4f32>, - SDTCisVT<2, v4f32>]>; + SDTCisVec<1>, + SDTCisSameAs<2, 1>]>; def X86ptest : SDNode<"X86ISD::PTEST", SDTX86CmpPTest>; +def X86testp : SDNode<"X86ISD::TESTP", SDTX86CmpPTest>; //===----------------------------------------------------------------------===// // SSE Complex Patterns Modified: llvm/trunk/lib/Target/X86/X86InstrSSE.td URL: http://llvm.org/viewvc/llvm-project/llvm/trunk/lib/Target/X86/X86InstrSSE.td?rev=110744&r1=110743&r2=110744&view=diff ============================================================================== --- llvm/trunk/lib/Target/X86/X86InstrSSE.td (original) +++ llvm/trunk/lib/Target/X86/X86InstrSSE.td Tue Aug 10 18:25:42 2010 @@ -4646,47 +4646,52 @@ // the intel intrinsic that corresponds to this. let Defs = [EFLAGS], isAsmParserOnly = 1, Predicates = [HasAVX] in { def VPTESTrr : SS48I<0x17, MRMSrcReg, (outs), (ins VR128:$src1, VR128:$src2), - "vptest\t{$src2, $src1|$src1, $src2}", - [(set EFLAGS, (X86ptest VR128:$src1, VR128:$src2))]>, - OpSize, VEX; -def VPTESTYrr : SS48I<0x17, MRMSrcReg, (outs), (ins VR256:$src1, VR256:$src2), - "vptest\t{$src2, $src1|$src1, $src2}", []>, OpSize, VEX; + "vptest\t{$src2, $src1|$src1, $src2}", + [(set EFLAGS, (X86ptest VR128:$src1, (v4f32 VR128:$src2)))]>, + OpSize, VEX; +def VPTESTrm : SS48I<0x17, MRMSrcMem, (outs), (ins VR128:$src1, f128mem:$src2), + "vptest\t{$src2, $src1|$src1, $src2}", + [(set EFLAGS,(X86ptest VR128:$src1, (memopv4f32 addr:$src2)))]>, + OpSize, VEX; -def VPTESTrm : SS48I<0x17, MRMSrcMem, (outs), (ins VR128:$src1, i128mem:$src2), - "vptest\t{$src2, $src1|$src1, $src2}", - [(set EFLAGS, (X86ptest VR128:$src1, (load addr:$src2)))]>, - OpSize, VEX; +def VPTESTYrr : SS48I<0x17, MRMSrcReg, (outs), (ins VR256:$src1, VR256:$src2), + "vptest\t{$src2, $src1|$src1, $src2}", + [(set EFLAGS, (X86ptest VR256:$src1, (v4i64 VR256:$src2)))]>, + OpSize, VEX; def VPTESTYrm : SS48I<0x17, MRMSrcMem, (outs), (ins VR256:$src1, i256mem:$src2), - "vptest\t{$src2, $src1|$src1, $src2}", []>, OpSize, VEX; + "vptest\t{$src2, $src1|$src1, $src2}", + [(set EFLAGS,(X86ptest VR256:$src1, (memopv4i64 addr:$src2)))]>, + OpSize, VEX; } let Defs = [EFLAGS] in { def PTESTrr : SS48I<0x17, MRMSrcReg, (outs), (ins VR128:$src1, VR128:$src2), - "ptest \t{$src2, $src1|$src1, $src2}", - [(set EFLAGS, (X86ptest VR128:$src1, VR128:$src2))]>, + "ptest \t{$src2, $src1|$src1, $src2}", + [(set EFLAGS, (X86ptest VR128:$src1, (v4f32 VR128:$src2)))]>, OpSize; -def PTESTrm : SS48I<0x17, MRMSrcMem, (outs), (ins VR128:$src1, i128mem:$src2), - "ptest \t{$src2, $src1|$src1, $src2}", - [(set EFLAGS, (X86ptest VR128:$src1, (load addr:$src2)))]>, +def PTESTrm : SS48I<0x17, MRMSrcMem, (outs), (ins VR128:$src1, f128mem:$src2), + "ptest \t{$src2, $src1|$src1, $src2}", + [(set EFLAGS, (X86ptest VR128:$src1, (memopv4f32 addr:$src2)))]>, OpSize; } // The bit test instructions below are AVX only multiclass avx_bittest opc, string OpcodeStr, RegisterClass RC, - X86MemOperand x86memop> { - def rr : SS48I, OpSize, VEX; - def rm : SS48I, OpSize, VEX; + X86MemOperand x86memop, PatFrag mem_frag, ValueType vt> { + def rr : SS48I, OpSize, VEX; + def rm : SS48I, + OpSize, VEX; } let Defs = [EFLAGS], isAsmParserOnly = 1, Predicates = [HasAVX] in { - defm VTESTPS : avx_bittest<0x0E, "vtestps", VR128, f128mem>; - defm VTESTPSY : avx_bittest<0x0E, "vtestps", VR256, f256mem>; - defm VTESTPD : avx_bittest<0x0F, "vtestpd", VR128, f128mem>; - defm VTESTPDY : avx_bittest<0x0F, "vtestpd", VR256, f256mem>; +defm VTESTPS : avx_bittest<0x0E, "vtestps", VR128, f128mem, memopv4f32, v4f32>; +defm VTESTPSY : avx_bittest<0x0E, "vtestps", VR256, f256mem, memopv8f32, v8f32>; +defm VTESTPD : avx_bittest<0x0F, "vtestpd", VR128, f128mem, memopv2f64, v2f64>; +defm VTESTPDY : avx_bittest<0x0F, "vtestpd", VR256, f256mem, memopv4f64, v4f64>; } //===----------------------------------------------------------------------===// From evan.cheng at apple.com Tue Aug 10 18:27:11 2010 From: evan.cheng at apple.com (Evan Cheng) Date: Tue, 10 Aug 2010 23:27:11 -0000 Subject: [llvm-commits] [llvm] r110745 - /llvm/trunk/lib/Target/ARM/ARMInstrThumb2.td Message-ID: <20100810232711.8DD402A6C12C@llvm.org> Author: evancheng Date: Tue Aug 10 18:27:11 2010 New Revision: 110745 URL: http://llvm.org/viewvc/llvm-project?rev=110745&view=rev Log: CBZ and CBNZ are implemented. Modified: llvm/trunk/lib/Target/ARM/ARMInstrThumb2.td Modified: llvm/trunk/lib/Target/ARM/ARMInstrThumb2.td URL: http://llvm.org/viewvc/llvm-project/llvm/trunk/lib/Target/ARM/ARMInstrThumb2.td?rev=110745&r1=110744&r2=110745&view=diff ============================================================================== --- llvm/trunk/lib/Target/ARM/ARMInstrThumb2.td (original) +++ llvm/trunk/lib/Target/ARM/ARMInstrThumb2.td Tue Aug 10 18:27:11 2010 @@ -2166,11 +2166,6 @@ defm t2TEQ : T2I_cmp_irs<0b0100, "teq", BinOpFrag<(ARMcmpZ (xor node:$LHS, node:$RHS), 0)>>; -// A8.6.27 CBNZ, CBZ - Compare and branch on (non)zero. -// Short range conditional branch. Looks awesome for loops. Need to figure -// out how to use this one. - - // Conditional moves // FIXME: should be able to write a pattern for ARMcmov, but can't use // a two-value operand where a dag node expects two operands. :( From grosbach at apple.com Tue Aug 10 18:33:20 2010 From: grosbach at apple.com (Jim Grosbach) Date: Tue, 10 Aug 2010 23:33:20 -0000 Subject: [llvm-commits] [llvm-gcc-4.2] r110746 - in /llvm-gcc-4.2/trunk/gcc/config/arm: arm-cores.def arm.c arm.h Message-ID: <20100810233320.E33132A6C12C@llvm.org> Author: grosbach Date: Tue Aug 10 18:33:20 2010 New Revision: 110746 URL: http://llvm.org/viewvc/llvm-project?rev=110746&view=rev Log: pass long cortex-m* to the backend when it's selected Modified: llvm-gcc-4.2/trunk/gcc/config/arm/arm-cores.def llvm-gcc-4.2/trunk/gcc/config/arm/arm.c llvm-gcc-4.2/trunk/gcc/config/arm/arm.h Modified: llvm-gcc-4.2/trunk/gcc/config/arm/arm-cores.def URL: http://llvm.org/viewvc/llvm-project/llvm-gcc-4.2/trunk/gcc/config/arm/arm-cores.def?rev=110746&r1=110745&r2=110746&view=diff ============================================================================== --- llvm-gcc-4.2/trunk/gcc/config/arm/arm-cores.def (original) +++ llvm-gcc-4.2/trunk/gcc/config/arm/arm-cores.def Tue Aug 10 18:33:20 2010 @@ -126,4 +126,5 @@ /* LLVM LOCAL end */ ARM_CORE("cortex-r4", cortexr4, 7R, FL_LDSCHED, 9e) ARM_CORE("cortex-m3", cortexm3, 7M, FL_LDSCHED, 9e) +ARM_CORE("cortex-m4", cortexm4, 7M, FL_LDSCHED, 9e) /* APPLE LOCAL end v7 support. Merge from mainline */ Modified: llvm-gcc-4.2/trunk/gcc/config/arm/arm.c URL: http://llvm.org/viewvc/llvm-project/llvm-gcc-4.2/trunk/gcc/config/arm/arm.c?rev=110746&r1=110745&r2=110746&view=diff ============================================================================== --- llvm-gcc-4.2/trunk/gcc/config/arm/arm.c (original) +++ llvm-gcc-4.2/trunk/gcc/config/arm/arm.c Tue Aug 10 18:33:20 2010 @@ -683,6 +683,8 @@ /* Nonzero if this chip supports the ARM 7A extensions. */ int arm_arch7a = 0; /* APPLE LOCAL end 6093388 -mfpu=neon default for v7a */ +/* Nonzero if this chip supports the ARM 7M extensions. */ +int arm_arch7m= 0; /* APPLE LOCAL begin v7 support. Merge from mainline */ /* Nonzero if instructions not present in the 'M' profile can be used. */ @@ -846,6 +848,9 @@ {"armv6t2", arm1156t2s, "6T2", FL_CO_PROC | FL_FOR_ARCH6T2, NULL}, {"armv7", cortexa8, "7", FL_CO_PROC | FL_FOR_ARCH7, NULL}, {"armv7a", cortexa8, "7A", FL_CO_PROC | FL_FOR_ARCH7A, NULL}, + {"armv7m", cortexm3, "7M", FL_CO_PROC | FL_FOR_ARCH7M, NULL}, + {"armv7m3", cortexm3, "7M", FL_CO_PROC | FL_FOR_ARCH7M, NULL}, + {"armv7m4", cortexm4, "7M", FL_CO_PROC | FL_FOR_ARCH7M, NULL}, /* APPLE LOCAL begin v7 support. Merge from Codesourcery */ {"armv7r", cortexr4, "7R", FL_CO_PROC | FL_FOR_ARCH7R, NULL}, {"armv7m", cortexm3, "7M", FL_CO_PROC | FL_FOR_ARCH7M, NULL}, @@ -853,6 +858,8 @@ {"armv7-a", cortexa8, "7A", FL_CO_PROC | FL_FOR_ARCH7A, NULL}, {"armv7-r", cortexr4, "7R", FL_CO_PROC | FL_FOR_ARCH7R, NULL}, {"armv7-m", cortexm3, "7M", FL_CO_PROC | FL_FOR_ARCH7M, NULL}, + {"armv7-m3", cortexm3, "7M", FL_CO_PROC | FL_FOR_ARCH7M, NULL}, + {"armv7-m4", cortexm4, "7M", FL_CO_PROC | FL_FOR_ARCH7M, NULL}, /* APPLE LOCAL end v7 support. Merge from mainline */ {"ep9312", ep9312, "4T", FL_LDSCHED | FL_CIRRUS | FL_FOR_ARCH4, NULL}, {"iwmmxt", iwmmxt, "5TE", FL_LDSCHED | FL_STRONG | FL_FOR_ARCH5TE | FL_XSCALE | FL_IWMMXT , NULL}, @@ -1561,6 +1568,7 @@ /* APPLE LOCAL 6093388 -mfpu=neon default for v7a */ arm_arch7a = (insn_flags & FL_FOR_ARCH7A) == FL_FOR_ARCH7A; /* APPLE LOCAL begin v7 support. Merge from mainline */ + arm_arch7m = (insn_flags & FL_FOR_ARCH7M) == FL_FOR_ARCH7M; arm_arch_notm = (insn_flags & FL_NOTM) != 0; arm_arch_thumb2 = (insn_flags & FL_THUMB2) != 0; /* APPLE LOCAL end v7 support. Merge from mainline */ @@ -24464,7 +24472,7 @@ void arm_darwin_subtarget_conditional_register_usage (void) { - if (!(arm_arch6 && !darwin_reserve_r9_on_v6) && !arm_arch7a) + if (!(arm_arch6 && !darwin_reserve_r9_on_v6) && !(arm_arch7a || arm_arch7m)) fixed_regs[9] = 1; call_used_regs[9] = 1; Modified: llvm-gcc-4.2/trunk/gcc/config/arm/arm.h URL: http://llvm.org/viewvc/llvm-project/llvm-gcc-4.2/trunk/gcc/config/arm/arm.h?rev=110746&r1=110745&r2=110746&view=diff ============================================================================== --- llvm-gcc-4.2/trunk/gcc/config/arm/arm.h (original) +++ llvm-gcc-4.2/trunk/gcc/config/arm/arm.h Tue Aug 10 18:33:20 2010 @@ -449,8 +449,8 @@ /* Nonzero if this chip supports the ARM Architecture 6 extensions. */ extern int arm_arch6; -/* LLVM LOCAL Declare arm_arch7a for use when setting the target triple. */ -extern int arm_arch7a; +/* LLVM LOCAL Declare arm_arch7m for use when setting the target triple. */ +extern int arm_arch7m; /* APPLE LOCAL begin 6258536 Atomic builtins */ /* Nonzero if this chip supports the ARM Architecture 7a extensions. */ @@ -3497,6 +3497,7 @@ case cortexa9: F.setCPU("cortex-a9"); break; \ case cortexr4: F.setCPU("cortex-r4"); break; \ case cortexm3: F.setCPU("cortex-m3"); break; \ + case cortexm4: F.setCPU("cortex-m4"); break; \ default: \ F.setCPU("arm7tdmi"); \ break; \ @@ -3528,16 +3529,18 @@ (TARGET_THUMB \ ? (arm_arch7a \ ? "thumbv7" \ - : (arm_arch_thumb2 \ - ? "thumbv6t2" \ - : (arm_arch6 \ - ? "thumbv6" \ - : (arm_arch5e \ - ? "thumbv5e" \ - : (arm_arch5 \ - ? "thumbv5" \ - : (arm_arch4t \ - ? "thumbv4t" : "")))))) \ + : (arm_arch7m \ + ? "thumbv7m" \ + : (arm_arch_thumb2 \ + ? "thumbv6t2" \ + : (arm_arch6 \ + ? "thumbv6" \ + : (arm_arch5e \ + ? "thumbv5e" \ + : (arm_arch5 \ + ? "thumbv5" \ + : (arm_arch4t \ + ? "thumbv4t" : ""))))))) \ : (arm_arch7a \ ? "armv7" \ : (arm_arch_thumb2 \ From echristo at apple.com Tue Aug 10 18:46:21 2010 From: echristo at apple.com (Eric Christopher) Date: Tue, 10 Aug 2010 23:46:21 -0000 Subject: [llvm-commits] [llvm] r110748 - /llvm/trunk/utils/TableGen/DAGISelMatcherGen.cpp Message-ID: <20100810234621.270EF2A6C12C@llvm.org> Author: echristo Date: Tue Aug 10 18:46:20 2010 New Revision: 110748 URL: http://llvm.org/viewvc/llvm-project?rev=110748&view=rev Log: We already have this as OperandNode. Modified: llvm/trunk/utils/TableGen/DAGISelMatcherGen.cpp Modified: llvm/trunk/utils/TableGen/DAGISelMatcherGen.cpp URL: http://llvm.org/viewvc/llvm-project/llvm/trunk/utils/TableGen/DAGISelMatcherGen.cpp?rev=110748&r1=110747&r2=110748&view=diff ============================================================================== --- llvm/trunk/utils/TableGen/DAGISelMatcherGen.cpp (original) +++ llvm/trunk/utils/TableGen/DAGISelMatcherGen.cpp Tue Aug 10 18:46:20 2010 @@ -689,8 +689,8 @@ !CGP.getDefaultOperand(OperandNode).DefaultOps.empty()) { // This is a predicate or optional def operand; emit the // 'default ops' operands. - const DAGDefaultOperand &DefaultOp = - CGP.getDefaultOperand(II.OperandList[InstOpNo].Rec); + const DAGDefaultOperand &DefaultOp + = CGP.getDefaultOperand(OperandNode); for (unsigned i = 0, e = DefaultOp.DefaultOps.size(); i != e; ++i) EmitResultOperand(DefaultOp.DefaultOps[i], InstOps); continue; @@ -908,6 +908,3 @@ // Unconditional match. return Gen.GetMatcher(); } - - - From gohman at apple.com Tue Aug 10 18:46:30 2010 From: gohman at apple.com (Dan Gohman) Date: Tue, 10 Aug 2010 23:46:30 -0000 Subject: [llvm-commits] [llvm] r110750 - in /llvm/trunk: include/llvm/Analysis/ScalarEvolution.h lib/Analysis/ScalarEvolution.cpp Message-ID: <20100810234630.E5B662A6C12D@llvm.org> Author: djg Date: Tue Aug 10 18:46:30 2010 New Revision: 110750 URL: http://llvm.org/viewvc/llvm-project?rev=110750&view=rev Log: Rename and reorder the arguments to isImpliedCond, for consistency and clarity. Modified: llvm/trunk/include/llvm/Analysis/ScalarEvolution.h llvm/trunk/lib/Analysis/ScalarEvolution.cpp Modified: llvm/trunk/include/llvm/Analysis/ScalarEvolution.h URL: http://llvm.org/viewvc/llvm-project/llvm/trunk/include/llvm/Analysis/ScalarEvolution.h?rev=110750&r1=110749&r2=110750&view=diff ============================================================================== --- llvm/trunk/include/llvm/Analysis/ScalarEvolution.h (original) +++ llvm/trunk/include/llvm/Analysis/ScalarEvolution.h Tue Aug 10 18:46:30 2010 @@ -352,10 +352,11 @@ std::pair getPredecessorWithUniqueSuccessorForBB(BasicBlock *BB); - /// isImpliedCond - Test whether the condition described by Pred, LHS, - /// and RHS is true whenever the given Cond value evaluates to true. - bool isImpliedCond(Value *Cond, ICmpInst::Predicate Pred, + /// isImpliedCond - Test whether the condition described by Pred, LHS, and + /// RHS is true whenever the given FoundCondValue value evaluates to true. + bool isImpliedCond(ICmpInst::Predicate Pred, const SCEV *LHS, const SCEV *RHS, + Value *FoundCondValue, bool Inverse); /// isImpliedCondOperands - Test whether the condition described by Pred, Modified: llvm/trunk/lib/Analysis/ScalarEvolution.cpp URL: http://llvm.org/viewvc/llvm-project/llvm/trunk/lib/Analysis/ScalarEvolution.cpp?rev=110750&r1=110749&r2=110750&view=diff ============================================================================== --- llvm/trunk/lib/Analysis/ScalarEvolution.cpp (original) +++ llvm/trunk/lib/Analysis/ScalarEvolution.cpp Tue Aug 10 18:46:30 2010 @@ -5223,7 +5223,8 @@ LoopContinuePredicate->isUnconditional()) return false; - return isImpliedCond(LoopContinuePredicate->getCondition(), Pred, LHS, RHS, + return isImpliedCond(Pred, LHS, RHS, + LoopContinuePredicate->getCondition(), LoopContinuePredicate->getSuccessor(0) != L->getHeader()); } @@ -5252,7 +5253,8 @@ LoopEntryPredicate->isUnconditional()) continue; - if (isImpliedCond(LoopEntryPredicate->getCondition(), Pred, LHS, RHS, + if (isImpliedCond(Pred, LHS, RHS, + LoopEntryPredicate->getCondition(), LoopEntryPredicate->getSuccessor(0) != Pair.second)) return true; } @@ -5262,24 +5264,24 @@ /// isImpliedCond - Test whether the condition described by Pred, LHS, /// and RHS is true whenever the given Cond value evaluates to true. -bool ScalarEvolution::isImpliedCond(Value *CondValue, - ICmpInst::Predicate Pred, +bool ScalarEvolution::isImpliedCond(ICmpInst::Predicate Pred, const SCEV *LHS, const SCEV *RHS, + Value *FoundCondValue, bool Inverse) { // Recursively handle And and Or conditions. - if (BinaryOperator *BO = dyn_cast(CondValue)) { + if (BinaryOperator *BO = dyn_cast(FoundCondValue)) { if (BO->getOpcode() == Instruction::And) { if (!Inverse) - return isImpliedCond(BO->getOperand(0), Pred, LHS, RHS, Inverse) || - isImpliedCond(BO->getOperand(1), Pred, LHS, RHS, Inverse); + return isImpliedCond(Pred, LHS, RHS, BO->getOperand(0), Inverse) || + isImpliedCond(Pred, LHS, RHS, BO->getOperand(1), Inverse); } else if (BO->getOpcode() == Instruction::Or) { if (Inverse) - return isImpliedCond(BO->getOperand(0), Pred, LHS, RHS, Inverse) || - isImpliedCond(BO->getOperand(1), Pred, LHS, RHS, Inverse); + return isImpliedCond(Pred, LHS, RHS, BO->getOperand(0), Inverse) || + isImpliedCond(Pred, LHS, RHS, BO->getOperand(1), Inverse); } } - ICmpInst *ICI = dyn_cast(CondValue); + ICmpInst *ICI = dyn_cast(FoundCondValue); if (!ICI) return false; // Bail if the ICmp's operands' types are wider than the needed type From daniel at zuster.org Tue Aug 10 18:46:40 2010 From: daniel at zuster.org (Daniel Dunbar) Date: Tue, 10 Aug 2010 23:46:40 -0000 Subject: [llvm-commits] [llvm] r110751 - /llvm/trunk/tools/lto/LTOModule.cpp Message-ID: <20100810234640.1A0D92A6C12C@llvm.org> Author: ddunbar Date: Tue Aug 10 18:46:39 2010 New Revision: 110751 URL: http://llvm.org/viewvc/llvm-project?rev=110751&view=rev Log: LTOModule.cpp: Fix numerous style issues. Modified: llvm/trunk/tools/lto/LTOModule.cpp Modified: llvm/trunk/tools/lto/LTOModule.cpp URL: http://llvm.org/viewvc/llvm-project/llvm/trunk/tools/lto/LTOModule.cpp?rev=110751&r1=110750&r2=110751&view=diff ============================================================================== --- llvm/trunk/tools/lto/LTOModule.cpp (original) +++ llvm/trunk/tools/lto/LTOModule.cpp Tue Aug 10 18:46:39 2010 @@ -4,10 +4,10 @@ // // This file is distributed under the University of Illinois Open Source // License. See LICENSE.TXT for details. -// +// //===----------------------------------------------------------------------===// // -// This file implements the Link Time Optimization library. This library is +// This file implements the Link Time Optimization library. This library is // intended to be used by linker to optimize code at link time. // //===----------------------------------------------------------------------===// @@ -36,495 +36,472 @@ using namespace llvm; -bool LTOModule::isBitcodeFile(const void* mem, size_t length) -{ - return llvm::sys::IdentifyFileType((char*)mem, length) - == llvm::sys::Bitcode_FileType; +bool LTOModule::isBitcodeFile(const void *mem, size_t length) { + return llvm::sys::IdentifyFileType((char*)mem, length) + == llvm::sys::Bitcode_FileType; } -bool LTOModule::isBitcodeFile(const char* path) -{ - return llvm::sys::Path(path).isBitcodeFile(); +bool LTOModule::isBitcodeFile(const char *path) { + return llvm::sys::Path(path).isBitcodeFile(); } -bool LTOModule::isBitcodeFileForTarget(const void* mem, size_t length, - const char* triplePrefix) -{ - MemoryBuffer* buffer = makeBuffer(mem, length); - if (!buffer) - return false; - return isTargetMatch(buffer, triplePrefix); +bool LTOModule::isBitcodeFileForTarget(const void *mem, size_t length, + const char *triplePrefix) { + MemoryBuffer *buffer = makeBuffer(mem, length); + if (!buffer) + return false; + return isTargetMatch(buffer, triplePrefix); } -bool LTOModule::isBitcodeFileForTarget(const char* path, - const char* triplePrefix) -{ - MemoryBuffer *buffer = MemoryBuffer::getFile(path); - if (buffer == NULL) - return false; - return isTargetMatch(buffer, triplePrefix); +bool LTOModule::isBitcodeFileForTarget(const char *path, + const char *triplePrefix) { + MemoryBuffer *buffer = MemoryBuffer::getFile(path); + if (buffer == NULL) + return false; + return isTargetMatch(buffer, triplePrefix); } -// takes ownership of buffer -bool LTOModule::isTargetMatch(MemoryBuffer* buffer, const char* triplePrefix) -{ - OwningPtr m(getLazyBitcodeModule(buffer, getGlobalContext())); - // on success, m owns buffer and both are deleted at end of this method - if (!m) { - delete buffer; - return false; - } - std::string actualTarget = m->getTargetTriple(); - return (strncmp(actualTarget.c_str(), triplePrefix, - strlen(triplePrefix)) == 0); +// Takes ownership of buffer. +bool LTOModule::isTargetMatch(MemoryBuffer *buffer, const char *triplePrefix) { + OwningPtr m(getLazyBitcodeModule(buffer, getGlobalContext())); + // On success, m owns buffer and both are deleted at end of this method. + if (!m) { + delete buffer; + return false; + } + std::string actualTarget = m->getTargetTriple(); + return (strncmp(actualTarget.c_str(), triplePrefix, + strlen(triplePrefix)) == 0); } -LTOModule::LTOModule(Module* m, TargetMachine* t) - : _module(m), _target(t), _symbolsParsed(false) +LTOModule::LTOModule(Module *m, TargetMachine *t) + : _module(m), _target(t), _symbolsParsed(false) { } -LTOModule* LTOModule::makeLTOModule(const char* path, - std::string& errMsg) -{ - OwningPtr buffer(MemoryBuffer::getFile(path, &errMsg)); - if (!buffer) - return NULL; - return makeLTOModule(buffer.get(), errMsg); +LTOModule *LTOModule::makeLTOModule(const char *path, + std::string &errMsg) { + OwningPtr buffer(MemoryBuffer::getFile(path, &errMsg)); + if (!buffer) + return NULL; + return makeLTOModule(buffer.get(), errMsg); } -/// makeBuffer - create a MemoryBuffer from a memory range. -/// MemoryBuffer requires the byte past end of the buffer to be a zero. -/// We might get lucky and already be that way, otherwise make a copy. -/// Also if next byte is on a different page, don't assume it is readable. -MemoryBuffer* LTOModule::makeBuffer(const void* mem, size_t length) -{ - const char *startPtr = (char*)mem; - const char *endPtr = startPtr+length; - if (((uintptr_t)endPtr & (sys::Process::GetPageSize()-1)) == 0 || - *endPtr != 0) - return MemoryBuffer::getMemBufferCopy(StringRef(startPtr, length)); - - return MemoryBuffer::getMemBuffer(StringRef(startPtr, length)); +/// makeBuffer - Create a MemoryBuffer from a memory range. MemoryBuffer +/// requires the byte past end of the buffer to be a zero. We might get lucky +/// and already be that way, otherwise make a copy. Also if next byte is on a +/// different page, don't assume it is readable. +MemoryBuffer *LTOModule::makeBuffer(const void *mem, size_t length) { + const char *startPtr = (char*)mem; + const char *endPtr = startPtr+length; + if (((uintptr_t)endPtr & (sys::Process::GetPageSize()-1)) == 0 || + *endPtr != 0) + return MemoryBuffer::getMemBufferCopy(StringRef(startPtr, length)); + + return MemoryBuffer::getMemBuffer(StringRef(startPtr, length)); } -LTOModule* LTOModule::makeLTOModule(const void* mem, size_t length, - std::string& errMsg) -{ - OwningPtr buffer(makeBuffer(mem, length)); - if (!buffer) - return NULL; - return makeLTOModule(buffer.get(), errMsg); +LTOModule *LTOModule::makeLTOModule(const void *mem, size_t length, + std::string &errMsg) { + OwningPtr buffer(makeBuffer(mem, length)); + if (!buffer) + return NULL; + return makeLTOModule(buffer.get(), errMsg); } -LTOModule* LTOModule::makeLTOModule(MemoryBuffer* buffer, - std::string& errMsg) -{ - InitializeAllTargets(); +LTOModule *LTOModule::makeLTOModule(MemoryBuffer *buffer, + std::string &errMsg) { + InitializeAllTargets(); - // parse bitcode buffer - OwningPtr m(ParseBitcodeFile(buffer, getGlobalContext(), &errMsg)); - if (!m) - return NULL; + // parse bitcode buffer + OwningPtr m(ParseBitcodeFile(buffer, getGlobalContext(), &errMsg)); + if (!m) + return NULL; - std::string Triple = m->getTargetTriple(); - if (Triple.empty()) - Triple = sys::getHostTriple(); + std::string Triple = m->getTargetTriple(); + if (Triple.empty()) + Triple = sys::getHostTriple(); - // find machine architecture for this module - const Target* march = TargetRegistry::lookupTarget(Triple, errMsg); - if (!march) - return NULL; + // find machine architecture for this module + const Target *march = TargetRegistry::lookupTarget(Triple, errMsg); + if (!march) + return NULL; - // construct LTModule, hand over ownership of module and target - SubtargetFeatures Features; - Features.getDefaultSubtargetFeatures("" /* cpu */, llvm::Triple(Triple)); - std::string FeatureStr = Features.getString(); - TargetMachine* target = march->createTargetMachine(Triple, FeatureStr); - return new LTOModule(m.take(), target); + // construct LTModule, hand over ownership of module and target + SubtargetFeatures Features; + Features.getDefaultSubtargetFeatures("" /* cpu */, llvm::Triple(Triple)); + std::string FeatureStr = Features.getString(); + TargetMachine *target = march->createTargetMachine(Triple, FeatureStr); + return new LTOModule(m.take(), target); } -const char* LTOModule::getTargetTriple() -{ - return _module->getTargetTriple().c_str(); +const char *LTOModule::getTargetTriple() { + return _module->getTargetTriple().c_str(); } -void LTOModule::setTargetTriple(const char *triple) -{ - _module->setTargetTriple(triple); +void LTOModule::setTargetTriple(const char *triple) { + _module->setTargetTriple(triple); } -void LTOModule::addDefinedFunctionSymbol(Function* f, Mangler &mangler) -{ - // add to list of defined symbols - addDefinedSymbol(f, mangler, true); +void LTOModule::addDefinedFunctionSymbol(Function *f, Mangler &mangler) { + // add to list of defined symbols + addDefinedSymbol(f, mangler, true); - // add external symbols referenced by this function. - for (Function::iterator b = f->begin(); b != f->end(); ++b) { - for (BasicBlock::iterator i = b->begin(); i != b->end(); ++i) { - for (unsigned count = 0, total = i->getNumOperands(); - count != total; ++count) { - findExternalRefs(i->getOperand(count), mangler); - } - } + // add external symbols referenced by this function. + for (Function::iterator b = f->begin(); b != f->end(); ++b) { + for (BasicBlock::iterator i = b->begin(); i != b->end(); ++i) { + for (unsigned count = 0, total = i->getNumOperands(); + count != total; ++count) { + findExternalRefs(i->getOperand(count), mangler); + } } + } } -// get string that data pointer points to -bool LTOModule::objcClassNameFromExpression(Constant* c, std::string& name) -{ - if (ConstantExpr* ce = dyn_cast(c)) { - Constant* op = ce->getOperand(0); - if (GlobalVariable* gvn = dyn_cast(op)) { - Constant* cn = gvn->getInitializer(); - if (ConstantArray* ca = dyn_cast(cn)) { - if (ca->isCString()) { - name = ".objc_class_name_" + ca->getAsString(); - return true; - } - } +// Get string that data pointer points to. +bool LTOModule::objcClassNameFromExpression(Constant *c, std::string &name) { + if (ConstantExpr *ce = dyn_cast(c)) { + Constant *op = ce->getOperand(0); + if (GlobalVariable *gvn = dyn_cast(op)) { + Constant *cn = gvn->getInitializer(); + if (ConstantArray *ca = dyn_cast(cn)) { + if (ca->isCString()) { + name = ".objc_class_name_" + ca->getAsString(); + return true; } + } } - return false; + } + return false; } -// parse i386/ppc ObjC class data structure -void LTOModule::addObjCClass(GlobalVariable* clgv) -{ - if (ConstantStruct* c = dyn_cast(clgv->getInitializer())) { - // second slot in __OBJC,__class is pointer to superclass name - std::string superclassName; - if (objcClassNameFromExpression(c->getOperand(1), superclassName)) { - NameAndAttributes info; - if (_undefines.find(superclassName.c_str()) == _undefines.end()) { - const char* symbolName = ::strdup(superclassName.c_str()); - info.name = ::strdup(symbolName); - info.attributes = LTO_SYMBOL_DEFINITION_UNDEFINED; - // string is owned by _undefines - _undefines[info.name] = info; - } - } - // third slot in __OBJC,__class is pointer to class name - std::string className; - if (objcClassNameFromExpression(c->getOperand(2), className)) { - const char* symbolName = ::strdup(className.c_str()); - NameAndAttributes info; - info.name = symbolName; - info.attributes = (lto_symbol_attributes) - (LTO_SYMBOL_PERMISSIONS_DATA | - LTO_SYMBOL_DEFINITION_REGULAR | - LTO_SYMBOL_SCOPE_DEFAULT); - _symbols.push_back(info); - _defines[info.name] = 1; - } - } +// Parse i386/ppc ObjC class data structure. +void LTOModule::addObjCClass(GlobalVariable *clgv) { + if (ConstantStruct *c = dyn_cast(clgv->getInitializer())) { + // second slot in __OBJC,__class is pointer to superclass name + std::string superclassName; + if (objcClassNameFromExpression(c->getOperand(1), superclassName)) { + NameAndAttributes info; + if (_undefines.find(superclassName.c_str()) == _undefines.end()) { + const char *symbolName = ::strdup(superclassName.c_str()); + info.name = ::strdup(symbolName); + info.attributes = LTO_SYMBOL_DEFINITION_UNDEFINED; + // string is owned by _undefines + _undefines[info.name] = info; + } + } + // third slot in __OBJC,__class is pointer to class name + std::string className; + if (objcClassNameFromExpression(c->getOperand(2), className)) { + const char *symbolName = ::strdup(className.c_str()); + NameAndAttributes info; + info.name = symbolName; + info.attributes = (lto_symbol_attributes) + (LTO_SYMBOL_PERMISSIONS_DATA | + LTO_SYMBOL_DEFINITION_REGULAR | + LTO_SYMBOL_SCOPE_DEFAULT); + _symbols.push_back(info); + _defines[info.name] = 1; + } + } } -// parse i386/ppc ObjC category data structure -void LTOModule::addObjCCategory(GlobalVariable* clgv) -{ - if (ConstantStruct* c = dyn_cast(clgv->getInitializer())) { - // second slot in __OBJC,__category is pointer to target class name - std::string targetclassName; - if (objcClassNameFromExpression(c->getOperand(1), targetclassName)) { - NameAndAttributes info; - if (_undefines.find(targetclassName.c_str()) == _undefines.end()) { - const char* symbolName = ::strdup(targetclassName.c_str()); - info.name = ::strdup(symbolName); - info.attributes = LTO_SYMBOL_DEFINITION_UNDEFINED; - // string is owned by _undefines - _undefines[info.name] = info; - } - } - } -} - - -// parse i386/ppc ObjC class list data structure -void LTOModule::addObjCClassRef(GlobalVariable* clgv) -{ +// Parse i386/ppc ObjC category data structure. +void LTOModule::addObjCCategory(GlobalVariable *clgv) { + if (ConstantStruct *c = dyn_cast(clgv->getInitializer())) { + // second slot in __OBJC,__category is pointer to target class name std::string targetclassName; - if (objcClassNameFromExpression(clgv->getInitializer(), targetclassName)) { - NameAndAttributes info; - if (_undefines.find(targetclassName.c_str()) == _undefines.end()) { - const char* symbolName = ::strdup(targetclassName.c_str()); - info.name = ::strdup(symbolName); - info.attributes = LTO_SYMBOL_DEFINITION_UNDEFINED; - // string is owned by _undefines - _undefines[info.name] = info; - } - } -} - - -void LTOModule::addDefinedDataSymbol(GlobalValue* v, Mangler& mangler) -{ - // add to list of defined symbols - addDefinedSymbol(v, mangler, false); - - // Special case i386/ppc ObjC data structures in magic sections: - // The issue is that the old ObjC object format did some strange - // contortions to avoid real linker symbols. For instance, the - // ObjC class data structure is allocated statically in the executable - // that defines that class. That data structures contains a pointer to - // its superclass. But instead of just initializing that part of the - // struct to the address of its superclass, and letting the static and - // dynamic linkers do the rest, the runtime works by having that field - // instead point to a C-string that is the name of the superclass. - // At runtime the objc initialization updates that pointer and sets - // it to point to the actual super class. As far as the linker - // knows it is just a pointer to a string. But then someone wanted the - // linker to issue errors at build time if the superclass was not found. - // So they figured out a way in mach-o object format to use an absolute - // symbols (.objc_class_name_Foo = 0) and a floating reference - // (.reference .objc_class_name_Bar) to cause the linker into erroring when - // a class was missing. - // The following synthesizes the implicit .objc_* symbols for the linker - // from the ObjC data structures generated by the front end. - if (v->hasSection() /* && isTargetDarwin */) { - // special case if this data blob is an ObjC class definition - if (v->getSection().compare(0, 15, "__OBJC,__class,") == 0) { - if (GlobalVariable* gv = dyn_cast(v)) { - addObjCClass(gv); - } - } - - // special case if this data blob is an ObjC category definition - else if (v->getSection().compare(0, 18, "__OBJC,__category,") == 0) { - if (GlobalVariable* gv = dyn_cast(v)) { - addObjCCategory(gv); - } - } - - // special case if this data blob is the list of referenced classes - else if (v->getSection().compare(0, 18, "__OBJC,__cls_refs,") == 0) { - if (GlobalVariable* gv = dyn_cast(v)) { - addObjCClassRef(gv); - } - } - } - - // add external symbols referenced by this data. - for (unsigned count = 0, total = v->getNumOperands(); - count != total; ++count) { - findExternalRefs(v->getOperand(count), mangler); - } -} - - -void LTOModule::addDefinedSymbol(GlobalValue* def, Mangler &mangler, - bool isFunction) -{ - // ignore all llvm.* symbols - if (def->getName().startswith("llvm.")) - return; - - // string is owned by _defines - const char* symbolName = ::strdup(mangler.getNameWithPrefix(def).c_str()); - - // set alignment part log2() can have rounding errors - uint32_t align = def->getAlignment(); - uint32_t attr = align ? CountTrailingZeros_32(def->getAlignment()) : 0; - - // set permissions part - if (isFunction) - attr |= LTO_SYMBOL_PERMISSIONS_CODE; - else { - GlobalVariable* gv = dyn_cast(def); - if (gv && gv->isConstant()) - attr |= LTO_SYMBOL_PERMISSIONS_RODATA; - else - attr |= LTO_SYMBOL_PERMISSIONS_DATA; - } - - // set definition part - if (def->hasWeakLinkage() || def->hasLinkOnceLinkage()) { - attr |= LTO_SYMBOL_DEFINITION_WEAK; - } - else if (def->hasCommonLinkage()) { - attr |= LTO_SYMBOL_DEFINITION_TENTATIVE; - } - else { - attr |= LTO_SYMBOL_DEFINITION_REGULAR; - } - - // set scope part - if (def->hasHiddenVisibility()) - attr |= LTO_SYMBOL_SCOPE_HIDDEN; - else if (def->hasProtectedVisibility()) - attr |= LTO_SYMBOL_SCOPE_PROTECTED; - else if (def->hasExternalLinkage() || def->hasWeakLinkage() - || def->hasLinkOnceLinkage() || def->hasCommonLinkage()) - attr |= LTO_SYMBOL_SCOPE_DEFAULT; - else - attr |= LTO_SYMBOL_SCOPE_INTERNAL; - - // add to table of symbols - NameAndAttributes info; - info.name = symbolName; - info.attributes = (lto_symbol_attributes)attr; - _symbols.push_back(info); - _defines[info.name] = 1; + if (objcClassNameFromExpression(c->getOperand(1), targetclassName)) { + NameAndAttributes info; + if (_undefines.find(targetclassName.c_str()) == _undefines.end()) { + const char *symbolName = ::strdup(targetclassName.c_str()); + info.name = ::strdup(symbolName); + info.attributes = LTO_SYMBOL_DEFINITION_UNDEFINED; + // string is owned by _undefines + _undefines[info.name] = info; + } + } + } } -void LTOModule::addAsmGlobalSymbol(const char *name) { - // only add new define if not already defined - if (_defines.count(name) == 0) - return; - - // string is owned by _defines - const char *symbolName = ::strdup(name); - uint32_t attr = LTO_SYMBOL_DEFINITION_REGULAR; - attr |= LTO_SYMBOL_SCOPE_DEFAULT; - NameAndAttributes info; - info.name = symbolName; - info.attributes = (lto_symbol_attributes)attr; - _symbols.push_back(info); - _defines[info.name] = 1; -} - -void LTOModule::addPotentialUndefinedSymbol(GlobalValue* decl, Mangler &mangler) -{ - // ignore all llvm.* symbols - if (decl->getName().startswith("llvm.")) - return; - - // ignore all aliases - if (isa(decl)) - return; - - std::string name = mangler.getNameWithPrefix(decl); - - // we already have the symbol - if (_undefines.find(name) != _undefines.end()) - return; +// Parse i386/ppc ObjC class list data structure. +void LTOModule::addObjCClassRef(GlobalVariable *clgv) { + std::string targetclassName; + if (objcClassNameFromExpression(clgv->getInitializer(), targetclassName)) { NameAndAttributes info; - // string is owned by _undefines - info.name = ::strdup(name.c_str()); - if (decl->hasExternalWeakLinkage()) - info.attributes = LTO_SYMBOL_DEFINITION_WEAKUNDEF; - else + if (_undefines.find(targetclassName.c_str()) == _undefines.end()) { + const char *symbolName = ::strdup(targetclassName.c_str()); + info.name = ::strdup(symbolName); info.attributes = LTO_SYMBOL_DEFINITION_UNDEFINED; - _undefines[name] = info; -} - - - -// Find external symbols referenced by VALUE. This is a recursive function. -void LTOModule::findExternalRefs(Value* value, Mangler &mangler) { - - if (GlobalValue* gv = dyn_cast(value)) { - if (!gv->hasExternalLinkage()) - addPotentialUndefinedSymbol(gv, mangler); - // If this is a variable definition, do not recursively process - // initializer. It might contain a reference to this variable - // and cause an infinite loop. The initializer will be - // processed in addDefinedDataSymbol(). - return; - } - - // GlobalValue, even with InternalLinkage type, may have operands with - // ExternalLinkage type. Do not ignore these operands. - if (Constant* c = dyn_cast(value)) { - // Handle ConstantExpr, ConstantStruct, ConstantArry etc. - for (unsigned i = 0, e = c->getNumOperands(); i != e; ++i) - findExternalRefs(c->getOperand(i), mangler); + // string is owned by _undefines + _undefines[info.name] = info; } + } } -void LTOModule::lazyParseSymbols() -{ - if (!_symbolsParsed) { - _symbolsParsed = true; - - // Use mangler to add GlobalPrefix to names to match linker names. - MCContext Context(*_target->getMCAsmInfo()); - Mangler mangler(Context, *_target->getTargetData()); - - // add functions - for (Module::iterator f = _module->begin(); f != _module->end(); ++f) { - if (f->isDeclaration()) - addPotentialUndefinedSymbol(f, mangler); - else - addDefinedFunctionSymbol(f, mangler); - } - - // add data - for (Module::global_iterator v = _module->global_begin(), - e = _module->global_end(); v != e; ++v) { - if (v->isDeclaration()) - addPotentialUndefinedSymbol(v, mangler); - else - addDefinedDataSymbol(v, mangler); - } - // add asm globals - const std::string &inlineAsm = _module->getModuleInlineAsm(); - const std::string glbl = ".globl"; - std::string asmSymbolName; - std::string::size_type pos = inlineAsm.find(glbl, 0); - while (pos != std::string::npos) { - // eat .globl - pos = pos + 6; - - // skip white space between .globl and symbol name - std::string::size_type pbegin = inlineAsm.find_first_not_of(' ', pos); - if (pbegin == std::string::npos) - break; - - // find end-of-line - std::string::size_type pend = inlineAsm.find_first_of('\n', pbegin); - if (pend == std::string::npos) - break; - - asmSymbolName.assign(inlineAsm, pbegin, pend - pbegin); - addAsmGlobalSymbol(asmSymbolName.c_str()); +void LTOModule::addDefinedDataSymbol(GlobalValue *v, Mangler &mangler) { + // Add to list of defined symbols. + addDefinedSymbol(v, mangler, false); + + // Special case i386/ppc ObjC data structures in magic sections: + // The issue is that the old ObjC object format did some strange + // contortions to avoid real linker symbols. For instance, the + // ObjC class data structure is allocated statically in the executable + // that defines that class. That data structures contains a pointer to + // its superclass. But instead of just initializing that part of the + // struct to the address of its superclass, and letting the static and + // dynamic linkers do the rest, the runtime works by having that field + // instead point to a C-string that is the name of the superclass. + // At runtime the objc initialization updates that pointer and sets + // it to point to the actual super class. As far as the linker + // knows it is just a pointer to a string. But then someone wanted the + // linker to issue errors at build time if the superclass was not found. + // So they figured out a way in mach-o object format to use an absolute + // symbols (.objc_class_name_Foo = 0) and a floating reference + // (.reference .objc_class_name_Bar) to cause the linker into erroring when + // a class was missing. + // The following synthesizes the implicit .objc_* symbols for the linker + // from the ObjC data structures generated by the front end. + if (v->hasSection() /* && isTargetDarwin */) { + // special case if this data blob is an ObjC class definition + if (v->getSection().compare(0, 15, "__OBJC,__class,") == 0) { + if (GlobalVariable *gv = dyn_cast(v)) { + addObjCClass(gv); + } + } + + // special case if this data blob is an ObjC category definition + else if (v->getSection().compare(0, 18, "__OBJC,__category,") == 0) { + if (GlobalVariable *gv = dyn_cast(v)) { + addObjCCategory(gv); + } + } + + // special case if this data blob is the list of referenced classes + else if (v->getSection().compare(0, 18, "__OBJC,__cls_refs,") == 0) { + if (GlobalVariable *gv = dyn_cast(v)) { + addObjCClassRef(gv); + } + } + } + + // add external symbols referenced by this data. + for (unsigned count = 0, total = v->getNumOperands(); + count != total; ++count) { + findExternalRefs(v->getOperand(count), mangler); + } +} + + +void LTOModule::addDefinedSymbol(GlobalValue *def, Mangler &mangler, + bool isFunction) { + // ignore all llvm.* symbols + if (def->getName().startswith("llvm.")) + return; + + // string is owned by _defines + const char *symbolName = ::strdup(mangler.getNameWithPrefix(def).c_str()); + + // set alignment part log2() can have rounding errors + uint32_t align = def->getAlignment(); + uint32_t attr = align ? CountTrailingZeros_32(def->getAlignment()) : 0; + + // set permissions part + if (isFunction) + attr |= LTO_SYMBOL_PERMISSIONS_CODE; + else { + GlobalVariable *gv = dyn_cast(def); + if (gv && gv->isConstant()) + attr |= LTO_SYMBOL_PERMISSIONS_RODATA; + else + attr |= LTO_SYMBOL_PERMISSIONS_DATA; + } - // search next .globl - pos = inlineAsm.find(glbl, pend); - } + // set definition part + if (def->hasWeakLinkage() || def->hasLinkOnceLinkage()) { + attr |= LTO_SYMBOL_DEFINITION_WEAK; + } + else if (def->hasCommonLinkage()) { + attr |= LTO_SYMBOL_DEFINITION_TENTATIVE; + } + else { + attr |= LTO_SYMBOL_DEFINITION_REGULAR; + } + + // set scope part + if (def->hasHiddenVisibility()) + attr |= LTO_SYMBOL_SCOPE_HIDDEN; + else if (def->hasProtectedVisibility()) + attr |= LTO_SYMBOL_SCOPE_PROTECTED; + else if (def->hasExternalLinkage() || def->hasWeakLinkage() + || def->hasLinkOnceLinkage() || def->hasCommonLinkage()) + attr |= LTO_SYMBOL_SCOPE_DEFAULT; + else + attr |= LTO_SYMBOL_SCOPE_INTERNAL; - // make symbols for all undefines - for (StringMap::iterator it=_undefines.begin(); - it != _undefines.end(); ++it) { - // if this symbol also has a definition, then don't make an undefine - // because it is a tentative definition - if (_defines.count(it->getKey()) == 0) { - NameAndAttributes info = it->getValue(); - _symbols.push_back(info); - } - } - } + // add to table of symbols + NameAndAttributes info; + info.name = symbolName; + info.attributes = (lto_symbol_attributes)attr; + _symbols.push_back(info); + _defines[info.name] = 1; } - -uint32_t LTOModule::getSymbolCount() -{ - lazyParseSymbols(); - return _symbols.size(); +void LTOModule::addAsmGlobalSymbol(const char *name) { + // only add new define if not already defined + if (_defines.count(name) == 0) + return; + + // string is owned by _defines + const char *symbolName = ::strdup(name); + uint32_t attr = LTO_SYMBOL_DEFINITION_REGULAR; + attr |= LTO_SYMBOL_SCOPE_DEFAULT; + NameAndAttributes info; + info.name = symbolName; + info.attributes = (lto_symbol_attributes)attr; + _symbols.push_back(info); + _defines[info.name] = 1; +} + +void LTOModule::addPotentialUndefinedSymbol(GlobalValue *decl, + Mangler &mangler) { + // ignore all llvm.* symbols + if (decl->getName().startswith("llvm.")) + return; + + // ignore all aliases + if (isa(decl)) + return; + + std::string name = mangler.getNameWithPrefix(decl); + + // we already have the symbol + if (_undefines.find(name) != _undefines.end()) + return; + + NameAndAttributes info; + // string is owned by _undefines + info.name = ::strdup(name.c_str()); + if (decl->hasExternalWeakLinkage()) + info.attributes = LTO_SYMBOL_DEFINITION_WEAKUNDEF; + else + info.attributes = LTO_SYMBOL_DEFINITION_UNDEFINED; + _undefines[name] = info; } -lto_symbol_attributes LTOModule::getSymbolAttributes(uint32_t index) -{ - lazyParseSymbols(); - if (index < _symbols.size()) - return _symbols[index].attributes; - else - return lto_symbol_attributes(0); -} -const char* LTOModule::getSymbolName(uint32_t index) -{ - lazyParseSymbols(); - if (index < _symbols.size()) - return _symbols[index].name; - else - return NULL; +// Find external symbols referenced by VALUE. This is a recursive function. +void LTOModule::findExternalRefs(Value *value, Mangler &mangler) { + if (GlobalValue *gv = dyn_cast(value)) { + if (!gv->hasExternalLinkage()) + addPotentialUndefinedSymbol(gv, mangler); + // If this is a variable definition, do not recursively process + // initializer. It might contain a reference to this variable + // and cause an infinite loop. The initializer will be + // processed in addDefinedDataSymbol(). + return; + } + + // GlobalValue, even with InternalLinkage type, may have operands with + // ExternalLinkage type. Do not ignore these operands. + if (Constant *c = dyn_cast(value)) { + // Handle ConstantExpr, ConstantStruct, ConstantArry etc. + for (unsigned i = 0, e = c->getNumOperands(); i != e; ++i) + findExternalRefs(c->getOperand(i), mangler); + } +} + +void LTOModule::lazyParseSymbols() { + if (!_symbolsParsed) { + _symbolsParsed = true; + + // Use mangler to add GlobalPrefix to names to match linker names. + MCContext Context(*_target->getMCAsmInfo()); + Mangler mangler(Context, *_target->getTargetData()); + + // add functions + for (Module::iterator f = _module->begin(); f != _module->end(); ++f) { + if (f->isDeclaration()) + addPotentialUndefinedSymbol(f, mangler); + else + addDefinedFunctionSymbol(f, mangler); + } + + // add data + for (Module::global_iterator v = _module->global_begin(), + e = _module->global_end(); v != e; ++v) { + if (v->isDeclaration()) + addPotentialUndefinedSymbol(v, mangler); + else + addDefinedDataSymbol(v, mangler); + } + + // add asm globals + const std::string &inlineAsm = _module->getModuleInlineAsm(); + const std::string glbl = ".globl"; + std::string asmSymbolName; + std::string::size_type pos = inlineAsm.find(glbl, 0); + while (pos != std::string::npos) { + // eat .globl + pos = pos + 6; + + // skip white space between .globl and symbol name + std::string::size_type pbegin = inlineAsm.find_first_not_of(' ', pos); + if (pbegin == std::string::npos) + break; + + // find end-of-line + std::string::size_type pend = inlineAsm.find_first_of('\n', pbegin); + if (pend == std::string::npos) + break; + + asmSymbolName.assign(inlineAsm, pbegin, pend - pbegin); + addAsmGlobalSymbol(asmSymbolName.c_str()); + + // search next .globl + pos = inlineAsm.find(glbl, pend); + } + + // make symbols for all undefines + for (StringMap::iterator it=_undefines.begin(); + it != _undefines.end(); ++it) { + // if this symbol also has a definition, then don't make an undefine + // because it is a tentative definition + if (_defines.count(it->getKey()) == 0) { + NameAndAttributes info = it->getValue(); + _symbols.push_back(info); + } + } + } +} + + +uint32_t LTOModule::getSymbolCount() { + lazyParseSymbols(); + return _symbols.size(); +} + + +lto_symbol_attributes LTOModule::getSymbolAttributes(uint32_t index) { + lazyParseSymbols(); + if (index < _symbols.size()) + return _symbols[index].attributes; + else + return lto_symbol_attributes(0); +} + +const char *LTOModule::getSymbolName(uint32_t index) { + lazyParseSymbols(); + if (index < _symbols.size()) + return _symbols[index].name; + else + return NULL; } From daniel at zuster.org Tue Aug 10 18:46:46 2010 From: daniel at zuster.org (Daniel Dunbar) Date: Tue, 10 Aug 2010 23:46:46 -0000 Subject: [llvm-commits] [llvm] r110752 - /llvm/trunk/tools/lto/LTOModule.cpp Message-ID: <20100810234647.013E32A6C12D@llvm.org> Author: ddunbar Date: Tue Aug 10 18:46:46 2010 New Revision: 110752 URL: http://llvm.org/viewvc/llvm-project?rev=110752&view=rev Log: lto: Reduce nesting. Modified: llvm/trunk/tools/lto/LTOModule.cpp Modified: llvm/trunk/tools/lto/LTOModule.cpp URL: http://llvm.org/viewvc/llvm-project/llvm/trunk/tools/lto/LTOModule.cpp?rev=110752&r1=110751&r2=110752&view=diff ============================================================================== --- llvm/trunk/tools/lto/LTOModule.cpp (original) +++ llvm/trunk/tools/lto/LTOModule.cpp Tue Aug 10 18:46:46 2010 @@ -420,65 +420,66 @@ } void LTOModule::lazyParseSymbols() { - if (!_symbolsParsed) { - _symbolsParsed = true; + if (_symbolsParsed) + return; - // Use mangler to add GlobalPrefix to names to match linker names. - MCContext Context(*_target->getMCAsmInfo()); - Mangler mangler(Context, *_target->getTargetData()); - - // add functions - for (Module::iterator f = _module->begin(); f != _module->end(); ++f) { - if (f->isDeclaration()) - addPotentialUndefinedSymbol(f, mangler); - else - addDefinedFunctionSymbol(f, mangler); - } + _symbolsParsed = true; - // add data - for (Module::global_iterator v = _module->global_begin(), - e = _module->global_end(); v != e; ++v) { - if (v->isDeclaration()) - addPotentialUndefinedSymbol(v, mangler); - else - addDefinedDataSymbol(v, mangler); - } + // Use mangler to add GlobalPrefix to names to match linker names. + MCContext Context(*_target->getMCAsmInfo()); + Mangler mangler(Context, *_target->getTargetData()); + + // add functions + for (Module::iterator f = _module->begin(); f != _module->end(); ++f) { + if (f->isDeclaration()) + addPotentialUndefinedSymbol(f, mangler); + else + addDefinedFunctionSymbol(f, mangler); + } - // add asm globals - const std::string &inlineAsm = _module->getModuleInlineAsm(); - const std::string glbl = ".globl"; - std::string asmSymbolName; - std::string::size_type pos = inlineAsm.find(glbl, 0); - while (pos != std::string::npos) { - // eat .globl - pos = pos + 6; - - // skip white space between .globl and symbol name - std::string::size_type pbegin = inlineAsm.find_first_not_of(' ', pos); - if (pbegin == std::string::npos) - break; - - // find end-of-line - std::string::size_type pend = inlineAsm.find_first_of('\n', pbegin); - if (pend == std::string::npos) - break; + // add data + for (Module::global_iterator v = _module->global_begin(), + e = _module->global_end(); v != e; ++v) { + if (v->isDeclaration()) + addPotentialUndefinedSymbol(v, mangler); + else + addDefinedDataSymbol(v, mangler); + } - asmSymbolName.assign(inlineAsm, pbegin, pend - pbegin); - addAsmGlobalSymbol(asmSymbolName.c_str()); + // add asm globals + const std::string &inlineAsm = _module->getModuleInlineAsm(); + const std::string glbl = ".globl"; + std::string asmSymbolName; + std::string::size_type pos = inlineAsm.find(glbl, 0); + while (pos != std::string::npos) { + // eat .globl + pos = pos + 6; + + // skip white space between .globl and symbol name + std::string::size_type pbegin = inlineAsm.find_first_not_of(' ', pos); + if (pbegin == std::string::npos) + break; + + // find end-of-line + std::string::size_type pend = inlineAsm.find_first_of('\n', pbegin); + if (pend == std::string::npos) + break; - // search next .globl - pos = inlineAsm.find(glbl, pend); - } + asmSymbolName.assign(inlineAsm, pbegin, pend - pbegin); + addAsmGlobalSymbol(asmSymbolName.c_str()); + + // search next .globl + pos = inlineAsm.find(glbl, pend); + } - // make symbols for all undefines - for (StringMap::iterator it=_undefines.begin(); - it != _undefines.end(); ++it) { - // if this symbol also has a definition, then don't make an undefine - // because it is a tentative definition - if (_defines.count(it->getKey()) == 0) { - NameAndAttributes info = it->getValue(); - _symbols.push_back(info); - } + // make symbols for all undefines + for (StringMap::iterator it=_undefines.begin(); + it != _undefines.end(); ++it) { + // if this symbol also has a definition, then don't make an undefine + // because it is a tentative definition + if (_defines.count(it->getKey()) == 0) { + NameAndAttributes info = it->getValue(); + _symbols.push_back(info); } } } From ofv at wanadoo.es Tue Aug 10 18:48:22 2010 From: ofv at wanadoo.es (Oscar Fuentes) Date: Tue, 10 Aug 2010 23:48:22 -0000 Subject: [llvm-commits] [llvm] r110753 - in /llvm/trunk/include/llvm/Config: config.h.cmake llvm-config.h.cmake Message-ID: <20100810234822.5FEC12A6C12C@llvm.org> Author: ofv Date: Tue Aug 10 18:48:22 2010 New Revision: 110753 URL: http://llvm.org/viewvc/llvm-project?rev=110753&view=rev Log: Avoid multiple definition warnings when both config.h and llvm-config.h are included. This is the cmake counterpart of r110547. See bug #7809. Modified: llvm/trunk/include/llvm/Config/config.h.cmake llvm/trunk/include/llvm/Config/llvm-config.h.cmake Modified: llvm/trunk/include/llvm/Config/config.h.cmake URL: http://llvm.org/viewvc/llvm-project/llvm/trunk/include/llvm/Config/config.h.cmake?rev=110753&r1=110752&r2=110753&view=diff ============================================================================== --- llvm/trunk/include/llvm/Config/config.h.cmake (original) +++ llvm/trunk/include/llvm/Config/config.h.cmake Tue Aug 10 18:48:22 2010 @@ -3,6 +3,9 @@ ** Created by Kevin from config.h.in ** ***************************************/ +#ifndef CONFIG_H +#define CONFIG_H + /* Define if dlopen(0) will open the symbols of the program */ #undef CAN_DLOPEN_SELF @@ -628,3 +631,5 @@ /* Native LLVM architecture, short name */ #cmakedefine LLVM_NATIVE_ARCHNAME ${LLVM_NATIVE_ARCH} + +#endif Modified: llvm/trunk/include/llvm/Config/llvm-config.h.cmake URL: http://llvm.org/viewvc/llvm-project/llvm/trunk/include/llvm/Config/llvm-config.h.cmake?rev=110753&r1=110752&r2=110753&view=diff ============================================================================== --- llvm/trunk/include/llvm/Config/llvm-config.h.cmake (original) +++ llvm/trunk/include/llvm/Config/llvm-config.h.cmake Tue Aug 10 18:48:22 2010 @@ -11,6 +11,11 @@ they can be in exported headers and won't override package specific directives. This is a C file so we can include it in the llvm-c headers. */ +/* To avoid multiple inclusions of these variables when we include the exported + headers and config.h, conditionally include these. */ +/* TODO: This is a bit of a hack. */ +#ifndef CONFIG_H + /* Installation directory for binary executables */ #cmakedefine LLVM_BINDIR "${LLVM_BINDIR}" @@ -82,3 +87,5 @@ /* Installation prefix directory */ #cmakedefine LLVM_PREFIX "${LLVM_PREFIX}" + +#endif From echristo at apple.com Tue Aug 10 18:49:55 2010 From: echristo at apple.com (Eric Christopher) Date: Tue, 10 Aug 2010 16:49:55 -0700 Subject: [llvm-commits] [llvm] r110753 - in /llvm/trunk/include/llvm/Config: config.h.cmake llvm-config.h.cmake In-Reply-To: <20100810234822.5FEC12A6C12C@llvm.org> References: <20100810234822.5FEC12A6C12C@llvm.org> Message-ID: <712C4129-BE98-4339-AD31-4204FE7A7CB1@apple.com> On Aug 10, 2010, at 4:48 PM, Oscar Fuentes wrote: > Author: ofv > Date: Tue Aug 10 18:48:22 2010 > New Revision: 110753 > > URL: http://llvm.org/viewvc/llvm-project?rev=110753&view=rev > Log: > Avoid multiple definition warnings when both config.h and > llvm-config.h are included. > > This is the cmake counterpart of r110547. See bug #7809. Thanks! -eric From bob.wilson at apple.com Tue Aug 10 19:01:18 2010 From: bob.wilson at apple.com (Bob Wilson) Date: Wed, 11 Aug 2010 00:01:18 -0000 Subject: [llvm-commits] [llvm] r110754 - in /llvm/trunk: lib/Target/ARM/ARMBaseInstrInfo.h lib/Target/ARM/ARMCodeEmitter.cpp lib/Target/ARM/ARMInstrFormats.td lib/Target/ARM/ARMInstrInfo.td lib/Target/ARM/Disassembler/ARMDisassemblerCore.cpp lib/Target/ARM/Disassembler/ARMDisassemblerCore.h utils/TableGen/ARMDecoderEmitter.cpp Message-ID: <20100811000118.7FCFA2A6C12C@llvm.org> Author: bwilson Date: Tue Aug 10 19:01:18 2010 New Revision: 110754 URL: http://llvm.org/viewvc/llvm-project?rev=110754&view=rev Log: Add a separate ARM instruction format for Saturate instructions. (I discovered 2 more copies of the ARM instruction format list, bringing the total to 4!! Two of them were already out of sync. I haven't yet gotten into the disassembler enough to know the best way to fix this, but something needs to be done.) Add support for encoding these instructions. Modified: llvm/trunk/lib/Target/ARM/ARMBaseInstrInfo.h llvm/trunk/lib/Target/ARM/ARMCodeEmitter.cpp llvm/trunk/lib/Target/ARM/ARMInstrFormats.td llvm/trunk/lib/Target/ARM/ARMInstrInfo.td llvm/trunk/lib/Target/ARM/Disassembler/ARMDisassemblerCore.cpp llvm/trunk/lib/Target/ARM/Disassembler/ARMDisassemblerCore.h llvm/trunk/utils/TableGen/ARMDecoderEmitter.cpp Modified: llvm/trunk/lib/Target/ARM/ARMBaseInstrInfo.h URL: http://llvm.org/viewvc/llvm-project/llvm/trunk/lib/Target/ARM/ARMBaseInstrInfo.h?rev=110754&r1=110753&r2=110754&view=diff ============================================================================== --- llvm/trunk/lib/Target/ARM/ARMBaseInstrInfo.h (original) +++ llvm/trunk/lib/Target/ARM/ARMBaseInstrInfo.h Tue Aug 10 19:01:18 2010 @@ -98,44 +98,45 @@ // Miscellaneous arithmetic instructions ArithMiscFrm = 12 << FormShift, + SatFrm = 13 << FormShift, // Extend instructions - ExtFrm = 13 << FormShift, + ExtFrm = 14 << FormShift, // VFP formats - VFPUnaryFrm = 14 << FormShift, - VFPBinaryFrm = 15 << FormShift, - VFPConv1Frm = 16 << FormShift, - VFPConv2Frm = 17 << FormShift, - VFPConv3Frm = 18 << FormShift, - VFPConv4Frm = 19 << FormShift, - VFPConv5Frm = 20 << FormShift, - VFPLdStFrm = 21 << FormShift, - VFPLdStMulFrm = 22 << FormShift, - VFPMiscFrm = 23 << FormShift, + VFPUnaryFrm = 15 << FormShift, + VFPBinaryFrm = 16 << FormShift, + VFPConv1Frm = 17 << FormShift, + VFPConv2Frm = 18 << FormShift, + VFPConv3Frm = 19 << FormShift, + VFPConv4Frm = 20 << FormShift, + VFPConv5Frm = 21 << FormShift, + VFPLdStFrm = 22 << FormShift, + VFPLdStMulFrm = 23 << FormShift, + VFPMiscFrm = 24 << FormShift, // Thumb format - ThumbFrm = 24 << FormShift, + ThumbFrm = 25 << FormShift, // Miscelleaneous format - MiscFrm = 25 << FormShift, + MiscFrm = 26 << FormShift, // NEON formats - NGetLnFrm = 26 << FormShift, - NSetLnFrm = 27 << FormShift, - NDupFrm = 28 << FormShift, - NLdStFrm = 29 << FormShift, - N1RegModImmFrm= 30 << FormShift, - N2RegFrm = 31 << FormShift, - NVCVTFrm = 32 << FormShift, - NVDupLnFrm = 33 << FormShift, - N2RegVShLFrm = 34 << FormShift, - N2RegVShRFrm = 35 << FormShift, - N3RegFrm = 36 << FormShift, - N3RegVShFrm = 37 << FormShift, - NVExtFrm = 38 << FormShift, - NVMulSLFrm = 39 << FormShift, - NVTBLFrm = 40 << FormShift, + NGetLnFrm = 27 << FormShift, + NSetLnFrm = 28 << FormShift, + NDupFrm = 29 << FormShift, + NLdStFrm = 30 << FormShift, + N1RegModImmFrm= 31 << FormShift, + N2RegFrm = 32 << FormShift, + NVCVTFrm = 33 << FormShift, + NVDupLnFrm = 34 << FormShift, + N2RegVShLFrm = 35 << FormShift, + N2RegVShRFrm = 36 << FormShift, + N3RegFrm = 37 << FormShift, + N3RegVShFrm = 38 << FormShift, + NVExtFrm = 39 << FormShift, + NVMulSLFrm = 40 << FormShift, + NVTBLFrm = 41 << FormShift, //===------------------------------------------------------------------===// // Misc flags. Modified: llvm/trunk/lib/Target/ARM/ARMCodeEmitter.cpp URL: http://llvm.org/viewvc/llvm-project/llvm/trunk/lib/Target/ARM/ARMCodeEmitter.cpp?rev=110754&r1=110753&r2=110754&view=diff ============================================================================== --- llvm/trunk/lib/Target/ARM/ARMCodeEmitter.cpp (original) +++ llvm/trunk/lib/Target/ARM/ARMCodeEmitter.cpp Tue Aug 10 19:01:18 2010 @@ -124,6 +124,8 @@ void emitMiscArithInstruction(const MachineInstr &MI); + void emitSaturateInstruction(const MachineInstr &MI); + void emitBranchInstruction(const MachineInstr &MI); void emitInlineJumpTable(unsigned JTIndex); @@ -389,6 +391,9 @@ case ARMII::ArithMiscFrm: emitMiscArithInstruction(MI); break; + case ARMII::SatFrm: + emitSaturateInstruction(MI); + break; case ARMII::BrFrm: emitBranchInstruction(MI); break; @@ -1228,6 +1233,46 @@ emitWordLE(Binary); } +void ARMCodeEmitter::emitSaturateInstruction(const MachineInstr &MI) { + const TargetInstrDesc &TID = MI.getDesc(); + + // Part of binary is determined by TableGen. + unsigned Binary = getBinaryCodeForInstr(MI); + + // Set the conditional execution predicate + Binary |= II->getPredicate(&MI) << ARMII::CondShift; + + // Encode Rd + Binary |= getMachineOpValue(MI, 0) << ARMII::RegRdShift; + + // Encode saturate bit position. + unsigned Pos = MI.getOperand(1).getImm(); + if (TID.Opcode == ARM::SSATlsl || + TID.Opcode == ARM::SSATasr || + TID.Opcode == ARM::SSAT16) + Pos -= 1; + assert((Pos < 16 || (Pos < 32 && + TID.Opcode != ARM::SSAT16 && + TID.Opcode != ARM::USAT16)) && + "saturate bit position out of range"); + Binary |= Pos << 16; + + // Encode Rm + Binary |= getMachineOpValue(MI, 2); + + // Encode shift_imm. + if (TID.getNumOperands() == 4) { + unsigned ShiftAmt = MI.getOperand(3).getImm(); + if (ShiftAmt == 32 && + (TID.Opcode == ARM::SSATasr || TID.Opcode == ARM::USATasr)) + ShiftAmt = 0; + assert(ShiftAmt < 32 && "shift_imm range is 0 to 31!"); + Binary |= ShiftAmt << ARMII::ShiftShift; + } + + emitWordLE(Binary); +} + void ARMCodeEmitter::emitBranchInstruction(const MachineInstr &MI) { const TargetInstrDesc &TID = MI.getDesc(); Modified: llvm/trunk/lib/Target/ARM/ARMInstrFormats.td URL: http://llvm.org/viewvc/llvm-project/llvm/trunk/lib/Target/ARM/ARMInstrFormats.td?rev=110754&r1=110753&r2=110754&view=diff ============================================================================== --- llvm/trunk/lib/Target/ARM/ARMInstrFormats.td (original) +++ llvm/trunk/lib/Target/ARM/ARMInstrFormats.td Tue Aug 10 19:01:18 2010 @@ -36,37 +36,38 @@ def LdStExFrm : Format<11>; def ArithMiscFrm : Format<12>; -def ExtFrm : Format<13>; +def SatFrm : Format<13>; +def ExtFrm : Format<14>; -def VFPUnaryFrm : Format<14>; -def VFPBinaryFrm : Format<15>; -def VFPConv1Frm : Format<16>; -def VFPConv2Frm : Format<17>; -def VFPConv3Frm : Format<18>; -def VFPConv4Frm : Format<19>; -def VFPConv5Frm : Format<20>; -def VFPLdStFrm : Format<21>; -def VFPLdStMulFrm : Format<22>; -def VFPMiscFrm : Format<23>; - -def ThumbFrm : Format<24>; -def MiscFrm : Format<25>; - -def NGetLnFrm : Format<26>; -def NSetLnFrm : Format<27>; -def NDupFrm : Format<28>; -def NLdStFrm : Format<29>; -def N1RegModImmFrm: Format<30>; -def N2RegFrm : Format<31>; -def NVCVTFrm : Format<32>; -def NVDupLnFrm : Format<33>; -def N2RegVShLFrm : Format<34>; -def N2RegVShRFrm : Format<35>; -def N3RegFrm : Format<36>; -def N3RegVShFrm : Format<37>; -def NVExtFrm : Format<38>; -def NVMulSLFrm : Format<39>; -def NVTBLFrm : Format<40>; +def VFPUnaryFrm : Format<15>; +def VFPBinaryFrm : Format<16>; +def VFPConv1Frm : Format<17>; +def VFPConv2Frm : Format<18>; +def VFPConv3Frm : Format<19>; +def VFPConv4Frm : Format<20>; +def VFPConv5Frm : Format<21>; +def VFPLdStFrm : Format<22>; +def VFPLdStMulFrm : Format<23>; +def VFPMiscFrm : Format<24>; + +def ThumbFrm : Format<25>; +def MiscFrm : Format<26>; + +def NGetLnFrm : Format<27>; +def NSetLnFrm : Format<28>; +def NDupFrm : Format<29>; +def NLdStFrm : Format<30>; +def N1RegModImmFrm: Format<31>; +def N2RegFrm : Format<32>; +def NVCVTFrm : Format<33>; +def NVDupLnFrm : Format<34>; +def N2RegVShLFrm : Format<35>; +def N2RegVShRFrm : Format<36>; +def N3RegFrm : Format<37>; +def N3RegVShFrm : Format<38>; +def NVExtFrm : Format<39>; +def NVMulSLFrm : Format<40>; +def NVTBLFrm : Format<41>; // Misc flags. Modified: llvm/trunk/lib/Target/ARM/ARMInstrInfo.td URL: http://llvm.org/viewvc/llvm-project/llvm/trunk/lib/Target/ARM/ARMInstrInfo.td?rev=110754&r1=110753&r2=110754&view=diff ============================================================================== --- llvm/trunk/lib/Target/ARM/ARMInstrInfo.td (original) +++ llvm/trunk/lib/Target/ARM/ARMInstrInfo.td Tue Aug 10 19:01:18 2010 @@ -1810,20 +1810,22 @@ // Signed/Unsigned saturate -- for disassembly only def SSATlsl : AI<(outs GPR:$dst), (ins i32imm:$bit_pos, GPR:$a, i32imm:$shamt), - DPFrm, NoItinerary, "ssat", "\t$dst, $bit_pos, $a, lsl $shamt", + SatFrm, NoItinerary, + "ssat", "\t$dst, $bit_pos, $a, lsl $shamt", [/* For disassembly only; pattern left blank */]> { let Inst{27-21} = 0b0110101; let Inst{6-4} = 0b001; } def SSATasr : AI<(outs GPR:$dst), (ins i32imm:$bit_pos, GPR:$a, i32imm:$shamt), - DPFrm, NoItinerary, "ssat", "\t$dst, $bit_pos, $a, asr $shamt", + SatFrm, NoItinerary, + "ssat", "\t$dst, $bit_pos, $a, asr $shamt", [/* For disassembly only; pattern left blank */]> { let Inst{27-21} = 0b0110101; let Inst{6-4} = 0b101; } -def SSAT16 : AI<(outs GPR:$dst), (ins i32imm:$bit_pos, GPR:$a), DPFrm, +def SSAT16 : AI<(outs GPR:$dst), (ins i32imm:$bit_pos, GPR:$a), SatFrm, NoItinerary, "ssat16", "\t$dst, $bit_pos, $a", [/* For disassembly only; pattern left blank */]> { let Inst{27-20} = 0b01101010; @@ -1831,20 +1833,22 @@ } def USATlsl : AI<(outs GPR:$dst), (ins i32imm:$bit_pos, GPR:$a, i32imm:$shamt), - DPFrm, NoItinerary, "usat", "\t$dst, $bit_pos, $a, lsl $shamt", + SatFrm, NoItinerary, + "usat", "\t$dst, $bit_pos, $a, lsl $shamt", [/* For disassembly only; pattern left blank */]> { let Inst{27-21} = 0b0110111; let Inst{6-4} = 0b001; } def USATasr : AI<(outs GPR:$dst), (ins i32imm:$bit_pos, GPR:$a, i32imm:$shamt), - DPFrm, NoItinerary, "usat", "\t$dst, $bit_pos, $a, asr $shamt", + SatFrm, NoItinerary, + "usat", "\t$dst, $bit_pos, $a, asr $shamt", [/* For disassembly only; pattern left blank */]> { let Inst{27-21} = 0b0110111; let Inst{6-4} = 0b101; } -def USAT16 : AI<(outs GPR:$dst), (ins i32imm:$bit_pos, GPR:$a), DPFrm, +def USAT16 : AI<(outs GPR:$dst), (ins i32imm:$bit_pos, GPR:$a), SatFrm, NoItinerary, "usat16", "\t$dst, $bit_pos, $a", [/* For disassembly only; pattern left blank */]> { let Inst{27-20} = 0b01101110; Modified: llvm/trunk/lib/Target/ARM/Disassembler/ARMDisassemblerCore.cpp URL: http://llvm.org/viewvc/llvm-project/llvm/trunk/lib/Target/ARM/Disassembler/ARMDisassemblerCore.cpp?rev=110754&r1=110753&r2=110754&view=diff ============================================================================== --- llvm/trunk/lib/Target/ARM/Disassembler/ARMDisassemblerCore.cpp (original) +++ llvm/trunk/lib/Target/ARM/Disassembler/ARMDisassemblerCore.cpp Tue Aug 10 19:01:18 2010 @@ -908,34 +908,6 @@ return true; } -static inline bool SaturateOpcode(unsigned Opcode) { - switch (Opcode) { - case ARM::SSATlsl: case ARM::SSATasr: case ARM::SSAT16: - case ARM::USATlsl: case ARM::USATasr: case ARM::USAT16: - return true; - default: - return false; - } -} - -static inline unsigned decodeSaturatePos(unsigned Opcode, uint32_t insn) { - switch (Opcode) { - case ARM::SSATlsl: - case ARM::SSATasr: - return slice(insn, 20, 16) + 1; - case ARM::SSAT16: - return slice(insn, 19, 16) + 1; - case ARM::USATlsl: - case ARM::USATasr: - return slice(insn, 20, 16); - case ARM::USAT16: - return slice(insn, 19, 16); - default: - assert(0 && "Invalid opcode passed in"); - return 0; - } -} - // A major complication is the fact that some of the saturating add/subtract // operations have Rd Rm Rn, instead of the "normal" Rd Rn Rm. // They are QADD, QDADD, QDSUB, and QSUB. @@ -961,34 +933,6 @@ if (OpIdx >= NumOps) return false; - // SSAT/SSAT16/USAT/USAT16 has imm operand after Rd. - if (SaturateOpcode(Opcode)) { - MI.addOperand(MCOperand::CreateImm(decodeSaturatePos(Opcode, insn))); - - MI.addOperand(MCOperand::CreateReg(getRegisterEnum(B, ARM::GPRRegClassID, - decodeRm(insn)))); - - if (Opcode == ARM::SSAT16 || Opcode == ARM::USAT16) { - OpIdx += 2; - return true; - } - - // For SSAT operand reg (Rm) has been disassembled above. - // Now disassemble the shift amount. - - // Inst{11-7} encodes the imm5 shift amount. - unsigned ShAmt = slice(insn, 11, 7); - - // A8.6.183. Possible ASR shift amount of 32... - if (Opcode == ARM::SSATasr && ShAmt == 0) - ShAmt = 32; - - MI.addOperand(MCOperand::CreateImm(ShAmt)); - - OpIdx += 3; - return true; - } - // Special-case handling of BFC/BFI/SBFX/UBFX. if (Opcode == ARM::BFC || Opcode == ARM::BFI) { MI.addOperand(MCOperand::CreateReg(0)); @@ -1509,6 +1453,39 @@ return true; } +/// DisassembleSatFrm - Disassemble saturate instructions: +/// SSAT, SSAT16, USAT, and USAT16. +static bool DisassembleSatFrm(MCInst &MI, unsigned Opcode, uint32_t insn, + unsigned short NumOps, unsigned &NumOpsAdded, BO B) { + + const TargetInstrDesc &TID = ARMInsts[Opcode]; + NumOpsAdded = TID.getNumOperands() - 2; // ignore predicate operands + + // Disassemble register def. + MI.addOperand(MCOperand::CreateReg(getRegisterEnum(B, ARM::GPRRegClassID, + decodeRd(insn)))); + + unsigned Pos = slice(insn, 20, 16); + if (Opcode == ARM::SSATlsl || + Opcode == ARM::SSATasr || + Opcode == ARM::SSAT16) + Pos += 1; + MI.addOperand(MCOperand::CreateImm(Pos)); + + MI.addOperand(MCOperand::CreateReg(getRegisterEnum(B, ARM::GPRRegClassID, + decodeRm(insn)))); + + if (NumOpsAdded == 4) { + // Inst{11-7} encodes the imm5 shift amount. + unsigned ShAmt = slice(insn, 11, 7); + // A8.6.183. Possible ASR shift amount of 32... + if ((Opcode == ARM::SSATasr || Opcode == ARM::USATasr) && ShAmt == 0) + ShAmt = 32; + MI.addOperand(MCOperand::CreateImm(ShAmt)); + } + return true; +} + // Extend instructions. // SXT* and UXT*: Rd [Rn] Rm [rot_imm]. // The 2nd operand register is Rn and the 3rd operand regsiter is Rm for the @@ -3085,6 +3062,7 @@ &DisassembleLdStMulFrm, &DisassembleLdStExFrm, &DisassembleArithMiscFrm, + &DisassembleSatFrm, &DisassembleExtFrm, &DisassembleVFPUnaryFrm, &DisassembleVFPBinaryFrm, Modified: llvm/trunk/lib/Target/ARM/Disassembler/ARMDisassemblerCore.h URL: http://llvm.org/viewvc/llvm-project/llvm/trunk/lib/Target/ARM/Disassembler/ARMDisassemblerCore.h?rev=110754&r1=110753&r2=110754&view=diff ============================================================================== --- llvm/trunk/lib/Target/ARM/Disassembler/ARMDisassemblerCore.h (original) +++ llvm/trunk/lib/Target/ARM/Disassembler/ARMDisassemblerCore.h Tue Aug 10 19:01:18 2010 @@ -54,36 +54,35 @@ ENTRY(ARM_FORMAT_LDSTMULFRM, 10) \ ENTRY(ARM_FORMAT_LDSTEXFRM, 11) \ ENTRY(ARM_FORMAT_ARITHMISCFRM, 12) \ - ENTRY(ARM_FORMAT_EXTFRM, 13) \ - ENTRY(ARM_FORMAT_VFPUNARYFRM, 14) \ - ENTRY(ARM_FORMAT_VFPBINARYFRM, 15) \ - ENTRY(ARM_FORMAT_VFPCONV1FRM, 16) \ - ENTRY(ARM_FORMAT_VFPCONV2FRM, 17) \ - ENTRY(ARM_FORMAT_VFPCONV3FRM, 18) \ - ENTRY(ARM_FORMAT_VFPCONV4FRM, 19) \ - ENTRY(ARM_FORMAT_VFPCONV5FRM, 20) \ - ENTRY(ARM_FORMAT_VFPLDSTFRM, 21) \ - ENTRY(ARM_FORMAT_VFPLDSTMULFRM, 22) \ - ENTRY(ARM_FORMAT_VFPMISCFRM, 23) \ - ENTRY(ARM_FORMAT_THUMBFRM, 24) \ - ENTRY(ARM_FORMAT_NEONFRM, 25) \ - ENTRY(ARM_FORMAT_NEONGETLNFRM, 26) \ - ENTRY(ARM_FORMAT_NEONSETLNFRM, 27) \ - ENTRY(ARM_FORMAT_NEONDUPFRM, 28) \ - ENTRY(ARM_FORMAT_MISCFRM, 29) \ - ENTRY(ARM_FORMAT_THUMBMISCFRM, 30) \ - ENTRY(ARM_FORMAT_NLdSt, 31) \ - ENTRY(ARM_FORMAT_N1RegModImm, 32) \ - ENTRY(ARM_FORMAT_N2Reg, 33) \ - ENTRY(ARM_FORMAT_NVCVT, 34) \ - ENTRY(ARM_FORMAT_NVecDupLn, 35) \ - ENTRY(ARM_FORMAT_N2RegVecShL, 36) \ - ENTRY(ARM_FORMAT_N2RegVecShR, 37) \ - ENTRY(ARM_FORMAT_N3Reg, 38) \ - ENTRY(ARM_FORMAT_N3RegVecSh, 39) \ - ENTRY(ARM_FORMAT_NVecExtract, 40) \ - ENTRY(ARM_FORMAT_NVecMulScalar, 41) \ - ENTRY(ARM_FORMAT_NVTBL, 42) + ENTRY(ARM_FORMAT_SATFRM, 13) \ + ENTRY(ARM_FORMAT_EXTFRM, 14) \ + ENTRY(ARM_FORMAT_VFPUNARYFRM, 15) \ + ENTRY(ARM_FORMAT_VFPBINARYFRM, 16) \ + ENTRY(ARM_FORMAT_VFPCONV1FRM, 17) \ + ENTRY(ARM_FORMAT_VFPCONV2FRM, 18) \ + ENTRY(ARM_FORMAT_VFPCONV3FRM, 19) \ + ENTRY(ARM_FORMAT_VFPCONV4FRM, 20) \ + ENTRY(ARM_FORMAT_VFPCONV5FRM, 21) \ + ENTRY(ARM_FORMAT_VFPLDSTFRM, 22) \ + ENTRY(ARM_FORMAT_VFPLDSTMULFRM, 23) \ + ENTRY(ARM_FORMAT_VFPMISCFRM, 24) \ + ENTRY(ARM_FORMAT_THUMBFRM, 25) \ + ENTRY(ARM_FORMAT_MISCFRM, 26) \ + ENTRY(ARM_FORMAT_NEONGETLNFRM, 27) \ + ENTRY(ARM_FORMAT_NEONSETLNFRM, 28) \ + ENTRY(ARM_FORMAT_NEONDUPFRM, 29) \ + ENTRY(ARM_FORMAT_NLdSt, 30) \ + ENTRY(ARM_FORMAT_N1RegModImm, 31) \ + ENTRY(ARM_FORMAT_N2Reg, 32) \ + ENTRY(ARM_FORMAT_NVCVT, 33) \ + ENTRY(ARM_FORMAT_NVecDupLn, 34) \ + ENTRY(ARM_FORMAT_N2RegVecShL, 35) \ + ENTRY(ARM_FORMAT_N2RegVecShR, 36) \ + ENTRY(ARM_FORMAT_N3Reg, 37) \ + ENTRY(ARM_FORMAT_N3RegVecSh, 38) \ + ENTRY(ARM_FORMAT_NVecExtract, 39) \ + ENTRY(ARM_FORMAT_NVecMulScalar, 40) \ + ENTRY(ARM_FORMAT_NVTBL, 41) // ARM instruction format specifies the encoding used by the instruction. #define ENTRY(n, v) n = v, Modified: llvm/trunk/utils/TableGen/ARMDecoderEmitter.cpp URL: http://llvm.org/viewvc/llvm-project/llvm/trunk/utils/TableGen/ARMDecoderEmitter.cpp?rev=110754&r1=110753&r2=110754&view=diff ============================================================================== --- llvm/trunk/utils/TableGen/ARMDecoderEmitter.cpp (original) +++ llvm/trunk/utils/TableGen/ARMDecoderEmitter.cpp Tue Aug 10 19:01:18 2010 @@ -49,36 +49,35 @@ ENTRY(ARM_FORMAT_LDSTMULFRM, 10) \ ENTRY(ARM_FORMAT_LDSTEXFRM, 11) \ ENTRY(ARM_FORMAT_ARITHMISCFRM, 12) \ - ENTRY(ARM_FORMAT_EXTFRM, 13) \ - ENTRY(ARM_FORMAT_VFPUNARYFRM, 14) \ - ENTRY(ARM_FORMAT_VFPBINARYFRM, 15) \ - ENTRY(ARM_FORMAT_VFPCONV1FRM, 16) \ - ENTRY(ARM_FORMAT_VFPCONV2FRM, 17) \ - ENTRY(ARM_FORMAT_VFPCONV3FRM, 18) \ - ENTRY(ARM_FORMAT_VFPCONV4FRM, 19) \ - ENTRY(ARM_FORMAT_VFPCONV5FRM, 20) \ - ENTRY(ARM_FORMAT_VFPLDSTFRM, 21) \ - ENTRY(ARM_FORMAT_VFPLDSTMULFRM, 22) \ - ENTRY(ARM_FORMAT_VFPMISCFRM, 23) \ - ENTRY(ARM_FORMAT_THUMBFRM, 24) \ - ENTRY(ARM_FORMAT_NEONFRM, 25) \ - ENTRY(ARM_FORMAT_NEONGETLNFRM, 26) \ - ENTRY(ARM_FORMAT_NEONSETLNFRM, 27) \ - ENTRY(ARM_FORMAT_NEONDUPFRM, 28) \ - ENTRY(ARM_FORMAT_MISCFRM, 29) \ - ENTRY(ARM_FORMAT_THUMBMISCFRM, 30) \ - ENTRY(ARM_FORMAT_NLdSt, 31) \ - ENTRY(ARM_FORMAT_N1RegModImm, 32) \ - ENTRY(ARM_FORMAT_N2Reg, 33) \ - ENTRY(ARM_FORMAT_NVCVT, 34) \ - ENTRY(ARM_FORMAT_NVecDupLn, 35) \ - ENTRY(ARM_FORMAT_N2RegVecShL, 36) \ - ENTRY(ARM_FORMAT_N2RegVecShR, 37) \ - ENTRY(ARM_FORMAT_N3Reg, 38) \ - ENTRY(ARM_FORMAT_N3RegVecSh, 39) \ - ENTRY(ARM_FORMAT_NVecExtract, 40) \ - ENTRY(ARM_FORMAT_NVecMulScalar, 41) \ - ENTRY(ARM_FORMAT_NVTBL, 42) + ENTRY(ARM_FORMAT_SATFRM, 13) \ + ENTRY(ARM_FORMAT_EXTFRM, 14) \ + ENTRY(ARM_FORMAT_VFPUNARYFRM, 15) \ + ENTRY(ARM_FORMAT_VFPBINARYFRM, 16) \ + ENTRY(ARM_FORMAT_VFPCONV1FRM, 17) \ + ENTRY(ARM_FORMAT_VFPCONV2FRM, 18) \ + ENTRY(ARM_FORMAT_VFPCONV3FRM, 19) \ + ENTRY(ARM_FORMAT_VFPCONV4FRM, 20) \ + ENTRY(ARM_FORMAT_VFPCONV5FRM, 21) \ + ENTRY(ARM_FORMAT_VFPLDSTFRM, 22) \ + ENTRY(ARM_FORMAT_VFPLDSTMULFRM, 23) \ + ENTRY(ARM_FORMAT_VFPMISCFRM, 24) \ + ENTRY(ARM_FORMAT_THUMBFRM, 25) \ + ENTRY(ARM_FORMAT_MISCFRM, 26) \ + ENTRY(ARM_FORMAT_NEONGETLNFRM, 27) \ + ENTRY(ARM_FORMAT_NEONSETLNFRM, 28) \ + ENTRY(ARM_FORMAT_NEONDUPFRM, 29) \ + ENTRY(ARM_FORMAT_NLdSt, 30) \ + ENTRY(ARM_FORMAT_N1RegModImm, 31) \ + ENTRY(ARM_FORMAT_N2Reg, 32) \ + ENTRY(ARM_FORMAT_NVCVT, 33) \ + ENTRY(ARM_FORMAT_NVecDupLn, 34) \ + ENTRY(ARM_FORMAT_N2RegVecShL, 35) \ + ENTRY(ARM_FORMAT_N2RegVecShR, 36) \ + ENTRY(ARM_FORMAT_N3Reg, 37) \ + ENTRY(ARM_FORMAT_N3RegVecSh, 38) \ + ENTRY(ARM_FORMAT_NVecExtract, 39) \ + ENTRY(ARM_FORMAT_NVecMulScalar, 40) \ + ENTRY(ARM_FORMAT_NVTBL, 41) // ARM instruction format specifies the encoding used by the instruction. #define ENTRY(n, v) n = v, From clattner at apple.com Tue Aug 10 19:11:35 2010 From: clattner at apple.com (Chris Lattner) Date: Tue, 10 Aug 2010 17:11:35 -0700 Subject: [llvm-commits] [llvm] r110576 - in /llvm/trunk: lib/Target/CellSPU/SPUISelLowering.cpp lib/Target/CellSPU/SPUISelLowering.h lib/Target/CellSPU/SPUInstrInfo.td lib/Target/CellSPU/SPUNodes.td lib/Target/CellSPU/SPURegisterInfo.cpp test/CodeGen/CellSP... In-Reply-To: <1281437591.1796.146.camel@LLVMbuilder.research.nokia.com> References: <20100809163301.235462A6C12C@llvm.org> <25685170-45BA-47F0-AF9D-0D0600748145@apple.com> <1281437591.1796.146.camel@LLVMbuilder.research.nokia.com> Message-ID: On Aug 10, 2010, at 3:53 AM, Kalle.Raiskila at nokia.com wrote: > Experimenting a little shows that promoting v2i32 works rather nicely, > *if* v2i32 is not a "legal" type (i.e. there is no register class added > for v2i32). When it is a legal type, all sorts of asserts trigger when > trying to expand operations on that type. Right, that makes sense. > The reason it is legal > (currently, in the SPU backend) is that > a) it was like that when I found it :) I think that this is the root of the issue, and stems back to when legalize was much less mature. I think that fixing this bug is really the best path forward. It's in the target's best interest to be honest to legalize about what is and is not valid. Claiming v2i32 (and other 64-bit vectors) are legal will cause a lot of pain throughout the target and a ton of code duplication. Can you look into what would be required to remove this? > b) to the best of my understanding, v2i32 has to be legal if it is to be > used in return values and function parameters. Beyond Bob's post of "it should work", this is something that can easily be handled by the frontend (by having the frontend lower v2i32 arg/ret values into v4i32 values with shufflevector to extract). This is how the X86-64 backend handles its often-crazy ABI constraints. -Chris From daniel at zuster.org Tue Aug 10 19:11:17 2010 From: daniel at zuster.org (Daniel Dunbar) Date: Wed, 11 Aug 2010 00:11:17 -0000 Subject: [llvm-commits] [llvm] r110756 - /llvm/trunk/tools/lto/LTOModule.cpp Message-ID: <20100811001117.7F5E62A6C12C@llvm.org> Author: ddunbar Date: Tue Aug 10 19:11:17 2010 New Revision: 110756 URL: http://llvm.org/viewvc/llvm-project?rev=110756&view=rev Log: lto: Fix gratuitous memory leaks. Modified: llvm/trunk/tools/lto/LTOModule.cpp Modified: llvm/trunk/tools/lto/LTOModule.cpp URL: http://llvm.org/viewvc/llvm-project/llvm/trunk/tools/lto/LTOModule.cpp?rev=110756&r1=110755&r2=110756&view=diff ============================================================================== --- llvm/trunk/tools/lto/LTOModule.cpp (original) +++ llvm/trunk/tools/lto/LTOModule.cpp Tue Aug 10 19:11:17 2010 @@ -188,7 +188,7 @@ NameAndAttributes info; if (_undefines.find(superclassName.c_str()) == _undefines.end()) { const char *symbolName = ::strdup(superclassName.c_str()); - info.name = ::strdup(symbolName); + info.name = symbolName; info.attributes = LTO_SYMBOL_DEFINITION_UNDEFINED; // string is owned by _undefines _undefines[info.name] = info; @@ -220,7 +220,7 @@ NameAndAttributes info; if (_undefines.find(targetclassName.c_str()) == _undefines.end()) { const char *symbolName = ::strdup(targetclassName.c_str()); - info.name = ::strdup(symbolName); + info.name = symbolName; info.attributes = LTO_SYMBOL_DEFINITION_UNDEFINED; // string is owned by _undefines _undefines[info.name] = info; @@ -237,7 +237,7 @@ NameAndAttributes info; if (_undefines.find(targetclassName.c_str()) == _undefines.end()) { const char *symbolName = ::strdup(targetclassName.c_str()); - info.name = ::strdup(symbolName); + info.name = symbolName; info.attributes = LTO_SYMBOL_DEFINITION_UNDEFINED; // string is owned by _undefines _undefines[info.name] = info; From daniel at zuster.org Tue Aug 10 19:11:19 2010 From: daniel at zuster.org (Daniel Dunbar) Date: Wed, 11 Aug 2010 00:11:19 -0000 Subject: [llvm-commits] [llvm] r110757 - /llvm/trunk/tools/lto/LTOModule.cpp Message-ID: <20100811001119.EA8B92A6C12D@llvm.org> Author: ddunbar Date: Tue Aug 10 19:11:19 2010 New Revision: 110757 URL: http://llvm.org/viewvc/llvm-project?rev=110757&view=rev Log: lto: Fix an inverted conditional which prevented the addition of symbols scraped from inline assembly, except in cases where they had already been seen (in which case they would get added twice). - I can't see how this ever worked... Modified: llvm/trunk/tools/lto/LTOModule.cpp Modified: llvm/trunk/tools/lto/LTOModule.cpp URL: http://llvm.org/viewvc/llvm-project/llvm/trunk/tools/lto/LTOModule.cpp?rev=110757&r1=110756&r2=110757&view=diff ============================================================================== --- llvm/trunk/tools/lto/LTOModule.cpp (original) +++ llvm/trunk/tools/lto/LTOModule.cpp Tue Aug 10 19:11:19 2010 @@ -356,7 +356,7 @@ void LTOModule::addAsmGlobalSymbol(const char *name) { // only add new define if not already defined - if (_defines.count(name) == 0) + if (_defines.count(name)) return; // string is owned by _defines From gohman at apple.com Tue Aug 10 19:12:36 2010 From: gohman at apple.com (Dan Gohman) Date: Wed, 11 Aug 2010 00:12:36 -0000 Subject: [llvm-commits] [llvm] r110758 - in /llvm/trunk: lib/Analysis/ScalarEvolution.cpp test/Analysis/ScalarEvolution/max-trip-count.ll Message-ID: <20100811001236.B75C42A6C12C@llvm.org> Author: djg Date: Tue Aug 10 19:12:36 2010 New Revision: 110758 URL: http://llvm.org/viewvc/llvm-project?rev=110758&view=rev Log: When analyzing loop exit conditions combined with and and or, don't make any assumptions about when the two conditions will agree on when to permit the loop to exit. This fixes PR7845. Modified: llvm/trunk/lib/Analysis/ScalarEvolution.cpp llvm/trunk/test/Analysis/ScalarEvolution/max-trip-count.ll Modified: llvm/trunk/lib/Analysis/ScalarEvolution.cpp URL: http://llvm.org/viewvc/llvm-project/llvm/trunk/lib/Analysis/ScalarEvolution.cpp?rev=110758&r1=110757&r2=110758&view=diff ============================================================================== --- llvm/trunk/lib/Analysis/ScalarEvolution.cpp (original) +++ llvm/trunk/lib/Analysis/ScalarEvolution.cpp Tue Aug 10 19:12:36 2010 @@ -3854,14 +3854,13 @@ else MaxBECount = getUMinFromMismatchedTypes(BTI0.Max, BTI1.Max); } else { - // Both conditions must be true for the loop to exit. + // Both conditions must be true at the same time for the loop to exit. + // For now, be conservative. assert(L->contains(FBB) && "Loop block has no successor in loop!"); - if (BTI0.Exact != getCouldNotCompute() && - BTI1.Exact != getCouldNotCompute()) - BECount = getUMaxFromMismatchedTypes(BTI0.Exact, BTI1.Exact); - if (BTI0.Max != getCouldNotCompute() && - BTI1.Max != getCouldNotCompute()) - MaxBECount = getUMaxFromMismatchedTypes(BTI0.Max, BTI1.Max); + if (BTI0.Max == BTI1.Max) + MaxBECount = BTI0.Max; + if (BTI0.Exact == BTI1.Exact) + BECount = BTI0.Exact; } return BackedgeTakenInfo(BECount, MaxBECount); @@ -3889,14 +3888,13 @@ else MaxBECount = getUMinFromMismatchedTypes(BTI0.Max, BTI1.Max); } else { - // Both conditions must be false for the loop to exit. + // Both conditions must be false at the same time for the loop to exit. + // For now, be conservative. assert(L->contains(TBB) && "Loop block has no successor in loop!"); - if (BTI0.Exact != getCouldNotCompute() && - BTI1.Exact != getCouldNotCompute()) - BECount = getUMaxFromMismatchedTypes(BTI0.Exact, BTI1.Exact); - if (BTI0.Max != getCouldNotCompute() && - BTI1.Max != getCouldNotCompute()) - MaxBECount = getUMaxFromMismatchedTypes(BTI0.Max, BTI1.Max); + if (BTI0.Max == BTI1.Max) + MaxBECount = BTI0.Max; + if (BTI0.Exact == BTI1.Exact) + BECount = BTI0.Exact; } return BackedgeTakenInfo(BECount, MaxBECount); Modified: llvm/trunk/test/Analysis/ScalarEvolution/max-trip-count.ll URL: http://llvm.org/viewvc/llvm-project/llvm/trunk/test/Analysis/ScalarEvolution/max-trip-count.ll?rev=110758&r1=110757&r2=110758&view=diff ============================================================================== --- llvm/trunk/test/Analysis/ScalarEvolution/max-trip-count.ll (original) +++ llvm/trunk/test/Analysis/ScalarEvolution/max-trip-count.ll Tue Aug 10 19:12:36 2010 @@ -1,8 +1,9 @@ -; RUN: opt < %s -analyze -scalar-evolution \ -; RUN: | grep {\{%d,+,\[^\{\}\]\*\}<%bb>} +; RUN: opt < %s -analyze -scalar-evolution | FileCheck %s ; ScalarEvolution should be able to understand the loop and eliminate the casts. +; CHECK: {%d,+,sizeof(i32)} + define void @foo(i32* nocapture %d, i32 %n) nounwind { entry: %0 = icmp sgt i32 %n, 0 ; [#uses=1] @@ -32,3 +33,40 @@ return: ; preds = %bb1.return_crit_edge, %entry ret void } + +; ScalarEvolution should be able to find the maximum tripcount +; of this multiple-exit loop, and if it doesn't know the exact +; count, it should say so. + +; PR7845 +; CHECK: Loop %for.cond: Unpredictable backedge-taken count. +; CHECK: Loop %for.cond: max backedge-taken count is 5 + + at .str = private constant [4 x i8] c"%d\0A\00" ; <[4 x i8]*> [#uses=2] + +define i32 @main() nounwind { +entry: + br label %for.cond + +for.cond: ; preds = %for.inc, %entry + %g_4.0 = phi i32 [ 0, %entry ], [ %add, %for.inc ] ; [#uses=5] + %cmp = icmp slt i32 %g_4.0, 5 ; [#uses=1] + br i1 %cmp, label %for.body, label %for.end + +for.body: ; preds = %for.cond + %conv = trunc i32 %g_4.0 to i16 ; [#uses=1] + %tobool.not = icmp eq i16 %conv, 0 ; [#uses=1] + %tobool3 = icmp ne i32 %g_4.0, 0 ; [#uses=1] + %or.cond = and i1 %tobool.not, %tobool3 ; [#uses=1] + br i1 %or.cond, label %for.end, label %for.inc + +for.inc: ; preds = %for.body + %add = add nsw i32 %g_4.0, 1 ; [#uses=1] + br label %for.cond + +for.end: ; preds = %for.body, %for.cond + %call = call i32 (i8*, ...)* @printf(i8* getelementptr inbounds ([4 x i8]* @.str, i64 0, i64 0), i32 %g_4.0) nounwind ; [#uses=0] + ret i32 0 +} + +declare i32 @printf(i8*, ...) From rafael.espindola at gmail.com Tue Aug 10 19:15:14 2010 From: rafael.espindola at gmail.com (Rafael Espindola) Date: Wed, 11 Aug 2010 00:15:14 -0000 Subject: [llvm-commits] [llvm] r110759 - in /llvm/trunk: include/llvm-c/lto.h tools/gold/gold-plugin.cpp tools/lto/LTOCodeGenerator.cpp tools/lto/LTOCodeGenerator.h tools/lto/lto.cpp Message-ID: <20100811001514.31B0E2A6C12C@llvm.org> Author: rafael Date: Tue Aug 10 19:15:13 2010 New Revision: 110759 URL: http://llvm.org/viewvc/llvm-project?rev=110759&view=rev Log: Make it possible to set the cpu used for codegen. Modified: llvm/trunk/include/llvm-c/lto.h llvm/trunk/tools/gold/gold-plugin.cpp llvm/trunk/tools/lto/LTOCodeGenerator.cpp llvm/trunk/tools/lto/LTOCodeGenerator.h llvm/trunk/tools/lto/lto.cpp Modified: llvm/trunk/include/llvm-c/lto.h URL: http://llvm.org/viewvc/llvm-project/llvm/trunk/include/llvm-c/lto.h?rev=110759&r1=110758&r2=110759&view=diff ============================================================================== --- llvm/trunk/include/llvm-c/lto.h (original) +++ llvm/trunk/include/llvm-c/lto.h Tue Aug 10 19:15:13 2010 @@ -206,6 +206,13 @@ /** + * Sets the cpu to generate code for. + */ +extern void +lto_codegen_set_cpu(lto_code_gen_t cg, const char *cpu); + + +/** * Sets the location of the "gcc" to run. If not set, libLTO will search for * "gcc" on the path. */ Modified: llvm/trunk/tools/gold/gold-plugin.cpp URL: http://llvm.org/viewvc/llvm-project/llvm/trunk/tools/gold/gold-plugin.cpp?rev=110759&r1=110758&r2=110759&view=diff ============================================================================== --- llvm/trunk/tools/gold/gold-plugin.cpp (original) +++ llvm/trunk/tools/gold/gold-plugin.cpp Tue Aug 10 19:15:13 2010 @@ -70,6 +70,7 @@ static std::vector pass_through; static std::string extra_library_path; static std::string triple; + static std::string mcpu; // Additional options to pass into the code generator. // Note: This array will contain all plugin options which are not claimed // as plugin exclusive to pass to the code generator. @@ -85,6 +86,8 @@ if (opt == "generate-api-file") { generate_api_file = true; + } else if (opt.startswith("mcpu=")) { + mcpu = opt.substr(strlen("mcpu=")); } else if (opt.startswith("as=")) { if (!as_path.empty()) { (*message)(LDPL_WARNING, "Path to as specified twice. " @@ -413,6 +416,9 @@ } lto_codegen_set_assembler_args(cg, &as_args_p[0], as_args_p.size()); } + if (!options::mcpu.empty()) + lto_codegen_set_cpu(cg, options::mcpu.c_str()); + // Pass through extra options to the code generator. if (!options::extra.empty()) { for (std::vector::iterator it = options::extra.begin(); Modified: llvm/trunk/tools/lto/LTOCodeGenerator.cpp URL: http://llvm.org/viewvc/llvm-project/llvm/trunk/tools/lto/LTOCodeGenerator.cpp?rev=110759&r1=110758&r2=110759&view=diff ============================================================================== --- llvm/trunk/tools/lto/LTOCodeGenerator.cpp (original) +++ llvm/trunk/tools/lto/LTOCodeGenerator.cpp Tue Aug 10 19:15:13 2010 @@ -119,6 +119,11 @@ return true; } +void LTOCodeGenerator::setCpu(const char* mCpu) +{ + _mCpu = mCpu; +} + void LTOCodeGenerator::setAssemblerPath(const char* path) { if ( _assemblerPath ) @@ -314,7 +319,7 @@ // construct LTModule, hand over ownership of module and target SubtargetFeatures Features; - Features.getDefaultSubtargetFeatures("" /* cpu */, llvm::Triple(Triple)); + Features.getDefaultSubtargetFeatures(_mCpu, llvm::Triple(Triple)); std::string FeatureStr = Features.getString(); _target = march->createTargetMachine(Triple, FeatureStr); } Modified: llvm/trunk/tools/lto/LTOCodeGenerator.h URL: http://llvm.org/viewvc/llvm-project/llvm/trunk/tools/lto/LTOCodeGenerator.h?rev=110759&r1=110758&r2=110759&view=diff ============================================================================== --- llvm/trunk/tools/lto/LTOCodeGenerator.h (original) +++ llvm/trunk/tools/lto/LTOCodeGenerator.h Tue Aug 10 19:15:13 2010 @@ -36,6 +36,7 @@ bool addModule(struct LTOModule*, std::string& errMsg); bool setDebugInfo(lto_debug_model, std::string& errMsg); bool setCodePICModel(lto_codegen_model, std::string& errMsg); + void setCpu(const char *cpu); void setAssemblerPath(const char* path); void setAssemblerArgs(const char** args, int nargs); void addMustPreserveSymbol(const char* sym); @@ -63,6 +64,7 @@ llvm::MemoryBuffer* _nativeObjectFile; std::vector _codegenOptions; llvm::sys::Path* _assemblerPath; + std::string _mCpu; std::vector _assemblerArgs; }; Modified: llvm/trunk/tools/lto/lto.cpp URL: http://llvm.org/viewvc/llvm-project/llvm/trunk/tools/lto/lto.cpp?rev=110759&r1=110758&r2=110759&view=diff ============================================================================== --- llvm/trunk/tools/lto/lto.cpp (original) +++ llvm/trunk/tools/lto/lto.cpp Tue Aug 10 19:15:13 2010 @@ -211,6 +211,14 @@ } // +// sets the cpu to generate code for +// +void lto_codegen_set_cpu(lto_code_gen_t cg, const char* cpu) +{ + return cg->setCpu(cpu); +} + +// // sets the path to the assembler tool // void lto_codegen_set_assembler_path(lto_code_gen_t cg, const char* path) From isanbard at gmail.com Tue Aug 10 19:22:27 2010 From: isanbard at gmail.com (Bill Wendling) Date: Wed, 11 Aug 2010 00:22:27 -0000 Subject: [llvm-commits] [llvm] r110761 - /llvm/trunk/lib/Target/ARM/ARMInstrInfo.td Message-ID: <20100811002227.5DD2F2A6C12C@llvm.org> Author: void Date: Tue Aug 10 19:22:27 2010 New Revision: 110761 URL: http://llvm.org/viewvc/llvm-project?rev=110761&view=rev Log: Mark ARM compare instructions as isCompare. Modified: llvm/trunk/lib/Target/ARM/ARMInstrInfo.td Modified: llvm/trunk/lib/Target/ARM/ARMInstrInfo.td URL: http://llvm.org/viewvc/llvm-project/llvm/trunk/lib/Target/ARM/ARMInstrInfo.td?rev=110761&r1=110760&r2=110761&view=diff ============================================================================== --- llvm/trunk/lib/Target/ARM/ARMInstrInfo.td (original) +++ llvm/trunk/lib/Target/ARM/ARMInstrInfo.td Tue Aug 10 19:22:27 2010 @@ -496,7 +496,7 @@ /// AI1_cmp_irs - Defines a set of (op r, {so_imm|r|so_reg}) cmp / test /// patterns. Similar to AsI1_bin_irs except the instruction does not produce /// a explicit result, only implicitly set CPSR. -let Defs = [CPSR] in { +let isCompare = 1, Defs = [CPSR] in { multiclass AI1_cmp_irs opcod, string opc, PatFrag opnode, bit Commutable = 0> { def ri : AI1 Author: void Date: Tue Aug 10 19:23:00 2010 New Revision: 110762 URL: http://llvm.org/viewvc/llvm-project?rev=110762&view=rev Log: Handle ARM compares as well as converting for ARM adds, subs, and thumb2's adds. Modified: llvm/trunk/lib/Target/ARM/ARMBaseInstrInfo.cpp Modified: llvm/trunk/lib/Target/ARM/ARMBaseInstrInfo.cpp URL: http://llvm.org/viewvc/llvm-project/llvm/trunk/lib/Target/ARM/ARMBaseInstrInfo.cpp?rev=110762&r1=110761&r2=110762&view=diff ============================================================================== --- llvm/trunk/lib/Target/ARM/ARMBaseInstrInfo.cpp (original) +++ llvm/trunk/lib/Target/ARM/ARMBaseInstrInfo.cpp Tue Aug 10 19:23:00 2010 @@ -1358,6 +1358,8 @@ AnalyzeCompare(const MachineInstr *MI, unsigned &SrcReg, int &CmpValue) const { switch (MI->getOpcode()) { default: break; + case ARM::CMPri: + case ARM::CMPzri: case ARM::t2CMPri: case ARM::t2CMPzri: SrcReg = MI->getOperand(0).getReg(); @@ -1398,6 +1400,9 @@ // Set the "zero" bit in CPSR. switch (MI->getOpcode()) { default: break; + case ARM::ADDri: + case ARM::SUBri: + case ARM::t2ADDri: case ARM::t2SUBri: { MI->RemoveOperand(5); MachineInstrBuilder MB(MI); From ofv at wanadoo.es Tue Aug 10 19:51:32 2010 From: ofv at wanadoo.es (Oscar Fuentes) Date: Wed, 11 Aug 2010 00:51:32 -0000 Subject: [llvm-commits] [llvm] r110763 - in /llvm/trunk/cmake/modules: CMakeLists.txt LLVM.cmake LLVMConfig.cmake Message-ID: <20100811005132.9CBFA2A6C12C@llvm.org> Author: ofv Date: Tue Aug 10 19:51:32 2010 New Revision: 110763 URL: http://llvm.org/viewvc/llvm-project?rev=110763&view=rev Log: CMake: corrections on LLVM.cmake external services. Modified: llvm/trunk/cmake/modules/CMakeLists.txt llvm/trunk/cmake/modules/LLVM.cmake llvm/trunk/cmake/modules/LLVMConfig.cmake Modified: llvm/trunk/cmake/modules/CMakeLists.txt URL: http://llvm.org/viewvc/llvm-project/llvm/trunk/cmake/modules/CMakeLists.txt?rev=110763&r1=110762&r2=110763&view=diff ============================================================================== --- llvm/trunk/cmake/modules/CMakeLists.txt (original) +++ llvm/trunk/cmake/modules/CMakeLists.txt Tue Aug 10 19:51:32 2010 @@ -2,7 +2,8 @@ configure_file( LLVM.cmake - ${llvm_cmake_builddir}/LLVM.cmake) + ${llvm_cmake_builddir}/LLVM.cmake + @ONLY) install(FILES ${llvm_cmake_builddir}/LLVM.cmake Modified: llvm/trunk/cmake/modules/LLVM.cmake URL: http://llvm.org/viewvc/llvm-project/llvm/trunk/cmake/modules/LLVM.cmake?rev=110763&r1=110762&r2=110763&view=diff ============================================================================== --- llvm/trunk/cmake/modules/LLVM.cmake (original) +++ llvm/trunk/cmake/modules/LLVM.cmake Tue Aug 10 19:51:32 2010 @@ -1,3 +1,5 @@ +# This file provides information and services to the final user. + set(LLVM_COMMON_DEPENDS @LLVM_COMMON_DEPENDS@) set(llvm_libs @llvm_libs@) @@ -10,10 +12,18 @@ set(LLVM_ENABLE_THREADS @LLVM_ENABLE_THREADS@) -if( NOT EXISTS LLVMConfig.cmake ) +set(LLVM_NATIVE_ARCH @LLVM_NATIVE_ARCH@) + +# We try to include using the current setting of CMAKE_MODULE_PATH, +# which suppossedly was filled by the user with the directory where +# this file was installed: +include( LLVMConfig OPTIONAL RESULT_VARIABLE LLVMCONFIG_INCLUDED ) + +# If failed, we assume that this is an un-installed build: +if( NOT LLVMCONFIG_INCLUDED ) set(CMAKE_MODULE_PATH ${CMAKE_MODULE_PATH} "@LLVM_SOURCE_DIR@/cmake/modules") + include( LLVMConfig ) endif() -include( LLVMConfig ) Modified: llvm/trunk/cmake/modules/LLVMConfig.cmake URL: http://llvm.org/viewvc/llvm-project/llvm/trunk/cmake/modules/LLVMConfig.cmake?rev=110763&r1=110762&r2=110763&view=diff ============================================================================== --- llvm/trunk/cmake/modules/LLVMConfig.cmake (original) +++ llvm/trunk/cmake/modules/LLVMConfig.cmake Tue Aug 10 19:51:32 2010 @@ -53,7 +53,7 @@ function(llvm_map_components_to_libraries OUT_VAR) explicit_map_components_to_libraries(result ${ARGN}) get_system_libs(sys_result) - set( ${OUT_VAR} ${result} ${sys_result} ) + set( ${OUT_VAR} ${result} ${sys_result} PARENT_SCOPE ) endfunction(llvm_map_components_to_libraries) From isanbard at gmail.com Tue Aug 10 20:05:02 2010 From: isanbard at gmail.com (Bill Wendling) Date: Wed, 11 Aug 2010 01:05:02 -0000 Subject: [llvm-commits] [llvm] r110765 - /llvm/trunk/test/CodeGen/ARM/long_shift.ll Message-ID: <20100811010502.BF6772A6C12C@llvm.org> Author: void Date: Tue Aug 10 20:05:02 2010 New Revision: 110765 URL: http://llvm.org/viewvc/llvm-project?rev=110765&view=rev Log: Update test to match output of optimize compares for ARM. Modified: llvm/trunk/test/CodeGen/ARM/long_shift.ll Modified: llvm/trunk/test/CodeGen/ARM/long_shift.ll URL: http://llvm.org/viewvc/llvm-project/llvm/trunk/test/CodeGen/ARM/long_shift.ll?rev=110765&r1=110764&r2=110765&view=diff ============================================================================== --- llvm/trunk/test/CodeGen/ARM/long_shift.ll (original) +++ llvm/trunk/test/CodeGen/ARM/long_shift.ll Tue Aug 10 20:05:02 2010 @@ -24,8 +24,7 @@ ; CHECK: f2 ; CHECK: mov r0, r0, lsr r2 ; CHECK-NEXT: rsb r3, r2, #32 -; CHECK-NEXT: sub r2, r2, #32 -; CHECK-NEXT: cmp r2, #0 +; CHECK-NEXT: subs r2, r2, #32 ; CHECK-NEXT: orr r0, r0, r1, lsl r3 ; CHECK-NEXT: movge r0, r1, asr r2 %a = ashr i64 %x, %y @@ -37,8 +36,7 @@ ; CHECK: f3 ; CHECK: mov r0, r0, lsr r2 ; CHECK-NEXT: rsb r3, r2, #32 -; CHECK-NEXT: sub r2, r2, #32 -; CHECK-NEXT: cmp r2, #0 +; CHECK-NEXT: subs r2, r2, #32 ; CHECK-NEXT: orr r0, r0, r1, lsl r3 ; CHECK-NEXT: movge r0, r1, lsr r2 %a = lshr i64 %x, %y From bruno.cardoso at gmail.com Tue Aug 10 20:18:26 2010 From: bruno.cardoso at gmail.com (Bruno Cardoso Lopes) Date: Wed, 11 Aug 2010 01:18:26 -0000 Subject: [llvm-commits] [llvm] r110767 - /llvm/trunk/include/llvm/IntrinsicsX86.td Message-ID: <20100811011826.C767A2A6C12C@llvm.org> Author: bruno Date: Tue Aug 10 20:18:26 2010 New Revision: 110767 URL: http://llvm.org/viewvc/llvm-project?rev=110767&view=rev Log: Remove AVX 256-bit shuffle intrinsics now that clang is using __builtin_shufflevector for those Modified: llvm/trunk/include/llvm/IntrinsicsX86.td Modified: llvm/trunk/include/llvm/IntrinsicsX86.td URL: http://llvm.org/viewvc/llvm-project/llvm/trunk/include/llvm/IntrinsicsX86.td?rev=110767&r1=110766&r2=110767&view=diff ============================================================================== --- llvm/trunk/include/llvm/IntrinsicsX86.td (original) +++ llvm/trunk/include/llvm/IntrinsicsX86.td Tue Aug 10 20:18:26 2010 @@ -1108,16 +1108,6 @@ llvm_v8f32_ty, llvm_i32_ty], [IntrNoMem]>; } -// Vector shuffle -let TargetPrefix = "x86" in { // All intrinsics start with "llvm.x86.". - def int_x86_avx_shuf_pd_256 : GCCBuiltin<"__builtin_ia32_shufpd256">, - Intrinsic<[llvm_v4f64_ty], [llvm_v4f64_ty, - llvm_v4f64_ty, llvm_i8_ty], [IntrNoMem]>; - def int_x86_avx_shuf_ps_256 : GCCBuiltin<"__builtin_ia32_shufps256">, - Intrinsic<[llvm_v8f32_ty], [llvm_v8f32_ty, - llvm_v8f32_ty, llvm_i8_ty], [IntrNoMem]>; -} - // Vector compare let TargetPrefix = "x86" in { // All intrinsics start with "llvm.x86.". def int_x86_avx_cmp_pd_256 : GCCBuiltin<"__builtin_ia32_cmppd256">, From bruno.cardoso at gmail.com Tue Aug 10 20:44:11 2010 From: bruno.cardoso at gmail.com (Bruno Cardoso Lopes) Date: Wed, 11 Aug 2010 01:44:11 -0000 Subject: [llvm-commits] [llvm] r110769 - /llvm/trunk/include/llvm/IntrinsicsX86.td Message-ID: <20100811014411.2EAFB2A6C12C@llvm.org> Author: bruno Date: Tue Aug 10 20:44:11 2010 New Revision: 110769 URL: http://llvm.org/viewvc/llvm-project?rev=110769&view=rev Log: Remove AVX 256-bit unpack and interleave intrinsics now that clang is using __builtin_shufflevector for those Modified: llvm/trunk/include/llvm/IntrinsicsX86.td Modified: llvm/trunk/include/llvm/IntrinsicsX86.td URL: http://llvm.org/viewvc/llvm-project/llvm/trunk/include/llvm/IntrinsicsX86.td?rev=110769&r1=110768&r2=110769&view=diff ============================================================================== --- llvm/trunk/include/llvm/IntrinsicsX86.td (original) +++ llvm/trunk/include/llvm/IntrinsicsX86.td Tue Aug 10 20:44:11 2010 @@ -1176,22 +1176,6 @@ Intrinsic<[llvm_v2f64_ty], [llvm_v4f64_ty], [IntrNoMem]>; } -// Vector unpack and interleave -let TargetPrefix = "x86" in { // All intrinsics start with "llvm.x86.". - def int_x86_avx_unpckh_pd_256 : GCCBuiltin<"__builtin_ia32_unpckhpd256">, - Intrinsic<[llvm_v4f64_ty], [llvm_v4f64_ty, - llvm_v4f64_ty], [IntrNoMem]>; - def int_x86_avx_unpckl_pd_256 : GCCBuiltin<"__builtin_ia32_unpcklpd256">, - Intrinsic<[llvm_v4f64_ty], [llvm_v4f64_ty, - llvm_v4f64_ty], [IntrNoMem]>; - def int_x86_avx_unpckh_ps_256 : GCCBuiltin<"__builtin_ia32_unpckhps256">, - Intrinsic<[llvm_v8f32_ty], [llvm_v8f32_ty, - llvm_v8f32_ty], [IntrNoMem]>; - def int_x86_avx_unpckl_ps_256 : GCCBuiltin<"__builtin_ia32_unpcklps256">, - Intrinsic<[llvm_v8f32_ty], [llvm_v8f32_ty, - llvm_v8f32_ty], [IntrNoMem]>; -} - // Vector bit test let TargetPrefix = "x86" in { // All intrinsics start with "llvm.x86.". def int_x86_avx_vtestz_pd : GCCBuiltin<"__builtin_ia32_vtestzpd">, From bruno.cardoso at gmail.com Tue Aug 10 21:15:33 2010 From: bruno.cardoso at gmail.com (Bruno Cardoso Lopes) Date: Wed, 11 Aug 2010 02:15:33 -0000 Subject: [llvm-commits] [llvm] r110772 - /llvm/trunk/include/llvm/IntrinsicsX86.td Message-ID: <20100811021533.6D6182A6C12C@llvm.org> Author: bruno Date: Tue Aug 10 21:15:33 2010 New Revision: 110772 URL: http://llvm.org/viewvc/llvm-project?rev=110772&view=rev Log: Remove AVX 256-bit cast intrinsics now that clang is using __builtin_shufflevector for those Modified: llvm/trunk/include/llvm/IntrinsicsX86.td Modified: llvm/trunk/include/llvm/IntrinsicsX86.td URL: http://llvm.org/viewvc/llvm-project/llvm/trunk/include/llvm/IntrinsicsX86.td?rev=110772&r1=110771&r2=110772&view=diff ============================================================================== --- llvm/trunk/include/llvm/IntrinsicsX86.td (original) +++ llvm/trunk/include/llvm/IntrinsicsX86.td Tue Aug 10 21:15:33 2010 @@ -1162,18 +1162,6 @@ Intrinsic<[llvm_v4i32_ty], [llvm_v4f64_ty], [IntrNoMem]>; def int_x86_avx_cvtt_ps2dq_256 : GCCBuiltin<"__builtin_ia32_cvttps2dq256">, Intrinsic<[llvm_v8i32_ty], [llvm_v8f32_ty], [IntrNoMem]>; - def int_x86_avx_si_256_si : GCCBuiltin<"__builtin_ia32_si256_si">, - Intrinsic<[llvm_v8i32_ty], [llvm_v4i32_ty], [IntrNoMem]>; - def int_x86_avx_ps_256_ps : GCCBuiltin<"__builtin_ia32_ps256_ps">, - Intrinsic<[llvm_v8f32_ty], [llvm_v4f32_ty], [IntrNoMem]>; - def int_x86_avx_pd_256_pd : GCCBuiltin<"__builtin_ia32_pd256_pd">, - Intrinsic<[llvm_v4f64_ty], [llvm_v2f64_ty], [IntrNoMem]>; - def int_x86_avx_si_si_256 : GCCBuiltin<"__builtin_ia32_si_si256">, - Intrinsic<[llvm_v4i32_ty], [llvm_v8i32_ty], [IntrNoMem]>; - def int_x86_avx_ps_ps_256 : GCCBuiltin<"__builtin_ia32_ps_ps256">, - Intrinsic<[llvm_v4f32_ty], [llvm_v8f32_ty], [IntrNoMem]>; - def int_x86_avx_pd_pd_256 : GCCBuiltin<"__builtin_ia32_pd_pd256">, - Intrinsic<[llvm_v2f64_ty], [llvm_v4f64_ty], [IntrNoMem]>; } // Vector bit test From clchiou at gmail.com Tue Aug 10 22:10:08 2010 From: clchiou at gmail.com (Che-Liang Chiou) Date: Tue, 10 Aug 2010 20:10:08 -0700 Subject: [llvm-commits] [patch][Target/PTX] Create PTX backend Message-ID: SVN revision: 110776 This patch is a part of upstream work of a PTX backend using LLVM code generator. Change list summary: - Add an empty backend that is merely compilable - Add PTX entry to autoconf/configure.ac and include/llvm/ADT/Triple.h Outcome: $ ./configure --enable-targets=ptx $ make $ llc -version | grep ptx ptx - PTX Misc: - Diff of auto-generated files are put in a separated patch - The autotool version on my machine is newer than autoconf/AutoGegen.sh requires, so the diff of auto-gen'd files might be differ with that on your machine Cheers, Che-Liang -------------- next part -------------- A non-text attachment was scrubbed... Name: r110776-add-ptx-backend.patch Type: text/x-patch Size: 12773 bytes Desc: not available Url : http://lists.cs.uiuc.edu/pipermail/llvm-commits/attachments/20100810/a467c09c/attachment.bin -------------- next part -------------- A non-text attachment was scrubbed... Name: r110776-add-ptx-backend-autogen-files.patch Type: text/x-patch Size: 734250 bytes Desc: not available Url : http://lists.cs.uiuc.edu/pipermail/llvm-commits/attachments/20100810/a467c09c/attachment-0001.bin From resistor at mac.com Tue Aug 10 23:24:25 2010 From: resistor at mac.com (Owen Anderson) Date: Wed, 11 Aug 2010 04:24:25 -0000 Subject: [llvm-commits] [llvm] r110778 - /llvm/trunk/lib/Analysis/LazyValueInfo.cpp Message-ID: <20100811042425.6F7F72A6C12F@llvm.org> Author: resistor Date: Tue Aug 10 23:24:25 2010 New Revision: 110778 URL: http://llvm.org/viewvc/llvm-project?rev=110778&view=rev Log: Improve indentation. Modified: llvm/trunk/lib/Analysis/LazyValueInfo.cpp Modified: llvm/trunk/lib/Analysis/LazyValueInfo.cpp URL: http://llvm.org/viewvc/llvm-project/llvm/trunk/lib/Analysis/LazyValueInfo.cpp?rev=110778&r1=110777&r2=110778&view=diff ============================================================================== --- llvm/trunk/lib/Analysis/LazyValueInfo.cpp (original) +++ llvm/trunk/lib/Analysis/LazyValueInfo.cpp Tue Aug 10 23:24:25 2010 @@ -511,37 +511,38 @@ // If the condition of the branch is an equality comparison, we may be // able to infer the value. - if (ICmpInst *ICI = dyn_cast(BI->getCondition())) - if (ICI->getOperand(0) == Val && isa(ICI->getOperand(1))) { - if (ICI->isEquality()) { - // We know that V has the RHS constant if this is a true SETEQ or - // false SETNE. - if (isTrueDest == (ICI->getPredicate() == ICmpInst::ICMP_EQ)) - return LVILatticeVal::get(cast(ICI->getOperand(1))); - return LVILatticeVal::getNot(cast(ICI->getOperand(1))); - } else if (ConstantInt *CI = - dyn_cast(ICI->getOperand(1))) { - - // Calculate the range of values that would satisfy the comparison. - ConstantRange CmpRange(CI->getValue(), CI->getValue()+1); - ConstantRange TrueValues = - ConstantRange::makeICmpRegion(ICI->getPredicate(), CmpRange); - - // If we're interested in the false dest, invert the condition. - if (!isTrueDest) TrueValues = TrueValues.inverse(); + ICmpInst *ICI = dyn_cast(BI->getCondition()); + if (ICI && ICI->getOperand(0) == Val && + isa(ICI->getOperand(1))) { + if (ICI->isEquality()) { + // We know that V has the RHS constant if this is a true SETEQ or + // false SETNE. + if (isTrueDest == (ICI->getPredicate() == ICmpInst::ICMP_EQ)) + return LVILatticeVal::get(cast(ICI->getOperand(1))); + return LVILatticeVal::getNot(cast(ICI->getOperand(1))); + } + + if (ConstantInt *CI = dyn_cast(ICI->getOperand(1))) { + // Calculate the range of values that would satisfy the comparison. + ConstantRange CmpRange(CI->getValue(), CI->getValue()+1); + ConstantRange TrueValues = + ConstantRange::makeICmpRegion(ICI->getPredicate(), CmpRange); - // Figure out the possible values of the query BEFORE this branch. - LVILatticeVal InBlock = getBlockValue(BBFrom); - if (!InBlock.isConstantRange()) return InBlock; + // If we're interested in the false dest, invert the condition. + if (!isTrueDest) TrueValues = TrueValues.inverse(); + + // Figure out the possible values of the query BEFORE this branch. + LVILatticeVal InBlock = getBlockValue(BBFrom); + if (!InBlock.isConstantRange()) return InBlock; - // Find all potential values that satisfy both the input and output - // conditions. - ConstantRange PossibleValues = - TrueValues.intersectWith(InBlock.getConstantRange()); + // Find all potential values that satisfy both the input and output + // conditions. + ConstantRange PossibleValues = + TrueValues.intersectWith(InBlock.getConstantRange()); - return LVILatticeVal::getRange(PossibleValues); - } + return LVILatticeVal::getRange(PossibleValues); } + } } } From daniel at zuster.org Tue Aug 10 23:46:08 2010 From: daniel at zuster.org (Daniel Dunbar) Date: Wed, 11 Aug 2010 04:46:08 -0000 Subject: [llvm-commits] [llvm] r110779 - /llvm/trunk/utils/TableGen/AsmMatcherEmitter.cpp Message-ID: <20100811044608.327692A6C12C@llvm.org> Author: ddunbar Date: Tue Aug 10 23:46:08 2010 New Revision: 110779 URL: http://llvm.org/viewvc/llvm-project?rev=110779&view=rev Log: tblgen/AsmMatcher: Downgrade instructions with tied operands to a debug-only warning, for now. Modified: llvm/trunk/utils/TableGen/AsmMatcherEmitter.cpp Modified: llvm/trunk/utils/TableGen/AsmMatcherEmitter.cpp URL: http://llvm.org/viewvc/llvm-project/llvm/trunk/utils/TableGen/AsmMatcherEmitter.cpp?rev=110779&r1=110778&r2=110779&view=diff ============================================================================== --- llvm/trunk/utils/TableGen/AsmMatcherEmitter.cpp (original) +++ llvm/trunk/utils/TableGen/AsmMatcherEmitter.cpp Tue Aug 10 23:46:08 2010 @@ -260,9 +260,12 @@ } if (Tokens[i][0] == '$' && !OperandNames.insert(Tokens[i]).second) { - std::string Err = "'" + Name.str() + "': " + - "invalid assembler instruction; tied operand '" + Tokens[i].str() + "'"; - throw TGError(CGI.TheDef->getLoc(), Err); + DEBUG({ + errs() << "warning: '" << Name << "': " + << "ignoring instruction with tied operand '" + << Tokens[i].str() << "'\n"; + }); + return false; } } From daniel at zuster.org Tue Aug 10 23:46:11 2010 From: daniel at zuster.org (Daniel Dunbar) Date: Wed, 11 Aug 2010 04:46:11 -0000 Subject: [llvm-commits] [llvm] r110780 - /llvm/trunk/lib/Target/ARM/ARMInstrThumb2.td Message-ID: <20100811044611.271582A6C12D@llvm.org> Author: ddunbar Date: Tue Aug 10 23:46:10 2010 New Revision: 110780 URL: http://llvm.org/viewvc/llvm-project?rev=110780&view=rev Log: ARM: Quote $p in an asm string. Modified: llvm/trunk/lib/Target/ARM/ARMInstrThumb2.td Modified: llvm/trunk/lib/Target/ARM/ARMInstrThumb2.td URL: http://llvm.org/viewvc/llvm-project/llvm/trunk/lib/Target/ARM/ARMInstrThumb2.td?rev=110780&r1=110779&r2=110780&view=diff ============================================================================== --- llvm/trunk/lib/Target/ARM/ARMInstrThumb2.td (original) +++ llvm/trunk/lib/Target/ARM/ARMInstrThumb2.td Tue Aug 10 23:46:10 2010 @@ -780,7 +780,7 @@ let neverHasSideEffects = 1 in { let isReMaterializable = 1 in def t2LEApcrel : T2XI<(outs rGPR:$dst), (ins i32imm:$label, pred:$p), IIC_iALUi, - "adr$p.w\t$dst, #$label", []> { + "adr${p}.w\t$dst, #$label", []> { let Inst{31-27} = 0b11110; let Inst{25-24} = 0b10; // Inst{23:21} = '11' (add = FALSE) or '00' (add = TRUE) @@ -792,7 +792,7 @@ } // neverHasSideEffects def t2LEApcrelJT : T2XI<(outs rGPR:$dst), (ins i32imm:$label, nohash_imm:$id, pred:$p), IIC_iALUi, - "adr$p.w\t$dst, #${label}_${id}", []> { + "adr${p}.w\t$dst, #${label}_${id}", []> { let Inst{31-27} = 0b11110; let Inst{25-24} = 0b10; // Inst{23:21} = '11' (add = FALSE) or '00' (add = TRUE) From daniel at zuster.org Tue Aug 10 23:46:14 2010 From: daniel at zuster.org (Daniel Dunbar) Date: Wed, 11 Aug 2010 04:46:14 -0000 Subject: [llvm-commits] [llvm] r110781 - /llvm/trunk/lib/Target/ARM/ARMInstrVFP.td Message-ID: <20100811044614.09C6A2A6C12E@llvm.org> Author: ddunbar Date: Tue Aug 10 23:46:13 2010 New Revision: 110781 URL: http://llvm.org/viewvc/llvm-project?rev=110781&view=rev Log: ARM: Mark some disassembler only instructions as not available for matching -- for some reason they have a very odd MCInst form where the operands overlap, but I haven't dug in to find out why yet. Modified: llvm/trunk/lib/Target/ARM/ARMInstrVFP.td Modified: llvm/trunk/lib/Target/ARM/ARMInstrVFP.td URL: http://llvm.org/viewvc/llvm-project/llvm/trunk/lib/Target/ARM/ARMInstrVFP.td?rev=110781&r1=110780&r2=110781&view=diff ============================================================================== --- llvm/trunk/lib/Target/ARM/ARMInstrVFP.td (original) +++ llvm/trunk/lib/Target/ARM/ARMInstrVFP.td Tue Aug 10 23:46:13 2010 @@ -461,6 +461,7 @@ // FP to Fixed-Point: +let isCodeGenOnly = 1 in { def VTOSHS : AVConv1XI<0b11101, 0b11, 0b1110, 0b1010, 0, (outs SPR:$dst), (ins SPR:$a, i32imm:$fbits), IIC_fpCVTSI, "vcvt", ".s16.f32\t$dst, $a, $fbits", @@ -500,9 +501,11 @@ (outs DPR:$dst), (ins DPR:$a, i32imm:$fbits), IIC_fpCVTDI, "vcvt", ".u32.f64\t$dst, $a, $fbits", [/* For disassembly only; pattern left blank */]>; +} // Fixed-Point to FP: +let isCodeGenOnly = 1 in { def VSHTOS : AVConv1XI<0b11101, 0b11, 0b1010, 0b1010, 0, (outs SPR:$dst), (ins SPR:$a, i32imm:$fbits), IIC_fpCVTIS, "vcvt", ".f32.s16\t$dst, $a, $fbits", @@ -542,6 +545,7 @@ (outs DPR:$dst), (ins DPR:$a, i32imm:$fbits), IIC_fpCVTID, "vcvt", ".f64.u32\t$dst, $a, $fbits", [/* For disassembly only; pattern left blank */]>; +} } // End of 'let Constraints = "$src = $dst" in' From daniel at zuster.org Wed Aug 11 00:09:20 2010 From: daniel at zuster.org (Daniel Dunbar) Date: Wed, 11 Aug 2010 05:09:20 -0000 Subject: [llvm-commits] [llvm] r110782 - in /llvm/trunk/lib/Target/ARM: CMakeLists.txt Makefile Message-ID: <20100811050920.5172B2A6C12C@llvm.org> Author: ddunbar Date: Wed Aug 11 00:09:20 2010 New Revision: 110782 URL: http://llvm.org/viewvc/llvm-project?rev=110782&view=rev Log: MC/ARM: Enable generation of the ARM asm matcher, not that it can do much. Modified: llvm/trunk/lib/Target/ARM/CMakeLists.txt llvm/trunk/lib/Target/ARM/Makefile Modified: llvm/trunk/lib/Target/ARM/CMakeLists.txt URL: http://llvm.org/viewvc/llvm-project/llvm/trunk/lib/Target/ARM/CMakeLists.txt?rev=110782&r1=110781&r2=110782&view=diff ============================================================================== --- llvm/trunk/lib/Target/ARM/CMakeLists.txt (original) +++ llvm/trunk/lib/Target/ARM/CMakeLists.txt Wed Aug 11 00:09:20 2010 @@ -7,11 +7,12 @@ tablegen(ARMGenInstrInfo.inc -gen-instr-desc) tablegen(ARMGenCodeEmitter.inc -gen-emitter) tablegen(ARMGenAsmWriter.inc -gen-asm-writer) +tablegen(ARMGenAsmMatcher.inc -gen-asm-matcher) tablegen(ARMGenDAGISel.inc -gen-dag-isel) +tablegen(ARMGenFastISel.inc -gen-fast-isel) tablegen(ARMGenCallingConv.inc -gen-callingconv) tablegen(ARMGenSubtarget.inc -gen-subtarget) tablegen(ARMGenEDInfo.inc -gen-enhanced-disassembly-info) -tablegen(ARMGenFastISel.inc -gen-fast-isel) add_llvm_target(ARMCodeGen ARMAsmPrinter.cpp Modified: llvm/trunk/lib/Target/ARM/Makefile URL: http://llvm.org/viewvc/llvm-project/llvm/trunk/lib/Target/ARM/Makefile?rev=110782&r1=110781&r2=110782&view=diff ============================================================================== --- llvm/trunk/lib/Target/ARM/Makefile (original) +++ llvm/trunk/lib/Target/ARM/Makefile Wed Aug 11 00:09:20 2010 @@ -14,7 +14,7 @@ # Make sure that tblgen is run, first thing. BUILT_SOURCES = ARMGenRegisterInfo.h.inc ARMGenRegisterNames.inc \ ARMGenRegisterInfo.inc ARMGenInstrNames.inc \ - ARMGenInstrInfo.inc ARMGenAsmWriter.inc \ + ARMGenInstrInfo.inc ARMGenAsmWriter.inc ARMGenAsmMatcher.inc \ ARMGenDAGISel.inc ARMGenSubtarget.inc \ ARMGenCodeEmitter.inc ARMGenCallingConv.inc \ ARMGenDecoderTables.inc ARMGenEDInfo.inc \ From daniel at zuster.org Wed Aug 11 00:24:50 2010 From: daniel at zuster.org (Daniel Dunbar) Date: Wed, 11 Aug 2010 05:24:50 -0000 Subject: [llvm-commits] [llvm] r110783 - /llvm/trunk/lib/Target/ARM/AsmParser/ARMAsmParser.cpp Message-ID: <20100811052450.A3B8B2A6C12C@llvm.org> Author: ddunbar Date: Wed Aug 11 00:24:50 2010 New Revision: 110783 URL: http://llvm.org/viewvc/llvm-project?rev=110783&view=rev Log: MC/ARM: Switch to using the generated match functions instead of stub implementations. Modified: llvm/trunk/lib/Target/ARM/AsmParser/ARMAsmParser.cpp Modified: llvm/trunk/lib/Target/ARM/AsmParser/ARMAsmParser.cpp URL: http://llvm.org/viewvc/llvm-project/llvm/trunk/lib/Target/ARM/AsmParser/ARMAsmParser.cpp?rev=110783&r1=110782&r2=110783&view=diff ============================================================================== --- llvm/trunk/lib/Target/ARM/AsmParser/ARMAsmParser.cpp (original) +++ llvm/trunk/lib/Target/ARM/AsmParser/ARMAsmParser.cpp Wed Aug 11 00:24:50 2010 @@ -8,6 +8,7 @@ //===----------------------------------------------------------------------===// #include "ARM.h" +#include "ARMSubtarget.h" #include "llvm/MC/MCParser/MCAsmLexer.h" #include "llvm/MC/MCParser/MCAsmParser.h" #include "llvm/MC/MCParser/MCParsedAsmOperand.h" @@ -77,20 +78,14 @@ bool ParseDirectiveSyntax(SMLoc L); - // TODO - For now hacked versions of the next two are in here in this file to - // allow some parser testing until the table gen versions are implemented. - /// @name Auto-generated Match Functions /// { + + unsigned ComputeAvailableFeatures(const ARMSubtarget *Subtarget) const; + bool MatchInstruction(const SmallVectorImpl &Operands, MCInst &Inst); - /// MatchRegisterName - Match the given string to a register name and return - /// its register number, or -1 if there is no match. To allow return values - /// to be used directly in register lists, arm registers have values between - /// 0 and 15. - int MatchRegisterName(StringRef Name); - /// } @@ -195,15 +190,30 @@ return Imm.Val; } - bool isToken() const {return Kind == Token; } + bool isImm() const { return Kind == Immediate; } bool isReg() const { return Kind == Register; } + bool isToken() const {return Kind == Token; } + + void addExpr(MCInst &Inst, const MCExpr *Expr) const { + // Add as immediates when possible. + if (const MCConstantExpr *CE = dyn_cast(Expr)) + Inst.addOperand(MCOperand::CreateImm(CE->getValue())); + else + Inst.addOperand(MCOperand::CreateExpr(Expr)); + } + void addRegOperands(MCInst &Inst, unsigned N) const { assert(N == 1 && "Invalid number of operands!"); Inst.addOperand(MCOperand::CreateReg(getReg())); } + void addImmOperands(MCInst &Inst, unsigned N) const { + assert(N == 1 && "Invalid number of operands!"); + addExpr(Inst, getImm()); + } + static void CreateToken(OwningPtr &Op, StringRef Str, SMLoc S) { Op.reset(new ARMOperand); @@ -263,6 +273,14 @@ } // end anonymous namespace. + +/// @name Auto-generated Match Functions +/// { + +static unsigned MatchRegisterName(StringRef Name); + +/// } + /// Try to parse a register name. The token must be an Identifier when called, /// and if it is a register name a Reg operand is created, the token is eaten /// and false is returned. Else true is returned and no token is eaten. @@ -549,77 +567,6 @@ return false; } -/// A hack to allow some testing, to be replaced by a real table gen version. -int ARMAsmParser::MatchRegisterName(StringRef Name) { - if (Name == "r0" || Name == "R0") - return 0; - else if (Name == "r1" || Name == "R1") - return 1; - else if (Name == "r2" || Name == "R2") - return 2; - else if (Name == "r3" || Name == "R3") - return 3; - else if (Name == "r3" || Name == "R3") - return 3; - else if (Name == "r4" || Name == "R4") - return 4; - else if (Name == "r5" || Name == "R5") - return 5; - else if (Name == "r6" || Name == "R6") - return 6; - else if (Name == "r7" || Name == "R7") - return 7; - else if (Name == "r8" || Name == "R8") - return 8; - else if (Name == "r9" || Name == "R9") - return 9; - else if (Name == "r10" || Name == "R10") - return 10; - else if (Name == "r11" || Name == "R11" || Name == "fp") - return 11; - else if (Name == "r12" || Name == "R12" || Name == "ip") - return 12; - else if (Name == "r13" || Name == "R13" || Name == "sp") - return 13; - else if (Name == "r14" || Name == "R14" || Name == "lr") - return 14; - else if (Name == "r15" || Name == "R15" || Name == "pc") - return 15; - return -1; -} - -/// A hack to allow some testing, to be replaced by a real table gen version. -bool ARMAsmParser:: -MatchInstruction(const SmallVectorImpl &Operands, - MCInst &Inst) { - ARMOperand &Op0 = *(ARMOperand*)Operands[0]; - assert(Op0.Kind == ARMOperand::Token && "First operand not a Token"); - StringRef Mnemonic = Op0.getToken(); - if (Mnemonic == "add" || - Mnemonic == "stmfd" || - Mnemonic == "str" || - Mnemonic == "ldmfd" || - Mnemonic == "ldr" || - Mnemonic == "mov" || - Mnemonic == "sub" || - Mnemonic == "bl" || - Mnemonic == "push" || - Mnemonic == "blx" || - Mnemonic == "pop") { - // Hard-coded to a valid instruction, till we have a real matcher. - Inst = MCInst(); - Inst.setOpcode(ARM::MOVr); - Inst.addOperand(MCOperand::CreateReg(2)); - Inst.addOperand(MCOperand::CreateReg(2)); - Inst.addOperand(MCOperand::CreateImm(0)); - Inst.addOperand(MCOperand::CreateImm(0)); - Inst.addOperand(MCOperand::CreateReg(0)); - return false; - } - - return true; -} - /// Parse a arm instruction operand. For now this parses the operand regardless /// of the mnemonic. bool ARMAsmParser::ParseOperand(OwningPtr &Op) { @@ -810,3 +757,5 @@ RegisterAsmParser Y(TheThumbTarget); LLVMInitializeARMAsmLexer(); } + +#include "ARMGenAsmMatcher.inc" From evan.cheng at apple.com Wed Aug 11 01:22:01 2010 From: evan.cheng at apple.com (Evan Cheng) Date: Wed, 11 Aug 2010 06:22:01 -0000 Subject: [llvm-commits] [llvm] r110785 - in /llvm/trunk: lib/Target/ARM/ARM.td lib/Target/ARM/ARMISelLowering.cpp lib/Target/ARM/ARMInstrInfo.td lib/Target/ARM/ARMInstrThumb2.td lib/Target/ARM/ARMSubtarget.cpp lib/Target/ARM/ARMSubtarget.h lib/Target/ARM/Disassembler/ARMDisassemblerCore.cpp test/CodeGen/Thumb/barrier.ll test/CodeGen/Thumb2/thumb2-barrier.ll Message-ID: <20100811062201.B0EC52A6C12C@llvm.org> Author: evancheng Date: Wed Aug 11 01:22:01 2010 New Revision: 110785 URL: http://llvm.org/viewvc/llvm-project?rev=110785&view=rev Log: - Add subtarget feature -mattr=+db which determine whether an ARM cpu has the memory and synchronization barrier dmb and dsb instructions. - Change instruction names to something more sensible (matching name of actual instructions). - Added tests for memory barrier codegen. Added: llvm/trunk/test/CodeGen/Thumb/barrier.ll llvm/trunk/test/CodeGen/Thumb2/thumb2-barrier.ll Modified: llvm/trunk/lib/Target/ARM/ARM.td llvm/trunk/lib/Target/ARM/ARMISelLowering.cpp llvm/trunk/lib/Target/ARM/ARMInstrInfo.td llvm/trunk/lib/Target/ARM/ARMInstrThumb2.td llvm/trunk/lib/Target/ARM/ARMSubtarget.cpp llvm/trunk/lib/Target/ARM/ARMSubtarget.h llvm/trunk/lib/Target/ARM/Disassembler/ARMDisassemblerCore.cpp Modified: llvm/trunk/lib/Target/ARM/ARM.td URL: http://llvm.org/viewvc/llvm-project/llvm/trunk/lib/Target/ARM/ARM.td?rev=110785&r1=110784&r2=110785&view=diff ============================================================================== --- llvm/trunk/lib/Target/ARM/ARM.td (original) +++ llvm/trunk/lib/Target/ARM/ARM.td Wed Aug 11 01:22:01 2010 @@ -48,6 +48,8 @@ "Enable divide instructions">; def FeatureT2ExtractPack: SubtargetFeature<"t2xtpk", "HasT2ExtractPack", "true", "Enable Thumb2 extract and pack instructions">; +def FeatureDB : SubtargetFeature<"db", "HasDataBarrier", "true", + "Has data barrier (dmb / dsb) instructions">; def FeatureSlowFPBrcc : SubtargetFeature<"slow-fp-brcc", "SlowFPBrcc", "true", "FP compare + branch is slow">; @@ -134,11 +136,15 @@ // V7 Processors. def : Processor<"cortex-a8", CortexA8Itineraries, [ArchV7A, FeatureThumb2, FeatureNEON, FeatureHasSlowVMLx, - FeatureSlowFPBrcc, FeatureNEONForFP, FeatureT2ExtractPack]>; + FeatureSlowFPBrcc, FeatureNEONForFP, FeatureT2ExtractPack, + FeatureDB]>; def : Processor<"cortex-a9", CortexA9Itineraries, - [ArchV7A, FeatureThumb2, FeatureNEON, FeatureT2ExtractPack]>; -def : ProcNoItin<"cortex-m3", [ArchV7M, FeatureThumb2, FeatureHWDiv]>; -def : ProcNoItin<"cortex-m4", [ArchV7M, FeatureThumb2, FeatureHWDiv]>; + [ArchV7A, FeatureThumb2, FeatureNEON, FeatureT2ExtractPack, + FeatureDB]>; +def : ProcNoItin<"cortex-m3", [ArchV7M, FeatureThumb2, FeatureHWDiv, + FeatureDB]>; +def : ProcNoItin<"cortex-m4", [ArchV7M, FeatureThumb2, FeatureHWDiv, + FeatureDB]>; //===----------------------------------------------------------------------===// // Register File Description Modified: llvm/trunk/lib/Target/ARM/ARMISelLowering.cpp URL: http://llvm.org/viewvc/llvm-project/llvm/trunk/lib/Target/ARM/ARMISelLowering.cpp?rev=110785&r1=110784&r2=110785&view=diff ============================================================================== --- llvm/trunk/lib/Target/ARM/ARMISelLowering.cpp (original) +++ llvm/trunk/lib/Target/ARM/ARMISelLowering.cpp Wed Aug 11 01:22:01 2010 @@ -412,12 +412,10 @@ // doesn't yet know how to not do that for SjLj. setExceptionSelectorRegister(ARM::R0); setOperationAction(ISD::DYNAMIC_STACKALLOC, MVT::i32, Expand); - // Handle atomics directly for ARMv[67] (except for Thumb1), otherwise - // use the default expansion. - bool canHandleAtomics = - (Subtarget->hasV7Ops() || - (Subtarget->hasV6Ops() && !Subtarget->isThumb1Only())); - if (canHandleAtomics) { + // ARMv6 Thumb1 (except for CPUs that support dmb / dsb) and earlier use + // the default expansion. + if (Subtarget->hasDataBarrier() || + (Subtarget->hasV6Ops() && !Subtarget->isThumb1Only())) { // membarrier needs custom lowering; the rest are legal and handled // normally. setOperationAction(ISD::MEMBARRIER, MVT::Other, Custom); @@ -1992,17 +1990,19 @@ DebugLoc dl = Op.getDebugLoc(); SDValue Op5 = Op.getOperand(5); unsigned isDeviceBarrier = cast(Op5)->getZExtValue(); - // v6 and v7 can both handle barriers directly, but need handled a bit - // differently. Thumb1 and pre-v6 ARM mode use a libcall instead and should + // Some subtargets which have dmb and dsb instructions can handle barriers + // directly. Some ARMv6 cpus can support them with the help of mcr + // instruction. Thumb1 and pre-v6 ARM mode use a libcall instead and should // never get here. unsigned Opc = isDeviceBarrier ? ARMISD::SYNCBARRIER : ARMISD::MEMBARRIER; - if (Subtarget->hasV7Ops()) + if (Subtarget->hasDataBarrier()) return DAG.getNode(Opc, dl, MVT::Other, Op.getOperand(0)); - else if (Subtarget->hasV6Ops() && !Subtarget->isThumb1Only()) + else { + assert(Subtarget->hasV6Ops() && !Subtarget->isThumb1Only() && + "Unexpected ISD::MEMBARRIER encountered. Should be libcall!"); return DAG.getNode(Opc, dl, MVT::Other, Op.getOperand(0), DAG.getConstant(0, MVT::i32)); - assert(0 && "Unexpected ISD::MEMBARRIER encountered. Should be libcall!"); - return SDValue(); + } } static SDValue LowerVASTART(SDValue Op, SelectionDAG &DAG) { Modified: llvm/trunk/lib/Target/ARM/ARMInstrInfo.td URL: http://llvm.org/viewvc/llvm-project/llvm/trunk/lib/Target/ARM/ARMInstrInfo.td?rev=110785&r1=110784&r2=110785&view=diff ============================================================================== --- llvm/trunk/lib/Target/ARM/ARMInstrInfo.td (original) +++ llvm/trunk/lib/Target/ARM/ARMInstrInfo.td Wed Aug 11 01:22:01 2010 @@ -54,10 +54,10 @@ SDTCisInt<2>]>; def SDT_ARMEH_SJLJ_Longjmp: SDTypeProfile<0, 2, [SDTCisPtrTy<0>, SDTCisInt<1>]>; -def SDT_ARMMEMBARRIERV7 : SDTypeProfile<0, 0, []>; -def SDT_ARMSYNCBARRIERV7 : SDTypeProfile<0, 0, []>; -def SDT_ARMMEMBARRIERV6 : SDTypeProfile<0, 1, [SDTCisInt<0>]>; -def SDT_ARMSYNCBARRIERV6 : SDTypeProfile<0, 1, [SDTCisInt<0>]>; +def SDT_ARMMEMBARRIER : SDTypeProfile<0, 0, []>; +def SDT_ARMSYNCBARRIER : SDTypeProfile<0, 0, []>; +def SDT_ARMMEMBARRIERMCR : SDTypeProfile<0, 1, [SDTCisInt<0>]>; +def SDT_ARMSYNCBARRIERMCR : SDTypeProfile<0, 1, [SDTCisInt<0>]>; def SDT_ARMTCRET : SDTypeProfile<0, 1, [SDTCisPtrTy<0>]>; @@ -120,14 +120,14 @@ def ARMeh_sjlj_longjmp: SDNode<"ARMISD::EH_SJLJ_LONGJMP", SDT_ARMEH_SJLJ_Longjmp, [SDNPHasChain]>; -def ARMMemBarrierV7 : SDNode<"ARMISD::MEMBARRIER", SDT_ARMMEMBARRIERV7, - [SDNPHasChain]>; -def ARMSyncBarrierV7 : SDNode<"ARMISD::SYNCBARRIER", SDT_ARMMEMBARRIERV7, - [SDNPHasChain]>; -def ARMMemBarrierV6 : SDNode<"ARMISD::MEMBARRIER", SDT_ARMMEMBARRIERV6, - [SDNPHasChain]>; -def ARMSyncBarrierV6 : SDNode<"ARMISD::SYNCBARRIER", SDT_ARMMEMBARRIERV6, - [SDNPHasChain]>; +def ARMMemBarrier : SDNode<"ARMISD::MEMBARRIER", SDT_ARMMEMBARRIER, + [SDNPHasChain]>; +def ARMSyncBarrier : SDNode<"ARMISD::SYNCBARRIER", SDT_ARMMEMBARRIER, + [SDNPHasChain]>; +def ARMMemBarrierMCR : SDNode<"ARMISD::MEMBARRIER", SDT_ARMMEMBARRIERMCR, + [SDNPHasChain]>; +def ARMSyncBarrierMCR : SDNode<"ARMISD::SYNCBARRIER", SDT_ARMMEMBARRIERMCR, + [SDNPHasChain]>; def ARMrbit : SDNode<"ARMISD::RBIT", SDTIntUnaryOp>; @@ -154,6 +154,7 @@ def HasNEON : Predicate<"Subtarget->hasNEON()">; def HasDivide : Predicate<"Subtarget->hasDivide()">; def HasT2ExtractPack : Predicate<"Subtarget->hasT2ExtractPack()">; +def HasDB : Predicate<"Subtarget->hasDataBarrier()">; def UseNEONForFP : Predicate<"Subtarget->useNEONForSinglePrecisionFP()">; def DontUseNEONForFP : Predicate<"!Subtarget->useNEONForSinglePrecisionFP()">; def IsThumb : Predicate<"Subtarget->isThumb()">; @@ -2369,41 +2370,33 @@ // memory barriers protect the atomic sequences let hasSideEffects = 1 in { -def Int_MemBarrierV7 : AInoP<(outs), (ins), - Pseudo, NoItinerary, - "dmb", "", - [(ARMMemBarrierV7)]>, - Requires<[IsARM, HasV7]> { +def DMBsy : AInoP<(outs), (ins), Pseudo, NoItinerary, "dmb", "", + [(ARMMemBarrier)]>, Requires<[IsARM, HasV7]> { let Inst{31-4} = 0xf57ff05; // FIXME: add support for options other than a full system DMB // See DMB disassembly-only variants below. let Inst{3-0} = 0b1111; } -def Int_SyncBarrierV7 : AInoP<(outs), (ins), - Pseudo, NoItinerary, - "dsb", "", - [(ARMSyncBarrierV7)]>, - Requires<[IsARM, HasV7]> { +def DSBsy : AInoP<(outs), (ins), Pseudo, NoItinerary, "dsb", "", + [(ARMSyncBarrier)]>, Requires<[IsARM, HasV7]> { let Inst{31-4} = 0xf57ff04; // FIXME: add support for options other than a full system DSB // See DSB disassembly-only variants below. let Inst{3-0} = 0b1111; } -def Int_MemBarrierV6 : AInoP<(outs), (ins GPR:$zero), - Pseudo, NoItinerary, +def DMB_MCR : AInoP<(outs), (ins GPR:$zero), Pseudo, NoItinerary, "mcr", "\tp15, 0, $zero, c7, c10, 5", - [(ARMMemBarrierV6 GPR:$zero)]>, + [(ARMMemBarrierMCR GPR:$zero)]>, Requires<[IsARM, HasV6]> { // FIXME: add support for options other than a full system DMB // FIXME: add encoding } -def Int_SyncBarrierV6 : AInoP<(outs), (ins GPR:$zero), - Pseudo, NoItinerary, +def DSB_MCR : AInoP<(outs), (ins GPR:$zero), Pseudo, NoItinerary, "mcr", "\tp15, 0, $zero, c7, c10, 4", - [(ARMSyncBarrierV6 GPR:$zero)]>, + [(ARMSyncBarrierMCR GPR:$zero)]>, Requires<[IsARM, HasV6]> { // FIXME: add support for options other than a full system DSB // FIXME: add encoding Modified: llvm/trunk/lib/Target/ARM/ARMInstrThumb2.td URL: http://llvm.org/viewvc/llvm-project/llvm/trunk/lib/Target/ARM/ARMInstrThumb2.td?rev=110785&r1=110784&r2=110785&view=diff ============================================================================== --- llvm/trunk/lib/Target/ARM/ARMInstrThumb2.td (original) +++ llvm/trunk/lib/Target/ARM/ARMInstrThumb2.td Wed Aug 11 01:22:01 2010 @@ -2229,21 +2229,15 @@ // memory barriers protect the atomic sequences let hasSideEffects = 1 in { -def t2Int_MemBarrierV7 : AInoP<(outs), (ins), - ThumbFrm, NoItinerary, - "dmb", "", - [(ARMMemBarrierV7)]>, - Requires<[IsThumb2]> { +def t2DMBsy : AInoP<(outs), (ins), ThumbFrm, NoItinerary, "dmb", "", + [(ARMMemBarrier)]>, Requires<[HasDB]> { let Inst{31-4} = 0xF3BF8F5; // FIXME: add support for options other than a full system DMB let Inst{3-0} = 0b1111; } -def t2Int_SyncBarrierV7 : AInoP<(outs), (ins), - ThumbFrm, NoItinerary, - "dsb", "", - [(ARMSyncBarrierV7)]>, - Requires<[IsThumb2]> { +def t2DSBsy : AInoP<(outs), (ins), ThumbFrm, NoItinerary, "dsb", "", + [(ARMSyncBarrier)]>, Requires<[HasDB]> { let Inst{31-4} = 0xF3BF8F4; // FIXME: add support for options other than a full system DSB let Inst{3-0} = 0b1111; Modified: llvm/trunk/lib/Target/ARM/ARMSubtarget.cpp URL: http://llvm.org/viewvc/llvm-project/llvm/trunk/lib/Target/ARM/ARMSubtarget.cpp?rev=110785&r1=110784&r2=110785&view=diff ============================================================================== --- llvm/trunk/lib/Target/ARM/ARMSubtarget.cpp (original) +++ llvm/trunk/lib/Target/ARM/ARMSubtarget.cpp Wed Aug 11 01:22:01 2010 @@ -42,6 +42,7 @@ , HasFP16(false) , HasHardwareDivide(false) , HasT2ExtractPack(false) + , HasDataBarrier(false) , Pref32BitThumb(false) , stackAlignment(4) , CPUString("generic") Modified: llvm/trunk/lib/Target/ARM/ARMSubtarget.h URL: http://llvm.org/viewvc/llvm-project/llvm/trunk/lib/Target/ARM/ARMSubtarget.h?rev=110785&r1=110784&r2=110785&view=diff ============================================================================== --- llvm/trunk/lib/Target/ARM/ARMSubtarget.h (original) +++ llvm/trunk/lib/Target/ARM/ARMSubtarget.h Wed Aug 11 01:22:01 2010 @@ -84,6 +84,10 @@ /// instructions. bool HasT2ExtractPack; + /// HasDataBarrier - True if the subtarget supports DMB / DSB data barrier + /// instructions. + bool HasDataBarrier; + /// Pref32BitThumb - If true, codegen would prefer 32-bit Thumb instructions /// over 16-bit ones. bool Pref32BitThumb; @@ -139,6 +143,7 @@ return hasNEON() && UseNEONForSinglePrecisionFP; } bool hasDivide() const { return HasHardwareDivide; } bool hasT2ExtractPack() const { return HasT2ExtractPack; } + bool hasDataBarrier() const { return HasDataBarrier; } bool useVMLx() const {return hasVFP2() && !SlowVMLx; } bool isFPBrccSlow() const { return SlowFPBrcc; } bool prefers32BitThumb() const { return Pref32BitThumb; } Modified: llvm/trunk/lib/Target/ARM/Disassembler/ARMDisassemblerCore.cpp URL: http://llvm.org/viewvc/llvm-project/llvm/trunk/lib/Target/ARM/Disassembler/ARMDisassemblerCore.cpp?rev=110785&r1=110784&r2=110785&view=diff ============================================================================== --- llvm/trunk/lib/Target/ARM/Disassembler/ARMDisassemblerCore.cpp (original) +++ llvm/trunk/lib/Target/ARM/Disassembler/ARMDisassemblerCore.cpp Wed Aug 11 01:22:01 2010 @@ -493,7 +493,7 @@ static bool DisassemblePseudo(MCInst &MI, unsigned Opcode, uint32_t insn, unsigned short NumOps, unsigned &NumOpsAdded, BO) { - if (Opcode == ARM::Int_MemBarrierV7 || Opcode == ARM::Int_SyncBarrierV7) + if (Opcode == ARM::DMBsy || Opcode == ARM::DSBsy) return true; assert(0 && "Unexpected pseudo instruction!"); Added: llvm/trunk/test/CodeGen/Thumb/barrier.ll URL: http://llvm.org/viewvc/llvm-project/llvm/trunk/test/CodeGen/Thumb/barrier.ll?rev=110785&view=auto ============================================================================== --- llvm/trunk/test/CodeGen/Thumb/barrier.ll (added) +++ llvm/trunk/test/CodeGen/Thumb/barrier.ll Wed Aug 11 01:22:01 2010 @@ -0,0 +1,17 @@ +; RUN: llc < %s -march=thumb -mattr=+v6 | FileCheck %s + +declare void @llvm.memory.barrier( i1 , i1 , i1 , i1 , i1 ) + +define void @t1() { +; CHECK: t1: +; CHECK: blx {{_*}}sync_synchronize + call void @llvm.memory.barrier( i1 false, i1 false, i1 false, i1 true, i1 true ) + ret void +} + +define void @t2() { +; CHECK: t2: +; CHECK: blx {{_*}}sync_synchronize + call void @llvm.memory.barrier( i1 false, i1 false, i1 false, i1 true, i1 false ) + ret void +} Added: llvm/trunk/test/CodeGen/Thumb2/thumb2-barrier.ll URL: http://llvm.org/viewvc/llvm-project/llvm/trunk/test/CodeGen/Thumb2/thumb2-barrier.ll?rev=110785&view=auto ============================================================================== --- llvm/trunk/test/CodeGen/Thumb2/thumb2-barrier.ll (added) +++ llvm/trunk/test/CodeGen/Thumb2/thumb2-barrier.ll Wed Aug 11 01:22:01 2010 @@ -0,0 +1,17 @@ +; RUN: llc < %s -march=thumb -mcpu=cortex-a8 | FileCheck %s + +declare void @llvm.memory.barrier( i1 , i1 , i1 , i1 , i1 ) + +define void @t1() { +; CHECK: t1: +; CHECK: dsb + call void @llvm.memory.barrier( i1 false, i1 false, i1 false, i1 true, i1 true ) + ret void +} + +define void @t2() { +; CHECK: t2: +; CHECK: dmb + call void @llvm.memory.barrier( i1 false, i1 false, i1 false, i1 true, i1 false ) + ret void +} From evan.cheng at apple.com Wed Aug 11 01:30:38 2010 From: evan.cheng at apple.com (Evan Cheng) Date: Wed, 11 Aug 2010 06:30:38 -0000 Subject: [llvm-commits] [llvm] r110786 - in /llvm/trunk: lib/Target/ARM/ARM.td test/CodeGen/Thumb/barrier.ll Message-ID: <20100811063038.ED68F2A6C12C@llvm.org> Author: evancheng Date: Wed Aug 11 01:30:38 2010 New Revision: 110786 URL: http://llvm.org/viewvc/llvm-project?rev=110786&view=rev Log: Add Cortex-M0 support. It's a ARMv6m device (no ARM mode) with some 32-bit instructions: dmb, dsb, isb, msr, and mrs. Modified: llvm/trunk/lib/Target/ARM/ARM.td llvm/trunk/test/CodeGen/Thumb/barrier.ll Modified: llvm/trunk/lib/Target/ARM/ARM.td URL: http://llvm.org/viewvc/llvm-project/llvm/trunk/lib/Target/ARM/ARM.td?rev=110786&r1=110785&r2=110786&view=diff ============================================================================== --- llvm/trunk/lib/Target/ARM/ARM.td (original) +++ llvm/trunk/lib/Target/ARM/ARM.td Wed Aug 11 01:30:38 2010 @@ -127,6 +127,9 @@ def : Processor<"mpcorenovfp", ARMV6Itineraries, [ArchV6]>; def : Processor<"mpcore", ARMV6Itineraries, [ArchV6, FeatureVFP2]>; +// V6M Processors. +def : Processor<"cortex-m0", ARMV6Itineraries, [ArchV6, FeatureDB]>; + // V6T2 Processors. def : Processor<"arm1156t2-s", ARMV6Itineraries, [ArchV6T2, FeatureThumb2]>; @@ -141,6 +144,8 @@ def : Processor<"cortex-a9", CortexA9Itineraries, [ArchV7A, FeatureThumb2, FeatureNEON, FeatureT2ExtractPack, FeatureDB]>; + +// V7M Processors. def : ProcNoItin<"cortex-m3", [ArchV7M, FeatureThumb2, FeatureHWDiv, FeatureDB]>; def : ProcNoItin<"cortex-m4", [ArchV7M, FeatureThumb2, FeatureHWDiv, Modified: llvm/trunk/test/CodeGen/Thumb/barrier.ll URL: http://llvm.org/viewvc/llvm-project/llvm/trunk/test/CodeGen/Thumb/barrier.ll?rev=110786&r1=110785&r2=110786&view=diff ============================================================================== --- llvm/trunk/test/CodeGen/Thumb/barrier.ll (original) +++ llvm/trunk/test/CodeGen/Thumb/barrier.ll Wed Aug 11 01:30:38 2010 @@ -1,17 +1,24 @@ -; RUN: llc < %s -march=thumb -mattr=+v6 | FileCheck %s +; RUN: llc < %s -march=thumb -mattr=+v6 | FileCheck %s -check-prefix=V6 +; RUN: llc < %s -march=thumb -mcpu=cortex-m0 | FileCheck %s -check-prefix=M0 declare void @llvm.memory.barrier( i1 , i1 , i1 , i1 , i1 ) define void @t1() { -; CHECK: t1: -; CHECK: blx {{_*}}sync_synchronize +; V6: t1: +; V6: blx {{_*}}sync_synchronize + +; M0: t1: +; M0: dsb call void @llvm.memory.barrier( i1 false, i1 false, i1 false, i1 true, i1 true ) ret void } define void @t2() { -; CHECK: t2: -; CHECK: blx {{_*}}sync_synchronize +; V6: t2: +; V6: blx {{_*}}sync_synchronize + +; M0: t2: +; M0: dmb call void @llvm.memory.barrier( i1 false, i1 false, i1 false, i1 true, i1 false ) ret void } From evan.cheng at apple.com Wed Aug 11 01:36:31 2010 From: evan.cheng at apple.com (Evan Cheng) Date: Wed, 11 Aug 2010 06:36:31 -0000 Subject: [llvm-commits] [llvm] r110787 - in /llvm/trunk/lib/Target/ARM: ARMInstrInfo.td ARMInstrThumb2.td Message-ID: <20100811063631.A999E2A6C12C@llvm.org> Author: evancheng Date: Wed Aug 11 01:36:31 2010 New Revision: 110787 URL: http://llvm.org/viewvc/llvm-project?rev=110787&view=rev Log: Really control isel of barrier instructions with cpu feature. Modified: llvm/trunk/lib/Target/ARM/ARMInstrInfo.td llvm/trunk/lib/Target/ARM/ARMInstrThumb2.td Modified: llvm/trunk/lib/Target/ARM/ARMInstrInfo.td URL: http://llvm.org/viewvc/llvm-project/llvm/trunk/lib/Target/ARM/ARMInstrInfo.td?rev=110787&r1=110786&r2=110787&view=diff ============================================================================== --- llvm/trunk/lib/Target/ARM/ARMInstrInfo.td (original) +++ llvm/trunk/lib/Target/ARM/ARMInstrInfo.td Wed Aug 11 01:36:31 2010 @@ -2371,7 +2371,7 @@ // memory barriers protect the atomic sequences let hasSideEffects = 1 in { def DMBsy : AInoP<(outs), (ins), Pseudo, NoItinerary, "dmb", "", - [(ARMMemBarrier)]>, Requires<[IsARM, HasV7]> { + [(ARMMemBarrier)]>, Requires<[IsARM, HasDB]> { let Inst{31-4} = 0xf57ff05; // FIXME: add support for options other than a full system DMB // See DMB disassembly-only variants below. @@ -2379,7 +2379,7 @@ } def DSBsy : AInoP<(outs), (ins), Pseudo, NoItinerary, "dsb", "", - [(ARMSyncBarrier)]>, Requires<[IsARM, HasV7]> { + [(ARMSyncBarrier)]>, Requires<[IsARM, HasDB]> { let Inst{31-4} = 0xf57ff04; // FIXME: add support for options other than a full system DSB // See DSB disassembly-only variants below. Modified: llvm/trunk/lib/Target/ARM/ARMInstrThumb2.td URL: http://llvm.org/viewvc/llvm-project/llvm/trunk/lib/Target/ARM/ARMInstrThumb2.td?rev=110787&r1=110786&r2=110787&view=diff ============================================================================== --- llvm/trunk/lib/Target/ARM/ARMInstrThumb2.td (original) +++ llvm/trunk/lib/Target/ARM/ARMInstrThumb2.td Wed Aug 11 01:36:31 2010 @@ -2230,14 +2230,14 @@ // memory barriers protect the atomic sequences let hasSideEffects = 1 in { def t2DMBsy : AInoP<(outs), (ins), ThumbFrm, NoItinerary, "dmb", "", - [(ARMMemBarrier)]>, Requires<[HasDB]> { + [(ARMMemBarrier)]>, Requires<[IsThumb, HasDB]> { let Inst{31-4} = 0xF3BF8F5; // FIXME: add support for options other than a full system DMB let Inst{3-0} = 0b1111; } def t2DSBsy : AInoP<(outs), (ins), ThumbFrm, NoItinerary, "dsb", "", - [(ARMSyncBarrier)]>, Requires<[HasDB]> { + [(ARMSyncBarrier)]>, Requires<[IsThumb, HasDB]> { let Inst{31-4} = 0xF3BF8F4; // FIXME: add support for options other than a full system DSB let Inst{3-0} = 0b1111; From daniel at zuster.org Wed Aug 11 01:36:53 2010 From: daniel at zuster.org (Daniel Dunbar) Date: Wed, 11 Aug 2010 06:36:53 -0000 Subject: [llvm-commits] [llvm] r110788 - in /llvm/trunk/lib/Target/ARM: ARMInstrFormats.td AsmParser/ARMAsmParser.cpp Message-ID: <20100811063653.C65C72A6C12C@llvm.org> Author: ddunbar Date: Wed Aug 11 01:36:53 2010 New Revision: 110788 URL: http://llvm.org/viewvc/llvm-project?rev=110788&view=rev Log: MC/ARM: Add an ARMOperand class for condition codes. Modified: llvm/trunk/lib/Target/ARM/ARMInstrFormats.td llvm/trunk/lib/Target/ARM/AsmParser/ARMAsmParser.cpp Modified: llvm/trunk/lib/Target/ARM/ARMInstrFormats.td URL: http://llvm.org/viewvc/llvm-project/llvm/trunk/lib/Target/ARM/ARMInstrFormats.td?rev=110788&r1=110787&r2=110788&view=diff ============================================================================== --- llvm/trunk/lib/Target/ARM/ARMInstrFormats.td (original) +++ llvm/trunk/lib/Target/ARM/ARMInstrFormats.td Wed Aug 11 01:36:53 2010 @@ -138,11 +138,17 @@ // ARM special operands. // +def CondCodeOperand : AsmOperandClass { + let Name = "CondCode"; + let SuperClasses = []; +} + // ARM Predicate operand. Default to 14 = always (AL). Second part is CC // register whose default is 0 (no register). def pred : PredicateOperand { let PrintMethod = "printPredicateOperand"; + let ParserMatchClass = CondCodeOperand; } // Conditional code result for instructions whose 's' bit is set, e.g. subs. Modified: llvm/trunk/lib/Target/ARM/AsmParser/ARMAsmParser.cpp URL: http://llvm.org/viewvc/llvm-project/llvm/trunk/lib/Target/ARM/AsmParser/ARMAsmParser.cpp?rev=110788&r1=110787&r2=110788&view=diff ============================================================================== --- llvm/trunk/lib/Target/ARM/AsmParser/ARMAsmParser.cpp (original) +++ llvm/trunk/lib/Target/ARM/AsmParser/ARMAsmParser.cpp Wed Aug 11 01:36:53 2010 @@ -106,16 +106,21 @@ ARMOperand() {} public: enum KindTy { - Token, - Register, + CondCode, Immediate, - Memory + Memory, + Register, + Token } Kind; SMLoc StartLoc, EndLoc; union { struct { + ARMCC::CondCodes Val; + } CC; + + struct { const char *Data; unsigned Length; } Tok; @@ -155,8 +160,11 @@ StartLoc = o.StartLoc; EndLoc = o.EndLoc; switch (Kind) { + case CondCode: + CC = o.CC; + break; case Token: - Tok = o.Tok; + Tok = o.Tok; break; case Register: Reg = o.Reg; @@ -175,6 +183,11 @@ /// getEndLoc - Get the location of the last token of this operand. SMLoc getEndLoc() const { return EndLoc; } + ARMCC::CondCodes getCondCode() const { + assert(Kind == CondCode && "Invalid access!"); + return CC.Val; + } + StringRef getToken() const { assert(Kind == Token && "Invalid access!"); return StringRef(Tok.Data, Tok.Length); @@ -190,6 +203,8 @@ return Imm.Val; } + bool isCondCode() const { return Kind == CondCode; } + bool isImm() const { return Kind == Immediate; } bool isReg() const { return Kind == Register; } @@ -204,6 +219,11 @@ Inst.addOperand(MCOperand::CreateExpr(Expr)); } + void addCondCodeOperands(MCInst &Inst, unsigned N) const { + assert(N == 1 && "Invalid number of operands!"); + Inst.addOperand(MCOperand::CreateImm(unsigned(getCondCode()))); + } + void addRegOperands(MCInst &Inst, unsigned N) const { assert(N == 1 && "Invalid number of operands!"); Inst.addOperand(MCOperand::CreateReg(getReg())); From daniel at zuster.org Wed Aug 11 01:36:59 2010 From: daniel at zuster.org (Daniel Dunbar) Date: Wed, 11 Aug 2010 06:36:59 -0000 Subject: [llvm-commits] [llvm] r110789 - /llvm/trunk/utils/TableGen/AsmMatcherEmitter.cpp Message-ID: <20100811063659.5EFE12A6C12D@llvm.org> Author: ddunbar Date: Wed Aug 11 01:36:59 2010 New Revision: 110789 URL: http://llvm.org/viewvc/llvm-project?rev=110789&view=rev Log: tblgen/AsmMatcher: Treat '.' in assembly strings as a token separator. Modified: llvm/trunk/utils/TableGen/AsmMatcherEmitter.cpp Modified: llvm/trunk/utils/TableGen/AsmMatcherEmitter.cpp URL: http://llvm.org/viewvc/llvm-project/llvm/trunk/utils/TableGen/AsmMatcherEmitter.cpp?rev=110789&r1=110788&r2=110789&view=diff ============================================================================== --- llvm/trunk/utils/TableGen/AsmMatcherEmitter.cpp (original) +++ llvm/trunk/utils/TableGen/AsmMatcherEmitter.cpp Wed Aug 11 01:36:59 2010 @@ -199,6 +199,14 @@ break; } + case '.': + if (InTok) { + Tokens.push_back(AsmString.slice(Prev, i)); + } + Prev = i; + InTok = true; + break; + default: InTok = true; } From daniel at zuster.org Wed Aug 11 01:37:04 2010 From: daniel at zuster.org (Daniel Dunbar) Date: Wed, 11 Aug 2010 06:37:04 -0000 Subject: [llvm-commits] [llvm] r110790 - in /llvm/trunk: include/llvm/MC/MCParser/MCParsedAsmOperand.h lib/MC/MCParser/MCAsmParser.cpp lib/Target/ARM/AsmParser/ARMAsmParser.cpp lib/Target/X86/AsmParser/X86AsmParser.cpp Message-ID: <20100811063705.0068A2A6C12C@llvm.org> Author: ddunbar Date: Wed Aug 11 01:37:04 2010 New Revision: 110790 URL: http://llvm.org/viewvc/llvm-project?rev=110790&view=rev Log: MCAsmParser: Add dump() hook to MCParsedAsmOperand. Modified: llvm/trunk/include/llvm/MC/MCParser/MCParsedAsmOperand.h llvm/trunk/lib/MC/MCParser/MCAsmParser.cpp llvm/trunk/lib/Target/ARM/AsmParser/ARMAsmParser.cpp llvm/trunk/lib/Target/X86/AsmParser/X86AsmParser.cpp Modified: llvm/trunk/include/llvm/MC/MCParser/MCParsedAsmOperand.h URL: http://llvm.org/viewvc/llvm-project/llvm/trunk/include/llvm/MC/MCParser/MCParsedAsmOperand.h?rev=110790&r1=110789&r2=110790&view=diff ============================================================================== --- llvm/trunk/include/llvm/MC/MCParser/MCParsedAsmOperand.h (original) +++ llvm/trunk/include/llvm/MC/MCParser/MCParsedAsmOperand.h Wed Aug 11 01:37:04 2010 @@ -12,6 +12,7 @@ namespace llvm { class SMLoc; +class raw_ostream; /// MCParsedAsmOperand - This abstract class represents a source-level assembly /// instruction operand. It should be subclassed by target-specific code. This @@ -23,9 +24,12 @@ virtual ~MCParsedAsmOperand() {} /// getStartLoc - Get the location of the first token of this operand. - virtual SMLoc getStartLoc() const; + virtual SMLoc getStartLoc() const = 0; /// getEndLoc - Get the location of the last token of this operand. - virtual SMLoc getEndLoc() const; + virtual SMLoc getEndLoc() const = 0; + + /// dump - Print a debug representation of the operand to the given stream. + virtual void dump(raw_ostream &OS) const = 0; }; } // end namespace llvm. Modified: llvm/trunk/lib/MC/MCParser/MCAsmParser.cpp URL: http://llvm.org/viewvc/llvm-project/llvm/trunk/lib/MC/MCParser/MCAsmParser.cpp?rev=110790&r1=110789&r2=110790&view=diff ============================================================================== --- llvm/trunk/lib/MC/MCParser/MCAsmParser.cpp (original) +++ llvm/trunk/lib/MC/MCParser/MCAsmParser.cpp Wed Aug 11 01:37:04 2010 @@ -41,8 +41,4 @@ return ParseExpression(Res, L); } -/// getStartLoc - Get the location of the first token of this operand. -SMLoc MCParsedAsmOperand::getStartLoc() const { return SMLoc(); } -SMLoc MCParsedAsmOperand::getEndLoc() const { return SMLoc(); } - Modified: llvm/trunk/lib/Target/ARM/AsmParser/ARMAsmParser.cpp URL: http://llvm.org/viewvc/llvm-project/llvm/trunk/lib/Target/ARM/AsmParser/ARMAsmParser.cpp?rev=110790&r1=110789&r2=110790&view=diff ============================================================================== --- llvm/trunk/lib/Target/ARM/AsmParser/ARMAsmParser.cpp (original) +++ llvm/trunk/lib/Target/ARM/AsmParser/ARMAsmParser.cpp Wed Aug 11 01:37:04 2010 @@ -234,6 +234,8 @@ addExpr(Inst, getImm()); } + virtual void dump(raw_ostream &OS) const {} + static void CreateToken(OwningPtr &Op, StringRef Str, SMLoc S) { Op.reset(new ARMOperand); Modified: llvm/trunk/lib/Target/X86/AsmParser/X86AsmParser.cpp URL: http://llvm.org/viewvc/llvm-project/llvm/trunk/lib/Target/X86/AsmParser/X86AsmParser.cpp?rev=110790&r1=110789&r2=110790&view=diff ============================================================================== --- llvm/trunk/lib/Target/X86/AsmParser/X86AsmParser.cpp (original) +++ llvm/trunk/lib/Target/X86/AsmParser/X86AsmParser.cpp Wed Aug 11 01:37:04 2010 @@ -148,6 +148,8 @@ /// getEndLoc - Get the location of the last token of this operand. SMLoc getEndLoc() const { return EndLoc; } + virtual void dump(raw_ostream &OS) const {} + StringRef getToken() const { assert(Kind == Token && "Invalid access!"); return StringRef(Tok.Data, Tok.Length); From daniel at zuster.org Wed Aug 11 01:37:09 2010 From: daniel at zuster.org (Daniel Dunbar) Date: Wed, 11 Aug 2010 06:37:09 -0000 Subject: [llvm-commits] [llvm] r110791 - in /llvm/trunk: include/llvm/MC/MCParser/MCAsmParser.h lib/MC/MCParser/AsmParser.cpp lib/MC/MCParser/MCAsmParser.cpp tools/llvm-mc/llvm-mc.cpp Message-ID: <20100811063709.D23C22A6C12D@llvm.org> Author: ddunbar Date: Wed Aug 11 01:37:09 2010 New Revision: 110791 URL: http://llvm.org/viewvc/llvm-project?rev=110791&view=rev Log: llvm-mc: Add -show-inst-operands, for dumping the parsed instruction representation before matching. Modified: llvm/trunk/include/llvm/MC/MCParser/MCAsmParser.h llvm/trunk/lib/MC/MCParser/AsmParser.cpp llvm/trunk/lib/MC/MCParser/MCAsmParser.cpp llvm/trunk/tools/llvm-mc/llvm-mc.cpp Modified: llvm/trunk/include/llvm/MC/MCParser/MCAsmParser.h URL: http://llvm.org/viewvc/llvm-project/llvm/trunk/include/llvm/MC/MCParser/MCAsmParser.h?rev=110791&r1=110790&r2=110791&view=diff ============================================================================== --- llvm/trunk/include/llvm/MC/MCParser/MCAsmParser.h (original) +++ llvm/trunk/include/llvm/MC/MCParser/MCAsmParser.h Wed Aug 11 01:37:09 2010 @@ -39,6 +39,8 @@ TargetAsmParser *TargetParser; + unsigned ShowParsedOperands : 1; + protected: // Can only create subclasses. MCAsmParser(); @@ -61,6 +63,9 @@ TargetAsmParser &getTargetParser() const { return *TargetParser; } void setTargetParser(TargetAsmParser &P); + bool getShowParsedOperands() const { return ShowParsedOperands; } + void setShowParsedOperands(bool Value) { ShowParsedOperands = Value; } + /// Run - Run the parser on the input source buffer. virtual bool Run(bool NoInitialTextSection, bool NoFinalize = false) = 0; Modified: llvm/trunk/lib/MC/MCParser/AsmParser.cpp URL: http://llvm.org/viewvc/llvm-project/llvm/trunk/lib/MC/MCParser/AsmParser.cpp?rev=110791&r1=110790&r2=110791&view=diff ============================================================================== --- llvm/trunk/lib/MC/MCParser/AsmParser.cpp (original) +++ llvm/trunk/lib/MC/MCParser/AsmParser.cpp Wed Aug 11 01:37:09 2010 @@ -916,6 +916,21 @@ if (!HadError && Lexer.isNot(AsmToken::EndOfStatement)) HadError = TokError("unexpected token in argument list"); + // Dump the parsed representation, if requested. + if (getShowParsedOperands()) { + SmallString<256> Str; + raw_svector_ostream OS(Str); + OS << "parsed instruction: ["; + for (unsigned i = 0; i != ParsedOperands.size(); ++i) { + if (i != 0) + OS << ", "; + ParsedOperands[i]->dump(OS); + } + OS << "]"; + + PrintMessage(IDLoc, OS.str(), "note"); + } + // If parsing succeeded, match the instruction. if (!HadError) { MCInst Inst; Modified: llvm/trunk/lib/MC/MCParser/MCAsmParser.cpp URL: http://llvm.org/viewvc/llvm-project/llvm/trunk/lib/MC/MCParser/MCAsmParser.cpp?rev=110791&r1=110790&r2=110791&view=diff ============================================================================== --- llvm/trunk/lib/MC/MCParser/MCAsmParser.cpp (original) +++ llvm/trunk/lib/MC/MCParser/MCAsmParser.cpp Wed Aug 11 01:37:09 2010 @@ -15,7 +15,7 @@ #include "llvm/Target/TargetAsmParser.h" using namespace llvm; -MCAsmParser::MCAsmParser() : TargetParser(0) { +MCAsmParser::MCAsmParser() : TargetParser(0), ShowParsedOperands(0) { } MCAsmParser::~MCAsmParser() { Modified: llvm/trunk/tools/llvm-mc/llvm-mc.cpp URL: http://llvm.org/viewvc/llvm-project/llvm/trunk/tools/llvm-mc/llvm-mc.cpp?rev=110791&r1=110790&r2=110791&view=diff ============================================================================== --- llvm/trunk/tools/llvm-mc/llvm-mc.cpp (original) +++ llvm/trunk/tools/llvm-mc/llvm-mc.cpp Wed Aug 11 01:37:09 2010 @@ -51,6 +51,10 @@ static cl::opt ShowInst("show-inst", cl::desc("Show internal instruction representation")); +static cl::opt +ShowInstOperands("show-inst-operands", + cl::desc("Show instructions operands as parsed")); + static cl::opt OutputAsmVariant("output-asm-variant", cl::desc("Syntax variant to use for output printing")); @@ -320,6 +324,7 @@ return 1; } + Parser->setShowParsedOperands(ShowInstOperands); Parser->setTargetParser(*TAP.get()); int Res = Parser->Run(NoInitialTextSection); From daniel at zuster.org Wed Aug 11 01:37:12 2010 From: daniel at zuster.org (Daniel Dunbar) Date: Wed, 11 Aug 2010 06:37:12 -0000 Subject: [llvm-commits] [llvm] r110792 - /llvm/trunk/lib/Target/ARM/AsmParser/ARMAsmParser.cpp Message-ID: <20100811063712.DE1EE2A6C12C@llvm.org> Author: ddunbar Date: Wed Aug 11 01:37:12 2010 New Revision: 110792 URL: http://llvm.org/viewvc/llvm-project?rev=110792&view=rev Log: MC/ARM: Fill in ARMOperand::dump a bit. Modified: llvm/trunk/lib/Target/ARM/AsmParser/ARMAsmParser.cpp Modified: llvm/trunk/lib/Target/ARM/AsmParser/ARMAsmParser.cpp URL: http://llvm.org/viewvc/llvm-project/llvm/trunk/lib/Target/ARM/AsmParser/ARMAsmParser.cpp?rev=110792&r1=110791&r2=110792&view=diff ============================================================================== --- llvm/trunk/lib/Target/ARM/AsmParser/ARMAsmParser.cpp (original) +++ llvm/trunk/lib/Target/ARM/AsmParser/ARMAsmParser.cpp Wed Aug 11 01:37:12 2010 @@ -19,6 +19,7 @@ #include "llvm/Target/TargetAsmParser.h" #include "llvm/Support/Compiler.h" #include "llvm/Support/SourceMgr.h" +#include "llvm/Support/raw_ostream.h" #include "llvm/ADT/OwningPtr.h" #include "llvm/ADT/SmallVector.h" #include "llvm/ADT/Twine.h" @@ -234,7 +235,7 @@ addExpr(Inst, getImm()); } - virtual void dump(raw_ostream &OS) const {} + virtual void dump(raw_ostream &OS) const; static void CreateToken(OwningPtr &Op, StringRef Str, SMLoc S) { @@ -295,6 +296,25 @@ } // end anonymous namespace. +void ARMOperand::dump(raw_ostream &OS) const { + switch (Kind) { + case CondCode: + OS << ARMCondCodeToString(getCondCode()); + break; + case Immediate: + getImm()->print(OS); + break; + case Memory: + OS << ""; + break; + case Register: + OS << ""; + break; + case Token: + OS << "'" << getToken() << "'"; + break; + } +} /// @name Auto-generated Match Functions /// { From daniel at zuster.org Wed Aug 11 01:37:16 2010 From: daniel at zuster.org (Daniel Dunbar) Date: Wed, 11 Aug 2010 06:37:16 -0000 Subject: [llvm-commits] [llvm] r110793 - /llvm/trunk/lib/Target/ARM/AsmParser/ARMAsmParser.cpp Message-ID: <20100811063716.C9AA62A6C12D@llvm.org> Author: ddunbar Date: Wed Aug 11 01:37:16 2010 New Revision: 110793 URL: http://llvm.org/viewvc/llvm-project?rev=110793&view=rev Log: MC/ARM: Split mnemonic on '.' characters. Modified: llvm/trunk/lib/Target/ARM/AsmParser/ARMAsmParser.cpp Modified: llvm/trunk/lib/Target/ARM/AsmParser/ARMAsmParser.cpp URL: http://llvm.org/viewvc/llvm-project/llvm/trunk/lib/Target/ARM/AsmParser/ARMAsmParser.cpp?rev=110793&r1=110792&r2=110793&view=diff ============================================================================== --- llvm/trunk/lib/Target/ARM/AsmParser/ARMAsmParser.cpp (original) +++ llvm/trunk/lib/Target/ARM/AsmParser/ARMAsmParser.cpp Wed Aug 11 01:37:16 2010 @@ -651,12 +651,25 @@ bool ARMAsmParser::ParseInstruction(StringRef Name, SMLoc NameLoc, SmallVectorImpl &Operands) { OwningPtr Op; - ARMOperand::CreateToken(Op, Name, NameLoc); - + + // Create the leading tokens for the mnemonic, split by '.' characters. + size_t Start = 0, Next = Name.find('.'); + StringRef Head = Name.slice(Start, Next); + + ARMOperand::CreateToken(Op, Head, NameLoc); Operands.push_back(Op.take()); - if (getLexer().isNot(AsmToken::EndOfStatement)) { + while (Next != StringRef::npos) { + Start = Next; + Next = Name.find('.', Start + 1); + Head = Name.slice(Start, Next); + ARMOperand::CreateToken(Op, Head, NameLoc); + Operands.push_back(Op.take()); + } + + // Read the remaining operands. + if (getLexer().isNot(AsmToken::EndOfStatement)) { // Read the first operand. OwningPtr Op; if (ParseOperand(Op)) return true; From daniel at zuster.org Wed Aug 11 01:37:21 2010 From: daniel at zuster.org (Daniel Dunbar) Date: Wed, 11 Aug 2010 06:37:21 -0000 Subject: [llvm-commits] [llvm] r110794 - in /llvm/trunk: lib/Target/ARM/AsmParser/ARMAsmParser.cpp test/MC/AsmParser/ARM/arm_instructions.s Message-ID: <20100811063721.2BCA42A6C12C@llvm.org> Author: ddunbar Date: Wed Aug 11 01:37:20 2010 New Revision: 110794 URL: http://llvm.org/viewvc/llvm-project?rev=110794&view=rev Log: MC/ARM: Add basic support for handling predication by parsing it out of the mnemonic into a separate operand form. Added: llvm/trunk/test/MC/AsmParser/ARM/arm_instructions.s Modified: llvm/trunk/lib/Target/ARM/AsmParser/ARMAsmParser.cpp Modified: llvm/trunk/lib/Target/ARM/AsmParser/ARMAsmParser.cpp URL: http://llvm.org/viewvc/llvm-project/llvm/trunk/lib/Target/ARM/AsmParser/ARMAsmParser.cpp?rev=110794&r1=110793&r2=110794&view=diff ============================================================================== --- llvm/trunk/lib/Target/ARM/AsmParser/ARMAsmParser.cpp (original) +++ llvm/trunk/lib/Target/ARM/AsmParser/ARMAsmParser.cpp Wed Aug 11 01:37:20 2010 @@ -22,6 +22,7 @@ #include "llvm/Support/raw_ostream.h" #include "llvm/ADT/OwningPtr.h" #include "llvm/ADT/SmallVector.h" +#include "llvm/ADT/StringSwitch.h" #include "llvm/ADT/Twine.h" using namespace llvm; @@ -221,8 +222,10 @@ } void addCondCodeOperands(MCInst &Inst, unsigned N) const { - assert(N == 1 && "Invalid number of operands!"); + assert(N == 2 && "Invalid number of operands!"); Inst.addOperand(MCOperand::CreateImm(unsigned(getCondCode()))); + // FIXME: What belongs here? + Inst.addOperand(MCOperand::CreateReg(0)); } void addRegOperands(MCInst &Inst, unsigned N) const { @@ -237,6 +240,15 @@ virtual void dump(raw_ostream &OS) const; + static void CreateCondCode(OwningPtr &Op, ARMCC::CondCodes CC, + SMLoc S) { + Op.reset(new ARMOperand); + Op->Kind = CondCode; + Op->CC.Val = CC; + Op->StartLoc = S; + Op->EndLoc = S; + } + static void CreateToken(OwningPtr &Op, StringRef Str, SMLoc S) { Op.reset(new ARMOperand); @@ -656,9 +668,40 @@ size_t Start = 0, Next = Name.find('.'); StringRef Head = Name.slice(Start, Next); + // Determine the predicate, if any. + // + // FIXME: We need a way to check whether a prefix supports predication, + // otherwise we will end up with an ambiguity for instructions that happen to + // end with a predicate name. + unsigned CC = StringSwitch(Head.substr(Head.size()-2)) + .Case("eq", ARMCC::EQ) + .Case("ne", ARMCC::NE) + .Case("hs", ARMCC::HS) + .Case("lo", ARMCC::LO) + .Case("mi", ARMCC::MI) + .Case("pl", ARMCC::PL) + .Case("vs", ARMCC::VS) + .Case("vc", ARMCC::VC) + .Case("hi", ARMCC::HI) + .Case("ls", ARMCC::LS) + .Case("ge", ARMCC::GE) + .Case("lt", ARMCC::LT) + .Case("gt", ARMCC::GT) + .Case("le", ARMCC::LE) + .Case("al", ARMCC::AL) + .Default(~0U); + if (CC != ~0U) { + Head = Head.slice(0, Head.size() - 2); + } else + CC = ARMCC::AL; + ARMOperand::CreateToken(Op, Head, NameLoc); Operands.push_back(Op.take()); + ARMOperand::CreateCondCode(Op, ARMCC::CondCodes(CC), NameLoc); + Operands.push_back(Op.take()); + + // Add the remaining tokens in the mnemonic. while (Next != StringRef::npos) { Start = Next; Next = Name.find('.', Start + 1); Added: llvm/trunk/test/MC/AsmParser/ARM/arm_instructions.s URL: http://llvm.org/viewvc/llvm-project/llvm/trunk/test/MC/AsmParser/ARM/arm_instructions.s?rev=110794&view=auto ============================================================================== --- llvm/trunk/test/MC/AsmParser/ARM/arm_instructions.s (added) +++ llvm/trunk/test/MC/AsmParser/ARM/arm_instructions.s Wed Aug 11 01:37:20 2010 @@ -0,0 +1,8 @@ +@ RUN: llvm-mc -triple arm-unknown-unknown %s | FileCheck %s + +@ CHECK: nop + nop + +@ CHECK: nopeq + nopeq + From evan.cheng at apple.com Wed Aug 11 01:51:54 2010 From: evan.cheng at apple.com (Evan Cheng) Date: Wed, 11 Aug 2010 06:51:54 -0000 Subject: [llvm-commits] [llvm] r110795 - in /llvm/trunk: lib/Target/ARM/ARM.td lib/Target/ARM/ARMSubtarget.h test/CodeGen/Thumb/barrier.ll Message-ID: <20100811065154.D58392A6C12C@llvm.org> Author: evancheng Date: Wed Aug 11 01:51:54 2010 New Revision: 110795 URL: http://llvm.org/viewvc/llvm-project?rev=110795&view=rev Log: Add ARM Archv6M and let it implies FeatureDB (having dmb, etc.) Modified: llvm/trunk/lib/Target/ARM/ARM.td llvm/trunk/lib/Target/ARM/ARMSubtarget.h llvm/trunk/test/CodeGen/Thumb/barrier.ll Modified: llvm/trunk/lib/Target/ARM/ARM.td URL: http://llvm.org/viewvc/llvm-project/llvm/trunk/lib/Target/ARM/ARM.td?rev=110795&r1=110794&r2=110795&view=diff ============================================================================== --- llvm/trunk/lib/Target/ARM/ARM.td (original) +++ llvm/trunk/lib/Target/ARM/ARM.td Wed Aug 11 01:51:54 2010 @@ -20,20 +20,6 @@ // ARM Subtarget features. // -def ArchV4T : SubtargetFeature<"v4t", "ARMArchVersion", "V4T", - "ARM v4T">; -def ArchV5T : SubtargetFeature<"v5t", "ARMArchVersion", "V5T", - "ARM v5T">; -def ArchV5TE : SubtargetFeature<"v5te", "ARMArchVersion", "V5TE", - "ARM v5TE, v5TEj, v5TExp">; -def ArchV6 : SubtargetFeature<"v6", "ARMArchVersion", "V6", - "ARM v6">; -def ArchV6T2 : SubtargetFeature<"v6t2", "ARMArchVersion", "V6T2", - "ARM v6t2">; -def ArchV7A : SubtargetFeature<"v7a", "ARMArchVersion", "V7A", - "ARM v7A">; -def ArchV7M : SubtargetFeature<"v7m", "ARMArchVersion", "V7M", - "ARM v7M">; def FeatureVFP2 : SubtargetFeature<"vfp2", "ARMFPUType", "VFPv2", "Enable VFP2 instructions">; def FeatureVFP3 : SubtargetFeature<"vfp3", "ARMFPUType", "VFPv3", @@ -46,10 +32,10 @@ "Enable half-precision floating point">; def FeatureHWDiv : SubtargetFeature<"hwdiv", "HasHardwareDivide", "true", "Enable divide instructions">; -def FeatureT2ExtractPack: SubtargetFeature<"t2xtpk", "HasT2ExtractPack", "true", +def FeatureT2XtPk : SubtargetFeature<"t2xtpk", "HasT2ExtractPack", "true", "Enable Thumb2 extract and pack instructions">; -def FeatureDB : SubtargetFeature<"db", "HasDataBarrier", "true", - "Has data barrier (dmb / dsb) instructions">; +def FeatureDB : SubtargetFeature<"db", "HasDataBarrier", "true", + "Has data barrier (dmb / dsb) instructions">; def FeatureSlowFPBrcc : SubtargetFeature<"slow-fp-brcc", "SlowFPBrcc", "true", "FP compare + branch is slow">; @@ -59,18 +45,40 @@ // FIXME: Currently, this is only flagged for Cortex-A8. It may be true for // others as well. We should do more benchmarking and confirm one way or // the other. -def FeatureHasSlowVMLx : SubtargetFeature<"vmlx", "SlowVMLx", "true", - "Disable VFP MAC instructions">; +def FeatureHasSlowVMLx : SubtargetFeature<"vmlx", "SlowVMLx", "true", + "Disable VFP MAC instructions">; // Some processors benefit from using NEON instructions for scalar // single-precision FP operations. -def FeatureNEONForFP : SubtargetFeature<"neonfp", "UseNEONForSinglePrecisionFP", - "true", - "Use NEON for single precision FP">; +def FeatureNEONForFP : SubtargetFeature<"neonfp", "UseNEONForSinglePrecisionFP", + "true", + "Use NEON for single precision FP">; // Disable 32-bit to 16-bit narrowing for experimentation. def FeaturePref32BitThumb : SubtargetFeature<"32bit", "Pref32BitThumb", "true", "Prefer 32-bit Thumb instrs">; + +// ARM architectures. +def ArchV4T : SubtargetFeature<"v4t", "ARMArchVersion", "V4T", + "ARM v4T">; +def ArchV5T : SubtargetFeature<"v5t", "ARMArchVersion", "V5T", + "ARM v5T">; +def ArchV5TE : SubtargetFeature<"v5te", "ARMArchVersion", "V5TE", + "ARM v5TE, v5TEj, v5TExp">; +def ArchV6 : SubtargetFeature<"v6", "ARMArchVersion", "V6", + "ARM v6">; +def ArchV6M : SubtargetFeature<"v6m", "ARMArchVersion", "V6M", + "ARM v6m", + [FeatureDB]>; +def ArchV6T2 : SubtargetFeature<"v6t2", "ARMArchVersion", "V6T2", + "ARM v6t2">; +def ArchV7A : SubtargetFeature<"v7a", "ARMArchVersion", "V7A", + "ARM v7A", + [FeatureDB]>; +def ArchV7M : SubtargetFeature<"v7m", "ARMArchVersion", "V7M", + "ARM v7M", + [FeatureDB]>; + //===----------------------------------------------------------------------===// // ARM Processors supported. // @@ -128,7 +136,7 @@ def : Processor<"mpcore", ARMV6Itineraries, [ArchV6, FeatureVFP2]>; // V6M Processors. -def : Processor<"cortex-m0", ARMV6Itineraries, [ArchV6, FeatureDB]>; +def : Processor<"cortex-m0", ARMV6Itineraries, [ArchV6M]>; // V6T2 Processors. def : Processor<"arm1156t2-s", ARMV6Itineraries, @@ -139,17 +147,13 @@ // V7 Processors. def : Processor<"cortex-a8", CortexA8Itineraries, [ArchV7A, FeatureThumb2, FeatureNEON, FeatureHasSlowVMLx, - FeatureSlowFPBrcc, FeatureNEONForFP, FeatureT2ExtractPack, - FeatureDB]>; + FeatureSlowFPBrcc, FeatureNEONForFP, FeatureT2XtPk]>; def : Processor<"cortex-a9", CortexA9Itineraries, - [ArchV7A, FeatureThumb2, FeatureNEON, FeatureT2ExtractPack, - FeatureDB]>; + [ArchV7A, FeatureThumb2, FeatureNEON, FeatureT2XtPk]>; // V7M Processors. -def : ProcNoItin<"cortex-m3", [ArchV7M, FeatureThumb2, FeatureHWDiv, - FeatureDB]>; -def : ProcNoItin<"cortex-m4", [ArchV7M, FeatureThumb2, FeatureHWDiv, - FeatureDB]>; +def : ProcNoItin<"cortex-m3", [ArchV7M, FeatureThumb2, FeatureHWDiv]>; +def : ProcNoItin<"cortex-m4", [ArchV7M, FeatureThumb2, FeatureHWDiv]>; //===----------------------------------------------------------------------===// // Register File Description Modified: llvm/trunk/lib/Target/ARM/ARMSubtarget.h URL: http://llvm.org/viewvc/llvm-project/llvm/trunk/lib/Target/ARM/ARMSubtarget.h?rev=110795&r1=110794&r2=110795&view=diff ============================================================================== --- llvm/trunk/lib/Target/ARM/ARMSubtarget.h (original) +++ llvm/trunk/lib/Target/ARM/ARMSubtarget.h Wed Aug 11 01:51:54 2010 @@ -26,7 +26,7 @@ class ARMSubtarget : public TargetSubtarget { protected: enum ARMArchEnum { - V4, V4T, V5T, V5TE, V6, V6T2, V7A, V7M + V4, V4T, V5T, V5TE, V6, V6M, V6T2, V7A, V7M }; enum ARMFPEnum { Modified: llvm/trunk/test/CodeGen/Thumb/barrier.ll URL: http://llvm.org/viewvc/llvm-project/llvm/trunk/test/CodeGen/Thumb/barrier.ll?rev=110795&r1=110794&r2=110795&view=diff ============================================================================== --- llvm/trunk/test/CodeGen/Thumb/barrier.ll (original) +++ llvm/trunk/test/CodeGen/Thumb/barrier.ll Wed Aug 11 01:51:54 2010 @@ -1,5 +1,5 @@ -; RUN: llc < %s -march=thumb -mattr=+v6 | FileCheck %s -check-prefix=V6 -; RUN: llc < %s -march=thumb -mcpu=cortex-m0 | FileCheck %s -check-prefix=M0 +; RUN: llc < %s -march=thumb -mattr=+v6 | FileCheck %s -check-prefix=V6 +; RUN: llc < %s -march=thumb -mattr=+v6m | FileCheck %s -check-prefix=V6M declare void @llvm.memory.barrier( i1 , i1 , i1 , i1 , i1 ) @@ -7,8 +7,8 @@ ; V6: t1: ; V6: blx {{_*}}sync_synchronize -; M0: t1: -; M0: dsb +; V6M: t1: +; V6M: dsb call void @llvm.memory.barrier( i1 false, i1 false, i1 false, i1 true, i1 true ) ret void } @@ -17,8 +17,8 @@ ; V6: t2: ; V6: blx {{_*}}sync_synchronize -; M0: t2: -; M0: dmb +; V6M: t2: +; V6M: dmb call void @llvm.memory.barrier( i1 false, i1 false, i1 false, i1 true, i1 false ) ret void } From evan.cheng at apple.com Wed Aug 11 01:57:53 2010 From: evan.cheng at apple.com (Evan Cheng) Date: Wed, 11 Aug 2010 06:57:53 -0000 Subject: [llvm-commits] [llvm] r110796 - /llvm/trunk/lib/Target/ARM/ARM.td Message-ID: <20100811065753.AE6242A6C12C@llvm.org> Author: evancheng Date: Wed Aug 11 01:57:53 2010 New Revision: 110796 URL: http://llvm.org/viewvc/llvm-project?rev=110796&view=rev Log: ArchV6T2, V7A, and V7M implies Thumb2; Archv7A implies NEON. Modified: llvm/trunk/lib/Target/ARM/ARM.td Modified: llvm/trunk/lib/Target/ARM/ARM.td URL: http://llvm.org/viewvc/llvm-project/llvm/trunk/lib/Target/ARM/ARM.td?rev=110796&r1=110795&r2=110796&view=diff ============================================================================== --- llvm/trunk/lib/Target/ARM/ARM.td (original) +++ llvm/trunk/lib/Target/ARM/ARM.td Wed Aug 11 01:57:53 2010 @@ -71,13 +71,14 @@ "ARM v6m", [FeatureDB]>; def ArchV6T2 : SubtargetFeature<"v6t2", "ARMArchVersion", "V6T2", - "ARM v6t2">; + "ARM v6t2", + [FeatureThumb2]>; def ArchV7A : SubtargetFeature<"v7a", "ARMArchVersion", "V7A", "ARM v7A", - [FeatureDB]>; + [FeatureThumb2, FeatureNEON, FeatureDB]>; def ArchV7M : SubtargetFeature<"v7m", "ARMArchVersion", "V7M", "ARM v7M", - [FeatureDB]>; + [FeatureThumb2, FeatureDB]>; //===----------------------------------------------------------------------===// // ARM Processors supported. @@ -139,21 +140,19 @@ def : Processor<"cortex-m0", ARMV6Itineraries, [ArchV6M]>; // V6T2 Processors. -def : Processor<"arm1156t2-s", ARMV6Itineraries, - [ArchV6T2, FeatureThumb2]>; -def : Processor<"arm1156t2f-s", ARMV6Itineraries, - [ArchV6T2, FeatureThumb2, FeatureVFP2]>; +def : Processor<"arm1156t2-s", ARMV6Itineraries, [ArchV6T2]>; +def : Processor<"arm1156t2f-s", ARMV6Itineraries, [ArchV6T2, FeatureVFP2]>; // V7 Processors. def : Processor<"cortex-a8", CortexA8Itineraries, - [ArchV7A, FeatureThumb2, FeatureNEON, FeatureHasSlowVMLx, + [ArchV7A, FeatureHasSlowVMLx, FeatureSlowFPBrcc, FeatureNEONForFP, FeatureT2XtPk]>; def : Processor<"cortex-a9", CortexA9Itineraries, - [ArchV7A, FeatureThumb2, FeatureNEON, FeatureT2XtPk]>; + [ArchV7A, FeatureT2XtPk]>; // V7M Processors. -def : ProcNoItin<"cortex-m3", [ArchV7M, FeatureThumb2, FeatureHWDiv]>; -def : ProcNoItin<"cortex-m4", [ArchV7M, FeatureThumb2, FeatureHWDiv]>; +def : ProcNoItin<"cortex-m3", [ArchV7M, FeatureHWDiv]>; +def : ProcNoItin<"cortex-m4", [ArchV7M, FeatureHWDiv]>; //===----------------------------------------------------------------------===// // Register File Description From evan.cheng at apple.com Wed Aug 11 02:00:16 2010 From: evan.cheng at apple.com (Evan Cheng) Date: Wed, 11 Aug 2010 07:00:16 -0000 Subject: [llvm-commits] [llvm] r110797 - /llvm/trunk/lib/Target/ARM/ARM.td Message-ID: <20100811070016.396E52A6C12C@llvm.org> Author: evancheng Date: Wed Aug 11 02:00:16 2010 New Revision: 110797 URL: http://llvm.org/viewvc/llvm-project?rev=110797&view=rev Log: ArchV7M implies HW division instructions. Modified: llvm/trunk/lib/Target/ARM/ARM.td Modified: llvm/trunk/lib/Target/ARM/ARM.td URL: http://llvm.org/viewvc/llvm-project/llvm/trunk/lib/Target/ARM/ARM.td?rev=110797&r1=110796&r2=110797&view=diff ============================================================================== --- llvm/trunk/lib/Target/ARM/ARM.td (original) +++ llvm/trunk/lib/Target/ARM/ARM.td Wed Aug 11 02:00:16 2010 @@ -78,7 +78,7 @@ [FeatureThumb2, FeatureNEON, FeatureDB]>; def ArchV7M : SubtargetFeature<"v7m", "ARMArchVersion", "V7M", "ARM v7M", - [FeatureThumb2, FeatureDB]>; + [FeatureThumb2, FeatureDB, FeatureHWDiv]>; //===----------------------------------------------------------------------===// // ARM Processors supported. @@ -151,8 +151,8 @@ [ArchV7A, FeatureT2XtPk]>; // V7M Processors. -def : ProcNoItin<"cortex-m3", [ArchV7M, FeatureHWDiv]>; -def : ProcNoItin<"cortex-m4", [ArchV7M, FeatureHWDiv]>; +def : ProcNoItin<"cortex-m3", [ArchV7M]>; +def : ProcNoItin<"cortex-m4", [ArchV7M]>; //===----------------------------------------------------------------------===// // Register File Description From evan.cheng at apple.com Wed Aug 11 02:17:47 2010 From: evan.cheng at apple.com (Evan Cheng) Date: Wed, 11 Aug 2010 07:17:47 -0000 Subject: [llvm-commits] [llvm] r110798 - in /llvm/trunk: lib/Target/ARM/ARM.td lib/Target/ARM/ARMSubtarget.cpp lib/Target/ARM/ARMSubtarget.h lib/Target/ARM/ARMTargetMachine.cpp test/CodeGen/ARM/div.ll test/CodeGen/Thumb2/div.ll Message-ID: <20100811071747.233762A6C12C@llvm.org> Author: evancheng Date: Wed Aug 11 02:17:46 2010 New Revision: 110798 URL: http://llvm.org/viewvc/llvm-project?rev=110798&view=rev Log: Report error if codegen tries to instantiate a ARM target when the cpu does support it. e.g. cortex-m* processors. Modified: llvm/trunk/lib/Target/ARM/ARM.td llvm/trunk/lib/Target/ARM/ARMSubtarget.cpp llvm/trunk/lib/Target/ARM/ARMSubtarget.h llvm/trunk/lib/Target/ARM/ARMTargetMachine.cpp llvm/trunk/test/CodeGen/ARM/div.ll llvm/trunk/test/CodeGen/Thumb2/div.ll Modified: llvm/trunk/lib/Target/ARM/ARM.td URL: http://llvm.org/viewvc/llvm-project/llvm/trunk/lib/Target/ARM/ARM.td?rev=110798&r1=110797&r2=110798&view=diff ============================================================================== --- llvm/trunk/lib/Target/ARM/ARM.td (original) +++ llvm/trunk/lib/Target/ARM/ARM.td Wed Aug 11 02:17:46 2010 @@ -28,6 +28,8 @@ "Enable NEON instructions">; def FeatureThumb2 : SubtargetFeature<"thumb2", "ThumbMode", "Thumb2", "Enable Thumb2 instructions">; +def FeatureNoARM : SubtargetFeature<"noarm", "NoARM", "true", + "Does not support ARM mode execution">; def FeatureFP16 : SubtargetFeature<"fp16", "HasFP16", "true", "Enable half-precision floating point">; def FeatureHWDiv : SubtargetFeature<"hwdiv", "HasHardwareDivide", "true", @@ -69,7 +71,7 @@ "ARM v6">; def ArchV6M : SubtargetFeature<"v6m", "ARMArchVersion", "V6M", "ARM v6m", - [FeatureDB]>; + [FeatureNoARM, FeatureDB]>; def ArchV6T2 : SubtargetFeature<"v6t2", "ARMArchVersion", "V6T2", "ARM v6t2", [FeatureThumb2]>; @@ -78,7 +80,8 @@ [FeatureThumb2, FeatureNEON, FeatureDB]>; def ArchV7M : SubtargetFeature<"v7m", "ARMArchVersion", "V7M", "ARM v7M", - [FeatureThumb2, FeatureDB, FeatureHWDiv]>; + [FeatureThumb2, FeatureNoARM, FeatureDB, + FeatureHWDiv]>; //===----------------------------------------------------------------------===// // ARM Processors supported. Modified: llvm/trunk/lib/Target/ARM/ARMSubtarget.cpp URL: http://llvm.org/viewvc/llvm-project/llvm/trunk/lib/Target/ARM/ARMSubtarget.cpp?rev=110798&r1=110797&r2=110798&view=diff ============================================================================== --- llvm/trunk/lib/Target/ARM/ARMSubtarget.cpp (original) +++ llvm/trunk/lib/Target/ARM/ARMSubtarget.cpp Wed Aug 11 02:17:46 2010 @@ -36,6 +36,7 @@ , SlowFPBrcc(false) , IsThumb(isT) , ThumbMode(Thumb1) + , NoARM(false) , PostRAScheduler(false) , IsR9Reserved(ReserveR9) , UseMovt(UseMOVT) Modified: llvm/trunk/lib/Target/ARM/ARMSubtarget.h URL: http://llvm.org/viewvc/llvm-project/llvm/trunk/lib/Target/ARM/ARMSubtarget.h?rev=110798&r1=110797&r2=110798&view=diff ============================================================================== --- llvm/trunk/lib/Target/ARM/ARMSubtarget.h (original) +++ llvm/trunk/lib/Target/ARM/ARMSubtarget.h Wed Aug 11 02:17:46 2010 @@ -63,6 +63,9 @@ /// ThumbMode - Indicates supported Thumb version. ThumbTypeEnum ThumbMode; + /// NoARM - True if subtarget does not support ARM mode execution. + bool NoARM; + /// PostRAScheduler - True if using post-register-allocation scheduler. bool PostRAScheduler; @@ -136,6 +139,8 @@ bool hasV6T2Ops() const { return ARMArchVersion >= V6T2; } bool hasV7Ops() const { return ARMArchVersion >= V7A; } + bool hasARMOps() const { return !NoARM; } + bool hasVFP2() const { return ARMFPUType >= VFPv2; } bool hasVFP3() const { return ARMFPUType >= VFPv3; } bool hasNEON() const { return ARMFPUType >= NEON; } Modified: llvm/trunk/lib/Target/ARM/ARMTargetMachine.cpp URL: http://llvm.org/viewvc/llvm-project/llvm/trunk/lib/Target/ARM/ARMTargetMachine.cpp?rev=110798&r1=110797&r2=110798&view=diff ============================================================================== --- llvm/trunk/lib/Target/ARM/ARMTargetMachine.cpp (original) +++ llvm/trunk/lib/Target/ARM/ARMTargetMachine.cpp Wed Aug 11 02:17:46 2010 @@ -65,6 +65,9 @@ "v128:64:128-v64:64:64-n32")), TLInfo(*this), TSInfo(*this) { + if (!Subtarget.hasARMOps()) + report_fatal_error("CPU: '" + Subtarget.getCPUString() + "' does not " + "support ARM mode execution!"); } ThumbTargetMachine::ThumbTargetMachine(const Target &T, const std::string &TT, Modified: llvm/trunk/test/CodeGen/ARM/div.ll URL: http://llvm.org/viewvc/llvm-project/llvm/trunk/test/CodeGen/ARM/div.ll?rev=110798&r1=110797&r2=110798&view=diff ============================================================================== --- llvm/trunk/test/CodeGen/ARM/div.ll (original) +++ llvm/trunk/test/CodeGen/ARM/div.ll Wed Aug 11 02:17:46 2010 @@ -1,13 +1,9 @@ ; RUN: llc < %s -march=arm | FileCheck %s -check-prefix=CHECK-ARM -; RUN: llc < %s -march=arm -mcpu=cortex-m3 \ -; RUN: | FileCheck %s -check-prefix=CHECK-ARMV7M define i32 @f1(i32 %a, i32 %b) { entry: ; CHECK-ARM: f1 ; CHECK-ARM: __divsi3 -; CHECK-ARMV7M: f1 -; CHECK-ARMV7M: sdiv %tmp1 = sdiv i32 %a, %b ; [#uses=1] ret i32 %tmp1 } @@ -16,8 +12,6 @@ entry: ; CHECK-ARM: f2 ; CHECK-ARM: __udivsi3 -; CHECK-ARMV7M: f2 -; CHECK-ARMV7M: udiv %tmp1 = udiv i32 %a, %b ; [#uses=1] ret i32 %tmp1 } @@ -26,8 +20,6 @@ entry: ; CHECK-ARM: f3 ; CHECK-ARM: __modsi3 -; CHECK-ARMV7M: f3 -; CHECK-ARMV7M: sdiv %tmp1 = srem i32 %a, %b ; [#uses=1] ret i32 %tmp1 } @@ -36,8 +28,6 @@ entry: ; CHECK-ARM: f4 ; CHECK-ARM: __umodsi3 -; CHECK-ARMV7M: f4 -; CHECK-ARMV7M: udiv %tmp1 = urem i32 %a, %b ; [#uses=1] ret i32 %tmp1 } Modified: llvm/trunk/test/CodeGen/Thumb2/div.ll URL: http://llvm.org/viewvc/llvm-project/llvm/trunk/test/CodeGen/Thumb2/div.ll?rev=110798&r1=110797&r2=110798&view=diff ============================================================================== --- llvm/trunk/test/CodeGen/Thumb2/div.ll (original) +++ llvm/trunk/test/CodeGen/Thumb2/div.ll Wed Aug 11 02:17:46 2010 @@ -1,6 +1,6 @@ ; RUN: llc < %s -march=thumb -mattr=+thumb2 \ ; RUN: | FileCheck %s -check-prefix=CHECK-THUMB -; RUN: llc < %s -march=arm -mcpu=cortex-m3 -mattr=+thumb2 \ +; RUN: llc < %s -march=thumb -mcpu=cortex-m3 -mattr=+thumb2 \ ; RUN: | FileCheck %s -check-prefix=CHECK-THUMBV7M define i32 @f1(i32 %a, i32 %b) { From isanbard at gmail.com Wed Aug 11 03:43:16 2010 From: isanbard at gmail.com (Bill Wendling) Date: Wed, 11 Aug 2010 08:43:16 -0000 Subject: [llvm-commits] [llvm] r110799 - in /llvm/trunk: lib/Target/ARM/ARMISelLowering.cpp lib/Target/ARM/ARMISelLowering.h test/CodeGen/ARM/select.ll Message-ID: <20100811084316.8A1092A6C12C@llvm.org> Author: void Date: Wed Aug 11 03:43:16 2010 New Revision: 110799 URL: http://llvm.org/viewvc/llvm-project?rev=110799&view=rev Log: Consider this code snippet: float t1(int argc) { return (argc == 1123) ? 1.234f : 2.38213f; } We would generate truly awful code on ARM (those with a weak stomach should look away): _t1: movw r1, #1123 movs r2, #1 movs r3, #0 cmp r0, r1 mov.w r0, #0 it eq moveq r0, r2 movs r1, #4 cmp r0, #0 it ne movne r3, r1 adr r0, #LCPI1_0 ldr r0, [r0, r3] bx lr The problem was that legalization was creating a cascade of SELECT_CC nodes, for for the comparison of "argc == 1123" which was fed into a SELECT node for the ?: statement which was itself converted to a SELECT_CC node. This is because the ARM back-end doesn't have custom lowering for SELECT nodes, so it used the default "Expand". I added a fairly simple "LowerSELECT" to the ARM back-end. It takes care of this testcase, but can obviously be expanded to include more cases. Now we generate this, which looks optimal to me: _t1: movw r1, #1123 movs r2, #0 cmp r0, r1 adr r0, #LCPI0_0 it eq moveq r2, #4 ldr r0, [r0, r2] bx lr .align 2 LCPI0_0: .long 1075344593 @ float 2.382130e+00 .long 1067316150 @ float 1.234000e+00 Modified: llvm/trunk/lib/Target/ARM/ARMISelLowering.cpp llvm/trunk/lib/Target/ARM/ARMISelLowering.h llvm/trunk/test/CodeGen/ARM/select.ll Modified: llvm/trunk/lib/Target/ARM/ARMISelLowering.cpp URL: http://llvm.org/viewvc/llvm-project/llvm/trunk/lib/Target/ARM/ARMISelLowering.cpp?rev=110799&r1=110798&r2=110799&view=diff ============================================================================== --- llvm/trunk/lib/Target/ARM/ARMISelLowering.cpp (original) +++ llvm/trunk/lib/Target/ARM/ARMISelLowering.cpp Wed Aug 11 03:43:16 2010 @@ -483,9 +483,9 @@ setOperationAction(ISD::SETCC, MVT::i32, Expand); setOperationAction(ISD::SETCC, MVT::f32, Expand); setOperationAction(ISD::SETCC, MVT::f64, Expand); - setOperationAction(ISD::SELECT, MVT::i32, Expand); - setOperationAction(ISD::SELECT, MVT::f32, Expand); - setOperationAction(ISD::SELECT, MVT::f64, Expand); + setOperationAction(ISD::SELECT, MVT::i32, Custom); + setOperationAction(ISD::SELECT, MVT::f32, Custom); + setOperationAction(ISD::SELECT, MVT::f64, Custom); setOperationAction(ISD::SELECT_CC, MVT::i32, Custom); setOperationAction(ISD::SELECT_CC, MVT::f32, Custom); setOperationAction(ISD::SELECT_CC, MVT::f64, Custom); @@ -2314,6 +2314,52 @@ return DAG.getNode(ARMISD::FMSTAT, dl, MVT::Flag, Cmp); } +SDValue ARMTargetLowering::LowerSELECT(SDValue Op, SelectionDAG &DAG) const { + SDValue Cond = Op.getOperand(0); + SDValue SelectTrue = Op.getOperand(1); + SDValue SelectFalse = Op.getOperand(2); + DebugLoc dl = Op.getDebugLoc(); + + // Convert: + // + // (select (cmov 1, 0, cond), t, f) -> (cmov t, f, cond) + // (select (cmov 0, 1, cond), t, f) -> (cmov f, t, cond) + // + if (Cond.getOpcode() == ARMISD::CMOV && Cond.hasOneUse()) { + const ConstantSDNode *CMOVTrue = + dyn_cast(Cond.getOperand(0)); + const ConstantSDNode *CMOVFalse = + dyn_cast(Cond.getOperand(1)); + + if (CMOVTrue && CMOVFalse) { + unsigned CMOVTrueVal = CMOVTrue->getZExtValue(); + unsigned CMOVFalseVal = CMOVFalse->getZExtValue(); + + SDValue True; + SDValue False; + if (CMOVTrueVal == 1 && CMOVFalseVal == 0) { + True = SelectTrue; + False = SelectFalse; + } else if (CMOVTrueVal == 0 && CMOVFalseVal == 1) { + True = SelectFalse; + False = SelectTrue; + } + + if (True.getNode() && False.getNode()) { + EVT VT = Cond.getValueType(); + SDValue ARMcc = Cond.getOperand(2); + SDValue CCR = Cond.getOperand(3); + SDValue Cmp = Cond.getOperand(4); + return DAG.getNode(ARMISD::CMOV, dl, VT, True, False, ARMcc, CCR, Cmp); + } + } + } + + return DAG.getSelectCC(dl, Cond, + DAG.getConstant(0, Cond.getValueType()), + SelectTrue, SelectFalse, ISD::SETNE); +} + SDValue ARMTargetLowering::LowerSELECT_CC(SDValue Op, SelectionDAG &DAG) const { EVT VT = Op.getValueType(); SDValue LHS = Op.getOperand(0); @@ -3687,6 +3733,7 @@ return Subtarget->isTargetDarwin() ? LowerGlobalAddressDarwin(Op, DAG) : LowerGlobalAddressELF(Op, DAG); case ISD::GlobalTLSAddress: return LowerGlobalTLSAddress(Op, DAG); + case ISD::SELECT: return LowerSELECT(Op, DAG); case ISD::SELECT_CC: return LowerSELECT_CC(Op, DAG); case ISD::BR_CC: return LowerBR_CC(Op, DAG); case ISD::BR_JT: return LowerBR_JT(Op, DAG); Modified: llvm/trunk/lib/Target/ARM/ARMISelLowering.h URL: http://llvm.org/viewvc/llvm-project/llvm/trunk/lib/Target/ARM/ARMISelLowering.h?rev=110799&r1=110798&r2=110799&view=diff ============================================================================== --- llvm/trunk/lib/Target/ARM/ARMISelLowering.h (original) +++ llvm/trunk/lib/Target/ARM/ARMISelLowering.h Wed Aug 11 03:43:16 2010 @@ -335,6 +335,7 @@ SelectionDAG &DAG) const; SDValue LowerGLOBAL_OFFSET_TABLE(SDValue Op, SelectionDAG &DAG) const; SDValue LowerBR_JT(SDValue Op, SelectionDAG &DAG) const; + SDValue LowerSELECT(SDValue Op, SelectionDAG &DAG) const; SDValue LowerSELECT_CC(SDValue Op, SelectionDAG &DAG) const; SDValue LowerBR_CC(SDValue Op, SelectionDAG &DAG) const; SDValue LowerFCOPYSIGN(SDValue Op, SelectionDAG &DAG) const; Modified: llvm/trunk/test/CodeGen/ARM/select.ll URL: http://llvm.org/viewvc/llvm-project/llvm/trunk/test/CodeGen/ARM/select.ll?rev=110799&r1=110798&r2=110799&view=diff ============================================================================== --- llvm/trunk/test/CodeGen/ARM/select.ll (original) +++ llvm/trunk/test/CodeGen/ARM/select.ll Wed Aug 11 03:43:16 2010 @@ -1,5 +1,6 @@ ; RUN: llc < %s -march=arm | FileCheck %s ; RUN: llc < %s -march=arm -mattr=+vfp2 | FileCheck %s --check-prefix=CHECK-VFP +; RUN: llc < %s -mattr=+neon,+thumb2 -mtriple=thumbv7-apple-darwin | FileCheck %s --check-prefix=CHECK-NEON define i32 @f1(i32 %a.s) { ;CHECK: f1: @@ -65,3 +66,27 @@ %tmp1 = select i1 %tmp, double -1.000e+00, double %b ret double %tmp1 } + +; +; +; We used to generate really horrible code for this function. The main cause was +; a lack of a custom lowering routine for an ISD::SELECT. This would result in +; two "it" blocks in the code: one for the "icmp" and another to move the index +; into the constant pool based on the value of the "icmp". If we have one "it" +; block generated, odds are good that we have close to the ideal code for this: +; +; CHECK-NEON: _f8: +; CHECK-NEON: movw [[REGISTER_1:r[0-9]+]], #1123 +; CHECK-NEON-NEXT: movs [[REGISTER_2:r[0-9]+]], #0 +; CHECK-NEON-NEXT: cmp r0, [[REGISTER_1]] +; CHECK-NEON-NEXT: adr [[REGISTER_3:r[0-9]+]], #LCPI +; CHECK-NEON-NEXT: it eq +; CHECK-NEON-NEXT: moveq [[REGISTER_2]], #4 +; CHECK-NEON-NEXT: ldr +; CHECK-NEON: bx + +define arm_apcscc float @f8(i32 %a) nounwind { + %tmp = icmp eq i32 %a, 1123 + %tmp1 = select i1 %tmp, float 0x3FF3BE76C0000000, float 0x40030E9A20000000 + ret float %tmp1 +} From isanbard at gmail.com Wed Aug 11 04:36:48 2010 From: isanbard at gmail.com (Bill Wendling) Date: Wed, 11 Aug 2010 09:36:48 -0000 Subject: [llvm-commits] [llvm-gcc-4.2] r110801 - in /llvm-gcc-4.2/trunk/gcc/testsuite: g++.apple/block-5988451.C gcc.apple/block-5988451.c Message-ID: <20100811093648.29B692A6C12C@llvm.org> Author: void Date: Wed Aug 11 04:36:47 2010 New Revision: 110801 URL: http://llvm.org/viewvc/llvm-project?rev=110801&view=rev Log: Update testcases. Modified: llvm-gcc-4.2/trunk/gcc/testsuite/g++.apple/block-5988451.C llvm-gcc-4.2/trunk/gcc/testsuite/gcc.apple/block-5988451.c Modified: llvm-gcc-4.2/trunk/gcc/testsuite/g++.apple/block-5988451.C URL: http://llvm.org/viewvc/llvm-project/llvm-gcc-4.2/trunk/gcc/testsuite/g%2B%2B.apple/block-5988451.C?rev=110801&r1=110800&r2=110801&view=diff ============================================================================== --- llvm-gcc-4.2/trunk/gcc/testsuite/g++.apple/block-5988451.C (original) +++ llvm-gcc-4.2/trunk/gcc/testsuite/g++.apple/block-5988451.C Wed Aug 11 04:36:47 2010 @@ -11,8 +11,8 @@ dispatch_legacy_block_t completion); void dispatch_apply_wait(dispatch_legacy_block_t work, - unsigned iterations, - void *context); + unsigned iterations, + void *context); @@ -37,7 +37,7 @@ }, 10,NULL); }, - ^(dispatch_item_t item) {NSLog(@"test");}); /* { dg-warning "deprecated" } */ + ^(dispatch_item_t item) {NSLog(@"test");}); } Modified: llvm-gcc-4.2/trunk/gcc/testsuite/gcc.apple/block-5988451.c URL: http://llvm.org/viewvc/llvm-project/llvm-gcc-4.2/trunk/gcc/testsuite/gcc.apple/block-5988451.c?rev=110801&r1=110800&r2=110801&view=diff ============================================================================== --- llvm-gcc-4.2/trunk/gcc/testsuite/gcc.apple/block-5988451.c (original) +++ llvm-gcc-4.2/trunk/gcc/testsuite/gcc.apple/block-5988451.c Wed Aug 11 04:36:47 2010 @@ -6,9 +6,9 @@ typedef struct dispatch_queue_s *dispatch_queue_t; typedef struct dispatch_item_s *dispatch_item_t; -void dispatch_call(dispatch_queue_t queue, - dispatch_legacy_block_t work, - dispatch_legacy_block_t completion); +dispatch_item_t dispatch_call(dispatch_queue_t queue, + dispatch_legacy_block_t work, + dispatch_legacy_block_t completion); void dispatch_apply_wait(dispatch_legacy_block_t work, unsigned iterations, @@ -37,7 +37,7 @@ }, 10,NULL); }, - ^(dispatch_item_t item) {NSLog(@"test");}); /* { dg-warning "deprecated" } */ + ^(dispatch_item_t item) {NSLog(@"test");}); } From isanbard at gmail.com Wed Aug 11 04:54:36 2010 From: isanbard at gmail.com (Bill Wendling) Date: Wed, 11 Aug 2010 09:54:36 -0000 Subject: [llvm-commits] [llvm-gcc-4.2] r110802 - in /llvm-gcc-4.2/trunk/gcc/testsuite: g++.apple/pubtypes.C gcc.apple/pubtypes-1.c gcc.apple/pubtypes-2.c gcc.apple/pubtypes-3.c gcc.apple/pubtypes-4.c Message-ID: <20100811095436.4F6F12A6C12C@llvm.org> Author: void Date: Wed Aug 11 04:54:36 2010 New Revision: 110802 URL: http://llvm.org/viewvc/llvm-project?rev=110802&view=rev Log: Update to catch some inconsequential asm output. Modified: llvm-gcc-4.2/trunk/gcc/testsuite/g++.apple/pubtypes.C llvm-gcc-4.2/trunk/gcc/testsuite/gcc.apple/pubtypes-1.c llvm-gcc-4.2/trunk/gcc/testsuite/gcc.apple/pubtypes-2.c llvm-gcc-4.2/trunk/gcc/testsuite/gcc.apple/pubtypes-3.c llvm-gcc-4.2/trunk/gcc/testsuite/gcc.apple/pubtypes-4.c Modified: llvm-gcc-4.2/trunk/gcc/testsuite/g++.apple/pubtypes.C URL: http://llvm.org/viewvc/llvm-project/llvm-gcc-4.2/trunk/gcc/testsuite/g%2B%2B.apple/pubtypes.C?rev=110802&r1=110801&r2=110802&view=diff ============================================================================== --- llvm-gcc-4.2/trunk/gcc/testsuite/g++.apple/pubtypes.C (original) +++ llvm-gcc-4.2/trunk/gcc/testsuite/g++.apple/pubtypes.C Wed Aug 11 04:54:36 2010 @@ -4,7 +4,9 @@ /* { dg-options "-O0 -gdwarf-2 -dA -fverbose-asm -fno-eliminate-unused-debug-types" } */ /* { dg-final { scan-assembler "__debug_pubtypes" } } */ /* APPLE LOCAL begin ARM assembler uses @ for comments */ -/* { dg-final { scan-assembler "long+\[ \t\]+\(0x\)?\[0-9a-f]+\[ \t\n\]+\[#;@]+\[ \t\]+Length of Public Type Names Info" } } */ +/* LLVM LOCAL begin - Adjust for different (but apparently correct) output */ +/* { dg-final { scan-assembler "Lset\[0-9]+\[ \t]+=\[ \t]+Lpubtypes_end\[0-9]+-Lpubtypes_begin\[0-9]+\[ \t]+\[#;@]\[ \t]+Length of Public Types Info" } } */ +/* LLVM LOCAL end */ /* { dg-final { scan-assembler "\"empty\\\\0\"+\[ \t\]+\[#;@]+\[ \t\]+external name" } } */ /* { dg-final { scan-assembler "\"A\\\\0\"+\[ \t\]+\[#;@]+\[ \t\]+external name" } } */ /* { dg-final { scan-assembler "\"B\\\\0\"+\[ \t\]+\[#;@]+\[ \t\]+external name" } } */ Modified: llvm-gcc-4.2/trunk/gcc/testsuite/gcc.apple/pubtypes-1.c URL: http://llvm.org/viewvc/llvm-project/llvm-gcc-4.2/trunk/gcc/testsuite/gcc.apple/pubtypes-1.c?rev=110802&r1=110801&r2=110802&view=diff ============================================================================== --- llvm-gcc-4.2/trunk/gcc/testsuite/gcc.apple/pubtypes-1.c (original) +++ llvm-gcc-4.2/trunk/gcc/testsuite/gcc.apple/pubtypes-1.c Wed Aug 11 04:54:36 2010 @@ -1,10 +1,13 @@ /* Radar 4535968 */ /* { dg-do compile { target *-*-darwin* } } */ -/* { dg-options "-O0 -gdwarf-2 -dA -fno-eliminate-unused-debug-types" } */ +/* LLVM LOCAL -fverbose-asm */ +/* { dg-options "-O0 -gdwarf-2 -dA -fverbose-asm -fno-eliminate-unused-debug-types" } */ /* { dg-skip-if "Unmatchable assembly" { mmix-*-* } { "*" } { "" } } */ /* { dg-final { scan-assembler "__debug_pubtypes" } } */ /* APPLE LOCAL begin ARM assembler uses @ for comments */ -/* { dg-final { scan-assembler "long\[ \t]+\(0x\)?\[0-9a-f]+\[ \t\n]+\[#;@]\[ \t]+Length of Public Type Names Info" } } */ +/* LLVM LOCAL begin - Adjust for different (but apparently correct) output */ +/* { dg-final { scan-assembler "Lset\[0-9]+\[ \t]+=\[ \t]+Lpubtypes_end\[0-9]+-Lpubtypes_begin\[0-9]+\[ \t]+\[#;@]\[ \t]+Length of Public Types Info" } } */ +/* LLVM LOCAL end */ /* { dg-final { scan-assembler "used_struct\\\\0\"\[ \t]+\[#;@]\[ \t]+external name" } } */ /* { dg-final { scan-assembler "unused_struct\\\\0\"\[ \t]+\[#;@]\[ \t]+external name" } } */ /* APPLE LOCAL end ARM assembler uses @ for comments */ Modified: llvm-gcc-4.2/trunk/gcc/testsuite/gcc.apple/pubtypes-2.c URL: http://llvm.org/viewvc/llvm-project/llvm-gcc-4.2/trunk/gcc/testsuite/gcc.apple/pubtypes-2.c?rev=110802&r1=110801&r2=110802&view=diff ============================================================================== --- llvm-gcc-4.2/trunk/gcc/testsuite/gcc.apple/pubtypes-2.c (original) +++ llvm-gcc-4.2/trunk/gcc/testsuite/gcc.apple/pubtypes-2.c Wed Aug 11 04:54:36 2010 @@ -1,10 +1,12 @@ /* Radar 4535968 */ /* { dg-do compile { target *-*-darwin* } } */ -/* { dg-options "-O0 -gdwarf-2 -dA" } */ +/* { dg-options "-O0 -gdwarf-2 -dA -fverbose-asm" } */ /* { dg-skip-if "Unmatchable assembly" { mmix-*-* } { "*" } { "" } } */ /* { dg-final { scan-assembler "__debug_pubtypes" } } */ /* APPLE LOCAL begin ARM assembler uses @ for comments */ -/* { dg-final { scan-assembler "long\[ \t]+\(0x6a|106\)+\[ \t\n]+\[#;@]\[ \t]+Length of Public Type Names Info" } } */ +/* LLVM LOCAL begin - Adjust for different (but apparently correct) output */ +/* { dg-final { scan-assembler "Lset\[0-9]+\[ \t]+=\[ \t]+Lpubtypes_end\[0-9]+-Lpubtypes_begin\[0-9]+\[ \t]+\[#;@]\[ \t]+Length of Public Types Info" } } */ +/* LLVM LOCAL end */ /* { dg-final { scan-assembler "used_struct\\\\0\"\[ \t]+\[#;@]\[ \t\]+external name" } } */ /* { dg-final { scan-assembler-not "unused_struct\\\\0\"\[ \t]+\[#;@]\[ \t]+external name" } } */ /* APPLE LOCAL end ARM assembler uses @ for comments */ Modified: llvm-gcc-4.2/trunk/gcc/testsuite/gcc.apple/pubtypes-3.c URL: http://llvm.org/viewvc/llvm-project/llvm-gcc-4.2/trunk/gcc/testsuite/gcc.apple/pubtypes-3.c?rev=110802&r1=110801&r2=110802&view=diff ============================================================================== --- llvm-gcc-4.2/trunk/gcc/testsuite/gcc.apple/pubtypes-3.c (original) +++ llvm-gcc-4.2/trunk/gcc/testsuite/gcc.apple/pubtypes-3.c Wed Aug 11 04:54:36 2010 @@ -1,10 +1,13 @@ /* Radar 4535968 */ /* { dg-do compile { target *-*-darwin* } } */ -/* { dg-options "-O0 -gdwarf-2 -dA" } */ +/* LLVM LOCAL -fverbose-asm */ +/* { dg-options "-O0 -gdwarf-2 -dA -fverbose-asm" } */ /* { dg-skip-if "Unmatchable assembly" { mmix-*-* } { "*" } { "" } } */ /* { dg-final { scan-assembler "__debug_pubtypes" } } */ /* APPLE LOCAL begin ARM assembler uses @ for comments */ -/* { dg-final { scan-assembler "long\[ \t]+\(0x6a|106\)+\[ \t\n]+\[#;@]\[ \t\]+Length of Public Type Names Info" } } */ +/* LLVM LOCAL begin - Adjust for different (but apparently correct) output */ +/* { dg-final { scan-assembler "Lset\[0-9]+\[ \t]+=\[ \t]+Lpubtypes_end\[0-9]+-Lpubtypes_begin\[0-9]+\[ \t]+\[#;@]\[ \t]+Length of Public Types Info" } } */ +/* LLVM LOCAL end */ /* { dg-final { scan-assembler "used_struct\\\\0\"\[ \t]+\[#;@]\[ \t]+external name" } } */ /* { dg-final { scan-assembler-not "unused_struct\\\\0\"\[ \t]+\[#;@]\[ \t]+external name" } } */ /* { dg-final { scan-assembler-not "\"list_name_type\\\\0\"\[ \t]+\[#;@]\[ \t]+external name" } } */ Modified: llvm-gcc-4.2/trunk/gcc/testsuite/gcc.apple/pubtypes-4.c URL: http://llvm.org/viewvc/llvm-project/llvm-gcc-4.2/trunk/gcc/testsuite/gcc.apple/pubtypes-4.c?rev=110802&r1=110801&r2=110802&view=diff ============================================================================== --- llvm-gcc-4.2/trunk/gcc/testsuite/gcc.apple/pubtypes-4.c (original) +++ llvm-gcc-4.2/trunk/gcc/testsuite/gcc.apple/pubtypes-4.c Wed Aug 11 04:54:36 2010 @@ -1,6 +1,7 @@ /* Radar 4535968 */ /* { dg-do compile { target *-*-darwin* } } */ -/* { dg-options "-O0 -gdwarf-2 -dA" } */ +/* LLVM LOCAL -fverbose-asm */ +/* { dg-options "-O0 -gdwarf-2 -dA -fverbose-asm" } */ /* { dg-skip-if "Unmatchable assembly" { mmix-*-* } { "*" } { "" } } */ #include @@ -91,7 +92,9 @@ /* { dg-final { scan-assembler "__debug_pubtypes" } } */ /* APPLE LOCAL begin ARM assembler uses @ for comments */ -/* { dg-final { scan-assembler "long\[ \t]+\(0xa1|161\)+\[ \t\n]+\[#;@]\[ \t]+Length of Public Type Names Info" } } */ +/* LLVM LOCAL begin - Adjust for different (but apparently correct) output */ +/* { dg-final { scan-assembler "Lset\[0-9]+\[ \t]+=\[ \t]+Lpubtypes_end\[0-9]+-Lpubtypes_begin\[0-9]+\[ \t]+\[#;@]\[ \t]+Length of Public Types Info" } } */ +/* LLVM LOCAL end */ /* { dg-final { scan-assembler "used_struct\\\\0\"\[ \t]+\[#;@]\[ \t]+external name" } } */ /* { dg-final { scan-assembler-not "unused_struct\\\\0\"\[ \t]+\[#;@]\[ \t]+external name" } } */ /* { dg-final { scan-assembler "\"list_name_type\\\\0\"\[ \t]+\[#;@]\[ \t]+external name" } } */ From baldrick at free.fr Wed Aug 11 04:58:20 2010 From: baldrick at free.fr (Duncan Sands) Date: Wed, 11 Aug 2010 11:58:20 +0200 Subject: [llvm-commits] [llvm-gcc-4.2] r110632 - /llvm-gcc-4.2/trunk/gcc/llvm-convert.cpp In-Reply-To: <20100810001113.BF9CC2A6C12C@llvm.org> References: <20100810001113.BF9CC2A6C12C@llvm.org> Message-ID: <4C62743C.7070409@free.fr> Hi Bob, > Change EmitASM_EXPR to record the original type of an asm input, before the > special case of treating small structs and unions as integers. If the > operand has a matching constraint and it is tied to one of the outputs > (for which small aggregates are not treated as integers), use that original > type to compare against the output operand. Radar 8288710. testcase? Ciao, Duncan. From Kalle.Raiskila at nokia.com Wed Aug 11 06:19:44 2010 From: Kalle.Raiskila at nokia.com (Kalle.Raiskila at nokia.com) Date: Wed, 11 Aug 2010 13:19:44 +0200 Subject: [llvm-commits] [llvm] r110576 - in /llvm/trunk: lib/Target/CellSPU/SPUISelLowering.cpp lib/Target/CellSPU/SPUISelLowering.h lib/Target/CellSPU/SPUInstrInfo.td lib/Target/CellSPU/SPUNodes.td lib/Target/CellSPU/SPURegisterInfo.cpp test/CodeGen/CellSP... In-Reply-To: References: <20100809163301.235462A6C12C@llvm.org> <25685170-45BA-47F0-AF9D-0D0600748145@apple.com> <1281437591.1796.146.camel@LLVMbuilder.research.nokia.com> Message-ID: <1281525584.1870.13.camel@LLVMbuilder.research.nokia.com> On Tue, 2010-08-10 at 19:12 +0200, Bob Wilson wrote: > On Aug 10, 2010, at 3:53 AM, Kalle.Raiskila at nokia.com wrote: > > b) to the best of my understanding, v2i32 has to be legal if it is to be > > used in return values and function parameters. > > The types of return values and function parameters are also legalized. If you pass an argument with a non-legal type, it should be promoted or expanded to make it legal. The problem here was that v2i32 gets expanded to two i32s instead of promoted to one v4i32. Is it possible to force promotion somehow? > > But, if your target doesn't have any scalar > 32-bit registers, passing i32 arguments is going to be a pretty > "interesting" regardless.... This is indeed the case. SPU's native wordlength is 32, but all general purpose registers are 4-way vectors (128bit). And all instructions are SIMD vector instructions. Where i32s are needed (e.g. memory address) only the first slot of the vector register is used. This is the way i32s are "emulated" in the SPU backend. And this is how I tried to "emulate" v2i32s too. "Interesting", eih? :) kalle From Kalle.Raiskila at nokia.com Wed Aug 11 07:02:17 2010 From: Kalle.Raiskila at nokia.com (Kalle.Raiskila at nokia.com) Date: Wed, 11 Aug 2010 14:02:17 +0200 Subject: [llvm-commits] [llvm] r110576 - in /llvm/trunk: lib/Target/CellSPU/SPUISelLowering.cpp lib/Target/CellSPU/SPUISelLowering.h lib/Target/CellSPU/SPUInstrInfo.td lib/Target/CellSPU/SPUNodes.td lib/Target/CellSPU/SPURegisterInfo.cpp test/CodeGen/CellSP... In-Reply-To: References: <20100809163301.235462A6C12C@llvm.org> <25685170-45BA-47F0-AF9D-0D0600748145@apple.com> <1281437591.1796.146.camel@LLVMbuilder.research.nokia.com> Message-ID: <1281528137.1870.56.camel@LLVMbuilder.research.nokia.com> On Wed, 2010-08-11 at 02:11 +0200, Chris Lattner wrote: > On Aug 10, 2010, at 3:53 AM, Kalle.Raiskila at nokia.com wrote: > > The reason it is legal > > (currently, in the SPU backend) is that > > a) it was like that when I found it :) > > I think that this is the root of the issue, and stems back to when > legalize was much less mature. I think that fixing this bug is really > the best path forward. Ok, I'll have a look. Just removing the v2i32 code from the SPU backend is simple. Getting it to be promoted instead of expanded... lets see... I wonder if I should have a go at trying to get i32 promoted to v4i32 at the same time :) > > b) to the best of my understanding, v2i32 has to be legal if it is to be > > used in return values and function parameters. > > Beyond Bob's post of "it should work", this is something that can > easily be handled by the frontend (by having the frontend lower v2i32 > arg/ret values into v4i32 values with shufflevector to extract). This > is how the X86-64 backend handles its often-crazy ABI constraints. Certainly, when strict ABI compliance is required the frontend should do this lowering. However, not asserting on code that uses LLVM native types (including v2i32) would be nice. Especially as v2i32 is so easily mapped to v4i32. kalle From gohman at apple.com Wed Aug 11 10:09:00 2010 From: gohman at apple.com (Dan Gohman) Date: Wed, 11 Aug 2010 15:09:00 -0000 Subject: [llvm-commits] [llvm] r110808 - /llvm/trunk/test/CodeGen/Thumb/barrier.ll Message-ID: <20100811150900.4F3462A6C12C@llvm.org> Author: djg Date: Wed Aug 11 10:09:00 2010 New Revision: 110808 URL: http://llvm.org/viewvc/llvm-project?rev=110808&view=rev Log: Temporarily disable some failing tests, until they can be properly investigated. Modified: llvm/trunk/test/CodeGen/Thumb/barrier.ll Modified: llvm/trunk/test/CodeGen/Thumb/barrier.ll URL: http://llvm.org/viewvc/llvm-project/llvm/trunk/test/CodeGen/Thumb/barrier.ll?rev=110808&r1=110807&r2=110808&view=diff ============================================================================== --- llvm/trunk/test/CodeGen/Thumb/barrier.ll (original) +++ llvm/trunk/test/CodeGen/Thumb/barrier.ll Wed Aug 11 10:09:00 2010 @@ -5,7 +5,7 @@ define void @t1() { ; V6: t1: -; V6: blx {{_*}}sync_synchronize +; V6_TEMPORARILY_DISABLED: blx {{_*}}sync_synchronize ; V6M: t1: ; V6M: dsb @@ -15,7 +15,7 @@ define void @t2() { ; V6: t2: -; V6: blx {{_*}}sync_synchronize +; V6_TEMPORARILY_DISABLED: blx {{_*}}sync_synchronize ; V6M: t2: ; V6M: dmb From grosbach at apple.com Wed Aug 11 10:44:15 2010 From: grosbach at apple.com (Jim Grosbach) Date: Wed, 11 Aug 2010 15:44:15 -0000 Subject: [llvm-commits] [llvm] r110810 - in /llvm/trunk: lib/Target/ARM/ARM.td lib/Target/ARM/ARMISelLowering.cpp lib/Target/ARM/ARMSubtarget.cpp lib/Target/ARM/ARMSubtarget.h test/CodeGen/Thumb2/cortex-fp.ll Message-ID: <20100811154415.6F4E72A6C12C@llvm.org> Author: grosbach Date: Wed Aug 11 10:44:15 2010 New Revision: 110810 URL: http://llvm.org/viewvc/llvm-project?rev=110810&view=rev Log: cortex m4 has floating point support, but only single precision. Added: llvm/trunk/test/CodeGen/Thumb2/cortex-fp.ll Modified: llvm/trunk/lib/Target/ARM/ARM.td llvm/trunk/lib/Target/ARM/ARMISelLowering.cpp llvm/trunk/lib/Target/ARM/ARMSubtarget.cpp llvm/trunk/lib/Target/ARM/ARMSubtarget.h Modified: llvm/trunk/lib/Target/ARM/ARM.td URL: http://llvm.org/viewvc/llvm-project/llvm/trunk/lib/Target/ARM/ARM.td?rev=110810&r1=110809&r2=110810&view=diff ============================================================================== --- llvm/trunk/lib/Target/ARM/ARM.td (original) +++ llvm/trunk/lib/Target/ARM/ARM.td Wed Aug 11 10:44:15 2010 @@ -40,6 +40,8 @@ "Has data barrier (dmb / dsb) instructions">; def FeatureSlowFPBrcc : SubtargetFeature<"slow-fp-brcc", "SlowFPBrcc", "true", "FP compare + branch is slow">; +def FeatureVFPOnlySP : SubtargetFeature<"fp-only-sp", "FPOnlySP", "true", + "Floating point unit supports single precision only">; // Some processors have multiply-accumulate instructions that don't // play nicely with other VFP instructions, and it's generally better @@ -155,7 +157,7 @@ // V7M Processors. def : ProcNoItin<"cortex-m3", [ArchV7M]>; -def : ProcNoItin<"cortex-m4", [ArchV7M]>; +def : ProcNoItin<"cortex-m4", [ArchV7M, FeatureVFP2, FeatureVFPOnlySP]>; //===----------------------------------------------------------------------===// // Register File Description Modified: llvm/trunk/lib/Target/ARM/ARMISelLowering.cpp URL: http://llvm.org/viewvc/llvm-project/llvm/trunk/lib/Target/ARM/ARMISelLowering.cpp?rev=110810&r1=110809&r2=110810&view=diff ============================================================================== --- llvm/trunk/lib/Target/ARM/ARMISelLowering.cpp (original) +++ llvm/trunk/lib/Target/ARM/ARMISelLowering.cpp Wed Aug 11 10:44:15 2010 @@ -266,7 +266,8 @@ addRegisterClass(MVT::i32, ARM::GPRRegisterClass); if (!UseSoftFloat && Subtarget->hasVFP2() && !Subtarget->isThumb1Only()) { addRegisterClass(MVT::f32, ARM::SPRRegisterClass); - addRegisterClass(MVT::f64, ARM::DPRRegisterClass); + if (!Subtarget->isFPOnlySP()) + addRegisterClass(MVT::f64, ARM::DPRRegisterClass); setTruncStoreAction(MVT::f64, MVT::f32, Expand); } Modified: llvm/trunk/lib/Target/ARM/ARMSubtarget.cpp URL: http://llvm.org/viewvc/llvm-project/llvm/trunk/lib/Target/ARM/ARMSubtarget.cpp?rev=110810&r1=110809&r2=110810&view=diff ============================================================================== --- llvm/trunk/lib/Target/ARM/ARMSubtarget.cpp (original) +++ llvm/trunk/lib/Target/ARM/ARMSubtarget.cpp Wed Aug 11 10:44:15 2010 @@ -45,6 +45,7 @@ , HasT2ExtractPack(false) , HasDataBarrier(false) , Pref32BitThumb(false) + , FPOnlySP(false) , stackAlignment(4) , CPUString("generic") , TargetType(isELF) // Default to ELF unless otherwise specified. Modified: llvm/trunk/lib/Target/ARM/ARMSubtarget.h URL: http://llvm.org/viewvc/llvm-project/llvm/trunk/lib/Target/ARM/ARMSubtarget.h?rev=110810&r1=110809&r2=110810&view=diff ============================================================================== --- llvm/trunk/lib/Target/ARM/ARMSubtarget.h (original) +++ llvm/trunk/lib/Target/ARM/ARMSubtarget.h Wed Aug 11 10:44:15 2010 @@ -95,6 +95,10 @@ /// over 16-bit ones. bool Pref32BitThumb; + /// FPOnlySP - If true, the floating point unit only supports single + /// precision. + bool FPOnlySP; + /// stackAlignment - The minimum alignment known to hold of the stack frame on /// entry to the function and which must be maintained by every function. unsigned stackAlignment; @@ -151,6 +155,7 @@ bool hasDataBarrier() const { return HasDataBarrier; } bool useVMLx() const {return hasVFP2() && !SlowVMLx; } bool isFPBrccSlow() const { return SlowFPBrcc; } + bool isFPOnlySP() const { return FPOnlySP; } bool prefers32BitThumb() const { return Pref32BitThumb; } bool hasFP16() const { return HasFP16; } Added: llvm/trunk/test/CodeGen/Thumb2/cortex-fp.ll URL: http://llvm.org/viewvc/llvm-project/llvm/trunk/test/CodeGen/Thumb2/cortex-fp.ll?rev=110810&view=auto ============================================================================== --- llvm/trunk/test/CodeGen/Thumb2/cortex-fp.ll (added) +++ llvm/trunk/test/CodeGen/Thumb2/cortex-fp.ll Wed Aug 11 10:44:15 2010 @@ -0,0 +1,24 @@ +; RUN: llc < %s -march=thumb -mcpu=cortex-m3 | FileCheck %s -check-prefix=CORTEXM3 +; RUN: llc < %s -march=thumb -mcpu=cortex-m4 | FileCheck %s -check-prefix=CORTEXM4 +; RUN: llc < %s -march=thumb -mcpu=cortex-a8 | FileCheck %s -check-prefix=CORTEXA8 + + +define float @foo(float %a, float %b) { +entry: +; CHECK: foo +; CORTEXM3: blx ___mulsf3 +; CORTEXM4: vmul.f32 s0, s1, s0 +; CORTEXA8: vmul.f32 d0, d1, d0 + %0 = fmul float %a, %b + ret float %0 +} + +define double @bar(double %a, double %b) { +entry: +; CHECK: bar + %0 = fmul double %a, %b +; CORTEXM3: blx ___muldf3 +; CORTEXM4: blx ___muldf3 +; CORTEXA8: vmul.f64 d0, d1, d0 + ret double %0 +} From gohman at apple.com Wed Aug 11 11:36:07 2010 From: gohman at apple.com (Dan Gohman) Date: Wed, 11 Aug 2010 16:36:07 -0000 Subject: [llvm-commits] [llvm] r110825 - /llvm/trunk/test/CodeGen/Thumb2/cortex-fp.ll Message-ID: <20100811163607.797762A6C12C@llvm.org> Author: djg Date: Wed Aug 11 11:36:07 2010 New Revision: 110825 URL: http://llvm.org/viewvc/llvm-project?rev=110825&view=rev Log: Temporarily disable some failing tests, until they can be properly investigated. Modified: llvm/trunk/test/CodeGen/Thumb2/cortex-fp.ll Modified: llvm/trunk/test/CodeGen/Thumb2/cortex-fp.ll URL: http://llvm.org/viewvc/llvm-project/llvm/trunk/test/CodeGen/Thumb2/cortex-fp.ll?rev=110825&r1=110824&r2=110825&view=diff ============================================================================== --- llvm/trunk/test/CodeGen/Thumb2/cortex-fp.ll (original) +++ llvm/trunk/test/CodeGen/Thumb2/cortex-fp.ll Wed Aug 11 11:36:07 2010 @@ -1,5 +1,5 @@ -; RUN: llc < %s -march=thumb -mcpu=cortex-m3 | FileCheck %s -check-prefix=CORTEXM3 -; RUN: llc < %s -march=thumb -mcpu=cortex-m4 | FileCheck %s -check-prefix=CORTEXM4 +; RUN_TEMPORARILY_DISABLED: llc < %s -march=thumb -mcpu=cortex-m3 | FileCheck %s -check-prefix=CORTEXM3 +; RUN_TEMPORARILY_DISABLED: llc < %s -march=thumb -mcpu=cortex-m4 | FileCheck %s -check-prefix=CORTEXM4 ; RUN: llc < %s -march=thumb -mcpu=cortex-a8 | FileCheck %s -check-prefix=CORTEXA8 From stoklund at 2pi.dk Wed Aug 11 11:50:17 2010 From: stoklund at 2pi.dk (Jakob Stoklund Olesen) Date: Wed, 11 Aug 2010 16:50:17 -0000 Subject: [llvm-commits] [llvm] r110826 - in /llvm/trunk: include/llvm/CodeGen/SlotIndexes.h lib/CodeGen/RenderMachineFunction.cpp Message-ID: <20100811165017.D31392A6C12C@llvm.org> Author: stoklund Date: Wed Aug 11 11:50:17 2010 New Revision: 110826 URL: http://llvm.org/viewvc/llvm-project?rev=110826&view=rev Log: Fix a FIXME. The SlotIndex::Slot enum should be private. Modified: llvm/trunk/include/llvm/CodeGen/SlotIndexes.h llvm/trunk/lib/CodeGen/RenderMachineFunction.cpp Modified: llvm/trunk/include/llvm/CodeGen/SlotIndexes.h URL: http://llvm.org/viewvc/llvm-project/llvm/trunk/include/llvm/CodeGen/SlotIndexes.h?rev=110826&r1=110825&r2=110826&view=diff ============================================================================== --- llvm/trunk/include/llvm/CodeGen/SlotIndexes.h (original) +++ llvm/trunk/include/llvm/CodeGen/SlotIndexes.h Wed Aug 11 11:50:17 2010 @@ -128,7 +128,8 @@ friend class SlotIndexes; friend struct DenseMapInfo; - private: + enum Slot { LOAD, USE, DEF, STORE, NUM }; + static const unsigned PHI_BIT = 1 << 2; PointerIntPair lie; @@ -146,6 +147,11 @@ return entry().getIndex() | getSlot(); } + /// Returns the slot for this SlotIndex. + Slot getSlot() const { + return static_cast(lie.getInt() & ~PHI_BIT); + } + static inline unsigned getHashValue(const SlotIndex &v) { IndexListEntry *ptrVal = &v.entry(); return (unsigned((intptr_t)ptrVal) >> 4) ^ @@ -153,11 +159,6 @@ } public: - - // FIXME: Ugh. This is public because LiveIntervalAnalysis is still using it - // for some spill weight stuff. Fix that, then make this private. - enum Slot { LOAD, USE, DEF, STORE, NUM }; - static inline SlotIndex getEmptyKey() { return SlotIndex(IndexListEntry::getEmptyKeyEntry(), 0); } @@ -235,16 +236,31 @@ return other.getIndex() - getIndex(); } - /// Returns the slot for this SlotIndex. - Slot getSlot() const { - return static_cast(lie.getInt() & ~PHI_BIT); - } - /// Returns the state of the PHI bit. bool isPHI() const { return lie.getInt() & PHI_BIT; } + /// isLoad - Return true if this is a LOAD slot. + bool isLoad() const { + return getSlot() == LOAD; + } + + /// isDef - Return true if this is a DEF slot. + bool isDef() const { + return getSlot() == DEF; + } + + /// isUse - Return true if this is a USE slot. + bool isUse() const { + return getSlot() == USE; + } + + /// isStore - Return true if this is a STORE slot. + bool isStore() const { + return getSlot() == STORE; + } + /// Returns the base index for associated with this index. The base index /// is the one associated with the LOAD slot for the instruction pointed to /// by this index. Modified: llvm/trunk/lib/CodeGen/RenderMachineFunction.cpp URL: http://llvm.org/viewvc/llvm-project/llvm/trunk/lib/CodeGen/RenderMachineFunction.cpp?rev=110826&r1=110825&r2=110826&view=diff ============================================================================== --- llvm/trunk/lib/CodeGen/RenderMachineFunction.cpp (original) +++ llvm/trunk/lib/CodeGen/RenderMachineFunction.cpp Wed Aug 11 11:50:17 2010 @@ -551,11 +551,9 @@ return AliveStack; } } else { - if (i.getSlot() == SlotIndex::DEF && - mi->definesRegister(li->reg, tri)) { + if (i.isDef() && mi->definesRegister(li->reg, tri)) { return Defined; - } else if (i.getSlot() == SlotIndex::USE && - mi->readsRegister(li->reg)) { + } else if (i.isUse() && mi->readsRegister(li->reg)) { return Used; } else { if (vrm == 0 || @@ -771,7 +769,7 @@ os << indent + s(2) << "\n"; // Render the code column. - if (i.getSlot() == SlotIndex::LOAD) { + if (i.isLoad()) { MachineBasicBlock *mbb = sis->getMBBFromIndex(i); mi = sis->getInstructionFromIndex(i); From evan.cheng at apple.com Wed Aug 11 12:25:51 2010 From: evan.cheng at apple.com (Evan Cheng) Date: Wed, 11 Aug 2010 17:25:51 -0000 Subject: [llvm-commits] [llvm] r110829 - /llvm/trunk/test/CodeGen/Thumb/barrier.ll Message-ID: <20100811172552.08D2B2A6C12C@llvm.org> Author: evancheng Date: Wed Aug 11 12:25:51 2010 New Revision: 110829 URL: http://llvm.org/viewvc/llvm-project?rev=110829&view=rev Log: Fix test and re-enable it. Modified: llvm/trunk/test/CodeGen/Thumb/barrier.ll Modified: llvm/trunk/test/CodeGen/Thumb/barrier.ll URL: http://llvm.org/viewvc/llvm-project/llvm/trunk/test/CodeGen/Thumb/barrier.ll?rev=110829&r1=110828&r2=110829&view=diff ============================================================================== --- llvm/trunk/test/CodeGen/Thumb/barrier.ll (original) +++ llvm/trunk/test/CodeGen/Thumb/barrier.ll Wed Aug 11 12:25:51 2010 @@ -1,11 +1,11 @@ -; RUN: llc < %s -march=thumb -mattr=+v6 | FileCheck %s -check-prefix=V6 -; RUN: llc < %s -march=thumb -mattr=+v6m | FileCheck %s -check-prefix=V6M +; RUN: llc < %s -mtriple=thumbv6-apple-darwin | FileCheck %s -check-prefix=V6 +; RUN: llc < %s -march=thumb -mattr=+v6m | FileCheck %s -check-prefix=V6M declare void @llvm.memory.barrier( i1 , i1 , i1 , i1 , i1 ) define void @t1() { ; V6: t1: -; V6_TEMPORARILY_DISABLED: blx {{_*}}sync_synchronize +; V6: blx {{_*}}sync_synchronize ; V6M: t1: ; V6M: dsb @@ -15,7 +15,7 @@ define void @t2() { ; V6: t2: -; V6_TEMPORARILY_DISABLED: blx {{_*}}sync_synchronize +; V6: blx {{_*}}sync_synchronize ; V6M: t2: ; V6M: dmb From bob.wilson at apple.com Wed Aug 11 12:29:57 2010 From: bob.wilson at apple.com (Bob Wilson) Date: Wed, 11 Aug 2010 10:29:57 -0700 Subject: [llvm-commits] [llvm-gcc-4.2] r110632 - /llvm-gcc-4.2/trunk/gcc/llvm-convert.cpp In-Reply-To: <4C62743C.7070409@free.fr> References: <20100810001113.BF9CC2A6C12C@llvm.org> <4C62743C.7070409@free.fr> Message-ID: <56FBB8EF-6D66-4BA8-933B-E039065DCC03@apple.com> On Aug 11, 2010, at 2:58 AM, Duncan Sands wrote: > Hi Bob, > >> Change EmitASM_EXPR to record the original type of an asm input, before the >> special case of treating small structs and unions as integers. If the >> operand has a matching constraint and it is tied to one of the outputs >> (for which small aggregates are not treated as integers), use that original >> type to compare against the output operand. Radar 8288710. > > testcase? I was anticipating your request and actually created a testcase yesterday, but then I threw it away because I can't test it. We run the FrontendC tests with the host compiler, which for me is x86. I only have ARM cross compilers. The testcase is also specific to NEON. I might be able to come up with something that only requires VFP instead of NEON, but I don't know of a way to make a FrontendC test conditional on details of the target like that. From grosbach at apple.com Wed Aug 11 12:31:12 2010 From: grosbach at apple.com (Jim Grosbach) Date: Wed, 11 Aug 2010 17:31:12 -0000 Subject: [llvm-commits] [llvm] r110830 - /llvm/trunk/test/CodeGen/Thumb2/cortex-fp.ll Message-ID: <20100811173112.876A62A6C12C@llvm.org> Author: grosbach Date: Wed Aug 11 12:31:12 2010 New Revision: 110830 URL: http://llvm.org/viewvc/llvm-project?rev=110830&view=rev Log: Add a target triple, as the runtime library invocation varies a bit by platform. It's apparently "bl __muldf3" on linux, for example. Since that's not what we're checking here, it's more robust to just force a triple. We just wwant to check that the inline FP instructions are only generated on cpus that have them." Modified: llvm/trunk/test/CodeGen/Thumb2/cortex-fp.ll Modified: llvm/trunk/test/CodeGen/Thumb2/cortex-fp.ll URL: http://llvm.org/viewvc/llvm-project/llvm/trunk/test/CodeGen/Thumb2/cortex-fp.ll?rev=110830&r1=110829&r2=110830&view=diff ============================================================================== --- llvm/trunk/test/CodeGen/Thumb2/cortex-fp.ll (original) +++ llvm/trunk/test/CodeGen/Thumb2/cortex-fp.ll Wed Aug 11 12:31:12 2010 @@ -1,6 +1,6 @@ -; RUN_TEMPORARILY_DISABLED: llc < %s -march=thumb -mcpu=cortex-m3 | FileCheck %s -check-prefix=CORTEXM3 -; RUN_TEMPORARILY_DISABLED: llc < %s -march=thumb -mcpu=cortex-m4 | FileCheck %s -check-prefix=CORTEXM4 -; RUN: llc < %s -march=thumb -mcpu=cortex-a8 | FileCheck %s -check-prefix=CORTEXA8 +; RUN: llc < %s -mtriple=thumbv7-apple-darwin10 -march=thumb -mcpu=cortex-m3 | FileCheck %s -check-prefix=CORTEXM3 +; RUN: llc < %s -mtriple=thumbv7-apple-darwin10-march=thumb -mcpu=cortex-m4 | FileCheck %s -check-prefix=CORTEXM4 +; RUN: llc < %s -mtriple=thumbv7-apple-darwin10-march=thumb -mcpu=cortex-a8 | FileCheck %s -check-prefix=CORTEXA8 define float @foo(float %a, float %b) { From grosbach at apple.com Wed Aug 11 12:32:46 2010 From: grosbach at apple.com (Jim Grosbach) Date: Wed, 11 Aug 2010 17:32:46 -0000 Subject: [llvm-commits] [llvm] r110831 - /llvm/trunk/test/CodeGen/Thumb2/cortex-fp.ll Message-ID: <20100811173246.988282A6C12C@llvm.org> Author: grosbach Date: Wed Aug 11 12:32:46 2010 New Revision: 110831 URL: http://llvm.org/viewvc/llvm-project?rev=110831&view=rev Log: fix silly typo Modified: llvm/trunk/test/CodeGen/Thumb2/cortex-fp.ll Modified: llvm/trunk/test/CodeGen/Thumb2/cortex-fp.ll URL: http://llvm.org/viewvc/llvm-project/llvm/trunk/test/CodeGen/Thumb2/cortex-fp.ll?rev=110831&r1=110830&r2=110831&view=diff ============================================================================== --- llvm/trunk/test/CodeGen/Thumb2/cortex-fp.ll (original) +++ llvm/trunk/test/CodeGen/Thumb2/cortex-fp.ll Wed Aug 11 12:32:46 2010 @@ -1,6 +1,6 @@ ; RUN: llc < %s -mtriple=thumbv7-apple-darwin10 -march=thumb -mcpu=cortex-m3 | FileCheck %s -check-prefix=CORTEXM3 -; RUN: llc < %s -mtriple=thumbv7-apple-darwin10-march=thumb -mcpu=cortex-m4 | FileCheck %s -check-prefix=CORTEXM4 -; RUN: llc < %s -mtriple=thumbv7-apple-darwin10-march=thumb -mcpu=cortex-a8 | FileCheck %s -check-prefix=CORTEXA8 +; RUN: llc < %s -mtriple=thumbv7-apple-darwin10 -march=thumb -mcpu=cortex-m4 | FileCheck %s -check-prefix=CORTEXM4 +; RUN: llc < %s -mtriple=thumbv7-apple-darwin10 -march=thumb -mcpu=cortex-a8 | FileCheck %s -check-prefix=CORTEXA8 define float @foo(float %a, float %b) { From bruno.cardoso at gmail.com Wed Aug 11 12:39:23 2010 From: bruno.cardoso at gmail.com (Bruno Cardoso Lopes) Date: Wed, 11 Aug 2010 17:39:23 -0000 Subject: [llvm-commits] [llvm] r110833 - in /llvm/trunk/test/CodeGen/X86: avx-intrinsics-x86.ll avx-intrinsics-x86_64.ll Message-ID: <20100811173923.9BF702A6C12C@llvm.org> Author: bruno Date: Wed Aug 11 12:39:23 2010 New Revision: 110833 URL: http://llvm.org/viewvc/llvm-project?rev=110833&view=rev Log: Reapply r109881 using a more strict command line for llc. Added: llvm/trunk/test/CodeGen/X86/avx-intrinsics-x86.ll llvm/trunk/test/CodeGen/X86/avx-intrinsics-x86_64.ll Added: llvm/trunk/test/CodeGen/X86/avx-intrinsics-x86.ll URL: http://llvm.org/viewvc/llvm-project/llvm/trunk/test/CodeGen/X86/avx-intrinsics-x86.ll?rev=110833&view=auto ============================================================================== --- llvm/trunk/test/CodeGen/X86/avx-intrinsics-x86.ll (added) +++ llvm/trunk/test/CodeGen/X86/avx-intrinsics-x86.ll Wed Aug 11 12:39:23 2010 @@ -0,0 +1,1956 @@ +; RUN: llc < %s -mtriple=x86_64-apple-darwin -march=x86 -mcpu=corei7 -mattr=avx | FileCheck %s + +define <2 x i64> @test_x86_aesni_aesdec(<2 x i64> %a0, <2 x i64> %a1) { + ; CHECK: vaesdec + %res = call <2 x i64> @llvm.x86.aesni.aesdec(<2 x i64> %a0, <2 x i64> %a1) ; <<2 x i64>> [#uses=1] + ret <2 x i64> %res +} +declare <2 x i64> @llvm.x86.aesni.aesdec(<2 x i64>, <2 x i64>) nounwind readnone + + +define <2 x i64> @test_x86_aesni_aesdeclast(<2 x i64> %a0, <2 x i64> %a1) { + ; CHECK: vaesdeclast + %res = call <2 x i64> @llvm.x86.aesni.aesdeclast(<2 x i64> %a0, <2 x i64> %a1) ; <<2 x i64>> [#uses=1] + ret <2 x i64> %res +} +declare <2 x i64> @llvm.x86.aesni.aesdeclast(<2 x i64>, <2 x i64>) nounwind readnone + + +define <2 x i64> @test_x86_aesni_aesenc(<2 x i64> %a0, <2 x i64> %a1) { + ; CHECK: vaesenc + %res = call <2 x i64> @llvm.x86.aesni.aesenc(<2 x i64> %a0, <2 x i64> %a1) ; <<2 x i64>> [#uses=1] + ret <2 x i64> %res +} +declare <2 x i64> @llvm.x86.aesni.aesenc(<2 x i64>, <2 x i64>) nounwind readnone + + +define <2 x i64> @test_x86_aesni_aesenclast(<2 x i64> %a0, <2 x i64> %a1) { + ; CHECK: vaesenclast + %res = call <2 x i64> @llvm.x86.aesni.aesenclast(<2 x i64> %a0, <2 x i64> %a1) ; <<2 x i64>> [#uses=1] + ret <2 x i64> %res +} +declare <2 x i64> @llvm.x86.aesni.aesenclast(<2 x i64>, <2 x i64>) nounwind readnone + + +define <2 x i64> @test_x86_aesni_aesimc(<2 x i64> %a0) { + ; CHECK: vaesimc + %res = call <2 x i64> @llvm.x86.aesni.aesimc(<2 x i64> %a0) ; <<2 x i64>> [#uses=1] + ret <2 x i64> %res +} +declare <2 x i64> @llvm.x86.aesni.aesimc(<2 x i64>) nounwind readnone + + +define <2 x i64> @test_x86_aesni_aeskeygenassist(<2 x i64> %a0) { + ; CHECK: vaeskeygenassist + %res = call <2 x i64> @llvm.x86.aesni.aeskeygenassist(<2 x i64> %a0, i8 7) ; <<2 x i64>> [#uses=1] + ret <2 x i64> %res +} +declare <2 x i64> @llvm.x86.aesni.aeskeygenassist(<2 x i64>, i8) nounwind readnone + + +define <2 x double> @test_x86_sse2_add_sd(<2 x double> %a0, <2 x double> %a1) { + ; CHECK: vaddsd + %res = call <2 x double> @llvm.x86.sse2.add.sd(<2 x double> %a0, <2 x double> %a1) ; <<2 x double>> [#uses=1] + ret <2 x double> %res +} +declare <2 x double> @llvm.x86.sse2.add.sd(<2 x double>, <2 x double>) nounwind readnone + + +define <2 x double> @test_x86_sse2_cmp_pd(<2 x double> %a0, <2 x double> %a1) { + ; CHECK: vcmpordpd + %res = call <2 x double> @llvm.x86.sse2.cmp.pd(<2 x double> %a0, <2 x double> %a1, i8 7) ; <<2 x double>> [#uses=1] + ret <2 x double> %res +} +declare <2 x double> @llvm.x86.sse2.cmp.pd(<2 x double>, <2 x double>, i8) nounwind readnone + + +define <2 x double> @test_x86_sse2_cmp_sd(<2 x double> %a0, <2 x double> %a1) { + ; CHECK: vcmpordsd + %res = call <2 x double> @llvm.x86.sse2.cmp.sd(<2 x double> %a0, <2 x double> %a1, i8 7) ; <<2 x double>> [#uses=1] + ret <2 x double> %res +} +declare <2 x double> @llvm.x86.sse2.cmp.sd(<2 x double>, <2 x double>, i8) nounwind readnone + + +define i32 @test_x86_sse2_comieq_sd(<2 x double> %a0, <2 x double> %a1) { + ; CHECK: vcomisd + ; CHECK: sete + ; CHECK: movzbl + %res = call i32 @llvm.x86.sse2.comieq.sd(<2 x double> %a0, <2 x double> %a1) ; [#uses=1] + ret i32 %res +} +declare i32 @llvm.x86.sse2.comieq.sd(<2 x double>, <2 x double>) nounwind readnone + + +define i32 @test_x86_sse2_comige_sd(<2 x double> %a0, <2 x double> %a1) { + ; CHECK: vcomisd + ; CHECK: setae + ; CHECK: movzbl + %res = call i32 @llvm.x86.sse2.comige.sd(<2 x double> %a0, <2 x double> %a1) ; [#uses=1] + ret i32 %res +} +declare i32 @llvm.x86.sse2.comige.sd(<2 x double>, <2 x double>) nounwind readnone + + +define i32 @test_x86_sse2_comigt_sd(<2 x double> %a0, <2 x double> %a1) { + ; CHECK: vcomisd + ; CHECK: seta + ; CHECK: movzbl + %res = call i32 @llvm.x86.sse2.comigt.sd(<2 x double> %a0, <2 x double> %a1) ; [#uses=1] + ret i32 %res +} +declare i32 @llvm.x86.sse2.comigt.sd(<2 x double>, <2 x double>) nounwind readnone + + +define i32 @test_x86_sse2_comile_sd(<2 x double> %a0, <2 x double> %a1) { + ; CHECK: vcomisd + ; CHECK: setbe + ; CHECK: movzbl + %res = call i32 @llvm.x86.sse2.comile.sd(<2 x double> %a0, <2 x double> %a1) ; [#uses=1] + ret i32 %res +} +declare i32 @llvm.x86.sse2.comile.sd(<2 x double>, <2 x double>) nounwind readnone + + +define i32 @test_x86_sse2_comilt_sd(<2 x double> %a0, <2 x double> %a1) { + ; CHECK: vcomisd + ; CHECK: setb + ; CHECK: movzbl + %res = call i32 @llvm.x86.sse2.comilt.sd(<2 x double> %a0, <2 x double> %a1) ; [#uses=1] + ret i32 %res +} +declare i32 @llvm.x86.sse2.comilt.sd(<2 x double>, <2 x double>) nounwind readnone + + +define i32 @test_x86_sse2_comineq_sd(<2 x double> %a0, <2 x double> %a1) { + ; CHECK: vcomisd + ; CHECK: setne + ; CHECK: movzbl + %res = call i32 @llvm.x86.sse2.comineq.sd(<2 x double> %a0, <2 x double> %a1) ; [#uses=1] + ret i32 %res +} +declare i32 @llvm.x86.sse2.comineq.sd(<2 x double>, <2 x double>) nounwind readnone + + +define <2 x double> @test_x86_sse2_cvtdq2pd(<4 x i32> %a0) { + ; CHECK: vcvtdq2pd + %res = call <2 x double> @llvm.x86.sse2.cvtdq2pd(<4 x i32> %a0) ; <<2 x double>> [#uses=1] + ret <2 x double> %res +} +declare <2 x double> @llvm.x86.sse2.cvtdq2pd(<4 x i32>) nounwind readnone + + +define <4 x float> @test_x86_sse2_cvtdq2ps(<4 x i32> %a0) { + ; CHECK: vcvtdq2ps + %res = call <4 x float> @llvm.x86.sse2.cvtdq2ps(<4 x i32> %a0) ; <<4 x float>> [#uses=1] + ret <4 x float> %res +} +declare <4 x float> @llvm.x86.sse2.cvtdq2ps(<4 x i32>) nounwind readnone + + +define <4 x i32> @test_x86_sse2_cvtpd2dq(<2 x double> %a0) { + ; CHECK: vcvtpd2dq + %res = call <4 x i32> @llvm.x86.sse2.cvtpd2dq(<2 x double> %a0) ; <<4 x i32>> [#uses=1] + ret <4 x i32> %res +} +declare <4 x i32> @llvm.x86.sse2.cvtpd2dq(<2 x double>) nounwind readnone + + +define <4 x float> @test_x86_sse2_cvtpd2ps(<2 x double> %a0) { + ; CHECK: vcvtpd2ps + %res = call <4 x float> @llvm.x86.sse2.cvtpd2ps(<2 x double> %a0) ; <<4 x float>> [#uses=1] + ret <4 x float> %res +} +declare <4 x float> @llvm.x86.sse2.cvtpd2ps(<2 x double>) nounwind readnone + + +define <4 x i32> @test_x86_sse2_cvtps2dq(<4 x float> %a0) { + ; CHECK: vcvtps2dq + %res = call <4 x i32> @llvm.x86.sse2.cvtps2dq(<4 x float> %a0) ; <<4 x i32>> [#uses=1] + ret <4 x i32> %res +} +declare <4 x i32> @llvm.x86.sse2.cvtps2dq(<4 x float>) nounwind readnone + + +define <2 x double> @test_x86_sse2_cvtps2pd(<4 x float> %a0) { + ; CHECK: vcvtps2pd + %res = call <2 x double> @llvm.x86.sse2.cvtps2pd(<4 x float> %a0) ; <<2 x double>> [#uses=1] + ret <2 x double> %res +} +declare <2 x double> @llvm.x86.sse2.cvtps2pd(<4 x float>) nounwind readnone + + +define i32 @test_x86_sse2_cvtsd2si(<2 x double> %a0) { + ; CHECK: vcvtsd2si + %res = call i32 @llvm.x86.sse2.cvtsd2si(<2 x double> %a0) ; [#uses=1] + ret i32 %res +} +declare i32 @llvm.x86.sse2.cvtsd2si(<2 x double>) nounwind readnone + + +define <4 x float> @test_x86_sse2_cvtsd2ss(<4 x float> %a0, <2 x double> %a1) { + ; CHECK: vcvtsd2ss + %res = call <4 x float> @llvm.x86.sse2.cvtsd2ss(<4 x float> %a0, <2 x double> %a1) ; <<4 x float>> [#uses=1] + ret <4 x float> %res +} +declare <4 x float> @llvm.x86.sse2.cvtsd2ss(<4 x float>, <2 x double>) nounwind readnone + + +define <2 x double> @test_x86_sse2_cvtsi2sd(<2 x double> %a0) { + ; CHECK: movl + ; CHECK: vcvtsi2sd + %res = call <2 x double> @llvm.x86.sse2.cvtsi2sd(<2 x double> %a0, i32 7) ; <<2 x double>> [#uses=1] + ret <2 x double> %res +} +declare <2 x double> @llvm.x86.sse2.cvtsi2sd(<2 x double>, i32) nounwind readnone + + +define <2 x double> @test_x86_sse2_cvtss2sd(<2 x double> %a0, <4 x float> %a1) { + ; CHECK: vcvtss2sd + %res = call <2 x double> @llvm.x86.sse2.cvtss2sd(<2 x double> %a0, <4 x float> %a1) ; <<2 x double>> [#uses=1] + ret <2 x double> %res +} +declare <2 x double> @llvm.x86.sse2.cvtss2sd(<2 x double>, <4 x float>) nounwind readnone + + +define <4 x i32> @test_x86_sse2_cvttpd2dq(<2 x double> %a0) { + ; CHECK: vcvttpd2dq + %res = call <4 x i32> @llvm.x86.sse2.cvttpd2dq(<2 x double> %a0) ; <<4 x i32>> [#uses=1] + ret <4 x i32> %res +} +declare <4 x i32> @llvm.x86.sse2.cvttpd2dq(<2 x double>) nounwind readnone + + +define <4 x i32> @test_x86_sse2_cvttps2dq(<4 x float> %a0) { + ; CHECK: vcvttps2dq + %res = call <4 x i32> @llvm.x86.sse2.cvttps2dq(<4 x float> %a0) ; <<4 x i32>> [#uses=1] + ret <4 x i32> %res +} +declare <4 x i32> @llvm.x86.sse2.cvttps2dq(<4 x float>) nounwind readnone + + +define i32 @test_x86_sse2_cvttsd2si(<2 x double> %a0) { + ; CHECK: vcvttss2si + %res = call i32 @llvm.x86.sse2.cvttsd2si(<2 x double> %a0) ; [#uses=1] + ret i32 %res +} +declare i32 @llvm.x86.sse2.cvttsd2si(<2 x double>) nounwind readnone + + +define <2 x double> @test_x86_sse2_div_sd(<2 x double> %a0, <2 x double> %a1) { + ; CHECK: vdivsd + %res = call <2 x double> @llvm.x86.sse2.div.sd(<2 x double> %a0, <2 x double> %a1) ; <<2 x double>> [#uses=1] + ret <2 x double> %res +} +declare <2 x double> @llvm.x86.sse2.div.sd(<2 x double>, <2 x double>) nounwind readnone + + +define <16 x i8> @test_x86_sse2_loadu_dq(i8* %a0) { + ; CHECK: movl + ; CHECK: vmovdqu + %res = call <16 x i8> @llvm.x86.sse2.loadu.dq(i8* %a0) ; <<16 x i8>> [#uses=1] + ret <16 x i8> %res +} +declare <16 x i8> @llvm.x86.sse2.loadu.dq(i8*) nounwind readonly + + +define <2 x double> @test_x86_sse2_loadu_pd(i8* %a0) { + ; CHECK: movl + ; CHECK: vmovupd + %res = call <2 x double> @llvm.x86.sse2.loadu.pd(i8* %a0) ; <<2 x double>> [#uses=1] + ret <2 x double> %res +} +declare <2 x double> @llvm.x86.sse2.loadu.pd(i8*) nounwind readonly + + +define void @test_x86_sse2_maskmov_dqu(<16 x i8> %a0, <16 x i8> %a1, i8* %a2) { + ; CHECK: pushl + ; CHECK: movl + ; CHECK: vmaskmovdqu + ; CHECK: popl + call void @llvm.x86.sse2.maskmov.dqu(<16 x i8> %a0, <16 x i8> %a1, i8* %a2) + ret void +} +declare void @llvm.x86.sse2.maskmov.dqu(<16 x i8>, <16 x i8>, i8*) nounwind + + +define <2 x double> @test_x86_sse2_max_pd(<2 x double> %a0, <2 x double> %a1) { + ; CHECK: vmaxpd + %res = call <2 x double> @llvm.x86.sse2.max.pd(<2 x double> %a0, <2 x double> %a1) ; <<2 x double>> [#uses=1] + ret <2 x double> %res +} +declare <2 x double> @llvm.x86.sse2.max.pd(<2 x double>, <2 x double>) nounwind readnone + + +define <2 x double> @test_x86_sse2_max_sd(<2 x double> %a0, <2 x double> %a1) { + ; CHECK: vmaxsd + %res = call <2 x double> @llvm.x86.sse2.max.sd(<2 x double> %a0, <2 x double> %a1) ; <<2 x double>> [#uses=1] + ret <2 x double> %res +} +declare <2 x double> @llvm.x86.sse2.max.sd(<2 x double>, <2 x double>) nounwind readnone + + +define <2 x double> @test_x86_sse2_min_pd(<2 x double> %a0, <2 x double> %a1) { + ; CHECK: vminpd + %res = call <2 x double> @llvm.x86.sse2.min.pd(<2 x double> %a0, <2 x double> %a1) ; <<2 x double>> [#uses=1] + ret <2 x double> %res +} +declare <2 x double> @llvm.x86.sse2.min.pd(<2 x double>, <2 x double>) nounwind readnone + + +define <2 x double> @test_x86_sse2_min_sd(<2 x double> %a0, <2 x double> %a1) { + ; CHECK: vminsd + %res = call <2 x double> @llvm.x86.sse2.min.sd(<2 x double> %a0, <2 x double> %a1) ; <<2 x double>> [#uses=1] + ret <2 x double> %res +} +declare <2 x double> @llvm.x86.sse2.min.sd(<2 x double>, <2 x double>) nounwind readnone + + +define i32 @test_x86_sse2_movmsk_pd(<2 x double> %a0) { + ; CHECK: vmovmskpd + %res = call i32 @llvm.x86.sse2.movmsk.pd(<2 x double> %a0) ; [#uses=1] + ret i32 %res +} +declare i32 @llvm.x86.sse2.movmsk.pd(<2 x double>) nounwind readnone + + +define void @test_x86_sse2_movnt_dq(i8* %a0, <2 x i64> %a1) { + ; CHECK: movl + ; CHECK: vmovntdq + call void @llvm.x86.sse2.movnt.dq(i8* %a0, <2 x i64> %a1) + ret void +} +declare void @llvm.x86.sse2.movnt.dq(i8*, <2 x i64>) nounwind + + +define void @test_x86_sse2_movnt_pd(i8* %a0, <2 x double> %a1) { + ; CHECK: movl + ; CHECK: vmovntpd + call void @llvm.x86.sse2.movnt.pd(i8* %a0, <2 x double> %a1) + ret void +} +declare void @llvm.x86.sse2.movnt.pd(i8*, <2 x double>) nounwind + + +define <2 x double> @test_x86_sse2_mul_sd(<2 x double> %a0, <2 x double> %a1) { + ; CHECK: vmulsd + %res = call <2 x double> @llvm.x86.sse2.mul.sd(<2 x double> %a0, <2 x double> %a1) ; <<2 x double>> [#uses=1] + ret <2 x double> %res +} +declare <2 x double> @llvm.x86.sse2.mul.sd(<2 x double>, <2 x double>) nounwind readnone + + +define <8 x i16> @test_x86_sse2_packssdw_128(<4 x i32> %a0, <4 x i32> %a1) { + ; CHECK: vpackssdw + %res = call <8 x i16> @llvm.x86.sse2.packssdw.128(<4 x i32> %a0, <4 x i32> %a1) ; <<8 x i16>> [#uses=1] + ret <8 x i16> %res +} +declare <8 x i16> @llvm.x86.sse2.packssdw.128(<4 x i32>, <4 x i32>) nounwind readnone + + +define <16 x i8> @test_x86_sse2_packsswb_128(<8 x i16> %a0, <8 x i16> %a1) { + ; CHECK: vpacksswb + %res = call <16 x i8> @llvm.x86.sse2.packsswb.128(<8 x i16> %a0, <8 x i16> %a1) ; <<16 x i8>> [#uses=1] + ret <16 x i8> %res +} +declare <16 x i8> @llvm.x86.sse2.packsswb.128(<8 x i16>, <8 x i16>) nounwind readnone + + +define <16 x i8> @test_x86_sse2_packuswb_128(<8 x i16> %a0, <8 x i16> %a1) { + ; CHECK: vpackuswb + %res = call <16 x i8> @llvm.x86.sse2.packuswb.128(<8 x i16> %a0, <8 x i16> %a1) ; <<16 x i8>> [#uses=1] + ret <16 x i8> %res +} +declare <16 x i8> @llvm.x86.sse2.packuswb.128(<8 x i16>, <8 x i16>) nounwind readnone + + +define <16 x i8> @test_x86_sse2_padds_b(<16 x i8> %a0, <16 x i8> %a1) { + ; CHECK: vpaddsb + %res = call <16 x i8> @llvm.x86.sse2.padds.b(<16 x i8> %a0, <16 x i8> %a1) ; <<16 x i8>> [#uses=1] + ret <16 x i8> %res +} +declare <16 x i8> @llvm.x86.sse2.padds.b(<16 x i8>, <16 x i8>) nounwind readnone + + +define <8 x i16> @test_x86_sse2_padds_w(<8 x i16> %a0, <8 x i16> %a1) { + ; CHECK: vpaddsw + %res = call <8 x i16> @llvm.x86.sse2.padds.w(<8 x i16> %a0, <8 x i16> %a1) ; <<8 x i16>> [#uses=1] + ret <8 x i16> %res +} +declare <8 x i16> @llvm.x86.sse2.padds.w(<8 x i16>, <8 x i16>) nounwind readnone + + +define <16 x i8> @test_x86_sse2_paddus_b(<16 x i8> %a0, <16 x i8> %a1) { + ; CHECK: vpaddusb + %res = call <16 x i8> @llvm.x86.sse2.paddus.b(<16 x i8> %a0, <16 x i8> %a1) ; <<16 x i8>> [#uses=1] + ret <16 x i8> %res +} +declare <16 x i8> @llvm.x86.sse2.paddus.b(<16 x i8>, <16 x i8>) nounwind readnone + + +define <8 x i16> @test_x86_sse2_paddus_w(<8 x i16> %a0, <8 x i16> %a1) { + ; CHECK: vpaddusw + %res = call <8 x i16> @llvm.x86.sse2.paddus.w(<8 x i16> %a0, <8 x i16> %a1) ; <<8 x i16>> [#uses=1] + ret <8 x i16> %res +} +declare <8 x i16> @llvm.x86.sse2.paddus.w(<8 x i16>, <8 x i16>) nounwind readnone + + +define <16 x i8> @test_x86_sse2_pavg_b(<16 x i8> %a0, <16 x i8> %a1) { + ; CHECK: vpavgb + %res = call <16 x i8> @llvm.x86.sse2.pavg.b(<16 x i8> %a0, <16 x i8> %a1) ; <<16 x i8>> [#uses=1] + ret <16 x i8> %res +} +declare <16 x i8> @llvm.x86.sse2.pavg.b(<16 x i8>, <16 x i8>) nounwind readnone + + +define <8 x i16> @test_x86_sse2_pavg_w(<8 x i16> %a0, <8 x i16> %a1) { + ; CHECK: vpavgw + %res = call <8 x i16> @llvm.x86.sse2.pavg.w(<8 x i16> %a0, <8 x i16> %a1) ; <<8 x i16>> [#uses=1] + ret <8 x i16> %res +} +declare <8 x i16> @llvm.x86.sse2.pavg.w(<8 x i16>, <8 x i16>) nounwind readnone + + +define <16 x i8> @test_x86_sse2_pcmpeq_b(<16 x i8> %a0, <16 x i8> %a1) { + ; CHECK: vpcmpeqb + %res = call <16 x i8> @llvm.x86.sse2.pcmpeq.b(<16 x i8> %a0, <16 x i8> %a1) ; <<16 x i8>> [#uses=1] + ret <16 x i8> %res +} +declare <16 x i8> @llvm.x86.sse2.pcmpeq.b(<16 x i8>, <16 x i8>) nounwind readnone + + +define <4 x i32> @test_x86_sse2_pcmpeq_d(<4 x i32> %a0, <4 x i32> %a1) { + ; CHECK: vpcmpeqd + %res = call <4 x i32> @llvm.x86.sse2.pcmpeq.d(<4 x i32> %a0, <4 x i32> %a1) ; <<4 x i32>> [#uses=1] + ret <4 x i32> %res +} +declare <4 x i32> @llvm.x86.sse2.pcmpeq.d(<4 x i32>, <4 x i32>) nounwind readnone + + +define <8 x i16> @test_x86_sse2_pcmpeq_w(<8 x i16> %a0, <8 x i16> %a1) { + ; CHECK: vpcmpeqw + %res = call <8 x i16> @llvm.x86.sse2.pcmpeq.w(<8 x i16> %a0, <8 x i16> %a1) ; <<8 x i16>> [#uses=1] + ret <8 x i16> %res +} +declare <8 x i16> @llvm.x86.sse2.pcmpeq.w(<8 x i16>, <8 x i16>) nounwind readnone + + +define <16 x i8> @test_x86_sse2_pcmpgt_b(<16 x i8> %a0, <16 x i8> %a1) { + ; CHECK: vpcmpgtb + %res = call <16 x i8> @llvm.x86.sse2.pcmpgt.b(<16 x i8> %a0, <16 x i8> %a1) ; <<16 x i8>> [#uses=1] + ret <16 x i8> %res +} +declare <16 x i8> @llvm.x86.sse2.pcmpgt.b(<16 x i8>, <16 x i8>) nounwind readnone + + +define <4 x i32> @test_x86_sse2_pcmpgt_d(<4 x i32> %a0, <4 x i32> %a1) { + ; CHECK: vpcmpgtd + %res = call <4 x i32> @llvm.x86.sse2.pcmpgt.d(<4 x i32> %a0, <4 x i32> %a1) ; <<4 x i32>> [#uses=1] + ret <4 x i32> %res +} +declare <4 x i32> @llvm.x86.sse2.pcmpgt.d(<4 x i32>, <4 x i32>) nounwind readnone + + +define <8 x i16> @test_x86_sse2_pcmpgt_w(<8 x i16> %a0, <8 x i16> %a1) { + ; CHECK: vpcmpgtw + %res = call <8 x i16> @llvm.x86.sse2.pcmpgt.w(<8 x i16> %a0, <8 x i16> %a1) ; <<8 x i16>> [#uses=1] + ret <8 x i16> %res +} +declare <8 x i16> @llvm.x86.sse2.pcmpgt.w(<8 x i16>, <8 x i16>) nounwind readnone + + +define <4 x i32> @test_x86_sse2_pmadd_wd(<8 x i16> %a0, <8 x i16> %a1) { + ; CHECK: vpmaddwd + %res = call <4 x i32> @llvm.x86.sse2.pmadd.wd(<8 x i16> %a0, <8 x i16> %a1) ; <<4 x i32>> [#uses=1] + ret <4 x i32> %res +} +declare <4 x i32> @llvm.x86.sse2.pmadd.wd(<8 x i16>, <8 x i16>) nounwind readnone + + +define <8 x i16> @test_x86_sse2_pmaxs_w(<8 x i16> %a0, <8 x i16> %a1) { + ; CHECK: vpmaxsw + %res = call <8 x i16> @llvm.x86.sse2.pmaxs.w(<8 x i16> %a0, <8 x i16> %a1) ; <<8 x i16>> [#uses=1] + ret <8 x i16> %res +} +declare <8 x i16> @llvm.x86.sse2.pmaxs.w(<8 x i16>, <8 x i16>) nounwind readnone + + +define <16 x i8> @test_x86_sse2_pmaxu_b(<16 x i8> %a0, <16 x i8> %a1) { + ; CHECK: vpmaxub + %res = call <16 x i8> @llvm.x86.sse2.pmaxu.b(<16 x i8> %a0, <16 x i8> %a1) ; <<16 x i8>> [#uses=1] + ret <16 x i8> %res +} +declare <16 x i8> @llvm.x86.sse2.pmaxu.b(<16 x i8>, <16 x i8>) nounwind readnone + + +define <8 x i16> @test_x86_sse2_pmins_w(<8 x i16> %a0, <8 x i16> %a1) { + ; CHECK: vpminsw + %res = call <8 x i16> @llvm.x86.sse2.pmins.w(<8 x i16> %a0, <8 x i16> %a1) ; <<8 x i16>> [#uses=1] + ret <8 x i16> %res +} +declare <8 x i16> @llvm.x86.sse2.pmins.w(<8 x i16>, <8 x i16>) nounwind readnone + + +define <16 x i8> @test_x86_sse2_pminu_b(<16 x i8> %a0, <16 x i8> %a1) { + ; CHECK: vpminub + %res = call <16 x i8> @llvm.x86.sse2.pminu.b(<16 x i8> %a0, <16 x i8> %a1) ; <<16 x i8>> [#uses=1] + ret <16 x i8> %res +} +declare <16 x i8> @llvm.x86.sse2.pminu.b(<16 x i8>, <16 x i8>) nounwind readnone + + +define i32 @test_x86_sse2_pmovmskb_128(<16 x i8> %a0) { + ; CHECK: vpmovmskb + %res = call i32 @llvm.x86.sse2.pmovmskb.128(<16 x i8> %a0) ; [#uses=1] + ret i32 %res +} +declare i32 @llvm.x86.sse2.pmovmskb.128(<16 x i8>) nounwind readnone + + +define <8 x i16> @test_x86_sse2_pmulh_w(<8 x i16> %a0, <8 x i16> %a1) { + ; CHECK: vpmulhw + %res = call <8 x i16> @llvm.x86.sse2.pmulh.w(<8 x i16> %a0, <8 x i16> %a1) ; <<8 x i16>> [#uses=1] + ret <8 x i16> %res +} +declare <8 x i16> @llvm.x86.sse2.pmulh.w(<8 x i16>, <8 x i16>) nounwind readnone + + +define <8 x i16> @test_x86_sse2_pmulhu_w(<8 x i16> %a0, <8 x i16> %a1) { + ; CHECK: vpmulhuw + %res = call <8 x i16> @llvm.x86.sse2.pmulhu.w(<8 x i16> %a0, <8 x i16> %a1) ; <<8 x i16>> [#uses=1] + ret <8 x i16> %res +} +declare <8 x i16> @llvm.x86.sse2.pmulhu.w(<8 x i16>, <8 x i16>) nounwind readnone + + +define <2 x i64> @test_x86_sse2_pmulu_dq(<4 x i32> %a0, <4 x i32> %a1) { + ; CHECK: vpmuludq + %res = call <2 x i64> @llvm.x86.sse2.pmulu.dq(<4 x i32> %a0, <4 x i32> %a1) ; <<2 x i64>> [#uses=1] + ret <2 x i64> %res +} +declare <2 x i64> @llvm.x86.sse2.pmulu.dq(<4 x i32>, <4 x i32>) nounwind readnone + + +define <2 x i64> @test_x86_sse2_psad_bw(<16 x i8> %a0, <16 x i8> %a1) { + ; CHECK: vpsadbw + %res = call <2 x i64> @llvm.x86.sse2.psad.bw(<16 x i8> %a0, <16 x i8> %a1) ; <<2 x i64>> [#uses=1] + ret <2 x i64> %res +} +declare <2 x i64> @llvm.x86.sse2.psad.bw(<16 x i8>, <16 x i8>) nounwind readnone + + +define <4 x i32> @test_x86_sse2_psll_d(<4 x i32> %a0, <4 x i32> %a1) { + ; CHECK: vpslld + %res = call <4 x i32> @llvm.x86.sse2.psll.d(<4 x i32> %a0, <4 x i32> %a1) ; <<4 x i32>> [#uses=1] + ret <4 x i32> %res +} +declare <4 x i32> @llvm.x86.sse2.psll.d(<4 x i32>, <4 x i32>) nounwind readnone + + +define <2 x i64> @test_x86_sse2_psll_dq(<2 x i64> %a0) { + ; CHECK: vpslldq + %res = call <2 x i64> @llvm.x86.sse2.psll.dq(<2 x i64> %a0, i32 7) ; <<2 x i64>> [#uses=1] + ret <2 x i64> %res +} +declare <2 x i64> @llvm.x86.sse2.psll.dq(<2 x i64>, i32) nounwind readnone + + +define <2 x i64> @test_x86_sse2_psll_dq_bs(<2 x i64> %a0) { + ; CHECK: vpslldq + %res = call <2 x i64> @llvm.x86.sse2.psll.dq.bs(<2 x i64> %a0, i32 7) ; <<2 x i64>> [#uses=1] + ret <2 x i64> %res +} +declare <2 x i64> @llvm.x86.sse2.psll.dq.bs(<2 x i64>, i32) nounwind readnone + + +define <2 x i64> @test_x86_sse2_psll_q(<2 x i64> %a0, <2 x i64> %a1) { + ; CHECK: vpsllq + %res = call <2 x i64> @llvm.x86.sse2.psll.q(<2 x i64> %a0, <2 x i64> %a1) ; <<2 x i64>> [#uses=1] + ret <2 x i64> %res +} +declare <2 x i64> @llvm.x86.sse2.psll.q(<2 x i64>, <2 x i64>) nounwind readnone + + +define <8 x i16> @test_x86_sse2_psll_w(<8 x i16> %a0, <8 x i16> %a1) { + ; CHECK: vpsllw + %res = call <8 x i16> @llvm.x86.sse2.psll.w(<8 x i16> %a0, <8 x i16> %a1) ; <<8 x i16>> [#uses=1] + ret <8 x i16> %res +} +declare <8 x i16> @llvm.x86.sse2.psll.w(<8 x i16>, <8 x i16>) nounwind readnone + + +define <4 x i32> @test_x86_sse2_pslli_d(<4 x i32> %a0) { + ; CHECK: vpslld + %res = call <4 x i32> @llvm.x86.sse2.pslli.d(<4 x i32> %a0, i32 7) ; <<4 x i32>> [#uses=1] + ret <4 x i32> %res +} +declare <4 x i32> @llvm.x86.sse2.pslli.d(<4 x i32>, i32) nounwind readnone + + +define <2 x i64> @test_x86_sse2_pslli_q(<2 x i64> %a0) { + ; CHECK: vpsllq + %res = call <2 x i64> @llvm.x86.sse2.pslli.q(<2 x i64> %a0, i32 7) ; <<2 x i64>> [#uses=1] + ret <2 x i64> %res +} +declare <2 x i64> @llvm.x86.sse2.pslli.q(<2 x i64>, i32) nounwind readnone + + +define <8 x i16> @test_x86_sse2_pslli_w(<8 x i16> %a0) { + ; CHECK: vpsllw + %res = call <8 x i16> @llvm.x86.sse2.pslli.w(<8 x i16> %a0, i32 7) ; <<8 x i16>> [#uses=1] + ret <8 x i16> %res +} +declare <8 x i16> @llvm.x86.sse2.pslli.w(<8 x i16>, i32) nounwind readnone + + +define <4 x i32> @test_x86_sse2_psra_d(<4 x i32> %a0, <4 x i32> %a1) { + ; CHECK: vpsrad + %res = call <4 x i32> @llvm.x86.sse2.psra.d(<4 x i32> %a0, <4 x i32> %a1) ; <<4 x i32>> [#uses=1] + ret <4 x i32> %res +} +declare <4 x i32> @llvm.x86.sse2.psra.d(<4 x i32>, <4 x i32>) nounwind readnone + + +define <8 x i16> @test_x86_sse2_psra_w(<8 x i16> %a0, <8 x i16> %a1) { + ; CHECK: vpsraw + %res = call <8 x i16> @llvm.x86.sse2.psra.w(<8 x i16> %a0, <8 x i16> %a1) ; <<8 x i16>> [#uses=1] + ret <8 x i16> %res +} +declare <8 x i16> @llvm.x86.sse2.psra.w(<8 x i16>, <8 x i16>) nounwind readnone + + +define <4 x i32> @test_x86_sse2_psrai_d(<4 x i32> %a0) { + ; CHECK: vpsrad + %res = call <4 x i32> @llvm.x86.sse2.psrai.d(<4 x i32> %a0, i32 7) ; <<4 x i32>> [#uses=1] + ret <4 x i32> %res +} +declare <4 x i32> @llvm.x86.sse2.psrai.d(<4 x i32>, i32) nounwind readnone + + +define <8 x i16> @test_x86_sse2_psrai_w(<8 x i16> %a0) { + ; CHECK: vpsraw + %res = call <8 x i16> @llvm.x86.sse2.psrai.w(<8 x i16> %a0, i32 7) ; <<8 x i16>> [#uses=1] + ret <8 x i16> %res +} +declare <8 x i16> @llvm.x86.sse2.psrai.w(<8 x i16>, i32) nounwind readnone + + +define <4 x i32> @test_x86_sse2_psrl_d(<4 x i32> %a0, <4 x i32> %a1) { + ; CHECK: vpsrld + %res = call <4 x i32> @llvm.x86.sse2.psrl.d(<4 x i32> %a0, <4 x i32> %a1) ; <<4 x i32>> [#uses=1] + ret <4 x i32> %res +} +declare <4 x i32> @llvm.x86.sse2.psrl.d(<4 x i32>, <4 x i32>) nounwind readnone + + +define <2 x i64> @test_x86_sse2_psrl_dq(<2 x i64> %a0) { + ; CHECK: vpsrldq + %res = call <2 x i64> @llvm.x86.sse2.psrl.dq(<2 x i64> %a0, i32 7) ; <<2 x i64>> [#uses=1] + ret <2 x i64> %res +} +declare <2 x i64> @llvm.x86.sse2.psrl.dq(<2 x i64>, i32) nounwind readnone + + +define <2 x i64> @test_x86_sse2_psrl_dq_bs(<2 x i64> %a0) { + ; CHECK: vpsrldq + %res = call <2 x i64> @llvm.x86.sse2.psrl.dq.bs(<2 x i64> %a0, i32 7) ; <<2 x i64>> [#uses=1] + ret <2 x i64> %res +} +declare <2 x i64> @llvm.x86.sse2.psrl.dq.bs(<2 x i64>, i32) nounwind readnone + + +define <2 x i64> @test_x86_sse2_psrl_q(<2 x i64> %a0, <2 x i64> %a1) { + ; CHECK: vpsrlq + %res = call <2 x i64> @llvm.x86.sse2.psrl.q(<2 x i64> %a0, <2 x i64> %a1) ; <<2 x i64>> [#uses=1] + ret <2 x i64> %res +} +declare <2 x i64> @llvm.x86.sse2.psrl.q(<2 x i64>, <2 x i64>) nounwind readnone + + +define <8 x i16> @test_x86_sse2_psrl_w(<8 x i16> %a0, <8 x i16> %a1) { + ; CHECK: vpsrlw + %res = call <8 x i16> @llvm.x86.sse2.psrl.w(<8 x i16> %a0, <8 x i16> %a1) ; <<8 x i16>> [#uses=1] + ret <8 x i16> %res +} +declare <8 x i16> @llvm.x86.sse2.psrl.w(<8 x i16>, <8 x i16>) nounwind readnone + + +define <4 x i32> @test_x86_sse2_psrli_d(<4 x i32> %a0) { + ; CHECK: vpsrld + %res = call <4 x i32> @llvm.x86.sse2.psrli.d(<4 x i32> %a0, i32 7) ; <<4 x i32>> [#uses=1] + ret <4 x i32> %res +} +declare <4 x i32> @llvm.x86.sse2.psrli.d(<4 x i32>, i32) nounwind readnone + + +define <2 x i64> @test_x86_sse2_psrli_q(<2 x i64> %a0) { + ; CHECK: vpsrlq + %res = call <2 x i64> @llvm.x86.sse2.psrli.q(<2 x i64> %a0, i32 7) ; <<2 x i64>> [#uses=1] + ret <2 x i64> %res +} +declare <2 x i64> @llvm.x86.sse2.psrli.q(<2 x i64>, i32) nounwind readnone + + +define <8 x i16> @test_x86_sse2_psrli_w(<8 x i16> %a0) { + ; CHECK: vpsrlw + %res = call <8 x i16> @llvm.x86.sse2.psrli.w(<8 x i16> %a0, i32 7) ; <<8 x i16>> [#uses=1] + ret <8 x i16> %res +} +declare <8 x i16> @llvm.x86.sse2.psrli.w(<8 x i16>, i32) nounwind readnone + + +define <16 x i8> @test_x86_sse2_psubs_b(<16 x i8> %a0, <16 x i8> %a1) { + ; CHECK: vpsubsb + %res = call <16 x i8> @llvm.x86.sse2.psubs.b(<16 x i8> %a0, <16 x i8> %a1) ; <<16 x i8>> [#uses=1] + ret <16 x i8> %res +} +declare <16 x i8> @llvm.x86.sse2.psubs.b(<16 x i8>, <16 x i8>) nounwind readnone + + +define <8 x i16> @test_x86_sse2_psubs_w(<8 x i16> %a0, <8 x i16> %a1) { + ; CHECK: vpsubsw + %res = call <8 x i16> @llvm.x86.sse2.psubs.w(<8 x i16> %a0, <8 x i16> %a1) ; <<8 x i16>> [#uses=1] + ret <8 x i16> %res +} +declare <8 x i16> @llvm.x86.sse2.psubs.w(<8 x i16>, <8 x i16>) nounwind readnone + + +define <16 x i8> @test_x86_sse2_psubus_b(<16 x i8> %a0, <16 x i8> %a1) { + ; CHECK: vpsubusb + %res = call <16 x i8> @llvm.x86.sse2.psubus.b(<16 x i8> %a0, <16 x i8> %a1) ; <<16 x i8>> [#uses=1] + ret <16 x i8> %res +} +declare <16 x i8> @llvm.x86.sse2.psubus.b(<16 x i8>, <16 x i8>) nounwind readnone + + +define <8 x i16> @test_x86_sse2_psubus_w(<8 x i16> %a0, <8 x i16> %a1) { + ; CHECK: vpsubusw + %res = call <8 x i16> @llvm.x86.sse2.psubus.w(<8 x i16> %a0, <8 x i16> %a1) ; <<8 x i16>> [#uses=1] + ret <8 x i16> %res +} +declare <8 x i16> @llvm.x86.sse2.psubus.w(<8 x i16>, <8 x i16>) nounwind readnone + + +define <2 x double> @test_x86_sse2_sqrt_pd(<2 x double> %a0) { + ; CHECK: vsqrtpd + %res = call <2 x double> @llvm.x86.sse2.sqrt.pd(<2 x double> %a0) ; <<2 x double>> [#uses=1] + ret <2 x double> %res +} +declare <2 x double> @llvm.x86.sse2.sqrt.pd(<2 x double>) nounwind readnone + + +define <2 x double> @test_x86_sse2_sqrt_sd(<2 x double> %a0) { + ; CHECK: vsqrtsd + %res = call <2 x double> @llvm.x86.sse2.sqrt.sd(<2 x double> %a0) ; <<2 x double>> [#uses=1] + ret <2 x double> %res +} +declare <2 x double> @llvm.x86.sse2.sqrt.sd(<2 x double>) nounwind readnone + + +define void @test_x86_sse2_storel_dq(i8* %a0, <4 x i32> %a1) { + ; CHECK: movl + ; CHECK: vmovq + call void @llvm.x86.sse2.storel.dq(i8* %a0, <4 x i32> %a1) + ret void +} +declare void @llvm.x86.sse2.storel.dq(i8*, <4 x i32>) nounwind + + +define void @test_x86_sse2_storeu_dq(i8* %a0, <16 x i8> %a1) { + ; CHECK: movl + ; CHECK: vmovdqu + call void @llvm.x86.sse2.storeu.dq(i8* %a0, <16 x i8> %a1) + ret void +} +declare void @llvm.x86.sse2.storeu.dq(i8*, <16 x i8>) nounwind + + +define void @test_x86_sse2_storeu_pd(i8* %a0, <2 x double> %a1) { + ; CHECK: movl + ; CHECK: vmovupd + call void @llvm.x86.sse2.storeu.pd(i8* %a0, <2 x double> %a1) + ret void +} +declare void @llvm.x86.sse2.storeu.pd(i8*, <2 x double>) nounwind + + +define <2 x double> @test_x86_sse2_sub_sd(<2 x double> %a0, <2 x double> %a1) { + ; CHECK: vsubsd + %res = call <2 x double> @llvm.x86.sse2.sub.sd(<2 x double> %a0, <2 x double> %a1) ; <<2 x double>> [#uses=1] + ret <2 x double> %res +} +declare <2 x double> @llvm.x86.sse2.sub.sd(<2 x double>, <2 x double>) nounwind readnone + + +define i32 @test_x86_sse2_ucomieq_sd(<2 x double> %a0, <2 x double> %a1) { + ; CHECK: vucomisd + ; CHECK: sete + ; CHECK: movzbl + %res = call i32 @llvm.x86.sse2.ucomieq.sd(<2 x double> %a0, <2 x double> %a1) ; [#uses=1] + ret i32 %res +} +declare i32 @llvm.x86.sse2.ucomieq.sd(<2 x double>, <2 x double>) nounwind readnone + + +define i32 @test_x86_sse2_ucomige_sd(<2 x double> %a0, <2 x double> %a1) { + ; CHECK: vucomisd + ; CHECK: setae + ; CHECK: movzbl + %res = call i32 @llvm.x86.sse2.ucomige.sd(<2 x double> %a0, <2 x double> %a1) ; [#uses=1] + ret i32 %res +} +declare i32 @llvm.x86.sse2.ucomige.sd(<2 x double>, <2 x double>) nounwind readnone + + +define i32 @test_x86_sse2_ucomigt_sd(<2 x double> %a0, <2 x double> %a1) { + ; CHECK: vucomisd + ; CHECK: seta + ; CHECK: movzbl + %res = call i32 @llvm.x86.sse2.ucomigt.sd(<2 x double> %a0, <2 x double> %a1) ; [#uses=1] + ret i32 %res +} +declare i32 @llvm.x86.sse2.ucomigt.sd(<2 x double>, <2 x double>) nounwind readnone + + +define i32 @test_x86_sse2_ucomile_sd(<2 x double> %a0, <2 x double> %a1) { + ; CHECK: vucomisd + ; CHECK: setbe + ; CHECK: movzbl + %res = call i32 @llvm.x86.sse2.ucomile.sd(<2 x double> %a0, <2 x double> %a1) ; [#uses=1] + ret i32 %res +} +declare i32 @llvm.x86.sse2.ucomile.sd(<2 x double>, <2 x double>) nounwind readnone + + +define i32 @test_x86_sse2_ucomilt_sd(<2 x double> %a0, <2 x double> %a1) { + ; CHECK: vucomisd + ; CHECK: setb + ; CHECK: movzbl + %res = call i32 @llvm.x86.sse2.ucomilt.sd(<2 x double> %a0, <2 x double> %a1) ; [#uses=1] + ret i32 %res +} +declare i32 @llvm.x86.sse2.ucomilt.sd(<2 x double>, <2 x double>) nounwind readnone + + +define i32 @test_x86_sse2_ucomineq_sd(<2 x double> %a0, <2 x double> %a1) { + ; CHECK: vucomisd + ; CHECK: setne + ; CHECK: movzbl + %res = call i32 @llvm.x86.sse2.ucomineq.sd(<2 x double> %a0, <2 x double> %a1) ; [#uses=1] + ret i32 %res +} +declare i32 @llvm.x86.sse2.ucomineq.sd(<2 x double>, <2 x double>) nounwind readnone + + +define <2 x double> @test_x86_sse3_addsub_pd(<2 x double> %a0, <2 x double> %a1) { + ; CHECK: vaddsubpd + %res = call <2 x double> @llvm.x86.sse3.addsub.pd(<2 x double> %a0, <2 x double> %a1) ; <<2 x double>> [#uses=1] + ret <2 x double> %res +} +declare <2 x double> @llvm.x86.sse3.addsub.pd(<2 x double>, <2 x double>) nounwind readnone + + +define <4 x float> @test_x86_sse3_addsub_ps(<4 x float> %a0, <4 x float> %a1) { + ; CHECK: vaddsubps + %res = call <4 x float> @llvm.x86.sse3.addsub.ps(<4 x float> %a0, <4 x float> %a1) ; <<4 x float>> [#uses=1] + ret <4 x float> %res +} +declare <4 x float> @llvm.x86.sse3.addsub.ps(<4 x float>, <4 x float>) nounwind readnone + + +define <2 x double> @test_x86_sse3_hadd_pd(<2 x double> %a0, <2 x double> %a1) { + ; CHECK: vhaddpd + %res = call <2 x double> @llvm.x86.sse3.hadd.pd(<2 x double> %a0, <2 x double> %a1) ; <<2 x double>> [#uses=1] + ret <2 x double> %res +} +declare <2 x double> @llvm.x86.sse3.hadd.pd(<2 x double>, <2 x double>) nounwind readnone + + +define <4 x float> @test_x86_sse3_hadd_ps(<4 x float> %a0, <4 x float> %a1) { + ; CHECK: vhaddps + %res = call <4 x float> @llvm.x86.sse3.hadd.ps(<4 x float> %a0, <4 x float> %a1) ; <<4 x float>> [#uses=1] + ret <4 x float> %res +} +declare <4 x float> @llvm.x86.sse3.hadd.ps(<4 x float>, <4 x float>) nounwind readnone + + +define <2 x double> @test_x86_sse3_hsub_pd(<2 x double> %a0, <2 x double> %a1) { + ; CHECK: vhsubpd + %res = call <2 x double> @llvm.x86.sse3.hsub.pd(<2 x double> %a0, <2 x double> %a1) ; <<2 x double>> [#uses=1] + ret <2 x double> %res +} +declare <2 x double> @llvm.x86.sse3.hsub.pd(<2 x double>, <2 x double>) nounwind readnone + + +define <4 x float> @test_x86_sse3_hsub_ps(<4 x float> %a0, <4 x float> %a1) { + ; CHECK: vhsubps + %res = call <4 x float> @llvm.x86.sse3.hsub.ps(<4 x float> %a0, <4 x float> %a1) ; <<4 x float>> [#uses=1] + ret <4 x float> %res +} +declare <4 x float> @llvm.x86.sse3.hsub.ps(<4 x float>, <4 x float>) nounwind readnone + + +define <16 x i8> @test_x86_sse3_ldu_dq(i8* %a0) { + ; CHECK: movl + ; CHECK: vlddqu + %res = call <16 x i8> @llvm.x86.sse3.ldu.dq(i8* %a0) ; <<16 x i8>> [#uses=1] + ret <16 x i8> %res +} +declare <16 x i8> @llvm.x86.sse3.ldu.dq(i8*) nounwind readonly + + +define <2 x double> @test_x86_sse41_blendpd(<2 x double> %a0, <2 x double> %a1) { + ; CHECK: vblendpd + %res = call <2 x double> @llvm.x86.sse41.blendpd(<2 x double> %a0, <2 x double> %a1, i32 7) ; <<2 x double>> [#uses=1] + ret <2 x double> %res +} +declare <2 x double> @llvm.x86.sse41.blendpd(<2 x double>, <2 x double>, i32) nounwind readnone + + +define <4 x float> @test_x86_sse41_blendps(<4 x float> %a0, <4 x float> %a1) { + ; CHECK: vblendps + %res = call <4 x float> @llvm.x86.sse41.blendps(<4 x float> %a0, <4 x float> %a1, i32 7) ; <<4 x float>> [#uses=1] + ret <4 x float> %res +} +declare <4 x float> @llvm.x86.sse41.blendps(<4 x float>, <4 x float>, i32) nounwind readnone + + +define <2 x double> @test_x86_sse41_blendvpd(<2 x double> %a0, <2 x double> %a1, <2 x double> %a2) { + ; CHECK: vblendvpd + %res = call <2 x double> @llvm.x86.sse41.blendvpd(<2 x double> %a0, <2 x double> %a1, <2 x double> %a2) ; <<2 x double>> [#uses=1] + ret <2 x double> %res +} +declare <2 x double> @llvm.x86.sse41.blendvpd(<2 x double>, <2 x double>, <2 x double>) nounwind readnone + + +define <4 x float> @test_x86_sse41_blendvps(<4 x float> %a0, <4 x float> %a1, <4 x float> %a2) { + ; CHECK: vblendvps + %res = call <4 x float> @llvm.x86.sse41.blendvps(<4 x float> %a0, <4 x float> %a1, <4 x float> %a2) ; <<4 x float>> [#uses=1] + ret <4 x float> %res +} +declare <4 x float> @llvm.x86.sse41.blendvps(<4 x float>, <4 x float>, <4 x float>) nounwind readnone + + +define <2 x double> @test_x86_sse41_dppd(<2 x double> %a0, <2 x double> %a1) { + ; CHECK: vdppd + %res = call <2 x double> @llvm.x86.sse41.dppd(<2 x double> %a0, <2 x double> %a1, i32 7) ; <<2 x double>> [#uses=1] + ret <2 x double> %res +} +declare <2 x double> @llvm.x86.sse41.dppd(<2 x double>, <2 x double>, i32) nounwind readnone + + +define <4 x float> @test_x86_sse41_dpps(<4 x float> %a0, <4 x float> %a1) { + ; CHECK: vdpps + %res = call <4 x float> @llvm.x86.sse41.dpps(<4 x float> %a0, <4 x float> %a1, i32 7) ; <<4 x float>> [#uses=1] + ret <4 x float> %res +} +declare <4 x float> @llvm.x86.sse41.dpps(<4 x float>, <4 x float>, i32) nounwind readnone + + +define <4 x float> @test_x86_sse41_insertps(<4 x float> %a0, <4 x float> %a1) { + ; CHECK: vinsertps + %res = call <4 x float> @llvm.x86.sse41.insertps(<4 x float> %a0, <4 x float> %a1, i32 7) ; <<4 x float>> [#uses=1] + ret <4 x float> %res +} +declare <4 x float> @llvm.x86.sse41.insertps(<4 x float>, <4 x float>, i32) nounwind readnone + + +define <2 x i64> @test_x86_sse41_movntdqa(i8* %a0) { + ; CHECK: movl + ; CHECK: vmovntdqa + %res = call <2 x i64> @llvm.x86.sse41.movntdqa(i8* %a0) ; <<2 x i64>> [#uses=1] + ret <2 x i64> %res +} +declare <2 x i64> @llvm.x86.sse41.movntdqa(i8*) nounwind readonly + + +define <16 x i8> @test_x86_sse41_mpsadbw(<16 x i8> %a0, <16 x i8> %a1) { + ; CHECK: vmpsadbw + %res = call <16 x i8> @llvm.x86.sse41.mpsadbw(<16 x i8> %a0, <16 x i8> %a1, i32 7) ; <<16 x i8>> [#uses=1] + ret <16 x i8> %res +} +declare <16 x i8> @llvm.x86.sse41.mpsadbw(<16 x i8>, <16 x i8>, i32) nounwind readnone + + +define <8 x i16> @test_x86_sse41_packusdw(<4 x i32> %a0, <4 x i32> %a1) { + ; CHECK: vpackusdw + %res = call <8 x i16> @llvm.x86.sse41.packusdw(<4 x i32> %a0, <4 x i32> %a1) ; <<8 x i16>> [#uses=1] + ret <8 x i16> %res +} +declare <8 x i16> @llvm.x86.sse41.packusdw(<4 x i32>, <4 x i32>) nounwind readnone + + +define <16 x i8> @test_x86_sse41_pblendvb(<16 x i8> %a0, <16 x i8> %a1, <16 x i8> %a2) { + ; CHECK: vpblendvb + %res = call <16 x i8> @llvm.x86.sse41.pblendvb(<16 x i8> %a0, <16 x i8> %a1, <16 x i8> %a2) ; <<16 x i8>> [#uses=1] + ret <16 x i8> %res +} +declare <16 x i8> @llvm.x86.sse41.pblendvb(<16 x i8>, <16 x i8>, <16 x i8>) nounwind readnone + + +define <8 x i16> @test_x86_sse41_pblendw(<8 x i16> %a0, <8 x i16> %a1) { + ; CHECK: vpblendw + %res = call <8 x i16> @llvm.x86.sse41.pblendw(<8 x i16> %a0, <8 x i16> %a1, i32 7) ; <<8 x i16>> [#uses=1] + ret <8 x i16> %res +} +declare <8 x i16> @llvm.x86.sse41.pblendw(<8 x i16>, <8 x i16>, i32) nounwind readnone + + +define <2 x i64> @test_x86_sse41_pcmpeqq(<2 x i64> %a0, <2 x i64> %a1) { + ; CHECK: vpcmpeqq + %res = call <2 x i64> @llvm.x86.sse41.pcmpeqq(<2 x i64> %a0, <2 x i64> %a1) ; <<2 x i64>> [#uses=1] + ret <2 x i64> %res +} +declare <2 x i64> @llvm.x86.sse41.pcmpeqq(<2 x i64>, <2 x i64>) nounwind readnone + + +define <8 x i16> @test_x86_sse41_phminposuw(<8 x i16> %a0) { + ; CHECK: vphminposuw + %res = call <8 x i16> @llvm.x86.sse41.phminposuw(<8 x i16> %a0) ; <<8 x i16>> [#uses=1] + ret <8 x i16> %res +} +declare <8 x i16> @llvm.x86.sse41.phminposuw(<8 x i16>) nounwind readnone + + +define <16 x i8> @test_x86_sse41_pmaxsb(<16 x i8> %a0, <16 x i8> %a1) { + ; CHECK: vpmaxsb + %res = call <16 x i8> @llvm.x86.sse41.pmaxsb(<16 x i8> %a0, <16 x i8> %a1) ; <<16 x i8>> [#uses=1] + ret <16 x i8> %res +} +declare <16 x i8> @llvm.x86.sse41.pmaxsb(<16 x i8>, <16 x i8>) nounwind readnone + + +define <4 x i32> @test_x86_sse41_pmaxsd(<4 x i32> %a0, <4 x i32> %a1) { + ; CHECK: vpmaxsd + %res = call <4 x i32> @llvm.x86.sse41.pmaxsd(<4 x i32> %a0, <4 x i32> %a1) ; <<4 x i32>> [#uses=1] + ret <4 x i32> %res +} +declare <4 x i32> @llvm.x86.sse41.pmaxsd(<4 x i32>, <4 x i32>) nounwind readnone + + +define <4 x i32> @test_x86_sse41_pmaxud(<4 x i32> %a0, <4 x i32> %a1) { + ; CHECK: vpmaxud + %res = call <4 x i32> @llvm.x86.sse41.pmaxud(<4 x i32> %a0, <4 x i32> %a1) ; <<4 x i32>> [#uses=1] + ret <4 x i32> %res +} +declare <4 x i32> @llvm.x86.sse41.pmaxud(<4 x i32>, <4 x i32>) nounwind readnone + + +define <8 x i16> @test_x86_sse41_pmaxuw(<8 x i16> %a0, <8 x i16> %a1) { + ; CHECK: vpmaxuw + %res = call <8 x i16> @llvm.x86.sse41.pmaxuw(<8 x i16> %a0, <8 x i16> %a1) ; <<8 x i16>> [#uses=1] + ret <8 x i16> %res +} +declare <8 x i16> @llvm.x86.sse41.pmaxuw(<8 x i16>, <8 x i16>) nounwind readnone + + +define <16 x i8> @test_x86_sse41_pminsb(<16 x i8> %a0, <16 x i8> %a1) { + ; CHECK: vpminsb + %res = call <16 x i8> @llvm.x86.sse41.pminsb(<16 x i8> %a0, <16 x i8> %a1) ; <<16 x i8>> [#uses=1] + ret <16 x i8> %res +} +declare <16 x i8> @llvm.x86.sse41.pminsb(<16 x i8>, <16 x i8>) nounwind readnone + + +define <4 x i32> @test_x86_sse41_pminsd(<4 x i32> %a0, <4 x i32> %a1) { + ; CHECK: vpminsd + %res = call <4 x i32> @llvm.x86.sse41.pminsd(<4 x i32> %a0, <4 x i32> %a1) ; <<4 x i32>> [#uses=1] + ret <4 x i32> %res +} +declare <4 x i32> @llvm.x86.sse41.pminsd(<4 x i32>, <4 x i32>) nounwind readnone + + +define <4 x i32> @test_x86_sse41_pminud(<4 x i32> %a0, <4 x i32> %a1) { + ; CHECK: vpminud + %res = call <4 x i32> @llvm.x86.sse41.pminud(<4 x i32> %a0, <4 x i32> %a1) ; <<4 x i32>> [#uses=1] + ret <4 x i32> %res +} +declare <4 x i32> @llvm.x86.sse41.pminud(<4 x i32>, <4 x i32>) nounwind readnone + + +define <8 x i16> @test_x86_sse41_pminuw(<8 x i16> %a0, <8 x i16> %a1) { + ; CHECK: vpminuw + %res = call <8 x i16> @llvm.x86.sse41.pminuw(<8 x i16> %a0, <8 x i16> %a1) ; <<8 x i16>> [#uses=1] + ret <8 x i16> %res +} +declare <8 x i16> @llvm.x86.sse41.pminuw(<8 x i16>, <8 x i16>) nounwind readnone + + +define <4 x i32> @test_x86_sse41_pmovsxbd(<16 x i8> %a0) { + ; CHECK: vpmovsxbd + %res = call <4 x i32> @llvm.x86.sse41.pmovsxbd(<16 x i8> %a0) ; <<4 x i32>> [#uses=1] + ret <4 x i32> %res +} +declare <4 x i32> @llvm.x86.sse41.pmovsxbd(<16 x i8>) nounwind readnone + + +define <2 x i64> @test_x86_sse41_pmovsxbq(<16 x i8> %a0) { + ; CHECK: vpmovsxbq + %res = call <2 x i64> @llvm.x86.sse41.pmovsxbq(<16 x i8> %a0) ; <<2 x i64>> [#uses=1] + ret <2 x i64> %res +} +declare <2 x i64> @llvm.x86.sse41.pmovsxbq(<16 x i8>) nounwind readnone + + +define <8 x i16> @test_x86_sse41_pmovsxbw(<16 x i8> %a0) { + ; CHECK: vpmovsxbw + %res = call <8 x i16> @llvm.x86.sse41.pmovsxbw(<16 x i8> %a0) ; <<8 x i16>> [#uses=1] + ret <8 x i16> %res +} +declare <8 x i16> @llvm.x86.sse41.pmovsxbw(<16 x i8>) nounwind readnone + + +define <2 x i64> @test_x86_sse41_pmovsxdq(<4 x i32> %a0) { + ; CHECK: vpmovsxdq + %res = call <2 x i64> @llvm.x86.sse41.pmovsxdq(<4 x i32> %a0) ; <<2 x i64>> [#uses=1] + ret <2 x i64> %res +} +declare <2 x i64> @llvm.x86.sse41.pmovsxdq(<4 x i32>) nounwind readnone + + +define <4 x i32> @test_x86_sse41_pmovsxwd(<8 x i16> %a0) { + ; CHECK: vpmovsxwd + %res = call <4 x i32> @llvm.x86.sse41.pmovsxwd(<8 x i16> %a0) ; <<4 x i32>> [#uses=1] + ret <4 x i32> %res +} +declare <4 x i32> @llvm.x86.sse41.pmovsxwd(<8 x i16>) nounwind readnone + + +define <2 x i64> @test_x86_sse41_pmovsxwq(<8 x i16> %a0) { + ; CHECK: vpmovsxwq + %res = call <2 x i64> @llvm.x86.sse41.pmovsxwq(<8 x i16> %a0) ; <<2 x i64>> [#uses=1] + ret <2 x i64> %res +} +declare <2 x i64> @llvm.x86.sse41.pmovsxwq(<8 x i16>) nounwind readnone + + +define <4 x i32> @test_x86_sse41_pmovzxbd(<16 x i8> %a0) { + ; CHECK: vpmovzxbd + %res = call <4 x i32> @llvm.x86.sse41.pmovzxbd(<16 x i8> %a0) ; <<4 x i32>> [#uses=1] + ret <4 x i32> %res +} +declare <4 x i32> @llvm.x86.sse41.pmovzxbd(<16 x i8>) nounwind readnone + + +define <2 x i64> @test_x86_sse41_pmovzxbq(<16 x i8> %a0) { + ; CHECK: vpmovzxbq + %res = call <2 x i64> @llvm.x86.sse41.pmovzxbq(<16 x i8> %a0) ; <<2 x i64>> [#uses=1] + ret <2 x i64> %res +} +declare <2 x i64> @llvm.x86.sse41.pmovzxbq(<16 x i8>) nounwind readnone + + +define <8 x i16> @test_x86_sse41_pmovzxbw(<16 x i8> %a0) { + ; CHECK: vpmovzxbw + %res = call <8 x i16> @llvm.x86.sse41.pmovzxbw(<16 x i8> %a0) ; <<8 x i16>> [#uses=1] + ret <8 x i16> %res +} +declare <8 x i16> @llvm.x86.sse41.pmovzxbw(<16 x i8>) nounwind readnone + + +define <2 x i64> @test_x86_sse41_pmovzxdq(<4 x i32> %a0) { + ; CHECK: vpmovzxdq + %res = call <2 x i64> @llvm.x86.sse41.pmovzxdq(<4 x i32> %a0) ; <<2 x i64>> [#uses=1] + ret <2 x i64> %res +} +declare <2 x i64> @llvm.x86.sse41.pmovzxdq(<4 x i32>) nounwind readnone + + +define <4 x i32> @test_x86_sse41_pmovzxwd(<8 x i16> %a0) { + ; CHECK: vpmovzxwd + %res = call <4 x i32> @llvm.x86.sse41.pmovzxwd(<8 x i16> %a0) ; <<4 x i32>> [#uses=1] + ret <4 x i32> %res +} +declare <4 x i32> @llvm.x86.sse41.pmovzxwd(<8 x i16>) nounwind readnone + + +define <2 x i64> @test_x86_sse41_pmovzxwq(<8 x i16> %a0) { + ; CHECK: vpmovzxwq + %res = call <2 x i64> @llvm.x86.sse41.pmovzxwq(<8 x i16> %a0) ; <<2 x i64>> [#uses=1] + ret <2 x i64> %res +} +declare <2 x i64> @llvm.x86.sse41.pmovzxwq(<8 x i16>) nounwind readnone + + +define <2 x i64> @test_x86_sse41_pmuldq(<4 x i32> %a0, <4 x i32> %a1) { + ; CHECK: vpmuldq + %res = call <2 x i64> @llvm.x86.sse41.pmuldq(<4 x i32> %a0, <4 x i32> %a1) ; <<2 x i64>> [#uses=1] + ret <2 x i64> %res +} +declare <2 x i64> @llvm.x86.sse41.pmuldq(<4 x i32>, <4 x i32>) nounwind readnone + + +define i32 @test_x86_sse41_ptestc(<4 x float> %a0, <4 x float> %a1) { + ; CHECK: vptest + ; CHECK: setb + ; CHECK: movzbl + %res = call i32 @llvm.x86.sse41.ptestc(<4 x float> %a0, <4 x float> %a1) ; [#uses=1] + ret i32 %res +} +declare i32 @llvm.x86.sse41.ptestc(<4 x float>, <4 x float>) nounwind readnone + + +define i32 @test_x86_sse41_ptestnzc(<4 x float> %a0, <4 x float> %a1) { + ; CHECK: vptest + ; CHECK: seta + ; CHECK: movzbl + %res = call i32 @llvm.x86.sse41.ptestnzc(<4 x float> %a0, <4 x float> %a1) ; [#uses=1] + ret i32 %res +} +declare i32 @llvm.x86.sse41.ptestnzc(<4 x float>, <4 x float>) nounwind readnone + + +define i32 @test_x86_sse41_ptestz(<4 x float> %a0, <4 x float> %a1) { + ; CHECK: vptest + ; CHECK: sete + ; CHECK: movzbl + %res = call i32 @llvm.x86.sse41.ptestz(<4 x float> %a0, <4 x float> %a1) ; [#uses=1] + ret i32 %res +} +declare i32 @llvm.x86.sse41.ptestz(<4 x float>, <4 x float>) nounwind readnone + + +define <2 x double> @test_x86_sse41_round_pd(<2 x double> %a0) { + ; CHECK: vroundpd + %res = call <2 x double> @llvm.x86.sse41.round.pd(<2 x double> %a0, i32 7) ; <<2 x double>> [#uses=1] + ret <2 x double> %res +} +declare <2 x double> @llvm.x86.sse41.round.pd(<2 x double>, i32) nounwind readnone + + +define <4 x float> @test_x86_sse41_round_ps(<4 x float> %a0) { + ; CHECK: vroundps + %res = call <4 x float> @llvm.x86.sse41.round.ps(<4 x float> %a0, i32 7) ; <<4 x float>> [#uses=1] + ret <4 x float> %res +} +declare <4 x float> @llvm.x86.sse41.round.ps(<4 x float>, i32) nounwind readnone + + +define <2 x double> @test_x86_sse41_round_sd(<2 x double> %a0, <2 x double> %a1) { + ; CHECK: vroundsd + %res = call <2 x double> @llvm.x86.sse41.round.sd(<2 x double> %a0, <2 x double> %a1, i32 7) ; <<2 x double>> [#uses=1] + ret <2 x double> %res +} +declare <2 x double> @llvm.x86.sse41.round.sd(<2 x double>, <2 x double>, i32) nounwind readnone + + +define <4 x float> @test_x86_sse41_round_ss(<4 x float> %a0, <4 x float> %a1) { + ; CHECK: vroundss + %res = call <4 x float> @llvm.x86.sse41.round.ss(<4 x float> %a0, <4 x float> %a1, i32 7) ; <<4 x float>> [#uses=1] + ret <4 x float> %res +} +declare <4 x float> @llvm.x86.sse41.round.ss(<4 x float>, <4 x float>, i32) nounwind readnone + + +define i32 @test_x86_sse42_pcmpestri128(<16 x i8> %a0, <16 x i8> %a2) { + ; CHECK: movl + ; CHECK: movl + ; CHECK: vpcmpestri + ; CHECK: movl + %res = call i32 @llvm.x86.sse42.pcmpestri128(<16 x i8> %a0, i32 7, <16 x i8> %a2, i32 7, i8 7) ; [#uses=1] + ret i32 %res +} +declare i32 @llvm.x86.sse42.pcmpestri128(<16 x i8>, i32, <16 x i8>, i32, i8) nounwind readnone + + +define i32 @test_x86_sse42_pcmpestria128(<16 x i8> %a0, <16 x i8> %a2) { + ; CHECK: movl + ; CHECK: movl + ; CHECK: vpcmpestri + ; CHECK: movl + %res = call i32 @llvm.x86.sse42.pcmpestria128(<16 x i8> %a0, i32 7, <16 x i8> %a2, i32 7, i8 7) ; [#uses=1] + ret i32 %res +} +declare i32 @llvm.x86.sse42.pcmpestria128(<16 x i8>, i32, <16 x i8>, i32, i8) nounwind readnone + + +define i32 @test_x86_sse42_pcmpestric128(<16 x i8> %a0, <16 x i8> %a2) { + ; CHECK: movl + ; CHECK: movl + ; CHECK: vpcmpestri + ; CHECK: movl + %res = call i32 @llvm.x86.sse42.pcmpestric128(<16 x i8> %a0, i32 7, <16 x i8> %a2, i32 7, i8 7) ; [#uses=1] + ret i32 %res +} +declare i32 @llvm.x86.sse42.pcmpestric128(<16 x i8>, i32, <16 x i8>, i32, i8) nounwind readnone + + +define i32 @test_x86_sse42_pcmpestrio128(<16 x i8> %a0, <16 x i8> %a2) { + ; CHECK: movl + ; CHECK: movl + ; CHECK: vpcmpestri + ; CHECK: movl + %res = call i32 @llvm.x86.sse42.pcmpestrio128(<16 x i8> %a0, i32 7, <16 x i8> %a2, i32 7, i8 7) ; [#uses=1] + ret i32 %res +} +declare i32 @llvm.x86.sse42.pcmpestrio128(<16 x i8>, i32, <16 x i8>, i32, i8) nounwind readnone + + +define i32 @test_x86_sse42_pcmpestris128(<16 x i8> %a0, <16 x i8> %a2) { + ; CHECK: movl + ; CHECK: movl + ; CHECK: vpcmpestri + ; CHECK: movl + %res = call i32 @llvm.x86.sse42.pcmpestris128(<16 x i8> %a0, i32 7, <16 x i8> %a2, i32 7, i8 7) ; [#uses=1] + ret i32 %res +} +declare i32 @llvm.x86.sse42.pcmpestris128(<16 x i8>, i32, <16 x i8>, i32, i8) nounwind readnone + + +define i32 @test_x86_sse42_pcmpestriz128(<16 x i8> %a0, <16 x i8> %a2) { + ; CHECK: movl + ; CHECK: movl + ; CHECK: vpcmpestri + ; CHECK: movl + %res = call i32 @llvm.x86.sse42.pcmpestriz128(<16 x i8> %a0, i32 7, <16 x i8> %a2, i32 7, i8 7) ; [#uses=1] + ret i32 %res +} +declare i32 @llvm.x86.sse42.pcmpestriz128(<16 x i8>, i32, <16 x i8>, i32, i8) nounwind readnone + + +define <16 x i8> @test_x86_sse42_pcmpestrm128(<16 x i8> %a0, <16 x i8> %a2) { + ; CHECK: movl + ; CHECK: movl + ; CHECK: vpcmpestrm + %res = call <16 x i8> @llvm.x86.sse42.pcmpestrm128(<16 x i8> %a0, i32 7, <16 x i8> %a2, i32 7, i8 7) ; <<16 x i8>> [#uses=1] + ret <16 x i8> %res +} +declare <16 x i8> @llvm.x86.sse42.pcmpestrm128(<16 x i8>, i32, <16 x i8>, i32, i8) nounwind readnone + + +define <2 x i64> @test_x86_sse42_pcmpgtq(<2 x i64> %a0, <2 x i64> %a1) { + ; CHECK: vpcmpgtq + %res = call <2 x i64> @llvm.x86.sse42.pcmpgtq(<2 x i64> %a0, <2 x i64> %a1) ; <<2 x i64>> [#uses=1] + ret <2 x i64> %res +} +declare <2 x i64> @llvm.x86.sse42.pcmpgtq(<2 x i64>, <2 x i64>) nounwind readnone + + +define i32 @test_x86_sse42_pcmpistri128(<16 x i8> %a0, <16 x i8> %a1) { + ; CHECK: vpcmpistri + ; CHECK: movl + %res = call i32 @llvm.x86.sse42.pcmpistri128(<16 x i8> %a0, <16 x i8> %a1, i8 7) ; [#uses=1] + ret i32 %res +} +declare i32 @llvm.x86.sse42.pcmpistri128(<16 x i8>, <16 x i8>, i8) nounwind readnone + + +define i32 @test_x86_sse42_pcmpistria128(<16 x i8> %a0, <16 x i8> %a1) { + ; CHECK: vpcmpistri + ; CHECK: movl + %res = call i32 @llvm.x86.sse42.pcmpistria128(<16 x i8> %a0, <16 x i8> %a1, i8 7) ; [#uses=1] + ret i32 %res +} +declare i32 @llvm.x86.sse42.pcmpistria128(<16 x i8>, <16 x i8>, i8) nounwind readnone + + +define i32 @test_x86_sse42_pcmpistric128(<16 x i8> %a0, <16 x i8> %a1) { + ; CHECK: vpcmpistri + ; CHECK: movl + %res = call i32 @llvm.x86.sse42.pcmpistric128(<16 x i8> %a0, <16 x i8> %a1, i8 7) ; [#uses=1] + ret i32 %res +} +declare i32 @llvm.x86.sse42.pcmpistric128(<16 x i8>, <16 x i8>, i8) nounwind readnone + + +define i32 @test_x86_sse42_pcmpistrio128(<16 x i8> %a0, <16 x i8> %a1) { + ; CHECK: vpcmpistri + ; CHECK: movl + %res = call i32 @llvm.x86.sse42.pcmpistrio128(<16 x i8> %a0, <16 x i8> %a1, i8 7) ; [#uses=1] + ret i32 %res +} +declare i32 @llvm.x86.sse42.pcmpistrio128(<16 x i8>, <16 x i8>, i8) nounwind readnone + + +define i32 @test_x86_sse42_pcmpistris128(<16 x i8> %a0, <16 x i8> %a1) { + ; CHECK: vpcmpistri + ; CHECK: movl + %res = call i32 @llvm.x86.sse42.pcmpistris128(<16 x i8> %a0, <16 x i8> %a1, i8 7) ; [#uses=1] + ret i32 %res +} +declare i32 @llvm.x86.sse42.pcmpistris128(<16 x i8>, <16 x i8>, i8) nounwind readnone + + +define i32 @test_x86_sse42_pcmpistriz128(<16 x i8> %a0, <16 x i8> %a1) { + ; CHECK: vpcmpistri + ; CHECK: movl + %res = call i32 @llvm.x86.sse42.pcmpistriz128(<16 x i8> %a0, <16 x i8> %a1, i8 7) ; [#uses=1] + ret i32 %res +} +declare i32 @llvm.x86.sse42.pcmpistriz128(<16 x i8>, <16 x i8>, i8) nounwind readnone + + +define <16 x i8> @test_x86_sse42_pcmpistrm128(<16 x i8> %a0, <16 x i8> %a1) { + ; CHECK: vpcmpistrm + %res = call <16 x i8> @llvm.x86.sse42.pcmpistrm128(<16 x i8> %a0, <16 x i8> %a1, i8 7) ; <<16 x i8>> [#uses=1] + ret <16 x i8> %res +} +declare <16 x i8> @llvm.x86.sse42.pcmpistrm128(<16 x i8>, <16 x i8>, i8) nounwind readnone + + +define <4 x float> @test_x86_sse_add_ss(<4 x float> %a0, <4 x float> %a1) { + ; CHECK: vaddss + %res = call <4 x float> @llvm.x86.sse.add.ss(<4 x float> %a0, <4 x float> %a1) ; <<4 x float>> [#uses=1] + ret <4 x float> %res +} +declare <4 x float> @llvm.x86.sse.add.ss(<4 x float>, <4 x float>) nounwind readnone + + +define <4 x float> @test_x86_sse_cmp_ps(<4 x float> %a0, <4 x float> %a1) { + ; CHECK: vcmpordps + %res = call <4 x float> @llvm.x86.sse.cmp.ps(<4 x float> %a0, <4 x float> %a1, i8 7) ; <<4 x float>> [#uses=1] + ret <4 x float> %res +} +declare <4 x float> @llvm.x86.sse.cmp.ps(<4 x float>, <4 x float>, i8) nounwind readnone + + +define <4 x float> @test_x86_sse_cmp_ss(<4 x float> %a0, <4 x float> %a1) { + ; CHECK: vcmpordss + %res = call <4 x float> @llvm.x86.sse.cmp.ss(<4 x float> %a0, <4 x float> %a1, i8 7) ; <<4 x float>> [#uses=1] + ret <4 x float> %res +} +declare <4 x float> @llvm.x86.sse.cmp.ss(<4 x float>, <4 x float>, i8) nounwind readnone + + +define i32 @test_x86_sse_comieq_ss(<4 x float> %a0, <4 x float> %a1) { + ; CHECK: vcomiss + ; CHECK: sete + ; CHECK: movzbl + %res = call i32 @llvm.x86.sse.comieq.ss(<4 x float> %a0, <4 x float> %a1) ; [#uses=1] + ret i32 %res +} +declare i32 @llvm.x86.sse.comieq.ss(<4 x float>, <4 x float>) nounwind readnone + + +define i32 @test_x86_sse_comige_ss(<4 x float> %a0, <4 x float> %a1) { + ; CHECK: vcomiss + ; CHECK: setae + ; CHECK: movzbl + %res = call i32 @llvm.x86.sse.comige.ss(<4 x float> %a0, <4 x float> %a1) ; [#uses=1] + ret i32 %res +} +declare i32 @llvm.x86.sse.comige.ss(<4 x float>, <4 x float>) nounwind readnone + + +define i32 @test_x86_sse_comigt_ss(<4 x float> %a0, <4 x float> %a1) { + ; CHECK: vcomiss + ; CHECK: seta + ; CHECK: movzbl + %res = call i32 @llvm.x86.sse.comigt.ss(<4 x float> %a0, <4 x float> %a1) ; [#uses=1] + ret i32 %res +} +declare i32 @llvm.x86.sse.comigt.ss(<4 x float>, <4 x float>) nounwind readnone + + +define i32 @test_x86_sse_comile_ss(<4 x float> %a0, <4 x float> %a1) { + ; CHECK: vcomiss + ; CHECK: setbe + ; CHECK: movzbl + %res = call i32 @llvm.x86.sse.comile.ss(<4 x float> %a0, <4 x float> %a1) ; [#uses=1] + ret i32 %res +} +declare i32 @llvm.x86.sse.comile.ss(<4 x float>, <4 x float>) nounwind readnone + + +define i32 @test_x86_sse_comilt_ss(<4 x float> %a0, <4 x float> %a1) { + ; CHECK: vcomiss + ; CHECK: setb + ; CHECK: movzbl + %res = call i32 @llvm.x86.sse.comilt.ss(<4 x float> %a0, <4 x float> %a1) ; [#uses=1] + ret i32 %res +} +declare i32 @llvm.x86.sse.comilt.ss(<4 x float>, <4 x float>) nounwind readnone + + +define i32 @test_x86_sse_comineq_ss(<4 x float> %a0, <4 x float> %a1) { + ; CHECK: vcomiss + ; CHECK: setne + ; CHECK: movzbl + %res = call i32 @llvm.x86.sse.comineq.ss(<4 x float> %a0, <4 x float> %a1) ; [#uses=1] + ret i32 %res +} +declare i32 @llvm.x86.sse.comineq.ss(<4 x float>, <4 x float>) nounwind readnone + + +define <4 x float> @test_x86_sse_cvtsi2ss(<4 x float> %a0) { + ; CHECK: movl + ; CHECK: vcvtsi2ss + %res = call <4 x float> @llvm.x86.sse.cvtsi2ss(<4 x float> %a0, i32 7) ; <<4 x float>> [#uses=1] + ret <4 x float> %res +} +declare <4 x float> @llvm.x86.sse.cvtsi2ss(<4 x float>, i32) nounwind readnone + + +define i32 @test_x86_sse_cvtss2si(<4 x float> %a0) { + ; CHECK: vcvtss2si + %res = call i32 @llvm.x86.sse.cvtss2si(<4 x float> %a0) ; [#uses=1] + ret i32 %res +} +declare i32 @llvm.x86.sse.cvtss2si(<4 x float>) nounwind readnone + + +define i32 @test_x86_sse_cvttss2si(<4 x float> %a0) { + ; CHECK: vcvttss2si + %res = call i32 @llvm.x86.sse.cvttss2si(<4 x float> %a0) ; [#uses=1] + ret i32 %res +} +declare i32 @llvm.x86.sse.cvttss2si(<4 x float>) nounwind readnone + + +define <4 x float> @test_x86_sse_div_ss(<4 x float> %a0, <4 x float> %a1) { + ; CHECK: vdivss + %res = call <4 x float> @llvm.x86.sse.div.ss(<4 x float> %a0, <4 x float> %a1) ; <<4 x float>> [#uses=1] + ret <4 x float> %res +} +declare <4 x float> @llvm.x86.sse.div.ss(<4 x float>, <4 x float>) nounwind readnone + + +define void @test_x86_sse_ldmxcsr(i8* %a0) { + ; CHECK: movl + ; CHECK: vldmxcsr + call void @llvm.x86.sse.ldmxcsr(i8* %a0) + ret void +} +declare void @llvm.x86.sse.ldmxcsr(i8*) nounwind + + +define <4 x float> @test_x86_sse_loadu_ps(i8* %a0) { + ; CHECK: movl + ; CHECK: vmovups + %res = call <4 x float> @llvm.x86.sse.loadu.ps(i8* %a0) ; <<4 x float>> [#uses=1] + ret <4 x float> %res +} +declare <4 x float> @llvm.x86.sse.loadu.ps(i8*) nounwind readonly + + +define <4 x float> @test_x86_sse_max_ps(<4 x float> %a0, <4 x float> %a1) { + ; CHECK: vmaxps + %res = call <4 x float> @llvm.x86.sse.max.ps(<4 x float> %a0, <4 x float> %a1) ; <<4 x float>> [#uses=1] + ret <4 x float> %res +} +declare <4 x float> @llvm.x86.sse.max.ps(<4 x float>, <4 x float>) nounwind readnone + + +define <4 x float> @test_x86_sse_max_ss(<4 x float> %a0, <4 x float> %a1) { + ; CHECK: vmaxss + %res = call <4 x float> @llvm.x86.sse.max.ss(<4 x float> %a0, <4 x float> %a1) ; <<4 x float>> [#uses=1] + ret <4 x float> %res +} +declare <4 x float> @llvm.x86.sse.max.ss(<4 x float>, <4 x float>) nounwind readnone + + +define <4 x float> @test_x86_sse_min_ps(<4 x float> %a0, <4 x float> %a1) { + ; CHECK: vminps + %res = call <4 x float> @llvm.x86.sse.min.ps(<4 x float> %a0, <4 x float> %a1) ; <<4 x float>> [#uses=1] + ret <4 x float> %res +} +declare <4 x float> @llvm.x86.sse.min.ps(<4 x float>, <4 x float>) nounwind readnone + + +define <4 x float> @test_x86_sse_min_ss(<4 x float> %a0, <4 x float> %a1) { + ; CHECK: vminss + %res = call <4 x float> @llvm.x86.sse.min.ss(<4 x float> %a0, <4 x float> %a1) ; <<4 x float>> [#uses=1] + ret <4 x float> %res +} +declare <4 x float> @llvm.x86.sse.min.ss(<4 x float>, <4 x float>) nounwind readnone + + +define i32 @test_x86_sse_movmsk_ps(<4 x float> %a0) { + ; CHECK: vmovmskps + %res = call i32 @llvm.x86.sse.movmsk.ps(<4 x float> %a0) ; [#uses=1] + ret i32 %res +} +declare i32 @llvm.x86.sse.movmsk.ps(<4 x float>) nounwind readnone + + +define void @test_x86_sse_movnt_ps(i8* %a0, <4 x float> %a1) { + ; CHECK: movl + ; CHECK: vmovntps + call void @llvm.x86.sse.movnt.ps(i8* %a0, <4 x float> %a1) + ret void +} +declare void @llvm.x86.sse.movnt.ps(i8*, <4 x float>) nounwind + + +define <4 x float> @test_x86_sse_mul_ss(<4 x float> %a0, <4 x float> %a1) { + ; CHECK: vmulss + %res = call <4 x float> @llvm.x86.sse.mul.ss(<4 x float> %a0, <4 x float> %a1) ; <<4 x float>> [#uses=1] + ret <4 x float> %res +} +declare <4 x float> @llvm.x86.sse.mul.ss(<4 x float>, <4 x float>) nounwind readnone + + +define <4 x float> @test_x86_sse_rcp_ps(<4 x float> %a0) { + ; CHECK: vrcpps + %res = call <4 x float> @llvm.x86.sse.rcp.ps(<4 x float> %a0) ; <<4 x float>> [#uses=1] + ret <4 x float> %res +} +declare <4 x float> @llvm.x86.sse.rcp.ps(<4 x float>) nounwind readnone + + +define <4 x float> @test_x86_sse_rcp_ss(<4 x float> %a0) { + ; CHECK: vrcpss + %res = call <4 x float> @llvm.x86.sse.rcp.ss(<4 x float> %a0) ; <<4 x float>> [#uses=1] + ret <4 x float> %res +} +declare <4 x float> @llvm.x86.sse.rcp.ss(<4 x float>) nounwind readnone + + +define <4 x float> @test_x86_sse_rsqrt_ps(<4 x float> %a0) { + ; CHECK: vrsqrtps + %res = call <4 x float> @llvm.x86.sse.rsqrt.ps(<4 x float> %a0) ; <<4 x float>> [#uses=1] + ret <4 x float> %res +} +declare <4 x float> @llvm.x86.sse.rsqrt.ps(<4 x float>) nounwind readnone + + +define <4 x float> @test_x86_sse_rsqrt_ss(<4 x float> %a0) { + ; CHECK: vrsqrtss + %res = call <4 x float> @llvm.x86.sse.rsqrt.ss(<4 x float> %a0) ; <<4 x float>> [#uses=1] + ret <4 x float> %res +} +declare <4 x float> @llvm.x86.sse.rsqrt.ss(<4 x float>) nounwind readnone + + +define <4 x float> @test_x86_sse_sqrt_ps(<4 x float> %a0) { + ; CHECK: vsqrtps + %res = call <4 x float> @llvm.x86.sse.sqrt.ps(<4 x float> %a0) ; <<4 x float>> [#uses=1] + ret <4 x float> %res +} +declare <4 x float> @llvm.x86.sse.sqrt.ps(<4 x float>) nounwind readnone + + +define <4 x float> @test_x86_sse_sqrt_ss(<4 x float> %a0) { + ; CHECK: vsqrtss + %res = call <4 x float> @llvm.x86.sse.sqrt.ss(<4 x float> %a0) ; <<4 x float>> [#uses=1] + ret <4 x float> %res +} +declare <4 x float> @llvm.x86.sse.sqrt.ss(<4 x float>) nounwind readnone + + +define void @test_x86_sse_stmxcsr(i8* %a0) { + ; CHECK: movl + ; CHECK: vstmxcsr + call void @llvm.x86.sse.stmxcsr(i8* %a0) + ret void +} +declare void @llvm.x86.sse.stmxcsr(i8*) nounwind + + +define void @test_x86_sse_storeu_ps(i8* %a0, <4 x float> %a1) { + ; CHECK: movl + ; CHECK: vmovups + call void @llvm.x86.sse.storeu.ps(i8* %a0, <4 x float> %a1) + ret void +} +declare void @llvm.x86.sse.storeu.ps(i8*, <4 x float>) nounwind + + +define <4 x float> @test_x86_sse_sub_ss(<4 x float> %a0, <4 x float> %a1) { + ; CHECK: vsubss + %res = call <4 x float> @llvm.x86.sse.sub.ss(<4 x float> %a0, <4 x float> %a1) ; <<4 x float>> [#uses=1] + ret <4 x float> %res +} +declare <4 x float> @llvm.x86.sse.sub.ss(<4 x float>, <4 x float>) nounwind readnone + + +define i32 @test_x86_sse_ucomieq_ss(<4 x float> %a0, <4 x float> %a1) { + ; CHECK: vucomiss + ; CHECK: sete + ; CHECK: movzbl + %res = call i32 @llvm.x86.sse.ucomieq.ss(<4 x float> %a0, <4 x float> %a1) ; [#uses=1] + ret i32 %res +} +declare i32 @llvm.x86.sse.ucomieq.ss(<4 x float>, <4 x float>) nounwind readnone + + +define i32 @test_x86_sse_ucomige_ss(<4 x float> %a0, <4 x float> %a1) { + ; CHECK: vucomiss + ; CHECK: setae + ; CHECK: movzbl + %res = call i32 @llvm.x86.sse.ucomige.ss(<4 x float> %a0, <4 x float> %a1) ; [#uses=1] + ret i32 %res +} +declare i32 @llvm.x86.sse.ucomige.ss(<4 x float>, <4 x float>) nounwind readnone + + +define i32 @test_x86_sse_ucomigt_ss(<4 x float> %a0, <4 x float> %a1) { + ; CHECK: vucomiss + ; CHECK: seta + ; CHECK: movzbl + %res = call i32 @llvm.x86.sse.ucomigt.ss(<4 x float> %a0, <4 x float> %a1) ; [#uses=1] + ret i32 %res +} +declare i32 @llvm.x86.sse.ucomigt.ss(<4 x float>, <4 x float>) nounwind readnone + + +define i32 @test_x86_sse_ucomile_ss(<4 x float> %a0, <4 x float> %a1) { + ; CHECK: vucomiss + ; CHECK: setbe + ; CHECK: movzbl + %res = call i32 @llvm.x86.sse.ucomile.ss(<4 x float> %a0, <4 x float> %a1) ; [#uses=1] + ret i32 %res +} +declare i32 @llvm.x86.sse.ucomile.ss(<4 x float>, <4 x float>) nounwind readnone + + +define i32 @test_x86_sse_ucomilt_ss(<4 x float> %a0, <4 x float> %a1) { + ; CHECK: vucomiss + ; CHECK: setb + ; CHECK: movzbl + %res = call i32 @llvm.x86.sse.ucomilt.ss(<4 x float> %a0, <4 x float> %a1) ; [#uses=1] + ret i32 %res +} +declare i32 @llvm.x86.sse.ucomilt.ss(<4 x float>, <4 x float>) nounwind readnone + + +define i32 @test_x86_sse_ucomineq_ss(<4 x float> %a0, <4 x float> %a1) { + ; CHECK: vucomiss + ; CHECK: setne + ; CHECK: movzbl + %res = call i32 @llvm.x86.sse.ucomineq.ss(<4 x float> %a0, <4 x float> %a1) ; [#uses=1] + ret i32 %res +} +declare i32 @llvm.x86.sse.ucomineq.ss(<4 x float>, <4 x float>) nounwind readnone + + +define <8 x i8> @test_x86_ssse3_pabs_b(<8 x i8> %a0) { + ; CHECK: vpabsb + %res = call <8 x i8> @llvm.x86.ssse3.pabs.b(<8 x i8> %a0) ; <<8 x i8>> [#uses=1] + ret <8 x i8> %res +} +declare <8 x i8> @llvm.x86.ssse3.pabs.b(<8 x i8>) nounwind readnone + + +define <16 x i8> @test_x86_ssse3_pabs_b_128(<16 x i8> %a0) { + ; CHECK: vpabsb + %res = call <16 x i8> @llvm.x86.ssse3.pabs.b.128(<16 x i8> %a0) ; <<16 x i8>> [#uses=1] + ret <16 x i8> %res +} +declare <16 x i8> @llvm.x86.ssse3.pabs.b.128(<16 x i8>) nounwind readnone + + +define <2 x i32> @test_x86_ssse3_pabs_d(<2 x i32> %a0) { + ; CHECK: vpabsd + %res = call <2 x i32> @llvm.x86.ssse3.pabs.d(<2 x i32> %a0) ; <<2 x i32>> [#uses=1] + ret <2 x i32> %res +} +declare <2 x i32> @llvm.x86.ssse3.pabs.d(<2 x i32>) nounwind readnone + + +define <4 x i32> @test_x86_ssse3_pabs_d_128(<4 x i32> %a0) { + ; CHECK: vpabsd + %res = call <4 x i32> @llvm.x86.ssse3.pabs.d.128(<4 x i32> %a0) ; <<4 x i32>> [#uses=1] + ret <4 x i32> %res +} +declare <4 x i32> @llvm.x86.ssse3.pabs.d.128(<4 x i32>) nounwind readnone + + +define <4 x i16> @test_x86_ssse3_pabs_w(<4 x i16> %a0) { + ; CHECK: vpabsw + %res = call <4 x i16> @llvm.x86.ssse3.pabs.w(<4 x i16> %a0) ; <<4 x i16>> [#uses=1] + ret <4 x i16> %res +} +declare <4 x i16> @llvm.x86.ssse3.pabs.w(<4 x i16>) nounwind readnone + + +define <8 x i16> @test_x86_ssse3_pabs_w_128(<8 x i16> %a0) { + ; CHECK: vpabsw + %res = call <8 x i16> @llvm.x86.ssse3.pabs.w.128(<8 x i16> %a0) ; <<8 x i16>> [#uses=1] + ret <8 x i16> %res +} +declare <8 x i16> @llvm.x86.ssse3.pabs.w.128(<8 x i16>) nounwind readnone + + +define <2 x i32> @test_x86_ssse3_phadd_d(<2 x i32> %a0, <2 x i32> %a1) { + ; CHECK: vphaddd + %res = call <2 x i32> @llvm.x86.ssse3.phadd.d(<2 x i32> %a0, <2 x i32> %a1) ; <<2 x i32>> [#uses=1] + ret <2 x i32> %res +} +declare <2 x i32> @llvm.x86.ssse3.phadd.d(<2 x i32>, <2 x i32>) nounwind readnone + + +define <4 x i32> @test_x86_ssse3_phadd_d_128(<4 x i32> %a0, <4 x i32> %a1) { + ; CHECK: vphaddd + %res = call <4 x i32> @llvm.x86.ssse3.phadd.d.128(<4 x i32> %a0, <4 x i32> %a1) ; <<4 x i32>> [#uses=1] + ret <4 x i32> %res +} +declare <4 x i32> @llvm.x86.ssse3.phadd.d.128(<4 x i32>, <4 x i32>) nounwind readnone + + +define <4 x i16> @test_x86_ssse3_phadd_sw(<4 x i16> %a0, <4 x i16> %a1) { + ; CHECK: vphaddsw + %res = call <4 x i16> @llvm.x86.ssse3.phadd.sw(<4 x i16> %a0, <4 x i16> %a1) ; <<4 x i16>> [#uses=1] + ret <4 x i16> %res +} +declare <4 x i16> @llvm.x86.ssse3.phadd.sw(<4 x i16>, <4 x i16>) nounwind readnone + + +define <4 x i32> @test_x86_ssse3_phadd_sw_128(<4 x i32> %a0, <4 x i32> %a1) { + ; CHECK: vphaddsw + %res = call <4 x i32> @llvm.x86.ssse3.phadd.sw.128(<4 x i32> %a0, <4 x i32> %a1) ; <<4 x i32>> [#uses=1] + ret <4 x i32> %res +} +declare <4 x i32> @llvm.x86.ssse3.phadd.sw.128(<4 x i32>, <4 x i32>) nounwind readnone + + +define <4 x i16> @test_x86_ssse3_phadd_w(<4 x i16> %a0, <4 x i16> %a1) { + ; CHECK: vphaddw + %res = call <4 x i16> @llvm.x86.ssse3.phadd.w(<4 x i16> %a0, <4 x i16> %a1) ; <<4 x i16>> [#uses=1] + ret <4 x i16> %res +} +declare <4 x i16> @llvm.x86.ssse3.phadd.w(<4 x i16>, <4 x i16>) nounwind readnone + + +define <8 x i16> @test_x86_ssse3_phadd_w_128(<8 x i16> %a0, <8 x i16> %a1) { + ; CHECK: vphaddw + %res = call <8 x i16> @llvm.x86.ssse3.phadd.w.128(<8 x i16> %a0, <8 x i16> %a1) ; <<8 x i16>> [#uses=1] + ret <8 x i16> %res +} +declare <8 x i16> @llvm.x86.ssse3.phadd.w.128(<8 x i16>, <8 x i16>) nounwind readnone + + +define <2 x i32> @test_x86_ssse3_phsub_d(<2 x i32> %a0, <2 x i32> %a1) { + ; CHECK: vphsubd + %res = call <2 x i32> @llvm.x86.ssse3.phsub.d(<2 x i32> %a0, <2 x i32> %a1) ; <<2 x i32>> [#uses=1] + ret <2 x i32> %res +} +declare <2 x i32> @llvm.x86.ssse3.phsub.d(<2 x i32>, <2 x i32>) nounwind readnone + + +define <4 x i32> @test_x86_ssse3_phsub_d_128(<4 x i32> %a0, <4 x i32> %a1) { + ; CHECK: vphsubd + %res = call <4 x i32> @llvm.x86.ssse3.phsub.d.128(<4 x i32> %a0, <4 x i32> %a1) ; <<4 x i32>> [#uses=1] + ret <4 x i32> %res +} +declare <4 x i32> @llvm.x86.ssse3.phsub.d.128(<4 x i32>, <4 x i32>) nounwind readnone + + +define <4 x i16> @test_x86_ssse3_phsub_sw(<4 x i16> %a0, <4 x i16> %a1) { + ; CHECK: vphsubsw + %res = call <4 x i16> @llvm.x86.ssse3.phsub.sw(<4 x i16> %a0, <4 x i16> %a1) ; <<4 x i16>> [#uses=1] + ret <4 x i16> %res +} +declare <4 x i16> @llvm.x86.ssse3.phsub.sw(<4 x i16>, <4 x i16>) nounwind readnone + + +define <8 x i16> @test_x86_ssse3_phsub_sw_128(<8 x i16> %a0, <8 x i16> %a1) { + ; CHECK: vphsubsw + %res = call <8 x i16> @llvm.x86.ssse3.phsub.sw.128(<8 x i16> %a0, <8 x i16> %a1) ; <<8 x i16>> [#uses=1] + ret <8 x i16> %res +} +declare <8 x i16> @llvm.x86.ssse3.phsub.sw.128(<8 x i16>, <8 x i16>) nounwind readnone + + +define <4 x i16> @test_x86_ssse3_phsub_w(<4 x i16> %a0, <4 x i16> %a1) { + ; CHECK: vphsubw + %res = call <4 x i16> @llvm.x86.ssse3.phsub.w(<4 x i16> %a0, <4 x i16> %a1) ; <<4 x i16>> [#uses=1] + ret <4 x i16> %res +} +declare <4 x i16> @llvm.x86.ssse3.phsub.w(<4 x i16>, <4 x i16>) nounwind readnone + + +define <8 x i16> @test_x86_ssse3_phsub_w_128(<8 x i16> %a0, <8 x i16> %a1) { + ; CHECK: vphsubw + %res = call <8 x i16> @llvm.x86.ssse3.phsub.w.128(<8 x i16> %a0, <8 x i16> %a1) ; <<8 x i16>> [#uses=1] + ret <8 x i16> %res +} +declare <8 x i16> @llvm.x86.ssse3.phsub.w.128(<8 x i16>, <8 x i16>) nounwind readnone + + +define <4 x i16> @test_x86_ssse3_pmadd_ub_sw(<4 x i16> %a0, <4 x i16> %a1) { + ; CHECK: vpmaddubsw + %res = call <4 x i16> @llvm.x86.ssse3.pmadd.ub.sw(<4 x i16> %a0, <4 x i16> %a1) ; <<4 x i16>> [#uses=1] + ret <4 x i16> %res +} +declare <4 x i16> @llvm.x86.ssse3.pmadd.ub.sw(<4 x i16>, <4 x i16>) nounwind readnone + + +define <8 x i16> @test_x86_ssse3_pmadd_ub_sw_128(<8 x i16> %a0, <8 x i16> %a1) { + ; CHECK: vpmaddubsw + %res = call <8 x i16> @llvm.x86.ssse3.pmadd.ub.sw.128(<8 x i16> %a0, <8 x i16> %a1) ; <<8 x i16>> [#uses=1] + ret <8 x i16> %res +} +declare <8 x i16> @llvm.x86.ssse3.pmadd.ub.sw.128(<8 x i16>, <8 x i16>) nounwind readnone + + +define <4 x i16> @test_x86_ssse3_pmul_hr_sw(<4 x i16> %a0, <4 x i16> %a1) { + ; CHECK: vpmulhrsw + %res = call <4 x i16> @llvm.x86.ssse3.pmul.hr.sw(<4 x i16> %a0, <4 x i16> %a1) ; <<4 x i16>> [#uses=1] + ret <4 x i16> %res +} +declare <4 x i16> @llvm.x86.ssse3.pmul.hr.sw(<4 x i16>, <4 x i16>) nounwind readnone + + +define <8 x i16> @test_x86_ssse3_pmul_hr_sw_128(<8 x i16> %a0, <8 x i16> %a1) { + ; CHECK: vpmulhrsw + %res = call <8 x i16> @llvm.x86.ssse3.pmul.hr.sw.128(<8 x i16> %a0, <8 x i16> %a1) ; <<8 x i16>> [#uses=1] + ret <8 x i16> %res +} +declare <8 x i16> @llvm.x86.ssse3.pmul.hr.sw.128(<8 x i16>, <8 x i16>) nounwind readnone + + +define <8 x i8> @test_x86_ssse3_pshuf_b(<8 x i8> %a0, <8 x i8> %a1) { + ; CHECK: vpshufb + %res = call <8 x i8> @llvm.x86.ssse3.pshuf.b(<8 x i8> %a0, <8 x i8> %a1) ; <<8 x i8>> [#uses=1] + ret <8 x i8> %res +} +declare <8 x i8> @llvm.x86.ssse3.pshuf.b(<8 x i8>, <8 x i8>) nounwind readnone + + +define <16 x i8> @test_x86_ssse3_pshuf_b_128(<16 x i8> %a0, <16 x i8> %a1) { + ; CHECK: vpshufb + %res = call <16 x i8> @llvm.x86.ssse3.pshuf.b.128(<16 x i8> %a0, <16 x i8> %a1) ; <<16 x i8>> [#uses=1] + ret <16 x i8> %res +} +declare <16 x i8> @llvm.x86.ssse3.pshuf.b.128(<16 x i8>, <16 x i8>) nounwind readnone + + +define <8 x i8> @test_x86_ssse3_psign_b(<8 x i8> %a0, <8 x i8> %a1) { + ; CHECK: vpsignb + %res = call <8 x i8> @llvm.x86.ssse3.psign.b(<8 x i8> %a0, <8 x i8> %a1) ; <<8 x i8>> [#uses=1] + ret <8 x i8> %res +} +declare <8 x i8> @llvm.x86.ssse3.psign.b(<8 x i8>, <8 x i8>) nounwind readnone + + +define <16 x i8> @test_x86_ssse3_psign_b_128(<16 x i8> %a0, <16 x i8> %a1) { + ; CHECK: vpsignb + %res = call <16 x i8> @llvm.x86.ssse3.psign.b.128(<16 x i8> %a0, <16 x i8> %a1) ; <<16 x i8>> [#uses=1] + ret <16 x i8> %res +} +declare <16 x i8> @llvm.x86.ssse3.psign.b.128(<16 x i8>, <16 x i8>) nounwind readnone + + +define <2 x i32> @test_x86_ssse3_psign_d(<2 x i32> %a0, <2 x i32> %a1) { + ; CHECK: vpsignd + %res = call <2 x i32> @llvm.x86.ssse3.psign.d(<2 x i32> %a0, <2 x i32> %a1) ; <<2 x i32>> [#uses=1] + ret <2 x i32> %res +} +declare <2 x i32> @llvm.x86.ssse3.psign.d(<2 x i32>, <2 x i32>) nounwind readnone + + +define <4 x i32> @test_x86_ssse3_psign_d_128(<4 x i32> %a0, <4 x i32> %a1) { + ; CHECK: vpsignd + %res = call <4 x i32> @llvm.x86.ssse3.psign.d.128(<4 x i32> %a0, <4 x i32> %a1) ; <<4 x i32>> [#uses=1] + ret <4 x i32> %res +} +declare <4 x i32> @llvm.x86.ssse3.psign.d.128(<4 x i32>, <4 x i32>) nounwind readnone + + +define <4 x i16> @test_x86_ssse3_psign_w(<4 x i16> %a0, <4 x i16> %a1) { + ; CHECK: vpsignw + %res = call <4 x i16> @llvm.x86.ssse3.psign.w(<4 x i16> %a0, <4 x i16> %a1) ; <<4 x i16>> [#uses=1] + ret <4 x i16> %res +} +declare <4 x i16> @llvm.x86.ssse3.psign.w(<4 x i16>, <4 x i16>) nounwind readnone + + +define <8 x i16> @test_x86_ssse3_psign_w_128(<8 x i16> %a0, <8 x i16> %a1) { + ; CHECK: vpsignw + %res = call <8 x i16> @llvm.x86.ssse3.psign.w.128(<8 x i16> %a0, <8 x i16> %a1) ; <<8 x i16>> [#uses=1] + ret <8 x i16> %res +} +declare <8 x i16> @llvm.x86.ssse3.psign.w.128(<8 x i16>, <8 x i16>) nounwind readnone + Added: llvm/trunk/test/CodeGen/X86/avx-intrinsics-x86_64.ll URL: http://llvm.org/viewvc/llvm-project/llvm/trunk/test/CodeGen/X86/avx-intrinsics-x86_64.ll?rev=110833&view=auto ============================================================================== --- llvm/trunk/test/CodeGen/X86/avx-intrinsics-x86_64.ll (added) +++ llvm/trunk/test/CodeGen/X86/avx-intrinsics-x86_64.ll Wed Aug 11 12:39:23 2010 @@ -0,0 +1,50 @@ +; RUN: llc < %s -mtriple=x86_64-apple-darwin -march=x86-64 -mcpu=corei7 -mattr=avx | FileCheck %s + +define i64 @test_x86_sse2_cvtsd2si64(<2 x double> %a0) { + ; CHECK: vcvtsd2si + %res = call i64 @llvm.x86.sse2.cvtsd2si64(<2 x double> %a0) ; [#uses=1] + ret i64 %res +} +declare i64 @llvm.x86.sse2.cvtsd2si64(<2 x double>) nounwind readnone + + +define <2 x double> @test_x86_sse2_cvtsi642sd(<2 x double> %a0, i64 %a1) { + ; CHECK: vcvtsi2sd + %res = call <2 x double> @llvm.x86.sse2.cvtsi642sd(<2 x double> %a0, i64 %a1) ; <<2 x double>> [#uses=1] + ret <2 x double> %res +} +declare <2 x double> @llvm.x86.sse2.cvtsi642sd(<2 x double>, i64) nounwind readnone + + +define i64 @test_x86_sse2_cvttsd2si64(<2 x double> %a0) { + ; CHECK: vcvttss2si + %res = call i64 @llvm.x86.sse2.cvttsd2si64(<2 x double> %a0) ; [#uses=1] + ret i64 %res +} +declare i64 @llvm.x86.sse2.cvttsd2si64(<2 x double>) nounwind readnone + + +define i64 @test_x86_sse_cvtss2si64(<4 x float> %a0) { + ; CHECK: vcvtss2si + %res = call i64 @llvm.x86.sse.cvtss2si64(<4 x float> %a0) ; [#uses=1] + ret i64 %res +} +declare i64 @llvm.x86.sse.cvtss2si64(<4 x float>) nounwind readnone + + +define <4 x float> @test_x86_sse_cvtsi642ss(<4 x float> %a0, i64 %a1) { + ; CHECK: vcvtsi2ss + %res = call <4 x float> @llvm.x86.sse.cvtsi642ss(<4 x float> %a0, i64 %a1) ; <<4 x float>> [#uses=1] + ret <4 x float> %res +} +declare <4 x float> @llvm.x86.sse.cvtsi642ss(<4 x float>, i64) nounwind readnone + + +define i64 @test_x86_sse_cvttss2si64(<4 x float> %a0) { + ; CHECK: vcvttss2si + %res = call i64 @llvm.x86.sse.cvttss2si64(<4 x float> %a0) ; [#uses=1] + ret i64 %res +} +declare i64 @llvm.x86.sse.cvttss2si64(<4 x float>) nounwind readnone + + From clattner at apple.com Wed Aug 11 13:08:42 2010 From: clattner at apple.com (Chris Lattner) Date: Wed, 11 Aug 2010 11:08:42 -0700 Subject: [llvm-commits] [llvm] r110576 - in /llvm/trunk: lib/Target/CellSPU/SPUISelLowering.cpp lib/Target/CellSPU/SPUISelLowering.h lib/Target/CellSPU/SPUInstrInfo.td lib/Target/CellSPU/SPUNodes.td lib/Target/CellSPU/SPURegisterInfo.cpp test/CodeGen/CellSP... In-Reply-To: <1281525584.1870.13.camel@LLVMbuilder.research.nokia.com> References: <20100809163301.235462A6C12C@llvm.org> <25685170-45BA-47F0-AF9D-0D0600748145@apple.com> <1281437591.1796.146.camel@LLVMbuilder.research.nokia.com> <1281525584.1870.13.camel@LLVMbuilder.research.nokia.com> Message-ID: <74891C6D-F84B-4906-95E9-CB630FE09DE2@apple.com> On Aug 11, 2010, at 4:19 AM, Kalle.Raiskila at nokia.com wrote: > On Tue, 2010-08-10 at 19:12 +0200, Bob Wilson wrote: >> On Aug 10, 2010, at 3:53 AM, Kalle.Raiskila at nokia.com wrote: >>> b) to the best of my understanding, v2i32 has to be legal if it is to be >>> used in return values and function parameters. >> >> The types of return values and function parameters are also legalized. If you pass an argument with a non-legal type, it should be promoted or expanded to make it legal. > > The problem here was that v2i32 gets expanded to two i32s instead of > promoted to one v4i32. Is it possible to force promotion somehow? This is something that is on my plate to implement, but again, you can handle this in the frontend. > Ok, I'll have a look. Just removing the v2i32 code from the SPU backend > is simple. Getting it to be promoted instead of expanded... lets see... Vector widening should already work (it does on x86 at least) for everything except arguments and return values. > I wonder if I should have a go at trying to get i32 promoted to v4i32 at > the same time :) While interesting, I'd steer away from that. There are assumptions throughout the code generator that the pointer type is an integer etc. >> Beyond Bob's post of "it should work", this is something that can >> easily be handled by the frontend (by having the frontend lower v2i32 >> arg/ret values into v4i32 values with shufflevector to extract). This >> is how the X86-64 backend handles its often-crazy ABI constraints. > > Certainly, when strict ABI compliance is required the frontend should do > this lowering. However, not asserting on code that uses LLVM native > types (including v2i32) would be nice. Especially as v2i32 is so easily > mapped to v4i32. Yes, I agree completely. This is something I'd also like on X86-64. It's on my todo list, but sadly my todo list isn't getting a lot of attention lately. -Chris From bob.wilson at apple.com Wed Aug 11 13:11:17 2010 From: bob.wilson at apple.com (Bob Wilson) Date: Wed, 11 Aug 2010 11:11:17 -0700 Subject: [llvm-commits] [llvm] r110576 - in /llvm/trunk: lib/Target/CellSPU/SPUISelLowering.cpp lib/Target/CellSPU/SPUISelLowering.h lib/Target/CellSPU/SPUInstrInfo.td lib/Target/CellSPU/SPUNodes.td lib/Target/CellSPU/SPURegisterInfo.cpp test/CodeGen/CellSP... In-Reply-To: <1281525584.1870.13.camel@LLVMbuilder.research.nokia.com> References: <20100809163301.235462A6C12C@llvm.org> <25685170-45BA-47F0-AF9D-0D0600748145@apple.com> <1281437591.1796.146.camel@LLVMbuilder.research.nokia.com> <1281525584.1870.13.camel@LLVMbuilder.research.nokia.com> Message-ID: On Aug 11, 2010, at 4:19 AM, Kalle.Raiskila at nokia.com wrote: > On Tue, 2010-08-10 at 19:12 +0200, Bob Wilson wrote: >> On Aug 10, 2010, at 3:53 AM, Kalle.Raiskila at nokia.com wrote: >>> b) to the best of my understanding, v2i32 has to be legal if it is to be >>> used in return values and function parameters. >> >> The types of return values and function parameters are also legalized. If you pass an argument with a non-legal type, it should be promoted or expanded to make it legal. > > The problem here was that v2i32 gets expanded to two i32s instead of > promoted to one v4i32. Is it possible to force promotion somehow? The following code from TargetLowering::computeRegisterProperties() suggests that promotion should be the default: // Determine if there is a legal wider type. bool IsLegalWiderType = false; EVT EltVT = VT.getVectorElementType(); unsigned NElts = VT.getVectorNumElements(); for (unsigned nVT = i+1; nVT <= MVT::LAST_VECTOR_VALUETYPE; ++nVT) { EVT SVT = (MVT::SimpleValueType)nVT; if (isTypeSynthesizable(SVT) && SVT.getVectorElementType() == EltVT && SVT.getVectorNumElements() > NElts && NElts != 1) { TransformToType[i] = SVT; ValueTypeActions.setTypeAction(VT, Promote); IsLegalWiderType = true; break; } } If that's not happening, you might want to step through that code and see why not. Otherwise, you can specify promote vs. expand for each operation via TargetLowering::setOperationAction(). > > >> >> But, if your target doesn't have any scalar >> 32-bit registers, passing i32 arguments is going to be a pretty >> "interesting" regardless.... > > This is indeed the case. SPU's native wordlength is 32, but all general > purpose registers are 4-way vectors (128bit). And all instructions are > SIMD vector instructions. Where i32s are needed (e.g. memory address) > only the first slot of the vector register is used. This is the way i32s > are "emulated" in the SPU backend. And this is how I tried to "emulate" > v2i32s too. > > "Interesting", eih? :) Ugh. I expect you'll have to fight against a lot of implicit assumptions that i32 is legal. Good luck.... From gohman at apple.com Wed Aug 11 13:14:00 2010 From: gohman at apple.com (Dan Gohman) Date: Wed, 11 Aug 2010 18:14:00 -0000 Subject: [llvm-commits] [llvm] r110835 - /llvm/trunk/lib/Target/X86/X86ISelLowering.cpp Message-ID: <20100811181400.98A1E2A6C12C@llvm.org> Author: djg Date: Wed Aug 11 13:14:00 2010 New Revision: 110835 URL: http://llvm.org/viewvc/llvm-project?rev=110835&view=rev Log: Use ISD::ADD instead of ISD::SUB with a negated constant. This avoids trouble if the return type of TD->getPointerSize() is changed to something which doesn't promote to a signed type, and is simpler anyway. Also, use getCopyFromReg instead of getRegister to read a physical register's value. Modified: llvm/trunk/lib/Target/X86/X86ISelLowering.cpp Modified: llvm/trunk/lib/Target/X86/X86ISelLowering.cpp URL: http://llvm.org/viewvc/llvm-project/llvm/trunk/lib/Target/X86/X86ISelLowering.cpp?rev=110835&r1=110834&r2=110835&view=diff ============================================================================== --- llvm/trunk/lib/Target/X86/X86ISelLowering.cpp (original) +++ llvm/trunk/lib/Target/X86/X86ISelLowering.cpp Wed Aug 11 13:14:00 2010 @@ -7210,12 +7210,13 @@ SDValue Handler = Op.getOperand(2); DebugLoc dl = Op.getDebugLoc(); - SDValue Frame = DAG.getRegister(Subtarget->is64Bit() ? X86::RBP : X86::EBP, - getPointerTy()); + SDValue Frame = DAG.getCopyFromReg(DAG.getEntryNode(), dl, + Subtarget->is64Bit() ? X86::RBP : X86::EBP, + getPointerTy()); unsigned StoreAddrReg = (Subtarget->is64Bit() ? X86::RCX : X86::ECX); - SDValue StoreAddr = DAG.getNode(ISD::SUB, dl, getPointerTy(), Frame, - DAG.getIntPtrConstant(-TD->getPointerSize())); + SDValue StoreAddr = DAG.getNode(ISD::ADD, dl, getPointerTy(), Frame, + DAG.getIntPtrConstant(TD->getPointerSize())); StoreAddr = DAG.getNode(ISD::ADD, dl, getPointerTy(), StoreAddr, Offset); Chain = DAG.getStore(Chain, dl, Handler, StoreAddr, NULL, 0, false, false, 0); Chain = DAG.getCopyToReg(Chain, dl, StoreAddrReg, StoreAddr); From gohman at apple.com Wed Aug 11 13:15:01 2010 From: gohman at apple.com (Dan Gohman) Date: Wed, 11 Aug 2010 18:15:01 -0000 Subject: [llvm-commits] [llvm] r110836 - in /llvm/trunk: include/llvm/Target/TargetData.h lib/Target/TargetData.cpp Message-ID: <20100811181501.3DC7D2A6C12C@llvm.org> Author: djg Date: Wed Aug 11 13:15:01 2010 New Revision: 110836 URL: http://llvm.org/viewvc/llvm-project?rev=110836&view=rev Log: Don't use unsigned char for alignments in TargetData. There aren't that many of these things, so the memory savings isn't significant, and there are now situations where there can be alignments greater than 128. Modified: llvm/trunk/include/llvm/Target/TargetData.h llvm/trunk/lib/Target/TargetData.cpp Modified: llvm/trunk/include/llvm/Target/TargetData.h URL: http://llvm.org/viewvc/llvm-project/llvm/trunk/include/llvm/Target/TargetData.h?rev=110836&r1=110835&r2=110836&view=diff ============================================================================== --- llvm/trunk/include/llvm/Target/TargetData.h (original) +++ llvm/trunk/include/llvm/Target/TargetData.h Wed Aug 11 13:15:01 2010 @@ -50,13 +50,13 @@ /// padding and make the structure slightly more cache friendly. struct TargetAlignElem { AlignTypeEnum AlignType : 8; //< Alignment type (AlignTypeEnum) - unsigned char ABIAlign; //< ABI alignment for this type/bitw - unsigned char PrefAlign; //< Pref. alignment for this type/bitw + unsigned ABIAlign; //< ABI alignment for this type/bitw + unsigned PrefAlign; //< Pref. alignment for this type/bitw uint32_t TypeBitWidth; //< Type bit width /// Initializer - static TargetAlignElem get(AlignTypeEnum align_type, unsigned char abi_align, - unsigned char pref_align, uint32_t bit_width); + static TargetAlignElem get(AlignTypeEnum align_type, unsigned abi_align, + unsigned pref_align, uint32_t bit_width); /// Equality predicate bool operator==(const TargetAlignElem &rhs) const; }; @@ -64,9 +64,9 @@ class TargetData : public ImmutablePass { private: bool LittleEndian; ///< Defaults to false - unsigned char PointerMemSize; ///< Pointer size in bytes - unsigned char PointerABIAlign; ///< Pointer ABI alignment - unsigned char PointerPrefAlign; ///< Pointer preferred alignment + unsigned PointerMemSize; ///< Pointer size in bytes + unsigned PointerABIAlign; ///< Pointer ABI alignment + unsigned PointerPrefAlign; ///< Pointer preferred alignment SmallVector LegalIntWidths; ///< Legal Integers. @@ -86,12 +86,12 @@ mutable void *LayoutMap; //! Set/initialize target alignments - void setAlignment(AlignTypeEnum align_type, unsigned char abi_align, - unsigned char pref_align, uint32_t bit_width); + void setAlignment(AlignTypeEnum align_type, unsigned abi_align, + unsigned pref_align, uint32_t bit_width); unsigned getAlignmentInfo(AlignTypeEnum align_type, uint32_t bit_width, bool ABIAlign, const Type *Ty) const; //! Internal helper method that returns requested alignment for type. - unsigned char getAlignment(const Type *Ty, bool abi_or_pref) const; + unsigned getAlignment(const Type *Ty, bool abi_or_pref) const; /// Valid alignment predicate. /// @@ -161,13 +161,13 @@ } /// Target pointer alignment - unsigned char getPointerABIAlignment() const { return PointerABIAlign; } + unsigned getPointerABIAlignment() const { return PointerABIAlign; } /// Return target's alignment for stack-based pointers - unsigned char getPointerPrefAlignment() const { return PointerPrefAlign; } + unsigned getPointerPrefAlignment() const { return PointerPrefAlign; } /// Target pointer size - unsigned char getPointerSize() const { return PointerMemSize; } + unsigned getPointerSize() const { return PointerMemSize; } /// Target pointer size, in bits - unsigned char getPointerSizeInBits() const { return 8*PointerMemSize; } + unsigned getPointerSizeInBits() const { return 8*PointerMemSize; } /// Size examples: /// @@ -223,26 +223,26 @@ /// getABITypeAlignment - Return the minimum ABI-required alignment for the /// specified type. - unsigned char getABITypeAlignment(const Type *Ty) const; + unsigned getABITypeAlignment(const Type *Ty) const; /// getABIIntegerTypeAlignment - Return the minimum ABI-required alignment for /// an integer type of the specified bitwidth. - unsigned char getABIIntegerTypeAlignment(unsigned BitWidth) const; + unsigned getABIIntegerTypeAlignment(unsigned BitWidth) const; /// getCallFrameTypeAlignment - Return the minimum ABI-required alignment /// for the specified type when it is part of a call frame. - unsigned char getCallFrameTypeAlignment(const Type *Ty) const; + unsigned getCallFrameTypeAlignment(const Type *Ty) const; /// getPrefTypeAlignment - Return the preferred stack/global alignment for /// the specified type. This is always at least as good as the ABI alignment. - unsigned char getPrefTypeAlignment(const Type *Ty) const; + unsigned getPrefTypeAlignment(const Type *Ty) const; /// getPreferredTypeAlignmentShift - Return the preferred alignment for the /// specified type, returned as log2 of the value (a shift amount). /// - unsigned char getPreferredTypeAlignmentShift(const Type *Ty) const; + unsigned getPreferredTypeAlignmentShift(const Type *Ty) const; /// getIntPtrType - Return an unsigned integer type that is the same size or /// greater to the host pointer size. Modified: llvm/trunk/lib/Target/TargetData.cpp URL: http://llvm.org/viewvc/llvm-project/llvm/trunk/lib/Target/TargetData.cpp?rev=110836&r1=110835&r2=110836&view=diff ============================================================================== --- llvm/trunk/lib/Target/TargetData.cpp (original) +++ llvm/trunk/lib/Target/TargetData.cpp Wed Aug 11 13:15:01 2010 @@ -97,8 +97,8 @@ //===----------------------------------------------------------------------===// TargetAlignElem -TargetAlignElem::get(AlignTypeEnum align_type, unsigned char abi_align, - unsigned char pref_align, uint32_t bit_width) { +TargetAlignElem::get(AlignTypeEnum align_type, unsigned abi_align, + unsigned pref_align, uint32_t bit_width) { assert(abi_align <= pref_align && "Preferred alignment worse than ABI!"); TargetAlignElem retval; retval.AlignType = align_type; @@ -196,10 +196,10 @@ } unsigned Size = getInt(Specifier.substr(1)); Split = Token.split(':'); - unsigned char ABIAlign = getInt(Split.first) / 8; + unsigned ABIAlign = getInt(Split.first) / 8; Split = Split.second.split(':'); - unsigned char PrefAlign = getInt(Split.first) / 8; + unsigned PrefAlign = getInt(Split.first) / 8; if (PrefAlign == 0) PrefAlign = ABIAlign; setAlignment(AlignType, ABIAlign, PrefAlign, Size); @@ -237,8 +237,8 @@ } void -TargetData::setAlignment(AlignTypeEnum align_type, unsigned char abi_align, - unsigned char pref_align, uint32_t bit_width) { +TargetData::setAlignment(AlignTypeEnum align_type, unsigned abi_align, + unsigned pref_align, uint32_t bit_width) { assert(abi_align <= pref_align && "Preferred alignment worse than ABI!"); for (unsigned i = 0, e = Alignments.size(); i != e; ++i) { if (Alignments[i].AlignType == align_type && @@ -495,7 +495,7 @@ Get the ABI (\a abi_or_pref == true) or preferred alignment (\a abi_or_pref == false) for the requested type \a Ty. */ -unsigned char TargetData::getAlignment(const Type *Ty, bool abi_or_pref) const { +unsigned TargetData::getAlignment(const Type *Ty, bool abi_or_pref) const { int AlignType = -1; assert(Ty->isSized() && "Cannot getTypeInfo() on a type that is unsized!"); @@ -517,7 +517,7 @@ // Get the layout annotation... which is lazily created on demand. const StructLayout *Layout = getStructLayout(cast(Ty)); unsigned Align = getAlignmentInfo(AGGREGATE_ALIGN, 0, abi_or_pref, Ty); - return std::max(Align, (unsigned)Layout->getAlignment()); + return std::max(Align, Layout->getAlignment()); } case Type::UnionTyID: { const UnionType *UnTy = cast(Ty); @@ -526,7 +526,7 @@ // Unions need the maximum alignment of all their entries for (UnionType::element_iterator i = UnTy->element_begin(), e = UnTy->element_end(); i != e; ++i) { - Align = std::max(Align, (unsigned)getAlignment(*i, abi_or_pref)); + Align = std::max(Align, getAlignment(*i, abi_or_pref)); } return Align; } @@ -555,18 +555,18 @@ abi_or_pref, Ty); } -unsigned char TargetData::getABITypeAlignment(const Type *Ty) const { +unsigned TargetData::getABITypeAlignment(const Type *Ty) const { return getAlignment(Ty, true); } /// getABIIntegerTypeAlignment - Return the minimum ABI-required alignment for /// an integer type of the specified bitwidth. -unsigned char TargetData::getABIIntegerTypeAlignment(unsigned BitWidth) const { +unsigned TargetData::getABIIntegerTypeAlignment(unsigned BitWidth) const { return getAlignmentInfo(INTEGER_ALIGN, BitWidth, true, 0); } -unsigned char TargetData::getCallFrameTypeAlignment(const Type *Ty) const { +unsigned TargetData::getCallFrameTypeAlignment(const Type *Ty) const { for (unsigned i = 0, e = Alignments.size(); i != e; ++i) if (Alignments[i].AlignType == STACK_ALIGN) return Alignments[i].ABIAlign; @@ -574,12 +574,12 @@ return getABITypeAlignment(Ty); } -unsigned char TargetData::getPrefTypeAlignment(const Type *Ty) const { +unsigned TargetData::getPrefTypeAlignment(const Type *Ty) const { return getAlignment(Ty, false); } -unsigned char TargetData::getPreferredTypeAlignmentShift(const Type *Ty) const { - unsigned Align = (unsigned) getPrefTypeAlignment(Ty); +unsigned TargetData::getPreferredTypeAlignmentShift(const Type *Ty) const { + unsigned Align = getPrefTypeAlignment(Ty); assert(!(Align & (Align-1)) && "Alignment is not a power of two!"); return Log2_32(Align); } From grosbach at apple.com Wed Aug 11 13:22:46 2010 From: grosbach at apple.com (Jim Grosbach) Date: Wed, 11 Aug 2010 18:22:46 -0000 Subject: [llvm-commits] [llvm-gcc-4.2] r110837 - in /llvm-gcc-4.2/trunk/gcc/config/arm: arm-cores.def arm.c arm.h darwin.h Message-ID: <20100811182246.D25782A6C12C@llvm.org> Author: grosbach Date: Wed Aug 11 13:22:46 2010 New Revision: 110837 URL: http://llvm.org/viewvc/llvm-project?rev=110837&view=rev Log: pass along reasonable cortex-m0 processor options to the back end. Modified: llvm-gcc-4.2/trunk/gcc/config/arm/arm-cores.def llvm-gcc-4.2/trunk/gcc/config/arm/arm.c llvm-gcc-4.2/trunk/gcc/config/arm/arm.h llvm-gcc-4.2/trunk/gcc/config/arm/darwin.h Modified: llvm-gcc-4.2/trunk/gcc/config/arm/arm-cores.def URL: http://llvm.org/viewvc/llvm-project/llvm-gcc-4.2/trunk/gcc/config/arm/arm-cores.def?rev=110837&r1=110836&r2=110837&view=diff ============================================================================== --- llvm-gcc-4.2/trunk/gcc/config/arm/arm-cores.def (original) +++ llvm-gcc-4.2/trunk/gcc/config/arm/arm-cores.def Wed Aug 11 13:22:46 2010 @@ -123,8 +123,9 @@ ARM_CORE("cortex-a8", cortexa8, 7A, FL_LDSCHED, 9e) /* LLVM LOCAL begin */ ARM_CORE("cortex-a9", cortexa9, 7A, FL_LDSCHED, 9e) -/* LLVM LOCAL end */ ARM_CORE("cortex-r4", cortexr4, 7R, FL_LDSCHED, 9e) ARM_CORE("cortex-m3", cortexm3, 7M, FL_LDSCHED, 9e) ARM_CORE("cortex-m4", cortexm4, 7M, FL_LDSCHED, 9e) +ARM_CORE("cortex-m0", cortexm0, 6M, FL_LDSCHED, 9e) +/* LLVM LOCAL end */ /* APPLE LOCAL end v7 support. Merge from mainline */ Modified: llvm-gcc-4.2/trunk/gcc/config/arm/arm.c URL: http://llvm.org/viewvc/llvm-project/llvm-gcc-4.2/trunk/gcc/config/arm/arm.c?rev=110837&r1=110836&r2=110837&view=diff ============================================================================== --- llvm-gcc-4.2/trunk/gcc/config/arm/arm.c (original) +++ llvm-gcc-4.2/trunk/gcc/config/arm/arm.c Wed Aug 11 13:22:46 2010 @@ -645,6 +645,8 @@ #define FL_FOR_ARCH7A (FL_FOR_ARCH7 | FL_NOTM | FL_NEON) #define FL_FOR_ARCH7R (FL_FOR_ARCH7A | FL_DIV) #define FL_FOR_ARCH7M (FL_FOR_ARCH7 | FL_DIV) +/* LLVM LOCAL processor support */ +#define FL_FOR_ARCH6M (FL_FOR_ARCH6 &~ FL_NOTM) /* APPLE LOCAL end v7 support. Merge from mainline */ /* The bits in this mask specify which @@ -679,6 +681,9 @@ /* Nonzero if this chip supports the ARM 6K extensions. */ int arm_arch6k = 0; +/* Nonzero if this chip supports the ARM 6M extensions. */ +int arm_arch6m = 0; + /* APPLE LOCAL begin 6093388 -mfpu=neon default for v7a */ /* Nonzero if this chip supports the ARM 7A extensions. */ int arm_arch7a = 0; @@ -834,10 +839,14 @@ {"armv5tej",arm926ejs, "5TEJ",FL_CO_PROC | FL_FOR_ARCH5TEJ, NULL}, {"xscale", xscale, "5TE", FL_CO_PROC | FL_XSCALE | FL_FOR_ARCH5TE, NULL}, {"armv6", arm1136jfs, "6", FL_CO_PROC | FL_FOR_ARCH6, NULL}, + /* LLVM LOCAL processor support */ + {"armv6m", cortexm0, "6M", FL_CO_PROC | FL_FOR_ARCH6M, NULL}, {"armv6j", arm1136js, "6J", FL_CO_PROC | FL_FOR_ARCH6J, NULL}, {"armv6k", arm1136jfs, "6K", FL_CO_PROC | FL_FOR_ARCH6K, NULL}, #else {"armv6", arm1136js, "6", FL_CO_PROC | FL_FOR_ARCH6, NULL}, + /* LLVM LOCAL processor support */ + {"armv6m", cortexm0, "6M", FL_CO_PROC | FL_FOR_ARCH6M, NULL}, {"armv6j", arm1136js, "6J", FL_CO_PROC | FL_FOR_ARCH6J, NULL}, {"armv6k", mpcore, "6K", FL_CO_PROC | FL_FOR_ARCH6K, NULL}, #endif @@ -848,18 +857,24 @@ {"armv6t2", arm1156t2s, "6T2", FL_CO_PROC | FL_FOR_ARCH6T2, NULL}, {"armv7", cortexa8, "7", FL_CO_PROC | FL_FOR_ARCH7, NULL}, {"armv7a", cortexa8, "7A", FL_CO_PROC | FL_FOR_ARCH7A, NULL}, + /* LLVM LOCAL begin processor support */ {"armv7m", cortexm3, "7M", FL_CO_PROC | FL_FOR_ARCH7M, NULL}, {"armv7m3", cortexm3, "7M", FL_CO_PROC | FL_FOR_ARCH7M, NULL}, - {"armv7m4", cortexm4, "7M", FL_CO_PROC | FL_FOR_ARCH7M, NULL}, + {"armv7m4", cortexm4, "7M", FL_CO_PROC | FL_FOR_ARCH7M, NULL}, + {"armv6m0", cortexm0, "6M", FL_CO_PROC | FL_FOR_ARCH6M, NULL}, + /* LLVM LOCAL end processor support */ /* APPLE LOCAL begin v7 support. Merge from Codesourcery */ {"armv7r", cortexr4, "7R", FL_CO_PROC | FL_FOR_ARCH7R, NULL}, {"armv7m", cortexm3, "7M", FL_CO_PROC | FL_FOR_ARCH7M, NULL}, /* APPLE LOCAL end v7 support. Merge from Codesourcery */ {"armv7-a", cortexa8, "7A", FL_CO_PROC | FL_FOR_ARCH7A, NULL}, {"armv7-r", cortexr4, "7R", FL_CO_PROC | FL_FOR_ARCH7R, NULL}, + /* LLVM LOCAL begin processor support */ {"armv7-m", cortexm3, "7M", FL_CO_PROC | FL_FOR_ARCH7M, NULL}, {"armv7-m3", cortexm3, "7M", FL_CO_PROC | FL_FOR_ARCH7M, NULL}, {"armv7-m4", cortexm4, "7M", FL_CO_PROC | FL_FOR_ARCH7M, NULL}, + {"armv6-m0", cortexm0, "6M", FL_CO_PROC | FL_FOR_ARCH6M, NULL}, + /* LLVM LOCAL end processor support */ /* APPLE LOCAL end v7 support. Merge from mainline */ {"ep9312", ep9312, "4T", FL_LDSCHED | FL_CIRRUS | FL_FOR_ARCH4, NULL}, {"iwmmxt", iwmmxt, "5TE", FL_LDSCHED | FL_STRONG | FL_FOR_ARCH5TE | FL_XSCALE | FL_IWMMXT , NULL}, @@ -1456,10 +1471,12 @@ targetm.rtx_costs = all_cores[(int)arm_tune].rtx_costs; /* LLVM LOCAL begin */ - /* v7m processors don't have ARM mode, so default to thumb mode. + /* v7m and v6m processors don't have ARM mode, so default to thumb mode. Explicitly only set for default so we can error if the user sets -marm or -mno-thumb. */ - if ((insn_flags & FL_FOR_ARCH7M) == FL_FOR_ARCH7M && thumb_option < 0) + if (((insn_flags & FL_FOR_ARCH7M) == FL_FOR_ARCH7M + || (insn_flags & FL_FOR_ARCH6M) == FL_FOR_ARCH6M) + && thumb_option < 0) thumb_option = 1; /* LLVM LOCAL end */ @@ -1569,6 +1586,8 @@ arm_arch7a = (insn_flags & FL_FOR_ARCH7A) == FL_FOR_ARCH7A; /* APPLE LOCAL begin v7 support. Merge from mainline */ arm_arch7m = (insn_flags & FL_FOR_ARCH7M) == FL_FOR_ARCH7M; + /* LLVM LOCAL processor support */ + arm_arch6m = (insn_flags & FL_FOR_ARCH6M) == FL_FOR_ARCH6M; arm_arch_notm = (insn_flags & FL_NOTM) != 0; arm_arch_thumb2 = (insn_flags & FL_THUMB2) != 0; /* APPLE LOCAL end v7 support. Merge from mainline */ Modified: llvm-gcc-4.2/trunk/gcc/config/arm/arm.h URL: http://llvm.org/viewvc/llvm-project/llvm-gcc-4.2/trunk/gcc/config/arm/arm.h?rev=110837&r1=110836&r2=110837&view=diff ============================================================================== --- llvm-gcc-4.2/trunk/gcc/config/arm/arm.h (original) +++ llvm-gcc-4.2/trunk/gcc/config/arm/arm.h Wed Aug 11 13:22:46 2010 @@ -449,6 +449,9 @@ /* Nonzero if this chip supports the ARM Architecture 6 extensions. */ extern int arm_arch6; +/* LLVM LOCAL Declare arm_arch6m for use when setting the target triple. */ +extern int arm_arch6m; + /* LLVM LOCAL Declare arm_arch7m for use when setting the target triple. */ extern int arm_arch7m; @@ -3498,6 +3501,7 @@ case cortexr4: F.setCPU("cortex-r4"); break; \ case cortexm3: F.setCPU("cortex-m3"); break; \ case cortexm4: F.setCPU("cortex-m4"); break; \ + case cortexm0: F.setCPU("cortex-m0"); break; \ default: \ F.setCPU("arm7tdmi"); \ break; \ @@ -3533,14 +3537,16 @@ ? "thumbv7m" \ : (arm_arch_thumb2 \ ? "thumbv6t2" \ - : (arm_arch6 \ - ? "thumbv6" \ - : (arm_arch5e \ - ? "thumbv5e" \ - : (arm_arch5 \ - ? "thumbv5" \ - : (arm_arch4t \ - ? "thumbv4t" : ""))))))) \ + : (arm_arch6m \ + ? "thumbv6m" \ + : (arm_arch6 \ + ? "thumbv6" \ + : (arm_arch5e \ + ? "thumbv5e" \ + : (arm_arch5 \ + ? "thumbv5" \ + : (arm_arch4t \ + ? "thumbv4t" : "")))))))) \ : (arm_arch7a \ ? "armv7" \ : (arm_arch_thumb2 \ Modified: llvm-gcc-4.2/trunk/gcc/config/arm/darwin.h URL: http://llvm.org/viewvc/llvm-project/llvm-gcc-4.2/trunk/gcc/config/arm/darwin.h?rev=110837&r1=110836&r2=110837&view=diff ============================================================================== --- llvm-gcc-4.2/trunk/gcc/config/arm/darwin.h (original) +++ llvm-gcc-4.2/trunk/gcc/config/arm/darwin.h Wed Aug 11 13:22:46 2010 @@ -328,8 +328,10 @@ #define SUBTARGET_ASM_DECLARE_FUNCTION_NAME ARM_DECLARE_FUNCTION_NAME /* APPLE LOCAL begin 6093388 -mfpu=neon default for v7a */ -/* We default to VFP for v6, NEON for v7 */ -#define FPUTYPE_DEFAULT (arm_arch7a ? "neon" : "vfp") +/* We default to VFP for v6, NEON for v7. */ +#define FPUTYPE_DEFAULT (arm_arch7a ? "neon" : \ + ((arm_tune == cortexm3 || arm_tune == cortexm0) ? \ + "fpe2" : "vfp")) #undef TARGET_DEFAULT_FLOAT_ABI #define TARGET_DEFAULT_FLOAT_ABI ((arm_arch6 || arm_arch7a) ? ARM_FLOAT_ABI_SOFTFP : ARM_FLOAT_ABI_SOFT) From clattner at apple.com Wed Aug 11 13:25:34 2010 From: clattner at apple.com (Chris Lattner) Date: Wed, 11 Aug 2010 11:25:34 -0700 Subject: [llvm-commits] [llvm] r110576 - in /llvm/trunk: lib/Target/CellSPU/SPUISelLowering.cpp lib/Target/CellSPU/SPUISelLowering.h lib/Target/CellSPU/SPUInstrInfo.td lib/Target/CellSPU/SPUNodes.td lib/Target/CellSPU/SPURegisterInfo.cpp test/CodeGen/CellSP... In-Reply-To: References: <20100809163301.235462A6C12C@llvm.org> <25685170-45BA-47F0-AF9D-0D0600748145@apple.com> <1281437591.1796.146.camel@LLVMbuilder.research.nokia.com> <1281525584.1870.13.camel@LLVMbuilder.research.nokia.com> Message-ID: <729BDEF9-0BF8-4AEF-AA91-E82F6A75EB53@apple.com> On Aug 11, 2010, at 11:11 AM, Bob Wilson wrote: > > On Aug 11, 2010, at 4:19 AM, Kalle.Raiskila at nokia.com wrote: > >> On Tue, 2010-08-10 at 19:12 +0200, Bob Wilson wrote: >>> On Aug 10, 2010, at 3:53 AM, Kalle.Raiskila at nokia.com wrote: >>>> b) to the best of my understanding, v2i32 has to be legal if it is to be >>>> used in return values and function parameters. >>> >>> The types of return values and function parameters are also legalized. If you pass an argument with a non-legal type, it should be promoted or expanded to make it legal. >> >> The problem here was that v2i32 gets expanded to two i32s instead of >> promoted to one v4i32. Is it possible to force promotion somehow? > > The following code from TargetLowering::computeRegisterProperties() suggests that promotion should be the default: > If that's not happening, you might want to step through that code and see why not. Otherwise, you can specify promote vs. expand for each operation via TargetLowering::setOperationAction(). This isn't happening on X86 either, try running this through llc: define <2 x float> @test1(<4 x float> %A) nounwind { %B = shufflevector <4 x float> %A, <4 x float> undef, <2 x i32> %C = fadd <2 x float> %B, %B ret <2 x float> %C } The two floats are returned in XMM0/XMM1 instead of the low two elements of XMM0. -Chris From gohman at apple.com Wed Aug 11 14:05:53 2010 From: gohman at apple.com (Dan Gohman) Date: Wed, 11 Aug 2010 19:05:53 -0000 Subject: [llvm-commits] [llvm] r110842 - in /llvm/trunk: include/llvm/Pass.h lib/VMCore/Pass.cpp Message-ID: <20100811190553.5F65F2A6C12C@llvm.org> Author: djg Date: Wed Aug 11 14:05:53 2010 New Revision: 110842 URL: http://llvm.org/viewvc/llvm-project?rev=110842&view=rev Log: Delete FunctionPass::runOnModule, which is unused. Modified: llvm/trunk/include/llvm/Pass.h llvm/trunk/lib/VMCore/Pass.cpp Modified: llvm/trunk/include/llvm/Pass.h URL: http://llvm.org/viewvc/llvm-project/llvm/trunk/include/llvm/Pass.h?rev=110842&r1=110841&r2=110842&view=diff ============================================================================== --- llvm/trunk/include/llvm/Pass.h (original) +++ llvm/trunk/include/llvm/Pass.h Wed Aug 11 14:05:53 2010 @@ -295,12 +295,6 @@ /// virtual bool doFinalization(Module &); - /// runOnModule - On a module, we run this pass by initializing, - /// ronOnFunction'ing once for every function in the module, then by - /// finalizing. - /// - virtual bool runOnModule(Module &M); - /// run - On a function, we simply initialize, run the function, then /// finalize. /// Modified: llvm/trunk/lib/VMCore/Pass.cpp URL: http://llvm.org/viewvc/llvm-project/llvm/trunk/lib/VMCore/Pass.cpp?rev=110842&r1=110841&r2=110842&view=diff ============================================================================== --- llvm/trunk/lib/VMCore/Pass.cpp (original) +++ llvm/trunk/lib/VMCore/Pass.cpp Wed Aug 11 14:05:53 2010 @@ -141,19 +141,6 @@ return createPrintFunctionPass(Banner, &O); } -// run - On a module, we run this pass by initializing, runOnFunction'ing once -// for every function in the module, then by finalizing. -// -bool FunctionPass::runOnModule(Module &M) { - bool Changed = doInitialization(M); - - for (Module::iterator I = M.begin(), E = M.end(); I != E; ++I) - if (!I->isDeclaration()) // Passes are not run on external functions! - Changed |= runOnFunction(*I); - - return Changed | doFinalization(M); -} - // run - On a function, we simply initialize, run the function, then finalize. // bool FunctionPass::run(Function &F) { From gohman at apple.com Wed Aug 11 14:11:05 2010 From: gohman at apple.com (Dan Gohman) Date: Wed, 11 Aug 2010 19:11:05 -0000 Subject: [llvm-commits] [llvm] r110843 - in /llvm/trunk: include/llvm/Pass.h lib/VMCore/Pass.cpp Message-ID: <20100811191105.D885E2A6C12C@llvm.org> Author: djg Date: Wed Aug 11 14:11:05 2010 New Revision: 110843 URL: http://llvm.org/viewvc/llvm-project?rev=110843&view=rev Log: Delete FunctionPass::run, which is unused. Modified: llvm/trunk/include/llvm/Pass.h llvm/trunk/lib/VMCore/Pass.cpp Modified: llvm/trunk/include/llvm/Pass.h URL: http://llvm.org/viewvc/llvm-project/llvm/trunk/include/llvm/Pass.h?rev=110843&r1=110842&r2=110843&view=diff ============================================================================== --- llvm/trunk/include/llvm/Pass.h (original) +++ llvm/trunk/include/llvm/Pass.h Wed Aug 11 14:11:05 2010 @@ -295,11 +295,6 @@ /// virtual bool doFinalization(Module &); - /// run - On a function, we simply initialize, run the function, then - /// finalize. - /// - bool run(Function &F); - virtual void assignPassManager(PMStack &PMS, PassManagerType T); Modified: llvm/trunk/lib/VMCore/Pass.cpp URL: http://llvm.org/viewvc/llvm-project/llvm/trunk/lib/VMCore/Pass.cpp?rev=110843&r1=110842&r2=110843&view=diff ============================================================================== --- llvm/trunk/lib/VMCore/Pass.cpp (original) +++ llvm/trunk/lib/VMCore/Pass.cpp Wed Aug 11 14:11:05 2010 @@ -141,17 +141,6 @@ return createPrintFunctionPass(Banner, &O); } -// run - On a function, we simply initialize, run the function, then finalize. -// -bool FunctionPass::run(Function &F) { - // Passes are not run on external functions! - if (F.isDeclaration()) return false; - - bool Changed = doInitialization(*F.getParent()); - Changed |= runOnFunction(F); - return Changed | doFinalization(*F.getParent()); -} - bool FunctionPass::doInitialization(Module &) { // By default, don't do anything. return false; From bruno.cardoso at gmail.com Wed Aug 11 14:21:05 2010 From: bruno.cardoso at gmail.com (Bruno Cardoso Lopes) Date: Wed, 11 Aug 2010 19:21:05 -0000 Subject: [llvm-commits] [llvm] r110845 - /llvm/trunk/include/llvm/IntrinsicsX86.td Message-ID: <20100811192105.B8D8B2A6C12C@llvm.org> Author: bruno Date: Wed Aug 11 14:21:05 2010 New Revision: 110845 URL: http://llvm.org/viewvc/llvm-project?rev=110845&view=rev Log: Remove rsqrt/sqrt_nr intrinsics since there are no more builtins for them on clang Modified: llvm/trunk/include/llvm/IntrinsicsX86.td Modified: llvm/trunk/include/llvm/IntrinsicsX86.td URL: http://llvm.org/viewvc/llvm-project/llvm/trunk/include/llvm/IntrinsicsX86.td?rev=110845&r1=110844&r2=110845&view=diff ============================================================================== --- llvm/trunk/include/llvm/IntrinsicsX86.td (original) +++ llvm/trunk/include/llvm/IntrinsicsX86.td Wed Aug 11 14:21:05 2010 @@ -1006,13 +1006,8 @@ def int_x86_avx_sqrt_ps_256 : GCCBuiltin<"__builtin_ia32_sqrtps256">, Intrinsic<[llvm_v8f32_ty], [llvm_v8f32_ty], [IntrNoMem]>; - def int_x86_avx_sqrt_ps_nr_256 : GCCBuiltin<"__builtin_ia32_sqrtps_nr256">, - Intrinsic<[llvm_v8f32_ty], [llvm_v8f32_ty], [IntrNoMem]>; - def int_x86_avx_rsqrt_ps_256 : GCCBuiltin<"__builtin_ia32_rsqrtps256">, Intrinsic<[llvm_v8f32_ty], [llvm_v8f32_ty], [IntrNoMem]>; - def int_x86_avx_rsqrt_ps_nr_256 : GCCBuiltin<"__builtin_ia32_rsqrtps_nr256">, - Intrinsic<[llvm_v8f32_ty], [llvm_v8f32_ty], [IntrNoMem]>; def int_x86_avx_rcp_ps_256 : GCCBuiltin<"__builtin_ia32_rcpps256">, Intrinsic<[llvm_v8f32_ty], [llvm_v8f32_ty], [IntrNoMem]>; From gohman at apple.com Wed Aug 11 15:28:16 2010 From: gohman at apple.com (Dan Gohman) Date: Wed, 11 Aug 2010 20:28:16 -0000 Subject: [llvm-commits] [llvm] r110847 - in /llvm/trunk: include/llvm/Pass.h lib/VMCore/Pass.cpp Message-ID: <20100811202816.D2D872A6C12C@llvm.org> Author: djg Date: Wed Aug 11 15:28:16 2010 New Revision: 110847 URL: http://llvm.org/viewvc/llvm-project?rev=110847&view=rev Log: Remove BasicBlockPass::runOnFunction, which was unused. Modified: llvm/trunk/include/llvm/Pass.h llvm/trunk/lib/VMCore/Pass.cpp Modified: llvm/trunk/include/llvm/Pass.h URL: http://llvm.org/viewvc/llvm-project/llvm/trunk/include/llvm/Pass.h?rev=110847&r1=110846&r2=110847&view=diff ============================================================================== --- llvm/trunk/include/llvm/Pass.h (original) +++ llvm/trunk/include/llvm/Pass.h Wed Aug 11 15:28:16 2010 @@ -346,12 +346,6 @@ /// virtual bool doFinalization(Module &); - - // To run this pass on a function, we simply call runOnBasicBlock once for - // each function. - // - bool runOnFunction(Function &F); - virtual void assignPassManager(PMStack &PMS, PassManagerType T); Modified: llvm/trunk/lib/VMCore/Pass.cpp URL: http://llvm.org/viewvc/llvm-project/llvm/trunk/lib/VMCore/Pass.cpp?rev=110847&r1=110846&r2=110847&view=diff ============================================================================== --- llvm/trunk/lib/VMCore/Pass.cpp (original) +++ llvm/trunk/lib/VMCore/Pass.cpp Wed Aug 11 15:28:16 2010 @@ -166,16 +166,6 @@ return 0; } -// To run this pass on a function, we simply call runOnBasicBlock once for each -// function. -// -bool BasicBlockPass::runOnFunction(Function &F) { - bool Changed = doInitialization(F); - for (Function::iterator I = F.begin(), E = F.end(); I != E; ++I) - Changed |= runOnBasicBlock(*I); - return Changed | doFinalization(F); -} - bool BasicBlockPass::doInitialization(Module &) { // By default, don't do anything. return false; From gohman at apple.com Wed Aug 11 15:34:44 2010 From: gohman at apple.com (Dan Gohman) Date: Wed, 11 Aug 2010 20:34:44 -0000 Subject: [llvm-commits] [llvm] r110848 - in /llvm/trunk: include/llvm/Analysis/LoopPass.h lib/Analysis/LoopPass.cpp Message-ID: <20100811203444.234D32A6C12C@llvm.org> Author: djg Date: Wed Aug 11 15:34:43 2010 New Revision: 110848 URL: http://llvm.org/viewvc/llvm-project?rev=110848&view=rev Log: Make LoopPass::getContainedPass return a LoopPass* instead of a Pass* and remove casts from all its callers. Modified: llvm/trunk/include/llvm/Analysis/LoopPass.h llvm/trunk/lib/Analysis/LoopPass.cpp Modified: llvm/trunk/include/llvm/Analysis/LoopPass.h URL: http://llvm.org/viewvc/llvm-project/llvm/trunk/include/llvm/Analysis/LoopPass.h?rev=110848&r1=110847&r2=110848&view=diff ============================================================================== --- llvm/trunk/include/llvm/Analysis/LoopPass.h (original) +++ llvm/trunk/include/llvm/Analysis/LoopPass.h Wed Aug 11 15:34:43 2010 @@ -104,10 +104,10 @@ /// Print passes managed by this manager void dumpPassStructure(unsigned Offset); - Pass *getContainedPass(unsigned N) { + LoopPass *getContainedPass(unsigned N) { assert(N < PassVector.size() && "Pass number out of range!"); - Pass *FP = static_cast(PassVector[N]); - return FP; + LoopPass *LP = static_cast(PassVector[N]); + return LP; } virtual PassManagerType getPassManagerType() const { Modified: llvm/trunk/lib/Analysis/LoopPass.cpp URL: http://llvm.org/viewvc/llvm-project/llvm/trunk/lib/Analysis/LoopPass.cpp?rev=110848&r1=110847&r2=110848&view=diff ============================================================================== --- llvm/trunk/lib/Analysis/LoopPass.cpp (original) +++ llvm/trunk/lib/Analysis/LoopPass.cpp Wed Aug 11 15:34:43 2010 @@ -183,7 +183,7 @@ void LPPassManager::cloneBasicBlockSimpleAnalysis(BasicBlock *From, BasicBlock *To, Loop *L) { for (unsigned Index = 0; Index < getNumContainedPasses(); ++Index) { - LoopPass *LP = (LoopPass *)getContainedPass(Index); + LoopPass *LP = getContainedPass(Index); LP->cloneBasicBlockAnalysis(From, To, L); } } @@ -198,7 +198,7 @@ } } for (unsigned Index = 0; Index < getNumContainedPasses(); ++Index) { - LoopPass *LP = (LoopPass *)getContainedPass(Index); + LoopPass *LP = getContainedPass(Index); LP->deleteAnalysisValue(V, L); } } @@ -240,7 +240,7 @@ I != E; ++I) { Loop *L = *I; for (unsigned Index = 0; Index < getNumContainedPasses(); ++Index) { - LoopPass *P = (LoopPass*)getContainedPass(Index); + LoopPass *P = getContainedPass(Index); Changed |= P->doInitialization(L, *this); } } @@ -254,7 +254,7 @@ // Run all passes on the current Loop. for (unsigned Index = 0; Index < getNumContainedPasses(); ++Index) { - LoopPass *P = (LoopPass*)getContainedPass(Index); + LoopPass *P = getContainedPass(Index); dumpPassInfo(P, EXECUTION_MSG, ON_LOOP_MSG, CurrentLoop->getHeader()->getName()); @@ -320,7 +320,7 @@ // Finalization for (unsigned Index = 0; Index < getNumContainedPasses(); ++Index) { - LoopPass *P = (LoopPass *)getContainedPass(Index); + LoopPass *P = getContainedPass(Index); Changed |= P->doFinalization(); } From bruno.cardoso at gmail.com Wed Aug 11 16:12:09 2010 From: bruno.cardoso at gmail.com (Bruno Cardoso Lopes) Date: Wed, 11 Aug 2010 21:12:09 -0000 Subject: [llvm-commits] [llvm] r110854 - /llvm/trunk/test/CodeGen/X86/avx-intrinsics-x86.ll Message-ID: <20100811211209.C9B2A2A6C12C@llvm.org> Author: bruno Date: Wed Aug 11 16:12:09 2010 New Revision: 110854 URL: http://llvm.org/viewvc/llvm-project?rev=110854&view=rev Log: Add testcases for all AVX 256-bit intrinsics added in the last couple days Modified: llvm/trunk/test/CodeGen/X86/avx-intrinsics-x86.ll Modified: llvm/trunk/test/CodeGen/X86/avx-intrinsics-x86.ll URL: http://llvm.org/viewvc/llvm-project/llvm/trunk/test/CodeGen/X86/avx-intrinsics-x86.ll?rev=110854&r1=110853&r2=110854&view=diff ============================================================================== --- llvm/trunk/test/CodeGen/X86/avx-intrinsics-x86.ll (original) +++ llvm/trunk/test/CodeGen/X86/avx-intrinsics-x86.ll Wed Aug 11 16:12:09 2010 @@ -1954,3 +1954,754 @@ } declare <8 x i16> @llvm.x86.ssse3.psign.w.128(<8 x i16>, <8 x i16>) nounwind readnone + +define <4 x double> @test_x86_avx_addsub_pd_256(<4 x double> %a0, <4 x double> %a1) { + ; CHECK: vaddsubpd + %res = call <4 x double> @llvm.x86.avx.addsub.pd.256(<4 x double> %a0, <4 x double> %a1) ; <<4 x double>> [#uses=1] + ret <4 x double> %res +} +declare <4 x double> @llvm.x86.avx.addsub.pd.256(<4 x double>, <4 x double>) nounwind readnone + + +define <8 x float> @test_x86_avx_addsub_ps_256(<8 x float> %a0, <8 x float> %a1) { + ; CHECK: vaddsubps + %res = call <8 x float> @llvm.x86.avx.addsub.ps.256(<8 x float> %a0, <8 x float> %a1) ; <<8 x float>> [#uses=1] + ret <8 x float> %res +} +declare <8 x float> @llvm.x86.avx.addsub.ps.256(<8 x float>, <8 x float>) nounwind readnone + + +define <4 x double> @test_x86_avx_blend_pd_256(<4 x double> %a0, <4 x double> %a1) { + ; CHECK: vblendpd + %res = call <4 x double> @llvm.x86.avx.blend.pd.256(<4 x double> %a0, <4 x double> %a1, i32 7) ; <<4 x double>> [#uses=1] + ret <4 x double> %res +} +declare <4 x double> @llvm.x86.avx.blend.pd.256(<4 x double>, <4 x double>, i32) nounwind readnone + + +define <8 x float> @test_x86_avx_blend_ps_256(<8 x float> %a0, <8 x float> %a1) { + ; CHECK: vblendps + %res = call <8 x float> @llvm.x86.avx.blend.ps.256(<8 x float> %a0, <8 x float> %a1, i32 7) ; <<8 x float>> [#uses=1] + ret <8 x float> %res +} +declare <8 x float> @llvm.x86.avx.blend.ps.256(<8 x float>, <8 x float>, i32) nounwind readnone + + +define <4 x double> @test_x86_avx_blendv_pd_256(<4 x double> %a0, <4 x double> %a1, <4 x double> %a2) { + ; CHECK: vblendvpd + %res = call <4 x double> @llvm.x86.avx.blendv.pd.256(<4 x double> %a0, <4 x double> %a1, <4 x double> %a2) ; <<4 x double>> [#uses=1] + ret <4 x double> %res +} +declare <4 x double> @llvm.x86.avx.blendv.pd.256(<4 x double>, <4 x double>, <4 x double>) nounwind readnone + + +define <8 x float> @test_x86_avx_blendv_ps_256(<8 x float> %a0, <8 x float> %a1, <8 x float> %a2) { + ; CHECK: vblendvps + %res = call <8 x float> @llvm.x86.avx.blendv.ps.256(<8 x float> %a0, <8 x float> %a1, <8 x float> %a2) ; <<8 x float>> [#uses=1] + ret <8 x float> %res +} +declare <8 x float> @llvm.x86.avx.blendv.ps.256(<8 x float>, <8 x float>, <8 x float>) nounwind readnone + + +define <4 x double> @test_x86_avx_cmp_pd_256(<4 x double> %a0, <4 x double> %a1) { + ; CHECK: vcmpordpd + %res = call <4 x double> @llvm.x86.avx.cmp.pd.256(<4 x double> %a0, <4 x double> %a1, i8 7) ; <<4 x double>> [#uses=1] + ret <4 x double> %res +} +declare <4 x double> @llvm.x86.avx.cmp.pd.256(<4 x double>, <4 x double>, i8) nounwind readnone + + +define <8 x float> @test_x86_avx_cmp_ps_256(<8 x float> %a0, <8 x float> %a1) { + ; CHECK: vcmpordps + %res = call <8 x float> @llvm.x86.avx.cmp.ps.256(<8 x float> %a0, <8 x float> %a1, i8 7) ; <<8 x float>> [#uses=1] + ret <8 x float> %res +} +declare <8 x float> @llvm.x86.avx.cmp.ps.256(<8 x float>, <8 x float>, i8) nounwind readnone + + +define <4 x float> @test_x86_avx_cvt_pd2_ps_256(<4 x double> %a0) { + ; CHECK: vcvtpd2psy + %res = call <4 x float> @llvm.x86.avx.cvt.pd2.ps.256(<4 x double> %a0) ; <<4 x float>> [#uses=1] + ret <4 x float> %res +} +declare <4 x float> @llvm.x86.avx.cvt.pd2.ps.256(<4 x double>) nounwind readnone + + +define <4 x i32> @test_x86_avx_cvt_pd2dq_256(<4 x double> %a0) { + ; CHECK: vcvtpd2dqy + %res = call <4 x i32> @llvm.x86.avx.cvt.pd2dq.256(<4 x double> %a0) ; <<4 x i32>> [#uses=1] + ret <4 x i32> %res +} +declare <4 x i32> @llvm.x86.avx.cvt.pd2dq.256(<4 x double>) nounwind readnone + + +define <4 x double> @test_x86_avx_cvt_ps2_pd_256(<4 x float> %a0) { + ; CHECK: vcvtps2pd + %res = call <4 x double> @llvm.x86.avx.cvt.ps2.pd.256(<4 x float> %a0) ; <<4 x double>> [#uses=1] + ret <4 x double> %res +} +declare <4 x double> @llvm.x86.avx.cvt.ps2.pd.256(<4 x float>) nounwind readnone + + +define <8 x i32> @test_x86_avx_cvt_ps2dq_256(<8 x float> %a0) { + ; CHECK: vcvtps2dq + %res = call <8 x i32> @llvm.x86.avx.cvt.ps2dq.256(<8 x float> %a0) ; <<8 x i32>> [#uses=1] + ret <8 x i32> %res +} +declare <8 x i32> @llvm.x86.avx.cvt.ps2dq.256(<8 x float>) nounwind readnone + + +define <4 x double> @test_x86_avx_cvtdq2_pd_256(<4 x i32> %a0) { + ; CHECK: vcvtdq2pd + %res = call <4 x double> @llvm.x86.avx.cvtdq2.pd.256(<4 x i32> %a0) ; <<4 x double>> [#uses=1] + ret <4 x double> %res +} +declare <4 x double> @llvm.x86.avx.cvtdq2.pd.256(<4 x i32>) nounwind readnone + + +define <8 x float> @test_x86_avx_cvtdq2_ps_256(<8 x i32> %a0) { + ; CHECK: vcvtdq2ps + %res = call <8 x float> @llvm.x86.avx.cvtdq2.ps.256(<8 x i32> %a0) ; <<8 x float>> [#uses=1] + ret <8 x float> %res +} +declare <8 x float> @llvm.x86.avx.cvtdq2.ps.256(<8 x i32>) nounwind readnone + + +define <4 x i32> @test_x86_avx_cvtt_pd2dq_256(<4 x double> %a0) { + ; CHECK: vcvttpd2dqy + %res = call <4 x i32> @llvm.x86.avx.cvtt.pd2dq.256(<4 x double> %a0) ; <<4 x i32>> [#uses=1] + ret <4 x i32> %res +} +declare <4 x i32> @llvm.x86.avx.cvtt.pd2dq.256(<4 x double>) nounwind readnone + + +define <8 x i32> @test_x86_avx_cvtt_ps2dq_256(<8 x float> %a0) { + ; CHECK: vcvttps2dq + %res = call <8 x i32> @llvm.x86.avx.cvtt.ps2dq.256(<8 x float> %a0) ; <<8 x i32>> [#uses=1] + ret <8 x i32> %res +} +declare <8 x i32> @llvm.x86.avx.cvtt.ps2dq.256(<8 x float>) nounwind readnone + + +define <8 x float> @test_x86_avx_dp_ps_256(<8 x float> %a0, <8 x float> %a1) { + ; CHECK: vdpps + %res = call <8 x float> @llvm.x86.avx.dp.ps.256(<8 x float> %a0, <8 x float> %a1, i32 7) ; <<8 x float>> [#uses=1] + ret <8 x float> %res +} +declare <8 x float> @llvm.x86.avx.dp.ps.256(<8 x float>, <8 x float>, i32) nounwind readnone + + +define <4 x double> @test_x86_avx_hadd_pd_256(<4 x double> %a0, <4 x double> %a1) { + ; CHECK: vhaddpd + %res = call <4 x double> @llvm.x86.avx.hadd.pd.256(<4 x double> %a0, <4 x double> %a1) ; <<4 x double>> [#uses=1] + ret <4 x double> %res +} +declare <4 x double> @llvm.x86.avx.hadd.pd.256(<4 x double>, <4 x double>) nounwind readnone + + +define <8 x float> @test_x86_avx_hadd_ps_256(<8 x float> %a0, <8 x float> %a1) { + ; CHECK: vhaddps + %res = call <8 x float> @llvm.x86.avx.hadd.ps.256(<8 x float> %a0, <8 x float> %a1) ; <<8 x float>> [#uses=1] + ret <8 x float> %res +} +declare <8 x float> @llvm.x86.avx.hadd.ps.256(<8 x float>, <8 x float>) nounwind readnone + + +define <4 x double> @test_x86_avx_hsub_pd_256(<4 x double> %a0, <4 x double> %a1) { + ; CHECK: vhsubpd + %res = call <4 x double> @llvm.x86.avx.hsub.pd.256(<4 x double> %a0, <4 x double> %a1) ; <<4 x double>> [#uses=1] + ret <4 x double> %res +} +declare <4 x double> @llvm.x86.avx.hsub.pd.256(<4 x double>, <4 x double>) nounwind readnone + + +define <8 x float> @test_x86_avx_hsub_ps_256(<8 x float> %a0, <8 x float> %a1) { + ; CHECK: vhsubps + %res = call <8 x float> @llvm.x86.avx.hsub.ps.256(<8 x float> %a0, <8 x float> %a1) ; <<8 x float>> [#uses=1] + ret <8 x float> %res +} +declare <8 x float> @llvm.x86.avx.hsub.ps.256(<8 x float>, <8 x float>) nounwind readnone + + +define <32 x i8> @test_x86_avx_ldu_dq_256(i8* %a0) { + ; CHECK: vlddqu + %res = call <32 x i8> @llvm.x86.avx.ldu.dq.256(i8* %a0) ; <<32 x i8>> [#uses=1] + ret <32 x i8> %res +} +declare <32 x i8> @llvm.x86.avx.ldu.dq.256(i8*) nounwind readonly + + +define <32 x i8> @test_x86_avx_loadu_dq_256(i8* %a0) { + ; CHECK: vmovdqu + %res = call <32 x i8> @llvm.x86.avx.loadu.dq.256(i8* %a0) ; <<32 x i8>> [#uses=1] + ret <32 x i8> %res +} +declare <32 x i8> @llvm.x86.avx.loadu.dq.256(i8*) nounwind readonly + + +define <4 x double> @test_x86_avx_loadu_pd_256(i8* %a0) { + ; CHECK: vmovupd + %res = call <4 x double> @llvm.x86.avx.loadu.pd.256(i8* %a0) ; <<4 x double>> [#uses=1] + ret <4 x double> %res +} +declare <4 x double> @llvm.x86.avx.loadu.pd.256(i8*) nounwind readonly + + +define <8 x float> @test_x86_avx_loadu_ps_256(i8* %a0) { + ; CHECK: vmovups + %res = call <8 x float> @llvm.x86.avx.loadu.ps.256(i8* %a0) ; <<8 x float>> [#uses=1] + ret <8 x float> %res +} +declare <8 x float> @llvm.x86.avx.loadu.ps.256(i8*) nounwind readonly + + +define <2 x double> @test_x86_avx_maskload_pd(i8* %a0, <2 x double> %a1) { + ; CHECK: vmaskmovpd + %res = call <2 x double> @llvm.x86.avx.maskload.pd(i8* %a0, <2 x double> %a1) ; <<2 x double>> [#uses=1] + ret <2 x double> %res +} +declare <2 x double> @llvm.x86.avx.maskload.pd(i8*, <2 x double>) nounwind readonly + + +define <4 x double> @test_x86_avx_maskload_pd_256(i8* %a0, <4 x double> %a1) { + ; CHECK: vmaskmovpd + %res = call <4 x double> @llvm.x86.avx.maskload.pd.256(i8* %a0, <4 x double> %a1) ; <<4 x double>> [#uses=1] + ret <4 x double> %res +} +declare <4 x double> @llvm.x86.avx.maskload.pd.256(i8*, <4 x double>) nounwind readonly + + +define <4 x float> @test_x86_avx_maskload_ps(i8* %a0, <4 x float> %a1) { + ; CHECK: vmaskmovps + %res = call <4 x float> @llvm.x86.avx.maskload.ps(i8* %a0, <4 x float> %a1) ; <<4 x float>> [#uses=1] + ret <4 x float> %res +} +declare <4 x float> @llvm.x86.avx.maskload.ps(i8*, <4 x float>) nounwind readonly + + +define <8 x float> @test_x86_avx_maskload_ps_256(i8* %a0, <8 x float> %a1) { + ; CHECK: vmaskmovps + %res = call <8 x float> @llvm.x86.avx.maskload.ps.256(i8* %a0, <8 x float> %a1) ; <<8 x float>> [#uses=1] + ret <8 x float> %res +} +declare <8 x float> @llvm.x86.avx.maskload.ps.256(i8*, <8 x float>) nounwind readonly + + +define void @test_x86_avx_maskstore_pd(i8* %a0, <2 x double> %a1, <2 x double> %a2) { + ; CHECK: vmaskmovpd + call void @llvm.x86.avx.maskstore.pd(i8* %a0, <2 x double> %a1, <2 x double> %a2) + ret void +} +declare void @llvm.x86.avx.maskstore.pd(i8*, <2 x double>, <2 x double>) nounwind + + +define void @test_x86_avx_maskstore_pd_256(i8* %a0, <4 x double> %a1, <4 x double> %a2) { + ; CHECK: vmaskmovpd + call void @llvm.x86.avx.maskstore.pd.256(i8* %a0, <4 x double> %a1, <4 x double> %a2) + ret void +} +declare void @llvm.x86.avx.maskstore.pd.256(i8*, <4 x double>, <4 x double>) nounwind + + +define void @test_x86_avx_maskstore_ps(i8* %a0, <4 x float> %a1, <4 x float> %a2) { + ; CHECK: vmaskmovps + call void @llvm.x86.avx.maskstore.ps(i8* %a0, <4 x float> %a1, <4 x float> %a2) + ret void +} +declare void @llvm.x86.avx.maskstore.ps(i8*, <4 x float>, <4 x float>) nounwind + + +define void @test_x86_avx_maskstore_ps_256(i8* %a0, <8 x float> %a1, <8 x float> %a2) { + ; CHECK: vmaskmovps + call void @llvm.x86.avx.maskstore.ps.256(i8* %a0, <8 x float> %a1, <8 x float> %a2) + ret void +} +declare void @llvm.x86.avx.maskstore.ps.256(i8*, <8 x float>, <8 x float>) nounwind + + +define <4 x double> @test_x86_avx_max_pd_256(<4 x double> %a0, <4 x double> %a1) { + ; CHECK: vmaxpd + %res = call <4 x double> @llvm.x86.avx.max.pd.256(<4 x double> %a0, <4 x double> %a1) ; <<4 x double>> [#uses=1] + ret <4 x double> %res +} +declare <4 x double> @llvm.x86.avx.max.pd.256(<4 x double>, <4 x double>) nounwind readnone + + +define <8 x float> @test_x86_avx_max_ps_256(<8 x float> %a0, <8 x float> %a1) { + ; CHECK: vmaxps + %res = call <8 x float> @llvm.x86.avx.max.ps.256(<8 x float> %a0, <8 x float> %a1) ; <<8 x float>> [#uses=1] + ret <8 x float> %res +} +declare <8 x float> @llvm.x86.avx.max.ps.256(<8 x float>, <8 x float>) nounwind readnone + + +define <4 x double> @test_x86_avx_min_pd_256(<4 x double> %a0, <4 x double> %a1) { + ; CHECK: vminpd + %res = call <4 x double> @llvm.x86.avx.min.pd.256(<4 x double> %a0, <4 x double> %a1) ; <<4 x double>> [#uses=1] + ret <4 x double> %res +} +declare <4 x double> @llvm.x86.avx.min.pd.256(<4 x double>, <4 x double>) nounwind readnone + + +define <8 x float> @test_x86_avx_min_ps_256(<8 x float> %a0, <8 x float> %a1) { + ; CHECK: vminps + %res = call <8 x float> @llvm.x86.avx.min.ps.256(<8 x float> %a0, <8 x float> %a1) ; <<8 x float>> [#uses=1] + ret <8 x float> %res +} +declare <8 x float> @llvm.x86.avx.min.ps.256(<8 x float>, <8 x float>) nounwind readnone + + +define i32 @test_x86_avx_movmsk_pd_256(<4 x double> %a0) { + ; CHECK: vmovmskpd + %res = call i32 @llvm.x86.avx.movmsk.pd.256(<4 x double> %a0) ; [#uses=1] + ret i32 %res +} +declare i32 @llvm.x86.avx.movmsk.pd.256(<4 x double>) nounwind readnone + + +define i32 @test_x86_avx_movmsk_ps_256(<8 x float> %a0) { + ; CHECK: vmovmskps + %res = call i32 @llvm.x86.avx.movmsk.ps.256(<8 x float> %a0) ; [#uses=1] + ret i32 %res +} +declare i32 @llvm.x86.avx.movmsk.ps.256(<8 x float>) nounwind readnone + + +define void @test_x86_avx_movnt_dq_256(i8* %a0, <4 x i64> %a1) { + ; CHECK: vmovntdq + call void @llvm.x86.avx.movnt.dq.256(i8* %a0, <4 x i64> %a1) + ret void +} +declare void @llvm.x86.avx.movnt.dq.256(i8*, <4 x i64>) nounwind + + +define void @test_x86_avx_movnt_pd_256(i8* %a0, <4 x double> %a1) { + ; CHECK: vmovntpd + call void @llvm.x86.avx.movnt.pd.256(i8* %a0, <4 x double> %a1) + ret void +} +declare void @llvm.x86.avx.movnt.pd.256(i8*, <4 x double>) nounwind + + +define void @test_x86_avx_movnt_ps_256(i8* %a0, <8 x float> %a1) { + ; CHECK: vmovntps + call void @llvm.x86.avx.movnt.ps.256(i8* %a0, <8 x float> %a1) + ret void +} +declare void @llvm.x86.avx.movnt.ps.256(i8*, <8 x float>) nounwind + + +define i32 @test_x86_avx_ptestc_256(<4 x i64> %a0, <4 x i64> %a1) { + ; CHECK: vptest + ; CHECK: setb + ; CHECK: movzbl + %res = call i32 @llvm.x86.avx.ptestc.256(<4 x i64> %a0, <4 x i64> %a1) ; [#uses=1] + ret i32 %res +} +declare i32 @llvm.x86.avx.ptestc.256(<4 x i64>, <4 x i64>) nounwind readnone + + +define i32 @test_x86_avx_ptestnzc_256(<4 x i64> %a0, <4 x i64> %a1) { + ; CHECK: vptest + ; CHECK: seta + ; CHECK: movzbl + %res = call i32 @llvm.x86.avx.ptestnzc.256(<4 x i64> %a0, <4 x i64> %a1) ; [#uses=1] + ret i32 %res +} +declare i32 @llvm.x86.avx.ptestnzc.256(<4 x i64>, <4 x i64>) nounwind readnone + + +define i32 @test_x86_avx_ptestz_256(<4 x i64> %a0, <4 x i64> %a1) { + ; CHECK: vptest + ; CHECK: sete + ; CHECK: movzbl + %res = call i32 @llvm.x86.avx.ptestz.256(<4 x i64> %a0, <4 x i64> %a1) ; [#uses=1] + ret i32 %res +} +declare i32 @llvm.x86.avx.ptestz.256(<4 x i64>, <4 x i64>) nounwind readnone + + +define <8 x float> @test_x86_avx_rcp_ps_256(<8 x float> %a0) { + ; CHECK: vrcpps + %res = call <8 x float> @llvm.x86.avx.rcp.ps.256(<8 x float> %a0) ; <<8 x float>> [#uses=1] + ret <8 x float> %res +} +declare <8 x float> @llvm.x86.avx.rcp.ps.256(<8 x float>) nounwind readnone + + +define <4 x double> @test_x86_avx_round_pd_256(<4 x double> %a0) { + ; CHECK: vroundpd + %res = call <4 x double> @llvm.x86.avx.round.pd.256(<4 x double> %a0, i32 7) ; <<4 x double>> [#uses=1] + ret <4 x double> %res +} +declare <4 x double> @llvm.x86.avx.round.pd.256(<4 x double>, i32) nounwind readnone + + +define <8 x float> @test_x86_avx_round_ps_256(<8 x float> %a0) { + ; CHECK: vroundps + %res = call <8 x float> @llvm.x86.avx.round.ps.256(<8 x float> %a0, i32 7) ; <<8 x float>> [#uses=1] + ret <8 x float> %res +} +declare <8 x float> @llvm.x86.avx.round.ps.256(<8 x float>, i32) nounwind readnone + + +define <8 x float> @test_x86_avx_rsqrt_ps_256(<8 x float> %a0) { + ; CHECK: vrsqrtps + %res = call <8 x float> @llvm.x86.avx.rsqrt.ps.256(<8 x float> %a0) ; <<8 x float>> [#uses=1] + ret <8 x float> %res +} +declare <8 x float> @llvm.x86.avx.rsqrt.ps.256(<8 x float>) nounwind readnone + + +define <4 x double> @test_x86_avx_sqrt_pd_256(<4 x double> %a0) { + ; CHECK: vsqrtpd + %res = call <4 x double> @llvm.x86.avx.sqrt.pd.256(<4 x double> %a0) ; <<4 x double>> [#uses=1] + ret <4 x double> %res +} +declare <4 x double> @llvm.x86.avx.sqrt.pd.256(<4 x double>) nounwind readnone + + +define <8 x float> @test_x86_avx_sqrt_ps_256(<8 x float> %a0) { + ; CHECK: vsqrtps + %res = call <8 x float> @llvm.x86.avx.sqrt.ps.256(<8 x float> %a0) ; <<8 x float>> [#uses=1] + ret <8 x float> %res +} +declare <8 x float> @llvm.x86.avx.sqrt.ps.256(<8 x float>) nounwind readnone + + +define void @test_x86_avx_storeu_dq_256(i8* %a0, <32 x i8> %a1) { + ; CHECK: vmovdqu + call void @llvm.x86.avx.storeu.dq.256(i8* %a0, <32 x i8> %a1) + ret void +} +declare void @llvm.x86.avx.storeu.dq.256(i8*, <32 x i8>) nounwind + + +define void @test_x86_avx_storeu_pd_256(i8* %a0, <4 x double> %a1) { + ; CHECK: vmovupd + call void @llvm.x86.avx.storeu.pd.256(i8* %a0, <4 x double> %a1) + ret void +} +declare void @llvm.x86.avx.storeu.pd.256(i8*, <4 x double>) nounwind + + +define void @test_x86_avx_storeu_ps_256(i8* %a0, <8 x float> %a1) { + ; CHECK: vmovups + call void @llvm.x86.avx.storeu.ps.256(i8* %a0, <8 x float> %a1) + ret void +} +declare void @llvm.x86.avx.storeu.ps.256(i8*, <8 x float>) nounwind + + +define <4 x double> @test_x86_avx_vbroadcast_sd_256(i8* %a0) { + ; CHECK: vbroadcastsd + %res = call <4 x double> @llvm.x86.avx.vbroadcast.sd.256(i8* %a0) ; <<4 x double>> [#uses=1] + ret <4 x double> %res +} +declare <4 x double> @llvm.x86.avx.vbroadcast.sd.256(i8*) nounwind readonly + + +define <4 x double> @test_x86_avx_vbroadcastf128_pd_256(i8* %a0) { + ; CHECK: vbroadcastf128 + %res = call <4 x double> @llvm.x86.avx.vbroadcastf128.pd.256(i8* %a0) ; <<4 x double>> [#uses=1] + ret <4 x double> %res +} +declare <4 x double> @llvm.x86.avx.vbroadcastf128.pd.256(i8*) nounwind readonly + + +define <8 x float> @test_x86_avx_vbroadcastf128_ps_256(i8* %a0) { + ; CHECK: vbroadcastf128 + %res = call <8 x float> @llvm.x86.avx.vbroadcastf128.ps.256(i8* %a0) ; <<8 x float>> [#uses=1] + ret <8 x float> %res +} +declare <8 x float> @llvm.x86.avx.vbroadcastf128.ps.256(i8*) nounwind readonly + + +define <4 x float> @test_x86_avx_vbroadcastss(i8* %a0) { + ; CHECK: vbroadcastss + %res = call <4 x float> @llvm.x86.avx.vbroadcastss(i8* %a0) ; <<4 x float>> [#uses=1] + ret <4 x float> %res +} +declare <4 x float> @llvm.x86.avx.vbroadcastss(i8*) nounwind readonly + + +define <8 x float> @test_x86_avx_vbroadcastss_256(i8* %a0) { + ; CHECK: vbroadcastss + %res = call <8 x float> @llvm.x86.avx.vbroadcastss.256(i8* %a0) ; <<8 x float>> [#uses=1] + ret <8 x float> %res +} +declare <8 x float> @llvm.x86.avx.vbroadcastss.256(i8*) nounwind readonly + + +define <2 x double> @test_x86_avx_vextractf128_pd_256(<4 x double> %a0) { + ; CHECK: vextractf128 + %res = call <2 x double> @llvm.x86.avx.vextractf128.pd.256(<4 x double> %a0, i8 7) ; <<2 x double>> [#uses=1] + ret <2 x double> %res +} +declare <2 x double> @llvm.x86.avx.vextractf128.pd.256(<4 x double>, i8) nounwind readnone + + +define <4 x float> @test_x86_avx_vextractf128_ps_256(<8 x float> %a0) { + ; CHECK: vextractf128 + %res = call <4 x float> @llvm.x86.avx.vextractf128.ps.256(<8 x float> %a0, i8 7) ; <<4 x float>> [#uses=1] + ret <4 x float> %res +} +declare <4 x float> @llvm.x86.avx.vextractf128.ps.256(<8 x float>, i8) nounwind readnone + + +define <4 x i32> @test_x86_avx_vextractf128_si_256(<8 x i32> %a0) { + ; CHECK: vextractf128 + %res = call <4 x i32> @llvm.x86.avx.vextractf128.si.256(<8 x i32> %a0, i8 7) ; <<4 x i32>> [#uses=1] + ret <4 x i32> %res +} +declare <4 x i32> @llvm.x86.avx.vextractf128.si.256(<8 x i32>, i8) nounwind readnone + + +define <4 x double> @test_x86_avx_vinsertf128_pd_256(<4 x double> %a0, <2 x double> %a1) { + ; CHECK: vinsertf128 + %res = call <4 x double> @llvm.x86.avx.vinsertf128.pd.256(<4 x double> %a0, <2 x double> %a1, i8 7) ; <<4 x double>> [#uses=1] + ret <4 x double> %res +} +declare <4 x double> @llvm.x86.avx.vinsertf128.pd.256(<4 x double>, <2 x double>, i8) nounwind readnone + + +define <8 x float> @test_x86_avx_vinsertf128_ps_256(<8 x float> %a0, <4 x float> %a1) { + ; CHECK: vinsertf128 + %res = call <8 x float> @llvm.x86.avx.vinsertf128.ps.256(<8 x float> %a0, <4 x float> %a1, i8 7) ; <<8 x float>> [#uses=1] + ret <8 x float> %res +} +declare <8 x float> @llvm.x86.avx.vinsertf128.ps.256(<8 x float>, <4 x float>, i8) nounwind readnone + + +define <8 x i32> @test_x86_avx_vinsertf128_si_256(<8 x i32> %a0, <4 x i32> %a1) { + ; CHECK: vinsertf128 + %res = call <8 x i32> @llvm.x86.avx.vinsertf128.si.256(<8 x i32> %a0, <4 x i32> %a1, i8 7) ; <<8 x i32>> [#uses=1] + ret <8 x i32> %res +} +declare <8 x i32> @llvm.x86.avx.vinsertf128.si.256(<8 x i32>, <4 x i32>, i8) nounwind readnone + + +define <4 x double> @test_x86_avx_vperm2f128_pd_256(<4 x double> %a0, <4 x double> %a1) { + ; CHECK: vperm2f128 + %res = call <4 x double> @llvm.x86.avx.vperm2f128.pd.256(<4 x double> %a0, <4 x double> %a1, i8 7) ; <<4 x double>> [#uses=1] + ret <4 x double> %res +} +declare <4 x double> @llvm.x86.avx.vperm2f128.pd.256(<4 x double>, <4 x double>, i8) nounwind readnone + + +define <8 x float> @test_x86_avx_vperm2f128_ps_256(<8 x float> %a0, <8 x float> %a1) { + ; CHECK: vperm2f128 + %res = call <8 x float> @llvm.x86.avx.vperm2f128.ps.256(<8 x float> %a0, <8 x float> %a1, i8 7) ; <<8 x float>> [#uses=1] + ret <8 x float> %res +} +declare <8 x float> @llvm.x86.avx.vperm2f128.ps.256(<8 x float>, <8 x float>, i8) nounwind readnone + + +define <8 x i32> @test_x86_avx_vperm2f128_si_256(<8 x i32> %a0, <8 x i32> %a1) { + ; CHECK: vperm2f128 + %res = call <8 x i32> @llvm.x86.avx.vperm2f128.si.256(<8 x i32> %a0, <8 x i32> %a1, i8 7) ; <<8 x i32>> [#uses=1] + ret <8 x i32> %res +} +declare <8 x i32> @llvm.x86.avx.vperm2f128.si.256(<8 x i32>, <8 x i32>, i8) nounwind readnone + + +define <2 x double> @test_x86_avx_vpermil_pd(<2 x double> %a0) { + ; CHECK: vpermilpd + %res = call <2 x double> @llvm.x86.avx.vpermil.pd(<2 x double> %a0, i8 7) ; <<2 x double>> [#uses=1] + ret <2 x double> %res +} +declare <2 x double> @llvm.x86.avx.vpermil.pd(<2 x double>, i8) nounwind readnone + + +define <4 x double> @test_x86_avx_vpermil_pd_256(<4 x double> %a0) { + ; CHECK: vpermilpd + %res = call <4 x double> @llvm.x86.avx.vpermil.pd.256(<4 x double> %a0, i8 7) ; <<4 x double>> [#uses=1] + ret <4 x double> %res +} +declare <4 x double> @llvm.x86.avx.vpermil.pd.256(<4 x double>, i8) nounwind readnone + + +define <4 x float> @test_x86_avx_vpermil_ps(<4 x float> %a0) { + ; CHECK: vpermilps + %res = call <4 x float> @llvm.x86.avx.vpermil.ps(<4 x float> %a0, i8 7) ; <<4 x float>> [#uses=1] + ret <4 x float> %res +} +declare <4 x float> @llvm.x86.avx.vpermil.ps(<4 x float>, i8) nounwind readnone + + +define <8 x float> @test_x86_avx_vpermil_ps_256(<8 x float> %a0) { + ; CHECK: vpermilps + %res = call <8 x float> @llvm.x86.avx.vpermil.ps.256(<8 x float> %a0, i8 7) ; <<8 x float>> [#uses=1] + ret <8 x float> %res +} +declare <8 x float> @llvm.x86.avx.vpermil.ps.256(<8 x float>, i8) nounwind readnone + + +define <2 x double> @test_x86_avx_vpermilvar_pd(<2 x double> %a0, <2 x i64> %a1) { + ; CHECK: vpermilpd + %res = call <2 x double> @llvm.x86.avx.vpermilvar.pd(<2 x double> %a0, <2 x i64> %a1) ; <<2 x double>> [#uses=1] + ret <2 x double> %res +} +declare <2 x double> @llvm.x86.avx.vpermilvar.pd(<2 x double>, <2 x i64>) nounwind readnone + + +define <4 x double> @test_x86_avx_vpermilvar_pd_256(<4 x double> %a0, <4 x i64> %a1) { + ; CHECK: vpermilpd + %res = call <4 x double> @llvm.x86.avx.vpermilvar.pd.256(<4 x double> %a0, <4 x i64> %a1) ; <<4 x double>> [#uses=1] + ret <4 x double> %res +} +declare <4 x double> @llvm.x86.avx.vpermilvar.pd.256(<4 x double>, <4 x i64>) nounwind readnone + + +define <4 x float> @test_x86_avx_vpermilvar_ps(<4 x float> %a0, <4 x i32> %a1) { + ; CHECK: vpermilps + %res = call <4 x float> @llvm.x86.avx.vpermilvar.ps(<4 x float> %a0, <4 x i32> %a1) ; <<4 x float>> [#uses=1] + ret <4 x float> %res +} +declare <4 x float> @llvm.x86.avx.vpermilvar.ps(<4 x float>, <4 x i32>) nounwind readnone + + +define <8 x float> @test_x86_avx_vpermilvar_ps_256(<8 x float> %a0, <8 x i32> %a1) { + ; CHECK: vpermilps + %res = call <8 x float> @llvm.x86.avx.vpermilvar.ps.256(<8 x float> %a0, <8 x i32> %a1) ; <<8 x float>> [#uses=1] + ret <8 x float> %res +} +declare <8 x float> @llvm.x86.avx.vpermilvar.ps.256(<8 x float>, <8 x i32>) nounwind readnone + + +define i32 @test_x86_avx_vtestc_pd(<2 x double> %a0, <2 x double> %a1) { + ; CHECK: vtestpd + ; CHECK: setb + ; CHECK: movzbl + %res = call i32 @llvm.x86.avx.vtestc.pd(<2 x double> %a0, <2 x double> %a1) ; [#uses=1] + ret i32 %res +} +declare i32 @llvm.x86.avx.vtestc.pd(<2 x double>, <2 x double>) nounwind readnone + + +define i32 @test_x86_avx_vtestc_pd_256(<4 x double> %a0, <4 x double> %a1) { + ; CHECK: vtestpd + ; CHECK: setb + ; CHECK: movzbl + %res = call i32 @llvm.x86.avx.vtestc.pd.256(<4 x double> %a0, <4 x double> %a1) ; [#uses=1] + ret i32 %res +} +declare i32 @llvm.x86.avx.vtestc.pd.256(<4 x double>, <4 x double>) nounwind readnone + + +define i32 @test_x86_avx_vtestc_ps(<4 x float> %a0, <4 x float> %a1) { + ; CHECK: vtestps + ; CHECK: setb + ; CHECK: movzbl + %res = call i32 @llvm.x86.avx.vtestc.ps(<4 x float> %a0, <4 x float> %a1) ; [#uses=1] + ret i32 %res +} +declare i32 @llvm.x86.avx.vtestc.ps(<4 x float>, <4 x float>) nounwind readnone + + +define i32 @test_x86_avx_vtestc_ps_256(<8 x float> %a0, <8 x float> %a1) { + ; CHECK: vtestps + ; CHECK: setb + ; CHECK: movzbl + %res = call i32 @llvm.x86.avx.vtestc.ps.256(<8 x float> %a0, <8 x float> %a1) ; [#uses=1] + ret i32 %res +} +declare i32 @llvm.x86.avx.vtestc.ps.256(<8 x float>, <8 x float>) nounwind readnone + + +define i32 @test_x86_avx_vtestnzc_pd(<2 x double> %a0, <2 x double> %a1) { + ; CHECK: vtestpd + ; CHECK: seta + ; CHECK: movzbl + %res = call i32 @llvm.x86.avx.vtestnzc.pd(<2 x double> %a0, <2 x double> %a1) ; [#uses=1] + ret i32 %res +} +declare i32 @llvm.x86.avx.vtestnzc.pd(<2 x double>, <2 x double>) nounwind readnone + + +define i32 @test_x86_avx_vtestnzc_pd_256(<4 x double> %a0, <4 x double> %a1) { + ; CHECK: vtestpd + ; CHECK: seta + ; CHECK: movzbl + %res = call i32 @llvm.x86.avx.vtestnzc.pd.256(<4 x double> %a0, <4 x double> %a1) ; [#uses=1] + ret i32 %res +} +declare i32 @llvm.x86.avx.vtestnzc.pd.256(<4 x double>, <4 x double>) nounwind readnone + + +define i32 @test_x86_avx_vtestnzc_ps(<4 x float> %a0, <4 x float> %a1) { + ; CHECK: vtestps + ; CHECK: seta + ; CHECK: movzbl + %res = call i32 @llvm.x86.avx.vtestnzc.ps(<4 x float> %a0, <4 x float> %a1) ; [#uses=1] + ret i32 %res +} +declare i32 @llvm.x86.avx.vtestnzc.ps(<4 x float>, <4 x float>) nounwind readnone + + +define i32 @test_x86_avx_vtestnzc_ps_256(<8 x float> %a0, <8 x float> %a1) { + ; CHECK: vtestps + ; CHECK: seta + ; CHECK: movzbl + %res = call i32 @llvm.x86.avx.vtestnzc.ps.256(<8 x float> %a0, <8 x float> %a1) ; [#uses=1] + ret i32 %res +} +declare i32 @llvm.x86.avx.vtestnzc.ps.256(<8 x float>, <8 x float>) nounwind readnone + + +define i32 @test_x86_avx_vtestz_pd(<2 x double> %a0, <2 x double> %a1) { + ; CHECK: vtestpd + ; CHECK: sete + ; CHECK: movzbl + %res = call i32 @llvm.x86.avx.vtestz.pd(<2 x double> %a0, <2 x double> %a1) ; [#uses=1] + ret i32 %res +} +declare i32 @llvm.x86.avx.vtestz.pd(<2 x double>, <2 x double>) nounwind readnone + + +define i32 @test_x86_avx_vtestz_pd_256(<4 x double> %a0, <4 x double> %a1) { + ; CHECK: vtestpd + ; CHECK: sete + ; CHECK: movzbl + %res = call i32 @llvm.x86.avx.vtestz.pd.256(<4 x double> %a0, <4 x double> %a1) ; [#uses=1] + ret i32 %res +} +declare i32 @llvm.x86.avx.vtestz.pd.256(<4 x double>, <4 x double>) nounwind readnone + + +define i32 @test_x86_avx_vtestz_ps(<4 x float> %a0, <4 x float> %a1) { + ; CHECK: vtestps + ; CHECK: sete + ; CHECK: movzbl + %res = call i32 @llvm.x86.avx.vtestz.ps(<4 x float> %a0, <4 x float> %a1) ; [#uses=1] + ret i32 %res +} +declare i32 @llvm.x86.avx.vtestz.ps(<4 x float>, <4 x float>) nounwind readnone + + +define i32 @test_x86_avx_vtestz_ps_256(<8 x float> %a0, <8 x float> %a1) { + ; CHECK: vtestps + ; CHECK: sete + ; CHECK: movzbl + %res = call i32 @llvm.x86.avx.vtestz.ps.256(<8 x float> %a0, <8 x float> %a1) ; [#uses=1] + ret i32 %res +} +declare i32 @llvm.x86.avx.vtestz.ps.256(<8 x float>, <8 x float>) nounwind readnone + + +define void @test_x86_avx_vzeroall() { + ; CHECK: vzeroall + call void @llvm.x86.avx.vzeroall() + ret void +} +declare void @llvm.x86.avx.vzeroall() nounwind + + +define void @test_x86_avx_vzeroupper() { + ; CHECK: vzeroupper + call void @llvm.x86.avx.vzeroupper() + ret void +} +declare void @llvm.x86.avx.vzeroupper() nounwind + + From bob.wilson at apple.com Wed Aug 11 16:12:32 2010 From: bob.wilson at apple.com (Bob Wilson) Date: Wed, 11 Aug 2010 21:12:32 -0000 Subject: [llvm-commits] [llvm-gcc-4.2] r110855 - /llvm-gcc-4.2/trunk/gcc/config/arm/arm.h Message-ID: <20100811211232.18A4D2A6C12C@llvm.org> Author: bwilson Date: Wed Aug 11 16:12:31 2010 New Revision: 110855 URL: http://llvm.org/viewvc/llvm-project?rev=110855&view=rev Log: Revert my incorrect fix for Radar 8284120. --- Reverse-merging r110619 into '.': U gcc/config/arm/arm.h Modified: llvm-gcc-4.2/trunk/gcc/config/arm/arm.h Modified: llvm-gcc-4.2/trunk/gcc/config/arm/arm.h URL: http://llvm.org/viewvc/llvm-project/llvm-gcc-4.2/trunk/gcc/config/arm/arm.h?rev=110855&r1=110854&r2=110855&view=diff ============================================================================== --- llvm-gcc-4.2/trunk/gcc/config/arm/arm.h (original) +++ llvm-gcc-4.2/trunk/gcc/config/arm/arm.h Wed Aug 11 16:12:31 2010 @@ -3508,13 +3508,8 @@ } \ if (TARGET_VFP3) \ F.AddFeature("vfp3"); \ - else { \ + else \ F.AddFeature("vfp3", false); \ - if (TARGET_VFP) \ - F.AddFeature("vfp2"); \ - else \ - F.AddFeature("vfp2", false); \ - } \ if (TARGET_NEON) \ F.AddFeature("neon"); \ else \ From criswell at uiuc.edu Wed Aug 11 16:38:02 2010 From: criswell at uiuc.edu (John Criswell) Date: Wed, 11 Aug 2010 21:38:02 -0000 Subject: [llvm-commits] [poolalloc] r110859 - /poolalloc/trunk/test/TEST.poolalloc.Makefile Message-ID: <20100811213802.BEDB12A6C12C@llvm.org> Author: criswell Date: Wed Aug 11 16:38:02 2010 New Revision: 110859 URL: http://llvm.org/viewvc/llvm-project?rev=110859&view=rev Log: Load DSA whenever we load the DSA Assistantance library. The devirtualizer pass uses DSA. Modified: poolalloc/trunk/test/TEST.poolalloc.Makefile Modified: poolalloc/trunk/test/TEST.poolalloc.Makefile URL: http://llvm.org/viewvc/llvm-project/poolalloc/trunk/test/TEST.poolalloc.Makefile?rev=110859&r1=110858&r2=110859&view=diff ============================================================================== --- poolalloc/trunk/test/TEST.poolalloc.Makefile (original) +++ poolalloc/trunk/test/TEST.poolalloc.Makefile Wed Aug 11 16:38:02 2010 @@ -54,8 +54,8 @@ -$(LLVMLD) -link-as-library $< $(PA_PRE_RT) -o $@ $(PROGRAMS_TO_TEST:%=Output/%.base.bc): \ -Output/%.base.bc: Output/%.temp.bc $(LOPT) $(ASSIST_SO) - -$(LOPT) -load $(ASSIST_SO) -instnamer -internalize -indclone -funcspec -ipsccp -deadargelim -instcombine -globaldce -stats $< -f -o $@ +Output/%.base.bc: Output/%.temp.bc $(LOPT) $(ASSIST_SO) $(DSA_SO) + -$(LOPT) -load $(DSA_SO) -load $(ASSIST_SO) -instnamer -internalize -indclone -funcspec -ipsccp -deadargelim -instcombine -globaldce -stats $< -f -o $@ # This rule runs the pool allocator on the .base.bc file to produce a new .bc # file From nicholas at mxc.ca Wed Aug 11 17:04:36 2010 From: nicholas at mxc.ca (Nick Lewycky) Date: Wed, 11 Aug 2010 22:04:36 -0000 Subject: [llvm-commits] [llvm] r110861 - in /llvm/trunk: include/llvm/Support/ConstantRange.h lib/Support/ConstantRange.cpp unittests/Support/ConstantRangeTest.cpp Message-ID: <20100811220436.9CD662A6C12D@llvm.org> Author: nicholas Date: Wed Aug 11 17:04:36 2010 New Revision: 110861 URL: http://llvm.org/viewvc/llvm-project?rev=110861&view=rev Log: Clean up ConstantRange a bit: - remove ashr which never worked. - fix lshr and shl and add tests. - remove dead function "intersect1Wrapped". - add a new sub method to subtract ranges, with test. Modified: llvm/trunk/include/llvm/Support/ConstantRange.h llvm/trunk/lib/Support/ConstantRange.cpp llvm/trunk/unittests/Support/ConstantRangeTest.cpp Modified: llvm/trunk/include/llvm/Support/ConstantRange.h URL: http://llvm.org/viewvc/llvm-project/llvm/trunk/include/llvm/Support/ConstantRange.h?rev=110861&r1=110860&r2=110861&view=diff ============================================================================== --- llvm/trunk/include/llvm/Support/ConstantRange.h (original) +++ llvm/trunk/include/llvm/Support/ConstantRange.h Wed Aug 11 17:04:36 2010 @@ -41,8 +41,6 @@ /// class ConstantRange { APInt Lower, Upper; - static ConstantRange intersect1Wrapped(const ConstantRange &LHS, - const ConstantRange &RHS); public: /// Initialize a full (the default) or empty set for the specified bit width. @@ -196,40 +194,43 @@ ConstantRange sextOrTrunc(uint32_t BitWidth) const; /// add - Return a new range representing the possible values resulting - /// from an addition of a value in this range and a value in Other. + /// from an addition of a value in this range and a value in \p Other. ConstantRange add(const ConstantRange &Other) const; + /// sub - Return a new range representing the possible values resulting + /// from a subtraction of a value in this range and a value in \p Other. + ConstantRange sub(const ConstantRange &Other) const; + /// multiply - Return a new range representing the possible values resulting - /// from a multiplication of a value in this range and a value in Other. + /// from a multiplication of a value in this range and a value in \p Other. /// TODO: This isn't fully implemented yet. ConstantRange multiply(const ConstantRange &Other) const; /// smax - Return a new range representing the possible values resulting - /// from a signed maximum of a value in this range and a value in Other. + /// from a signed maximum of a value in this range and a value in \p Other. ConstantRange smax(const ConstantRange &Other) const; /// umax - Return a new range representing the possible values resulting - /// from an unsigned maximum of a value in this range and a value in Other. + /// from an unsigned maximum of a value in this range and a value in \p Other. ConstantRange umax(const ConstantRange &Other) const; /// udiv - Return a new range representing the possible values resulting - /// from an unsigned division of a value in this range and a value in Other. - /// TODO: This isn't fully implemented yet. + /// from an unsigned division of a value in this range and a value in + /// \p Other. ConstantRange udiv(const ConstantRange &Other) const; /// shl - Return a new range representing the possible values resulting - /// from a left shift of a value in this range by the Amount value. - ConstantRange shl(const ConstantRange &Amount) const; + /// from a left shift of a value in this range by a value in \p Other. + /// TODO: This isn't fully implemented yet. + ConstantRange shl(const ConstantRange &Other) const; - /// ashr - Return a new range representing the possible values resulting from - /// an arithmetic right shift of a value in this range by the Amount value. - ConstantRange ashr(const ConstantRange &Amount) const; - - /// shr - Return a new range representing the possible values resulting - /// from a logical right shift of a value in this range by the Amount value. - ConstantRange lshr(const ConstantRange &Amount) const; + /// lshr - Return a new range representing the possible values resulting + /// from a logical right shift of a value in this range and a value in + /// \p Other. + ConstantRange lshr(const ConstantRange &Other) const; /// inverse - Return a new range that is the logical not of the current set. + /// ConstantRange inverse() const; /// print - Print out the bounds to a stream... Modified: llvm/trunk/lib/Support/ConstantRange.cpp URL: http://llvm.org/viewvc/llvm-project/llvm/trunk/lib/Support/ConstantRange.cpp?rev=110861&r1=110860&r2=110861&view=diff ============================================================================== --- llvm/trunk/lib/Support/ConstantRange.cpp (original) +++ llvm/trunk/lib/Support/ConstantRange.cpp Wed Aug 11 17:04:36 2010 @@ -39,7 +39,7 @@ /// Initialize a range to hold the single specified value. /// -ConstantRange::ConstantRange(const APInt & V) : Lower(V), Upper(V + 1) {} +ConstantRange::ConstantRange(const APInt &V) : Lower(V), Upper(V + 1) {} ConstantRange::ConstantRange(const APInt &L, const APInt &U) : Lower(L), Upper(U) { @@ -203,14 +203,12 @@ } /// contains - Return true if the argument is a subset of this range. -/// Two equal set contain each other. The empty set is considered to be -/// contained by all other sets. +/// Two equal sets contain each other. The empty set contained by all other +/// sets. /// bool ConstantRange::contains(const ConstantRange &Other) const { - if (isFullSet()) return true; - if (Other.isFullSet()) return false; - if (Other.isEmptySet()) return true; - if (isEmptySet()) return false; + if (isFullSet() || Other.isEmptySet()) return true; + if (isEmptySet() || Other.isFullSet()) return false; if (!isWrappedSet()) { if (Other.isWrappedSet()) @@ -236,46 +234,6 @@ return ConstantRange(Lower - Val, Upper - Val); } - -// intersect1Wrapped - This helper function is used to intersect two ranges when -// it is known that LHS is wrapped and RHS isn't. -// -ConstantRange -ConstantRange::intersect1Wrapped(const ConstantRange &LHS, - const ConstantRange &RHS) { - assert(LHS.isWrappedSet() && !RHS.isWrappedSet()); - - // Check to see if we overlap on the Left side of RHS... - // - if (RHS.Lower.ult(LHS.Upper)) { - // We do overlap on the left side of RHS, see if we overlap on the right of - // RHS... - if (RHS.Upper.ugt(LHS.Lower)) { - // Ok, the result overlaps on both the left and right sides. See if the - // resultant interval will be smaller if we wrap or not... - // - if (LHS.getSetSize().ult(RHS.getSetSize())) - return LHS; - else - return RHS; - - } else { - // No overlap on the right, just on the left. - return ConstantRange(RHS.Lower, LHS.Upper); - } - } else { - // We don't overlap on the left side of RHS, see if we overlap on the right - // of RHS... - if (RHS.Upper.ugt(LHS.Lower)) { - // Simple overlap... - return ConstantRange(LHS.Lower, RHS.Upper); - } else { - // No overlap... - return ConstantRange(LHS.getBitWidth(), false); - } - } -} - /// intersectWith - Return the range that results from the intersection of this /// range with another range. The resultant range is guaranteed to include all /// elements contained in both input ranges, and to have the smallest possible @@ -487,7 +445,7 @@ assert(SrcTySize > DstTySize && "Not a value truncation"); APInt Size(APInt::getLowBitsSet(SrcTySize, DstTySize)); if (isFullSet() || getSetSize().ugt(Size)) - return ConstantRange(DstTySize); + return ConstantRange(DstTySize, /*isFullSet=*/true); APInt L = Lower; L.trunc(DstTySize); APInt U = Upper; U.trunc(DstTySize); @@ -540,6 +498,27 @@ } ConstantRange +ConstantRange::sub(const ConstantRange &Other) const { + if (isEmptySet() || Other.isEmptySet()) + return ConstantRange(getBitWidth(), /*isFullSet=*/false); + if (isFullSet() || Other.isFullSet()) + return ConstantRange(getBitWidth(), /*isFullSet=*/true); + + APInt Spread_X = getSetSize(), Spread_Y = Other.getSetSize(); + APInt NewLower = getLower() - Other.getLower(); + APInt NewUpper = getUpper() - Other.getUpper() + 1; + if (NewLower == NewUpper) + return ConstantRange(getBitWidth(), /*isFullSet=*/true); + + ConstantRange X = ConstantRange(NewLower, NewUpper); + if (X.getSetSize().ult(Spread_X) || X.getSetSize().ult(Spread_Y)) + // We've wrapped, therefore, full set. + return ConstantRange(getBitWidth(), /*isFullSet=*/true); + + return X; +} + +ConstantRange ConstantRange::multiply(const ConstantRange &Other) const { // TODO: If either operand is a single element and the multiply is known to // be non-wrapping, round the result min and max value to the appropriate @@ -617,49 +596,40 @@ } ConstantRange -ConstantRange::shl(const ConstantRange &Amount) const { - if (isEmptySet()) - return *this; +ConstantRange::shl(const ConstantRange &Other) const { + if (isEmptySet() || Other.isEmptySet()) + return ConstantRange(getBitWidth(), /*isFullSet=*/false); - APInt min = getUnsignedMin() << Amount.getUnsignedMin(); - APInt max = getUnsignedMax() << Amount.getUnsignedMax(); + APInt min = getUnsignedMin().shl(Other.getUnsignedMin()); + APInt max = getUnsignedMax().shl(Other.getUnsignedMax()); // there's no overflow! APInt Zeros(getBitWidth(), getUnsignedMax().countLeadingZeros()); - if (Zeros.uge(Amount.getUnsignedMax())) - return ConstantRange(min, max); + if (Zeros.ugt(Other.getUnsignedMax())) + return ConstantRange(min, max + 1); // FIXME: implement the other tricky cases - return ConstantRange(getBitWidth()); + return ConstantRange(getBitWidth(), /*isFullSet=*/true); } ConstantRange -ConstantRange::ashr(const ConstantRange &Amount) const { - if (isEmptySet()) - return *this; - - APInt min = getUnsignedMax().ashr(Amount.getUnsignedMin()); - APInt max = getUnsignedMin().ashr(Amount.getUnsignedMax()); - return ConstantRange(min, max); -} - -ConstantRange -ConstantRange::lshr(const ConstantRange &Amount) const { - if (isEmptySet()) - return *this; +ConstantRange::lshr(const ConstantRange &Other) const { + if (isEmptySet() || Other.isEmptySet()) + return ConstantRange(getBitWidth(), /*isFullSet=*/false); - APInt min = getUnsignedMax().lshr(Amount.getUnsignedMin()); - APInt max = getUnsignedMin().lshr(Amount.getUnsignedMax()); - return ConstantRange(min, max); + APInt max = getUnsignedMax().lshr(Other.getUnsignedMin()); + APInt min = getUnsignedMin().lshr(Other.getUnsignedMax()); + if (min == max + 1) + return ConstantRange(getBitWidth(), /*isFullSet=*/true); + + return ConstantRange(min, max + 1); } ConstantRange ConstantRange::inverse() const { if (isFullSet()) { - return ConstantRange(APInt::getNullValue(Lower.getBitWidth()), - APInt::getNullValue(Lower.getBitWidth())); + return ConstantRange(getBitWidth(), /*isFullSet=*/false); } else if (isEmptySet()) { - return ConstantRange(APInt::getAllOnesValue(Lower.getBitWidth()), - APInt::getAllOnesValue(Lower.getBitWidth())); + return ConstantRange(getBitWidth(), /*isFullSet=*/true); } return ConstantRange(Upper, Lower); } @@ -680,5 +650,3 @@ void ConstantRange::dump() const { print(dbgs()); } - - Modified: llvm/trunk/unittests/Support/ConstantRangeTest.cpp URL: http://llvm.org/viewvc/llvm-project/llvm/trunk/unittests/Support/ConstantRangeTest.cpp?rev=110861&r1=110860&r2=110861&view=diff ============================================================================== --- llvm/trunk/unittests/Support/ConstantRangeTest.cpp (original) +++ llvm/trunk/unittests/Support/ConstantRangeTest.cpp Wed Aug 11 17:04:36 2010 @@ -259,11 +259,31 @@ EXPECT_EQ(Empty.add(Wrap), Empty); EXPECT_EQ(Empty.add(APInt(16, 4)), Empty); EXPECT_EQ(Some.add(APInt(16, 4)), - ConstantRange(APInt(16, 0xe), APInt(16, 0xaae))); + ConstantRange(APInt(16, 0xe), APInt(16, 0xaae))); EXPECT_EQ(Wrap.add(APInt(16, 4)), - ConstantRange(APInt(16, 0xaae), APInt(16, 0xe))); + ConstantRange(APInt(16, 0xaae), APInt(16, 0xe))); EXPECT_EQ(One.add(APInt(16, 4)), - ConstantRange(APInt(16, 0xe))); + ConstantRange(APInt(16, 0xe))); +} + +TEST_F(ConstantRangeTest, Sub) { + EXPECT_EQ(Full.sub(APInt(16, 4)), Full); + EXPECT_EQ(Full.sub(Full), Full); + EXPECT_EQ(Full.sub(Empty), Empty); + EXPECT_EQ(Full.sub(One), Full); + EXPECT_EQ(Full.sub(Some), Full); + EXPECT_EQ(Full.sub(Wrap), Full); + EXPECT_EQ(Empty.sub(Empty), Empty); + EXPECT_EQ(Empty.sub(One), Empty); + EXPECT_EQ(Empty.sub(Some), Empty); + EXPECT_EQ(Empty.sub(Wrap), Empty); + EXPECT_EQ(Empty.sub(APInt(16, 4)), Empty); + EXPECT_EQ(Some.sub(APInt(16, 4)), + ConstantRange(APInt(16, 0x6), APInt(16, 0xaa6))); + EXPECT_EQ(Wrap.sub(APInt(16, 4)), + ConstantRange(APInt(16, 0xaa6), APInt(16, 0x6))); + EXPECT_EQ(One.sub(APInt(16, 4)), + ConstantRange(APInt(16, 0x6))); } TEST_F(ConstantRangeTest, Multiply) { @@ -351,4 +371,44 @@ EXPECT_EQ(Wrap.udiv(Wrap), Full); } +TEST_F(ConstantRangeTest, Shl) { + EXPECT_EQ(Full.shl(Full), Full); + EXPECT_EQ(Full.shl(Empty), Empty); + EXPECT_EQ(Full.shl(One), Full); // TODO: [0, (-1 << 0xa) + 1) + EXPECT_EQ(Full.shl(Some), Full); // TODO: [0, (-1 << 0xa) + 1) + EXPECT_EQ(Full.shl(Wrap), Full); + EXPECT_EQ(Empty.shl(Empty), Empty); + EXPECT_EQ(Empty.shl(One), Empty); + EXPECT_EQ(Empty.shl(Some), Empty); + EXPECT_EQ(Empty.shl(Wrap), Empty); + EXPECT_EQ(One.shl(One), ConstantRange(APInt(16, 0xa << 0xa), + APInt(16, (0xa << 0xa) + 1))); + EXPECT_EQ(One.shl(Some), Full); // TODO: [0xa << 0xa, 0) + EXPECT_EQ(One.shl(Wrap), Full); // TODO: [0xa, 0xa << 14 + 1) + EXPECT_EQ(Some.shl(Some), Full); // TODO: [0xa << 0xa, 0xfc01) + EXPECT_EQ(Some.shl(Wrap), Full); // TODO: [0xa, 0x7ff << 0x5 + 1) + EXPECT_EQ(Wrap.shl(Wrap), Full); +} + +TEST_F(ConstantRangeTest, Lshr) { + EXPECT_EQ(Full.lshr(Full), Full); + EXPECT_EQ(Full.lshr(Empty), Empty); + EXPECT_EQ(Full.lshr(One), ConstantRange(APInt(16, 0), + APInt(16, (0xffff >> 0xa) + 1))); + EXPECT_EQ(Full.lshr(Some), ConstantRange(APInt(16, 0), + APInt(16, (0xffff >> 0xa) + 1))); + EXPECT_EQ(Full.lshr(Wrap), Full); + EXPECT_EQ(Empty.lshr(Empty), Empty); + EXPECT_EQ(Empty.lshr(One), Empty); + EXPECT_EQ(Empty.lshr(Some), Empty); + EXPECT_EQ(Empty.lshr(Wrap), Empty); + EXPECT_EQ(One.lshr(One), ConstantRange(APInt(16, 0))); + EXPECT_EQ(One.lshr(Some), ConstantRange(APInt(16, 0))); + EXPECT_EQ(One.lshr(Wrap), ConstantRange(APInt(16, 0), APInt(16, 0xb))); + EXPECT_EQ(Some.lshr(Some), ConstantRange(APInt(16, 0), + APInt(16, (0xaaa >> 0xa) + 1))); + EXPECT_EQ(Some.lshr(Wrap), ConstantRange(APInt(16, 0), APInt(16, 0xaaa))); + EXPECT_EQ(Wrap.lshr(Wrap), Full); +} + } // anonymous namespace From matt at console-pimps.org Wed Aug 11 17:20:35 2010 From: matt at console-pimps.org (Matt Fleming) Date: Wed, 11 Aug 2010 23:20:35 +0100 Subject: [llvm-commits] [PATCH 2/5] Record a symbol's size which is needed for ELF symbol tables. In-Reply-To: References: Message-ID: <8dfd2734fd5b1963627fa8238f5e45c18096c38c.1281542945.git.matt@console-pimps.org> --- include/llvm/MC/MCAssembler.h | 14 ++++++++++++++ lib/MC/MCAssembler.cpp | 3 ++- 2 files changed, 16 insertions(+), 1 deletions(-) diff --git a/include/llvm/MC/MCAssembler.h b/include/llvm/MC/MCAssembler.h index 50cb73b..24bd7d2 100644 --- a/include/llvm/MC/MCAssembler.h +++ b/include/llvm/MC/MCAssembler.h @@ -24,6 +24,7 @@ namespace llvm { class raw_ostream; class MCAsmLayout; class MCAssembler; +class MCBinaryExpr; class MCContext; class MCCodeEmitter; class MCExpr; @@ -453,6 +454,10 @@ public: // common symbol can never get a definition. uint64_t CommonSize; + /// SymbolSize - An expression describing how to calculate the size of + /// a symbol. If a symbol has no size this field will be NULL. + const MCExpr *SymbolSize; + /// CommonAlign - The alignment of the symbol, if it is 'common'. // // FIXME: Pack this in with other fields? @@ -510,6 +515,15 @@ public: return CommonSize; } + void setSize(const MCExpr *SS) { + SymbolSize = SS; + } + + const MCExpr *getSize() { + return SymbolSize; + } + + /// getCommonAlignment - Return the alignment of a 'common' symbol. unsigned getCommonAlignment() const { assert(isCommon() && "Not a 'common' symbol!"); diff --git a/lib/MC/MCAssembler.cpp b/lib/MC/MCAssembler.cpp index 2512a81..8e255aa 100644 --- a/lib/MC/MCAssembler.cpp +++ b/lib/MC/MCAssembler.cpp @@ -211,7 +211,8 @@ MCSymbolData::MCSymbolData(const MCSymbol &_Symbol, MCFragment *_Fragment, uint64_t _Offset, MCAssembler *A) : Symbol(&_Symbol), Fragment(_Fragment), Offset(_Offset), IsExternal(false), IsPrivateExtern(false), - CommonSize(0), CommonAlign(0), Flags(0), Index(0) + CommonSize(0), SymbolSize(0), CommonAlign(0), + Flags(0), Index(0) { if (A) A->getSymbolList().push_back(this); -- 1.6.4.rc0 From matt at console-pimps.org Wed Aug 11 17:20:34 2010 From: matt at console-pimps.org (Matt Fleming) Date: Wed, 11 Aug 2010 23:20:34 +0100 Subject: [llvm-commits] [PATCH 1/5] ELF entry size support. In-Reply-To: References: Message-ID: Some ELF sections contain fixed-sized entries. Provide a way to record the entry size of a section. --- include/llvm/MC/MCContext.h | 3 ++- include/llvm/MC/MCSectionELF.h | 5 +++++ 2 files changed, 7 insertions(+), 1 deletions(-) diff --git a/include/llvm/MC/MCContext.h b/include/llvm/MC/MCContext.h index 4db0491..17e79fb 100644 --- a/include/llvm/MC/MCContext.h +++ b/include/llvm/MC/MCContext.h @@ -129,7 +129,8 @@ namespace llvm { const MCSection *getELFSection(StringRef Section, unsigned Type, unsigned Flags, SectionKind Kind, - bool IsExplicit = false); + bool IsExplicit = false, + unsigned EntrySize = 0); const MCSection *getCOFFSection(StringRef Section, unsigned Characteristics, int Selection, SectionKind Kind); diff --git a/include/llvm/MC/MCSectionELF.h b/include/llvm/MC/MCSectionELF.h index 5fe8171..a90aa38 100644 --- a/include/llvm/MC/MCSectionELF.h +++ b/include/llvm/MC/MCSectionELF.h @@ -35,6 +35,11 @@ class MCSectionELF : public MCSection { /// IsExplicit - Indicates that this section comes from globals with an /// explicit section specified. bool IsExplicit; + + /// EntrySize - The size of each entry in this section. This size only + /// makes sense for sections that contain fixed-sized entries. If a + /// section does not contain fixed-sized entries 'EntrySize' will be 0. + unsigned EntrySize; private: friend class MCContext; -- 1.6.4.rc0 From matt at console-pimps.org Wed Aug 11 17:20:33 2010 From: matt at console-pimps.org (Matt Fleming) Date: Wed, 11 Aug 2010 23:20:33 +0100 Subject: [llvm-commits] [PATCH 0/5] ELF object support Message-ID: This series contains the patches that have been sitting in my github tree that me and Roman Divacky have been working on for a while now. It isn't a complete implementation but is enough to get a semi-complete relocatable ELF file emitted. This is version 2 of the series. I've reworked some of the code based on comments and feedback from the llvm-commits list and Eli Friedman. The ELF object writer code is now endian safe, many magic numbers have been replaced with symbols and MCELFStreamer now inherits from MCObjectStreamer instead of MCStreamer. Again, all comments welcome. Matt Fleming (5): ELF entry size support. Record a symbol's size which is needed for ELF symbol tables. Layout helper function. Add ELF ObjectWriter and Streamer support. Hookup ELF support for X86. include/llvm/MC/ELFObjectWriter.h | 46 ++ include/llvm/MC/MCAssembler.h | 16 + include/llvm/MC/MCContext.h | 3 +- include/llvm/MC/MCELFSymbolFlags.h | 54 ++ include/llvm/MC/MCSectionELF.h | 10 +- include/llvm/MC/MCStreamer.h | 6 + include/llvm/Support/ELF.h | 6 + lib/MC/CMakeLists.txt | 2 + lib/MC/ELFObjectWriter.cpp | 1032 +++++++++++++++++++++++++++++++++++ lib/MC/MCAssembler.cpp | 37 ++- lib/MC/MCContext.cpp | 4 +- lib/MC/MCELFStreamer.cpp | 401 ++++++++++++++ lib/Target/X86/X86AsmBackend.cpp | 17 +- lib/Target/X86/X86TargetMachine.cpp | 3 +- 14 files changed, 1625 insertions(+), 12 deletions(-) create mode 100644 include/llvm/MC/ELFObjectWriter.h create mode 100644 include/llvm/MC/MCELFSymbolFlags.h create mode 100644 lib/MC/ELFObjectWriter.cpp create mode 100644 lib/MC/MCELFStreamer.cpp From matt at console-pimps.org Wed Aug 11 17:20:36 2010 From: matt at console-pimps.org (Matt Fleming) Date: Wed, 11 Aug 2010 23:20:36 +0100 Subject: [llvm-commits] [PATCH 3/5] Layout helper function. In-Reply-To: <8dfd2734fd5b1963627fa8238f5e45c18096c38c.1281542945.git.matt@console-pimps.org> References: <8dfd2734fd5b1963627fa8238f5e45c18096c38c.1281542945.git.matt@console-pimps.org> Message-ID: Introduce a helper method to add a section to the end of a layout. This will be used by the ELF ObjectWriter code to add the metadata sections (symbol table, etc) to the end of an object file. --- include/llvm/MC/MCAssembler.h | 2 ++ lib/MC/MCAssembler.cpp | 34 ++++++++++++++++++++++++++++++++++ 2 files changed, 36 insertions(+), 0 deletions(-) diff --git a/include/llvm/MC/MCAssembler.h b/include/llvm/MC/MCAssembler.h index 24bd7d2..bade9d3 100644 --- a/include/llvm/MC/MCAssembler.h +++ b/include/llvm/MC/MCAssembler.h @@ -664,6 +664,8 @@ public: void WriteSectionData(const MCSectionData *Section, const MCAsmLayout &Layout, MCObjectWriter *OW) const; + void AddSectionToTheEnd(MCSectionData &SD, MCAsmLayout &Layout); + public: /// Construct a new assembler instance. /// diff --git a/lib/MC/MCAssembler.cpp b/lib/MC/MCAssembler.cpp index 8e255aa..35f3956 100644 --- a/lib/MC/MCAssembler.cpp +++ b/lib/MC/MCAssembler.cpp @@ -652,6 +652,40 @@ void MCAssembler::WriteSectionData(const MCSectionData *SD, assert(OW->getStream().tell() - Start == Layout.getSectionFileSize(SD)); } +void MCAssembler::AddSectionToTheEnd(MCSectionData &SD, MCAsmLayout &Layout) { + // Create dummy fragments and assign section ordinals. + unsigned SectionIndex = 0; + for (MCAssembler::iterator it = begin(), ie = end(); it != ie; ++it) + SectionIndex++; + + SD.setOrdinal(SectionIndex); + + // Assign layout order indices to sections and fragments. + unsigned FragmentIndex = 0; + unsigned i = 0; + for (unsigned e = Layout.getSectionOrder().size(); i != e; ++i) { + MCSectionData *SD = Layout.getSectionOrder()[i]; + + for (MCSectionData::iterator it2 = SD->begin(), + ie2 = SD->end(); it2 != ie2; ++it2) + FragmentIndex++; + } + + SD.setLayoutOrder(i); + for (MCSectionData::iterator it2 = SD.begin(), + ie2 = SD.end(); it2 != ie2; ++it2) { + it2->setLayoutOrder(FragmentIndex++); + } + Layout.getSectionOrder().push_back(&SD); + + Layout.LayoutSection(&SD); + + // Layout until everything fits. + while (LayoutOnce(Layout)) + continue; + +} + void MCAssembler::Finish(MCObjectWriter *Writer) { DEBUG_WITH_TYPE("mc-dump", { llvm::errs() << "assembler backend - pre-layout\n--\n"; -- 1.6.4.rc0 From matt at console-pimps.org Wed Aug 11 17:20:37 2010 From: matt at console-pimps.org (Matt Fleming) Date: Wed, 11 Aug 2010 23:20:37 +0100 Subject: [llvm-commits] [PATCH 4/5] Add ELF ObjectWriter and Streamer support. In-Reply-To: References: <8dfd2734fd5b1963627fa8238f5e45c18096c38c.1281542945.git.matt@console-pimps.org> Message-ID: <9cdd00007aa27877807cea203cdbc02984088a8e.1281542945.git.matt@console-pimps.org> --- include/llvm/MC/ELFObjectWriter.h | 46 ++ include/llvm/MC/MCELFSymbolFlags.h | 54 ++ include/llvm/MC/MCSectionELF.h | 5 +- include/llvm/MC/MCStreamer.h | 6 + include/llvm/Support/ELF.h | 6 + lib/MC/CMakeLists.txt | 2 + lib/MC/ELFObjectWriter.cpp | 1032 ++++++++++++++++++++++++++++++++++++ lib/MC/MCContext.cpp | 4 +- lib/MC/MCELFStreamer.cpp | 401 ++++++++++++++ 9 files changed, 1552 insertions(+), 4 deletions(-) create mode 100644 include/llvm/MC/ELFObjectWriter.h create mode 100644 include/llvm/MC/MCELFSymbolFlags.h create mode 100644 lib/MC/ELFObjectWriter.cpp create mode 100644 lib/MC/MCELFStreamer.cpp diff --git a/include/llvm/MC/ELFObjectWriter.h b/include/llvm/MC/ELFObjectWriter.h new file mode 100644 index 0000000..3b9951f --- /dev/null +++ b/include/llvm/MC/ELFObjectWriter.h @@ -0,0 +1,46 @@ +//===-- llvm/MC/ELFObjectWriter.h - ELF File Writer ---------*- C++ -*-===// +// +// The LLVM Compiler Infrastructure +// +// This file is distributed under the University of Illinois Open Source +// License. See LICENSE.TXT for details. +// +//===----------------------------------------------------------------------===// + +#ifndef LLVM_MC_ELFOBJECTWRITER_H +#define LLVM_MC_ELFOBJECTWRITER_H + +#include "llvm/MC/MCObjectWriter.h" +#include "llvm/Support/raw_ostream.h" +#include + +namespace llvm { +class MCAsmFixup; +class MCAssembler; +class MCFragment; +class MCValue; +class raw_ostream; + +class ELFObjectWriter : public MCObjectWriter { + void *Impl; + +public: + ELFObjectWriter(raw_ostream &OS, bool Is64Bit, bool IsLittleEndian = true, + bool HasRelocationAddend = true); + + virtual ~ELFObjectWriter(); + + virtual void ExecutePostLayoutBinding(MCAssembler &Asm); + + virtual void RecordRelocation(const MCAssembler &Asm, + const MCAsmLayout &Layout, + const MCFragment *Fragment, + const MCFixup &Fixup, MCValue Target, + uint64_t &FixedValue); + + virtual void WriteObject(const MCAssembler &Asm, const MCAsmLayout &Layout); +}; + +} // End llvm namespace + +#endif diff --git a/include/llvm/MC/MCELFSymbolFlags.h b/include/llvm/MC/MCELFSymbolFlags.h new file mode 100644 index 0000000..eb7978b --- /dev/null +++ b/include/llvm/MC/MCELFSymbolFlags.h @@ -0,0 +1,54 @@ +//===- MCELFSymbolFlags.h - ELF Symbol Flags ----------------*- C++ -*-===// +// +// The LLVM Compiler Infrastructure +// +// This file is distributed under the University of Illinois Open Source +// License. See LICENSE.TXT for details. +// +//===----------------------------------------------------------------------===// +// +// This file declares the SymbolFlags used for the ELF target. +// +//===----------------------------------------------------------------------===// + +#ifndef LLVM_MC_MCELFSYMBOLFLAGS_H +#define LLVM_MC_MCELFSYMBOLFLAGS_H + +#include "llvm/Support/ELF.h" + +// Because all the symbol flags need to be stored in the MCSymbolData +// 'flags' variable we need to provide shift constants per flag type. + +namespace llvm { + enum { + ELF_STT_Shift = 0, // Shift value for STT_* flags. + ELF_STB_Shift = 4, // Shift value for STB_* flags. + ELF_STV_Shift = 8 // Shift value ofr STV_* flags. + }; + + enum SymbolFlags { + ELF_STB_Local = (ELF::STB_LOCAL << ELF_STB_Shift), + ELF_STB_Global = (ELF::STB_GLOBAL << ELF_STB_Shift), + ELF_STB_Weak = (ELF::STB_WEAK << ELF_STB_Shift), + ELF_STB_Loproc = (ELF::STB_LOPROC << ELF_STB_Shift), + ELF_STB_Hiproc = (ELF::STB_HIPROC << ELF_STB_Shift), + + ELF_STT_Notype = (ELF::STT_NOTYPE << ELF_STT_Shift), + ELF_STT_Object = (ELF::STT_OBJECT << ELF_STT_Shift), + ELF_STT_Func = (ELF::STT_FUNC << ELF_STT_Shift), + ELF_STT_Section = (ELF::STT_SECTION << ELF_STT_Shift), + ELF_STT_File = (ELF::STT_FILE << ELF_STT_Shift), + ELF_STT_Common = (ELF::STT_COMMON << ELF_STT_Shift), + ELF_STT_Tls = (ELF::STT_TLS << ELF_STT_Shift), + ELF_STT_Loproc = (ELF::STT_LOPROC << ELF_STT_Shift), + ELF_STT_Hiproc = (ELF::STT_HIPROC << ELF_STT_Shift), + + ELF_STV_Default = (ELF::STV_DEFAULT << ELF_STV_Shift), + ELF_STV_Internal = (ELF::STV_INTERNAL << ELF_STV_Shift), + ELF_STV_Hidden = (ELF::STV_HIDDEN << ELF_STV_Shift), + ELF_STV_Protected = (ELF::STV_PROTECTED << ELF_STV_Shift) + }; + +} // end namespace llvm + +#endif diff --git a/include/llvm/MC/MCSectionELF.h b/include/llvm/MC/MCSectionELF.h index a90aa38..5de0bf5 100644 --- a/include/llvm/MC/MCSectionELF.h +++ b/include/llvm/MC/MCSectionELF.h @@ -44,9 +44,9 @@ class MCSectionELF : public MCSection { private: friend class MCContext; MCSectionELF(StringRef Section, unsigned type, unsigned flags, - SectionKind K, bool isExplicit) + SectionKind K, bool isExplicit, unsigned entrySize) : MCSection(SV_ELF, K), SectionName(Section), Type(type), Flags(flags), - IsExplicit(isExplicit) {} + IsExplicit(isExplicit), EntrySize(entrySize) {} ~MCSectionELF(); public: @@ -174,6 +174,7 @@ public: StringRef getSectionName() const { return SectionName; } unsigned getType() const { return Type; } unsigned getFlags() const { return Flags; } + unsigned getEntrySize() const { return EntrySize; } void PrintSwitchToSection(const MCAsmInfo &MAI, raw_ostream &OS) const; diff --git a/include/llvm/MC/MCStreamer.h b/include/llvm/MC/MCStreamer.h index 5767a94..e152c39 100644 --- a/include/llvm/MC/MCStreamer.h +++ b/include/llvm/MC/MCStreamer.h @@ -359,6 +359,12 @@ namespace llvm { MCCodeEmitter &CE, raw_ostream &OS, bool RelaxAll = false); + /// createELFStreamer - Create a machine code streamer which will generate + /// ELF format object files. + MCStreamer *createELFStreamer(MCContext &Ctx, TargetAsmBackend &TAB, + raw_ostream &OS, MCCodeEmitter *CE, + bool RelaxAll = false); + /// createLoggingStreamer - Create a machine code streamer which just logs the /// API calls and then dispatches to another streamer. /// diff --git a/include/llvm/Support/ELF.h b/include/llvm/Support/ELF.h index a4223cf..f33aeb4 100644 --- a/include/llvm/Support/ELF.h +++ b/include/llvm/Support/ELF.h @@ -330,6 +330,12 @@ struct Elf64_Sym { } }; +// The size (in bytes) of symbol table entries. +enum { + SYMENTRY_SIZE32 = 16, // 32-bit symbol entry size + SYMENTRY_SIZE64 = 24 // 64-bit symbol entry size. +}; + // Symbol bindings. enum { STB_LOCAL = 0, // Local symbol, not visible outside obj file containing def diff --git a/lib/MC/CMakeLists.txt b/lib/MC/CMakeLists.txt index 7b9b355..60a3a3e 100644 --- a/lib/MC/CMakeLists.txt +++ b/lib/MC/CMakeLists.txt @@ -1,4 +1,5 @@ add_llvm_library(LLVMMC + ELFObjectWriter.cpp MCAsmInfo.cpp MCAsmInfoCOFF.cpp MCAsmInfoDarwin.cpp @@ -7,6 +8,7 @@ add_llvm_library(LLVMMC MCCodeEmitter.cpp MCContext.cpp MCDisassembler.cpp + MCELFStreamer.cpp MCExpr.cpp MCInst.cpp MCInstPrinter.cpp diff --git a/lib/MC/ELFObjectWriter.cpp b/lib/MC/ELFObjectWriter.cpp new file mode 100644 index 0000000..84a154c --- /dev/null +++ b/lib/MC/ELFObjectWriter.cpp @@ -0,0 +1,1032 @@ +//===- lib/MC/ELFObjectWriter.cpp - ELF File Writer -------------------===// +// +// The LLVM Compiler Infrastructure +// +// This file is distributed under the University of Illinois Open Source +// License. See LICENSE.TXT for details. +// +//===----------------------------------------------------------------------===// +// +// This file implements ELF object file writer information. +// +//===----------------------------------------------------------------------===// + +#include "llvm/MC/ELFObjectWriter.h" +#include "llvm/ADT/STLExtras.h" +#include "llvm/ADT/StringMap.h" +#include "llvm/ADT/Twine.h" +#include "llvm/MC/MCAssembler.h" +#include "llvm/MC/MCAsmLayout.h" +#include "llvm/MC/MCContext.h" +#include "llvm/MC/MCELFSymbolFlags.h" +#include "llvm/MC/MCExpr.h" +#include "llvm/MC/MCObjectWriter.h" +#include "llvm/MC/MCSectionELF.h" +#include "llvm/MC/MCSymbol.h" +#include "llvm/MC/MCValue.h" +#include "llvm/Support/Debug.h" +#include "llvm/Support/ErrorHandling.h" +#include "llvm/Support/ELF.h" +#include "llvm/Target/TargetAsmBackend.h" + +#include "../Target/X86/X86FixupKinds.h" + +#include +using namespace llvm; + +namespace { + + class ELFObjectWriterImpl { + static bool isFixupKindX86PCRel(unsigned Kind) { + switch (Kind) { + default: + return false; + case X86::reloc_pcrel_1byte: + case X86::reloc_pcrel_4byte: + case X86::reloc_riprel_4byte: + case X86::reloc_riprel_4byte_movq_load: + return true; + } + } + + static bool isFixupKindX86RIPRel(unsigned Kind) { + return Kind == X86::reloc_riprel_4byte || + Kind == X86::reloc_riprel_4byte_movq_load; + } + + + /// ELFSymbolData - Helper struct for containing some precomputed information + /// on symbols. + struct ELFSymbolData { + MCSymbolData *SymbolData; + uint64_t StringIndex; + uint32_t SectionIndex; + + // Support lexicographic sorting. + bool operator<(const ELFSymbolData &RHS) const { + const std::string &Name = SymbolData->getSymbol().getName(); + return Name < RHS.SymbolData->getSymbol().getName(); + } + }; + + /// @name Relocation Data + /// @{ + + struct ELFRelocationEntry { + // Make these big enough for both 32-bit and 64-bit + uint64_t r_offset; + uint64_t r_info; + uint64_t r_addend; + + // Support lexicographic sorting. + bool operator<(const ELFRelocationEntry &RE) const { + return RE.r_offset < r_offset; + } + }; + + llvm::DenseMap > Relocations; + DenseMap SectionStringTableIndex; + + /// @} + /// @name Symbol Table Data + /// @{ + + SmallString<256> StringTable; + std::vector LocalSymbolData; + std::vector ExternalSymbolData; + std::vector UndefinedSymbolData; + + /// @} + + ELFObjectWriter *Writer; + + raw_ostream &OS; + + // This holds the current offset into the object file. + size_t FileOff; + + unsigned Is64Bit : 1; + + bool HasRelocationAddend; + + // This holds the symbol table index of the last local symbol. + unsigned LastLocalSymbolIndex; + // This holds the .strtab section index. + unsigned StringTableIndex; + + unsigned ShstrtabIndex; + + public: + ELFObjectWriterImpl(ELFObjectWriter *_Writer, bool _Is64Bit, + bool _HasRelAddend) + : Writer(_Writer), OS(Writer->getStream()), FileOff(0), + Is64Bit(_Is64Bit), HasRelocationAddend(_HasRelAddend) { + } + + void Write8(uint8_t Value) { Writer->Write8(Value); } + void Write16(uint16_t Value) { Writer->Write16(Value); } + void Write32(uint32_t Value) { Writer->Write32(Value); } + void Write64(uint64_t Value) { Writer->Write64(Value); } + void WriteZeros(unsigned N) { Writer->WriteZeros(N); } + void WriteBytes(StringRef Str, unsigned ZeroFillSize = 0) { + Writer->WriteBytes(Str, ZeroFillSize); + } + + void WriteWord(uint64_t W) { + if (Is64Bit) { + Writer->Write64(W); + } else { + Writer->Write32(W); + } + } + + void String8(char *buf, uint8_t Value) { + buf[0] = Value; + } + + void StringLE16(char *buf, uint16_t Value) { + buf[0] = char(Value >> 0); + buf[1] = char(Value >> 8); + } + + void StringLE32(char *buf, uint32_t Value) { + buf[0] = char(Value >> 0); + buf[1] = char(Value >> 8); + buf[2] = char(Value >> 16); + buf[3] = char(Value >> 24); + } + + void StringLE64(char *buf, uint64_t Value) { + buf[0] = char(Value >> 0); + buf[1] = char(Value >> 8); + buf[2] = char(Value >> 16); + buf[3] = char(Value >> 24); + buf[4] = char(Value >> 32); + buf[5] = char(Value >> 40); + buf[6] = char(Value >> 48); + buf[7] = char(Value >> 56); + } + + void StringBE16(char *buf ,uint16_t Value) { + buf[0] = char(Value >> 8); + buf[1] = char(Value >> 0); + } + + void StringBE32(char *buf, uint32_t Value) { + buf[0] = char(Value >> 24); + buf[1] = char(Value >> 16); + buf[2] = char(Value >> 8); + buf[3] = char(Value >> 0); + } + + void StringBE64(char *buf, uint64_t Value) { + buf[0] = char(Value >> 56); + buf[1] = char(Value >> 48); + buf[2] = char(Value >> 40); + buf[3] = char(Value >> 32); + buf[4] = char(Value >> 24); + buf[5] = char(Value >> 16); + buf[6] = char(Value >> 8); + buf[7] = char(Value >> 0); + } + + void String16(char *buf, uint16_t Value) { + if (Writer->isLittleEndian()) + StringLE16(buf, Value); + else + StringBE16(buf, Value); + } + + void String32(char *buf, uint32_t Value) { + if (Writer->isLittleEndian()) + StringLE32(buf, Value); + else + StringBE32(buf, Value); + } + + void String64(char *buf, uint64_t Value) { + if (Writer->isLittleEndian()) + StringLE64(buf, Value); + else + StringBE64(buf, Value); + } + + void WriteHeader(uint64_t SectionDataSize, unsigned NumberOfSections); + + void WriteSymbolEntry(MCDataFragment *F, uint64_t name, uint8_t info, + uint64_t value, uint64_t size, + uint8_t other, uint16_t shndx); + + void WriteSymbol(MCDataFragment *F, ELFSymbolData &MSD, + const MCAsmLayout &Layout); + + void WriteSymbolTable(MCDataFragment *F, const MCAssembler &Asm, + const MCAsmLayout &Layout); + + void RecordRelocation(const MCAssembler &Asm, const MCAsmLayout &Layout, + const MCFragment *Fragment, const MCFixup &Fixup, + MCValue Target, uint64_t &FixedValue); + + // XXX-PERF: this should be cached + uint64_t getNumOfLocalSymbols(const MCAssembler &Asm) { + std::vector Local; + + uint64_t Index = 0; + for (MCAssembler::const_symbol_iterator it = Asm.symbol_begin(), + ie = Asm.symbol_end(); it != ie; ++it) { + const MCSymbol &Symbol = it->getSymbol(); + + // Ignore non-linker visible symbols. + if (!Asm.isSymbolLinkerVisible(Symbol)) + continue; + + if (it->isExternal() || Symbol.isUndefined()) + continue; + + Index++; + } + + return Index; + } + + uint64_t getSymbolIndexInSymbolTable(MCAssembler &Asm, const MCSymbol *S); + + /// ComputeSymbolTable - Compute the symbol table data + /// + /// \param StringTable [out] - The string table data. + /// \param StringIndexMap [out] - Map from symbol names to offsets in the + /// string table. + void ComputeSymbolTable(MCAssembler &Asm); + + void WriteRelocation(MCAssembler &Asm, MCAsmLayout &Layout, + const MCSectionData &SD); + + void WriteRelocations(MCAssembler &Asm, MCAsmLayout &Layout) { + for (MCAssembler::const_iterator it = Asm.begin(), + ie = Asm.end(); it != ie; ++it) { + WriteRelocation(Asm, Layout, *it); + } + } + + void CreateMetadataSections(MCAssembler &Asm, MCAsmLayout &Layout); + + void ExecutePostLayoutBinding(MCAssembler &Asm) {} + + void WriteSecHdrEntry(uint32_t Name, uint32_t Type, uint64_t Flags, + uint64_t Address, uint64_t Offset, + uint64_t Size, uint32_t Link, uint32_t Info, + uint64_t Alignment, uint64_t EntrySize); + + void WriteRelocationsFragment(const MCAssembler &Asm, MCDataFragment *F, + const MCSectionData *SD); + + void WriteObject(const MCAssembler &Asm, const MCAsmLayout &Layout); + }; + +} + +// Emit the ELF header. +void ELFObjectWriterImpl::WriteHeader(uint64_t SectionDataSize, + unsigned NumberOfSections) { + // ELF Header + // ---------- + // + // Note + // ---- + // emitWord method behaves differently for ELF32 and ELF64, writing + // 4 bytes in the former and 8 in the latter. + + Write8(0x7f); // e_ident[EI_MAG0] + Write8('E'); // e_ident[EI_MAG1] + Write8('L'); // e_ident[EI_MAG2] + Write8('F'); // e_ident[EI_MAG3] + + Write8(Is64Bit ? ELF::ELFCLASS64 : ELF::ELFCLASS32); // e_ident[EI_CLASS] + + // e_ident[EI_DATA] + Write8(Writer->isLittleEndian() ? ELF::ELFDATA2LSB : ELF::ELFDATA2MSB); + + Write8(ELF::EV_CURRENT); // e_ident[EI_VERSION] + Write8(ELF::ELFOSABI_LINUX); // e_ident[EI_OSABI] + Write8(0); // e_ident[EI_ABIVERSION] + + WriteZeros(ELF::EI_NIDENT - ELF::EI_PAD); + + Write16(ELF::ET_REL); // e_type + + // FIXME: Make this configurable + Write16(ELF::EM_X86_64); // e_machine = target + + Write32(ELF::EV_CURRENT); // e_version + WriteWord(0); // e_entry, no entry point in .o file + WriteWord(0); // e_phoff, no program header for .o + WriteWord(SectionDataSize + 64); // e_shoff = sec hdr table off in bytes + + // FIXME: Make this configurable. + Write32(0); // e_flags = whatever the target wants + + // e_ehsize = ELF header size + Write16(Is64Bit ? sizeof(ELF::Elf64_Ehdr) : sizeof(ELF::Elf32_Ehdr)); + + Write16(0); // e_phentsize = prog header entry size + Write16(0); // e_phnum = # prog header entries = 0 + + // e_shentsize = Section header entry size + Write16(Is64Bit ? sizeof(ELF::Elf64_Shdr) : sizeof(ELF::Elf32_Shdr)); + + // e_shnum = # of section header ents + Write16(NumberOfSections); + + // e_shstrndx = Section # of '.shstrtab' + Write16(ShstrtabIndex); +} + +void ELFObjectWriterImpl::WriteSymbolEntry(MCDataFragment *F, uint64_t name, + uint8_t info, uint64_t value, + uint64_t size, uint8_t other, + uint16_t shndx) { + if (Is64Bit) { + char buf[8]; + + String32(buf, name); + F->getContents() += StringRef(buf, 4); // st_name + + String8(buf, info); + F->getContents() += StringRef(buf, 1); // st_info + String8(buf, other); + F->getContents() += StringRef(buf, 1); // st_other + + String16(buf, shndx); + F->getContents() += StringRef(buf, 2); // st_shndx + + String64(buf, value); + F->getContents() += StringRef(buf, 8); // st_value + + String64(buf, size); + F->getContents() += StringRef(buf, 8); // st_size + } else { + char buf[4]; + + String32(buf, name); + F->getContents() += StringRef(buf, 4); // st_name + + String32(buf, value); + F->getContents() += StringRef(buf, 4); // st_value + + String32(buf, size); + F->getContents() += StringRef(buf, 4); // st_size + + String8(buf, info); + F->getContents() += StringRef(buf, 1); // st_info + + String8(buf, other); + F->getContents() += StringRef(buf, 1); // st_other + + String16(buf, shndx); + F->getContents() += StringRef(buf, 2); // st_shndx + } +} + +void ELFObjectWriterImpl::WriteSymbol(MCDataFragment *F, ELFSymbolData &MSD, + const MCAsmLayout &Layout) { + MCSymbolData &Data = *MSD.SymbolData; + const MCSymbol &Symbol = Data.getSymbol(); + uint8_t Info = (Data.getFlags() & 0xff); + uint8_t Other = ((Data.getFlags() & 0xf00) >> ELF_STV_Shift); + uint64_t Value = 0; + uint64_t Size = 0; + const MCExpr *ESize; + + if (Data.isCommon() && Data.isExternal()) + Value = Data.getCommonAlignment(); + + ESize = Data.getSize(); + if (Data.getSize()) { + MCValue Res; + if (ESize->getKind() == MCExpr::Binary) { + const MCBinaryExpr *BE = static_cast(ESize); + + if (BE->EvaluateAsRelocatable(Res, &Layout)) { + MCSymbolData &A = + Layout.getAssembler().getSymbolData(Res.getSymA()->getSymbol()); + MCSymbolData &B = + Layout.getAssembler().getSymbolData(Res.getSymB()->getSymbol()); + + Size = Layout.getSymbolAddress(&A) - Layout.getSymbolAddress(&B); + Value = Layout.getSymbolAddress(&Data); + } + } else if (ESize->getKind() == MCExpr::Constant) { + const MCConstantExpr *CE; + CE = static_cast(ESize); + Size = CE->getValue(); + } else { + assert(0 && "Unsupported size expression"); + } + } + + // Write out the symbol table entry + WriteSymbolEntry(F, MSD.StringIndex, Info, Value, + Size, Other, MSD.SectionIndex); +} + +void ELFObjectWriterImpl::WriteSymbolTable(MCDataFragment *F, + const MCAssembler &Asm, + const MCAsmLayout &Layout) { + // The string table must be emitted first because we need the index + // into the string table for all the symbol names. + assert(StringTable.size() && "Missing string table"); + + // FIXME: Make sure the start of the symbol table is aligned. + + // The first entry is the undefined symbol entry. + unsigned EntrySize = Is64Bit ? ELF::SYMENTRY_SIZE64 : ELF::SYMENTRY_SIZE32; + for (unsigned i = 0; i < EntrySize; ++i) + F->getContents() += '\x00'; + + // Write the symbol table entries. + LastLocalSymbolIndex = LocalSymbolData.size() + 1; + for (unsigned i = 0, e = LocalSymbolData.size(); i != e; ++i) { + ELFSymbolData &MSD = LocalSymbolData[i]; + WriteSymbol(F, MSD, Layout); + } + + // Write out a symbol table entry for each section. + for (unsigned Index = 1; Index < Asm.size(); ++Index) + WriteSymbolEntry(F, 0, ELF::STT_SECTION, 0, 0, ELF::STV_DEFAULT, Index); + LastLocalSymbolIndex += Asm.size() - 1; + + for (unsigned i = 0, e = ExternalSymbolData.size(); i != e; ++i) { + ELFSymbolData &MSD = ExternalSymbolData[i]; + MCSymbolData &Data = *MSD.SymbolData; + assert((Data.getFlags() & ELF_STB_Global) && + "External symbol requires STB_GLOBAL flag"); + WriteSymbol(F, MSD, Layout); + if (Data.getFlags() & ELF_STB_Local) + LastLocalSymbolIndex++; + } + + for (unsigned i = 0, e = UndefinedSymbolData.size(); i != e; ++i) { + ELFSymbolData &MSD = UndefinedSymbolData[i]; + MCSymbolData &Data = *MSD.SymbolData; + Data.setFlags(Data.getFlags() | ELF_STB_Global); + WriteSymbol(F, MSD, Layout); + if (Data.getFlags() & ELF_STB_Local) + LastLocalSymbolIndex++; + } +} + +// FIXME: this is currently X86_64 only +void ELFObjectWriterImpl::RecordRelocation(const MCAssembler &Asm, + const MCAsmLayout &Layout, + const MCFragment *Fragment, + const MCFixup &Fixup, + MCValue Target, + uint64_t &FixedValue) { + unsigned IsPCRel = isFixupKindX86PCRel(Fixup.getKind()); + ELFRelocationEntry ERE; + struct ELF::Elf64_Rela ERE64; + + uint64_t FixupOffset = + Layout.getFragmentOffset(Fragment) + Fixup.getOffset(); + int64_t Value; + int64_t Addend = 0; + unsigned Index = 0; + unsigned Type; + + Value = Target.getConstant(); + + if (Target.isAbsolute()) { + Type = ELF::R_X86_64_NONE; + Index = 0; + } else { + const MCSymbol *Symbol = &Target.getSymA()->getSymbol(); + MCSymbolData &SD = Asm.getSymbolData(*Symbol); + const MCSymbolData *Base = Asm.getAtom(Layout, &SD); + + if (Base) { + Index = getSymbolIndexInSymbolTable(const_cast(Asm), &Base->getSymbol()); + if (Base != &SD) + Value += Layout.getSymbolAddress(&SD) - Layout.getSymbolAddress(Base); + Addend = Value; + Value = 0; + } else { + MCFragment *F = SD.getFragment(); + if (F) { + // Index of the section in .symtab against this symbol + // is being relocated + 2 (empty section + abs. symbols). + Index = SD.getFragment()->getParent()->getOrdinal() + + getNumOfLocalSymbols(Asm) + 1; + + MCSectionData *FSD = F->getParent(); + // Offset of the symbol in the section + Addend = Layout.getSymbolAddress(&SD) - Layout.getSectionAddress(FSD); + } else { + FixedValue = Value; + return; + } + } + } + + // determine the type of the relocation + if (IsPCRel) { + Type = ELF::R_X86_64_PC32; + } else { + switch (Fixup.getKind()) { + case FK_Data_8: Type = ELF::R_X86_64_64; break; + case X86::reloc_pcrel_4byte: + case FK_Data_4: + long Offset; + Offset = Target.getConstant(); + // check that the offset fits within a signed long + if (!(((long) -1 << 31) & Offset) || (((long) -1 << 31) & Offset) == ((long) -1 << 31)) + Type = ELF::R_X86_64_32S; + else + Type = ELF::R_X86_64_32; + break; + case FK_Data_2: Type = ELF::R_X86_64_16; break; + case X86::reloc_pcrel_1byte: + case FK_Data_1: + Type = ELF::R_X86_64_8; + break; + } + } + + FixedValue = Value; + + ERE64.setSymbolAndType(Index, Type); + + ERE.r_offset = FixupOffset; + ERE.r_info = ERE64.r_info; + if (HasRelocationAddend) + ERE.r_addend = Addend; + + Relocations[Fragment->getParent()].push_back(ERE); +} + +// XXX-PERF: this should be cached +uint64_t ELFObjectWriterImpl::getSymbolIndexInSymbolTable(MCAssembler &Asm, + const MCSymbol *S) { + std::vector Local; + std::vector External; + std::vector Undefined; + + for (MCAssembler::symbol_iterator it = Asm.symbol_begin(), + ie = Asm.symbol_end(); it != ie; ++it) { + const MCSymbol &Symbol = it->getSymbol(); + + // Ignore non-linker visible symbols. + if (!Asm.isSymbolLinkerVisible(Symbol)) + continue; + + if (it->isExternal() || Symbol.isUndefined()) + continue; + + ELFSymbolData MSD; + MSD.SymbolData = it; + + Local.push_back(MSD); + } + for (MCAssembler::symbol_iterator it = Asm.symbol_begin(), + ie = Asm.symbol_end(); it != ie; ++it) { + const MCSymbol &Symbol = it->getSymbol(); + + // Ignore non-linker visible symbols. + if (!Asm.isSymbolLinkerVisible(Symbol)) + continue; + + if (!it->isExternal() && !Symbol.isUndefined()) + continue; + + ELFSymbolData MSD; + MSD.SymbolData = it; + + if (Symbol.isUndefined()) { + Undefined.push_back(MSD); + } else if (Symbol.isAbsolute()) { + External.push_back(MSD); + } else if (it->isCommon()) { + External.push_back(MSD); + } else { + External.push_back(MSD); + } + } + + array_pod_sort(Local.begin(), Local.end()); + array_pod_sort(External.begin(), External.end()); + array_pod_sort(Undefined.begin(), Undefined.end()); + + for (unsigned i = 0, e = Local.size(); i != e; ++i) + if (&Local[i].SymbolData->getSymbol() == S) + return i + /* empty symbol */ 1; + for (unsigned i = 0, e = External.size(); i != e; ++i) + if (&External[i].SymbolData->getSymbol() == S) + return i + Local.size() + Asm.size() + /* empty symbol */ 1 + + /* .rela.text + .rela.eh_frame */ + 2; + for (unsigned i = 0, e = Undefined.size(); i != e; ++i) + if (&Undefined[i].SymbolData->getSymbol() == S) + return i + Local.size() + External.size() + Asm.size() + /* empty symbol */ 1 + + /* .rela.text + .rela.eh_frame */ + 2; +} + +void ELFObjectWriterImpl::ComputeSymbolTable(MCAssembler &Asm) { + // Build section lookup table. + DenseMap SectionIndexMap; + unsigned Index = 1; + for (MCAssembler::iterator it = Asm.begin(), + ie = Asm.end(); it != ie; ++it, ++Index) + SectionIndexMap[&it->getSection()] = Index; + + // Index 0 is always the empty string. + StringMap StringIndexMap; + StringTable += '\x00'; + + // Add the data for local symbols. + for (MCAssembler::symbol_iterator it = Asm.symbol_begin(), + ie = Asm.symbol_end(); it != ie; ++it) { + const MCSymbol &Symbol = it->getSymbol(); + + // Ignore non-linker visible symbols. + if (!Asm.isSymbolLinkerVisible(Symbol)) + continue; + + if (it->isExternal() || Symbol.isUndefined()) + continue; + + uint64_t &Entry = StringIndexMap[Symbol.getName()]; + if (!Entry) { + Entry = StringTable.size(); + StringTable += Symbol.getName(); + StringTable += '\x00'; + } + + ELFSymbolData MSD; + MSD.SymbolData = it; + MSD.StringIndex = Entry; + + if (Symbol.isAbsolute()) { + MSD.SectionIndex = ELF::SHN_ABS; + LocalSymbolData.push_back(MSD); + } else { + MSD.SectionIndex = SectionIndexMap.lookup(&Symbol.getSection()); + assert(MSD.SectionIndex && "Invalid section index!"); + LocalSymbolData.push_back(MSD); + } + } + + // Now add non-local symbols. + for (MCAssembler::symbol_iterator it = Asm.symbol_begin(), + ie = Asm.symbol_end(); it != ie; ++it) { + const MCSymbol &Symbol = it->getSymbol(); + + // Ignore non-linker visible symbols. + if (!Asm.isSymbolLinkerVisible(Symbol)) + continue; + + if (!it->isExternal() && !Symbol.isUndefined()) + continue; + + uint64_t &Entry = StringIndexMap[Symbol.getName()]; + if (!Entry) { + Entry = StringTable.size(); + StringTable += Symbol.getName(); + StringTable += '\x00'; + } + + ELFSymbolData MSD; + MSD.SymbolData = it; + MSD.StringIndex = Entry; + + if (Symbol.isUndefined()) { + MSD.SectionIndex = ELF::SHN_UNDEF; + // XXX: for some reason we dont Emit* this + it->setFlags(it->getFlags() | ELF_STB_Global); + UndefinedSymbolData.push_back(MSD); + } else if (Symbol.isAbsolute()) { + MSD.SectionIndex = ELF::SHN_ABS; + ExternalSymbolData.push_back(MSD); + } else if (it->isCommon()) { + MSD.SectionIndex = ELF::SHN_COMMON; + ExternalSymbolData.push_back(MSD); + } else { + MSD.SectionIndex = SectionIndexMap.lookup(&Symbol.getSection()); + assert(MSD.SectionIndex && "Invalid section index!"); + ExternalSymbolData.push_back(MSD); + } + } + + // Symbols are required to be in lexicographic order. + array_pod_sort(LocalSymbolData.begin(), LocalSymbolData.end()); + array_pod_sort(ExternalSymbolData.begin(), ExternalSymbolData.end()); + array_pod_sort(UndefinedSymbolData.begin(), UndefinedSymbolData.end()); + + // Set the symbol indices. Local symbols must come before all other + // symbols with non-local bindings. + Index = 0; + for (unsigned i = 0, e = LocalSymbolData.size(); i != e; ++i) + LocalSymbolData[i].SymbolData->setIndex(Index++); + for (unsigned i = 0, e = ExternalSymbolData.size(); i != e; ++i) + ExternalSymbolData[i].SymbolData->setIndex(Index++); + for (unsigned i = 0, e = UndefinedSymbolData.size(); i != e; ++i) + UndefinedSymbolData[i].SymbolData->setIndex(Index++); +} + +void ELFObjectWriterImpl::WriteRelocation(MCAssembler &Asm, MCAsmLayout &Layout, + const MCSectionData &SD) { + if (!Relocations[&SD].empty()) { + MCContext &Ctx = Asm.getContext(); + const MCSection *RelaSection; + const MCSectionELF &Section = + static_cast(SD.getSection()); + + const StringRef SectionName = Section.getSectionName(); + std::string RelaSectionName = ".rela"; + + RelaSectionName += SectionName; + unsigned EntrySize = Is64Bit ? ELF::SYMENTRY_SIZE64 : ELF::SYMENTRY_SIZE32; + + RelaSection = Ctx.getELFSection(RelaSectionName, ELF::SHT_RELA, 0, + SectionKind::getReadOnly(), + false, EntrySize); + + MCSectionData &RelaSD = Asm.getOrCreateSectionData(*RelaSection); + RelaSD.setAlignment(1); + + MCDataFragment *F = new MCDataFragment(&RelaSD); + + WriteRelocationsFragment(Asm, F, &SD); + + Asm.AddSectionToTheEnd(RelaSD, Layout); + } +} + +void ELFObjectWriterImpl::WriteSecHdrEntry(uint32_t Name, uint32_t Type, + uint64_t Flags, uint64_t Address, + uint64_t Offset, uint64_t Size, + uint32_t Link, uint32_t Info, + uint64_t Alignment, + uint64_t EntrySize) { + Write32(Name); // sh_name: index into string table + Write32(Type); // sh_type + WriteWord(Flags); // sh_flags + WriteWord(Address); // sh_addr + WriteWord(Offset); // sh_offset + WriteWord(Size); // sh_size + Write32(Link); // sh_link + Write32(Info); // sh_info + WriteWord(Alignment); // sh_addralign + WriteWord(EntrySize); // sh_entsize +} + +void ELFObjectWriterImpl::WriteRelocationsFragment(const MCAssembler &Asm, + MCDataFragment *F, + const MCSectionData *SD) { + std::vector &Relocs = Relocations[SD]; + // sort by the r_offset just like gnu as does + array_pod_sort(Relocs.begin(), Relocs.end()); + + for (unsigned i = 0, e = Relocs.size(); i != e; ++i) { + ELFRelocationEntry entry = Relocs[e - i - 1]; + + if (Is64Bit) { + F->getContents() += StringRef((const char *)&entry.r_offset, 8); + F->getContents() += StringRef((const char *)&entry.r_info, 8); + + if (HasRelocationAddend) + F->getContents() += StringRef((const char *)&entry.r_addend, 8); + } else { + F->getContents() += StringRef((const char *)&entry.r_offset, 4); + F->getContents() += StringRef((const char *)&entry.r_info, 4); + + if (HasRelocationAddend) + F->getContents() += StringRef((const char *)&entry.r_addend, 4); + } + } +} + +void ELFObjectWriterImpl::CreateMetadataSections(MCAssembler &Asm, + MCAsmLayout &Layout) { + MCContext &Ctx = Asm.getContext(); + MCDataFragment *F; + + WriteRelocations(Asm, Layout); + + const MCSection *SymtabSection; + unsigned EntrySize = Is64Bit ? ELF::SYMENTRY_SIZE64 : ELF::SYMENTRY_SIZE32; + + SymtabSection = Ctx.getELFSection(".symtab", ELF::SHT_SYMTAB, 0, + SectionKind::getReadOnly(), + false, EntrySize); + + MCSectionData &SymtabSD = Asm.getOrCreateSectionData(*SymtabSection); + + SymtabSD.setAlignment(Is64Bit ? 8 : 4); + + F = new MCDataFragment(&SymtabSD); + + // Symbol table + WriteSymbolTable(F, Asm, Layout); + Asm.AddSectionToTheEnd(SymtabSD, Layout); + + const MCSection *StrtabSection; + StrtabSection = Ctx.getELFSection(".strtab", ELF::SHT_STRTAB, 0, + SectionKind::getReadOnly(), false); + + MCSectionData &StrtabSD = Asm.getOrCreateSectionData(*StrtabSection); + StrtabSD.setAlignment(1); + + // FIXME: This isn't right. If the sections get rearranged this will + // be wrong. We need a proper lookup. + StringTableIndex = Asm.size(); + + F = new MCDataFragment(&StrtabSD); + F->getContents().append(StringTable.begin(), StringTable.end()); + Asm.AddSectionToTheEnd(StrtabSD, Layout); + + const MCSection *ShstrtabSection; + ShstrtabSection = Ctx.getELFSection(".shstrtab", ELF::SHT_STRTAB, 0, + SectionKind::getReadOnly(), false); + + MCSectionData &ShstrtabSD = Asm.getOrCreateSectionData(*ShstrtabSection); + ShstrtabSD.setAlignment(1); + + F = new MCDataFragment(&ShstrtabSD); + + // FIXME: This isn't right. If the sections get rearranged this will + // be wrong. We need a proper lookup. + ShstrtabIndex = Asm.size(); + + // Section header string table. + // + // The first entry of a string table holds a null character so skip + // section 0. + uint64_t Index = 1; + F->getContents() += '\x00'; + + for (MCAssembler::const_iterator it = Asm.begin(), + ie = Asm.end(); it != ie; ++it) { + const MCSectionData &SD = *it; + const MCSectionELF &Section = + static_cast(SD.getSection()); + + + // Remember the index into the string table so we can write it + // into the sh_name field of the section header table. + SectionStringTableIndex[&it->getSection()] = Index; + + Index += Section.getSectionName().size() + 1; + F->getContents() += Section.getSectionName(); + F->getContents() += '\x00'; + } + + Asm.AddSectionToTheEnd(ShstrtabSD, Layout); +} + +void ELFObjectWriterImpl::WriteObject(const MCAssembler &Asm, + const MCAsmLayout &Layout) { + // Compute symbol table information. + ComputeSymbolTable(const_cast(Asm)); + + CreateMetadataSections(const_cast(Asm), + const_cast(Layout)); + + // Add 1 for the null section. + unsigned NumSections = Asm.size() + 1; + + uint64_t SectionDataSize = 0; + + for (MCAssembler::const_iterator it = Asm.begin(), + ie = Asm.end(); it != ie; ++it) { + const MCSectionData &SD = *it; + const MCSectionELF &Section = + static_cast(SD.getSection()); + + // Get the size of the section in the output file (including padding). + uint64_t Size = Layout.getSectionFileSize(&SD); + SectionDataSize += Size; + } + + // Write out the ELF header ... + WriteHeader(SectionDataSize, NumSections); + FileOff = Is64Bit ? sizeof(ELF::Elf64_Ehdr) : sizeof(ELF::Elf32_Ehdr); + + // ... then all of the sections ... + DenseMap SectionOffsetMap; + + for (MCAssembler::const_iterator it = Asm.begin(), + ie = Asm.end(); it != ie; ++it) { + // Remember the offset into the file for this section. + SectionOffsetMap[&it->getSection()] = FileOff; + + const MCSectionData &SD = *it; + FileOff += Layout.getSectionFileSize(&SD); + + Asm.WriteSectionData(it, Layout, Writer); + } + + // ... and then the section header table. + // Should we align the section header table? + // + // Null section first. + WriteSecHdrEntry(0, 0, 0, 0, 0, 0, 0, 0, 0, 0); + + for (MCAssembler::const_iterator it = Asm.begin(), + ie = Asm.end(); it != ie; ++it) { + const MCSectionData &SD = *it; + const MCSectionELF &Section = + static_cast(SD.getSection()); + + uint64_t sh_link = 0; + uint64_t sh_info = 0; + + switch(Section.getType()) { + case ELF::SHT_DYNAMIC: + sh_link = SectionStringTableIndex[&it->getSection()]; + sh_info = 0; + break; + + case ELF::SHT_REL: + case ELF::SHT_RELA: + const MCSection *SymtabSection; + const MCSection *InfoSection; + const StringRef *SectionName; + const MCSectionData *SymtabSD; + const MCSectionData *InfoSD; + + SymtabSection = Asm.getContext().getELFSection(".symtab", ELF::SHT_SYMTAB, 0, + SectionKind::getReadOnly(), + false); + SymtabSD = &Asm.getSectionData(*SymtabSection); + // we have to count the empty section in too + sh_link = SymtabSD->getLayoutOrder() + 1; + + SectionName = &Section.getSectionName(); + SectionName = &SectionName->slice(5, SectionName->size()); + InfoSection = Asm.getContext().getELFSection(*SectionName, + ELF::SHT_PROGBITS, 0, + SectionKind::getReadOnly(), + false); + InfoSD = &Asm.getSectionData(*InfoSection); + sh_info = InfoSD->getLayoutOrder() + 1; + break; + + case ELF::SHT_SYMTAB: + case ELF::SHT_DYNSYM: + sh_link = StringTableIndex; + sh_info = LastLocalSymbolIndex; + break; + + case ELF::SHT_PROGBITS: + case ELF::SHT_STRTAB: + case ELF::SHT_NOBITS: + // Nothing to do. + break; + + case ELF::SHT_HASH: + case ELF::SHT_GROUP: + case ELF::SHT_SYMTAB_SHNDX: + default: + assert(0 && "FIXME: sh_type value not supported!"); + break; + } + + WriteSecHdrEntry(SectionStringTableIndex[&it->getSection()], + Section.getType(), Section.getFlags(), + Layout.getSectionAddress(&SD), + SectionOffsetMap.lookup(&SD.getSection()), + Layout.getSectionSize(&SD), sh_link, + sh_info, SD.getAlignment(), + Section.getEntrySize()); + } +} + +ELFObjectWriter::ELFObjectWriter(raw_ostream &OS, + bool Is64Bit, + bool IsLittleEndian, + bool HasRelocationAddend) + : MCObjectWriter(OS, IsLittleEndian) +{ + Impl = new ELFObjectWriterImpl(this, Is64Bit, HasRelocationAddend); +} + +ELFObjectWriter::~ELFObjectWriter() { + delete (ELFObjectWriterImpl*) Impl; +} + +void ELFObjectWriter::ExecutePostLayoutBinding(MCAssembler &Asm) { + ((ELFObjectWriterImpl*) Impl)->ExecutePostLayoutBinding(Asm); +} + +void ELFObjectWriter::RecordRelocation(const MCAssembler &Asm, + const MCAsmLayout &Layout, + const MCFragment *Fragment, + const MCFixup &Fixup, MCValue Target, + uint64_t &FixedValue) { + ((ELFObjectWriterImpl*) Impl)->RecordRelocation(Asm, Layout, Fragment, Fixup, + Target, FixedValue); +} + +void ELFObjectWriter::WriteObject(const MCAssembler &Asm, + const MCAsmLayout &Layout) { + ((ELFObjectWriterImpl*) Impl)->WriteObject(Asm, Layout); +} diff --git a/lib/MC/MCContext.cpp b/lib/MC/MCContext.cpp index 3996334..adf476c 100644 --- a/lib/MC/MCContext.cpp +++ b/lib/MC/MCContext.cpp @@ -148,7 +148,7 @@ getMachOSection(StringRef Segment, StringRef Section, const MCSection *MCContext:: getELFSection(StringRef Section, unsigned Type, unsigned Flags, - SectionKind Kind, bool IsExplicit) { + SectionKind Kind, bool IsExplicit, unsigned EntrySize) { if (ELFUniquingMap == 0) ELFUniquingMap = new ELFUniqueMapTy(); ELFUniqueMapTy &Map = *(ELFUniqueMapTy*)ELFUniquingMap; @@ -158,7 +158,7 @@ getELFSection(StringRef Section, unsigned Type, unsigned Flags, if (Entry.getValue()) return Entry.getValue(); MCSectionELF *Result = new (*this) MCSectionELF(Entry.getKey(), Type, Flags, - Kind, IsExplicit); + Kind, IsExplicit, EntrySize); Entry.setValue(Result); return Result; } diff --git a/lib/MC/MCELFStreamer.cpp b/lib/MC/MCELFStreamer.cpp new file mode 100644 index 0000000..fa48f95 --- /dev/null +++ b/lib/MC/MCELFStreamer.cpp @@ -0,0 +1,401 @@ +//===- lib/MC/MCELFStreamer.cpp - ELF Object Output ------------===// +// +// The LLVM Compiler Infrastructure +// +// This file is distributed under the University of Illinois Open Source +// License. See LICENSE.TXT for details. +// +//===----------------------------------------------------------------------===// +// +// This file assembles .s files and emits ELF .o object files. +// +//===----------------------------------------------------------------------===// + +#include "llvm/MC/MCStreamer.h" + +#include "llvm/MC/MCAssembler.h" +#include "llvm/MC/MCContext.h" +#include "llvm/MC/MCCodeEmitter.h" +#include "llvm/MC/MCELFSymbolFlags.h" +#include "llvm/MC/MCExpr.h" +#include "llvm/MC/MCInst.h" +#include "llvm/MC/MCObjectStreamer.h" +#include "llvm/MC/MCSection.h" +#include "llvm/MC/MCSectionELF.h" +#include "llvm/MC/MCSymbol.h" +#include "llvm/Support/Debug.h" +#include "llvm/Support/ELF.h" +#include "llvm/Support/ErrorHandling.h" +#include "llvm/Support/raw_ostream.h" +#include "llvm/Target/TargetAsmBackend.h" + +using namespace llvm; + +namespace { + +class MCELFStreamer : public MCObjectStreamer { +public: + MCELFStreamer(MCContext &Context, TargetAsmBackend &TAB, + raw_ostream &OS, MCCodeEmitter *Emitter) + : MCObjectStreamer(Context, TAB, OS, Emitter) {} + + ~MCELFStreamer() {} + + /// @name MCStreamer Interface + /// @{ + + virtual void EmitLabel(MCSymbol *Symbol); + virtual void EmitAssemblerFlag(MCAssemblerFlag Flag); + virtual void EmitAssignment(MCSymbol *Symbol, const MCExpr *Value); + virtual void EmitSymbolAttribute(MCSymbol *Symbol, MCSymbolAttr Attribute); + virtual void EmitSymbolDesc(MCSymbol *Symbol, unsigned DescValue) { + assert(0 && "ELF doesn't support this directive"); + } + virtual void EmitCommonSymbol(MCSymbol *Symbol, uint64_t Size, + unsigned ByteAlignment); + virtual void BeginCOFFSymbolDef(const MCSymbol *Symbol) { + assert(0 && "ELF doesn't support this directive"); + } + + virtual void EmitCOFFSymbolStorageClass(int StorageClass) { + assert(0 && "ELF doesn't support this directive"); + } + + virtual void EmitCOFFSymbolType(int Type) { + assert(0 && "ELF doesn't support this directive"); + } + + virtual void EndCOFFSymbolDef() { + assert(0 && "ELF doesn't support this directive"); + } + + virtual void EmitELFSize(MCSymbol *Symbol, const MCExpr *Value) { + MCSymbolData &SD = getAssembler().getOrCreateSymbolData(*Symbol); + SD.setSize(Value); + } + + virtual void EmitLocalCommonSymbol(MCSymbol *Symbol, uint64_t Size) { + assert(0 && "ELF doesn't support this directive"); + } + virtual void EmitZerofill(const MCSection *Section, MCSymbol *Symbol = 0, + unsigned Size = 0, unsigned ByteAlignment = 0) { + assert(0 && "ELF doesn't support this directive"); + } + virtual void EmitTBSSSymbol(const MCSection *Section, MCSymbol *Symbol, + uint64_t Size, unsigned ByteAlignment = 0) { + assert(0 && "ELF doesn't support this directive"); + } + virtual void EmitBytes(StringRef Data, unsigned AddrSpace); + virtual void EmitValue(const MCExpr *Value, unsigned Size,unsigned AddrSpace); + virtual void EmitGPRel32Value(const MCExpr *Value) { + assert(0 && "ELF doesn't support this directive"); + } + virtual void EmitValueToAlignment(unsigned ByteAlignment, int64_t Value = 0, + unsigned ValueSize = 1, + unsigned MaxBytesToEmit = 0); + virtual void EmitCodeAlignment(unsigned ByteAlignment, + unsigned MaxBytesToEmit = 0); + virtual void EmitValueToOffset(const MCExpr *Offset, + unsigned char Value = 0); + + virtual void EmitFileDirective(StringRef Filename); + virtual void EmitDwarfFileDirective(unsigned FileNo, StringRef Filename) { + DEBUG(dbgs() << "FIXME: MCELFStreamer:EmitDwarfFileDirective not implemented\n"); + } + + virtual void EmitInstruction(const MCInst &Inst); + virtual void Finish(); + + /// @} +}; + +} // end anonymous namespace. + +void MCELFStreamer::EmitLabel(MCSymbol *Symbol) { + assert(Symbol->isUndefined() && "Cannot define a symbol twice!"); + + // FIXME: This is wasteful, we don't necessarily need to create a data + // fragment. Instead, we should mark the symbol as pointing into the data + // fragment if it exists, otherwise we should just queue the label and set its + // fragment pointer when we emit the next fragment. + MCDataFragment *F = getOrCreateDataFragment(); + MCSymbolData &SD = getAssembler().getOrCreateSymbolData(*Symbol); + assert(!SD.getFragment() && "Unexpected fragment on symbol data!"); + SD.setFragment(F); + SD.setOffset(F->getContents().size()); + + Symbol->setSection(*CurSection); +} + +void MCELFStreamer::EmitAssemblerFlag(MCAssemblerFlag Flag) { + switch (Flag) { + case MCAF_SubsectionsViaSymbols: + getAssembler().setSubsectionsViaSymbols(true); + return; + } + + assert(0 && "invalid assembler flag!"); +} + +void MCELFStreamer::EmitAssignment(MCSymbol *Symbol, const MCExpr *Value) { + // TODO: This is exactly the same as WinCOFFStreamer. Consider merging into + // MCObjectStreamer. + // FIXME: Lift context changes into super class. + getAssembler().getOrCreateSymbolData(*Symbol); + Symbol->setVariableValue(AddValueSymbols(Value)); +} + +void MCELFStreamer::EmitSymbolAttribute(MCSymbol *Symbol, + MCSymbolAttr Attribute) { + // Indirect symbols are handled differently, to match how 'as' handles + // them. This makes writing matching .o files easier. + if (Attribute == MCSA_IndirectSymbol) { + // Note that we intentionally cannot use the symbol data here; this is + // important for matching the string table that 'as' generates. + IndirectSymbolData ISD; + ISD.Symbol = Symbol; + ISD.SectionData = getCurrentSectionData(); + getAssembler().getIndirectSymbols().push_back(ISD); + return; + } + + // Adding a symbol attribute always introduces the symbol, note that an + // important side effect of calling getOrCreateSymbolData here is to register + // the symbol with the assembler. + MCSymbolData &SD = getAssembler().getOrCreateSymbolData(*Symbol); + + // The implementation of symbol attributes is designed to match 'as', but it + // leaves much to desired. It doesn't really make sense to arbitrarily add and + // remove flags, but 'as' allows this (in particular, see .desc). + // + // In the future it might be worth trying to make these operations more well + // defined. + switch (Attribute) { + case MCSA_LazyReference: + case MCSA_Reference: + case MCSA_NoDeadStrip: + case MCSA_PrivateExtern: + case MCSA_WeakReference: + case MCSA_WeakDefinition: + case MCSA_Invalid: + case MCSA_ELF_TypeIndFunction: + case MCSA_IndirectSymbol: + assert(0 && "Invalid symbol attribute for ELF!"); + break; + + case MCSA_Global: + SD.setFlags(SD.getFlags() | ELF_STB_Global); + SD.setExternal(true); + break; + + case MCSA_Weak: + SD.setFlags(SD.getFlags() | ELF_STB_Weak); + break; + + case MCSA_Local: + SD.setFlags(SD.getFlags() | ELF_STB_Local); + break; + + case MCSA_ELF_TypeFunction: + SD.setFlags(SD.getFlags() | ELF_STT_Func); + break; + + case MCSA_ELF_TypeObject: + SD.setFlags(SD.getFlags() | ELF_STT_Object); + break; + + case MCSA_ELF_TypeTLS: + SD.setFlags(SD.getFlags() | ELF_STT_Tls); + break; + + case MCSA_ELF_TypeCommon: + SD.setFlags(SD.getFlags() | ELF_STT_Common); + break; + + case MCSA_ELF_TypeNoType: + SD.setFlags(SD.getFlags() | ELF_STT_Notype); + break; + + case MCSA_Protected: + SD.setFlags(SD.getFlags() | ELF_STV_Protected); + break; + + case MCSA_Hidden: + SD.setFlags(SD.getFlags() | ELF_STV_Hidden); + break; + + case MCSA_Internal: + SD.setFlags(SD.getFlags() | ELF_STV_Internal); + break; + } +} + +void MCELFStreamer::EmitCommonSymbol(MCSymbol *Symbol, uint64_t Size, + unsigned ByteAlignment) { + MCSymbolData &SD = getAssembler().getOrCreateSymbolData(*Symbol); + + if ((SD.getFlags() & (0xf << ELF_STB_Shift)) == ELF_STB_Local) { + const MCSection *Section = getAssembler().getContext().getELFSection(".bss", + MCSectionELF::SHT_NOBITS, + MCSectionELF::SHF_WRITE | + MCSectionELF::SHF_ALLOC, + SectionKind::getBSS()); + + MCSectionData &SectData = getAssembler().getOrCreateSectionData(*Section); + MCFragment *F = new MCFillFragment(0, 0, Size, &SectData); + SD.setFragment(F); + Symbol->setSection(*Section); + SD.setSize(MCConstantExpr::Create(Size, getContext())); + } else { + SD.setExternal(true); + } + + SD.setCommon(Size, ByteAlignment); +} + +void MCELFStreamer::EmitBytes(StringRef Data, unsigned AddrSpace) { + // TODO: This is exactly the same as WinCOFFStreamer. Consider merging into + // MCObjectStreamer. + getOrCreateDataFragment()->getContents().append(Data.begin(), Data.end()); +} + +void MCELFStreamer::EmitValue(const MCExpr *Value, unsigned Size, + unsigned AddrSpace) { + // TODO: This is exactly the same as WinCOFFStreamer. Consider merging into + // MCObjectStreamer. + MCDataFragment *DF = getOrCreateDataFragment(); + + // Avoid fixups when possible. + int64_t AbsValue; + if (AddValueSymbols(Value)->EvaluateAsAbsolute(AbsValue)) { + // FIXME: Endianness assumption. + for (unsigned i = 0; i != Size; ++i) + DF->getContents().push_back(uint8_t(AbsValue >> (i * 8))); + } else { + DF->addFixup(MCFixup::Create(DF->getContents().size(), AddValueSymbols(Value), + MCFixup::getKindForSize(Size))); + DF->getContents().resize(DF->getContents().size() + Size, 0); + } +} + +void MCELFStreamer::EmitValueToAlignment(unsigned ByteAlignment, + int64_t Value, unsigned ValueSize, + unsigned MaxBytesToEmit) { + // TODO: This is exactly the same as WinCOFFStreamer. Consider merging into + // MCObjectStreamer. + if (MaxBytesToEmit == 0) + MaxBytesToEmit = ByteAlignment; + new MCAlignFragment(ByteAlignment, Value, ValueSize, MaxBytesToEmit, + getCurrentSectionData()); + + // Update the maximum alignment on the current section if necessary. + if (ByteAlignment > getCurrentSectionData()->getAlignment()) + getCurrentSectionData()->setAlignment(ByteAlignment); +} + +void MCELFStreamer::EmitCodeAlignment(unsigned ByteAlignment, + unsigned MaxBytesToEmit) { + // TODO: This is exactly the same as WinCOFFStreamer. Consider merging into + // MCObjectStreamer. + if (MaxBytesToEmit == 0) + MaxBytesToEmit = ByteAlignment; + MCAlignFragment *F = new MCAlignFragment(ByteAlignment, 0, 1, MaxBytesToEmit, + getCurrentSectionData()); + F->setEmitNops(true); + + // Update the maximum alignment on the current section if necessary. + if (ByteAlignment > getCurrentSectionData()->getAlignment()) + getCurrentSectionData()->setAlignment(ByteAlignment); +} + +void MCELFStreamer::EmitValueToOffset(const MCExpr *Offset, + unsigned char Value) { + // TODO: This is exactly the same as MCMachOStreamer. Consider merging into + // MCObjectStreamer. + new MCOrgFragment(*Offset, Value, getCurrentSectionData()); +} + +// Add a symbol for the file name of this module. This is the second +// entry in the module's symbol table (the first being the null symbol). +void MCELFStreamer::EmitFileDirective(StringRef Filename) { + MCSymbol *Symbol = getAssembler().getContext().GetOrCreateSymbol(Filename); + Symbol->setSection(*CurSection); + Symbol->setAbsolute(); + + MCSymbolData &SD = getAssembler().getOrCreateSymbolData(*Symbol); + + SD.setFlags(ELF_STT_File | ELF_STB_Local | ELF_STV_Default); +} + +void MCELFStreamer::EmitInstruction(const MCInst &Inst) { + // Scan for values. + for (unsigned i = 0; i != Inst.getNumOperands(); ++i) + if (Inst.getOperand(i).isExpr()) + AddValueSymbols(Inst.getOperand(i).getExpr()); + + getCurrentSectionData()->setHasInstructions(true); + + // FIXME-PERF: Common case is that we don't need to relax, encode directly + // onto the data fragments buffers. + + SmallVector Fixups; + SmallString<256> Code; + raw_svector_ostream VecOS(Code); + getAssembler().getEmitter().EncodeInstruction(Inst, VecOS, Fixups); + VecOS.flush(); + + // FIXME: Eliminate this copy. + SmallVector AsmFixups; + for (unsigned i = 0, e = Fixups.size(); i != e; ++i) { + MCFixup &F = Fixups[i]; + AsmFixups.push_back(MCFixup::Create(F.getOffset(), F.getValue(), + F.getKind())); + } + + // See if we might need to relax this instruction, if so it needs its own + // fragment. + // + // FIXME-PERF: Support target hook to do a fast path that avoids the encoder, + // when we can immediately tell that we will get something which might need + // relaxation (and compute its size). + // + // FIXME-PERF: We should also be smart about immediately relaxing instructions + // which we can already show will never possibly fit (we can also do a very + // good job of this before we do the first relaxation pass, because we have + // total knowledge about undefined symbols at that point). Even now, though, + // we can do a decent job, especially on Darwin where scattering means that we + // are going to often know that we can never fully resolve a fixup. + if (getAssembler().getBackend().MayNeedRelaxation(Inst)) { + MCInstFragment *IF = new MCInstFragment(Inst, getCurrentSectionData()); + + // Add the fixups and data. + // + // FIXME: Revisit this design decision when relaxation is done, we may be + // able to get away with not storing any extra data in the MCInst. + IF->getCode() = Code; + IF->getFixups() = AsmFixups; + + return; + } + + // Add the fixups and data. + MCDataFragment *DF = getOrCreateDataFragment(); + for (unsigned i = 0, e = AsmFixups.size(); i != e; ++i) { + AsmFixups[i].setOffset(AsmFixups[i].getOffset() + DF->getContents().size()); + DF->addFixup(AsmFixups[i]); + } + DF->getContents().append(Code.begin(), Code.end()); +} + +void MCELFStreamer::Finish() { + getAssembler().Finish(); +} + +MCStreamer *llvm::createELFStreamer(MCContext &Context, TargetAsmBackend &TAB, + raw_ostream &OS, MCCodeEmitter *CE, + bool RelaxAll) { + MCELFStreamer *S = new MCELFStreamer(Context, TAB, OS, CE); + if (RelaxAll) + S->getAssembler().setRelaxAll(true); + return S; +} -- 1.6.4.rc0 From matt at console-pimps.org Wed Aug 11 17:20:38 2010 From: matt at console-pimps.org (Matt Fleming) Date: Wed, 11 Aug 2010 23:20:38 +0100 Subject: [llvm-commits] [PATCH 5/5] Hookup ELF support for X86. In-Reply-To: <9cdd00007aa27877807cea203cdbc02984088a8e.1281542945.git.matt@console-pimps.org> References: <8dfd2734fd5b1963627fa8238f5e45c18096c38c.1281542945.git.matt@console-pimps.org> <9cdd00007aa27877807cea203cdbc02984088a8e.1281542945.git.matt@console-pimps.org> Message-ID: <19b03804f32cb43396e48453f41506295bb28aad.1281542945.git.matt@console-pimps.org> --- lib/Target/X86/X86AsmBackend.cpp | 17 +++++++++++++---- lib/Target/X86/X86TargetMachine.cpp | 3 +-- 2 files changed, 14 insertions(+), 6 deletions(-) diff --git a/lib/Target/X86/X86AsmBackend.cpp b/lib/Target/X86/X86AsmBackend.cpp index 248eeac..6455a18 100644 --- a/lib/Target/X86/X86AsmBackend.cpp +++ b/lib/Target/X86/X86AsmBackend.cpp @@ -11,6 +11,7 @@ #include "X86.h" #include "X86FixupKinds.h" #include "llvm/ADT/Twine.h" +#include "llvm/MC/ELFObjectWriter.h" #include "llvm/MC/MCAssembler.h" #include "llvm/MC/MCExpr.h" #include "llvm/MC/MCObjectWriter.h" @@ -191,10 +192,6 @@ public: HasScatteredSymbols = true; } - MCObjectWriter *createObjectWriter(raw_ostream &OS) const { - return 0; - } - bool isVirtualSection(const MCSection &Section) const { const MCSectionELF &SE = static_cast(Section); return SE.getType() == MCSectionELF::SHT_NOBITS;; @@ -205,12 +202,24 @@ class ELFX86_32AsmBackend : public ELFX86AsmBackend { public: ELFX86_32AsmBackend(const Target &T) : ELFX86AsmBackend(T) {} + + MCObjectWriter *createObjectWriter(raw_ostream &OS) const { + return new ELFObjectWriter(OS, /*Is64Bit=*/false, + /*IsLittleEndian=*/true, + /*HasRelocationAddend=*/false); + } }; class ELFX86_64AsmBackend : public ELFX86AsmBackend { public: ELFX86_64AsmBackend(const Target &T) : ELFX86AsmBackend(T) {} + + MCObjectWriter *createObjectWriter(raw_ostream &OS) const { + return new ELFObjectWriter(OS, /*Is64Bit=*/true, + /*IsLittleEndian=*/true, + /*HasRelocationAddend=*/true); + } }; class WindowsX86AsmBackend : public X86AsmBackend { diff --git a/lib/Target/X86/X86TargetMachine.cpp b/lib/Target/X86/X86TargetMachine.cpp index 560f070..3c8e7f1 100644 --- a/lib/Target/X86/X86TargetMachine.cpp +++ b/lib/Target/X86/X86TargetMachine.cpp @@ -54,8 +54,7 @@ static MCStreamer *createMCStreamer(const Target &T, const std::string &TT, case Triple::Win32: return createWinCOFFStreamer(Ctx, TAB, *_Emitter, _OS, RelaxAll); default: - // FIXME: default to ELF. - report_fatal_error("object emission not implemented for this target."); + return createELFStreamer(Ctx, TAB, _OS, _Emitter, RelaxAll); } } -- 1.6.4.rc0 From resistor at mac.com Wed Aug 11 17:36:04 2010 From: resistor at mac.com (Owen Anderson) Date: Wed, 11 Aug 2010 22:36:04 -0000 Subject: [llvm-commits] [llvm] r110863 - /llvm/trunk/lib/Analysis/LazyValueInfo.cpp Message-ID: <20100811223605.05A522A6C12C@llvm.org> Author: resistor Date: Wed Aug 11 17:36:04 2010 New Revision: 110863 URL: http://llvm.org/viewvc/llvm-project?rev=110863&view=rev Log: Fix a subtle use-after-free issue. Modified: llvm/trunk/lib/Analysis/LazyValueInfo.cpp Modified: llvm/trunk/lib/Analysis/LazyValueInfo.cpp URL: http://llvm.org/viewvc/llvm-project/llvm/trunk/lib/Analysis/LazyValueInfo.cpp?rev=110863&r1=110862&r2=110863&view=diff ============================================================================== --- llvm/trunk/lib/Analysis/LazyValueInfo.cpp (original) +++ llvm/trunk/lib/Analysis/LazyValueInfo.cpp Wed Aug 11 17:36:04 2010 @@ -384,7 +384,6 @@ } // end anonymous namespace void LazyValueInfoCache::LVIValueHandle::deleted() { - Parent->ValueCache.erase(*this); for (std::set >::iterator I = Parent->OverDefinedCache.begin(), E = Parent->OverDefinedCache.end(); @@ -394,6 +393,10 @@ if (tmp->second == getValPtr()) Parent->OverDefinedCache.erase(tmp); } + + // This erasure deallocates *this, so it MUST happen after we're done + // using any and all members of *this. + Parent->ValueCache.erase(*this); } From wendling at apple.com Wed Aug 11 17:45:54 2010 From: wendling at apple.com (Bill Wendling) Date: Wed, 11 Aug 2010 15:45:54 -0700 Subject: [llvm-commits] [PATCH 2/5] Record a symbol's size which is needed for ELF symbol tables. In-Reply-To: <8dfd2734fd5b1963627fa8238f5e45c18096c38c.1281542945.git.matt@console-pimps.org> References: <8dfd2734fd5b1963627fa8238f5e45c18096c38c.1281542945.git.matt@console-pimps.org> Message-ID: <84CC8582-7A97-47BF-BE2C-1C7409566414@apple.com> On Aug 11, 2010, at 3:20 PM, Matt Fleming wrote: > --- > include/llvm/MC/MCAssembler.h | 14 ++++++++++++++ > lib/MC/MCAssembler.cpp | 3 ++- > 2 files changed, 16 insertions(+), 1 deletions(-) > > diff --git a/include/llvm/MC/MCAssembler.h b/include/llvm/MC/MCAssembler.h > index 50cb73b..24bd7d2 100644 > --- a/include/llvm/MC/MCAssembler.h > +++ b/include/llvm/MC/MCAssembler.h > @@ -24,6 +24,7 @@ namespace llvm { > class raw_ostream; > class MCAsmLayout; > class MCAssembler; > +class MCBinaryExpr; > class MCContext; > class MCCodeEmitter; > class MCExpr; > @@ -453,6 +454,10 @@ public: > // common symbol can never get a definition. > uint64_t CommonSize; > > + /// SymbolSize - An expression describing how to calculate the size of > + /// a symbol. If a symbol has no size this field will be NULL. > + const MCExpr *SymbolSize; > + > /// CommonAlign - The alignment of the symbol, if it is 'common'. > // > // FIXME: Pack this in with other fields? > @@ -510,6 +515,15 @@ public: > return CommonSize; > } > > + void setSize(const MCExpr *SS) { > + SymbolSize = SS; > + } > + > + const MCExpr *getSize() { You can constify this method "getSize() const {". -bw From stoklund at 2pi.dk Wed Aug 11 18:08:22 2010 From: stoklund at 2pi.dk (Jakob Stoklund Olesen) Date: Wed, 11 Aug 2010 23:08:22 -0000 Subject: [llvm-commits] [llvm] r110874 - /llvm/trunk/lib/Target/X86/X86InstrInfo.cpp Message-ID: <20100811230822.DFEDD2A6C12C@llvm.org> Author: stoklund Date: Wed Aug 11 18:08:22 2010 New Revision: 110874 URL: http://llvm.org/viewvc/llvm-project?rev=110874&view=rev Log: Fix even if it doesn't reproduce on trunk. When a register is defined by a partial load: %reg1234:sub_32 = MOV32mr ; GR64:%reg1234 That load cannot be folded into an instruction using the full 64-bit register. It would become a 64-bit load. This is related to the recent change to have isLoadFromStackSlot return false on a sub-register load. Modified: llvm/trunk/lib/Target/X86/X86InstrInfo.cpp Modified: llvm/trunk/lib/Target/X86/X86InstrInfo.cpp URL: http://llvm.org/viewvc/llvm-project/llvm/trunk/lib/Target/X86/X86InstrInfo.cpp?rev=110874&r1=110873&r2=110874&view=diff ============================================================================== --- llvm/trunk/lib/Target/X86/X86InstrInfo.cpp (original) +++ llvm/trunk/lib/Target/X86/X86InstrInfo.cpp Wed Aug 11 18:08:22 2010 @@ -2410,6 +2410,11 @@ } else if (Ops.size() != 1) return NULL; + // Make sure the subregisters match. + // Otherwise we risk changing the size of the load. + if (LoadMI->getOperand(0).getSubReg() != MI->getOperand(Ops[0]).getSubReg()) + return NULL; + SmallVector MOs; switch (LoadMI->getOpcode()) { case X86::V_SET0PS: From bob.wilson at apple.com Wed Aug 11 18:10:46 2010 From: bob.wilson at apple.com (Bob Wilson) Date: Wed, 11 Aug 2010 23:10:46 -0000 Subject: [llvm-commits] [llvm] r110875 - in /llvm/trunk: lib/Target/ARM/ARMAsmPrinter.cpp lib/Target/ARM/ARMCodeEmitter.cpp lib/Target/ARM/ARMInstrInfo.td lib/Target/ARM/AsmPrinter/ARMInstPrinter.cpp lib/Target/ARM/AsmPrinter/ARMInstPrinter.h lib/Target/ARM/Disassembler/ARMDisassembler.cpp lib/Target/ARM/Disassembler/ARMDisassemblerCore.cpp test/MC/Disassembler/arm-tests.txt utils/TableGen/EDEmitter.cpp Message-ID: <20100811231046.E19702A6C12C@llvm.org> Author: bwilson Date: Wed Aug 11 18:10:46 2010 New Revision: 110875 URL: http://llvm.org/viewvc/llvm-project?rev=110875&view=rev Log: Move the ARM SSAT and USAT optional shift amount operand out of the instruction opcode. This also fixes part of PR7792. Modified: llvm/trunk/lib/Target/ARM/ARMAsmPrinter.cpp llvm/trunk/lib/Target/ARM/ARMCodeEmitter.cpp llvm/trunk/lib/Target/ARM/ARMInstrInfo.td llvm/trunk/lib/Target/ARM/AsmPrinter/ARMInstPrinter.cpp llvm/trunk/lib/Target/ARM/AsmPrinter/ARMInstPrinter.h llvm/trunk/lib/Target/ARM/Disassembler/ARMDisassembler.cpp llvm/trunk/lib/Target/ARM/Disassembler/ARMDisassemblerCore.cpp llvm/trunk/test/MC/Disassembler/arm-tests.txt llvm/trunk/utils/TableGen/EDEmitter.cpp Modified: llvm/trunk/lib/Target/ARM/ARMAsmPrinter.cpp URL: http://llvm.org/viewvc/llvm-project/llvm/trunk/lib/Target/ARM/ARMAsmPrinter.cpp?rev=110875&r1=110874&r2=110875&view=diff ============================================================================== --- llvm/trunk/lib/Target/ARM/ARMAsmPrinter.cpp (original) +++ llvm/trunk/lib/Target/ARM/ARMAsmPrinter.cpp Wed Aug 11 18:10:46 2010 @@ -120,8 +120,10 @@ void printAddrModePCOperand(const MachineInstr *MI, int OpNum, raw_ostream &O, const char *Modifier = 0); - void printBitfieldInvMaskImmOperand (const MachineInstr *MI, int OpNum, - raw_ostream &O); + void printBitfieldInvMaskImmOperand(const MachineInstr *MI, int OpNum, + raw_ostream &O); + void printSatShiftOperand(const MachineInstr *MI, int OpNum, + raw_ostream &O); void printThumbS4ImmOperand(const MachineInstr *MI, int OpNum, raw_ostream &O); @@ -669,6 +671,25 @@ O << "#" << lsb << ", #" << width; } +void ARMAsmPrinter::printSatShiftOperand(const MachineInstr *MI, int OpNum, + raw_ostream &O) { + unsigned ShiftOp = MI->getOperand(OpNum).getImm(); + ARM_AM::ShiftOpc Opc = ARM_AM::getSORegShOp(ShiftOp); + switch (Opc) { + case ARM_AM::no_shift: + return; + case ARM_AM::lsl: + O << ", lsl #"; + break; + case ARM_AM::asr: + O << ", asr #"; + break; + default: + assert(0 && "unexpected shift opcode for saturate shift operand"); + } + O << ARM_AM::getSORegOffset(ShiftOp); +} + //===--------------------------------------------------------------------===// void ARMAsmPrinter::printThumbS4ImmOperand(const MachineInstr *MI, int Op, Modified: llvm/trunk/lib/Target/ARM/ARMCodeEmitter.cpp URL: http://llvm.org/viewvc/llvm-project/llvm/trunk/lib/Target/ARM/ARMCodeEmitter.cpp?rev=110875&r1=110874&r2=110875&view=diff ============================================================================== --- llvm/trunk/lib/Target/ARM/ARMCodeEmitter.cpp (original) +++ llvm/trunk/lib/Target/ARM/ARMCodeEmitter.cpp Wed Aug 11 18:10:46 2010 @@ -1247,9 +1247,7 @@ // Encode saturate bit position. unsigned Pos = MI.getOperand(1).getImm(); - if (TID.Opcode == ARM::SSATlsl || - TID.Opcode == ARM::SSATasr || - TID.Opcode == ARM::SSAT16) + if (TID.Opcode == ARM::SSAT || TID.Opcode == ARM::SSAT16) Pos -= 1; assert((Pos < 16 || (Pos < 32 && TID.Opcode != ARM::SSAT16 && @@ -1262,9 +1260,12 @@ // Encode shift_imm. if (TID.getNumOperands() == 4) { + unsigned ShiftOp = MI.getOperand(3).getImm(); + ARM_AM::ShiftOpc Opc = ARM_AM::getSORegShOp(ShiftOp); + if (Opc == ARM_AM::asr) + Binary |= (1 << 6); unsigned ShiftAmt = MI.getOperand(3).getImm(); - if (ShiftAmt == 32 && - (TID.Opcode == ARM::SSATasr || TID.Opcode == ARM::USATasr)) + if (ShiftAmt == 32 && Opc == ARM_AM::asr) ShiftAmt = 0; assert(ShiftAmt < 32 && "shift_imm range is 0 to 31!"); Binary |= ShiftAmt << ARMII::ShiftShift; Modified: llvm/trunk/lib/Target/ARM/ARMInstrInfo.td URL: http://llvm.org/viewvc/llvm-project/llvm/trunk/lib/Target/ARM/ARMInstrInfo.td?rev=110875&r1=110874&r2=110875&view=diff ============================================================================== --- llvm/trunk/lib/Target/ARM/ARMInstrInfo.td (original) +++ llvm/trunk/lib/Target/ARM/ARMInstrInfo.td Wed Aug 11 18:10:46 2010 @@ -1810,20 +1810,15 @@ // Signed/Unsigned saturate -- for disassembly only -def SSATlsl : AI<(outs GPR:$dst), (ins i32imm:$bit_pos, GPR:$a, i32imm:$shamt), - SatFrm, NoItinerary, - "ssat", "\t$dst, $bit_pos, $a, lsl $shamt", - [/* For disassembly only; pattern left blank */]> { - let Inst{27-21} = 0b0110101; - let Inst{6-4} = 0b001; +def sat_shift : Operand { + let PrintMethod = "printSatShiftOperand"; } -def SSATasr : AI<(outs GPR:$dst), (ins i32imm:$bit_pos, GPR:$a, i32imm:$shamt), - SatFrm, NoItinerary, - "ssat", "\t$dst, $bit_pos, $a, asr $shamt", - [/* For disassembly only; pattern left blank */]> { +def SSAT : AI<(outs GPR:$dst), (ins i32imm:$bit_pos, GPR:$a, sat_shift:$sh), + SatFrm, NoItinerary, "ssat", "\t$dst, $bit_pos, $a$sh", + [/* For disassembly only; pattern left blank */]> { let Inst{27-21} = 0b0110101; - let Inst{6-4} = 0b101; + let Inst{5-4} = 0b01; } def SSAT16 : AI<(outs GPR:$dst), (ins i32imm:$bit_pos, GPR:$a), SatFrm, @@ -1833,20 +1828,11 @@ let Inst{7-4} = 0b0011; } -def USATlsl : AI<(outs GPR:$dst), (ins i32imm:$bit_pos, GPR:$a, i32imm:$shamt), - SatFrm, NoItinerary, - "usat", "\t$dst, $bit_pos, $a, lsl $shamt", - [/* For disassembly only; pattern left blank */]> { - let Inst{27-21} = 0b0110111; - let Inst{6-4} = 0b001; -} - -def USATasr : AI<(outs GPR:$dst), (ins i32imm:$bit_pos, GPR:$a, i32imm:$shamt), - SatFrm, NoItinerary, - "usat", "\t$dst, $bit_pos, $a, asr $shamt", - [/* For disassembly only; pattern left blank */]> { +def USAT : AI<(outs GPR:$dst), (ins i32imm:$bit_pos, GPR:$a, sat_shift:$sh), + SatFrm, NoItinerary, "usat", "\t$dst, $bit_pos, $a$sh", + [/* For disassembly only; pattern left blank */]> { let Inst{27-21} = 0b0110111; - let Inst{6-4} = 0b101; + let Inst{5-4} = 0b01; } def USAT16 : AI<(outs GPR:$dst), (ins i32imm:$bit_pos, GPR:$a), SatFrm, @@ -1856,8 +1842,8 @@ let Inst{7-4} = 0b0011; } -def : ARMV6Pat<(int_arm_ssat GPR:$a, imm:$pos), (SSATlsl imm:$pos, GPR:$a, 0)>; -def : ARMV6Pat<(int_arm_usat GPR:$a, imm:$pos), (USATlsl imm:$pos, GPR:$a, 0)>; +def : ARMV6Pat<(int_arm_ssat GPR:$a, imm:$pos), (SSAT imm:$pos, GPR:$a, 0)>; +def : ARMV6Pat<(int_arm_usat GPR:$a, imm:$pos), (USAT imm:$pos, GPR:$a, 0)>; //===----------------------------------------------------------------------===// // Bitwise Instructions. Modified: llvm/trunk/lib/Target/ARM/AsmPrinter/ARMInstPrinter.cpp URL: http://llvm.org/viewvc/llvm-project/llvm/trunk/lib/Target/ARM/AsmPrinter/ARMInstPrinter.cpp?rev=110875&r1=110874&r2=110875&view=diff ============================================================================== --- llvm/trunk/lib/Target/ARM/AsmPrinter/ARMInstPrinter.cpp (original) +++ llvm/trunk/lib/Target/ARM/AsmPrinter/ARMInstPrinter.cpp Wed Aug 11 18:10:46 2010 @@ -461,9 +461,9 @@ assert(0 && "FIXME: Implement printAddrModePCOperand"); } -void ARMInstPrinter::printBitfieldInvMaskImmOperand (const MCInst *MI, - unsigned OpNum, - raw_ostream &O) { +void ARMInstPrinter::printBitfieldInvMaskImmOperand(const MCInst *MI, + unsigned OpNum, + raw_ostream &O) { const MCOperand &MO = MI->getOperand(OpNum); uint32_t v = ~MO.getImm(); int32_t lsb = CountTrailingZeros_32(v); @@ -472,6 +472,25 @@ O << '#' << lsb << ", #" << width; } +void ARMInstPrinter::printSatShiftOperand(const MCInst *MI, unsigned OpNum, + raw_ostream &O) { + unsigned ShiftOp = MI->getOperand(OpNum).getImm(); + ARM_AM::ShiftOpc Opc = ARM_AM::getSORegShOp(ShiftOp); + switch (Opc) { + case ARM_AM::no_shift: + return; + case ARM_AM::lsl: + O << ", lsl #"; + break; + case ARM_AM::asr: + O << ", asr #"; + break; + default: + assert(0 && "unexpected shift opcode for saturate shift operand"); + } + O << ARM_AM::getSORegOffset(ShiftOp); +} + void ARMInstPrinter::printRegisterList(const MCInst *MI, unsigned OpNum, raw_ostream &O) { O << "{"; Modified: llvm/trunk/lib/Target/ARM/AsmPrinter/ARMInstPrinter.h URL: http://llvm.org/viewvc/llvm-project/llvm/trunk/lib/Target/ARM/AsmPrinter/ARMInstPrinter.h?rev=110875&r1=110874&r2=110875&view=diff ============================================================================== --- llvm/trunk/lib/Target/ARM/AsmPrinter/ARMInstPrinter.h (original) +++ llvm/trunk/lib/Target/ARM/AsmPrinter/ARMInstPrinter.h Wed Aug 11 18:10:46 2010 @@ -57,6 +57,7 @@ void printBitfieldInvMaskImmOperand(const MCInst *MI, unsigned OpNum, raw_ostream &O); + void printSatShiftOperand(const MCInst *MI, unsigned OpNum, raw_ostream &O); void printThumbS4ImmOperand(const MCInst *MI, unsigned OpNum, raw_ostream &O); void printThumbITMask(const MCInst *MI, unsigned OpNum, raw_ostream &O); Modified: llvm/trunk/lib/Target/ARM/Disassembler/ARMDisassembler.cpp URL: http://llvm.org/viewvc/llvm-project/llvm/trunk/lib/Target/ARM/Disassembler/ARMDisassembler.cpp?rev=110875&r1=110874&r2=110875&view=diff ============================================================================== --- llvm/trunk/lib/Target/ARM/Disassembler/ARMDisassembler.cpp (original) +++ llvm/trunk/lib/Target/ARM/Disassembler/ARMDisassembler.cpp Wed Aug 11 18:10:46 2010 @@ -106,7 +106,7 @@ // Ditto for STRT, which is a super-instruction for A8.6.210 Encoding A1 & A2. // As a result, the decoder fails to deocode SSAT properly. if (slice(insn, 27, 21) == 0x35 && slice(insn, 5, 4) == 1) - return slice(insn, 6, 6) == 0 ? ARM::SSATlsl : ARM::SSATasr; + return ARM::SSAT; // Ditto for RSCrs, which is a super-instruction for A8.6.146 & A8.6.147. // As a result, the decoder fails to decode STRHT/LDRHT/LDRSHT/LDRSBT. Modified: llvm/trunk/lib/Target/ARM/Disassembler/ARMDisassemblerCore.cpp URL: http://llvm.org/viewvc/llvm-project/llvm/trunk/lib/Target/ARM/Disassembler/ARMDisassemblerCore.cpp?rev=110875&r1=110874&r2=110875&view=diff ============================================================================== --- llvm/trunk/lib/Target/ARM/Disassembler/ARMDisassemblerCore.cpp (original) +++ llvm/trunk/lib/Target/ARM/Disassembler/ARMDisassemblerCore.cpp Wed Aug 11 18:10:46 2010 @@ -1466,9 +1466,7 @@ decodeRd(insn)))); unsigned Pos = slice(insn, 20, 16); - if (Opcode == ARM::SSATlsl || - Opcode == ARM::SSATasr || - Opcode == ARM::SSAT16) + if (Opcode == ARM::SSAT || Opcode == ARM::SSAT16) Pos += 1; MI.addOperand(MCOperand::CreateImm(Pos)); @@ -1476,12 +1474,17 @@ decodeRm(insn)))); if (NumOpsAdded == 4) { + ARM_AM::ShiftOpc Opc = (slice(insn, 6, 6) != 0 ? ARM_AM::asr : ARM_AM::lsl); // Inst{11-7} encodes the imm5 shift amount. unsigned ShAmt = slice(insn, 11, 7); - // A8.6.183. Possible ASR shift amount of 32... - if ((Opcode == ARM::SSATasr || Opcode == ARM::USATasr) && ShAmt == 0) - ShAmt = 32; - MI.addOperand(MCOperand::CreateImm(ShAmt)); + if (ShAmt == 0) { + // A8.6.183. Possible ASR shift amount of 32... + if (Opc == ARM_AM::asr) + ShAmt = 32; + else + Opc = ARM_AM::no_shift; + } + MI.addOperand(MCOperand::CreateImm(ARM_AM::getSORegOpc(Opc, ShAmt))); } return true; } Modified: llvm/trunk/test/MC/Disassembler/arm-tests.txt URL: http://llvm.org/viewvc/llvm-project/llvm/trunk/test/MC/Disassembler/arm-tests.txt?rev=110875&r1=110874&r2=110875&view=diff ============================================================================== --- llvm/trunk/test/MC/Disassembler/arm-tests.txt (original) +++ llvm/trunk/test/MC/Disassembler/arm-tests.txt Wed Aug 11 18:10:46 2010 @@ -78,6 +78,10 @@ # CHECK: ssat r8, #1, r10, lsl #8 0x1a 0x84 0xa0 0xe6 +# CHECK-NOT: ssatmi r0, #17, r12, lsl #0 +# CHECK: ssatmi r0, #17, r12 +0x1c 0x00 0xb0 0x46 + # CHECK: stmdb r10!, {r4, r5, r6, r7, lr} 0xf0 0x40 0x2a 0xe9 Modified: llvm/trunk/utils/TableGen/EDEmitter.cpp URL: http://llvm.org/viewvc/llvm-project/llvm/trunk/utils/TableGen/EDEmitter.cpp?rev=110875&r1=110874&r2=110875&view=diff ============================================================================== --- llvm/trunk/utils/TableGen/EDEmitter.cpp (original) +++ llvm/trunk/utils/TableGen/EDEmitter.cpp Wed Aug 11 18:10:46 2010 @@ -607,6 +607,7 @@ IMM("jt2block_operand"); IMM("t_imm_s4"); IMM("pclabel"); + IMM("sat_shift"); MISC("brtarget", "kOperandTypeARMBranchTarget"); // ? MISC("so_reg", "kOperandTypeARMSoReg"); // R, R, I From dpatel at apple.com Wed Aug 11 18:17:54 2010 From: dpatel at apple.com (Devang Patel) Date: Wed, 11 Aug 2010 23:17:54 -0000 Subject: [llvm-commits] [llvm] r110876 - /llvm/trunk/lib/Analysis/DebugInfo.cpp Message-ID: <20100811231754.514A92A6C12C@llvm.org> Author: dpatel Date: Wed Aug 11 18:17:54 2010 New Revision: 110876 URL: http://llvm.org/viewvc/llvm-project?rev=110876&view=rev Log: Even if a variable has constant value all the time, it is still a variable in gdb's eyes. Tested by scope.exp in gdb testsuite. Modified: llvm/trunk/lib/Analysis/DebugInfo.cpp Modified: llvm/trunk/lib/Analysis/DebugInfo.cpp URL: http://llvm.org/viewvc/llvm-project/llvm/trunk/lib/Analysis/DebugInfo.cpp?rev=110876&r1=110875&r2=110876&view=diff ============================================================================== --- llvm/trunk/lib/Analysis/DebugInfo.cpp (original) +++ llvm/trunk/lib/Analysis/DebugInfo.cpp Wed Aug 11 18:17:54 2010 @@ -1093,7 +1093,7 @@ unsigned LineNo, DIType Ty,bool isLocalToUnit, bool isDefinition, llvm::Constant *Val) { Value *Elts[] = { - GetTagConstant(dwarf::DW_TAG_constant), + GetTagConstant(dwarf::DW_TAG_variable), llvm::Constant::getNullValue(Type::getInt32Ty(VMContext)), Context, MDString::get(VMContext, Name), From johnny.chen at apple.com Wed Aug 11 18:35:12 2010 From: johnny.chen at apple.com (Johnny Chen) Date: Wed, 11 Aug 2010 23:35:12 -0000 Subject: [llvm-commits] [llvm] r110880 - in /llvm/trunk: lib/Target/ARM/ARMInstrInfo.td lib/Target/ARM/Disassembler/ARMDisassemblerCore.cpp lib/Target/ARM/Disassembler/ThumbDisassemblerCore.h test/MC/Disassembler/arm-tests.txt Message-ID: <20100811233512.A52E02A6C12C@llvm.org> Author: johnny Date: Wed Aug 11 18:35:12 2010 New Revision: 110880 URL: http://llvm.org/viewvc/llvm-project?rev=110880&view=rev Log: Changed the format of DMBsy, DSBsy, and friends from Pseudo to MiscFrm. Added two test cases to arm-tests.txt. Modified: llvm/trunk/lib/Target/ARM/ARMInstrInfo.td llvm/trunk/lib/Target/ARM/Disassembler/ARMDisassemblerCore.cpp llvm/trunk/lib/Target/ARM/Disassembler/ThumbDisassemblerCore.h llvm/trunk/test/MC/Disassembler/arm-tests.txt Modified: llvm/trunk/lib/Target/ARM/ARMInstrInfo.td URL: http://llvm.org/viewvc/llvm-project/llvm/trunk/lib/Target/ARM/ARMInstrInfo.td?rev=110880&r1=110879&r2=110880&view=diff ============================================================================== --- llvm/trunk/lib/Target/ARM/ARMInstrInfo.td (original) +++ llvm/trunk/lib/Target/ARM/ARMInstrInfo.td Wed Aug 11 18:35:12 2010 @@ -2356,7 +2356,7 @@ // memory barriers protect the atomic sequences let hasSideEffects = 1 in { -def DMBsy : AInoP<(outs), (ins), Pseudo, NoItinerary, "dmb", "", +def DMBsy : AInoP<(outs), (ins), MiscFrm, NoItinerary, "dmb", "", [(ARMMemBarrier)]>, Requires<[IsARM, HasDB]> { let Inst{31-4} = 0xf57ff05; // FIXME: add support for options other than a full system DMB @@ -2364,7 +2364,7 @@ let Inst{3-0} = 0b1111; } -def DSBsy : AInoP<(outs), (ins), Pseudo, NoItinerary, "dsb", "", +def DSBsy : AInoP<(outs), (ins), MiscFrm, NoItinerary, "dsb", "", [(ARMSyncBarrier)]>, Requires<[IsARM, HasDB]> { let Inst{31-4} = 0xf57ff04; // FIXME: add support for options other than a full system DSB @@ -2372,7 +2372,7 @@ let Inst{3-0} = 0b1111; } -def DMB_MCR : AInoP<(outs), (ins GPR:$zero), Pseudo, NoItinerary, +def DMB_MCR : AInoP<(outs), (ins GPR:$zero), MiscFrm, NoItinerary, "mcr", "\tp15, 0, $zero, c7, c10, 5", [(ARMMemBarrierMCR GPR:$zero)]>, Requires<[IsARM, HasV6]> { @@ -2380,7 +2380,7 @@ // FIXME: add encoding } -def DSB_MCR : AInoP<(outs), (ins GPR:$zero), Pseudo, NoItinerary, +def DSB_MCR : AInoP<(outs), (ins GPR:$zero), MiscFrm, NoItinerary, "mcr", "\tp15, 0, $zero, c7, c10, 4", [(ARMSyncBarrierMCR GPR:$zero)]>, Requires<[IsARM, HasV6]> { Modified: llvm/trunk/lib/Target/ARM/Disassembler/ARMDisassemblerCore.cpp URL: http://llvm.org/viewvc/llvm-project/llvm/trunk/lib/Target/ARM/Disassembler/ARMDisassemblerCore.cpp?rev=110880&r1=110879&r2=110880&view=diff ============================================================================== --- llvm/trunk/lib/Target/ARM/Disassembler/ARMDisassemblerCore.cpp (original) +++ llvm/trunk/lib/Target/ARM/Disassembler/ARMDisassemblerCore.cpp Wed Aug 11 18:35:12 2010 @@ -493,9 +493,6 @@ static bool DisassemblePseudo(MCInst &MI, unsigned Opcode, uint32_t insn, unsigned short NumOps, unsigned &NumOpsAdded, BO) { - if (Opcode == ARM::DMBsy || Opcode == ARM::DSBsy) - return true; - assert(0 && "Unexpected pseudo instruction!"); return false; } Modified: llvm/trunk/lib/Target/ARM/Disassembler/ThumbDisassemblerCore.h URL: http://llvm.org/viewvc/llvm-project/llvm/trunk/lib/Target/ARM/Disassembler/ThumbDisassemblerCore.h?rev=110880&r1=110879&r2=110880&view=diff ============================================================================== --- llvm/trunk/lib/Target/ARM/Disassembler/ThumbDisassemblerCore.h (original) +++ llvm/trunk/lib/Target/ARM/Disassembler/ThumbDisassemblerCore.h Wed Aug 11 18:35:12 2010 @@ -1629,8 +1629,8 @@ // A8.6.26 // t2BXJ -> Rn // -// Miscellaneous control: t2Int_MemBarrierV7 (and its t2DMB variants), -// t2Int_SyncBarrierV7 (and its t2DSB varianst), t2ISBsy, t2CLREX +// Miscellaneous control: t2DMBsy (and its t2DMB variants), +// t2DSBsy (and its t2DSB varianst), t2ISBsy, t2CLREX // -> no operand (except pred-imm pred-ccr for CLREX, memory barrier variants) // // Hint: t2NOP, t2YIELD, t2WFE, t2WFI, t2SEV Modified: llvm/trunk/test/MC/Disassembler/arm-tests.txt URL: http://llvm.org/viewvc/llvm-project/llvm/trunk/test/MC/Disassembler/arm-tests.txt?rev=110880&r1=110879&r2=110880&view=diff ============================================================================== --- llvm/trunk/test/MC/Disassembler/arm-tests.txt (original) +++ llvm/trunk/test/MC/Disassembler/arm-tests.txt Wed Aug 11 18:35:12 2010 @@ -12,9 +12,15 @@ # CHECK: cmn r0, #1 0x01 0x00 0x70 0xe3 +# CHECK: dmb +0x5f 0xf0 0x7f 0xf5 + # CHECK: dmb nshst 0x56 0xf0 0x7f 0xf5 +# CHECK: dsb +0x4f 0xf0 0x7f 0xf5 + # CHECK: ldclvc p5, cr15, [r8], #-0 0x00 0xf5 0x78 0x7c From daniel at zuster.org Wed Aug 11 18:54:00 2010 From: daniel at zuster.org (Daniel Dunbar) Date: Wed, 11 Aug 2010 23:54:00 -0000 Subject: [llvm-commits] [llvm] r110883 - in /llvm/trunk: autoconf/configure.ac autoconf/m4/link_options.m4 configure include/llvm/Config/config.h.in Message-ID: <20100811235400.2C0AB2A6C12C@llvm.org> Author: ddunbar Date: Wed Aug 11 18:53:59 2010 New Revision: 110883 URL: http://llvm.org/viewvc/llvm-project?rev=110883&view=rev Log: configure: Add detection of the linker version string. - Review appreciated, as long as you understand that I understand that this is a horrible hack. Modified: llvm/trunk/autoconf/configure.ac llvm/trunk/autoconf/m4/link_options.m4 llvm/trunk/configure llvm/trunk/include/llvm/Config/config.h.in Modified: llvm/trunk/autoconf/configure.ac URL: http://llvm.org/viewvc/llvm-project/llvm/trunk/autoconf/configure.ac?rev=110883&r1=110882&r2=110883&view=diff ============================================================================== --- llvm/trunk/autoconf/configure.ac (original) +++ llvm/trunk/autoconf/configure.ac Wed Aug 11 18:53:59 2010 @@ -1041,6 +1041,9 @@ AC_PATH_PROGS(OCAMLDOC, [ocamldoc]) AC_PATH_PROGS(GAS, [gas as]) +dnl Get the version of the linker in use. +AC_LINK_GET_VERSION + dnl Determine whether the linker supports the -R option. AC_LINK_USE_R Modified: llvm/trunk/autoconf/m4/link_options.m4 URL: http://llvm.org/viewvc/llvm-project/llvm/trunk/autoconf/m4/link_options.m4?rev=110883&r1=110882&r2=110883&view=diff ============================================================================== --- llvm/trunk/autoconf/m4/link_options.m4 (original) +++ llvm/trunk/autoconf/m4/link_options.m4 Wed Aug 11 18:53:59 2010 @@ -1,4 +1,25 @@ # +# Get the linker version string. +# +# This macro is specific to LLVM. +# +AC_DEFUN([AC_LINK_GET_VERSION], + [AC_CACHE_CHECK([for linker version],[llvm_cv_link_version], + [ + version_string="$(ld -v 2>&1 | head -1)" + + # Check for ld64. + if (echo "$version_string" | grep -q "ld64"); then + llvm_cv_link_version=$(echo "$version_string" | sed -e "s#.*ld64-\([^ ]*\)#\1#") + else + llvm_cv_link_version=$(echo "$version_string" | sed -e "s#[^0-9]*\([0-9.]*\).*#\1#") + fi + ]) + AC_DEFINE_UNQUOTED([HOST_LINK_VERSION],"$llvm_cv_link_version", + [Linker version detected at compile time.]) +]) + +# # Determine if the system can handle the -R option being passed to the linker. # # This macro is specific to LLVM. Modified: llvm/trunk/configure URL: http://llvm.org/viewvc/llvm-project/llvm/trunk/configure?rev=110883&r1=110882&r2=110883&view=diff ============================================================================== --- llvm/trunk/configure (original) +++ llvm/trunk/configure Wed Aug 11 18:53:59 2010 @@ -8729,6 +8729,31 @@ done +{ echo "$as_me:$LINENO: checking for linker version" >&5 +echo $ECHO_N "checking for linker version... $ECHO_C" >&6; } +if test "${llvm_cv_link_version+set}" = set; then + echo $ECHO_N "(cached) $ECHO_C" >&6 +else + + version_string="$(ld -v 2>&1 | head -1)" + + # Check for ld64. + if (echo "$version_string" | grep -q "ld64"); then + llvm_cv_link_version=$(echo "$version_string" | sed -e "s#.*ld64-\([^ ]*\)#\1#") + else + llvm_cv_link_version=$(echo "$version_string" | sed -e "s#[^0-9]*\([0-9.]*\).*#\1#") + fi + +fi +{ echo "$as_me:$LINENO: result: $llvm_cv_link_version" >&5 +echo "${ECHO_T}$llvm_cv_link_version" >&6; } + +cat >>confdefs.h <<_ACEOF +#define HOST_LINK_VERSION "$llvm_cv_link_version" +_ACEOF + + + { echo "$as_me:$LINENO: checking for compiler -Wl,-R option" >&5 echo $ECHO_N "checking for compiler -Wl,-R option... $ECHO_C" >&6; } if test "${llvm_cv_link_use_r+set}" = set; then @@ -11395,7 +11420,7 @@ lt_dlunknown=0; lt_dlno_uscore=1; lt_dlneed_uscore=2 lt_status=$lt_dlunknown cat > conftest.$ac_ext < References: <20100811235400.2C0AB2A6C12C@llvm.org> Message-ID: <7449CF4F-096D-4772-8777-D9C928717FDD@apple.com> On Aug 11, 2010, at 4:54 PM, Daniel Dunbar wrote: > Author: ddunbar > Date: Wed Aug 11 18:53:59 2010 > New Revision: 110883 > > URL: http://llvm.org/viewvc/llvm-project?rev=110883&view=rev > Log: > configure: Add detection of the linker version string. > - Review appreciated, as long as you understand that I understand that this is > a horrible hack. Seems reasonable, it may or may not work for gnu ld, but it should be close if it matters. -eric From dpatel at apple.com Wed Aug 11 19:17:38 2010 From: dpatel at apple.com (Devang Patel) Date: Thu, 12 Aug 2010 00:17:38 -0000 Subject: [llvm-commits] [llvm] r110887 - /llvm/trunk/test/CodeGen/X86/2010-08-10-DbgConstant.ll Message-ID: <20100812001738.7B9172A6C12C@llvm.org> Author: dpatel Date: Wed Aug 11 19:17:38 2010 New Revision: 110887 URL: http://llvm.org/viewvc/llvm-project?rev=110887&view=rev Log: This is x86 only test. Modified: llvm/trunk/test/CodeGen/X86/2010-08-10-DbgConstant.ll Modified: llvm/trunk/test/CodeGen/X86/2010-08-10-DbgConstant.ll URL: http://llvm.org/viewvc/llvm-project/llvm/trunk/test/CodeGen/X86/2010-08-10-DbgConstant.ll?rev=110887&r1=110886&r2=110887&view=diff ============================================================================== --- llvm/trunk/test/CodeGen/X86/2010-08-10-DbgConstant.ll (original) +++ llvm/trunk/test/CodeGen/X86/2010-08-10-DbgConstant.ll Wed Aug 11 19:17:38 2010 @@ -1,4 +1,4 @@ -; RUN: llc -O0 < %s | FileCheck %s +; RUN: llc -march=x86 -O0 < %s | FileCheck %s ; CHECK: DW_TAG_constant ; CHECK-NEXT: ascii "ro" #{{#?}} DW_AT_name From daniel at zuster.org Wed Aug 11 19:55:32 2010 From: daniel at zuster.org (Daniel Dunbar) Date: Thu, 12 Aug 2010 00:55:32 -0000 Subject: [llvm-commits] [llvm] r110888 - in /llvm/trunk: include/llvm/Target/Target.td lib/Target/ARM/AsmParser/ARMAsmParser.cpp lib/Target/X86/X86.td utils/TableGen/AsmMatcherEmitter.cpp Message-ID: <20100812005532.CCAD92A6C12C@llvm.org> Author: ddunbar Date: Wed Aug 11 19:55:32 2010 New Revision: 110888 URL: http://llvm.org/viewvc/llvm-project?rev=110888&view=rev Log: tblgen/AsmMatcher: Always emit the match function as 'MatchInstructionImpl', target specific parsers can adapt the TargetAsmParser to this. Modified: llvm/trunk/include/llvm/Target/Target.td llvm/trunk/lib/Target/ARM/AsmParser/ARMAsmParser.cpp llvm/trunk/lib/Target/X86/X86.td llvm/trunk/utils/TableGen/AsmMatcherEmitter.cpp Modified: llvm/trunk/include/llvm/Target/Target.td URL: http://llvm.org/viewvc/llvm-project/llvm/trunk/include/llvm/Target/Target.td?rev=110888&r1=110887&r2=110888&view=diff ============================================================================== --- llvm/trunk/include/llvm/Target/Target.td (original) +++ llvm/trunk/include/llvm/Target/Target.td Wed Aug 11 19:55:32 2010 @@ -511,10 +511,6 @@ // perform target specific instruction post-processing. string AsmParserInstCleanup = ""; - // MatchInstructionName - The name of the instruction matching function to - // generate. - string MatchInstructionName = "MatchInstruction"; - // Variant - AsmParsers can be of multiple different variants. Variants are // used to support targets that need to parser multiple formats for the // assembly language. Modified: llvm/trunk/lib/Target/ARM/AsmParser/ARMAsmParser.cpp URL: http://llvm.org/viewvc/llvm-project/llvm/trunk/lib/Target/ARM/AsmParser/ARMAsmParser.cpp?rev=110888&r1=110887&r2=110888&view=diff ============================================================================== --- llvm/trunk/lib/Target/ARM/AsmParser/ARMAsmParser.cpp (original) +++ llvm/trunk/lib/Target/ARM/AsmParser/ARMAsmParser.cpp Wed Aug 11 19:55:32 2010 @@ -80,13 +80,19 @@ bool ParseDirectiveSyntax(SMLoc L); + bool MatchInstruction(const SmallVectorImpl &Operands, + MCInst &Inst) { + return MatchInstructionImpl(Operands, Inst); + } + /// @name Auto-generated Match Functions /// { unsigned ComputeAvailableFeatures(const ARMSubtarget *Subtarget) const; - bool MatchInstruction(const SmallVectorImpl &Operands, - MCInst &Inst); + bool MatchInstructionImpl(const SmallVectorImpl + &Operands, + MCInst &Inst); /// } Modified: llvm/trunk/lib/Target/X86/X86.td URL: http://llvm.org/viewvc/llvm-project/llvm/trunk/lib/Target/X86/X86.td?rev=110888&r1=110887&r2=110888&view=diff ============================================================================== --- llvm/trunk/lib/Target/X86/X86.td (original) +++ llvm/trunk/lib/Target/X86/X86.td Wed Aug 11 19:55:32 2010 @@ -182,7 +182,6 @@ // Currently the X86 assembly parser only supports ATT syntax. def ATTAsmParser : AsmParser { string AsmParserClassName = "ATTAsmParser"; - string MatchInstructionName = "MatchInstructionImpl"; int Variant = 0; // Discard comments in assembly strings. Modified: llvm/trunk/utils/TableGen/AsmMatcherEmitter.cpp URL: http://llvm.org/viewvc/llvm-project/llvm/trunk/utils/TableGen/AsmMatcherEmitter.cpp?rev=110888&r1=110887&r2=110888&view=diff ============================================================================== --- llvm/trunk/utils/TableGen/AsmMatcherEmitter.cpp (original) +++ llvm/trunk/utils/TableGen/AsmMatcherEmitter.cpp Wed Aug 11 19:55:32 2010 @@ -1699,13 +1699,10 @@ it != ie; ++it) MaxNumOperands = std::max(MaxNumOperands, (*it)->Operands.size()); - const std::string &MatchName = - AsmParser->getValueAsString("MatchInstructionName"); OS << "bool " << Target.getName() << ClassName << "::\n" - << MatchName - << "(const SmallVectorImpl &Operands,\n"; - OS.indent(MatchName.size() + 1); - OS << "MCInst &Inst) {\n"; + << "MatchInstructionImpl(const SmallVectorImpl" + << " &Operands,\n"; + OS << " MCInst &Inst) {\n"; // Emit the static match table; unused classes get initalized to 0 which is // guaranteed to be InvalidMatchClass. From daniel at zuster.org Wed Aug 11 19:55:38 2010 From: daniel at zuster.org (Daniel Dunbar) Date: Thu, 12 Aug 2010 00:55:38 -0000 Subject: [llvm-commits] [llvm] r110889 - in /llvm/trunk: include/llvm/Target/TargetAsmParser.h lib/MC/MCParser/AsmParser.cpp lib/Target/ARM/AsmParser/ARMAsmParser.cpp lib/Target/X86/AsmParser/X86AsmParser.cpp Message-ID: <20100812005538.41E9F2A6C12D@llvm.org> Author: ddunbar Date: Wed Aug 11 19:55:38 2010 New Revision: 110889 URL: http://llvm.org/viewvc/llvm-project?rev=110889&view=rev Log: MC/AsmParser: Push the burdon of emitting diagnostics about unmatched instructions onto the target specific parser, which can do a better job. Modified: llvm/trunk/include/llvm/Target/TargetAsmParser.h llvm/trunk/lib/MC/MCParser/AsmParser.cpp llvm/trunk/lib/Target/ARM/AsmParser/ARMAsmParser.cpp llvm/trunk/lib/Target/X86/AsmParser/X86AsmParser.cpp Modified: llvm/trunk/include/llvm/Target/TargetAsmParser.h URL: http://llvm.org/viewvc/llvm-project/llvm/trunk/include/llvm/Target/TargetAsmParser.h?rev=110889&r1=110888&r2=110889&view=diff ============================================================================== --- llvm/trunk/include/llvm/Target/TargetAsmParser.h (original) +++ llvm/trunk/include/llvm/Target/TargetAsmParser.h Wed Aug 11 19:55:38 2010 @@ -73,8 +73,12 @@ /// MatchInstruction - Recognize a series of operands of a parsed instruction /// as an actual MCInst. This returns false and fills in Inst on success and /// returns true on failure to match. + /// + /// On failure, the target parser is responsible for emitting a diagnostic + /// explaining the match failure. virtual bool - MatchInstruction(const SmallVectorImpl &Operands, + MatchInstruction(SMLoc IDLoc, + const SmallVectorImpl &Operands, MCInst &Inst) = 0; }; Modified: llvm/trunk/lib/MC/MCParser/AsmParser.cpp URL: http://llvm.org/viewvc/llvm-project/llvm/trunk/lib/MC/MCParser/AsmParser.cpp?rev=110889&r1=110888&r2=110889&view=diff ============================================================================== --- llvm/trunk/lib/MC/MCParser/AsmParser.cpp (original) +++ llvm/trunk/lib/MC/MCParser/AsmParser.cpp Wed Aug 11 19:55:38 2010 @@ -934,17 +934,11 @@ // If parsing succeeded, match the instruction. if (!HadError) { MCInst Inst; - if (!getTargetParser().MatchInstruction(ParsedOperands, Inst)) { + if (!getTargetParser().MatchInstruction(IDLoc, ParsedOperands, Inst)) { // Emit the instruction on success. Out.EmitInstruction(Inst); - } else { - // Otherwise emit a diagnostic about the match failure and set the error - // flag. - // - // FIXME: We should give nicer diagnostics about the exact failure. - Error(IDLoc, "unrecognized instruction"); + } else HadError = true; - } } // If there was no error, consume the end-of-statement token. Otherwise this Modified: llvm/trunk/lib/Target/ARM/AsmParser/ARMAsmParser.cpp URL: http://llvm.org/viewvc/llvm-project/llvm/trunk/lib/Target/ARM/AsmParser/ARMAsmParser.cpp?rev=110889&r1=110888&r2=110889&view=diff ============================================================================== --- llvm/trunk/lib/Target/ARM/AsmParser/ARMAsmParser.cpp (original) +++ llvm/trunk/lib/Target/ARM/AsmParser/ARMAsmParser.cpp Wed Aug 11 19:55:38 2010 @@ -80,9 +80,16 @@ bool ParseDirectiveSyntax(SMLoc L); - bool MatchInstruction(const SmallVectorImpl &Operands, + bool MatchInstruction(SMLoc IDLoc, + const SmallVectorImpl &Operands, MCInst &Inst) { - return MatchInstructionImpl(Operands, Inst); + if (!MatchInstructionImpl(Operands, Inst)) + return false; + + // FIXME: We should give nicer diagnostics about the exact failure. + Error(IDLoc, "unrecognized instruction"); + + return true; } /// @name Auto-generated Match Functions Modified: llvm/trunk/lib/Target/X86/AsmParser/X86AsmParser.cpp URL: http://llvm.org/viewvc/llvm-project/llvm/trunk/lib/Target/X86/AsmParser/X86AsmParser.cpp?rev=110889&r1=110888&r2=110889&view=diff ============================================================================== --- llvm/trunk/lib/Target/X86/AsmParser/X86AsmParser.cpp (original) +++ llvm/trunk/lib/Target/X86/AsmParser/X86AsmParser.cpp Wed Aug 11 19:55:38 2010 @@ -10,6 +10,7 @@ #include "llvm/Target/TargetAsmParser.h" #include "X86.h" #include "X86Subtarget.h" +#include "llvm/ADT/SmallString.h" #include "llvm/ADT/SmallVector.h" #include "llvm/ADT/StringSwitch.h" #include "llvm/ADT/Twine.h" @@ -50,7 +51,8 @@ bool ParseDirectiveWord(unsigned Size, SMLoc L); - bool MatchInstruction(const SmallVectorImpl &Operands, + bool MatchInstruction(SMLoc IDLoc, + const SmallVectorImpl &Operands, MCInst &Inst); /// @name Auto-generated Matcher Functions @@ -871,31 +873,32 @@ return false; } + bool -X86ATTAsmParser::MatchInstruction(const SmallVectorImpl +X86ATTAsmParser::MatchInstruction(SMLoc IDLoc, + const SmallVectorImpl &Operands, MCInst &Inst) { + assert(!Operands.empty() && "Unexpect empty operand list!"); + + X86Operand *Op = static_cast(Operands[0]); + assert(Op->isToken() && "Leading operand should always be a mnemonic!"); + // First, try a direct match. if (!MatchInstructionImpl(Operands, Inst)) return false; - // Ignore anything which is obviously not a suffix match. - if (Operands.size() == 0) - return true; - X86Operand *Op = static_cast(Operands[0]); - if (!Op->isToken() || Op->getToken().size() > 15) - return true; - // FIXME: Ideally, we would only attempt suffix matches for things which are // valid prefixes, and we could just infer the right unambiguous // type. However, that requires substantially more matcher support than the // following hack. // Change the operand to point to a temporary token. - char Tmp[16]; StringRef Base = Op->getToken(); - memcpy(Tmp, Base.data(), Base.size()); - Op->setTokenValue(StringRef(Tmp, Base.size() + 1)); + SmallString<16> Tmp; + Tmp += Base; + Tmp += ' '; + Op->setTokenValue(Tmp.str()); // Check for the various suffix matches. Tmp[Base.size()] = 'b'; @@ -917,6 +920,10 @@ return false; // Otherwise, the match failed. + + // FIXME: We should give nicer diagnostics about the exact failure. + Error(IDLoc, "unrecognized instruction"); + return true; } From daniel at zuster.org Wed Aug 11 19:55:42 2010 From: daniel at zuster.org (Daniel Dunbar) Date: Thu, 12 Aug 2010 00:55:42 -0000 Subject: [llvm-commits] [llvm] r110890 - in /llvm/trunk: lib/Target/X86/AsmParser/X86AsmParser.cpp test/MC/AsmParser/X86/x86_instruction_errors.s Message-ID: <20100812005542.584612A6C12C@llvm.org> Author: ddunbar Date: Wed Aug 11 19:55:42 2010 New Revision: 110890 URL: http://llvm.org/viewvc/llvm-project?rev=110890&view=rev Log: MC/X86/AsmParser: Give an explicit error message when we reject an instruction because it could have an ambiguous suffix. Added: llvm/trunk/test/MC/AsmParser/X86/x86_instruction_errors.s Modified: llvm/trunk/lib/Target/X86/AsmParser/X86AsmParser.cpp Modified: llvm/trunk/lib/Target/X86/AsmParser/X86AsmParser.cpp URL: http://llvm.org/viewvc/llvm-project/llvm/trunk/lib/Target/X86/AsmParser/X86AsmParser.cpp?rev=110890&r1=110889&r2=110890&view=diff ============================================================================== --- llvm/trunk/lib/Target/X86/AsmParser/X86AsmParser.cpp (original) +++ llvm/trunk/lib/Target/X86/AsmParser/X86AsmParser.cpp Wed Aug 11 19:55:42 2010 @@ -21,6 +21,7 @@ #include "llvm/MC/MCParser/MCAsmParser.h" #include "llvm/MC/MCParser/MCParsedAsmOperand.h" #include "llvm/Support/SourceMgr.h" +#include "llvm/Support/raw_ostream.h" #include "llvm/Target/TargetRegistry.h" #include "llvm/Target/TargetAsmParser.h" using namespace llvm; @@ -921,8 +922,36 @@ // Otherwise, the match failed. - // FIXME: We should give nicer diagnostics about the exact failure. - Error(IDLoc, "unrecognized instruction"); + // If we had multiple suffix matches, then identify this as an ambiguous + // match. + if (MatchB + MatchW + MatchL + MatchQ != 4) { + char MatchChars[4]; + unsigned NumMatches = 0; + if (!MatchB) + MatchChars[NumMatches++] = 'b'; + if (!MatchW) + MatchChars[NumMatches++] = 'w'; + if (!MatchL) + MatchChars[NumMatches++] = 'l'; + if (!MatchQ) + MatchChars[NumMatches++] = 'q'; + + SmallString<126> Msg; + raw_svector_ostream OS(Msg); + OS << "ambiguous instructions require an explicit suffix (could be "; + for (unsigned i = 0; i != NumMatches; ++i) { + if (i != 0) + OS << ", "; + if (i + 1 == NumMatches) + OS << "or "; + OS << "'" << Base << MatchChars[i] << "'"; + } + OS << ")"; + Error(IDLoc, OS.str()); + } else { + // FIXME: We should give nicer diagnostics about the exact failure. + Error(IDLoc, "unrecognized instruction"); + } return true; } Added: llvm/trunk/test/MC/AsmParser/X86/x86_instruction_errors.s URL: http://llvm.org/viewvc/llvm-project/llvm/trunk/test/MC/AsmParser/X86/x86_instruction_errors.s?rev=110890&view=auto ============================================================================== --- llvm/trunk/test/MC/AsmParser/X86/x86_instruction_errors.s (added) +++ llvm/trunk/test/MC/AsmParser/X86/x86_instruction_errors.s Wed Aug 11 19:55:42 2010 @@ -0,0 +1,5 @@ +// RUN: not llvm-mc -triple x86_64-unknown-unknown %s 2> %t.err +// RUN: FileCheck < %t.err %s + +// CHECK: error: ambiguous instructions require an explicit suffix (could be 'cmpb', 'cmpw', 'cmpl', or 'cmpq') +cmp $0, 0(%eax) From johnny.chen at apple.com Wed Aug 11 20:40:54 2010 From: johnny.chen at apple.com (Johnny Chen) Date: Thu, 12 Aug 2010 01:40:54 -0000 Subject: [llvm-commits] [llvm] r110894 - in /llvm/trunk: lib/Target/ARM/Disassembler/ARMDisassembler.cpp lib/Target/ARM/Disassembler/ARMDisassemblerCore.cpp test/MC/Disassembler/arm-tests.txt Message-ID: <20100812014054.802202A6C12C@llvm.org> Author: johnny Date: Wed Aug 11 20:40:54 2010 New Revision: 110894 URL: http://llvm.org/viewvc/llvm-project?rev=110894&view=rev Log: The autogened decoder was confusing the ARM STRBT for ARM USAT, because the .td entry for ARM STRBT is actually a super-instruction for A8.6.199 STRBT A1 & A2. Recover by looking for ARM:USAT encoding pattern before delegating to the auto- gened decoder. Added a "usat" test case to arm-tests.txt. Modified: llvm/trunk/lib/Target/ARM/Disassembler/ARMDisassembler.cpp llvm/trunk/lib/Target/ARM/Disassembler/ARMDisassemblerCore.cpp llvm/trunk/test/MC/Disassembler/arm-tests.txt Modified: llvm/trunk/lib/Target/ARM/Disassembler/ARMDisassembler.cpp URL: http://llvm.org/viewvc/llvm-project/llvm/trunk/lib/Target/ARM/Disassembler/ARMDisassembler.cpp?rev=110894&r1=110893&r2=110894&view=diff ============================================================================== --- llvm/trunk/lib/Target/ARM/Disassembler/ARMDisassembler.cpp (original) +++ llvm/trunk/lib/Target/ARM/Disassembler/ARMDisassembler.cpp Wed Aug 11 20:40:54 2010 @@ -26,6 +26,8 @@ #include "llvm/Support/ErrorHandling.h" #include "llvm/Support/raw_ostream.h" +//#define DEBUG(X) do { X; } while (0) + /// ARMGenDecoderTables.inc - ARMDecoderTables.inc is tblgen'ed from /// ARMDecoderEmitter.cpp TableGen backend. It contains: /// @@ -87,6 +89,11 @@ return ARM::BFI; } + // Ditto for STRBT, which is a super-instruction for A8.6.199 Encoding A1 & A2. + // As a result, the decoder fails to deocode USAT properly. + if (slice(insn, 27, 21) == 0x37 && slice(insn, 5, 4) == 1) + return ARM::USAT; + // Ditto for ADDSrs, which is a super-instruction for A8.6.7 & A8.6.8. // As a result, the decoder fails to decode UMULL properly. if (slice(insn, 27, 21) == 0x04 && slice(insn, 7, 4) == 9) { Modified: llvm/trunk/lib/Target/ARM/Disassembler/ARMDisassemblerCore.cpp URL: http://llvm.org/viewvc/llvm-project/llvm/trunk/lib/Target/ARM/Disassembler/ARMDisassemblerCore.cpp?rev=110894&r1=110893&r2=110894&view=diff ============================================================================== --- llvm/trunk/lib/Target/ARM/Disassembler/ARMDisassemblerCore.cpp (original) +++ llvm/trunk/lib/Target/ARM/Disassembler/ARMDisassemblerCore.cpp Wed Aug 11 20:40:54 2010 @@ -20,6 +20,8 @@ #include "llvm/Support/Debug.h" #include "llvm/Support/raw_ostream.h" +//#define DEBUG(X) do { X; } while (0) + /// ARMGenInstrInfo.inc - ARMGenInstrInfo.inc contains the static const /// TargetInstrDesc ARMInsts[] definition and the TargetOperandInfo[]'s /// describing the operand info for each ARMInsts[i]. Modified: llvm/trunk/test/MC/Disassembler/arm-tests.txt URL: http://llvm.org/viewvc/llvm-project/llvm/trunk/test/MC/Disassembler/arm-tests.txt?rev=110894&r1=110893&r2=110894&view=diff ============================================================================== --- llvm/trunk/test/MC/Disassembler/arm-tests.txt (original) +++ llvm/trunk/test/MC/Disassembler/arm-tests.txt Wed Aug 11 20:40:54 2010 @@ -97,3 +97,5 @@ # CHECK: ubfx r0, r0, #16, #1 0x50 0x08 0xe0 0xe7 +# CHECK: usat r8, #0, r10, asr #32 +0x5a 0x80 0xe0 0xe6 From daniel at zuster.org Wed Aug 11 20:49:46 2010 From: daniel at zuster.org (Daniel Dunbar) Date: Thu, 12 Aug 2010 01:49:46 -0000 Subject: [llvm-commits] [zorg] r110895 - /zorg/trunk/buildbot/osuosl/master/master.cfg Message-ID: <20100812014946.1AD8C2A6C12E@llvm.org> Author: ddunbar Date: Wed Aug 11 20:49:45 2010 New Revision: 110895 URL: http://llvm.org/viewvc/llvm-project?rev=110895&view=rev Log: buildbot: Drop cache limits, to decrease machine pressure. Modified: zorg/trunk/buildbot/osuosl/master/master.cfg Modified: zorg/trunk/buildbot/osuosl/master/master.cfg URL: http://llvm.org/viewvc/llvm-project/zorg/trunk/buildbot/osuosl/master/master.cfg?rev=110895&r1=110894&r2=110895&view=diff ============================================================================== --- zorg/trunk/buildbot/osuosl/master/master.cfg (original) +++ zorg/trunk/buildbot/osuosl/master/master.cfg Wed Aug 11 20:49:45 2010 @@ -68,16 +68,16 @@ ####### RESOURCE USAGE # Number of build records to maintain per builder. -c['buildHorizon'] = 1000 +c['buildHorizon'] = 200 # Number of logs to maintain per builder. -c['logHorizon'] = 100 +c['logHorizon'] = 50 # Number of events (connect, disconnect, etc.) to maintain. c['eventHorizon'] = 100 # Number of builds to cache in memory. -c['buildCacheSize'] = 1000 +c['buildCacheSize'] = 200 # Use gzip instead of bz2, to reduce server load. c['logCompressionMethod'] = 'gz' From bruno.cardoso at gmail.com Wed Aug 11 21:06:36 2010 From: bruno.cardoso at gmail.com (Bruno Cardoso Lopes) Date: Thu, 12 Aug 2010 02:06:36 -0000 Subject: [llvm-commits] [llvm] r110897 - in /llvm/trunk: lib/Target/X86/X86ISelLowering.cpp lib/Target/X86/X86InstrSSE.td lib/Target/X86/X86MCInstLower.cpp test/CodeGen/X86/avx-256.ll Message-ID: <20100812020636.CDDB72A6C12C@llvm.org> Author: bruno Date: Wed Aug 11 21:06:36 2010 New Revision: 110897 URL: http://llvm.org/viewvc/llvm-project?rev=110897&view=rev Log: Begin to support some vector operations for AVX 256-bit intructions. The long term goal here is to be able to match enough of vector_shuffle and build_vector so all avx intrinsics which aren't mapped to their own built-ins but to shufflevector calls can be codegen'd. This is the first (baby) step, support building zeroed vectors. Added: llvm/trunk/test/CodeGen/X86/avx-256.ll Modified: llvm/trunk/lib/Target/X86/X86ISelLowering.cpp llvm/trunk/lib/Target/X86/X86InstrSSE.td llvm/trunk/lib/Target/X86/X86MCInstLower.cpp Modified: llvm/trunk/lib/Target/X86/X86ISelLowering.cpp URL: http://llvm.org/viewvc/llvm-project/llvm/trunk/lib/Target/X86/X86ISelLowering.cpp?rev=110897&r1=110896&r2=110897&view=diff ============================================================================== --- llvm/trunk/lib/Target/X86/X86ISelLowering.cpp (original) +++ llvm/trunk/lib/Target/X86/X86ISelLowering.cpp Wed Aug 11 21:06:36 2010 @@ -883,7 +883,7 @@ setOperationAction(ISD::FDIV, MVT::v8f32, Legal); setOperationAction(ISD::FSQRT, MVT::v8f32, Legal); setOperationAction(ISD::FNEG, MVT::v8f32, Custom); - //setOperationAction(ISD::BUILD_VECTOR, MVT::v8f32, Custom); + setOperationAction(ISD::BUILD_VECTOR, MVT::v8f32, Custom); //setOperationAction(ISD::VECTOR_SHUFFLE, MVT::v8f32, Custom); //setOperationAction(ISD::EXTRACT_VECTOR_ELT, MVT::v8f32, Custom); //setOperationAction(ISD::SELECT, MVT::v8f32, Custom); @@ -3412,18 +3412,27 @@ DebugLoc dl) { assert(VT.isVector() && "Expected a vector type"); - // Always build zero vectors as <4 x i32> or <2 x i32> bitcasted to their dest - // type. This ensures they get CSE'd. + // Always build zero vectors as <4 x i32> or <2 x i32> bitcasted + // to their dest type. This ensures they get CSE'd. SDValue Vec; if (VT.getSizeInBits() == 64) { // MMX SDValue Cst = DAG.getTargetConstant(0, MVT::i32); Vec = DAG.getNode(ISD::BUILD_VECTOR, dl, MVT::v2i32, Cst, Cst); - } else if (HasSSE2) { // SSE2 - SDValue Cst = DAG.getTargetConstant(0, MVT::i32); - Vec = DAG.getNode(ISD::BUILD_VECTOR, dl, MVT::v4i32, Cst, Cst, Cst, Cst); - } else { // SSE1 + } else if (VT.getSizeInBits() == 128) { + if (HasSSE2) { // SSE2 + SDValue Cst = DAG.getTargetConstant(0, MVT::i32); + Vec = DAG.getNode(ISD::BUILD_VECTOR, dl, MVT::v4i32, Cst, Cst, Cst, Cst); + } else { // SSE1 + SDValue Cst = DAG.getTargetConstantFP(+0.0, MVT::f32); + Vec = DAG.getNode(ISD::BUILD_VECTOR, dl, MVT::v4f32, Cst, Cst, Cst, Cst); + } + } else if (VT.getSizeInBits() == 256) { // AVX + // 256-bit logic and arithmetic instructions in AVX are + // all floating-point, no support for integer ops. Default + // to emitting fp zeroed vectors then. SDValue Cst = DAG.getTargetConstantFP(+0.0, MVT::f32); - Vec = DAG.getNode(ISD::BUILD_VECTOR, dl, MVT::v4f32, Cst, Cst, Cst, Cst); + SDValue Ops[] = { Cst, Cst, Cst, Cst, Cst, Cst, Cst, Cst }; + Vec = DAG.getNode(ISD::BUILD_VECTOR, dl, MVT::v8f32, Ops, 8); } return DAG.getNode(ISD::BIT_CONVERT, dl, VT, Vec); } @@ -3437,9 +3446,9 @@ // type. This ensures they get CSE'd. SDValue Cst = DAG.getTargetConstant(~0U, MVT::i32); SDValue Vec; - if (VT.getSizeInBits() == 64) // MMX + if (VT.getSizeInBits() == 64) // MMX Vec = DAG.getNode(ISD::BUILD_VECTOR, dl, MVT::v2i32, Cst, Cst); - else // SSE + else // SSE Vec = DAG.getNode(ISD::BUILD_VECTOR, dl, MVT::v4i32, Cst, Cst, Cst, Cst); return DAG.getNode(ISD::BIT_CONVERT, dl, VT, Vec); } @@ -3844,9 +3853,13 @@ SDValue X86TargetLowering::LowerBUILD_VECTOR(SDValue Op, SelectionDAG &DAG) const { DebugLoc dl = Op.getDebugLoc(); - // All zero's are handled with pxor, all one's are handled with pcmpeqd. - if (ISD::isBuildVectorAllZeros(Op.getNode()) - || ISD::isBuildVectorAllOnes(Op.getNode())) { + // All zero's are handled with pxor in SSE2 and above, xorps in SSE1 and + // all one's are handled with pcmpeqd. In AVX, zero's are handled with + // vpxor in 128-bit and xor{pd,ps} in 256-bit, but no 256 version of pcmpeqd + // is present, so AllOnes is ignored. + if (ISD::isBuildVectorAllZeros(Op.getNode()) || + (Op.getValueType().getSizeInBits() != 256 && + ISD::isBuildVectorAllOnes(Op.getNode()))) { // Canonicalize this to either <4 x i32> or <2 x i32> (SSE vs MMX) to // 1) ensure the zero vectors are CSE'd, and 2) ensure that i64 scalars are // eliminated on x86-32 hosts. Modified: llvm/trunk/lib/Target/X86/X86InstrSSE.td URL: http://llvm.org/viewvc/llvm-project/llvm/trunk/lib/Target/X86/X86InstrSSE.td?rev=110897&r1=110896&r2=110897&view=diff ============================================================================== --- llvm/trunk/lib/Target/X86/X86InstrSSE.td (original) +++ llvm/trunk/lib/Target/X86/X86InstrSSE.td Wed Aug 11 21:06:36 2010 @@ -2186,6 +2186,14 @@ [(set VR128:$dst, (v4i32 immAllZerosV))]>; } +let isReMaterializable = 1, isAsCheapAsAMove = 1, canFoldAsLoad = 1, + isCodeGenOnly = 1, Predicates = [HasAVX] in { +def V_SET0PSY : PSI<0x57, MRMInitReg, (outs VR256:$dst), (ins), "", + [(set VR256:$dst, (v8f32 immAllZerosV))]>, VEX_4V; +def V_SET0PDY : PDI<0x57, MRMInitReg, (outs VR256:$dst), (ins), "", + [(set VR256:$dst, (v4f64 immAllZerosV))]>, VEX_4V; +} + def : Pat<(v2i64 immAllZerosV), (V_SET0PI)>; def : Pat<(v8i16 immAllZerosV), (V_SET0PI)>; def : Pat<(v16i8 immAllZerosV), (V_SET0PI)>; Modified: llvm/trunk/lib/Target/X86/X86MCInstLower.cpp URL: http://llvm.org/viewvc/llvm-project/llvm/trunk/lib/Target/X86/X86MCInstLower.cpp?rev=110897&r1=110896&r2=110897&view=diff ============================================================================== --- llvm/trunk/lib/Target/X86/X86MCInstLower.cpp (original) +++ llvm/trunk/lib/Target/X86/X86MCInstLower.cpp Wed Aug 11 21:06:36 2010 @@ -374,12 +374,14 @@ case X86::MMX_V_SET0: LowerUnaryToTwoAddr(OutMI, X86::MMX_PXORrr); break; case X86::MMX_V_SETALLONES: LowerUnaryToTwoAddr(OutMI, X86::MMX_PCMPEQDrr); break; - case X86::FsFLD0SS: LowerUnaryToTwoAddr(OutMI, X86::PXORrr); break; - case X86::FsFLD0SD: LowerUnaryToTwoAddr(OutMI, X86::PXORrr); break; - case X86::V_SET0PS: LowerUnaryToTwoAddr(OutMI, X86::XORPSrr); break; - case X86::V_SET0PD: LowerUnaryToTwoAddr(OutMI, X86::XORPDrr); break; - case X86::V_SET0PI: LowerUnaryToTwoAddr(OutMI, X86::PXORrr); break; - case X86::V_SETALLONES: LowerUnaryToTwoAddr(OutMI, X86::PCMPEQDrr); break; + case X86::FsFLD0SS: LowerUnaryToTwoAddr(OutMI, X86::PXORrr); break; + case X86::FsFLD0SD: LowerUnaryToTwoAddr(OutMI, X86::PXORrr); break; + case X86::V_SET0PS: LowerUnaryToTwoAddr(OutMI, X86::XORPSrr); break; + case X86::V_SET0PSY: LowerUnaryToTwoAddr(OutMI, X86::VXORPSYrr); break; + case X86::V_SET0PD: LowerUnaryToTwoAddr(OutMI, X86::XORPDrr); break; + case X86::V_SET0PDY: LowerUnaryToTwoAddr(OutMI, X86::VXORPDYrr); break; + case X86::V_SET0PI: LowerUnaryToTwoAddr(OutMI, X86::PXORrr); break; + case X86::V_SETALLONES: LowerUnaryToTwoAddr(OutMI, X86::PCMPEQDrr); break; case X86::MOV16r0: LowerSubReg32_Op0(OutMI, X86::MOV32r0); // MOV16r0 -> MOV32r0 Added: llvm/trunk/test/CodeGen/X86/avx-256.ll URL: http://llvm.org/viewvc/llvm-project/llvm/trunk/test/CodeGen/X86/avx-256.ll?rev=110897&view=auto ============================================================================== --- llvm/trunk/test/CodeGen/X86/avx-256.ll (added) +++ llvm/trunk/test/CodeGen/X86/avx-256.ll Wed Aug 11 21:06:36 2010 @@ -0,0 +1,15 @@ +; RUN: llc < %s -mtriple=x86_64-apple-darwin -march=x86 -mcpu=corei7 -mattr=avx | FileCheck %s + + at x = common global <8 x float> zeroinitializer, align 32 + at y = common global <4 x double> zeroinitializer, align 32 + +define void @zero() nounwind ssp { +entry: + ; CHECK: vxorps + ; CHECK: vmovaps + ; CHECK: vmovaps + store <8 x float> zeroinitializer, <8 x float>* @x, align 32 + store <4 x double> zeroinitializer, <4 x double>* @y, align 32 + ret void +} + From bruno.cardoso at gmail.com Wed Aug 11 21:08:53 2010 From: bruno.cardoso at gmail.com (Bruno Cardoso Lopes) Date: Thu, 12 Aug 2010 02:08:53 -0000 Subject: [llvm-commits] [llvm] r110898 - /llvm/trunk/lib/Target/X86/X86InstrInfo.cpp Message-ID: <20100812020853.2165C2A6C12C@llvm.org> Author: bruno Date: Wed Aug 11 21:08:52 2010 New Revision: 110898 URL: http://llvm.org/viewvc/llvm-project?rev=110898&view=rev Log: Fix comment order Modified: llvm/trunk/lib/Target/X86/X86InstrInfo.cpp Modified: llvm/trunk/lib/Target/X86/X86InstrInfo.cpp URL: http://llvm.org/viewvc/llvm-project/llvm/trunk/lib/Target/X86/X86InstrInfo.cpp?rev=110898&r1=110897&r2=110898&view=diff ============================================================================== --- llvm/trunk/lib/Target/X86/X86InstrInfo.cpp (original) +++ llvm/trunk/lib/Target/X86/X86InstrInfo.cpp Wed Aug 11 21:08:52 2010 @@ -2980,7 +2980,7 @@ // that we don't include here. We don't want to replace instructions selected // by intrinsics. static const unsigned ReplaceableInstrs[][3] = { - //PackedInt PackedSingle PackedDouble + //PackedSingle PackedDouble PackedInt { X86::MOVAPSmr, X86::MOVAPDmr, X86::MOVDQAmr }, { X86::MOVAPSrm, X86::MOVAPDrm, X86::MOVDQArm }, { X86::MOVAPSrr, X86::MOVAPDrr, X86::MOVDQArr }, From echristo at apple.com Thu Aug 12 02:01:23 2010 From: echristo at apple.com (Eric Christopher) Date: Thu, 12 Aug 2010 07:01:23 -0000 Subject: [llvm-commits] [llvm] r110905 - in /llvm/trunk: lib/Transforms/InstCombine/InstCombineVectorOps.cpp test/Transforms/InstCombine/vec_shuffle.ll Message-ID: <20100812070123.2D57A2A6C12C@llvm.org> Author: echristo Date: Thu Aug 12 02:01:22 2010 New Revision: 110905 URL: http://llvm.org/viewvc/llvm-project?rev=110905&view=rev Log: Temporarily revert 110737 and 110734, they were causing failures in an external testsuite. Modified: llvm/trunk/lib/Transforms/InstCombine/InstCombineVectorOps.cpp llvm/trunk/test/Transforms/InstCombine/vec_shuffle.ll Modified: llvm/trunk/lib/Transforms/InstCombine/InstCombineVectorOps.cpp URL: http://llvm.org/viewvc/llvm-project/llvm/trunk/lib/Transforms/InstCombine/InstCombineVectorOps.cpp?rev=110905&r1=110904&r2=110905&view=diff ============================================================================== --- llvm/trunk/lib/Transforms/InstCombine/InstCombineVectorOps.cpp (original) +++ llvm/trunk/lib/Transforms/InstCombine/InstCombineVectorOps.cpp Thu Aug 12 02:01:22 2010 @@ -448,8 +448,10 @@ if (isa(SVI.getOperand(2))) return ReplaceInstUsesWith(SVI, UndefValue::get(SVI.getType())); - unsigned VWidth = Mask.size(); - unsigned LHSWidth = cast(LHS->getType())->getNumElements(); + unsigned VWidth = cast(SVI.getType())->getNumElements(); + + if (VWidth != cast(LHS->getType())->getNumElements()) + return 0; APInt UndefElts(VWidth, 0); APInt AllOnesEltMask(APInt::getAllOnesValue(VWidth)); @@ -462,12 +464,14 @@ // Canonicalize shuffle(x ,x,mask) -> shuffle(x, undef,mask') // Canonicalize shuffle(undef,x,mask) -> shuffle(x, undef,mask'). if (LHS == RHS || isa(LHS)) { - if (isa(LHS) && LHS == RHS) - return ReplaceInstUsesWith(SVI, UndefValue::get(SVI.getType())); + if (isa(LHS) && LHS == RHS) { + // shuffle(undef,undef,mask) -> undef. + return ReplaceInstUsesWith(SVI, LHS); + } // Remap any references to RHS to use LHS. std::vector Elts; - for (unsigned i = 0, e = LHSWidth; i != VWidth; ++i) { + for (unsigned i = 0, e = Mask.size(); i != e; ++i) { if (Mask[i] >= 2*e) Elts.push_back(UndefValue::get(Type::getInt32Ty(SVI.getContext()))); else { @@ -491,148 +495,67 @@ } // Analyze the shuffle, are the LHS or RHS and identity shuffles? - if (VWidth == LHSWidth) { - bool isLHSID = true, isRHSID = true; - - for (unsigned i = 0, e = Mask.size(); i != e; ++i) { - if (Mask[i] >= e*2) continue; // Ignore undef values. - // Is this an identity shuffle of the LHS value? - isLHSID &= (Mask[i] == i); - - // Is this an identity shuffle of the RHS value? - isRHSID &= (Mask[i]-e == i); - } - - // Eliminate identity shuffles. - if (isLHSID) return ReplaceInstUsesWith(SVI, LHS); - if (isRHSID) return ReplaceInstUsesWith(SVI, RHS); - } + bool isLHSID = true, isRHSID = true; - // Check for a handful of important shuffle(shuffle()) combinations. - ShuffleVectorInst *LSVI = dyn_cast(LHS); - if (!LSVI) - return MadeChange ? &SVI : 0; - - LHS = LSVI->getOperand(0); - std::vector LHSMask = getShuffleMask(LSVI); - unsigned LHSInNElts = cast(LHS->getType())->getNumElements(); - - // If lhs is identity, propagate - bool isLHSLoExtract = true, isLHSHiExtract = true; - for (unsigned i = 0, e = LHSMask.size(); i != e; ++i) { - if (LHSMask[i] >= LHSInNElts*2) continue; // Ignore undef values; - isLHSLoExtract &= (LHSMask[i] == i); - isLHSHiExtract &= (LHSMask[i] == i+(LHSInNElts/2)); - } - if ((isLHSLoExtract || isLHSHiExtract) && - (isa(RHS) || (LHSWidth == LHSInNElts))) { - std::vector Elts; - for (unsigned i = 0, e = VWidth; i != e; ++i) { - if (Mask[i] >= 2*LHSWidth) - Elts.push_back(UndefValue::get(Type::getInt32Ty(SVI.getContext()))); - else - Elts.push_back(ConstantInt::get(Type::getInt32Ty(SVI.getContext()), - LHSMask[Mask[i]])); - } - if (isa(RHS)) - RHS = UndefValue::get(LHS->getType()); - return new ShuffleVectorInst(LHS, RHS, ConstantVector::get(Elts)); - } - - // If svi + lhs forms a full unpack, merge it. This allows llvm to emit - // efficient code for matrix transposes written with generic vector ops. - if ((LHSMask.size() == Mask.size()) && isPowerOf2_32(Mask.size()) && - (Mask.size() > 1)) { - bool isUnpackLo = true, isUnpackHi = true; - // check lhs mask for <0, u, 1, u .. >; - for (unsigned i = 0, e = LHSMask.size(); i != e; ++i) { - if (LHSMask[i] >= 2*e) continue; - isUnpackLo &= (LHSMask[i] == (i/2)); - isUnpackHi &= (LHSMask[i] == (i/2) + (e/2)); - } - for (unsigned i = 0, e = Mask.size(); i != e && (isUnpackLo || isUnpackHi); - i += 2) { - isUnpackLo &= (Mask[i] == i) && (Mask[i+1] == (i/2)+e); - isUnpackHi &= (Mask[i] == i) && (Mask[i+1] == (i/2)+e+(e/2)); - } - if (isUnpackLo || isUnpackHi) { - std::vector Elts; - for (unsigned i = 0, e = Mask.size(); i != e; ++i) { - if (Mask[i] >= 2*e) - Elts.push_back(UndefValue::get(Type::getInt32Ty(SVI.getContext()))); - else if (Mask[i] >= e) - Elts.push_back(ConstantInt::get(Type::getInt32Ty(SVI.getContext()), - Mask[i])); - else - Elts.push_back(ConstantInt::get(Type::getInt32Ty(SVI.getContext()), - LHSMask[Mask[i]])); - } - return new ShuffleVectorInst(LHS, RHS, ConstantVector::get(Elts)); - } - } - - // If rhs is shuffle + identity, propagate. - if (ShuffleVectorInst *RSVI = dyn_cast(RHS)) { - std::vector RHSMask = getShuffleMask(RSVI); - unsigned RHSInNElts = - cast(RSVI->getOperand(0)->getType())->getNumElements(); - - // If rhs is identity, propagate - bool isRHSLoExtract = true, isRHSHiExtract = true; - for (unsigned i = 0, e = RHSMask.size(); i != e; ++i) { - if (RHSMask[i] >= RHSInNElts*2) continue; // Ignore undef values; - isRHSLoExtract &= (RHSMask[i] == i); - isRHSHiExtract &= (RHSMask[i] == i+(RHSInNElts/2)); - } - if ((isRHSLoExtract || isRHSHiExtract) && (LHSWidth == RHSInNElts)) { - std::vector Elts; - for (unsigned i = 0, e = VWidth; i != e; ++i) { - if (Mask[i] >= 2*LHSWidth) - Elts.push_back(UndefValue::get(Type::getInt32Ty(SVI.getContext()))); - else if (Mask[i] < LHSWidth) - Elts.push_back(ConstantInt::get(Type::getInt32Ty(SVI.getContext()), - Mask[i])); - else - Elts.push_back(ConstantInt::get(Type::getInt32Ty(SVI.getContext()), - RHSMask[Mask[i]-LHSWidth]+LHSWidth)); - } - SVI.setOperand(1, RSVI->getOperand(0)); - SVI.setOperand(2, ConstantVector::get(Elts)); - return &SVI; - } + for (unsigned i = 0, e = Mask.size(); i != e; ++i) { + if (Mask[i] >= e*2) continue; // Ignore undef values. + // Is this an identity shuffle of the LHS value? + isLHSID &= (Mask[i] == i); + + // Is this an identity shuffle of the RHS value? + isRHSID &= (Mask[i]-e == i); } - // Be extremely conservative when merging shufflevector instructions. It is - // difficult for the code generator to recognize a merged shuffle, which - // usually leads to worse code from merging a shuffle. - if (!isa(RHS)) - return MadeChange ? &SVI : 0; - - // If the merged shuffle mask is one of the two input shuffle masks, which - // just removes one instruction. This should handle splat(splat) -> splat. - if (LHSMask.size() == Mask.size()) { - std::vector NewMask; - for (unsigned i = 0, e = Mask.size(); i != e; ++i) - if (Mask[i] >= e) - NewMask.push_back(2*e); - else - NewMask.push_back(LHSMask[Mask[i]]); - - // If the result mask is equal to the src shuffle or this shuffle mask, - // do the replacement. - if (NewMask == LHSMask || NewMask == Mask) { - std::vector Elts; - for (unsigned i = 0, e = NewMask.size(); i != e; ++i) { - if (NewMask[i] >= LHSInNElts*2) { - Elts.push_back(UndefValue::get(Type::getInt32Ty(SVI.getContext()))); - } else { - Elts.push_back(ConstantInt::get(Type::getInt32Ty(SVI.getContext()), - NewMask[i])); + // Eliminate identity shuffles. + if (isLHSID) return ReplaceInstUsesWith(SVI, LHS); + if (isRHSID) return ReplaceInstUsesWith(SVI, RHS); + + // If the LHS is a shufflevector itself, see if we can combine it with this + // one without producing an unusual shuffle. Here we are really conservative: + // we are absolutely afraid of producing a shuffle mask not in the input + // program, because the code gen may not be smart enough to turn a merged + // shuffle into two specific shuffles: it may produce worse code. As such, + // we only merge two shuffles if the result is one of the two input shuffle + // masks. In this case, merging the shuffles just removes one instruction, + // which we know is safe. This is good for things like turning: + // (splat(splat)) -> splat. + if (ShuffleVectorInst *LHSSVI = dyn_cast(LHS)) { + if (isa(RHS)) { + std::vector LHSMask = getShuffleMask(LHSSVI); + + if (LHSMask.size() == Mask.size()) { + std::vector NewMask; + for (unsigned i = 0, e = Mask.size(); i != e; ++i) + if (Mask[i] >= e) + NewMask.push_back(2*e); + else + NewMask.push_back(LHSMask[Mask[i]]); + + // If the result mask is equal to the src shuffle or this + // shuffle mask, do the replacement. + if (NewMask == LHSMask || NewMask == Mask) { + unsigned LHSInNElts = + cast(LHSSVI->getOperand(0)->getType())-> + getNumElements(); + std::vector Elts; + for (unsigned i = 0, e = NewMask.size(); i != e; ++i) { + if (NewMask[i] >= LHSInNElts*2) { + Elts.push_back(UndefValue::get( + Type::getInt32Ty(SVI.getContext()))); + } else { + Elts.push_back(ConstantInt::get( + Type::getInt32Ty(SVI.getContext()), + NewMask[i])); + } + } + return new ShuffleVectorInst(LHSSVI->getOperand(0), + LHSSVI->getOperand(1), + ConstantVector::get(Elts)); } } - return new ShuffleVectorInst(LHS, LSVI->getOperand(1), - ConstantVector::get(Elts)); } } + return MadeChange ? &SVI : 0; } + Modified: llvm/trunk/test/Transforms/InstCombine/vec_shuffle.ll URL: http://llvm.org/viewvc/llvm-project/llvm/trunk/test/Transforms/InstCombine/vec_shuffle.ll?rev=110905&r1=110904&r2=110905&view=diff ============================================================================== --- llvm/trunk/test/Transforms/InstCombine/vec_shuffle.ll (original) +++ llvm/trunk/test/Transforms/InstCombine/vec_shuffle.ll Thu Aug 12 02:01:22 2010 @@ -87,32 +87,3 @@ %tmp9 = shufflevector <4 x i8> %tmp7, <4 x i8> undef, <4 x i32> < i32 3, i32 1, i32 2, i32 0 > ; <<4 x i8>> [#uses=1] ret <4 x i8> %tmp9 } - -; Test fold of hi/lo vector halves -; Test fold of unpack operation -define void @test10(<16 x i8>* %out, <16 x i8> %r, <16 x i8> %g, <16 x i8> %b, <16 x i8> %a) nounwind ssp { -; CHECK: @test10 -; CHECK-NEXT: shufflevector -; CHECK-NEXT: shufflevector -; CHECK-NEXT: store -; CHECK-NEXT: getelementptr -; CHECK-NEXT: store -; CHECK-NEXT: ret - %tmp1 = shufflevector <16 x i8> %r, <16 x i8> undef, <8 x i32> ; <<8 x i8>> [#uses=1] - %tmp3 = shufflevector <8 x i8> %tmp1, <8 x i8> undef, <16 x i32> ; <<16 x i8>> [#uses=1] - %tmp4 = shufflevector <16 x i8> undef, <16 x i8> %tmp3, <16 x i32> ; <<16 x i8>> [#uses=1] - %tmp6 = shufflevector <16 x i8> %b, <16 x i8> undef, <8 x i32> ; <<8 x i8>> [#uses=1] - %tmp8 = shufflevector <8 x i8> %tmp6, <8 x i8> undef, <16 x i32> ; <<16 x i8>> [#uses=1] - %tmp9 = shufflevector <16 x i8> %tmp4, <16 x i8> %tmp8, <16 x i32> ; <<16 x i8>> [#uses=1] - %tmp11 = shufflevector <16 x i8> %r, <16 x i8> undef, <8 x i32> ; <<8 x i8>> [#uses=1] - %tmp13 = shufflevector <8 x i8> %tmp11, <8 x i8> undef, <16 x i32> ; <<16 x i8>> [#uses=1] - %tmp14 = shufflevector <16 x i8> undef, <16 x i8> %tmp13, <16 x i32> ; <<16 x i8>> [#uses=1] - %tmp16 = shufflevector <16 x i8> %b, <16 x i8> undef, <8 x i32> ; <<8 x i8>> [#uses=1] - %tmp18 = shufflevector <8 x i8> %tmp16, <8 x i8> undef, <16 x i32> ; <<16 x i8>> [#uses=1] - %tmp19 = shufflevector <16 x i8> %tmp14, <16 x i8> %tmp18, <16 x i32> ; <<16 x i8>> [#uses=1] - %arrayidx = getelementptr inbounds <16 x i8>* %out, i64 0 ; <<16 x i8>*> [#uses=1] - store <16 x i8> %tmp9, <16 x i8>* %arrayidx - %arrayidx24 = getelementptr inbounds <16 x i8>* %out, i64 1 ; <<16 x i8>*> [#uses=1] - store <16 x i8> %tmp19, <16 x i8>* %arrayidx24 - ret void -} From matt at console-pimps.org Thu Aug 12 04:31:31 2010 From: matt at console-pimps.org (Matt Fleming) Date: Thu, 12 Aug 2010 10:31:31 +0100 Subject: [llvm-commits] [PATCH 2/5] Record a symbol's size which is needed for ELF symbol tables. In-Reply-To: <84CC8582-7A97-47BF-BE2C-1C7409566414@apple.com> References: <8dfd2734fd5b1963627fa8238f5e45c18096c38c.1281542945.git.matt@console-pimps.org> <84CC8582-7A97-47BF-BE2C-1C7409566414@apple.com> Message-ID: <20100812093131.GA30744@console-pimps.org> On Wed, Aug 11, 2010 at 03:45:54PM -0700, Bill Wendling wrote: > On Aug 11, 2010, at 3:20 PM, Matt Fleming wrote: > > > --- > > include/llvm/MC/MCAssembler.h | 14 ++++++++++++++ > > lib/MC/MCAssembler.cpp | 3 ++- > > 2 files changed, 16 insertions(+), 1 deletions(-) > > > > diff --git a/include/llvm/MC/MCAssembler.h b/include/llvm/MC/MCAssembler.h > > index 50cb73b..24bd7d2 100644 > > --- a/include/llvm/MC/MCAssembler.h > > +++ b/include/llvm/MC/MCAssembler.h > > @@ -24,6 +24,7 @@ namespace llvm { > > class raw_ostream; > > class MCAsmLayout; > > class MCAssembler; > > +class MCBinaryExpr; > > class MCContext; > > class MCCodeEmitter; > > class MCExpr; > > @@ -453,6 +454,10 @@ public: > > // common symbol can never get a definition. > > uint64_t CommonSize; > > > > + /// SymbolSize - An expression describing how to calculate the size of > > + /// a symbol. If a symbol has no size this field will be NULL. > > + const MCExpr *SymbolSize; > > + > > /// CommonAlign - The alignment of the symbol, if it is 'common'. > > // > > // FIXME: Pack this in with other fields? > > @@ -510,6 +515,15 @@ public: > > return CommonSize; > > } > > > > + void setSize(const MCExpr *SS) { > > + SymbolSize = SS; > > + } > > + > > + const MCExpr *getSize() { > > You can constify this method "getSize() const {". Thanks, done! From baldrick at free.fr Thu Aug 12 06:31:39 2010 From: baldrick at free.fr (Duncan Sands) Date: Thu, 12 Aug 2010 11:31:39 -0000 Subject: [llvm-commits] [llvm] r110909 - in /llvm/trunk: include/llvm/ADT/Triple.h lib/Support/Triple.cpp unittests/ADT/TripleTest.cpp Message-ID: <20100812113139.EAD1E2A6C12C@llvm.org> Author: baldrick Date: Thu Aug 12 06:31:39 2010 New Revision: 110909 URL: http://llvm.org/viewvc/llvm-project?rev=110909&view=rev Log: Add a 'normalize' method to the Triple class, which takes a mucked up target triple and straightens it out. This does less than gcc's script config.sub, for example it turns i386-mingw32 into i386--mingw32 not i386-pc-mingw32, but it does a decent job of turning funky triples into something that the rest of the Triple class can understand. The plan is to use this to canonicalize triple's when they are first provided by users, and have the rest of LLVM only deal with canonical triples. Once this is done the special case workarounds in the Triple constructor can be removed, making the class more regular and easier to use. The comments and unittests for the Triple class are already adjusted in this patch appropriately for this brave new world of increased uniformity. Modified: llvm/trunk/include/llvm/ADT/Triple.h llvm/trunk/lib/Support/Triple.cpp llvm/trunk/unittests/ADT/TripleTest.cpp Modified: llvm/trunk/include/llvm/ADT/Triple.h URL: http://llvm.org/viewvc/llvm-project/llvm/trunk/include/llvm/ADT/Triple.h?rev=110909&r1=110908&r2=110909&view=diff ============================================================================== --- llvm/trunk/include/llvm/ADT/Triple.h (original) +++ llvm/trunk/include/llvm/ADT/Triple.h Thu Aug 12 06:31:39 2010 @@ -24,7 +24,7 @@ /// Triple - Helper class for working with target triples. /// -/// Target triples are strings in the format of: +/// Target triples are strings in the canonical form: /// ARCHITECTURE-VENDOR-OPERATING_SYSTEM /// or /// ARCHITECTURE-VENDOR-OPERATING_SYSTEM-ENVIRONMENT @@ -35,20 +35,11 @@ /// from the components of the target triple to well known IDs. /// /// At its core the Triple class is designed to be a wrapper for a triple -/// string; it does not normally change or normalize the triple string, instead -/// it provides additional APIs to parse normalized parts out of the triple. +/// string; the constructor does not change or normalize the triple string. +/// Clients that need to handle the non-canonical triples that users often +/// specify should use the normalize method. /// -/// One curiosity this implies is that for some odd triples the results of, -/// e.g., getOSName() can be very different from the result of getOS(). For -/// example, for 'i386-mingw32', getOS() will return MinGW32, but since -/// getOSName() is purely based on the string structure that will return the -/// empty string. -/// -/// Clients should generally avoid using getOSName() and related APIs unless -/// they are familiar with the triple format (this is particularly true when -/// rewriting a triple). -/// -/// See autoconf/config.guess for a glimpse into what they look like in +/// See autoconf/config.guess for a glimpse into what triples look like in /// practice. class Triple { public: @@ -117,6 +108,9 @@ mutable OSType OS; bool isInitialized() const { return Arch != InvalidArch; } + static ArchType ParseArch(StringRef ArchName); + static VendorType ParseVendor(StringRef VendorName); + static OSType ParseOS(StringRef OSName); void Parse() const; public: @@ -134,6 +128,16 @@ } /// @} + /// @name Normalization + /// @{ + + /// normalize - Turn an arbitrary machine specification into the canonical + /// triple form (or something sensible that the Triple class understands if + /// nothing better can reasonably be done). In particular, it handles the + /// common case in which otherwise valid components are in the wrong order. + static std::string normalize(StringRef Str); + + /// @} /// @name Typed Component Access /// @{ Modified: llvm/trunk/lib/Support/Triple.cpp URL: http://llvm.org/viewvc/llvm-project/llvm/trunk/lib/Support/Triple.cpp?rev=110909&r1=110908&r2=110909&view=diff ============================================================================== --- llvm/trunk/lib/Support/Triple.cpp (original) +++ llvm/trunk/lib/Support/Triple.cpp Thu Aug 12 06:31:39 2010 @@ -221,121 +221,254 @@ // -void Triple::Parse() const { - assert(!isInitialized() && "Invalid parse call."); - - StringRef ArchName = getArchName(); - StringRef VendorName = getVendorName(); - StringRef OSName = getOSName(); - +Triple::ArchType Triple::ParseArch(StringRef ArchName) { if (ArchName.size() == 4 && ArchName[0] == 'i' && ArchName[2] == '8' && ArchName[3] == '6' && ArchName[1] - '3' < 6) // i[3-9]86 - Arch = x86; + return x86; else if (ArchName == "amd64" || ArchName == "x86_64") - Arch = x86_64; + return x86_64; else if (ArchName == "bfin") - Arch = bfin; + return bfin; else if (ArchName == "pic16") - Arch = pic16; + return pic16; else if (ArchName == "powerpc") - Arch = ppc; + return ppc; else if ((ArchName == "powerpc64") || (ArchName == "ppu")) - Arch = ppc64; + return ppc64; else if (ArchName == "mblaze") - Arch = mblaze; + return mblaze; else if (ArchName == "arm" || ArchName.startswith("armv") || ArchName == "xscale") - Arch = arm; + return arm; else if (ArchName == "thumb" || ArchName.startswith("thumbv")) - Arch = thumb; + return thumb; else if (ArchName.startswith("alpha")) - Arch = alpha; + return alpha; else if (ArchName == "spu" || ArchName == "cellspu") - Arch = cellspu; + return cellspu; else if (ArchName == "msp430") - Arch = msp430; + return msp430; else if (ArchName == "mips" || ArchName == "mipsallegrex") - Arch = mips; + return mips; else if (ArchName == "mipsel" || ArchName == "mipsallegrexel" || ArchName == "psp") - Arch = mipsel; + return mipsel; else if (ArchName == "sparc") - Arch = sparc; + return sparc; else if (ArchName == "sparcv9") - Arch = sparcv9; + return sparcv9; else if (ArchName == "s390x") - Arch = systemz; + return systemz; else if (ArchName == "tce") - Arch = tce; + return tce; else if (ArchName == "xcore") - Arch = xcore; + return xcore; else - Arch = UnknownArch; - - - // Handle some exceptional cases where the OS / environment components are - // stuck into the vendor field. - if (StringRef(getTriple()).count('-') == 1) { - StringRef VendorName = getVendorName(); - - if (VendorName.startswith("mingw32")) { // 'i386-mingw32', etc. - Vendor = PC; - OS = MinGW32; - return; - } - - // arm-elf is another example, but we don't currently parse anything about - // the environment. - } + return UnknownArch; +} +Triple::VendorType Triple::ParseVendor(StringRef VendorName) { if (VendorName == "apple") - Vendor = Apple; + return Apple; else if (VendorName == "pc") - Vendor = PC; + return PC; else - Vendor = UnknownVendor; + return UnknownVendor; +} +Triple::OSType Triple::ParseOS(StringRef OSName) { if (OSName.startswith("auroraux")) - OS = AuroraUX; + return AuroraUX; else if (OSName.startswith("cygwin")) - OS = Cygwin; + return Cygwin; else if (OSName.startswith("darwin")) - OS = Darwin; + return Darwin; else if (OSName.startswith("dragonfly")) - OS = DragonFly; + return DragonFly; else if (OSName.startswith("freebsd")) - OS = FreeBSD; + return FreeBSD; else if (OSName.startswith("linux")) - OS = Linux; + return Linux; else if (OSName.startswith("lv2")) - OS = Lv2; + return Lv2; else if (OSName.startswith("mingw32")) - OS = MinGW32; + return MinGW32; else if (OSName.startswith("mingw64")) - OS = MinGW64; + return MinGW64; else if (OSName.startswith("netbsd")) - OS = NetBSD; + return NetBSD; else if (OSName.startswith("openbsd")) - OS = OpenBSD; + return OpenBSD; else if (OSName.startswith("psp")) - OS = Psp; + return Psp; else if (OSName.startswith("solaris")) - OS = Solaris; + return Solaris; else if (OSName.startswith("win32")) - OS = Win32; + return Win32; else if (OSName.startswith("haiku")) - OS = Haiku; + return Haiku; else if (OSName.startswith("minix")) - OS = Minix; + return Minix; else - OS = UnknownOS; + return UnknownOS; +} + +void Triple::Parse() const { + assert(!isInitialized() && "Invalid parse call."); + + Arch = ParseArch(getArchName()); + Vendor = ParseVendor(getVendorName()); + OS = ParseOS(getOSName()); + + // Handle some exceptional cases where the OS / environment components are + // stuck into the vendor field. + // TODO: Remove this logic and have places that need it use 'normalize'. + if (StringRef(getTriple()).count('-') == 1) { + StringRef VendorName = getVendorName(); + + if (VendorName.startswith("mingw32")) { // 'i386-mingw32', etc. + Vendor = PC; + OS = MinGW32; + return; + } + + // arm-elf is another example, but we don't currently parse anything about + // the environment. + } assert(isInitialized() && "Failed to initialize!"); } +std::string Triple::normalize(StringRef Str) { + // Parse into components. + SmallVector Components; + for (size_t First = 0, Last = 0; Last != StringRef::npos; First = Last + 1) { + Last = Str.find('-', First); + Components.push_back(Str.slice(First, Last)); + } + + // If the first component corresponds to a known architecture, preferentially + // use it for the architecture. If the second component corresponds to a + // known vendor, preferentially use it for the vendor, etc. This avoids silly + // component movement when a component parses as (eg) both a valid arch and a + // valid os. + ArchType Arch = UnknownArch; + if (Components.size() > 0) + Arch = ParseArch(Components[0]); + VendorType Vendor = UnknownVendor; + if (Components.size() > 1) + Vendor = ParseVendor(Components[1]); + OSType OS = UnknownOS; + if (Components.size() > 2) + OS = ParseOS(Components[2]); + + // Note which components are already in their final position. These will not + // be moved. + bool Found[3]; + Found[0] = Arch != UnknownArch; + Found[1] = Vendor != UnknownVendor; + Found[2] = OS != UnknownOS; + + // If they are not there already, permute the components into their canonical + // positions by seeing if they parse as a valid architecture, and if so moving + // the component to the architecture position etc. + for (unsigned Pos = 0; Pos != 3; ++Pos) { + if (Found[Pos]) + continue; // Already in the canonical position. + + for (unsigned Idx = 0; Idx != Components.size(); ++Idx) { + // Do not reparse any components that already matched. + if (Idx < 3 && Found[Idx]) + continue; + + // Does this component parse as valid for the target position? + bool Valid = false; + StringRef Comp = Components[Idx]; + switch (Pos) { + default: + assert(false && "unexpected component type!"); + case 0: + Arch = ParseArch(Comp); + Valid = Arch != UnknownArch; + break; + case 1: + Vendor = ParseVendor(Comp); + Valid = Vendor != UnknownVendor; + break; + case 2: + OS = ParseOS(Comp); + Valid = OS != UnknownOS; + break; + } + if (!Valid) + continue; // Nope, try the next component. + + // Move the component to the target position, pushing any non-fixed + // components that are in the way to the right. This tends to give + // good results in the common cases of a forgotten vendor component + // or a wrongly positioned environment. + if (Pos < Idx) { + // Insert left, pushing the existing components to the right. For + // example, a-b-i386 -> i386-a-b when moving i386 to the front. + StringRef CurrentComponent(""); // The empty component. + // Replace the component we are moving with an empty component. + std::swap(CurrentComponent, Components[Idx]); + // Insert the component being moved at Pos, displacing any existing + // components to the right. + for (unsigned i = Pos; !CurrentComponent.empty(); ++i) { + // Skip over any fixed components. + while (i < 3 && Found[i]) ++i; + // Place the component at the new position, getting the component + // that was at this position - it will be moved right. + std::swap(CurrentComponent, Components[i]); + } + } else if (Pos > Idx) { + // Push right by inserting empty components until the component at Idx + // reaches the target position Pos. For example, pc-a -> -pc-a when + // moving pc to the second position. + do { + // Insert one empty component at Idx. + StringRef CurrentComponent(""); // The empty component. + for (unsigned i = Idx; i < Components.size(); ++i) { + // Skip over any fixed components. + while (i < 3 && Found[i]) ++i; + // Place the component at the new position, getting the component + // that was at this position - it will be moved right. + std::swap(CurrentComponent, Components[i]); + // If it was placed on top of an empty component then we are done. + if (CurrentComponent.empty()) + break; + } + // The last component was pushed off the end - append it. + if (!CurrentComponent.empty()) + Components.push_back(CurrentComponent); + + // Advance Idx to the component's new position. + while (++Idx < 3 && Found[Idx]) {} + } while (Idx < Pos); // Add more until the final position is reached. + } + assert(Pos < Components.size() && Components[Pos] == Comp && + "Component moved wrong!"); + Found[Pos] = true; + break; + } + } + + // Special case logic goes here. At this point Arch, Vendor and OS have the + // correct values for the computed components. + + // Stick the corrected components back together to form the normalized string. + std::string Normalized; + for (unsigned i = 0, e = Components.size(); i != e; ++i) { + if (i) Normalized += '-'; + Normalized += Components[i]; + } + return Normalized; +} + StringRef Triple::getArchName() const { return StringRef(Data).split('-').first; // Isolate first component } Modified: llvm/trunk/unittests/ADT/TripleTest.cpp URL: http://llvm.org/viewvc/llvm-project/llvm/trunk/unittests/ADT/TripleTest.cpp?rev=110909&r1=110908&r2=110909&view=diff ============================================================================== --- llvm/trunk/unittests/ADT/TripleTest.cpp (original) +++ llvm/trunk/unittests/ADT/TripleTest.cpp Thu Aug 12 06:31:39 2010 @@ -92,18 +92,117 @@ T = Triple("huh"); EXPECT_EQ(Triple::UnknownArch, T.getArch()); +} - // Two exceptional cases. +static std::string Join(StringRef A, StringRef B, StringRef C) { + std::string Str = A; Str += '-'; Str += B; Str += '-'; Str += C; + return Str; +} - T = Triple("i386-mingw32"); - EXPECT_EQ(Triple::x86, T.getArch()); - EXPECT_EQ(Triple::PC, T.getVendor()); - EXPECT_EQ(Triple::MinGW32, T.getOS()); +static std::string Join(StringRef A, StringRef B, StringRef C, StringRef D) { + std::string Str = A; Str += '-'; Str += B; Str += '-'; Str += C; Str += '-'; + Str += D; return Str; +} - T = Triple("arm-elf"); - EXPECT_EQ(Triple::arm, T.getArch()); - EXPECT_EQ(Triple::UnknownVendor, T.getVendor()); - EXPECT_EQ(Triple::UnknownOS, T.getOS()); +TEST(TripleTest, Normalization) { + EXPECT_EQ("", Triple::normalize("")); + EXPECT_EQ("-", Triple::normalize("-")); + EXPECT_EQ("--", Triple::normalize("--")); + EXPECT_EQ("---", Triple::normalize("---")); + EXPECT_EQ("----", Triple::normalize("----")); + + EXPECT_EQ("a", Triple::normalize("a")); + EXPECT_EQ("a-b", Triple::normalize("a-b")); + EXPECT_EQ("a-b-c", Triple::normalize("a-b-c")); + EXPECT_EQ("a-b-c-d", Triple::normalize("a-b-c-d")); + + EXPECT_EQ("i386-b-c", Triple::normalize("i386-b-c")); + EXPECT_EQ("i386-a-c", Triple::normalize("a-i386-c")); + EXPECT_EQ("i386-a-b", Triple::normalize("a-b-i386")); + + EXPECT_EQ("a-pc-c", Triple::normalize("a-pc-c")); + EXPECT_EQ("-pc-b-c", Triple::normalize("pc-b-c")); + EXPECT_EQ("a-pc-b", Triple::normalize("a-b-pc")); + + EXPECT_EQ("a-b-linux", Triple::normalize("a-b-linux")); + EXPECT_EQ("--linux-b-c", Triple::normalize("linux-b-c")); + EXPECT_EQ("a--linux-c", Triple::normalize("a-linux-c")); + + EXPECT_EQ("i386-pc-a", Triple::normalize("a-pc-i386")); + EXPECT_EQ("i386-pc-", Triple::normalize("-pc-i386")); + EXPECT_EQ("-pc-linux-c", Triple::normalize("linux-pc-c")); + EXPECT_EQ("-pc-linux", Triple::normalize("linux-pc-")); + + EXPECT_EQ("i386", Triple::normalize("i386")); + EXPECT_EQ("-pc", Triple::normalize("pc")); + EXPECT_EQ("--linux", Triple::normalize("linux")); + + // Check that normalizing a permutated set of valid components returns a + // triple with the unpermuted components. + StringRef C[4]; + C[3] = "environment"; + for (int Arch = 1+Triple::UnknownArch; Arch < Triple::InvalidArch; ++Arch) { + C[0] = Triple::getArchTypeName(Triple::ArchType(Arch)); + for (int Vendor = 1+Triple::UnknownVendor; Vendor <= Triple::PC; + ++Vendor) { + C[1] = Triple::getVendorTypeName(Triple::VendorType(Vendor)); + for (int OS = 1+Triple::UnknownOS; OS <= Triple::Minix; ++OS) { + C[2] = Triple::getOSTypeName(Triple::OSType(OS)); + + std::string E = Join(C[0], C[1], C[2]); + std::string F = Join(C[0], C[1], C[2], C[3]); + EXPECT_EQ(E, Triple::normalize(Join(C[0], C[1], C[2]))); + EXPECT_EQ(F, Triple::normalize(Join(C[0], C[1], C[2], C[3]))); + + // If a value has multiple interpretations, then the permutation + // test will inevitably fail. Currently this is only the case for + // "psp" which parses as both an architecture and an O/S. + if (OS == Triple::Psp) + continue; + + EXPECT_EQ(E, Triple::normalize(Join(C[0], C[2], C[1]))); + EXPECT_EQ(E, Triple::normalize(Join(C[1], C[2], C[0]))); + EXPECT_EQ(E, Triple::normalize(Join(C[1], C[0], C[2]))); + EXPECT_EQ(E, Triple::normalize(Join(C[2], C[0], C[1]))); + EXPECT_EQ(E, Triple::normalize(Join(C[2], C[1], C[0]))); + + EXPECT_EQ(F, Triple::normalize(Join(C[0], C[1], C[3], C[2]))); + EXPECT_EQ(F, Triple::normalize(Join(C[0], C[2], C[3], C[1]))); + EXPECT_EQ(F, Triple::normalize(Join(C[0], C[2], C[1], C[3]))); + EXPECT_EQ(F, Triple::normalize(Join(C[0], C[3], C[1], C[2]))); + EXPECT_EQ(F, Triple::normalize(Join(C[0], C[3], C[2], C[1]))); + EXPECT_EQ(F, Triple::normalize(Join(C[1], C[2], C[3], C[0]))); + EXPECT_EQ(F, Triple::normalize(Join(C[1], C[2], C[0], C[3]))); + EXPECT_EQ(F, Triple::normalize(Join(C[1], C[3], C[0], C[2]))); + EXPECT_EQ(F, Triple::normalize(Join(C[1], C[3], C[2], C[0]))); + EXPECT_EQ(F, Triple::normalize(Join(C[1], C[0], C[2], C[3]))); + EXPECT_EQ(F, Triple::normalize(Join(C[1], C[0], C[3], C[2]))); + EXPECT_EQ(F, Triple::normalize(Join(C[2], C[3], C[0], C[1]))); + EXPECT_EQ(F, Triple::normalize(Join(C[2], C[3], C[1], C[0]))); + EXPECT_EQ(F, Triple::normalize(Join(C[2], C[0], C[1], C[3]))); + EXPECT_EQ(F, Triple::normalize(Join(C[2], C[0], C[3], C[1]))); + EXPECT_EQ(F, Triple::normalize(Join(C[2], C[1], C[3], C[0]))); + EXPECT_EQ(F, Triple::normalize(Join(C[2], C[1], C[0], C[3]))); + EXPECT_EQ(F, Triple::normalize(Join(C[3], C[0], C[1], C[2]))); + EXPECT_EQ(F, Triple::normalize(Join(C[3], C[0], C[2], C[1]))); + EXPECT_EQ(F, Triple::normalize(Join(C[3], C[1], C[2], C[0]))); + EXPECT_EQ(F, Triple::normalize(Join(C[3], C[1], C[0], C[2]))); + EXPECT_EQ(F, Triple::normalize(Join(C[3], C[2], C[0], C[1]))); + EXPECT_EQ(F, Triple::normalize(Join(C[3], C[2], C[1], C[0]))); + } + } + } + + EXPECT_EQ("a-b-psp", Triple::normalize("a-b-psp")); + EXPECT_EQ("psp-b-c", Triple::normalize("psp-b-c")); + + // Various real-world funky triples. The value returned by GCC's config.sub + // is given in the comment. + EXPECT_EQ("i386--mingw32", Triple::normalize("i386-mingw32")); // i386-pc-mingw32 + EXPECT_EQ("x86_64--linux-gnu", Triple::normalize("x86_64-linux-gnu")); // x86_64-pc-linux-gnu + EXPECT_EQ("i486--linux-gnu", Triple::normalize("i486-linux-gnu")); // i486-pc-linux-gnu + EXPECT_EQ("i386-redhat-linux", Triple::normalize("i386-redhat-linux")); // i386-redhat-linux-gnu + EXPECT_EQ("i686--linux", Triple::normalize("i686-linux")); // i686-pc-linux-gnu } TEST(TripleTest, MutateName) { From baldrick at free.fr Thu Aug 12 06:36:08 2010 From: baldrick at free.fr (Duncan Sands) Date: Thu, 12 Aug 2010 11:36:08 -0000 Subject: [llvm-commits] [dragonegg] r110910 - in /dragonegg/trunk: Makefile utils/target.cpp Message-ID: <20100812113608.B212E2A6C12C@llvm.org> Author: baldrick Date: Thu Aug 12 06:36:08 2010 New Revision: 110910 URL: http://llvm.org/viewvc/llvm-project?rev=110910&view=rev Log: Normalize the triple provided when configuring gcc before using it. This fixes the dragonegg build when gcc is configured with (for example) x86_64-linux-gnu rather than x86_64-pc-linux-gnu. The problem was that the triple class would not understand that the O/S was linux in the first case. Modified: dragonegg/trunk/Makefile dragonegg/trunk/utils/target.cpp Modified: dragonegg/trunk/Makefile URL: http://llvm.org/viewvc/llvm-project/dragonegg/trunk/Makefile?rev=110910&r1=110909&r2=110910&view=diff ============================================================================== --- dragonegg/trunk/Makefile (original) +++ dragonegg/trunk/Makefile Thu Aug 12 06:36:08 2010 @@ -51,13 +51,13 @@ -MD -MP \ -DIN_GCC -DREVISION=\"$(REVISION)\" \ -DGCC_MAJOR=$(GCC_MAJOR) -DGCC_MINOR=$(GCC_MINOR) \ - -DTARGET_NAME=\"$(TARGET_TRIPLE)\" \ -I$(SRC_DIR) -I$(GCC_PLUGIN_DIR)/include LD_OPTIONS+=$(LDFLAGS) $(shell $(LLVM_CONFIG) --ldflags) # NOTE: The following flags can only be used after TARGET_UTIL has been built. -TARGET_HEADERS+=-I$(SRC_DIR)/$(shell $(TARGET_UTIL) -p) \ +TARGET_HEADERS+=-DTARGET_NAME=\"$(shell $(TARGET_UTIL) -t)\" \ + -I$(SRC_DIR)/$(shell $(TARGET_UTIL) -p) \ -I$(SRC_DIR)/$(shell $(TARGET_UTIL) -o) @@ -65,7 +65,8 @@ $(TARGET_UTIL_OBJECTS): %.o : $(SRC_DIR)/utils/%.cpp @echo Compiling utils/$*.cpp - $(QUIET)$(CXX) -c $(CPP_OPTIONS) $(CXXFLAGS) $< + $(QUIET)$(CXX) -c -DTARGET_TRIPLE=\"$(TARGET_TRIPLE)\" \ + $(CPP_OPTIONS) $(CXXFLAGS) $< $(TARGET_UTIL): $(TARGET_UTIL_OBJECTS) @echo Linking $@ @@ -83,7 +84,7 @@ $(TARGET_OBJECT): $(TARGET_UTIL) @echo Compiling $(shell $(TARGET_UTIL) -p)/llvm-target.cpp $(QUIET)$(CXX) -o $@ -c $(CPP_OPTIONS) $(TARGET_HEADERS) $(CXXFLAGS) \ - $(TARGET_SOURCE) + $(TARGET_SOURCE) $(PLUGIN): $(PLUGIN_OBJECTS) $(TARGET_OBJECT) $(TARGET_UTIL) @echo Linking $@ Modified: dragonegg/trunk/utils/target.cpp URL: http://llvm.org/viewvc/llvm-project/dragonegg/trunk/utils/target.cpp?rev=110910&r1=110909&r2=110910&view=diff ============================================================================== --- dragonegg/trunk/utils/target.cpp (original) +++ dragonegg/trunk/utils/target.cpp Thu Aug 12 06:36:08 2010 @@ -36,7 +36,7 @@ }; int main(int argc, char **argv) { - Triple T(TARGET_NAME); + Triple T(Triple::normalize(TARGET_TRIPLE)); for (int i = 1; i < argc; ++i) { bool Found = false; From baldrick at free.fr Thu Aug 12 06:38:42 2010 From: baldrick at free.fr (Duncan Sands) Date: Thu, 12 Aug 2010 11:38:42 -0000 Subject: [llvm-commits] [dragonegg] r110911 - /dragonegg/trunk/www/index.html Message-ID: <20100812113842.7A1E72A6C12C@llvm.org> Author: baldrick Date: Thu Aug 12 06:38:42 2010 New Revision: 110911 URL: http://llvm.org/viewvc/llvm-project?rev=110911&view=rev Log: Update the list of dragonegg-2.7 problems. Modified: dragonegg/trunk/www/index.html Modified: dragonegg/trunk/www/index.html URL: http://llvm.org/viewvc/llvm-project/dragonegg/trunk/www/index.html?rev=110911&r1=110910&r2=110911&view=diff ============================================================================== --- dragonegg/trunk/www/index.html (original) +++ dragonegg/trunk/www/index.html Thu Aug 12 06:38:42 2010 @@ -74,9 +74,11 @@ Use the four component style x86_64-unknown-linux-gnu or i386-unknown-linux-gnu instead.
  • Fortran common variables may not be output when they should be, - causing link failures. This has been fixed in the - development version of DragonEgg. + causing link failures.
  • +
  • Programs using OpenMP directives crash the plugin.
+

These problems have been fixed in the + development version of DragonEgg.

From gohman at apple.com Thu Aug 12 09:46:54 2010 From: gohman at apple.com (Dan Gohman) Date: Thu, 12 Aug 2010 14:46:54 -0000 Subject: [llvm-commits] [llvm] r110914 - /llvm/trunk/lib/Analysis/ScalarEvolution.cpp Message-ID: <20100812144654.790DB2A6C12C@llvm.org> Author: djg Date: Thu Aug 12 09:46:54 2010 New Revision: 110914 URL: http://llvm.org/viewvc/llvm-project?rev=110914&view=rev Log: Optimize ScalarEvolution::getAddExpr's duplicate operand detection by having it finish processing the whole operand list before starting the whole getAddExpr process over again, instead of immediately after the first duplicate is found. Modified: llvm/trunk/lib/Analysis/ScalarEvolution.cpp Modified: llvm/trunk/lib/Analysis/ScalarEvolution.cpp URL: http://llvm.org/viewvc/llvm-project/llvm/trunk/lib/Analysis/ScalarEvolution.cpp?rev=110914&r1=110913&r2=110914&view=diff ============================================================================== --- llvm/trunk/lib/Analysis/ScalarEvolution.cpp (original) +++ llvm/trunk/lib/Analysis/ScalarEvolution.cpp Thu Aug 12 09:46:54 2010 @@ -1373,6 +1373,7 @@ // so, merge them together into an multiply expression. Since we sorted the // list, these values are required to be adjacent. const Type *Ty = Ops[0]->getType(); + bool FoundMatch = false; for (unsigned i = 0, e = Ops.size()-1; i != e; ++i) if (Ops[i] == Ops[i+1]) { // X + Y + Y --> X + Y*2 // Found a match, merge the two values into a multiply, and add any @@ -1381,10 +1382,13 @@ const SCEV *Mul = getMulExpr(Ops[i], Two); if (Ops.size() == 2) return Mul; - Ops.erase(Ops.begin()+i, Ops.begin()+i+2); - Ops.push_back(Mul); - return getAddExpr(Ops, HasNUW, HasNSW); + Ops[i] = Mul; + Ops.erase(Ops.begin()+i+1); + --i; --e; + FoundMatch = true; } + if (FoundMatch) + return getAddExpr(Ops, HasNUW, HasNSW); // Check for truncates. If all the operands are truncated from the same // type, see if factoring out the truncate would permit the result to be From gohman at apple.com Thu Aug 12 09:52:55 2010 From: gohman at apple.com (Dan Gohman) Date: Thu, 12 Aug 2010 14:52:55 -0000 Subject: [llvm-commits] [llvm] r110915 - /llvm/trunk/lib/Analysis/ScalarEvolution.cpp Message-ID: <20100812145255.47E782A6C12C@llvm.org> Author: djg Date: Thu Aug 12 09:52:55 2010 New Revision: 110915 URL: http://llvm.org/viewvc/llvm-project?rev=110915&view=rev Log: Hoist some loop-invariant code out of a hot loop. Modified: llvm/trunk/lib/Analysis/ScalarEvolution.cpp Modified: llvm/trunk/lib/Analysis/ScalarEvolution.cpp URL: http://llvm.org/viewvc/llvm-project/llvm/trunk/lib/Analysis/ScalarEvolution.cpp?rev=110915&r1=110914&r2=110915&view=diff ============================================================================== --- llvm/trunk/lib/Analysis/ScalarEvolution.cpp (original) +++ llvm/trunk/lib/Analysis/ScalarEvolution.cpp Thu Aug 12 09:52:55 2010 @@ -1512,8 +1512,10 @@ const SCEVMulExpr *Mul = cast(Ops[Idx]); for (unsigned MulOp = 0, e = Mul->getNumOperands(); MulOp != e; ++MulOp) { const SCEV *MulOpSCEV = Mul->getOperand(MulOp); + if (isa(MulOpSCEV)) + continue; for (unsigned AddOp = 0, e = Ops.size(); AddOp != e; ++AddOp) - if (MulOpSCEV == Ops[AddOp] && !isa(Ops[AddOp])) { + if (MulOpSCEV == Ops[AddOp]) { // Fold W + X + (X * Y * Z) --> W + (X * ((Y*Z)+1)) const SCEV *InnerMul = Mul->getOperand(MulOp == 0); if (Mul->getNumOperands() != 2) { @@ -1525,7 +1527,7 @@ } const SCEV *One = getConstant(Ty, 1); const SCEV *AddOne = getAddExpr(InnerMul, One); - const SCEV *OuterMul = getMulExpr(AddOne, Ops[AddOp]); + const SCEV *OuterMul = getMulExpr(AddOne, MulOpSCEV); if (Ops.size() == 2) return OuterMul; if (AddOp < Idx) { Ops.erase(Ops.begin()+AddOp); From gohman at apple.com Thu Aug 12 10:00:23 2010 From: gohman at apple.com (Dan Gohman) Date: Thu, 12 Aug 2010 15:00:23 -0000 Subject: [llvm-commits] [llvm] r110916 - /llvm/trunk/lib/Analysis/ScalarEvolution.cpp Message-ID: <20100812150023.D7E8E2A6C12C@llvm.org> Author: djg Date: Thu Aug 12 10:00:23 2010 New Revision: 110916 URL: http://llvm.org/viewvc/llvm-project?rev=110916&view=rev Log: Optimize ScalarEvolution::getAddExpr's operand factoring code by having it finish processing all of the muliply operands before starting the whole getAddExpr process over again, instead of immediately after the first simplification. Modified: llvm/trunk/lib/Analysis/ScalarEvolution.cpp Modified: llvm/trunk/lib/Analysis/ScalarEvolution.cpp URL: http://llvm.org/viewvc/llvm-project/llvm/trunk/lib/Analysis/ScalarEvolution.cpp?rev=110916&r1=110915&r2=110916&view=diff ============================================================================== --- llvm/trunk/lib/Analysis/ScalarEvolution.cpp (original) +++ llvm/trunk/lib/Analysis/ScalarEvolution.cpp Thu Aug 12 10:00:23 2010 @@ -1541,6 +1541,7 @@ } // Check this multiply against other multiplies being added together. + bool AnyFold = false; for (unsigned OtherMulIdx = Idx+1; OtherMulIdx < Ops.size() && isa(Ops[OtherMulIdx]); ++OtherMulIdx) { @@ -1568,12 +1569,14 @@ const SCEV *InnerMulSum = getAddExpr(InnerMul1,InnerMul2); const SCEV *OuterMul = getMulExpr(MulOpSCEV, InnerMulSum); if (Ops.size() == 2) return OuterMul; - Ops.erase(Ops.begin()+Idx); - Ops.erase(Ops.begin()+OtherMulIdx-1); - Ops.push_back(OuterMul); - return getAddExpr(Ops); + Ops[Idx] = OuterMul; + Ops.erase(Ops.begin()+OtherMulIdx); + OtherMulIdx = Idx; + AnyFold = true; } } + if (AnyFold) + return getAddExpr(Ops); } } From daniel at zuster.org Thu Aug 12 11:03:30 2010 From: daniel at zuster.org (Daniel Dunbar) Date: Thu, 12 Aug 2010 16:03:30 -0000 Subject: [llvm-commits] [zorg] r110918 - in /zorg/trunk/lnt/lnt/viewer/js: View2D.js View2DTest.html Message-ID: <20100812160330.D636C2A6C12C@llvm.org> Author: ddunbar Date: Thu Aug 12 11:03:30 2010 New Revision: 110918 URL: http://llvm.org/viewvc/llvm-project?rev=110918&view=rev Log: lnt/View2D: Rewrite in pure JS. Modified: zorg/trunk/lnt/lnt/viewer/js/View2D.js zorg/trunk/lnt/lnt/viewer/js/View2DTest.html Modified: zorg/trunk/lnt/lnt/viewer/js/View2D.js URL: http://llvm.org/viewvc/llvm-project/zorg/trunk/lnt/lnt/viewer/js/View2D.js?rev=110918&r1=110917&r2=110918&view=diff ============================================================================== --- zorg/trunk/lnt/lnt/viewer/js/View2D.js (original) +++ zorg/trunk/lnt/lnt/viewer/js/View2D.js Thu Aug 12 11:03:30 2010 @@ -8,15 +8,12 @@ //===----------------------------------------------------------------------===// // // This file implements a generic 2D view widget and a 2D graph widget on top of -// it, using the HTML5 Canvas. It currently supports Firefox and Safari -// (Chromium should work, but is untested). +// it, using the HTML5 Canvas. It currently supports Chrome, Firefox, and +// Safari. // // See the Graph2D implementation for details of how to extend the View2D // object. // -// FIXME: Currently, this uses MooTools extensions, but I would like to rewrite -// it in pure JS for more portability (e.g., use in Buildbot). -// //===----------------------------------------------------------------------===// function lerp(a, b, t) { @@ -132,772 +129,806 @@ return "rgb(" + norm[0] + "," + norm[1] + "," + norm[2] + "," + col[3] + ")"; } -var ViewData = new Class ({ - initialize: function(location, scale) { - if (!location) - location = [0, 0]; - if (!scale) - scale = [1, 1]; +/* ViewData Class */ - this.location = location; - this.scale = scale; - }, +function ViewData(location, scale) { + if (!location) + location = [0, 0]; + if (!scale) + scale = [1, 1]; - copy: function() { - return new ViewData(this.location, this.scale); - }, -}); + this.location = location; + this.scale = scale; +} -var ViewAction = new Class ({ - initialize: function(mode, v2d, start) { - this.mode = mode; - this.start = start; - this.vd = v2d.viewData.copy(); - }, +ViewData.prototype.copy = function() { + return new ViewData(this.location, this.scale); +} - update: function(v2d, co) { - if (this.mode == 'p') { - var delta = vec2_sub(v2d.convertClientToNDC(co, this.vd), - v2d.convertClientToNDC(this.start, this.vd)) - v2d.viewData.location = vec2_add(this.vd.location, delta); - } else { - var delta = vec2_sub(v2d.convertClientToNDC(co, this.vd), - v2d.convertClientToNDC(this.start, this.vd)) - v2d.viewData.scale = vec2_Npow(Math.E, - vec2_addN(vec2_log(this.vd.scale), - delta[1])) - v2d.viewData.location = vec2_mul(this.vd.location, - vec2_div(v2d.viewData.scale, - this.vd.scale)) - } +/* ViewAction Class */ +function ViewAction(mode, v2d, start) { + this.mode = mode; + this.start = start; + this.vd = v2d.viewData.copy(); +} - v2d.refresh(); - }, +ViewAction.prototype.update = function(v2d, co) { + if (this.mode == 'p') { + var delta = vec2_sub(v2d.convertClientToNDC(co, this.vd), + v2d.convertClientToNDC(this.start, this.vd)) + v2d.viewData.location = vec2_add(this.vd.location, delta); + } else { + var delta = vec2_sub(v2d.convertClientToNDC(co, this.vd), + v2d.convertClientToNDC(this.start, this.vd)) + v2d.viewData.scale = vec2_Npow(Math.E, + vec2_addN(vec2_log(this.vd.scale), + delta[1])) + v2d.viewData.location = vec2_mul(this.vd.location, + vec2_div(v2d.viewData.scale, + this.vd.scale)) + } - complete: function(v2d, co) { - this.update(v2d, co); - }, + v2d.refresh(); +} - abort: function(v2d) { - v2d.viewData = this.vd; - }, -}); +ViewAction.prototype.complete = function(v2d, co) { + this.update(v2d, co); +} -var View2D = new Class ({ - initialize: function(canvasname) { - this.canvasname = canvasname - this.viewData = new ViewData(); - this.size = [1, 1]; - this.aspect = 1; - this.registered = false; - - this.viewAction = null; - - this.useWidgets = true; - this.previewPosition = [5, 5]; - this.previewSize = [60, 60]; +ViewAction.prototype.abort = function(v2d) { + v2d.viewData = this.vd; +} - this.clearColor = [1, 1, 1]; +/* EventWrapper Class */ - // Bound once registered. - this.canvas = null; - }, +function EventWrapper(domevent) { + this.domevent = domevent; + this.client = { + x: domevent.clientX, + y: domevent.clientY, + }; + this.alt = domevent.altKey; + this.shift = domevent.shiftKey; + this.meta = domevent.metaKey; + this.wheel = (domevent.wheelDelta) ? domevent.wheelDelta / 120 : -(domevent.detail || 0) / 3; +} - registerEvents: function(canvas) { - if (this.registered) - return; +EventWrapper.prototype.stop = function() { + this.domevent.stopPropagation(); + this.domevent.preventDefault(); +} - this.registered = true; +/* View2D Class */ - this.canvas = canvas; +function View2D(canvasname) { + this.canvasname = canvasname; + this.viewData = new ViewData(); + this.size = [1, 1]; + this.aspect = 1; + this.registered = false; - // FIXME: Why do I have to do this? - var obj = this; + this.viewAction = null; - canvas.addEvent('mousedown', function(event) { obj.onMouseDown(event); }) - canvas.addEvent('mousemove', function(event) { obj.onMouseMove(event); }) - canvas.addEvent('mouseup', function(event) { obj.onMouseUp(event); }) - canvas.addEvent('mousewheel', function(event) { obj.onMouseWheel(event); }) + this.useWidgets = true; + this.previewPosition = [5, 5]; + this.previewSize = [60, 60]; - // FIXME: Capturing! - }, + this.clearColor = [1, 1, 1]; - onMouseDown: function(event) { - pos = [event.client.x - this.canvas.offsetLeft, - this.size[1] - 1 - (event.client.y - this.canvas.offsetTop)]; + // Bound once registered. + this.canvas = null; +} - if (this.viewAction != null) - this.viewAction.abort(this); +View2D.prototype.registerEvents = function(canvas) { + if (this.registered) + return; - if (event.shift) - this.viewAction = new ViewAction('p', this, pos); - else if (event.alt || event.meta) - this.viewAction = new ViewAction('z', this, pos); - event.stop(); - }, - onMouseMove: function(event) { - pos = [event.client.x - this.canvas.offsetLeft, - this.size[1] - 1 - (event.client.y - this.canvas.offsetTop)]; - - if (this.viewAction != null) - this.viewAction.update(this, pos); - event.stop(); - }, - onMouseUp: function(event) { - pos = [event.client.x - this.canvas.offsetLeft, - this.size[1] - 1 - (event.client.y - this.canvas.offsetTop)]; - - if (this.viewAction != null) - this.viewAction.complete(this, pos); - this.viewAction = null; - event.stop(); - }, - onMouseWheel: function(event) { - if (this.viewAction == null) { - var factor = event.wheel; - if (event.shift) - factor *= .1; - var zoom = 1.0 + .03 * factor; - this.viewData.location = vec2_mulN(this.viewData.location, zoom); - this.viewData.scale = vec2_mulN(this.viewData.scale, zoom); - this.refresh(); - } - event.stop(); - }, + this.registered = true; - setViewData: function(vd) { - // FIXME: Check equality and avoid refresh. - this.viewData = vd; + this.canvas = canvas; + + // FIXME: Why do I have to do this? + var obj = this; + + canvas.onmousedown = function(event) { obj.onMouseDown(new EventWrapper(event)); }; + canvas.onmousemove = function(event) { obj.onMouseMove(new EventWrapper(event)); }; + canvas.onmouseup = function(event) { obj.onMouseUp(new EventWrapper(event)); }; + canvas.onmousewheel = function(event) { obj.onMouseWheel(new EventWrapper(event)); }; + if (canvas.addEventListener) { + canvas.addEventListener('DOMMouseScroll', function(event) { obj.onMouseWheel(new EventWrapper(event)); }, false); + } + + // FIXME: Capturing! +} + +View2D.prototype.onMouseDown = function(event) { + pos = [event.client.x - this.canvas.offsetLeft, + this.size[1] - 1 - (event.client.y - this.canvas.offsetTop)]; + + if (this.viewAction != null) + this.viewAction.abort(this); + + if (event.shift) + this.viewAction = new ViewAction('p', this, pos); + else if (event.alt || event.meta) + this.viewAction = new ViewAction('z', this, pos); + event.stop(); +} + +View2D.prototype.onMouseMove = function(event) { + pos = [event.client.x - this.canvas.offsetLeft, + this.size[1] - 1 - (event.client.y - this.canvas.offsetTop)]; + + if (this.viewAction != null) + this.viewAction.update(this, pos); + event.stop(); +} + +View2D.prototype.onMouseUp = function(event) { + pos = [event.client.x - this.canvas.offsetLeft, + this.size[1] - 1 - (event.client.y - this.canvas.offsetTop)]; + + if (this.viewAction != null) + this.viewAction.complete(this, pos); + this.viewAction = null; + event.stop(); +} + +View2D.prototype.onMouseWheel = function(event) { + if (this.viewAction == null) { + var factor = event.wheel; + if (event.shift) + factor *= .1; + var zoom = 1.0 + .03 * factor; + this.viewData.location = vec2_mulN(this.viewData.location, zoom); + this.viewData.scale = vec2_mulN(this.viewData.scale, zoom); this.refresh(); - }, + } + event.stop(); +} - refresh: function() { - // FIXME: Event loop? - this.draw(); - }, +View2D.prototype.setViewData = function(vd) { + // FIXME: Check equality and avoid refresh. + this.viewData = vd; + this.refresh(); +} - // Coordinate conversion. +View2D.prototype.refresh = function() { + // FIXME: Event loop? + this.draw(); +} - getAspectScale: function() { - if (this.aspect > 1) { - return [1.0 / this.aspect, 1.0]; - } else { - return [1.0, this.aspect]; - } - }, +// Coordinate conversion. - getPixelSize: function() { - return vec2_sub(this.convertClientToWorld([1,1]), - this.convertClientToWorld([0,0])); - }, +View2D.prototype.getAspectScale = function() { + if (this.aspect > 1) { + return [1.0 / this.aspect, 1.0]; + } else { + return [1.0, this.aspect]; + } +} - convertClientToNDC: function(pt, vd) { - if (vd == null) - vd = this.viewData - return [pt[0] / this.size[0] * 2 - 1, - pt[1] / this.size[1] * 2 - 1]; - }, +View2D.prototype.getPixelSize = function() { + return vec2_sub(this.convertClientToWorld([1,1]), + this.convertClientToWorld([0,0])); +} - convertClientToWorld: function(pt, vd) { - if (vd == null) - vd = this.viewData - pt = this.convertClientToNDC(pt, vd) - pt = vec2_sub(pt, vd.location); - pt = vec2_div(pt, vec2_mul(vd.scale, this.getAspectScale())); - return pt; - }, +View2D.prototype.convertClientToNDC = function(pt, vd) { + if (vd == null) + vd = this.viewData + return [pt[0] / this.size[0] * 2 - 1, + pt[1] / this.size[1] * 2 - 1]; +} - convertWorldToPreview: function(pt, pos, size) { - var asp_scale = this.getAspectScale(); - pt = vec2_mul(pt, asp_scale); - pt = vec2_addN(pt, 1); - pt = vec2_mulN(pt, .5); - pt = vec2_mul(pt, size); - pt = vec2_add(pt, pos); - return pt; - }, +View2D.prototype.convertClientToWorld = function(pt, vd) { + if (vd == null) + vd = this.viewData + pt = this.convertClientToNDC(pt, vd) + pt = vec2_sub(pt, vd.location); + pt = vec2_div(pt, vec2_mul(vd.scale, this.getAspectScale())); + return pt; +} - setViewMatrix: function(ctx) { - ctx.scale(this.size[0], this.size[1]); - ctx.scale(.5, .5); - ctx.translate(1, 1); - ctx.translate(this.viewData.location[0], this.viewData.location[1]); - var scale = vec2_mul(this.viewData.scale, this.getAspectScale()); - ctx.scale(scale[0], scale[1]); - }, +View2D.prototype.convertWorldToPreview = function(pt, pos, size) { + var asp_scale = this.getAspectScale(); + pt = vec2_mul(pt, asp_scale); + pt = vec2_addN(pt, 1); + pt = vec2_mulN(pt, .5); + pt = vec2_mul(pt, size); + pt = vec2_add(pt, pos); + return pt; +} - setPreviewMatrix: function(ctx, pos, size) { - ctx.translate(pos[0], pos[1]); - ctx.scale(size[0], size[1]); - ctx.scale(.5, .5); - ctx.translate(1, 1); - var scale = this.getAspectScale(); - ctx.scale(scale[0], scale[1]); - }, +View2D.prototype.setViewMatrix = function(ctx) { + ctx.scale(this.size[0], this.size[1]); + ctx.scale(.5, .5); + ctx.translate(1, 1); + ctx.translate(this.viewData.location[0], this.viewData.location[1]); + var scale = vec2_mul(this.viewData.scale, this.getAspectScale()); + ctx.scale(scale[0], scale[1]); +} - setWindowMatrix: function(ctx) { - ctx.translate(.5, .5); - ctx.translate(0, this.size[1]); - ctx.scale(1, -1); - }, +View2D.prototype.setPreviewMatrix = function(ctx, pos, size) { + ctx.translate(pos[0], pos[1]); + ctx.scale(size[0], size[1]); + ctx.scale(.5, .5); + ctx.translate(1, 1); + var scale = this.getAspectScale(); + ctx.scale(scale[0], scale[1]); +} - draw: function() { - var canvas = document.getElementById(this.canvasname); - var ctx = canvas.getContext("2d"); - - this.registerEvents(canvas); - - if (canvas.width != this.size[0] || canvas.height != this.size[1]) { - this.size = [canvas.width, canvas.height]; - this.aspect = canvas.width / canvas.height; - this.previewPosition[0] = this.size[0] - this.previewSize[0] - 5; - this.on_size_change(); - } +View2D.prototype.setWindowMatrix = function(ctx) { + ctx.translate(.5, .5); + ctx.translate(0, this.size[1]); + ctx.scale(1, -1); +} - this.on_draw_start(); +View2D.prototype.draw = function() { + var canvas = document.getElementById(this.canvasname); + var ctx = canvas.getContext("2d"); - ctx.save(); + this.registerEvents(canvas); - // Clear and draw the view content. - ctx.save(); - this.setWindowMatrix(ctx); + if (canvas.width != this.size[0] || canvas.height != this.size[1]) { + this.size = [canvas.width, canvas.height]; + this.aspect = canvas.width / canvas.height; + this.previewPosition[0] = this.size[0] - this.previewSize[0] - 5; + this.on_size_change(); + } - ctx.clearRect(0, 0, this.size[0], this.size[1]); - ctx.fillStyle = col3_to_rgb(this.clearColor); - ctx.fillRect(0, 0, this.size[0], this.size[1]); + this.on_draw_start(); - this.setViewMatrix(ctx); - this.on_draw(canvas, ctx); - ctx.restore(); + ctx.save(); - if (this.useWidgets) - this.drawPreview(canvas, ctx) + // Clear and draw the view content. + ctx.save(); + this.setWindowMatrix(ctx); - ctx.restore(); - }, + ctx.clearRect(0, 0, this.size[0], this.size[1]); + ctx.fillStyle = col3_to_rgb(this.clearColor); + ctx.fillRect(0, 0, this.size[0], this.size[1]); - drawPreview: function(canvas, ctx) { - // Setup the preview context. - this.setWindowMatrix(ctx); - - // Draw the preview area outline. - ctx.fillStyle = "rgba(128,128,128,.5)"; - ctx.fillRect(this.previewPosition[0]-1, this.previewPosition[1]-1, - this.previewSize[0]+2, this.previewSize[1]+2); - ctx.lineWidth = 1; - ctx.strokeStyle = "rgb(0,0,0)"; - ctx.strokeRect(this.previewPosition[0]-1, this.previewPosition[1]-1, - this.previewSize[0]+2, this.previewSize[1]+2); - - // Compute the aspect corrected preview area. - var pv_size = [this.previewSize[0], this.previewSize[1]]; - if (this.aspect > 1) { - pv_size[1] /= this.aspect; - } else { - pv_size[0] *= this.aspect; - } - var pv_pos = vec2_add(this.previewPosition, - vec2_mulN(vec2_sub(this.previewSize, pv_size), .5)); + this.setViewMatrix(ctx); + this.on_draw(canvas, ctx); + ctx.restore(); - // Draw the preview, making sure to clip to the proper area. - ctx.save(); - ctx.beginPath(); - ctx.rect(pv_pos[0], pv_pos[1], pv_size[0], pv_size[1]); - ctx.clip(); - ctx.closePath(); + if (this.useWidgets) + this.drawPreview(canvas, ctx) - this.setPreviewMatrix(ctx, pv_pos, pv_size); - this.on_draw_preview(canvas, ctx); - ctx.restore(); + ctx.restore(); +} - // Draw the current view overlay. - // - // FIXME: Find a replacement for stippling. - ll = this.convertClientToWorld([0, 0]) - ur = this.convertClientToWorld(this.size); - - // Convert to pixel coordinates instead of drawing in content - // perspective. - ll = vec2_floor(this.convertWorldToPreview(ll, pv_pos, pv_size)) - ur = vec2_ceil(this.convertWorldToPreview(ur, pv_pos, pv_size)) - ll = vec2_clamp(ll, this.previewPosition, - vec2_add(this.previewPosition, this.previewSize)) - ur = vec2_clamp(ur, this.previewPosition, - vec2_add(this.previewPosition, this.previewSize)) - - ctx.strokeStyle = "rgba(128,128,128,255)"; - ctx.lineWidth = 1; - ctx.strokeRect(ll[0], ll[1], ur[0] - ll[0], ur[1] - ll[1]); - }, +View2D.prototype.drawPreview = function(canvas, ctx) { + // Setup the preview context. + this.setWindowMatrix(ctx); - on_size_change: function() {}, - on_draw_start: function() {}, - on_draw: function(canvas, ctx) {}, - on_draw_preview: function(canvas, ctx) {}, -}); - -var View2DTest = new Class ({ - Extends: View2D, - - on_draw: function(canvas, ctx) { - ctx.fillStyle = "rgb(255,255,255)"; - ctx.fillRect(-1000, -1000, 2000, 20000); - - ctx.lineWidth = .01; - ctx.strokeTyle = "rgb(0,200,0)"; - ctx.strokeRect(-1, -1, 2, 2); + // Draw the preview area outline. + ctx.fillStyle = "rgba(128,128,128,.5)"; + ctx.fillRect(this.previewPosition[0]-1, this.previewPosition[1]-1, + this.previewSize[0]+2, this.previewSize[1]+2); + ctx.lineWidth = 1; + ctx.strokeStyle = "rgb(0,0,0)"; + ctx.strokeRect(this.previewPosition[0]-1, this.previewPosition[1]-1, + this.previewSize[0]+2, this.previewSize[1]+2); - ctx.fillStyle = "rgb(200,0,0)"; - ctx.fillRect(-.8, -.8, 1, 1); + // Compute the aspect corrected preview area. + var pv_size = [this.previewSize[0], this.previewSize[1]]; + if (this.aspect > 1) { + pv_size[1] /= this.aspect; + } else { + pv_size[0] *= this.aspect; + } + var pv_pos = vec2_add(this.previewPosition, + vec2_mulN(vec2_sub(this.previewSize, pv_size), .5)); - ctx.fillStyle = "rgb(0,0,200)"; - ctx.beginPath(); - ctx.arc(0, 0, .5, 0, 2 * Math.PI, false); - ctx.fill(); - ctx.closePath(); - }, + // Draw the preview, making sure to clip to the proper area. + ctx.save(); + ctx.beginPath(); + ctx.rect(pv_pos[0], pv_pos[1], pv_size[0], pv_size[1]); + ctx.clip(); + ctx.closePath(); - on_draw_preview: function(canvas, ctx) { - ctx.fillStyle = "rgba(255,255,255,.4)"; - ctx.fillRect(-1000, -1000, 2000, 20000); - - ctx.lineWidth = .01; - ctx.strokeTyle = "rgba(0,200,0,.4)"; - ctx.strokeRect(-1, -1, 2, 2); + this.setPreviewMatrix(ctx, pv_pos, pv_size); + this.on_draw_preview(canvas, ctx); + ctx.restore(); - ctx.fillStyle = "rgba(200,0,0,.4)"; - ctx.fillRect(-.8, -.8, 1, 1); + // Draw the current view overlay. + // + // FIXME: Find a replacement for stippling. + ll = this.convertClientToWorld([0, 0]) + ur = this.convertClientToWorld(this.size); - ctx.fillStyle = "rgba(0,0,200,.4)"; - ctx.beginPath(); - ctx.arc(0, 0, .5, 0, 2 * Math.PI, false); - ctx.fill(); - ctx.closePath(); - }, -}); + // Convert to pixel coordinates instead of drawing in content + // perspective. + ll = vec2_floor(this.convertWorldToPreview(ll, pv_pos, pv_size)) + ur = vec2_ceil(this.convertWorldToPreview(ur, pv_pos, pv_size)) + ll = vec2_clamp(ll, this.previewPosition, + vec2_add(this.previewPosition, this.previewSize)) + ur = vec2_clamp(ur, this.previewPosition, + vec2_add(this.previewPosition, this.previewSize)) -var Graph2D_GraphInfo = new Class ({ - initialize: function() { - this.xAxisH = 0; - this.yAxisW = 0; - this.ll = [0, 0]; - this.ur = [1, 1]; - }, + ctx.strokeStyle = "rgba(128,128,128,255)"; + ctx.lineWidth = 1; + ctx.strokeRect(ll[0], ll[1], ur[0] - ll[0], ur[1] - ll[1]); +} - toNDC: function(pt) { - return [2 * (pt[0] - this.ll[0]) / (this.ur[0] - this.ll[0]) - 1, - 2 * (pt[1] - this.ll[1]) / (this.ur[1] - this.ll[1]) - 1]; - }, +View2D.prototype.on_size_change = function() {} +View2D.prototype.on_draw_start = function() {} +View2D.prototype.on_draw = function(canvas, ctx) {} +View2D.prototype.on_draw_preview = function(canvas, ctx) {} - fromNDC: function(pt) { - return [this.ll[0] + (this.ur[0] - this.ll[0]) * (pt[0] + 1) * .5, - this.ll[1] + (this.ur[1] - this.ll[1]) * (pt[1] + 1) * .5]; - }, -}); +/* View2DTest Class */ -var Graph2D_PlotStyle = new Class ({ - initialize: function() {}, +function View2DTest(canvasname) { + View2D.call(this, canvasname); +} +View2DTest.prototype = new View2D(); +View2DTest.prototype.constructor = View2DTest; - plot: function(graph, ctx, data) {}, -}); +View2DTest.prototype.on_draw = function(canvas, ctx) { + ctx.fillStyle = "rgb(255,255,255)"; + ctx.fillRect(-1000, -1000, 2000, 20000); -var Graph2D_LinePlotStyle = new Class ({ - Extends: Graph2D_PlotStyle, - - initialize: function(width, color) { - if (!width) - width = 1; - if (!color) - color = [0,0,0]; - - this.parent(); - this.width = width; - this.color = color; - }, + ctx.lineWidth = .01; + ctx.strokeTyle = "rgb(0,200,0)"; + ctx.strokeRect(-1, -1, 2, 2); - plot: function(graph, ctx, data) { - if (data.length === 0) - return; + ctx.fillStyle = "rgb(200,0,0)"; + ctx.fillRect(-.8, -.8, 1, 1); - ctx.beginPath(); - var co = graph.graphInfo.toNDC(data[0]); - ctx.moveTo(co[0], co[1]); - for (var i = 1, e = data.length; i != e; ++i) { - var co = graph.graphInfo.toNDC(data[i]); - ctx.lineTo(co[0], co[1]); - } - ctx.lineWidth = this.width * (graph.getPixelSize()[0] + graph.getPixelSize()[1]) * .5; - ctx.strokeStyle = col3_to_rgb(this.color); - ctx.stroke(); - }, -}); + ctx.fillStyle = "rgb(0,0,200)"; + ctx.beginPath(); + ctx.arc(0, 0, .5, 0, 2 * Math.PI, false); + ctx.fill(); + ctx.closePath(); +} -var Graph2D_PointPlotStyle = new Class ({ - Extends: Graph2D_PlotStyle, +View2DTest.prototype.on_draw_preview = function(canvas, ctx) { + ctx.fillStyle = "rgba(255,255,255,.4)"; + ctx.fillRect(-1000, -1000, 2000, 20000); - initialize: function(width, color) { - if (!width) - width = 1; - if (!color) - color = [0,0,0]; - - this.parent(); - this.width = width; - this.color = color; - }, + ctx.lineWidth = .01; + ctx.strokeTyle = "rgba(0,200,0,.4)"; + ctx.strokeRect(-1, -1, 2, 2); - plot: function(graph, ctx, data) { - if (data.length === 0) - return; + ctx.fillStyle = "rgba(200,0,0,.4)"; + ctx.fillRect(-.8, -.8, 1, 1); - ctx.beginPath(); - var radius = this.width * (graph.getPixelSize()[0] + graph.getPixelSize()[1]) * .5; - for (var i = 0, e = data.length; i != e; ++i) { - var co = graph.graphInfo.toNDC(data[i]); - ctx.moveTo(co[0], co[1]); - ctx.arc(co[0], co[1], radius, 0, Math.PI * 2, /*anticlockwise=*/false); - } - ctx.fillStyle = col3_to_rgb(this.color); - ctx.fill(); - }, -}); + ctx.fillStyle = "rgba(0,0,200,.4)"; + ctx.beginPath(); + ctx.arc(0, 0, .5, 0, 2 * Math.PI, false); + ctx.fill(); + ctx.closePath(); +} -var Graph2D_ErrorBarPlotStyle = new Class ({ - Extends: Graph2D_PlotStyle, +/* Graph2D_GraphInfo Class */ - initialize: function(width, color) { - if (!width) - width = 1; - if (!color) - color = [0,0,0]; - - this.parent(); - this.width = width; - this.color = color; - }, +function Graph2D_GraphInfo() { + this.xAxisH = 0; + this.yAxisW = 0; + this.ll = [0, 0]; + this.ur = [1, 1]; +} - plot: function(graph, ctx, data) { - if (data.length === 0) - return; +Graph2D_GraphInfo.prototype.toNDC = function(pt) { + return [2 * (pt[0] - this.ll[0]) / (this.ur[0] - this.ll[0]) - 1, + 2 * (pt[1] - this.ll[1]) / (this.ur[1] - this.ll[1]) - 1]; +} - ctx.beginPath(); - for (var i = 0, e = data.length; i != e; ++i) { - var co_min = graph.graphInfo.toNDC([data[i][0], data[i][1]]); - var co_max = graph.graphInfo.toNDC([data[i][0], data[i][2]]); - ctx.moveTo(co_min[0], co_min[1]); - ctx.lineTo(co_max[0], co_max[1]); - } - ctx.lineWidth = this.width * (graph.getPixelSize()[0] + graph.getPixelSize()[1]) * .5; - ctx.strokeStyle = col3_to_rgb(this.color); - ctx.stroke(); - }, -}); +Graph2D_GraphInfo.prototype.fromNDC = function(pt) { + return [this.ll[0] + (this.ur[0] - this.ll[0]) * (pt[0] + 1) * .5, + this.ll[1] + (this.ur[1] - this.ll[1]) * (pt[1] + 1) * .5]; +} -var Graph2D_Axis = new Class ({ - // Static Methods - formats: { - normal: function(value, iDigits, fDigits) { - // FIXME: iDigits? - return value.toFixed(fDigits); - }, - day: function(value, iDigits, fDigits) { - var date = new Date(value * 1000.); - var res = date.getUTCFullYear(); - res += "-" + (date.getUTCMonth() + 1); - res += "-" + (date.getUTCDate() + 1); - return res; - }, - }, +/* Graph2D_PlotStyle Class */ - initialize: function(dir, format) { - if (!format) - format = this.formats.normal; +function Graph2D_PlotStyle() { +} - this.dir = dir; - this.format = format; - }, +Graph2D_PlotStyle.prototype.plot = function(graph, ctx, data) {} - draw: function(graph, ctx, ll, ur, mainUR) { - var dir = this.dir, ndir = 1 - this.dir; - var vMin = ll[dir]; - var vMax = ur[dir]; - var near = ll[ndir]; - var far = ur[ndir]; - var border = mainUR[ndir]; - - var line_base = (graph.getPixelSize()[0] + graph.getPixelSize()[1]) * .5; - ctx.lineWidth = 2 * line_base; - ctx.strokeStyle = "rgb(0,0,0)"; +/* Graph2D_LinePlotStyle Class */ - ctx.beginPath(); - var co = vec2_cswap([vMin, far], dir); - co = graph.graphInfo.toNDC(co); - ctx.moveTo(co[0], co[1]); - var co = vec2_cswap([vMax, far], dir); - co = graph.graphInfo.toNDC(co); - ctx.lineTo(co[0], co[1]); - ctx.stroke(); +function Graph2D_LinePlotStyle(width, color) { + Graph2D_PlotStyle.call(this); - var delta = vMax - vMin; - var steps = Math.floor(Math.log(delta) / Math.log(10)); - if (delta / Math.pow(10, steps) >= 5.0) { - var size = .5; - } else if (delta / Math.pow(10, steps) >= 2.5) { - var size = .25; - } else { - var size = .1; - } - size *= Math.pow(10, steps); + if (!width) + width = 1; + if (!color) + color = [0,0,0]; - if (steps <= 0) { - var iDigits = 0, fDigits = 1 + Math.abs(steps); - } else { - var iDigits = steps, fDigits = 0; - } + this.width = width; + this.color = color; +} +Graph2D_LinePlotStyle.prototype = new Graph2D_PlotStyle(); +Graph2D_LinePlotStyle.prototype.constructor = Graph2D_LinePlotStyle; - var start = Math.ceil(vMin / size); - var end = Math.ceil(vMax / size); +Graph2D_LinePlotStyle.prototype.plot = function(graph, ctx, data) { + if (data.length === 0) + return; - // FIXME: Draw in window coordinates to make crisper. + ctx.beginPath(); + var co = graph.graphInfo.toNDC(data[0]); + ctx.moveTo(co[0], co[1]); + for (var i = 1, e = data.length; i != e; ++i) { + var co = graph.graphInfo.toNDC(data[i]); + ctx.lineTo(co[0], co[1]); + } + ctx.lineWidth = this.width * (graph.getPixelSize()[0] + graph.getPixelSize()[1]) * .5; + ctx.strokeStyle = col3_to_rgb(this.color); + ctx.stroke(); +} - // FIXME: Draw grid in layers to avoid ugly overlaps. +/* Graph2D_PointPlotStyle Class */ - for (var i = start; i != end; ++i) { - if (i == 0) { - ctx.lineWidth = 3 * line_base; - var p = .5; - } else if (!(i & 1)) { - ctx.lineWidth = 2 * line_base; - var p = .5; - } else { - ctx.lineWidth = 1 * line_base; - var p = .75; - } +function Graph2D_PointPlotStyle(width, color) { + Graph2D_PlotStyle.call(this); - ctx.beginPath(); - var co = vec2_cswap([i * size, lerp(near, far, p)], dir); - co = graph.graphInfo.toNDC(co); - ctx.moveTo(co[0], co[1]); - var co = vec2_cswap([i * size, far], dir); - co = graph.graphInfo.toNDC(co); - ctx.lineTo(co[0], co[1]); - ctx.stroke(); - } + if (!width) + width = 1; + if (!color) + color = [0,0,0]; - for (var alt = 0; alt < 2; ++alt) { - if (alt) - ctx.strokeStyle = "rgba(190,190,190,.5)"; - else - ctx.strokeStyle = "rgba(128,128,128,.5)"; + this.width = width; + this.color = color; +} +Graph2D_PointPlotStyle.prototype = new Graph2D_PlotStyle(); +Graph2D_PointPlotStyle.prototype.constructor = Graph2D_PointPlotStyle; + +Graph2D_PointPlotStyle.prototype.plot = function(graph, ctx, data) { + if (data.length === 0) + return; + + ctx.beginPath(); + var radius = this.width * (graph.getPixelSize()[0] + graph.getPixelSize()[1]) * .5; + for (var i = 0, e = data.length; i != e; ++i) { + var co = graph.graphInfo.toNDC(data[i]); + ctx.moveTo(co[0], co[1]); + ctx.arc(co[0], co[1], radius, 0, Math.PI * 2, /*anticlockwise=*/false); + } + ctx.fillStyle = col3_to_rgb(this.color); + ctx.fill(); +} + +/* Graph2D_ErrorBarPlotStyle Class */ + +function Graph2D_ErrorBarPlotStyle(width, color) { + Graph2D_PlotStyle.call(this); + + if (!width) + width = 1; + if (!color) + color = [0,0,0]; + + this.width = width; + this.color = color; +} +Graph2D_ErrorBarPlotStyle.prototype = new Graph2D_PlotStyle(); +Graph2D_ErrorBarPlotStyle.prototype.constructor = Graph2D_ErrorBarPlotStyle; + +Graph2D_ErrorBarPlotStyle.prototype.plot = function(graph, ctx, data) { + if (data.length === 0) + return; + + ctx.beginPath(); + for (var i = 0, e = data.length; i != e; ++i) { + var co_min = graph.graphInfo.toNDC([data[i][0], data[i][1]]); + var co_max = graph.graphInfo.toNDC([data[i][0], data[i][2]]); + ctx.moveTo(co_min[0], co_min[1]); + ctx.lineTo(co_max[0], co_max[1]); + } + ctx.lineWidth = this.width * (graph.getPixelSize()[0] + graph.getPixelSize()[1]) * .5; + ctx.strokeStyle = col3_to_rgb(this.color); + ctx.stroke(); +} + +/* Graph2D_Axis Class */ + +function Graph2D_Axis(dir, format) { + if (!format) + format = this.formats.normal; + + this.dir = dir; + this.format = format; +} + +// Static Methods +Graph2D_Axis.prototype.formats = { + normal: function(value, iDigits, fDigits) { + // FIXME: iDigits? + return value.toFixed(fDigits); + }, + day: function(value, iDigits, fDigits) { + var date = new Date(value * 1000.); + var res = date.getUTCFullYear(); + res += "-" + (date.getUTCMonth() + 1); + res += "-" + (date.getUTCDate() + 1); + return res; + }, +}; + +Graph2D_Axis.prototype.draw = function(graph, ctx, ll, ur, mainUR) { + var dir = this.dir, ndir = 1 - this.dir; + var vMin = ll[dir]; + var vMax = ur[dir]; + var near = ll[ndir]; + var far = ur[ndir]; + var border = mainUR[ndir]; + + var line_base = (graph.getPixelSize()[0] + graph.getPixelSize()[1]) * .5; + ctx.lineWidth = 2 * line_base; + ctx.strokeStyle = "rgb(0,0,0)"; + + ctx.beginPath(); + var co = vec2_cswap([vMin, far], dir); + co = graph.graphInfo.toNDC(co); + ctx.moveTo(co[0], co[1]); + var co = vec2_cswap([vMax, far], dir); + co = graph.graphInfo.toNDC(co); + ctx.lineTo(co[0], co[1]); + ctx.stroke(); + + var delta = vMax - vMin; + var steps = Math.floor(Math.log(delta) / Math.log(10)); + if (delta / Math.pow(10, steps) >= 5.0) { + var size = .5; + } else if (delta / Math.pow(10, steps) >= 2.5) { + var size = .25; + } else { + var size = .1; + } + size *= Math.pow(10, steps); + + if (steps <= 0) { + var iDigits = 0, fDigits = 1 + Math.abs(steps); + } else { + var iDigits = steps, fDigits = 0; + } + + var start = Math.ceil(vMin / size); + var end = Math.ceil(vMax / size); + + // FIXME: Draw in window coordinates to make crisper. + + // FIXME: Draw grid in layers to avoid ugly overlaps. + + for (var i = start; i != end; ++i) { + if (i == 0) { + ctx.lineWidth = 3 * line_base; + var p = .5; + } else if (!(i & 1)) { + ctx.lineWidth = 2 * line_base; + var p = .5; + } else { ctx.lineWidth = 1 * line_base; - ctx.beginPath(); - for (var i = start; i != end; ++i) { - if (i == 0) - continue; - if ((i & 1) == alt) { - var co = vec2_cswap([i * size, far], dir); - co = graph.graphInfo.toNDC(co); - ctx.moveTo(co[0], co[1]); - var co = vec2_cswap([i * size, border], dir); - co = graph.graphInfo.toNDC(co); - ctx.lineTo(co[0], co[1]); - } - } - ctx.stroke(); + var p = .75; + } + + ctx.beginPath(); + var co = vec2_cswap([i * size, lerp(near, far, p)], dir); + co = graph.graphInfo.toNDC(co); + ctx.moveTo(co[0], co[1]); + var co = vec2_cswap([i * size, far], dir); + co = graph.graphInfo.toNDC(co); + ctx.lineTo(co[0], co[1]); + ctx.stroke(); + } - if (start <= 0 && 0 < end) { - ctx.beginPath(); - var co = vec2_cswap([0, far], dir); + for (var alt = 0; alt < 2; ++alt) { + if (alt) + ctx.strokeStyle = "rgba(190,190,190,.5)"; + else + ctx.strokeStyle = "rgba(128,128,128,.5)"; + ctx.lineWidth = 1 * line_base; + ctx.beginPath(); + for (var i = start; i != end; ++i) { + if (i == 0) + continue; + if ((i & 1) == alt) { + var co = vec2_cswap([i * size, far], dir); co = graph.graphInfo.toNDC(co); ctx.moveTo(co[0], co[1]); - var co = vec2_cswap([0, border], dir); + var co = vec2_cswap([i * size, border], dir); co = graph.graphInfo.toNDC(co); ctx.lineTo(co[0], co[1]); - ctx.strokeStyle = "rgba(64,64,64,.5)"; - ctx.lineWidth = 3 * line_base; - ctx.stroke(); } } + ctx.stroke(); - // FIXME: Draw this in screen coordinates, and stop being stupid. Also, - // figure out font height? - if (this.dir == 1) { - var offset = [-.5, -.25]; - } else { - var offset = [-.5, 1.1]; + if (start <= 0 && 0 < end) { + ctx.beginPath(); + var co = vec2_cswap([0, far], dir); + co = graph.graphInfo.toNDC(co); + ctx.moveTo(co[0], co[1]); + var co = vec2_cswap([0, border], dir); + co = graph.graphInfo.toNDC(co); + ctx.lineTo(co[0], co[1]); + ctx.strokeStyle = "rgba(64,64,64,.5)"; + ctx.lineWidth = 3 * line_base; + ctx.stroke(); } - ctx.fillStyle = "rgb(0,0,0)"; - var pxl = graph.getPixelSize(); - for (var i = start; i != end; ++i) { - if ((i & 1) == 0) { - var label = this.format(i * size, iDigits, fDigits); - ctx.save(); - var co = vec2_cswap([i*size, lerp(near, far, .5)], dir); - co = graph.graphInfo.toNDC(co); - ctx.translate(co[0], co[1]); - ctx.scale(pxl[0], -pxl[1]); - // FIXME: Abstract. - var bb_w = label.length * 5; - if (ctx.measureText != null) - bb_w = ctx.measureText(label).width; - var bb_h = 12; - // FIXME: Abstract? Or ignore. - if (ctx.fillText != null) { - ctx.fillText(label, bb_w*offset[0], bb_h*offset[1]); - } else if (ctx.mozDrawText != null) { - ctx.translate(bb_w*offset[0], bb_h*offset[1]); - ctx.mozDrawText(label); - } - ctx.restore(); + } + + // FIXME: Draw this in screen coordinates, and stop being stupid. Also, + // figure out font height? + if (this.dir == 1) { + var offset = [-.5, -.25]; + } else { + var offset = [-.5, 1.1]; + } + ctx.fillStyle = "rgb(0,0,0)"; + var pxl = graph.getPixelSize(); + for (var i = start; i != end; ++i) { + if ((i & 1) == 0) { + var label = this.format(i * size, iDigits, fDigits); + ctx.save(); + var co = vec2_cswap([i*size, lerp(near, far, .5)], dir); + co = graph.graphInfo.toNDC(co); + ctx.translate(co[0], co[1]); + ctx.scale(pxl[0], -pxl[1]); + // FIXME: Abstract. + var bb_w = label.length * 5; + if (ctx.measureText != null) + bb_w = ctx.measureText(label).width; + var bb_h = 12; + // FIXME: Abstract? Or ignore. + if (ctx.fillText != null) { + ctx.fillText(label, bb_w*offset[0], bb_h*offset[1]); + } else if (ctx.mozDrawText != null) { + ctx.translate(bb_w*offset[0], bb_h*offset[1]); + ctx.mozDrawText(label); } + ctx.restore(); } - }, -}); - -var Graph2D = new Class ({ - Extends: View2D, + } +} - initialize: function(canvasname) { - this.parent(canvasname); - this.useWidgets = false; - this.plots = []; - this.graphInfo = null; - this.xAxis = new Graph2D_Axis(0); - this.yAxis = new Graph2D_Axis(1); - this.debugText = null; +/* Graph2D Class */ - this.clearColor = [.8, .8, .8]; - }, +function Graph2D(canvasname) { + View2D.call(this, canvasname) - // + this.useWidgets = false; + this.plots = []; + this.graphInfo = null; + this.xAxis = new Graph2D_Axis(0); + this.yAxis = new Graph2D_Axis(1); + this.debugText = null; - graphChanged: function() { - this.graphInfo = null; - // FIXME: Need event loop. - this.refresh(); - }, + this.clearColor = [.8, .8, .8]; +} +Graph2D.prototype = new View2D(); +Graph2D.prototype.constructor = Graph2D; - layoutGraph: function() { - var gi = new Graph2D_GraphInfo(); +// - gi.xAxisH = 40; - gi.yAxisW = 60; +Graph2D.prototype.graphChanged = function() { + this.graphInfo = null; + // FIXME: Need event loop. + this.refresh(); +} + +Graph2D.prototype.layoutGraph = function() { + var gi = new Graph2D_GraphInfo(); + + gi.xAxisH = 40; + gi.yAxisW = 60; + + var min = null, max = null; + for (var i = 0, e = this.plots.length; i != e; ++i) { + var data = this.plots[i][0]; + for (var i2 = 0, e2 = data.length; i2 != e2; ++i2) { + if (min == null) + min = data[i2]; + else + min = vec2_min(min, data[i2]); - var min = null, max = null; - for (var i = 0, e = this.plots.length; i != e; ++i) { - var data = this.plots[i][0]; - for (var i2 = 0, e2 = data.length; i2 != e2; ++i2) { - if (min == null) - min = data[i2]; - else - min = vec2_min(min, data[i2]); - - if (max == null) - max = data[i2]; - else - max = vec2_max(max, data[i2]); - } + if (max == null) + max = data[i2]; + else + max = vec2_max(max, data[i2]); } + } - if (min === null) - min = [0, 0]; - if (max === null) - max = [0, 0]; - if (Math.abs(max[0] - min[0]) < .001) - max[0] += 1; - if (Math.abs(max[1] - min[1]) < .001) - max[1] += 1; - - // Set graph transform to the [min,max] rect to the content area with - // some padding. - // - // FIXME: Add real mat3 and implement this properly. - var pad = 5; - var vd = new ViewData(); - var ll_target = this.convertClientToWorld([gi.yAxisW + pad, gi.xAxisH + pad], vd); - var ur_target = this.convertClientToWorld(vec2_subN(this.size, pad), vd); - var target_size = vec2_sub(ur_target, ll_target); - var target_center = vec2_add(ll_target, vec2_mulN(target_size, .5)); - - var center = vec2_mulN(vec2_add(min, max), .5); - var size = vec2_sub(max, min); - - var scale = vec2_mulN(target_size, .5); - size = vec2_div(size, scale); - center = vec2_sub(center, vec2_mulN(vec2_mul(target_center, size), .5)); + if (min === null) + min = [0, 0]; + if (max === null) + max = [0, 0]; + if (Math.abs(max[0] - min[0]) < .001) + max[0] += 1; + if (Math.abs(max[1] - min[1]) < .001) + max[1] += 1; - gi.ll = vec2_sub(center, vec2_mulN(size, .5)); - gi.ur = vec2_add(center, vec2_mulN(size, .5)); + // Set graph transform to the [min,max] rect to the content area with + // some padding. + // + // FIXME: Add real mat3 and implement this properly. + var pad = 5; + var vd = new ViewData(); + var ll_target = this.convertClientToWorld([gi.yAxisW + pad, gi.xAxisH + pad], vd); + var ur_target = this.convertClientToWorld(vec2_subN(this.size, pad), vd); + var target_size = vec2_sub(ur_target, ll_target); + var target_center = vec2_add(ll_target, vec2_mulN(target_size, .5)); + + var center = vec2_mulN(vec2_add(min, max), .5); + var size = vec2_sub(max, min); + + var scale = vec2_mulN(target_size, .5); + size = vec2_div(size, scale); + center = vec2_sub(center, vec2_mulN(vec2_mul(target_center, size), .5)); - return gi; - }, + gi.ll = vec2_sub(center, vec2_mulN(size, .5)); + gi.ur = vec2_add(center, vec2_mulN(size, .5)); - // + return gi; +} - convertClientToGraph: function(pt) { - return this.graphInfo.fromNDC(this.convertClientToWorld(pt)); - }, +// - // +Graph2D.prototype.convertClientToGraph = function(pt) { + return this.graphInfo.fromNDC(this.convertClientToWorld(pt)); +} - on_size_change: function() { - this.graphInfo = null; - }, +// - on_draw_start: function() { - if (!this.graphInfo) - this.graphInfo = this.layoutGraph(); - }, +Graph2D.prototype.on_size_change = function() { + this.graphInfo = null; +} - on_draw: function(canvas, ctx) { - var gi = this.graphInfo; - var w = this.size[0], h = this.size[1]; - - this.xAxis.draw(this, ctx, - this.convertClientToGraph([gi.yAxisW, 0]), - this.convertClientToGraph([w, gi.xAxisH]), - this.convertClientToGraph([w, h])) - this.yAxis.draw(this, ctx, - this.convertClientToGraph([0, gi.xAxisH]), - this.convertClientToGraph([gi.yAxisW, h]), - this.convertClientToGraph([w, h])) +Graph2D.prototype.on_draw_start = function() { + if (!this.graphInfo) + this.graphInfo = this.layoutGraph(); +} - if (this.debugText != null) { - ctx.save(); - ctx.setTransform(1, 0, 0, 1, 0, 0); - ctx.fillText(this.debugText, this.size[0]/2 + 10, this.size[1]/2 + 10); - ctx.restore(); - } +Graph2D.prototype.on_draw = function(canvas, ctx) { + var gi = this.graphInfo; + var w = this.size[0], h = this.size[1]; + + this.xAxis.draw(this, ctx, + this.convertClientToGraph([gi.yAxisW, 0]), + this.convertClientToGraph([w, gi.xAxisH]), + this.convertClientToGraph([w, h])) + this.yAxis.draw(this, ctx, + this.convertClientToGraph([0, gi.xAxisH]), + this.convertClientToGraph([gi.yAxisW, h]), + this.convertClientToGraph([w, h])) - // Draw the contents. + if (this.debugText != null) { ctx.save(); - ctx.beginPath(); - var content_ll = this.convertClientToWorld([gi.yAxisW, gi.xAxisH]); - var content_ur = this.convertClientToWorld(this.size); - ctx.rect(content_ll[0], content_ll[1], - content_ur[0]-content_ll[0], content_ur[1]-content_ll[1]); - ctx.clip(); - - for (var i = 0, e = this.plots.length; i != e; ++i) { - var data = this.plots[i][0]; - var style = this.plots[i][1]; - style.plot(this, ctx, data); - } + ctx.setTransform(1, 0, 0, 1, 0, 0); + ctx.fillText(this.debugText, this.size[0]/2 + 10, this.size[1]/2 + 10); ctx.restore(); - }, - - // Client API. + } - clearPlots: function() { - this.plots = []; - this.graphChanged(); - }, + // Draw the contents. + ctx.save(); + ctx.beginPath(); + var content_ll = this.convertClientToWorld([gi.yAxisW, gi.xAxisH]); + var content_ur = this.convertClientToWorld(this.size); + ctx.rect(content_ll[0], content_ll[1], + content_ur[0]-content_ll[0], content_ur[1]-content_ll[1]); + ctx.clip(); + + for (var i = 0, e = this.plots.length; i != e; ++i) { + var data = this.plots[i][0]; + var style = this.plots[i][1]; + style.plot(this, ctx, data); + } + ctx.restore(); +} + +// Client API. + +Graph2D.prototype.clearPlots = function() { + this.plots = []; + this.graphChanged(); +} + +Graph2D.prototype.addPlot = function(data, style) { + if (!style) + style = new Graph2D_LinePlotStyle(1); + this.plots.push( [data, style] ); + this.graphChanged(); +} - addPlot: function(data, style) { - if (!style) - style = new Graph2D_LinePlotStyle(1); - this.plots.push( [data, style] ); - this.graphChanged(); - }, -}); Modified: zorg/trunk/lnt/lnt/viewer/js/View2DTest.html URL: http://llvm.org/viewvc/llvm-project/zorg/trunk/lnt/lnt/viewer/js/View2DTest.html?rev=110918&r1=110917&r2=110918&view=diff ============================================================================== --- zorg/trunk/lnt/lnt/viewer/js/View2DTest.html (original) +++ zorg/trunk/lnt/lnt/viewer/js/View2DTest.html Thu Aug 12 11:03:30 2010 @@ -1,7 +1,6 @@ View2D Test - - %(subject)s Removed: zorg/trunk/lnt/lnt/viewer/resources/mootools-1.2.4-core-nc.js URL: http://llvm.org/viewvc/llvm-project/zorg/trunk/lnt/lnt/viewer/resources/mootools-1.2.4-core-nc.js?rev=110918&view=auto ============================================================================== --- zorg/trunk/lnt/lnt/viewer/resources/mootools-1.2.4-core-nc.js (original) +++ zorg/trunk/lnt/lnt/viewer/resources/mootools-1.2.4-core-nc.js (removed) @@ -1,4329 +0,0 @@ -/* ---- - -script: Core.js - -description: The core of MooTools, contains all the base functions and the Native and Hash implementations. Required by all the other scripts. - -license: MIT-style license. - -copyright: Copyright (c) 2006-2008 [Valerio Proietti](http://mad4milk.net/). - -authors: The MooTools production team (http://mootools.net/developers/) - -inspiration: -- Class implementation inspired by [Base.js](http://dean.edwards.name/weblog/2006/03/base/) Copyright (c) 2006 Dean Edwards, [GNU Lesser General Public License](http://opensource.org/licenses/lgpl-license.php) -- Some functionality inspired by [Prototype.js](http://prototypejs.org) Copyright (c) 2005-2007 Sam Stephenson, [MIT License](http://opensource.org/licenses/mit-license.php) - -provides: [Mootools, Native, Hash.base, Array.each, $util] - -... -*/ - -var MooTools = { - 'version': '1.2.4', - 'build': '0d9113241a90b9cd5643b926795852a2026710d4' -}; - -var Native = function(options){ - options = options || {}; - var name = options.name; - var legacy = options.legacy; - var protect = options.protect; - var methods = options.implement; - var generics = options.generics; - var initialize = options.initialize; - var afterImplement = options.afterImplement || function(){}; - var object = initialize || legacy; - generics = generics !== false; - - object.constructor = Native; - object.$family = {name: 'native'}; - if (legacy && initialize) object.prototype = legacy.prototype; - object.prototype.constructor = object; - - if (name){ - var family = name.toLowerCase(); - object.prototype.$family = {name: family}; - Native.typize(object, family); - } - - var add = function(obj, name, method, force){ - if (!protect || force || !obj.prototype[name]) obj.prototype[name] = method; - if (generics) Native.genericize(obj, name, protect); - afterImplement.call(obj, name, method); - return obj; - }; - - object.alias = function(a1, a2, a3){ - if (typeof a1 == 'string'){ - var pa1 = this.prototype[a1]; - if ((a1 = pa1)) return add(this, a2, a1, a3); - } - for (var a in a1) this.alias(a, a1[a], a2); - return this; - }; - - object.implement = function(a1, a2, a3){ - if (typeof a1 == 'string') return add(this, a1, a2, a3); - for (var p in a1) add(this, p, a1[p], a2); - return this; - }; - - if (methods) object.implement(methods); - - return object; -}; - -Native.genericize = function(object, property, check){ - if ((!check || !object[property]) && typeof object.prototype[property] == 'function') object[property] = function(){ - var args = Array.prototype.slice.call(arguments); - return object.prototype[property].apply(args.shift(), args); - }; -}; - -Native.implement = function(objects, properties){ - for (var i = 0, l = objects.length; i < l; i++) objects[i].implement(properties); -}; - -Native.typize = function(object, family){ - if (!object.type) object.type = function(item){ - return ($type(item) === family); - }; -}; - -(function(){ - var natives = {'Array': Array, 'Date': Date, 'Function': Function, 'Number': Number, 'RegExp': RegExp, 'String': String}; - for (var n in natives) new Native({name: n, initialize: natives[n], protect: true}); - - var types = {'boolean': Boolean, 'native': Native, 'object': Object}; - for (var t in types) Native.typize(types[t], t); - - var generics = { - 'Array': ["concat", "indexOf", "join", "lastIndexOf", "pop", "push", "reverse", "shift", "slice", "sort", "splice", "toString", "unshift", "valueOf"], - 'String': ["charAt", "charCodeAt", "concat", "indexOf", "lastIndexOf", "match", "replace", "search", "slice", "split", "substr", "substring", "toLowerCase", "toUpperCase", "valueOf"] - }; - for (var g in generics){ - for (var i = generics[g].length; i--;) Native.genericize(natives[g], generics[g][i], true); - } -})(); - -var Hash = new Native({ - - name: 'Hash', - - initialize: function(object){ - if ($type(object) == 'hash') object = $unlink(object.getClean()); - for (var key in object) this[key] = object[key]; - return this; - } - -}); - -Hash.implement({ - - forEach: function(fn, bind){ - for (var key in this){ - if (this.hasOwnProperty(key)) fn.call(bind, this[key], key, this); - } - }, - - getClean: function(){ - var clean = {}; - for (var key in this){ - if (this.hasOwnProperty(key)) clean[key] = this[key]; - } - return clean; - }, - - getLength: function(){ - var length = 0; - for (var key in this){ - if (this.hasOwnProperty(key)) length++; - } - return length; - } - -}); - -Hash.alias('forEach', 'each'); - -Array.implement({ - - forEach: function(fn, bind){ - for (var i = 0, l = this.length; i < l; i++) fn.call(bind, this[i], i, this); - } - -}); - -Array.alias('forEach', 'each'); - -function $A(iterable){ - if (iterable.item){ - var l = iterable.length, array = new Array(l); - while (l--) array[l] = iterable[l]; - return array; - } - return Array.prototype.slice.call(iterable); -}; - -function $arguments(i){ - return function(){ - return arguments[i]; - }; -}; - -function $chk(obj){ - return !!(obj || obj === 0); -}; - -function $clear(timer){ - clearTimeout(timer); - clearInterval(timer); - return null; -}; - -function $defined(obj){ - return (obj != undefined); -}; - -function $each(iterable, fn, bind){ - var type = $type(iterable); - ((type == 'arguments' || type == 'collection' || type == 'array') ? Array : Hash).each(iterable, fn, bind); -}; - -function $empty(){}; - -function $extend(original, extended){ - for (var key in (extended || {})) original[key] = extended[key]; - return original; -}; - -function $H(object){ - return new Hash(object); -}; - -function $lambda(value){ - return ($type(value) == 'function') ? value : function(){ - return value; - }; -}; - -function $merge(){ - var args = Array.slice(arguments); - args.unshift({}); - return $mixin.apply(null, args); -}; - -function $mixin(mix){ - for (var i = 1, l = arguments.length; i < l; i++){ - var object = arguments[i]; - if ($type(object) != 'object') continue; - for (var key in object){ - var op = object[key], mp = mix[key]; - mix[key] = (mp && $type(op) == 'object' && $type(mp) == 'object') ? $mixin(mp, op) : $unlink(op); - } - } - return mix; -}; - -function $pick(){ - for (var i = 0, l = arguments.length; i < l; i++){ - if (arguments[i] != undefined) return arguments[i]; - } - return null; -}; - -function $random(min, max){ - return Math.floor(Math.random() * (max - min + 1) + min); -}; - -function $splat(obj){ - var type = $type(obj); - return (type) ? ((type != 'array' && type != 'arguments') ? [obj] : obj) : []; -}; - -var $time = Date.now || function(){ - return +new Date; -}; - -function $try(){ - for (var i = 0, l = arguments.length; i < l; i++){ - try { - return arguments[i](); - } catch(e){} - } - return null; -}; - -function $type(obj){ - if (obj == undefined) return false; - if (obj.$family) return (obj.$family.name == 'number' && !isFinite(obj)) ? false : obj.$family.name; - if (obj.nodeName){ - switch (obj.nodeType){ - case 1: return 'element'; - case 3: return (/\S/).test(obj.nodeValue) ? 'textnode' : 'whitespace'; - } - } else if (typeof obj.length == 'number'){ - if (obj.callee) return 'arguments'; - else if (obj.item) return 'collection'; - } - return typeof obj; -}; - -function $unlink(object){ - var unlinked; - switch ($type(object)){ - case 'object': - unlinked = {}; - for (var p in object) unlinked[p] = $unlink(object[p]); - break; - case 'hash': - unlinked = new Hash(object); - break; - case 'array': - unlinked = []; - for (var i = 0, l = object.length; i < l; i++) unlinked[i] = $unlink(object[i]); - break; - default: return object; - } - return unlinked; -}; - - -/* ---- - -script: Browser.js - -description: The Browser Core. Contains Browser initialization, Window and Document, and the Browser Hash. - -license: MIT-style license. - -requires: -- /Native -- /$util - -provides: [Browser, Window, Document, $exec] - -... -*/ - -var Browser = $merge({ - - Engine: {name: 'unknown', version: 0}, - - Platform: {name: (window.orientation != undefined) ? 'ipod' : (navigator.platform.match(/mac|win|linux/i) || ['other'])[0].toLowerCase()}, - - Features: {xpath: !!(document.evaluate), air: !!(window.runtime), query: !!(document.querySelector)}, - - Plugins: {}, - - Engines: { - - presto: function(){ - return (!window.opera) ? false : ((arguments.callee.caller) ? 960 : ((document.getElementsByClassName) ? 950 : 925)); - }, - - trident: function(){ - return (!window.ActiveXObject) ? false : ((window.XMLHttpRequest) ? ((document.querySelectorAll) ? 6 : 5) : 4); - }, - - webkit: function(){ - return (navigator.taintEnabled) ? false : ((Browser.Features.xpath) ? ((Browser.Features.query) ? 525 : 420) : 419); - }, - - gecko: function(){ - return (!document.getBoxObjectFor && window.mozInnerScreenX == null) ? false : ((document.getElementsByClassName) ? 19 : 18); - } - - } - -}, Browser || {}); - -Browser.Platform[Browser.Platform.name] = true; - -Browser.detect = function(){ - - for (var engine in this.Engines){ - var version = this.Engines[engine](); - if (version){ - this.Engine = {name: engine, version: version}; - this.Engine[engine] = this.Engine[engine + version] = true; - break; - } - } - - return {name: engine, version: version}; - -}; - -Browser.detect(); - -Browser.Request = function(){ - return $try(function(){ - return new XMLHttpRequest(); - }, function(){ - return new ActiveXObject('MSXML2.XMLHTTP'); - }, function(){ - return new ActiveXObject('Microsoft.XMLHTTP'); - }); -}; - -Browser.Features.xhr = !!(Browser.Request()); - -Browser.Plugins.Flash = (function(){ - var version = ($try(function(){ - return navigator.plugins['Shockwave Flash'].description; - }, function(){ - return new ActiveXObject('ShockwaveFlash.ShockwaveFlash').GetVariable('$version'); - }) || '0 r0').match(/\d+/g); - return {version: parseInt(version[0] || 0 + '.' + version[1], 10) || 0, build: parseInt(version[2], 10) || 0}; -})(); - -function $exec(text){ - if (!text) return text; - if (window.execScript){ - window.execScript(text); - } else { - var script = document.createElement('script'); - script.setAttribute('type', 'text/javascript'); - script[(Browser.Engine.webkit && Browser.Engine.version < 420) ? 'innerText' : 'text'] = text; - document.head.appendChild(script); - document.head.removeChild(script); - } - return text; -}; - -Native.UID = 1; - -var $uid = (Browser.Engine.trident) ? function(item){ - return (item.uid || (item.uid = [Native.UID++]))[0]; -} : function(item){ - return item.uid || (item.uid = Native.UID++); -}; - -var Window = new Native({ - - name: 'Window', - - legacy: (Browser.Engine.trident) ? null: window.Window, - - initialize: function(win){ - $uid(win); - if (!win.Element){ - win.Element = $empty; - if (Browser.Engine.webkit) win.document.createElement("iframe"); //fixes safari 2 - win.Element.prototype = (Browser.Engine.webkit) ? window["[[DOMElement.prototype]]"] : {}; - } - win.document.window = win; - return $extend(win, Window.Prototype); - }, - - afterImplement: function(property, value){ - window[property] = Window.Prototype[property] = value; - } - -}); - -Window.Prototype = {$family: {name: 'window'}}; - -new Window(window); - -var Document = new Native({ - - name: 'Document', - - legacy: (Browser.Engine.trident) ? null: window.Document, - - initialize: function(doc){ - $uid(doc); - doc.head = doc.getElementsByTagName('head')[0]; - doc.html = doc.getElementsByTagName('html')[0]; - if (Browser.Engine.trident && Browser.Engine.version <= 4) $try(function(){ - doc.execCommand("BackgroundImageCache", false, true); - }); - if (Browser.Engine.trident) doc.window.attachEvent('onunload', function(){ - doc.window.detachEvent('onunload', arguments.callee); - doc.head = doc.html = doc.window = null; - }); - return $extend(doc, Document.Prototype); - }, - - afterImplement: function(property, value){ - document[property] = Document.Prototype[property] = value; - } - -}); - -Document.Prototype = {$family: {name: 'document'}}; - -new Document(document); - - -/* ---- - -script: Array.js - -description: Contains Array Prototypes like each, contains, and erase. - -license: MIT-style license. - -requires: -- /$util -- /Array.each - -provides: [Array] - -... -*/ - -Array.implement({ - - every: function(fn, bind){ - for (var i = 0, l = this.length; i < l; i++){ - if (!fn.call(bind, this[i], i, this)) return false; - } - return true; - }, - - filter: function(fn, bind){ - var results = []; - for (var i = 0, l = this.length; i < l; i++){ - if (fn.call(bind, this[i], i, this)) results.push(this[i]); - } - return results; - }, - - clean: function(){ - return this.filter($defined); - }, - - indexOf: function(item, from){ - var len = this.length; - for (var i = (from < 0) ? Math.max(0, len + from) : from || 0; i < len; i++){ - if (this[i] === item) return i; - } - return -1; - }, - - map: function(fn, bind){ - var results = []; - for (var i = 0, l = this.length; i < l; i++) results[i] = fn.call(bind, this[i], i, this); - return results; - }, - - some: function(fn, bind){ - for (var i = 0, l = this.length; i < l; i++){ - if (fn.call(bind, this[i], i, this)) return true; - } - return false; - }, - - associate: function(keys){ - var obj = {}, length = Math.min(this.length, keys.length); - for (var i = 0; i < length; i++) obj[keys[i]] = this[i]; - return obj; - }, - - link: function(object){ - var result = {}; - for (var i = 0, l = this.length; i < l; i++){ - for (var key in object){ - if (object[key](this[i])){ - result[key] = this[i]; - delete object[key]; - break; - } - } - } - return result; - }, - - contains: function(item, from){ - return this.indexOf(item, from) != -1; - }, - - extend: function(array){ - for (var i = 0, j = array.length; i < j; i++) this.push(array[i]); - return this; - }, - - getLast: function(){ - return (this.length) ? this[this.length - 1] : null; - }, - - getRandom: function(){ - return (this.length) ? this[$random(0, this.length - 1)] : null; - }, - - include: function(item){ - if (!this.contains(item)) this.push(item); - return this; - }, - - combine: function(array){ - for (var i = 0, l = array.length; i < l; i++) this.include(array[i]); - return this; - }, - - erase: function(item){ - for (var i = this.length; i--; i){ - if (this[i] === item) this.splice(i, 1); - } - return this; - }, - - empty: function(){ - this.length = 0; - return this; - }, - - flatten: function(){ - var array = []; - for (var i = 0, l = this.length; i < l; i++){ - var type = $type(this[i]); - if (!type) continue; - array = array.concat((type == 'array' || type == 'collection' || type == 'arguments') ? Array.flatten(this[i]) : this[i]); - } - return array; - }, - - hexToRgb: function(array){ - if (this.length != 3) return null; - var rgb = this.map(function(value){ - if (value.length == 1) value += value; - return value.toInt(16); - }); - return (array) ? rgb : 'rgb(' + rgb + ')'; - }, - - rgbToHex: function(array){ - if (this.length < 3) return null; - if (this.length == 4 && this[3] == 0 && !array) return 'transparent'; - var hex = []; - for (var i = 0; i < 3; i++){ - var bit = (this[i] - 0).toString(16); - hex.push((bit.length == 1) ? '0' + bit : bit); - } - return (array) ? hex : '#' + hex.join(''); - } - -}); - - -/* ---- - -script: Function.js - -description: Contains Function Prototypes like create, bind, pass, and delay. - -license: MIT-style license. - -requires: -- /Native -- /$util - -provides: [Function] - -... -*/ - -Function.implement({ - - extend: function(properties){ - for (var property in properties) this[property] = properties[property]; - return this; - }, - - create: function(options){ - var self = this; - options = options || {}; - return function(event){ - var args = options.arguments; - args = (args != undefined) ? $splat(args) : Array.slice(arguments, (options.event) ? 1 : 0); - if (options.event) args = [event || window.event].extend(args); - var returns = function(){ - return self.apply(options.bind || null, args); - }; - if (options.delay) return setTimeout(returns, options.delay); - if (options.periodical) return setInterval(returns, options.periodical); - if (options.attempt) return $try(returns); - return returns(); - }; - }, - - run: function(args, bind){ - return this.apply(bind, $splat(args)); - }, - - pass: function(args, bind){ - return this.create({bind: bind, arguments: args}); - }, - - bind: function(bind, args){ - return this.create({bind: bind, arguments: args}); - }, - - bindWithEvent: function(bind, args){ - return this.create({bind: bind, arguments: args, event: true}); - }, - - attempt: function(args, bind){ - return this.create({bind: bind, arguments: args, attempt: true})(); - }, - - delay: function(delay, bind, args){ - return this.create({bind: bind, arguments: args, delay: delay})(); - }, - - periodical: function(periodical, bind, args){ - return this.create({bind: bind, arguments: args, periodical: periodical})(); - } - -}); - - -/* ---- - -script: Number.js - -description: Contains Number Prototypes like limit, round, times, and ceil. - -license: MIT-style license. - -requires: -- /Native -- /$util - -provides: [Number] - -... -*/ - -Number.implement({ - - limit: function(min, max){ - return Math.min(max, Math.max(min, this)); - }, - - round: function(precision){ - precision = Math.pow(10, precision || 0); - return Math.round(this * precision) / precision; - }, - - times: function(fn, bind){ - for (var i = 0; i < this; i++) fn.call(bind, i, this); - }, - - toFloat: function(){ - return parseFloat(this); - }, - - toInt: function(base){ - return parseInt(this, base || 10); - } - -}); - -Number.alias('times', 'each'); - -(function(math){ - var methods = {}; - math.each(function(name){ - if (!Number[name]) methods[name] = function(){ - return Math[name].apply(null, [this].concat($A(arguments))); - }; - }); - Number.implement(methods); -})(['abs', 'acos', 'asin', 'atan', 'atan2', 'ceil', 'cos', 'exp', 'floor', 'log', 'max', 'min', 'pow', 'sin', 'sqrt', 'tan']); - - -/* ---- - -script: String.js - -description: Contains String Prototypes like camelCase, capitalize, test, and toInt. - -license: MIT-style license. - -requires: -- /Native - -provides: [String] - -... -*/ - -String.implement({ - - test: function(regex, params){ - return ((typeof regex == 'string') ? new RegExp(regex, params) : regex).test(this); - }, - - contains: function(string, separator){ - return (separator) ? (separator + this + separator).indexOf(separator + string + separator) > -1 : this.indexOf(string) > -1; - }, - - trim: function(){ - return this.replace(/^\s+|\s+$/g, ''); - }, - - clean: function(){ - return this.replace(/\s+/g, ' ').trim(); - }, - - camelCase: function(){ - return this.replace(/-\D/g, function(match){ - return match.charAt(1).toUpperCase(); - }); - }, - - hyphenate: function(){ - return this.replace(/[A-Z]/g, function(match){ - return ('-' + match.charAt(0).toLowerCase()); - }); - }, - - capitalize: function(){ - return this.replace(/\b[a-z]/g, function(match){ - return match.toUpperCase(); - }); - }, - - escapeRegExp: function(){ - return this.replace(/([-.*+?^${}()|[\]\/\\])/g, '\\$1'); - }, - - toInt: function(base){ - return parseInt(this, base || 10); - }, - - toFloat: function(){ - return parseFloat(this); - }, - - hexToRgb: function(array){ - var hex = this.match(/^#?(\w{1,2})(\w{1,2})(\w{1,2})$/); - return (hex) ? hex.slice(1).hexToRgb(array) : null; - }, - - rgbToHex: function(array){ - var rgb = this.match(/\d{1,3}/g); - return (rgb) ? rgb.rgbToHex(array) : null; - }, - - stripScripts: function(option){ - var scripts = ''; - var text = this.replace(/]*>([\s\S]*?)<\/script>/gi, function(){ - scripts += arguments[1] + '\n'; - return ''; - }); - if (option === true) $exec(scripts); - else if ($type(option) == 'function') option(scripts, text); - return text; - }, - - substitute: function(object, regexp){ - return this.replace(regexp || (/\\?\{([^{}]+)\}/g), function(match, name){ - if (match.charAt(0) == '\\') return match.slice(1); - return (object[name] != undefined) ? object[name] : ''; - }); - } - -}); - - -/* ---- - -script: Hash.js - -description: Contains Hash Prototypes. Provides a means for overcoming the JavaScript practical impossibility of extending native Objects. - -license: MIT-style license. - -requires: -- /Hash.base - -provides: [Hash] - -... -*/ - -Hash.implement({ - - has: Object.prototype.hasOwnProperty, - - keyOf: function(value){ - for (var key in this){ - if (this.hasOwnProperty(key) && this[key] === value) return key; - } - return null; - }, - - hasValue: function(value){ - return (Hash.keyOf(this, value) !== null); - }, - - extend: function(properties){ - Hash.each(properties || {}, function(value, key){ - Hash.set(this, key, value); - }, this); - return this; - }, - - combine: function(properties){ - Hash.each(properties || {}, function(value, key){ - Hash.include(this, key, value); - }, this); - return this; - }, - - erase: function(key){ - if (this.hasOwnProperty(key)) delete this[key]; - return this; - }, - - get: function(key){ - return (this.hasOwnProperty(key)) ? this[key] : null; - }, - - set: function(key, value){ - if (!this[key] || this.hasOwnProperty(key)) this[key] = value; - return this; - }, - - empty: function(){ - Hash.each(this, function(value, key){ - delete this[key]; - }, this); - return this; - }, - - include: function(key, value){ - if (this[key] == undefined) this[key] = value; - return this; - }, - - map: function(fn, bind){ - var results = new Hash; - Hash.each(this, function(value, key){ - results.set(key, fn.call(bind, value, key, this)); - }, this); - return results; - }, - - filter: function(fn, bind){ - var results = new Hash; - Hash.each(this, function(value, key){ - if (fn.call(bind, value, key, this)) results.set(key, value); - }, this); - return results; - }, - - every: function(fn, bind){ - for (var key in this){ - if (this.hasOwnProperty(key) && !fn.call(bind, this[key], key)) return false; - } - return true; - }, - - some: function(fn, bind){ - for (var key in this){ - if (this.hasOwnProperty(key) && fn.call(bind, this[key], key)) return true; - } - return false; - }, - - getKeys: function(){ - var keys = []; - Hash.each(this, function(value, key){ - keys.push(key); - }); - return keys; - }, - - getValues: function(){ - var values = []; - Hash.each(this, function(value){ - values.push(value); - }); - return values; - }, - - toQueryString: function(base){ - var queryString = []; - Hash.each(this, function(value, key){ - if (base) key = base + '[' + key + ']'; - var result; - switch ($type(value)){ - case 'object': result = Hash.toQueryString(value, key); break; - case 'array': - var qs = {}; - value.each(function(val, i){ - qs[i] = val; - }); - result = Hash.toQueryString(qs, key); - break; - default: result = key + '=' + encodeURIComponent(value); - } - if (value != undefined) queryString.push(result); - }); - - return queryString.join('&'); - } - -}); - -Hash.alias({keyOf: 'indexOf', hasValue: 'contains'}); - - -/* ---- - -script: Event.js - -description: Contains the Event Class, to make the event object cross-browser. - -license: MIT-style license. - -requires: -- /Window -- /Document -- /Hash -- /Array -- /Function -- /String - -provides: [Event] - -... -*/ - -var Event = new Native({ - - name: 'Event', - - initialize: function(event, win){ - win = win || window; - var doc = win.document; - event = event || win.event; - if (event.$extended) return event; - this.$extended = true; - var type = event.type; - var target = event.target || event.srcElement; - while (target && target.nodeType == 3) target = target.parentNode; - - if (type.test(/key/)){ - var code = event.which || event.keyCode; - var key = Event.Keys.keyOf(code); - if (type == 'keydown'){ - var fKey = code - 111; - if (fKey > 0 && fKey < 13) key = 'f' + fKey; - } - key = key || String.fromCharCode(code).toLowerCase(); - } else if (type.match(/(click|mouse|menu)/i)){ - doc = (!doc.compatMode || doc.compatMode == 'CSS1Compat') ? doc.html : doc.body; - var page = { - x: event.pageX || event.clientX + doc.scrollLeft, - y: event.pageY || event.clientY + doc.scrollTop - }; - var client = { - x: (event.pageX) ? event.pageX - win.pageXOffset : event.clientX, - y: (event.pageY) ? event.pageY - win.pageYOffset : event.clientY - }; - if (type.match(/DOMMouseScroll|mousewheel/)){ - var wheel = (event.wheelDelta) ? event.wheelDelta / 120 : -(event.detail || 0) / 3; - } - var rightClick = (event.which == 3) || (event.button == 2); - var related = null; - if (type.match(/over|out/)){ - switch (type){ - case 'mouseover': related = event.relatedTarget || event.fromElement; break; - case 'mouseout': related = event.relatedTarget || event.toElement; - } - if (!(function(){ - while (related && related.nodeType == 3) related = related.parentNode; - return true; - }).create({attempt: Browser.Engine.gecko})()) related = false; - } - } - - return $extend(this, { - event: event, - type: type, - - page: page, - client: client, - rightClick: rightClick, - - wheel: wheel, - - relatedTarget: related, - target: target, - - code: code, - key: key, - - shift: event.shiftKey, - control: event.ctrlKey, - alt: event.altKey, - meta: event.metaKey - }); - } - -}); - -Event.Keys = new Hash({ - 'enter': 13, - 'up': 38, - 'down': 40, - 'left': 37, - 'right': 39, - 'esc': 27, - 'space': 32, - 'backspace': 8, - 'tab': 9, - 'delete': 46 -}); - -Event.implement({ - - stop: function(){ - return this.stopPropagation().preventDefault(); - }, - - stopPropagation: function(){ - if (this.event.stopPropagation) this.event.stopPropagation(); - else this.event.cancelBubble = true; - return this; - }, - - preventDefault: function(){ - if (this.event.preventDefault) this.event.preventDefault(); - else this.event.returnValue = false; - return this; - } - -}); - - -/* ---- - -script: Class.js - -description: Contains the Class Function for easily creating, extending, and implementing reusable Classes. - -license: MIT-style license. - -requires: -- /$util -- /Native -- /Array -- /String -- /Function -- /Number -- /Hash - -provides: [Class] - -... -*/ - -function Class(params){ - - if (params instanceof Function) params = {initialize: params}; - - var newClass = function(){ - Object.reset(this); - if (newClass._prototyping) return this; - this._current = $empty; - var value = (this.initialize) ? this.initialize.apply(this, arguments) : this; - delete this._current; delete this.caller; - return value; - }.extend(this); - - newClass.implement(params); - - newClass.constructor = Class; - newClass.prototype.constructor = newClass; - - return newClass; - -}; - -Function.prototype.protect = function(){ - this._protected = true; - return this; -}; - -Object.reset = function(object, key){ - - if (key == null){ - for (var p in object) Object.reset(object, p); - return object; - } - - delete object[key]; - - switch ($type(object[key])){ - case 'object': - var F = function(){}; - F.prototype = object[key]; - var i = new F; - object[key] = Object.reset(i); - break; - case 'array': object[key] = $unlink(object[key]); break; - } - - return object; - -}; - -new Native({name: 'Class', initialize: Class}).extend({ - - instantiate: function(F){ - F._prototyping = true; - var proto = new F; - delete F._prototyping; - return proto; - }, - - wrap: function(self, key, method){ - if (method._origin) method = method._origin; - - return function(){ - if (method._protected && this._current == null) throw new Error('The method "' + key + '" cannot be called.'); - var caller = this.caller, current = this._current; - this.caller = current; this._current = arguments.callee; - var result = method.apply(this, arguments); - this._current = current; this.caller = caller; - return result; - }.extend({_owner: self, _origin: method, _name: key}); - - } - -}); - -Class.implement({ - - implement: function(key, value){ - - if ($type(key) == 'object'){ - for (var p in key) this.implement(p, key[p]); - return this; - } - - var mutator = Class.Mutators[key]; - - if (mutator){ - value = mutator.call(this, value); - if (value == null) return this; - } - - var proto = this.prototype; - - switch ($type(value)){ - - case 'function': - if (value._hidden) return this; - proto[key] = Class.wrap(this, key, value); - break; - - case 'object': - var previous = proto[key]; - if ($type(previous) == 'object') $mixin(previous, value); - else proto[key] = $unlink(value); - break; - - case 'array': - proto[key] = $unlink(value); - break; - - default: proto[key] = value; - - } - - return this; - - } - -}); - -Class.Mutators = { - - Extends: function(parent){ - - this.parent = parent; - this.prototype = Class.instantiate(parent); - - this.implement('parent', function(){ - var name = this.caller._name, previous = this.caller._owner.parent.prototype[name]; - if (!previous) throw new Error('The method "' + name + '" has no parent.'); - return previous.apply(this, arguments); - }.protect()); - - }, - - Implements: function(items){ - $splat(items).each(function(item){ - if (item instanceof Function) item = Class.instantiate(item); - this.implement(item); - }, this); - - } - -}; - - -/* ---- - -script: Class.Extras.js - -description: Contains Utility Classes that can be implemented into your own Classes to ease the execution of many common tasks. - -license: MIT-style license. - -requires: -- /Class - -provides: [Chain, Events, Options] - -... -*/ - -var Chain = new Class({ - - $chain: [], - - chain: function(){ - this.$chain.extend(Array.flatten(arguments)); - return this; - }, - - callChain: function(){ - return (this.$chain.length) ? this.$chain.shift().apply(this, arguments) : false; - }, - - clearChain: function(){ - this.$chain.empty(); - return this; - } - -}); - -var Events = new Class({ - - $events: {}, - - addEvent: function(type, fn, internal){ - type = Events.removeOn(type); - if (fn != $empty){ - this.$events[type] = this.$events[type] || []; - this.$events[type].include(fn); - if (internal) fn.internal = true; - } - return this; - }, - - addEvents: function(events){ - for (var type in events) this.addEvent(type, events[type]); - return this; - }, - - fireEvent: function(type, args, delay){ - type = Events.removeOn(type); - if (!this.$events || !this.$events[type]) return this; - this.$events[type].each(function(fn){ - fn.create({'bind': this, 'delay': delay, 'arguments': args})(); - }, this); - return this; - }, - - removeEvent: function(type, fn){ - type = Events.removeOn(type); - if (!this.$events[type]) return this; - if (!fn.internal) this.$events[type].erase(fn); - return this; - }, - - removeEvents: function(events){ - var type; - if ($type(events) == 'object'){ - for (type in events) this.removeEvent(type, events[type]); - return this; - } - if (events) events = Events.removeOn(events); - for (type in this.$events){ - if (events && events != type) continue; - var fns = this.$events[type]; - for (var i = fns.length; i--; i) this.removeEvent(type, fns[i]); - } - return this; - } - -}); - -Events.removeOn = function(string){ - return string.replace(/^on([A-Z])/, function(full, first){ - return first.toLowerCase(); - }); -}; - -var Options = new Class({ - - setOptions: function(){ - this.options = $merge.run([this.options].extend(arguments)); - if (!this.addEvent) return this; - for (var option in this.options){ - if ($type(this.options[option]) != 'function' || !(/^on[A-Z]/).test(option)) continue; - this.addEvent(option, this.options[option]); - delete this.options[option]; - } - return this; - } - -}); - - -/* ---- - -script: Element.js - -description: One of the most important items in MooTools. Contains the dollar function, the dollars function, and an handful of cross-browser, time-saver methods to let you easily work with HTML Elements. - -license: MIT-style license. - -requires: -- /Window -- /Document -- /Array -- /String -- /Function -- /Number -- /Hash - -provides: [Element, Elements, $, $$, Iframe] - -... -*/ - -var Element = new Native({ - - name: 'Element', - - legacy: window.Element, - - initialize: function(tag, props){ - var konstructor = Element.Constructors.get(tag); - if (konstructor) return konstructor(props); - if (typeof tag == 'string') return document.newElement(tag, props); - return document.id(tag).set(props); - }, - - afterImplement: function(key, value){ - Element.Prototype[key] = value; - if (Array[key]) return; - Elements.implement(key, function(){ - var items = [], elements = true; - for (var i = 0, j = this.length; i < j; i++){ - var returns = this[i][key].apply(this[i], arguments); - items.push(returns); - if (elements) elements = ($type(returns) == 'element'); - } - return (elements) ? new Elements(items) : items; - }); - } - -}); - -Element.Prototype = {$family: {name: 'element'}}; - -Element.Constructors = new Hash; - -var IFrame = new Native({ - - name: 'IFrame', - - generics: false, - - initialize: function(){ - var params = Array.link(arguments, {properties: Object.type, iframe: $defined}); - var props = params.properties || {}; - var iframe = document.id(params.iframe); - var onload = props.onload || $empty; - delete props.onload; - props.id = props.name = $pick(props.id, props.name, iframe ? (iframe.id || iframe.name) : 'IFrame_' + $time()); - iframe = new Element(iframe || 'iframe', props); - var onFrameLoad = function(){ - var host = $try(function(){ - return iframe.contentWindow.location.host; - }); - if (!host || host == window.location.host){ - var win = new Window(iframe.contentWindow); - new Document(iframe.contentWindow.document); - $extend(win.Element.prototype, Element.Prototype); - } - onload.call(iframe.contentWindow, iframe.contentWindow.document); - }; - var contentWindow = $try(function(){ - return iframe.contentWindow; - }); - ((contentWindow && contentWindow.document.body) || window.frames[props.id]) ? onFrameLoad() : iframe.addListener('load', onFrameLoad); - return iframe; - } - -}); - -var Elements = new Native({ - - initialize: function(elements, options){ - options = $extend({ddup: true, cash: true}, options); - elements = elements || []; - if (options.ddup || options.cash){ - var uniques = {}, returned = []; - for (var i = 0, l = elements.length; i < l; i++){ - var el = document.id(elements[i], !options.cash); - if (options.ddup){ - if (uniques[el.uid]) continue; - uniques[el.uid] = true; - } - if (el) returned.push(el); - } - elements = returned; - } - return (options.cash) ? $extend(elements, this) : elements; - } - -}); - -Elements.implement({ - - filter: function(filter, bind){ - if (!filter) return this; - return new Elements(Array.filter(this, (typeof filter == 'string') ? function(item){ - return item.match(filter); - } : filter, bind)); - } - -}); - -Document.implement({ - - newElement: function(tag, props){ - if (Browser.Engine.trident && props){ - ['name', 'type', 'checked'].each(function(attribute){ - if (!props[attribute]) return; - tag += ' ' + attribute + '="' + props[attribute] + '"'; - if (attribute != 'checked') delete props[attribute]; - }); - tag = '<' + tag + '>'; - } - return document.id(this.createElement(tag)).set(props); - }, - - newTextNode: function(text){ - return this.createTextNode(text); - }, - - getDocument: function(){ - return this; - }, - - getWindow: function(){ - return this.window; - }, - - id: (function(){ - - var types = { - - string: function(id, nocash, doc){ - id = doc.getElementById(id); - return (id) ? types.element(id, nocash) : null; - }, - - element: function(el, nocash){ - $uid(el); - if (!nocash && !el.$family && !(/^object|embed$/i).test(el.tagName)){ - var proto = Element.Prototype; - for (var p in proto) el[p] = proto[p]; - }; - return el; - }, - - object: function(obj, nocash, doc){ - if (obj.toElement) return types.element(obj.toElement(doc), nocash); - return null; - } - - }; - - types.textnode = types.whitespace = types.window = types.document = $arguments(0); - - return function(el, nocash, doc){ - if (el && el.$family && el.uid) return el; - var type = $type(el); - return (types[type]) ? types[type](el, nocash, doc || document) : null; - }; - - })() - -}); - -if (window.$ == null) Window.implement({ - $: function(el, nc){ - return document.id(el, nc, this.document); - } -}); - -Window.implement({ - - $$: function(selector){ - if (arguments.length == 1 && typeof selector == 'string') return this.document.getElements(selector); - var elements = []; - var args = Array.flatten(arguments); - for (var i = 0, l = args.length; i < l; i++){ - var item = args[i]; - switch ($type(item)){ - case 'element': elements.push(item); break; - case 'string': elements.extend(this.document.getElements(item, true)); - } - } - return new Elements(elements); - }, - - getDocument: function(){ - return this.document; - }, - - getWindow: function(){ - return this; - } - -}); - -Native.implement([Element, Document], { - - getElement: function(selector, nocash){ - return document.id(this.getElements(selector, true)[0] || null, nocash); - }, - - getElements: function(tags, nocash){ - tags = tags.split(','); - var elements = []; - var ddup = (tags.length > 1); - tags.each(function(tag){ - var partial = this.getElementsByTagName(tag.trim()); - (ddup) ? elements.extend(partial) : elements = partial; - }, this); - return new Elements(elements, {ddup: ddup, cash: !nocash}); - } - -}); - -(function(){ - -var collected = {}, storage = {}; -var props = {input: 'checked', option: 'selected', textarea: (Browser.Engine.webkit && Browser.Engine.version < 420) ? 'innerHTML' : 'value'}; - -var get = function(uid){ - return (storage[uid] || (storage[uid] = {})); -}; - -var clean = function(item, retain){ - if (!item) return; - var uid = item.uid; - if (Browser.Engine.trident){ - if (item.clearAttributes){ - var clone = retain && item.cloneNode(false); - item.clearAttributes(); - if (clone) item.mergeAttributes(clone); - } else if (item.removeEvents){ - item.removeEvents(); - } - if ((/object/i).test(item.tagName)){ - for (var p in item){ - if (typeof item[p] == 'function') item[p] = $empty; - } - Element.dispose(item); - } - } - if (!uid) return; - collected[uid] = storage[uid] = null; -}; - -var purge = function(){ - Hash.each(collected, clean); - if (Browser.Engine.trident) $A(document.getElementsByTagName('object')).each(clean); - if (window.CollectGarbage) CollectGarbage(); - collected = storage = null; -}; - -var walk = function(element, walk, start, match, all, nocash){ - var el = element[start || walk]; - var elements = []; - while (el){ - if (el.nodeType == 1 && (!match || Element.match(el, match))){ - if (!all) return document.id(el, nocash); - elements.push(el); - } - el = el[walk]; - } - return (all) ? new Elements(elements, {ddup: false, cash: !nocash}) : null; -}; - -var attributes = { - 'html': 'innerHTML', - 'class': 'className', - 'for': 'htmlFor', - 'defaultValue': 'defaultValue', - 'text': (Browser.Engine.trident || (Browser.Engine.webkit && Browser.Engine.version < 420)) ? 'innerText' : 'textContent' -}; -var bools = ['compact', 'nowrap', 'ismap', 'declare', 'noshade', 'checked', 'disabled', 'readonly', 'multiple', 'selected', 'noresize', 'defer']; -var camels = ['value', 'type', 'defaultValue', 'accessKey', 'cellPadding', 'cellSpacing', 'colSpan', 'frameBorder', 'maxLength', 'readOnly', 'rowSpan', 'tabIndex', 'useMap']; - -bools = bools.associate(bools); - -Hash.extend(attributes, bools); -Hash.extend(attributes, camels.associate(camels.map(String.toLowerCase))); - -var inserters = { - - before: function(context, element){ - if (element.parentNode) element.parentNode.insertBefore(context, element); - }, - - after: function(context, element){ - if (!element.parentNode) return; - var next = element.nextSibling; - (next) ? element.parentNode.insertBefore(context, next) : element.parentNode.appendChild(context); - }, - - bottom: function(context, element){ - element.appendChild(context); - }, - - top: function(context, element){ - var first = element.firstChild; - (first) ? element.insertBefore(context, first) : element.appendChild(context); - } - -}; - -inserters.inside = inserters.bottom; - -Hash.each(inserters, function(inserter, where){ - - where = where.capitalize(); - - Element.implement('inject' + where, function(el){ - inserter(this, document.id(el, true)); - return this; - }); - - Element.implement('grab' + where, function(el){ - inserter(document.id(el, true), this); - return this; - }); - -}); - -Element.implement({ - - set: function(prop, value){ - switch ($type(prop)){ - case 'object': - for (var p in prop) this.set(p, prop[p]); - break; - case 'string': - var property = Element.Properties.get(prop); - (property && property.set) ? property.set.apply(this, Array.slice(arguments, 1)) : this.setProperty(prop, value); - } - return this; - }, - - get: function(prop){ - var property = Element.Properties.get(prop); - return (property && property.get) ? property.get.apply(this, Array.slice(arguments, 1)) : this.getProperty(prop); - }, - - erase: function(prop){ - var property = Element.Properties.get(prop); - (property && property.erase) ? property.erase.apply(this) : this.removeProperty(prop); - return this; - }, - - setProperty: function(attribute, value){ - var key = attributes[attribute]; - if (value == undefined) return this.removeProperty(attribute); - if (key && bools[attribute]) value = !!value; - (key) ? this[key] = value : this.setAttribute(attribute, '' + value); - return this; - }, - - setProperties: function(attributes){ - for (var attribute in attributes) this.setProperty(attribute, attributes[attribute]); - return this; - }, - - getProperty: function(attribute){ - var key = attributes[attribute]; - var value = (key) ? this[key] : this.getAttribute(attribute, 2); - return (bools[attribute]) ? !!value : (key) ? value : value || null; - }, - - getProperties: function(){ - var args = $A(arguments); - return args.map(this.getProperty, this).associate(args); - }, - - removeProperty: function(attribute){ - var key = attributes[attribute]; - (key) ? this[key] = (key && bools[attribute]) ? false : '' : this.removeAttribute(attribute); - return this; - }, - - removeProperties: function(){ - Array.each(arguments, this.removeProperty, this); - return this; - }, - - hasClass: function(className){ - return this.className.contains(className, ' '); - }, - - addClass: function(className){ - if (!this.hasClass(className)) this.className = (this.className + ' ' + className).clean(); - return this; - }, - - removeClass: function(className){ - this.className = this.className.replace(new RegExp('(^|\\s)' + className + '(?:\\s|$)'), '$1'); - return this; - }, - - toggleClass: function(className){ - return this.hasClass(className) ? this.removeClass(className) : this.addClass(className); - }, - - adopt: function(){ - Array.flatten(arguments).each(function(element){ - element = document.id(element, true); - if (element) this.appendChild(element); - }, this); - return this; - }, - - appendText: function(text, where){ - return this.grab(this.getDocument().newTextNode(text), where); - }, - - grab: function(el, where){ - inserters[where || 'bottom'](document.id(el, true), this); - return this; - }, - - inject: function(el, where){ - inserters[where || 'bottom'](this, document.id(el, true)); - return this; - }, - - replaces: function(el){ - el = document.id(el, true); - el.parentNode.replaceChild(this, el); - return this; - }, - - wraps: function(el, where){ - el = document.id(el, true); - return this.replaces(el).grab(el, where); - }, - - getPrevious: function(match, nocash){ - return walk(this, 'previousSibling', null, match, false, nocash); - }, - - getAllPrevious: function(match, nocash){ - return walk(this, 'previousSibling', null, match, true, nocash); - }, - - getNext: function(match, nocash){ - return walk(this, 'nextSibling', null, match, false, nocash); - }, - - getAllNext: function(match, nocash){ - return walk(this, 'nextSibling', null, match, true, nocash); - }, - - getFirst: function(match, nocash){ - return walk(this, 'nextSibling', 'firstChild', match, false, nocash); - }, - - getLast: function(match, nocash){ - return walk(this, 'previousSibling', 'lastChild', match, false, nocash); - }, - - getParent: function(match, nocash){ - return walk(this, 'parentNode', null, match, false, nocash); - }, - - getParents: function(match, nocash){ - return walk(this, 'parentNode', null, match, true, nocash); - }, - - getSiblings: function(match, nocash){ - return this.getParent().getChildren(match, nocash).erase(this); - }, - - getChildren: function(match, nocash){ - return walk(this, 'nextSibling', 'firstChild', match, true, nocash); - }, - - getWindow: function(){ - return this.ownerDocument.window; - }, - - getDocument: function(){ - return this.ownerDocument; - }, - - getElementById: function(id, nocash){ - var el = this.ownerDocument.getElementById(id); - if (!el) return null; - for (var parent = el.parentNode; parent != this; parent = parent.parentNode){ - if (!parent) return null; - } - return document.id(el, nocash); - }, - - getSelected: function(){ - return new Elements($A(this.options).filter(function(option){ - return option.selected; - })); - }, - - getComputedStyle: function(property){ - if (this.currentStyle) return this.currentStyle[property.camelCase()]; - var computed = this.getDocument().defaultView.getComputedStyle(this, null); - return (computed) ? computed.getPropertyValue([property.hyphenate()]) : null; - }, - - toQueryString: function(){ - var queryString = []; - this.getElements('input, select, textarea', true).each(function(el){ - if (!el.name || el.disabled || el.type == 'submit' || el.type == 'reset' || el.type == 'file') return; - var value = (el.tagName.toLowerCase() == 'select') ? Element.getSelected(el).map(function(opt){ - return opt.value; - }) : ((el.type == 'radio' || el.type == 'checkbox') && !el.checked) ? null : el.value; - $splat(value).each(function(val){ - if (typeof val != 'undefined') queryString.push(el.name + '=' + encodeURIComponent(val)); - }); - }); - return queryString.join('&'); - }, - - clone: function(contents, keepid){ - contents = contents !== false; - var clone = this.cloneNode(contents); - var clean = function(node, element){ - if (!keepid) node.removeAttribute('id'); - if (Browser.Engine.trident){ - node.clearAttributes(); - node.mergeAttributes(element); - node.removeAttribute('uid'); - if (node.options){ - var no = node.options, eo = element.options; - for (var j = no.length; j--;) no[j].selected = eo[j].selected; - } - } - var prop = props[element.tagName.toLowerCase()]; - if (prop && element[prop]) node[prop] = element[prop]; - }; - - if (contents){ - var ce = clone.getElementsByTagName('*'), te = this.getElementsByTagName('*'); - for (var i = ce.length; i--;) clean(ce[i], te[i]); - } - - clean(clone, this); - return document.id(clone); - }, - - destroy: function(){ - Element.empty(this); - Element.dispose(this); - clean(this, true); - return null; - }, - - empty: function(){ - $A(this.childNodes).each(function(node){ - Element.destroy(node); - }); - return this; - }, - - dispose: function(){ - return (this.parentNode) ? this.parentNode.removeChild(this) : this; - }, - - hasChild: function(el){ - el = document.id(el, true); - if (!el) return false; - if (Browser.Engine.webkit && Browser.Engine.version < 420) return $A(this.getElementsByTagName(el.tagName)).contains(el); - return (this.contains) ? (this != el && this.contains(el)) : !!(this.compareDocumentPosition(el) & 16); - }, - - match: function(tag){ - return (!tag || (tag == this) || (Element.get(this, 'tag') == tag)); - } - -}); - -Native.implement([Element, Window, Document], { - - addListener: function(type, fn){ - if (type == 'unload'){ - var old = fn, self = this; - fn = function(){ - self.removeListener('unload', fn); - old(); - }; - } else { - collected[this.uid] = this; - } - if (this.addEventListener) this.addEventListener(type, fn, false); - else this.attachEvent('on' + type, fn); - return this; - }, - - removeListener: function(type, fn){ - if (this.removeEventListener) this.removeEventListener(type, fn, false); - else this.detachEvent('on' + type, fn); - return this; - }, - - retrieve: function(property, dflt){ - var storage = get(this.uid), prop = storage[property]; - if (dflt != undefined && prop == undefined) prop = storage[property] = dflt; - return $pick(prop); - }, - - store: function(property, value){ - var storage = get(this.uid); - storage[property] = value; - return this; - }, - - eliminate: function(property){ - var storage = get(this.uid); - delete storage[property]; - return this; - } - -}); - -window.addListener('unload', purge); - -})(); - -Element.Properties = new Hash; - -Element.Properties.style = { - - set: function(style){ - this.style.cssText = style; - }, - - get: function(){ - return this.style.cssText; - }, - - erase: function(){ - this.style.cssText = ''; - } - -}; - -Element.Properties.tag = { - - get: function(){ - return this.tagName.toLowerCase(); - } - -}; - -Element.Properties.html = (function(){ - var wrapper = document.createElement('div'); - - var translations = { - table: [1, '', '
'], - select: [1, ''], - tbody: [2, '', '
'], - tr: [3, '', '
'] - }; - translations.thead = translations.tfoot = translations.tbody; - - var html = { - set: function(){ - var html = Array.flatten(arguments).join(''); - var wrap = Browser.Engine.trident && translations[this.get('tag')]; - if (wrap){ - var first = wrapper; - first.innerHTML = wrap[1] + html + wrap[2]; - for (var i = wrap[0]; i--;) first = first.firstChild; - this.empty().adopt(first.childNodes); - } else { - this.innerHTML = html; - } - } - }; - - html.erase = html.set; - - return html; -})(); - -if (Browser.Engine.webkit && Browser.Engine.version < 420) Element.Properties.text = { - get: function(){ - if (this.innerText) return this.innerText; - var temp = this.ownerDocument.newElement('div', {html: this.innerHTML}).inject(this.ownerDocument.body); - var text = temp.innerText; - temp.destroy(); - return text; - } -}; - - -/* ---- - -script: Element.Event.js - -description: Contains Element methods for dealing with events. This file also includes mouseenter and mouseleave custom Element Events. - -license: MIT-style license. - -requires: -- /Element -- /Event - -provides: [Element.Event] - -... -*/ - -Element.Properties.events = {set: function(events){ - this.addEvents(events); -}}; - -Native.implement([Element, Window, Document], { - - addEvent: function(type, fn){ - var events = this.retrieve('events', {}); - events[type] = events[type] || {'keys': [], 'values': []}; - if (events[type].keys.contains(fn)) return this; - events[type].keys.push(fn); - var realType = type, custom = Element.Events.get(type), condition = fn, self = this; - if (custom){ - if (custom.onAdd) custom.onAdd.call(this, fn); - if (custom.condition){ - condition = function(event){ - if (custom.condition.call(this, event)) return fn.call(this, event); - return true; - }; - } - realType = custom.base || realType; - } - var defn = function(){ - return fn.call(self); - }; - var nativeEvent = Element.NativeEvents[realType]; - if (nativeEvent){ - if (nativeEvent == 2){ - defn = function(event){ - event = new Event(event, self.getWindow()); - if (condition.call(self, event) === false) event.stop(); - }; - } - this.addListener(realType, defn); - } - events[type].values.push(defn); - return this; - }, - - removeEvent: function(type, fn){ - var events = this.retrieve('events'); - if (!events || !events[type]) return this; - var pos = events[type].keys.indexOf(fn); - if (pos == -1) return this; - events[type].keys.splice(pos, 1); - var value = events[type].values.splice(pos, 1)[0]; - var custom = Element.Events.get(type); - if (custom){ - if (custom.onRemove) custom.onRemove.call(this, fn); - type = custom.base || type; - } - return (Element.NativeEvents[type]) ? this.removeListener(type, value) : this; - }, - - addEvents: function(events){ - for (var event in events) this.addEvent(event, events[event]); - return this; - }, - - removeEvents: function(events){ - var type; - if ($type(events) == 'object'){ - for (type in events) this.removeEvent(type, events[type]); - return this; - } - var attached = this.retrieve('events'); - if (!attached) return this; - if (!events){ - for (type in attached) this.removeEvents(type); - this.eliminate('events'); - } else if (attached[events]){ - while (attached[events].keys[0]) this.removeEvent(events, attached[events].keys[0]); - attached[events] = null; - } - return this; - }, - - fireEvent: function(type, args, delay){ - var events = this.retrieve('events'); - if (!events || !events[type]) return this; - events[type].keys.each(function(fn){ - fn.create({'bind': this, 'delay': delay, 'arguments': args})(); - }, this); - return this; - }, - - cloneEvents: function(from, type){ - from = document.id(from); - var fevents = from.retrieve('events'); - if (!fevents) return this; - if (!type){ - for (var evType in fevents) this.cloneEvents(from, evType); - } else if (fevents[type]){ - fevents[type].keys.each(function(fn){ - this.addEvent(type, fn); - }, this); - } - return this; - } - -}); - -Element.NativeEvents = { - click: 2, dblclick: 2, mouseup: 2, mousedown: 2, contextmenu: 2, //mouse buttons - mousewheel: 2, DOMMouseScroll: 2, //mouse wheel - mouseover: 2, mouseout: 2, mousemove: 2, selectstart: 2, selectend: 2, //mouse movement - keydown: 2, keypress: 2, keyup: 2, //keyboard - focus: 2, blur: 2, change: 2, reset: 2, select: 2, submit: 2, //form elements - load: 1, unload: 1, beforeunload: 2, resize: 1, move: 1, DOMContentLoaded: 1, readystatechange: 1, //window - error: 1, abort: 1, scroll: 1 //misc -}; - -(function(){ - -var $check = function(event){ - var related = event.relatedTarget; - if (related == undefined) return true; - if (related === false) return false; - return ($type(this) != 'document' && related != this && related.prefix != 'xul' && !this.hasChild(related)); -}; - -Element.Events = new Hash({ - - mouseenter: { - base: 'mouseover', - condition: $check - }, - - mouseleave: { - base: 'mouseout', - condition: $check - }, - - mousewheel: { - base: (Browser.Engine.gecko) ? 'DOMMouseScroll' : 'mousewheel' - } - -}); - -})(); - - -/* ---- - -script: Element.Style.js - -description: Contains methods for interacting with the styles of Elements in a fashionable way. - -license: MIT-style license. - -requires: -- /Element - -provides: [Element.Style] - -... -*/ - -Element.Properties.styles = {set: function(styles){ - this.setStyles(styles); -}}; - -Element.Properties.opacity = { - - set: function(opacity, novisibility){ - if (!novisibility){ - if (opacity == 0){ - if (this.style.visibility != 'hidden') this.style.visibility = 'hidden'; - } else { - if (this.style.visibility != 'visible') this.style.visibility = 'visible'; - } - } - if (!this.currentStyle || !this.currentStyle.hasLayout) this.style.zoom = 1; - if (Browser.Engine.trident) this.style.filter = (opacity == 1) ? '' : 'alpha(opacity=' + opacity * 100 + ')'; - this.style.opacity = opacity; - this.store('opacity', opacity); - }, - - get: function(){ - return this.retrieve('opacity', 1); - } - -}; - -Element.implement({ - - setOpacity: function(value){ - return this.set('opacity', value, true); - }, - - getOpacity: function(){ - return this.get('opacity'); - }, - - setStyle: function(property, value){ - switch (property){ - case 'opacity': return this.set('opacity', parseFloat(value)); - case 'float': property = (Browser.Engine.trident) ? 'styleFloat' : 'cssFloat'; - } - property = property.camelCase(); - if ($type(value) != 'string'){ - var map = (Element.Styles.get(property) || '@').split(' '); - value = $splat(value).map(function(val, i){ - if (!map[i]) return ''; - return ($type(val) == 'number') ? map[i].replace('@', Math.round(val)) : val; - }).join(' '); - } else if (value == String(Number(value))){ - value = Math.round(value); - } - this.style[property] = value; - return this; - }, - - getStyle: function(property){ - switch (property){ - case 'opacity': return this.get('opacity'); - case 'float': property = (Browser.Engine.trident) ? 'styleFloat' : 'cssFloat'; - } - property = property.camelCase(); - var result = this.style[property]; - if (!$chk(result)){ - result = []; - for (var style in Element.ShortStyles){ - if (property != style) continue; - for (var s in Element.ShortStyles[style]) result.push(this.getStyle(s)); - return result.join(' '); - } - result = this.getComputedStyle(property); - } - if (result){ - result = String(result); - var color = result.match(/rgba?\([\d\s,]+\)/); - if (color) result = result.replace(color[0], color[0].rgbToHex()); - } - if (Browser.Engine.presto || (Browser.Engine.trident && !$chk(parseInt(result, 10)))){ - if (property.test(/^(height|width)$/)){ - var values = (property == 'width') ? ['left', 'right'] : ['top', 'bottom'], size = 0; - values.each(function(value){ - size += this.getStyle('border-' + value + '-width').toInt() + this.getStyle('padding-' + value).toInt(); - }, this); - return this['offset' + property.capitalize()] - size + 'px'; - } - if ((Browser.Engine.presto) && String(result).test('px')) return result; - if (property.test(/(border(.+)Width|margin|padding)/)) return '0px'; - } - return result; - }, - - setStyles: function(styles){ - for (var style in styles) this.setStyle(style, styles[style]); - return this; - }, - - getStyles: function(){ - var result = {}; - Array.flatten(arguments).each(function(key){ - result[key] = this.getStyle(key); - }, this); - return result; - } - -}); - -Element.Styles = new Hash({ - left: '@px', top: '@px', bottom: '@px', right: '@px', - width: '@px', height: '@px', maxWidth: '@px', maxHeight: '@px', minWidth: '@px', minHeight: '@px', - backgroundColor: 'rgb(@, @, @)', backgroundPosition: '@px @px', color: 'rgb(@, @, @)', - fontSize: '@px', letterSpacing: '@px', lineHeight: '@px', clip: 'rect(@px @px @px @px)', - margin: '@px @px @px @px', padding: '@px @px @px @px', border: '@px @ rgb(@, @, @) @px @ rgb(@, @, @) @px @ rgb(@, @, @)', - borderWidth: '@px @px @px @px', borderStyle: '@ @ @ @', borderColor: 'rgb(@, @, @) rgb(@, @, @) rgb(@, @, @) rgb(@, @, @)', - zIndex: '@', 'zoom': '@', fontWeight: '@', textIndent: '@px', opacity: '@' -}); - -Element.ShortStyles = {margin: {}, padding: {}, border: {}, borderWidth: {}, borderStyle: {}, borderColor: {}}; - -['Top', 'Right', 'Bottom', 'Left'].each(function(direction){ - var Short = Element.ShortStyles; - var All = Element.Styles; - ['margin', 'padding'].each(function(style){ - var sd = style + direction; - Short[style][sd] = All[sd] = '@px'; - }); - var bd = 'border' + direction; - Short.border[bd] = All[bd] = '@px @ rgb(@, @, @)'; - var bdw = bd + 'Width', bds = bd + 'Style', bdc = bd + 'Color'; - Short[bd] = {}; - Short.borderWidth[bdw] = Short[bd][bdw] = All[bdw] = '@px'; - Short.borderStyle[bds] = Short[bd][bds] = All[bds] = '@'; - Short.borderColor[bdc] = Short[bd][bdc] = All[bdc] = 'rgb(@, @, @)'; -}); - - -/* ---- - -script: Element.Dimensions.js - -description: Contains methods to work with size, scroll, or positioning of Elements and the window object. - -license: MIT-style license. - -credits: -- Element positioning based on the [qooxdoo](http://qooxdoo.org/) code and smart browser fixes, [LGPL License](http://www.gnu.org/licenses/lgpl.html). -- Viewport dimensions based on [YUI](http://developer.yahoo.com/yui/) code, [BSD License](http://developer.yahoo.com/yui/license.html). - -requires: -- /Element - -provides: [Element.Dimensions] - -... -*/ - -(function(){ - -Element.implement({ - - scrollTo: function(x, y){ - if (isBody(this)){ - this.getWindow().scrollTo(x, y); - } else { - this.scrollLeft = x; - this.scrollTop = y; - } - return this; - }, - - getSize: function(){ - if (isBody(this)) return this.getWindow().getSize(); - return {x: this.offsetWidth, y: this.offsetHeight}; - }, - - getScrollSize: function(){ - if (isBody(this)) return this.getWindow().getScrollSize(); - return {x: this.scrollWidth, y: this.scrollHeight}; - }, - - getScroll: function(){ - if (isBody(this)) return this.getWindow().getScroll(); - return {x: this.scrollLeft, y: this.scrollTop}; - }, - - getScrolls: function(){ - var element = this, position = {x: 0, y: 0}; - while (element && !isBody(element)){ - position.x += element.scrollLeft; - position.y += element.scrollTop; - element = element.parentNode; - } - return position; - }, - - getOffsetParent: function(){ - var element = this; - if (isBody(element)) return null; - if (!Browser.Engine.trident) return element.offsetParent; - while ((element = element.parentNode) && !isBody(element)){ - if (styleString(element, 'position') != 'static') return element; - } - return null; - }, - - getOffsets: function(){ - if (this.getBoundingClientRect){ - var bound = this.getBoundingClientRect(), - html = document.id(this.getDocument().documentElement), - htmlScroll = html.getScroll(), - elemScrolls = this.getScrolls(), - elemScroll = this.getScroll(), - isFixed = (styleString(this, 'position') == 'fixed'); - - return { - x: bound.left.toInt() + elemScrolls.x - elemScroll.x + ((isFixed) ? 0 : htmlScroll.x) - html.clientLeft, - y: bound.top.toInt() + elemScrolls.y - elemScroll.y + ((isFixed) ? 0 : htmlScroll.y) - html.clientTop - }; - } - - var element = this, position = {x: 0, y: 0}; - if (isBody(this)) return position; - - while (element && !isBody(element)){ - position.x += element.offsetLeft; - position.y += element.offsetTop; - - if (Browser.Engine.gecko){ - if (!borderBox(element)){ - position.x += leftBorder(element); - position.y += topBorder(element); - } - var parent = element.parentNode; - if (parent && styleString(parent, 'overflow') != 'visible'){ - position.x += leftBorder(parent); - position.y += topBorder(parent); - } - } else if (element != this && Browser.Engine.webkit){ - position.x += leftBorder(element); - position.y += topBorder(element); - } - - element = element.offsetParent; - } - if (Browser.Engine.gecko && !borderBox(this)){ - position.x -= leftBorder(this); - position.y -= topBorder(this); - } - return position; - }, - - getPosition: function(relative){ - if (isBody(this)) return {x: 0, y: 0}; - var offset = this.getOffsets(), - scroll = this.getScrolls(); - var position = { - x: offset.x - scroll.x, - y: offset.y - scroll.y - }; - var relativePosition = (relative && (relative = document.id(relative))) ? relative.getPosition() : {x: 0, y: 0}; - return {x: position.x - relativePosition.x, y: position.y - relativePosition.y}; - }, - - getCoordinates: function(element){ - if (isBody(this)) return this.getWindow().getCoordinates(); - var position = this.getPosition(element), - size = this.getSize(); - var obj = { - left: position.x, - top: position.y, - width: size.x, - height: size.y - }; - obj.right = obj.left + obj.width; - obj.bottom = obj.top + obj.height; - return obj; - }, - - computePosition: function(obj){ - return { - left: obj.x - styleNumber(this, 'margin-left'), - top: obj.y - styleNumber(this, 'margin-top') - }; - }, - - setPosition: function(obj){ - return this.setStyles(this.computePosition(obj)); - } - -}); - - -Native.implement([Document, Window], { - - getSize: function(){ - if (Browser.Engine.presto || Browser.Engine.webkit){ - var win = this.getWindow(); - return {x: win.innerWidth, y: win.innerHeight}; - } - var doc = getCompatElement(this); - return {x: doc.clientWidth, y: doc.clientHeight}; - }, - - getScroll: function(){ - var win = this.getWindow(), doc = getCompatElement(this); - return {x: win.pageXOffset || doc.scrollLeft, y: win.pageYOffset || doc.scrollTop}; - }, - - getScrollSize: function(){ - var doc = getCompatElement(this), min = this.getSize(); - return {x: Math.max(doc.scrollWidth, min.x), y: Math.max(doc.scrollHeight, min.y)}; - }, - - getPosition: function(){ - return {x: 0, y: 0}; - }, - - getCoordinates: function(){ - var size = this.getSize(); - return {top: 0, left: 0, bottom: size.y, right: size.x, height: size.y, width: size.x}; - } - -}); - -// private methods - -var styleString = Element.getComputedStyle; - -function styleNumber(element, style){ - return styleString(element, style).toInt() || 0; -}; - -function borderBox(element){ - return styleString(element, '-moz-box-sizing') == 'border-box'; -}; - -function topBorder(element){ - return styleNumber(element, 'border-top-width'); -}; - -function leftBorder(element){ - return styleNumber(element, 'border-left-width'); -}; - -function isBody(element){ - return (/^(?:body|html)$/i).test(element.tagName); -}; - -function getCompatElement(element){ - var doc = element.getDocument(); - return (!doc.compatMode || doc.compatMode == 'CSS1Compat') ? doc.html : doc.body; -}; - -})(); - -//aliases -Element.alias('setPosition', 'position'); //compatability - -Native.implement([Window, Document, Element], { - - getHeight: function(){ - return this.getSize().y; - }, - - getWidth: function(){ - return this.getSize().x; - }, - - getScrollTop: function(){ - return this.getScroll().y; - }, - - getScrollLeft: function(){ - return this.getScroll().x; - }, - - getScrollHeight: function(){ - return this.getScrollSize().y; - }, - - getScrollWidth: function(){ - return this.getScrollSize().x; - }, - - getTop: function(){ - return this.getPosition().y; - }, - - getLeft: function(){ - return this.getPosition().x; - } - -}); - - -/* ---- - -script: Selectors.js - -description: Adds advanced CSS-style querying capabilities for targeting HTML Elements. Includes pseudo selectors. - -license: MIT-style license. - -requires: -- /Element - -provides: [Selectors] - -... -*/ - -Native.implement([Document, Element], { - - getElements: function(expression, nocash){ - expression = expression.split(','); - var items, local = {}; - for (var i = 0, l = expression.length; i < l; i++){ - var selector = expression[i], elements = Selectors.Utils.search(this, selector, local); - if (i != 0 && elements.item) elements = $A(elements); - items = (i == 0) ? elements : (items.item) ? $A(items).concat(elements) : items.concat(elements); - } - return new Elements(items, {ddup: (expression.length > 1), cash: !nocash}); - } - -}); - -Element.implement({ - - match: function(selector){ - if (!selector || (selector == this)) return true; - var tagid = Selectors.Utils.parseTagAndID(selector); - var tag = tagid[0], id = tagid[1]; - if (!Selectors.Filters.byID(this, id) || !Selectors.Filters.byTag(this, tag)) return false; - var parsed = Selectors.Utils.parseSelector(selector); - return (parsed) ? Selectors.Utils.filter(this, parsed, {}) : true; - } - -}); - -var Selectors = {Cache: {nth: {}, parsed: {}}}; - -Selectors.RegExps = { - id: (/#([\w-]+)/), - tag: (/^(\w+|\*)/), - quick: (/^(\w+|\*)$/), - splitter: (/\s*([+>~\s])\s*([a-zA-Z#.*:\[])/g), - combined: (/\.([\w-]+)|\[(\w+)(?:([!*^$~|]?=)(["']?)([^\4]*?)\4)?\]|:([\w-]+)(?:\(["']?(.*?)?["']?\)|$)/g) -}; - -Selectors.Utils = { - - chk: function(item, uniques){ - if (!uniques) return true; - var uid = $uid(item); - if (!uniques[uid]) return uniques[uid] = true; - return false; - }, - - parseNthArgument: function(argument){ - if (Selectors.Cache.nth[argument]) return Selectors.Cache.nth[argument]; - var parsed = argument.match(/^([+-]?\d*)?([a-z]+)?([+-]?\d*)?$/); - if (!parsed) return false; - var inta = parseInt(parsed[1], 10); - var a = (inta || inta === 0) ? inta : 1; - var special = parsed[2] || false; - var b = parseInt(parsed[3], 10) || 0; - if (a != 0){ - b--; - while (b < 1) b += a; - while (b >= a) b -= a; - } else { - a = b; - special = 'index'; - } - switch (special){ - case 'n': parsed = {a: a, b: b, special: 'n'}; break; - case 'odd': parsed = {a: 2, b: 0, special: 'n'}; break; - case 'even': parsed = {a: 2, b: 1, special: 'n'}; break; - case 'first': parsed = {a: 0, special: 'index'}; break; - case 'last': parsed = {special: 'last-child'}; break; - case 'only': parsed = {special: 'only-child'}; break; - default: parsed = {a: (a - 1), special: 'index'}; - } - - return Selectors.Cache.nth[argument] = parsed; - }, - - parseSelector: function(selector){ - if (Selectors.Cache.parsed[selector]) return Selectors.Cache.parsed[selector]; - var m, parsed = {classes: [], pseudos: [], attributes: []}; - while ((m = Selectors.RegExps.combined.exec(selector))){ - var cn = m[1], an = m[2], ao = m[3], av = m[5], pn = m[6], pa = m[7]; - if (cn){ - parsed.classes.push(cn); - } else if (pn){ - var parser = Selectors.Pseudo.get(pn); - if (parser) parsed.pseudos.push({parser: parser, argument: pa}); - else parsed.attributes.push({name: pn, operator: '=', value: pa}); - } else if (an){ - parsed.attributes.push({name: an, operator: ao, value: av}); - } - } - if (!parsed.classes.length) delete parsed.classes; - if (!parsed.attributes.length) delete parsed.attributes; - if (!parsed.pseudos.length) delete parsed.pseudos; - if (!parsed.classes && !parsed.attributes && !parsed.pseudos) parsed = null; - return Selectors.Cache.parsed[selector] = parsed; - }, - - parseTagAndID: function(selector){ - var tag = selector.match(Selectors.RegExps.tag); - var id = selector.match(Selectors.RegExps.id); - return [(tag) ? tag[1] : '*', (id) ? id[1] : false]; - }, - - filter: function(item, parsed, local){ - var i; - if (parsed.classes){ - for (i = parsed.classes.length; i--; i){ - var cn = parsed.classes[i]; - if (!Selectors.Filters.byClass(item, cn)) return false; - } - } - if (parsed.attributes){ - for (i = parsed.attributes.length; i--; i){ - var att = parsed.attributes[i]; - if (!Selectors.Filters.byAttribute(item, att.name, att.operator, att.value)) return false; - } - } - if (parsed.pseudos){ - for (i = parsed.pseudos.length; i--; i){ - var psd = parsed.pseudos[i]; - if (!Selectors.Filters.byPseudo(item, psd.parser, psd.argument, local)) return false; - } - } - return true; - }, - - getByTagAndID: function(ctx, tag, id){ - if (id){ - var item = (ctx.getElementById) ? ctx.getElementById(id, true) : Element.getElementById(ctx, id, true); - return (item && Selectors.Filters.byTag(item, tag)) ? [item] : []; - } else { - return ctx.getElementsByTagName(tag); - } - }, - - search: function(self, expression, local){ - var splitters = []; - - var selectors = expression.trim().replace(Selectors.RegExps.splitter, function(m0, m1, m2){ - splitters.push(m1); - return ':)' + m2; - }).split(':)'); - - var items, filtered, item; - - for (var i = 0, l = selectors.length; i < l; i++){ - - var selector = selectors[i]; - - if (i == 0 && Selectors.RegExps.quick.test(selector)){ - items = self.getElementsByTagName(selector); - continue; - } - - var splitter = splitters[i - 1]; - - var tagid = Selectors.Utils.parseTagAndID(selector); - var tag = tagid[0], id = tagid[1]; - - if (i == 0){ - items = Selectors.Utils.getByTagAndID(self, tag, id); - } else { - var uniques = {}, found = []; - for (var j = 0, k = items.length; j < k; j++) found = Selectors.Getters[splitter](found, items[j], tag, id, uniques); - items = found; - } - - var parsed = Selectors.Utils.parseSelector(selector); - - if (parsed){ - filtered = []; - for (var m = 0, n = items.length; m < n; m++){ - item = items[m]; - if (Selectors.Utils.filter(item, parsed, local)) filtered.push(item); - } - items = filtered; - } - - } - - return items; - - } - -}; - -Selectors.Getters = { - - ' ': function(found, self, tag, id, uniques){ - var items = Selectors.Utils.getByTagAndID(self, tag, id); - for (var i = 0, l = items.length; i < l; i++){ - var item = items[i]; - if (Selectors.Utils.chk(item, uniques)) found.push(item); - } - return found; - }, - - '>': function(found, self, tag, id, uniques){ - var children = Selectors.Utils.getByTagAndID(self, tag, id); - for (var i = 0, l = children.length; i < l; i++){ - var child = children[i]; - if (child.parentNode == self && Selectors.Utils.chk(child, uniques)) found.push(child); - } - return found; - }, - - '+': function(found, self, tag, id, uniques){ - while ((self = self.nextSibling)){ - if (self.nodeType == 1){ - if (Selectors.Utils.chk(self, uniques) && Selectors.Filters.byTag(self, tag) && Selectors.Filters.byID(self, id)) found.push(self); - break; - } - } - return found; - }, - - '~': function(found, self, tag, id, uniques){ - while ((self = self.nextSibling)){ - if (self.nodeType == 1){ - if (!Selectors.Utils.chk(self, uniques)) break; - if (Selectors.Filters.byTag(self, tag) && Selectors.Filters.byID(self, id)) found.push(self); - } - } - return found; - } - -}; - -Selectors.Filters = { - - byTag: function(self, tag){ - return (tag == '*' || (self.tagName && self.tagName.toLowerCase() == tag)); - }, - - byID: function(self, id){ - return (!id || (self.id && self.id == id)); - }, - - byClass: function(self, klass){ - return (self.className && self.className.contains && self.className.contains(klass, ' ')); - }, - - byPseudo: function(self, parser, argument, local){ - return parser.call(self, argument, local); - }, - - byAttribute: function(self, name, operator, value){ - var result = Element.prototype.getProperty.call(self, name); - if (!result) return (operator == '!='); - if (!operator || value == undefined) return true; - switch (operator){ - case '=': return (result == value); - case '*=': return (result.contains(value)); - case '^=': return (result.substr(0, value.length) == value); - case '$=': return (result.substr(result.length - value.length) == value); - case '!=': return (result != value); - case '~=': return result.contains(value, ' '); - case '|=': return result.contains(value, '-'); - } - return false; - } - -}; - -Selectors.Pseudo = new Hash({ - - // w3c pseudo selectors - - checked: function(){ - return this.checked; - }, - - empty: function(){ - return !(this.innerText || this.textContent || '').length; - }, - - not: function(selector){ - return !Element.match(this, selector); - }, - - contains: function(text){ - return (this.innerText || this.textContent || '').contains(text); - }, - - 'first-child': function(){ - return Selectors.Pseudo.index.call(this, 0); - }, - - 'last-child': function(){ - var element = this; - while ((element = element.nextSibling)){ - if (element.nodeType == 1) return false; - } - return true; - }, - - 'only-child': function(){ - var prev = this; - while ((prev = prev.previousSibling)){ - if (prev.nodeType == 1) return false; - } - var next = this; - while ((next = next.nextSibling)){ - if (next.nodeType == 1) return false; - } - return true; - }, - - 'nth-child': function(argument, local){ - argument = (argument == undefined) ? 'n' : argument; - var parsed = Selectors.Utils.parseNthArgument(argument); - if (parsed.special != 'n') return Selectors.Pseudo[parsed.special].call(this, parsed.a, local); - var count = 0; - local.positions = local.positions || {}; - var uid = $uid(this); - if (!local.positions[uid]){ - var self = this; - while ((self = self.previousSibling)){ - if (self.nodeType != 1) continue; - count ++; - var position = local.positions[$uid(self)]; - if (position != undefined){ - count = position + count; - break; - } - } - local.positions[uid] = count; - } - return (local.positions[uid] % parsed.a == parsed.b); - }, - - // custom pseudo selectors - - index: function(index){ - var element = this, count = 0; - while ((element = element.previousSibling)){ - if (element.nodeType == 1 && ++count > index) return false; - } - return (count == index); - }, - - even: function(argument, local){ - return Selectors.Pseudo['nth-child'].call(this, '2n+1', local); - }, - - odd: function(argument, local){ - return Selectors.Pseudo['nth-child'].call(this, '2n', local); - }, - - selected: function(){ - return this.selected; - }, - - enabled: function(){ - return (this.disabled === false); - } - -}); - - -/* ---- - -script: DomReady.js - -description: Contains the custom event domready. - -license: MIT-style license. - -requires: -- /Element.Event - -provides: [DomReady] - -... -*/ - -Element.Events.domready = { - - onAdd: function(fn){ - if (Browser.loaded) fn.call(this); - } - -}; - -(function(){ - - var domready = function(){ - if (Browser.loaded) return; - Browser.loaded = true; - window.fireEvent('domready'); - document.fireEvent('domready'); - }; - - window.addEvent('load', domready); - - if (Browser.Engine.trident){ - var temp = document.createElement('div'); - (function(){ - ($try(function(){ - temp.doScroll(); // Technique by Diego Perini - return document.id(temp).inject(document.body).set('html', 'temp').dispose(); - })) ? domready() : arguments.callee.delay(50); - })(); - } else if (Browser.Engine.webkit && Browser.Engine.version < 525){ - (function(){ - (['loaded', 'complete'].contains(document.readyState)) ? domready() : arguments.callee.delay(50); - })(); - } else { - document.addEvent('DOMContentLoaded', domready); - } - -})(); - - -/* ---- - -script: JSON.js - -description: JSON encoder and decoder. - -license: MIT-style license. - -See Also: - -requires: -- /Array -- /String -- /Number -- /Function -- /Hash - -provides: [JSON] - -... -*/ - -var JSON = new Hash(this.JSON && { - stringify: JSON.stringify, - parse: JSON.parse -}).extend({ - - $specialChars: {'\b': '\\b', '\t': '\\t', '\n': '\\n', '\f': '\\f', '\r': '\\r', '"' : '\\"', '\\': '\\\\'}, - - $replaceChars: function(chr){ - return JSON.$specialChars[chr] || '\\u00' + Math.floor(chr.charCodeAt() / 16).toString(16) + (chr.charCodeAt() % 16).toString(16); - }, - - encode: function(obj){ - switch ($type(obj)){ - case 'string': - return '"' + obj.replace(/[\x00-\x1f\\"]/g, JSON.$replaceChars) + '"'; - case 'array': - return '[' + String(obj.map(JSON.encode).clean()) + ']'; - case 'object': case 'hash': - var string = []; - Hash.each(obj, function(value, key){ - var json = JSON.encode(value); - if (json) string.push(JSON.encode(key) + ':' + json); - }); - return '{' + string + '}'; - case 'number': case 'boolean': return String(obj); - case false: return 'null'; - } - return null; - }, - - decode: function(string, secure){ - if ($type(string) != 'string' || !string.length) return null; - if (secure && !(/^[,:{}\[\]0-9.\-+Eaeflnr-u \n\r\t]*$/).test(string.replace(/\\./g, '@').replace(/"[^"\\\n\r]*"/g, ''))) return null; - return eval('(' + string + ')'); - } - -}); - -Native.implement([Hash, Array, String, Number], { - - toJSON: function(){ - return JSON.encode(this); - } - -}); - - -/* ---- - -script: Cookie.js - -description: Class for creating, reading, and deleting browser Cookies. - -license: MIT-style license. - -credits: -- Based on the functions by Peter-Paul Koch (http://quirksmode.org). - -requires: -- /Options - -provides: [Cookie] - -... -*/ - -var Cookie = new Class({ - - Implements: Options, - - options: { - path: false, - domain: false, - duration: false, - secure: false, - document: document - }, - - initialize: function(key, options){ - this.key = key; - this.setOptions(options); - }, - - write: function(value){ - value = encodeURIComponent(value); - if (this.options.domain) value += '; domain=' + this.options.domain; - if (this.options.path) value += '; path=' + this.options.path; - if (this.options.duration){ - var date = new Date(); - date.setTime(date.getTime() + this.options.duration * 24 * 60 * 60 * 1000); - value += '; expires=' + date.toGMTString(); - } - if (this.options.secure) value += '; secure'; - this.options.document.cookie = this.key + '=' + value; - return this; - }, - - read: function(){ - var value = this.options.document.cookie.match('(?:^|;)\\s*' + this.key.escapeRegExp() + '=([^;]*)'); - return (value) ? decodeURIComponent(value[1]) : null; - }, - - dispose: function(){ - new Cookie(this.key, $merge(this.options, {duration: -1})).write(''); - return this; - } - -}); - -Cookie.write = function(key, value, options){ - return new Cookie(key, options).write(value); -}; - -Cookie.read = function(key){ - return new Cookie(key).read(); -}; - -Cookie.dispose = function(key, options){ - return new Cookie(key, options).dispose(); -}; - - -/* ---- - -script: Swiff.js - -description: Wrapper for embedding SWF movies. Supports External Interface Communication. - -license: MIT-style license. - -credits: -- Flash detection & Internet Explorer + Flash Player 9 fix inspired by SWFObject. - -requires: -- /Options -- /$util - -provides: [Swiff] - -... -*/ - -var Swiff = new Class({ - - Implements: [Options], - - options: { - id: null, - height: 1, - width: 1, - container: null, - properties: {}, - params: { - quality: 'high', - allowScriptAccess: 'always', - wMode: 'transparent', - swLiveConnect: true - }, - callBacks: {}, - vars: {} - }, - - toElement: function(){ - return this.object; - }, - - initialize: function(path, options){ - this.instance = 'Swiff_' + $time(); - - this.setOptions(options); - options = this.options; - var id = this.id = options.id || this.instance; - var container = document.id(options.container); - - Swiff.CallBacks[this.instance] = {}; - - var params = options.params, vars = options.vars, callBacks = options.callBacks; - var properties = $extend({height: options.height, width: options.width}, options.properties); - - var self = this; - - for (var callBack in callBacks){ - Swiff.CallBacks[this.instance][callBack] = (function(option){ - return function(){ - return option.apply(self.object, arguments); - }; - })(callBacks[callBack]); - vars[callBack] = 'Swiff.CallBacks.' + this.instance + '.' + callBack; - } - - params.flashVars = Hash.toQueryString(vars); - if (Browser.Engine.trident){ - properties.classid = 'clsid:D27CDB6E-AE6D-11cf-96B8-444553540000'; - params.movie = path; - } else { - properties.type = 'application/x-shockwave-flash'; - properties.data = path; - } - var build = ''; - } - build += ''; - this.object = ((container) ? container.empty() : new Element('div')).set('html', build).firstChild; - }, - - replaces: function(element){ - element = document.id(element, true); - element.parentNode.replaceChild(this.toElement(), element); - return this; - }, - - inject: function(element){ - document.id(element, true).appendChild(this.toElement()); - return this; - }, - - remote: function(){ - return Swiff.remote.apply(Swiff, [this.toElement()].extend(arguments)); - } - -}); - -Swiff.CallBacks = {}; - -Swiff.remote = function(obj, fn){ - var rs = obj.CallFunction('' + __flash__argumentsToXML(arguments, 2) + ''); - return eval(rs); -}; - - -/* ---- - -script: Fx.js - -description: Contains the basic animation logic to be extended by all other Fx Classes. - -license: MIT-style license. - -requires: -- /Chain -- /Events -- /Options - -provides: [Fx] - -... -*/ - -var Fx = new Class({ - - Implements: [Chain, Events, Options], - - options: { - /* - onStart: $empty, - onCancel: $empty, - onComplete: $empty, - */ - fps: 50, - unit: false, - duration: 500, - link: 'ignore' - }, - - initialize: function(options){ - this.subject = this.subject || this; - this.setOptions(options); - this.options.duration = Fx.Durations[this.options.duration] || this.options.duration.toInt(); - var wait = this.options.wait; - if (wait === false) this.options.link = 'cancel'; - }, - - getTransition: function(){ - return function(p){ - return -(Math.cos(Math.PI * p) - 1) / 2; - }; - }, - - step: function(){ - var time = $time(); - if (time < this.time + this.options.duration){ - var delta = this.transition((time - this.time) / this.options.duration); - this.set(this.compute(this.from, this.to, delta)); - } else { - this.set(this.compute(this.from, this.to, 1)); - this.complete(); - } - }, - - set: function(now){ - return now; - }, - - compute: function(from, to, delta){ - return Fx.compute(from, to, delta); - }, - - check: function(){ - if (!this.timer) return true; - switch (this.options.link){ - case 'cancel': this.cancel(); return true; - case 'chain': this.chain(this.caller.bind(this, arguments)); return false; - } - return false; - }, - - start: function(from, to){ - if (!this.check(from, to)) return this; - this.from = from; - this.to = to; - this.time = 0; - this.transition = this.getTransition(); - this.startTimer(); - this.onStart(); - return this; - }, - - complete: function(){ - if (this.stopTimer()) this.onComplete(); - return this; - }, - - cancel: function(){ - if (this.stopTimer()) this.onCancel(); - return this; - }, - - onStart: function(){ - this.fireEvent('start', this.subject); - }, - - onComplete: function(){ - this.fireEvent('complete', this.subject); - if (!this.callChain()) this.fireEvent('chainComplete', this.subject); - }, - - onCancel: function(){ - this.fireEvent('cancel', this.subject).clearChain(); - }, - - pause: function(){ - this.stopTimer(); - return this; - }, - - resume: function(){ - this.startTimer(); - return this; - }, - - stopTimer: function(){ - if (!this.timer) return false; - this.time = $time() - this.time; - this.timer = $clear(this.timer); - return true; - }, - - startTimer: function(){ - if (this.timer) return false; - this.time = $time() - this.time; - this.timer = this.step.periodical(Math.round(1000 / this.options.fps), this); - return true; - } - -}); - -Fx.compute = function(from, to, delta){ - return (to - from) * delta + from; -}; - -Fx.Durations = {'short': 250, 'normal': 500, 'long': 1000}; - - -/* ---- - -script: Fx.CSS.js - -description: Contains the CSS animation logic. Used by Fx.Tween, Fx.Morph, Fx.Elements. - -license: MIT-style license. - -requires: -- /Fx -- /Element.Style - -provides: [Fx.CSS] - -... -*/ - -Fx.CSS = new Class({ - - Extends: Fx, - - //prepares the base from/to object - - prepare: function(element, property, values){ - values = $splat(values); - var values1 = values[1]; - if (!$chk(values1)){ - values[1] = values[0]; - values[0] = element.getStyle(property); - } - var parsed = values.map(this.parse); - return {from: parsed[0], to: parsed[1]}; - }, - - //parses a value into an array - - parse: function(value){ - value = $lambda(value)(); - value = (typeof value == 'string') ? value.split(' ') : $splat(value); - return value.map(function(val){ - val = String(val); - var found = false; - Fx.CSS.Parsers.each(function(parser, key){ - if (found) return; - var parsed = parser.parse(val); - if ($chk(parsed)) found = {value: parsed, parser: parser}; - }); - found = found || {value: val, parser: Fx.CSS.Parsers.String}; - return found; - }); - }, - - //computes by a from and to prepared objects, using their parsers. - - compute: function(from, to, delta){ - var computed = []; - (Math.min(from.length, to.length)).times(function(i){ - computed.push({value: from[i].parser.compute(from[i].value, to[i].value, delta), parser: from[i].parser}); - }); - computed.$family = {name: 'fx:css:value'}; - return computed; - }, - - //serves the value as settable - - serve: function(value, unit){ - if ($type(value) != 'fx:css:value') value = this.parse(value); - var returned = []; - value.each(function(bit){ - returned = returned.concat(bit.parser.serve(bit.value, unit)); - }); - return returned; - }, - - //renders the change to an element - - render: function(element, property, value, unit){ - element.setStyle(property, this.serve(value, unit)); - }, - - //searches inside the page css to find the values for a selector - - search: function(selector){ - if (Fx.CSS.Cache[selector]) return Fx.CSS.Cache[selector]; - var to = {}; - Array.each(document.styleSheets, function(sheet, j){ - var href = sheet.href; - if (href && href.contains('://') && !href.contains(document.domain)) return; - var rules = sheet.rules || sheet.cssRules; - Array.each(rules, function(rule, i){ - if (!rule.style) return; - var selectorText = (rule.selectorText) ? rule.selectorText.replace(/^\w+/, function(m){ - return m.toLowerCase(); - }) : null; - if (!selectorText || !selectorText.test('^' + selector + '$')) return; - Element.Styles.each(function(value, style){ - if (!rule.style[style] || Element.ShortStyles[style]) return; - value = String(rule.style[style]); - to[style] = (value.test(/^rgb/)) ? value.rgbToHex() : value; - }); - }); - }); - return Fx.CSS.Cache[selector] = to; - } - -}); - -Fx.CSS.Cache = {}; - -Fx.CSS.Parsers = new Hash({ - - Color: { - parse: function(value){ - if (value.match(/^#[0-9a-f]{3,6}$/i)) return value.hexToRgb(true); - return ((value = value.match(/(\d+),\s*(\d+),\s*(\d+)/))) ? [value[1], value[2], value[3]] : false; - }, - compute: function(from, to, delta){ - return from.map(function(value, i){ - return Math.round(Fx.compute(from[i], to[i], delta)); - }); - }, - serve: function(value){ - return value.map(Number); - } - }, - - Number: { - parse: parseFloat, - compute: Fx.compute, - serve: function(value, unit){ - return (unit) ? value + unit : value; - } - }, - - String: { - parse: $lambda(false), - compute: $arguments(1), - serve: $arguments(0) - } - -}); - - -/* ---- - -script: Fx.Tween.js - -description: Formerly Fx.Style, effect to transition any CSS property for an element. - -license: MIT-style license. - -requires: -- /Fx.CSS - -provides: [Fx.Tween, Element.fade, Element.highlight] - -... -*/ - -Fx.Tween = new Class({ - - Extends: Fx.CSS, - - initialize: function(element, options){ - this.element = this.subject = document.id(element); - this.parent(options); - }, - - set: function(property, now){ - if (arguments.length == 1){ - now = property; - property = this.property || this.options.property; - } - this.render(this.element, property, now, this.options.unit); - return this; - }, - - start: function(property, from, to){ - if (!this.check(property, from, to)) return this; - var args = Array.flatten(arguments); - this.property = this.options.property || args.shift(); - var parsed = this.prepare(this.element, this.property, args); - return this.parent(parsed.from, parsed.to); - } - -}); - -Element.Properties.tween = { - - set: function(options){ - var tween = this.retrieve('tween'); - if (tween) tween.cancel(); - return this.eliminate('tween').store('tween:options', $extend({link: 'cancel'}, options)); - }, - - get: function(options){ - if (options || !this.retrieve('tween')){ - if (options || !this.retrieve('tween:options')) this.set('tween', options); - this.store('tween', new Fx.Tween(this, this.retrieve('tween:options'))); - } - return this.retrieve('tween'); - } - -}; - -Element.implement({ - - tween: function(property, from, to){ - this.get('tween').start(arguments); - return this; - }, - - fade: function(how){ - var fade = this.get('tween'), o = 'opacity', toggle; - how = $pick(how, 'toggle'); - switch (how){ - case 'in': fade.start(o, 1); break; - case 'out': fade.start(o, 0); break; - case 'show': fade.set(o, 1); break; - case 'hide': fade.set(o, 0); break; - case 'toggle': - var flag = this.retrieve('fade:flag', this.get('opacity') == 1); - fade.start(o, (flag) ? 0 : 1); - this.store('fade:flag', !flag); - toggle = true; - break; - default: fade.start(o, arguments); - } - if (!toggle) this.eliminate('fade:flag'); - return this; - }, - - highlight: function(start, end){ - if (!end){ - end = this.retrieve('highlight:original', this.getStyle('background-color')); - end = (end == 'transparent') ? '#fff' : end; - } - var tween = this.get('tween'); - tween.start('background-color', start || '#ffff88', end).chain(function(){ - this.setStyle('background-color', this.retrieve('highlight:original')); - tween.callChain(); - }.bind(this)); - return this; - } - -}); - - -/* ---- - -script: Fx.Morph.js - -description: Formerly Fx.Styles, effect to transition any number of CSS properties for an element using an object of rules, or CSS based selector rules. - -license: MIT-style license. - -requires: -- /Fx.CSS - -provides: [Fx.Morph] - -... -*/ - -Fx.Morph = new Class({ - - Extends: Fx.CSS, - - initialize: function(element, options){ - this.element = this.subject = document.id(element); - this.parent(options); - }, - - set: function(now){ - if (typeof now == 'string') now = this.search(now); - for (var p in now) this.render(this.element, p, now[p], this.options.unit); - return this; - }, - - compute: function(from, to, delta){ - var now = {}; - for (var p in from) now[p] = this.parent(from[p], to[p], delta); - return now; - }, - - start: function(properties){ - if (!this.check(properties)) return this; - if (typeof properties == 'string') properties = this.search(properties); - var from = {}, to = {}; - for (var p in properties){ - var parsed = this.prepare(this.element, p, properties[p]); - from[p] = parsed.from; - to[p] = parsed.to; - } - return this.parent(from, to); - } - -}); - -Element.Properties.morph = { - - set: function(options){ - var morph = this.retrieve('morph'); - if (morph) morph.cancel(); - return this.eliminate('morph').store('morph:options', $extend({link: 'cancel'}, options)); - }, - - get: function(options){ - if (options || !this.retrieve('morph')){ - if (options || !this.retrieve('morph:options')) this.set('morph', options); - this.store('morph', new Fx.Morph(this, this.retrieve('morph:options'))); - } - return this.retrieve('morph'); - } - -}; - -Element.implement({ - - morph: function(props){ - this.get('morph').start(props); - return this; - } - -}); - - -/* ---- - -script: Fx.Transitions.js - -description: Contains a set of advanced transitions to be used with any of the Fx Classes. - -license: MIT-style license. - -credits: -- Easing Equations by Robert Penner, , modified and optimized to be used with MooTools. - -requires: -- /Fx - -provides: [Fx.Transitions] - -... -*/ - -Fx.implement({ - - getTransition: function(){ - var trans = this.options.transition || Fx.Transitions.Sine.easeInOut; - if (typeof trans == 'string'){ - var data = trans.split(':'); - trans = Fx.Transitions; - trans = trans[data[0]] || trans[data[0].capitalize()]; - if (data[1]) trans = trans['ease' + data[1].capitalize() + (data[2] ? data[2].capitalize() : '')]; - } - return trans; - } - -}); - -Fx.Transition = function(transition, params){ - params = $splat(params); - return $extend(transition, { - easeIn: function(pos){ - return transition(pos, params); - }, - easeOut: function(pos){ - return 1 - transition(1 - pos, params); - }, - easeInOut: function(pos){ - return (pos <= 0.5) ? transition(2 * pos, params) / 2 : (2 - transition(2 * (1 - pos), params)) / 2; - } - }); -}; - -Fx.Transitions = new Hash({ - - linear: $arguments(0) - -}); - -Fx.Transitions.extend = function(transitions){ - for (var transition in transitions) Fx.Transitions[transition] = new Fx.Transition(transitions[transition]); -}; - -Fx.Transitions.extend({ - - Pow: function(p, x){ - return Math.pow(p, x[0] || 6); - }, - - Expo: function(p){ - return Math.pow(2, 8 * (p - 1)); - }, - - Circ: function(p){ - return 1 - Math.sin(Math.acos(p)); - }, - - Sine: function(p){ - return 1 - Math.sin((1 - p) * Math.PI / 2); - }, - - Back: function(p, x){ - x = x[0] || 1.618; - return Math.pow(p, 2) * ((x + 1) * p - x); - }, - - Bounce: function(p){ - var value; - for (var a = 0, b = 1; 1; a += b, b /= 2){ - if (p >= (7 - 4 * a) / 11){ - value = b * b - Math.pow((11 - 6 * a - 11 * p) / 4, 2); - break; - } - } - return value; - }, - - Elastic: function(p, x){ - return Math.pow(2, 10 * --p) * Math.cos(20 * p * Math.PI * (x[0] || 1) / 3); - } - -}); - -['Quad', 'Cubic', 'Quart', 'Quint'].each(function(transition, i){ - Fx.Transitions[transition] = new Fx.Transition(function(p){ - return Math.pow(p, [i + 2]); - }); -}); - - -/* ---- - -script: Request.js - -description: Powerful all purpose Request Class. Uses XMLHTTPRequest. - -license: MIT-style license. - -requires: -- /Element -- /Chain -- /Events -- /Options -- /Browser - -provides: [Request] - -... -*/ - -var Request = new Class({ - - Implements: [Chain, Events, Options], - - options: {/* - onRequest: $empty, - onComplete: $empty, - onCancel: $empty, - onSuccess: $empty, - onFailure: $empty, - onException: $empty,*/ - url: '', - data: '', - headers: { - 'X-Requested-With': 'XMLHttpRequest', - 'Accept': 'text/javascript, text/html, application/xml, text/xml, */*' - }, - async: true, - format: false, - method: 'post', - link: 'ignore', - isSuccess: null, - emulation: true, - urlEncoded: true, - encoding: 'utf-8', - evalScripts: false, - evalResponse: false, - noCache: false - }, - - initialize: function(options){ - this.xhr = new Browser.Request(); - this.setOptions(options); - this.options.isSuccess = this.options.isSuccess || this.isSuccess; - this.headers = new Hash(this.options.headers); - }, - - onStateChange: function(){ - if (this.xhr.readyState != 4 || !this.running) return; - this.running = false; - this.status = 0; - $try(function(){ - this.status = this.xhr.status; - }.bind(this)); - this.xhr.onreadystatechange = $empty; - if (this.options.isSuccess.call(this, this.status)){ - this.response = {text: this.xhr.responseText, xml: this.xhr.responseXML}; - this.success(this.response.text, this.response.xml); - } else { - this.response = {text: null, xml: null}; - this.failure(); - } - }, - - isSuccess: function(){ - return ((this.status >= 200) && (this.status < 300)); - }, - - processScripts: function(text){ - if (this.options.evalResponse || (/(ecma|java)script/).test(this.getHeader('Content-type'))) return $exec(text); - return text.stripScripts(this.options.evalScripts); - }, - - success: function(text, xml){ - this.onSuccess(this.processScripts(text), xml); - }, - - onSuccess: function(){ - this.fireEvent('complete', arguments).fireEvent('success', arguments).callChain(); - }, - - failure: function(){ - this.onFailure(); - }, - - onFailure: function(){ - this.fireEvent('complete').fireEvent('failure', this.xhr); - }, - - setHeader: function(name, value){ - this.headers.set(name, value); - return this; - }, - - getHeader: function(name){ - return $try(function(){ - return this.xhr.getResponseHeader(name); - }.bind(this)); - }, - - check: function(){ - if (!this.running) return true; - switch (this.options.link){ - case 'cancel': this.cancel(); return true; - case 'chain': this.chain(this.caller.bind(this, arguments)); return false; - } - return false; - }, - - send: function(options){ - if (!this.check(options)) return this; - this.running = true; - - var type = $type(options); - if (type == 'string' || type == 'element') options = {data: options}; - - var old = this.options; - options = $extend({data: old.data, url: old.url, method: old.method}, options); - var data = options.data, url = String(options.url), method = options.method.toLowerCase(); - - switch ($type(data)){ - case 'element': data = document.id(data).toQueryString(); break; - case 'object': case 'hash': data = Hash.toQueryString(data); - } - - if (this.options.format){ - var format = 'format=' + this.options.format; - data = (data) ? format + '&' + data : format; - } - - if (this.options.emulation && !['get', 'post'].contains(method)){ - var _method = '_method=' + method; - data = (data) ? _method + '&' + data : _method; - method = 'post'; - } - - if (this.options.urlEncoded && method == 'post'){ - var encoding = (this.options.encoding) ? '; charset=' + this.options.encoding : ''; - this.headers.set('Content-type', 'application/x-www-form-urlencoded' + encoding); - } - - if (this.options.noCache){ - var noCache = 'noCache=' + new Date().getTime(); - data = (data) ? noCache + '&' + data : noCache; - } - - var trimPosition = url.lastIndexOf('/'); - if (trimPosition > -1 && (trimPosition = url.indexOf('#')) > -1) url = url.substr(0, trimPosition); - - if (data && method == 'get'){ - url = url + (url.contains('?') ? '&' : '?') + data; - data = null; - } - - this.xhr.open(method.toUpperCase(), url, this.options.async); - - this.xhr.onreadystatechange = this.onStateChange.bind(this); - - this.headers.each(function(value, key){ - try { - this.xhr.setRequestHeader(key, value); - } catch (e){ - this.fireEvent('exception', [key, value]); - } - }, this); - - this.fireEvent('request'); - this.xhr.send(data); - if (!this.options.async) this.onStateChange(); - return this; - }, - - cancel: function(){ - if (!this.running) return this; - this.running = false; - this.xhr.abort(); - this.xhr.onreadystatechange = $empty; - this.xhr = new Browser.Request(); - this.fireEvent('cancel'); - return this; - } - -}); - -(function(){ - -var methods = {}; -['get', 'post', 'put', 'delete', 'GET', 'POST', 'PUT', 'DELETE'].each(function(method){ - methods[method] = function(){ - var params = Array.link(arguments, {url: String.type, data: $defined}); - return this.send($extend(params, {method: method})); - }; -}); - -Request.implement(methods); - -})(); - -Element.Properties.send = { - - set: function(options){ - var send = this.retrieve('send'); - if (send) send.cancel(); - return this.eliminate('send').store('send:options', $extend({ - data: this, link: 'cancel', method: this.get('method') || 'post', url: this.get('action') - }, options)); - }, - - get: function(options){ - if (options || !this.retrieve('send')){ - if (options || !this.retrieve('send:options')) this.set('send', options); - this.store('send', new Request(this.retrieve('send:options'))); - } - return this.retrieve('send'); - } - -}; - -Element.implement({ - - send: function(url){ - var sender = this.get('send'); - sender.send({data: this, url: url || sender.options.url}); - return this; - } - -}); - - -/* ---- - -script: Request.HTML.js - -description: Extends the basic Request Class with additional methods for interacting with HTML responses. - -license: MIT-style license. - -requires: -- /Request -- /Element - -provides: [Request.HTML] - -... -*/ - -Request.HTML = new Class({ - - Extends: Request, - - options: { - update: false, - append: false, - evalScripts: true, - filter: false - }, - - processHTML: function(text){ - var match = text.match(/]*>([\s\S]*?)<\/body>/i); - text = (match) ? match[1] : text; - - var container = new Element('div'); - - return $try(function(){ - var root = '' + text + '', doc; - if (Browser.Engine.trident){ - doc = new ActiveXObject('Microsoft.XMLDOM'); - doc.async = false; - doc.loadXML(root); - } else { - doc = new DOMParser().parseFromString(root, 'text/xml'); - } - root = doc.getElementsByTagName('root')[0]; - if (!root) return null; - for (var i = 0, k = root.childNodes.length; i < k; i++){ - var child = Element.clone(root.childNodes[i], true, true); - if (child) container.grab(child); - } - return container; - }) || container.set('html', text); - }, - - success: function(text){ - var options = this.options, response = this.response; - - response.html = text.stripScripts(function(script){ - response.javascript = script; - }); - - var temp = this.processHTML(response.html); - - response.tree = temp.childNodes; - response.elements = temp.getElements('*'); - - if (options.filter) response.tree = response.elements.filter(options.filter); - if (options.update) document.id(options.update).empty().set('html', response.html); - else if (options.append) document.id(options.append).adopt(temp.getChildren()); - if (options.evalScripts) $exec(response.javascript); - - this.onSuccess(response.tree, response.elements, response.html, response.javascript); - } - -}); - -Element.Properties.load = { - - set: function(options){ - var load = this.retrieve('load'); - if (load) load.cancel(); - return this.eliminate('load').store('load:options', $extend({data: this, link: 'cancel', update: this, method: 'get'}, options)); - }, - - get: function(options){ - if (options || ! this.retrieve('load')){ - if (options || !this.retrieve('load:options')) this.set('load', options); - this.store('load', new Request.HTML(this.retrieve('load:options'))); - } - return this.retrieve('load'); - } - -}; - -Element.implement({ - - load: function(){ - this.get('load').send(Array.link(arguments, {data: Object.type, url: String.type})); - return this; - } - -}); - - -/* ---- - -script: Request.JSON.js - -description: Extends the basic Request Class with additional methods for sending and receiving JSON data. - -license: MIT-style license. - -requires: -- /Request JSON - -provides: [Request.HTML] - -... -*/ - -Request.JSON = new Class({ - - Extends: Request, - - options: { - secure: true - }, - - initialize: function(options){ - this.parent(options); - this.headers.extend({'Accept': 'application/json', 'X-Request': 'JSON'}); - }, - - success: function(text){ - this.response.json = JSON.decode(text, this.options.secure); - this.onSuccess(this.response.json, text); - } - -}); Modified: zorg/trunk/lnt/lnt/viewer/root.ptl URL: http://llvm.org/viewvc/llvm-project/zorg/trunk/lnt/lnt/viewer/root.ptl?rev=110919&r1=110918&r2=110919&view=diff ============================================================================== --- zorg/trunk/lnt/lnt/viewer/root.ptl (original) +++ zorg/trunk/lnt/lnt/viewer/root.ptl Thu Aug 12 11:03:34 2010 @@ -79,9 +79,8 @@ """ % (pathToRoot,) if addGraphJS: """ - - """ % (pathToRoot,pathToRoot) + """ % pathToRoot if addJSScript: """\ """ % view2d_js + html_report = """ - - - +%(header)s %(subject)s From daniel at zuster.org Thu Aug 12 11:03:41 2010 From: daniel at zuster.org (Daniel Dunbar) Date: Thu, 12 Aug 2010 16:03:41 -0000 Subject: [llvm-commits] [zorg] r110921 - /zorg/trunk/lnt/lnt/db/perfdbsummary.py Message-ID: <20100812160341.132282A6C12C@llvm.org> Author: ddunbar Date: Thu Aug 12 11:03:40 2010 New Revision: 110921 URL: http://llvm.org/viewvc/llvm-project?rev=110921&view=rev Log: LNT: Order by submission time among runs for the same revision, so that comparisons line up sensibly. Modified: zorg/trunk/lnt/lnt/db/perfdbsummary.py Modified: zorg/trunk/lnt/lnt/db/perfdbsummary.py URL: http://llvm.org/viewvc/llvm-project/zorg/trunk/lnt/lnt/db/perfdbsummary.py?rev=110921&r1=110920&r2=110921&view=diff ============================================================================== --- zorg/trunk/lnt/lnt/db/perfdbsummary.py (original) +++ zorg/trunk/lnt/lnt/db/perfdbsummary.py Thu Aug 12 11:03:40 2010 @@ -135,10 +135,12 @@ def fromdb(db, tag): revision = db.get_revision_number("RunInfo") - # Find all run_orders for runs with this tag. + # Find all run_orders for runs with this tag, ordered by run time so + # that runs are ordered by both (run_order, time) in the final ordering. all_run_orders = db.session.query(RunInfo.value, RunInfo.run_id, Run.machine_id).\ join(Run).\ + order_by(Run.start_time.desc()).\ filter(RunInfo.key == "run_order").\ filter(RunInfo.run_id.in_( db.session.query(RunInfo.run_id).\ From daniel at zuster.org Thu Aug 12 11:03:43 2010 From: daniel at zuster.org (Daniel Dunbar) Date: Thu, 12 Aug 2010 16:03:43 -0000 Subject: [llvm-commits] [zorg] r110922 - /zorg/trunk/lnt/lnt/util/NTEmailReport.py Message-ID: <20100812160343.AB3CD2A6C12F@llvm.org> Author: ddunbar Date: Thu Aug 12 11:03:43 2010 New Revision: 110922 URL: http://llvm.org/viewvc/llvm-project?rev=110922&view=rev Log: LNT/simple: Don't show "Changes Detail" header when there are no changes. Modified: zorg/trunk/lnt/lnt/util/NTEmailReport.py Modified: zorg/trunk/lnt/lnt/util/NTEmailReport.py URL: http://llvm.org/viewvc/llvm-project/zorg/trunk/lnt/lnt/util/NTEmailReport.py?rev=110922&r1=110921&r2=110922&view=diff ============================================================================== --- zorg/trunk/lnt/lnt/util/NTEmailReport.py (original) +++ zorg/trunk/lnt/lnt/util/NTEmailReport.py Thu Aug 12 11:03:43 2010 @@ -245,7 +245,8 @@ ('Existing Failures', existing_failures, False), ('Unchanged Tests', unchanged_tests, False)) total_changes = sum([sum(map(len, items.values())) - for _,items,_ in items_info]) + for name,items,_ in items_info + if name != 'Unchanged Tests']) graphs = [] print >>report, """===============""" print >>report, """Tests Summary""" From daniel at zuster.org Thu Aug 12 11:03:46 2010 From: daniel at zuster.org (Daniel Dunbar) Date: Thu, 12 Aug 2010 16:03:46 -0000 Subject: [llvm-commits] [zorg] r110923 - in /zorg/trunk/lnt/lnt: formats/JSONFormat.py util/__init__.py Message-ID: <20100812160346.CE0DF2A6C12D@llvm.org> Author: ddunbar Date: Thu Aug 12 11:03:46 2010 New Revision: 110923 URL: http://llvm.org/viewvc/llvm-project?rev=110923&view=rev Log: LNT: Make json module more easily accessable. Modified: zorg/trunk/lnt/lnt/formats/JSONFormat.py zorg/trunk/lnt/lnt/util/__init__.py Modified: zorg/trunk/lnt/lnt/formats/JSONFormat.py URL: http://llvm.org/viewvc/llvm-project/zorg/trunk/lnt/lnt/formats/JSONFormat.py?rev=110923&r1=110922&r2=110923&view=diff ============================================================================== --- zorg/trunk/lnt/lnt/formats/JSONFormat.py (original) +++ zorg/trunk/lnt/lnt/formats/JSONFormat.py Thu Aug 12 11:03:46 2010 @@ -1,7 +1,4 @@ -try: - import json -except ImportError: - import simplejson as json +from lnt.util import json def _matches_format(path_or_file): if isinstance(path_or_file, str): Modified: zorg/trunk/lnt/lnt/util/__init__.py URL: http://llvm.org/viewvc/llvm-project/zorg/trunk/lnt/lnt/util/__init__.py?rev=110923&r1=110922&r2=110923&view=diff ============================================================================== --- zorg/trunk/lnt/lnt/util/__init__.py (original) +++ zorg/trunk/lnt/lnt/util/__init__.py Thu Aug 12 11:03:46 2010 @@ -1 +1,6 @@ __all__ = [] + +try: + import json +except ImportError: + import simplejson as json From daniel at zuster.org Thu Aug 12 11:03:53 2010 From: daniel at zuster.org (Daniel Dunbar) Date: Thu, 12 Aug 2010 16:03:53 -0000 Subject: [llvm-commits] [zorg] r110925 - in /zorg/trunk/lnt/lnt/util: ImportData.py NTEmailReport.py Message-ID: <20100812160353.A382B2A6C12D@llvm.org> Author: ddunbar Date: Thu Aug 12 11:03:53 2010 New Revision: 110925 URL: http://llvm.org/viewvc/llvm-project?rev=110925&view=rev Log: LNT: Always generate reports on import, even if we don't plan on sending them anywhere. Modified: zorg/trunk/lnt/lnt/util/ImportData.py zorg/trunk/lnt/lnt/util/NTEmailReport.py Modified: zorg/trunk/lnt/lnt/util/ImportData.py URL: http://llvm.org/viewvc/llvm-project/zorg/trunk/lnt/lnt/util/ImportData.py?rev=110925&r1=110924&r2=110925&view=diff ============================================================================== --- zorg/trunk/lnt/lnt/util/ImportData.py (original) +++ zorg/trunk/lnt/lnt/util/ImportData.py Thu Aug 12 11:03:53 2010 @@ -45,16 +45,17 @@ result['load_time'] = time.time() - startTime # Find the email address for this machine's results. - toAddress = None - email_config = config.databases[db_name].email_config - if email_config.enabled: - # Find the machine name. - machineName = str(data.get('Machine',{}).get('Name')) - toAddress = email_config.get_to_address(machineName) - if toAddress is None: - result['error'] = ("unable to match machine name " - "for test results email address!") - return result + toAddress = email_config = None + if not disable_email: + email_config = config.databases[db_name].email_config + if email_config.enabled: + # Find the machine name. + machineName = str(data.get('Machine',{}).get('Name')) + toAddress = email_config.get_to_address(machineName) + if toAddress is None: + result['error'] = ("unable to match machine name " + "for test results email address!") + return result importStartTime = time.time() try: @@ -71,12 +72,10 @@ # Record the original run this is a duplicate of. result['original_run'] = run.id - if not disable_email and toAddress is not None: - result['report_to_address'] = toAddress - NTEmailReport.emailReport(db, run, - "%s/db_%s/" % (config.zorgURL, db_name), - email_config.host, email_config.from_address, - toAddress, success, commit) + result['report_to_address'] = toAddress + NTEmailReport.emailReport(db, run, + "%s/db_%s/" % (config.zorgURL, db_name), + email_config, toAddress, success, commit) result['added_machines'] = db.getNumMachines() - numMachines result['added_runs'] = db.getNumRuns() - numRuns Modified: zorg/trunk/lnt/lnt/util/NTEmailReport.py URL: http://llvm.org/viewvc/llvm-project/zorg/trunk/lnt/lnt/util/NTEmailReport.py?rev=110925&r1=110924&r2=110925&view=diff ============================================================================== --- zorg/trunk/lnt/lnt/util/NTEmailReport.py (original) +++ zorg/trunk/lnt/lnt/util/NTEmailReport.py Thu Aug 12 11:03:53 2010 @@ -37,7 +37,7 @@ emailReport(db, run, baseurl, host, from_, to) -def emailReport(db, run, baseurl, host, from_, to, was_added=True, +def emailReport(db, run, baseurl, email_config, to, was_added=True, will_commit=True): import email.mime.multipart import email.mime.text @@ -45,16 +45,22 @@ subject, report, html_report = getReport(db, run, baseurl, was_added, will_commit) + # Ignore if no to address was given, we do things this way because of the + # awkward way we collect result information as part of generating the email + # report. + if email_config is None or to is None: + return + # Generate a plain text message if we have no html report. if not html_report: msg = email.mime.text.MIMEText(report) msg['Subject'] = subject - msg['From'] = from_ + msg['From'] = email_config.from_address msg['To'] = to else: msg = email.mime.multipart.MIMEMultipart('alternative') msg['Subject'] = subject - msg['From'] = from_ + msg['From'] = email_config.from_address msg['To'] = to # Attach parts into message container, according to RFC 2046, the last @@ -63,8 +69,8 @@ msg.attach(email.mime.text.MIMEText(report, 'plain')) msg.attach(email.mime.text.MIMEText(html_report, 'html')) - s = smtplib.SMTP(host) - s.sendmail(from_, [to], msg.as_string()) + s = smtplib.SMTP(email_config.host) + s.sendmail(email_config.from_address, [to], msg.as_string()) s.quit() def findPreceedingRun(query, run): From daniel at zuster.org Thu Aug 12 11:03:50 2010 From: daniel at zuster.org (Daniel Dunbar) Date: Thu, 12 Aug 2010 16:03:50 -0000 Subject: [llvm-commits] [zorg] r110924 - in /zorg/trunk/lnt/lnt: lnttool/import_data.py util/ImportData.py viewer/root.ptl Message-ID: <20100812160350.B3B302A6C12C@llvm.org> Author: ddunbar Date: Thu Aug 12 11:03:50 2010 New Revision: 110924 URL: http://llvm.org/viewvc/llvm-project?rev=110924&view=rev Log: LNT: Change submission to return the result as an unstructured dictionary of results, which we send back as JSON when submitting remotely. Modified: zorg/trunk/lnt/lnt/lnttool/import_data.py zorg/trunk/lnt/lnt/util/ImportData.py zorg/trunk/lnt/lnt/viewer/root.ptl Modified: zorg/trunk/lnt/lnt/lnttool/import_data.py URL: http://llvm.org/viewvc/llvm-project/zorg/trunk/lnt/lnt/lnttool/import_data.py?rev=110924&r1=110923&r2=110924&view=diff ============================================================================== --- zorg/trunk/lnt/lnt/lnttool/import_data.py (original) +++ zorg/trunk/lnt/lnt/lnttool/import_data.py Thu Aug 12 11:03:50 2010 @@ -1,4 +1,4 @@ -import os, sys, time +import os, pprint, sys, time from lnt import formats from lnt.viewer import Config, PerfDB @@ -49,7 +49,9 @@ # Load the database. db = PerfDB.PerfDB(db_entry.path, echo=opts.showSQL) for file in args: - success, run = ImportData.import_and_report( - config, opts.database, db, file, sys.stdout, + result = ImportData.import_and_report( + config, opts.database, db, file, opts.format, opts.commit, opts.showSampleCount, opts.noEmail) + + pprint.pprint(result) Modified: zorg/trunk/lnt/lnt/util/ImportData.py URL: http://llvm.org/viewvc/llvm-project/zorg/trunk/lnt/lnt/util/ImportData.py?rev=110924&r1=110923&r2=110924&view=diff ============================================================================== --- zorg/trunk/lnt/lnt/util/ImportData.py (original) +++ zorg/trunk/lnt/lnt/util/ImportData.py Thu Aug 12 11:03:50 2010 @@ -4,17 +4,20 @@ from lnt.viewer import PerfDB from lnt.util import NTEmailReport -def import_and_report(config, db_name, db, file, log, format, commit=False, +def import_and_report(config, db_name, db, file, format, commit=False, show_sample_count=False, disable_email=False): """ - import_and_report(config, db_name, db, file, log, format, + import_and_report(config, db_name, db, file, format, [commit], [show_sample_count], - [disable_email]) -> (success, run) + [disable_email]) -> ... object ... Import a test data file into an LNT server and generate a test report. On success, run is the newly imported run. Note that success is uneffected by the value of commit, this merely changes whether the run (on success) is committed to the database. + + The result object is a dictionary containing information on the imported run + and its comparison to the previous run. """ numMachines = db.getNumMachines() numRuns = db.getNumRuns() @@ -24,7 +27,11 @@ if show_sample_count: numSamples = db.getNumSamples() - print >>log, 'IMPORT: %s' % file + result = {} + result['success'] = False + result['error'] = None + result['import_file'] = file + startTime = time.time() try: data = formats.read_any(file, format) @@ -32,10 +39,10 @@ raise except: import traceback - print >>log, 'ERROR: %r: load failed' % file - print >>log, traceback.format_exc() - return (False, None) - print >>log, ' LOAD TIME: %.2fs' % (time.time() - startTime,) + result['error'] = "load failure: %s" % traceback.format_exc() + return result + + result['load_time'] = time.time() - startTime # Find the email address for this machine's results. toAddress = None @@ -45,9 +52,9 @@ machineName = str(data.get('Machine',{}).get('Name')) toAddress = email_config.get_to_address(machineName) if toAddress is None: - print >>log,("ERROR: unable to match machine name " - "for test results email address!") - return (False, None) + result['error'] = ("unable to match machine name " + "for test results email address!") + return result importStartTime = time.time() try: @@ -56,41 +63,34 @@ raise except: import traceback - print >>log, 'ERROR: %r: import failed' % file - print >>log, traceback.format_exc() - return (False, None) + result['error'] = "import failure: %s" % traceback.format_exc() + return result - print >>log, ' IMPORT TIME: %.2fs' % (time.time() - importStartTime,) + result['db_import_time'] = time.time() - importStartTime if not success: - print >>log, " IGNORING DUPLICATE RUN" - print >>log, " MACHINE: %d" % (run.machine_id, ) - print >>log, " START : %s" % (run.start_time, ) - print >>log, " END : %s" % (run.end_time, ) - for ri in run.info.values(): - print >>log, " INFO : %r = %r" % (ri.key, ri.value) + # Record the original run this is a duplicate of. + result['original_run'] = run.id if not disable_email and toAddress is not None: - print >>log, "\nMAILING RESULTS TO: %r\n" % toAddress + result['report_to_address'] = toAddress NTEmailReport.emailReport(db, run, "%s/db_%s/" % (config.zorgURL, db_name), email_config.host, email_config.from_address, toAddress, success, commit) - print >>log, "ADDED: %d machines" % (db.getNumMachines() - numMachines,) - print >>log, "ADDED: %d runs" % (db.getNumRuns() - numRuns,) - print >>log, "ADDED: %d tests" % (db.getNumTests() - numTests,) + result['added_machines'] = db.getNumMachines() - numMachines + result['added_runs'] = db.getNumRuns() - numRuns + result['added_tests'] = db.getNumTests() - numTests if show_sample_count: - print >>log, "ADDED: %d samples" % (db.getNumSamples() - numSamples) + result['added_samples'] = db.getNumSamples() - numSamples + result['committed'] = commit if commit: - print >>log, 'COMMITTING RESULT:', db.commit() - print >>log, 'DONE' else: - print >>log, 'DISCARDING RESULT:', db.rollback() - print >>log, 'DONE' - print >>log, 'TOTAL IMPORT TIME: %.2fs' % (time.time() - startTime,) + result['import_time'] = time.time() - startTime - return (success, run) + result['success'] = True + return result Modified: zorg/trunk/lnt/lnt/viewer/root.ptl URL: http://llvm.org/viewvc/llvm-project/zorg/trunk/lnt/lnt/viewer/root.ptl?rev=110924&r1=110923&r2=110924&view=diff ============================================================================== --- zorg/trunk/lnt/lnt/viewer/root.ptl (original) +++ zorg/trunk/lnt/lnt/viewer/root.ptl Thu Aug 12 11:03:50 2010 @@ -18,6 +18,7 @@ import lnt from lnt.db import perfdbsummary +from lnt.util import json from lnt.viewer import PerfDB, Util from lnt.viewer.PerfDB import Machine, Run @@ -298,14 +299,6 @@ form.render() self.getFooter() - def result [plain] (success, run, log): - """\ -STATUS: %d - -OUTPUT: -%s -""" % (not run, log.getvalue()) - if not form.is_submitted() or form.has_errors(): return render() @@ -347,11 +340,10 @@ # # FIXME: Gracefully handle formats failures and DOS attempts. We # should at least reject overly large inputs. - log = StringIO() - success, run = ImportData.import_and_report( - self.config, self.dbName, db, path, log, '', commit) + result = ImportData.import_and_report( + self.config, self.dbName, db, path, '', commit) - return result(success, run, log) + return json.dumps(result) def favicon_ico(self): response = get_response() From daniel at zuster.org Thu Aug 12 11:03:56 2010 From: daniel at zuster.org (Daniel Dunbar) Date: Thu, 12 Aug 2010 16:03:56 -0000 Subject: [llvm-commits] [zorg] r110926 - in /zorg/trunk/lnt/lnt: util/ImportData.py util/NTEmailReport.py viewer/simple.ptl Message-ID: <20100812160356.C62642A6C12D@llvm.org> Author: ddunbar Date: Thu Aug 12 11:03:56 2010 New Revision: 110926 URL: http://llvm.org/viewvc/llvm-project?rev=110926&view=rev Log: LNT/import: Pass the result object to the report generation routines, so they can extend it. Modified: zorg/trunk/lnt/lnt/util/ImportData.py zorg/trunk/lnt/lnt/util/NTEmailReport.py zorg/trunk/lnt/lnt/viewer/simple.ptl Modified: zorg/trunk/lnt/lnt/util/ImportData.py URL: http://llvm.org/viewvc/llvm-project/zorg/trunk/lnt/lnt/util/ImportData.py?rev=110926&r1=110925&r2=110926&view=diff ============================================================================== --- zorg/trunk/lnt/lnt/util/ImportData.py (original) +++ zorg/trunk/lnt/lnt/util/ImportData.py Thu Aug 12 11:03:56 2010 @@ -73,7 +73,7 @@ result['original_run'] = run.id result['report_to_address'] = toAddress - NTEmailReport.emailReport(db, run, + NTEmailReport.emailReport(result, db, run, "%s/db_%s/" % (config.zorgURL, db_name), email_config, toAddress, success, commit) Modified: zorg/trunk/lnt/lnt/util/NTEmailReport.py URL: http://llvm.org/viewvc/llvm-project/zorg/trunk/lnt/lnt/util/NTEmailReport.py?rev=110926&r1=110925&r2=110926&view=diff ============================================================================== --- zorg/trunk/lnt/lnt/util/NTEmailReport.py (original) +++ zorg/trunk/lnt/lnt/util/NTEmailReport.py Thu Aug 12 11:03:56 2010 @@ -37,13 +37,13 @@ emailReport(db, run, baseurl, host, from_, to) -def emailReport(db, run, baseurl, email_config, to, was_added=True, +def emailReport(result, db, run, baseurl, email_config, to, was_added=True, will_commit=True): import email.mime.multipart import email.mime.text - subject, report, html_report = getReport(db, run, baseurl, was_added, - will_commit) + subject, report, html_report = getReport(result, db, run, baseurl, + was_added, will_commit) # Ignore if no to address was given, we do things this way because of the # awkward way we collect result information as part of generating the email @@ -88,7 +88,7 @@ best = r return best -def getSimpleReport(db, run, baseurl, was_added, will_commit, +def getSimpleReport(result, db, run, baseurl, was_added, will_commit, only_html_body = False, show_graphs = False): machine = run.machine tag = run.info['tag'].value @@ -402,13 +402,13 @@ return subject, report.getvalue(), html_report return subject, report.getvalue(), None -def getReport(db, run, baseurl, was_added, will_commit): +def getReport(result, db, run, baseurl, was_added, will_commit): report = StringIO.StringIO() # Use a simple report unless the tag indicates this is an old style nightly # test run. if 'tag' in run.info and run.info['tag'].value != 'nightlytest': - return getSimpleReport(db, run, baseurl, was_added, will_commit) + return getSimpleReport(result, db, run, baseurl, was_added, will_commit) machine = run.machine compareTo = None Modified: zorg/trunk/lnt/lnt/viewer/simple.ptl URL: http://llvm.org/viewvc/llvm-project/zorg/trunk/lnt/lnt/viewer/simple.ptl?rev=110926&r1=110925&r2=110926&view=diff ============================================================================== --- zorg/trunk/lnt/lnt/viewer/simple.ptl (original) +++ zorg/trunk/lnt/lnt/viewer/simple.ptl Thu Aug 12 11:03:56 2010 @@ -412,7 +412,7 @@ show_graphs = bool(request.form.get('show_graphs')) run,run_summary,compare_to = self.getInfo(db) - _, _, html_report = NTEmailReport.getSimpleReport( + _, _, html_report = NTEmailReport.getSimpleReport(None, db, run, str("%s/db_%s/") % (self.root.config.zorgURL, self.root.dbName), True, True, show_graphs = show_graphs) @@ -424,7 +424,7 @@ run,run_summary,compare_to = self.getInfo(db) - _, text_report, _ = NTEmailReport.getSimpleReport( + _, text_report, _ = NTEmailReport.getSimpleReport(None, db, run, str("%s/db_%s/") % (self.root.config.zorgURL, self.root.dbName), True, True) @@ -479,7 +479,7 @@ form.render() self.renderPopupEnd() - _, text_report, html_report = NTEmailReport.getSimpleReport( + _, text_report, html_report = NTEmailReport.getSimpleReport(None, db, run, str("%s/db_%s/") % (self.root.config.zorgURL, self.root.dbName), True, True, only_html_body = True, show_graphs = show_graphs) From daniel at zuster.org Thu Aug 12 11:04:05 2010 From: daniel at zuster.org (Daniel Dunbar) Date: Thu, 12 Aug 2010 16:04:05 -0000 Subject: [llvm-commits] [zorg] r110929 - in /zorg/trunk/lnt/lnt: lnttool/__init__.py lnttool/import_data.py util/ServerUtil.py Message-ID: <20100812160405.0DF852A6C12D@llvm.org> Author: ddunbar Date: Thu Aug 12 11:04:04 2010 New Revision: 110929 URL: http://llvm.org/viewvc/llvm-project?rev=110929&view=rev Log: LNT/lnttool: Change 'lnt import', 'lnt submit', and 'lnt runtest --submit' to print the submission result in pretty form. - Also adds a '-v' argument for switching between short (no PASSes) and long form. Modified: zorg/trunk/lnt/lnt/lnttool/__init__.py zorg/trunk/lnt/lnt/lnttool/import_data.py zorg/trunk/lnt/lnt/util/ServerUtil.py Modified: zorg/trunk/lnt/lnt/lnttool/__init__.py URL: http://llvm.org/viewvc/llvm-project/zorg/trunk/lnt/lnt/lnttool/__init__.py?rev=110929&r1=110928&r2=110929&view=diff ============================================================================== --- zorg/trunk/lnt/lnt/lnttool/__init__.py (original) +++ zorg/trunk/lnt/lnt/lnttool/__init__.py Thu Aug 12 11:04:04 2010 @@ -106,6 +106,9 @@ help=("whether the autosubmit result should be committed " "[%default]"), type=int, default=True) + parser.add_option("-v", "--verbose", dest="verbose", + help="show verbose test results", + action="store_true", default=False) (opts, args) = parser.parse_args(args) if len(args) < 1: @@ -127,7 +130,7 @@ from lnt.util import ServerUtil io = StringIO.StringIO(report.render(indent=None)) - ServerUtil.submitFile(opts.submit_url, io, True) + ServerUtil.submitFile(opts.submit_url, io, True, opts.verbose) def action_showtests(name, args): """show the available built-in tests""" @@ -154,13 +157,16 @@ help=("whether the result should be committed " "[%default]"), default=False) + parser.add_option("-v", "--verbose", dest="verbose", + help="show verbose test results", + action="store_true", default=False) (opts, args) = parser.parse_args(args) if len(args) < 2: parser.error("incorrect number of argments") from lnt.util import ServerUtil - ServerUtil.submitFiles(args[0], args[1:], opts.commit) + ServerUtil.submitFiles(args[0], args[1:], opts.commit, opts.verbose) ### Modified: zorg/trunk/lnt/lnt/lnttool/import_data.py URL: http://llvm.org/viewvc/llvm-project/zorg/trunk/lnt/lnt/lnttool/import_data.py?rev=110929&r1=110928&r2=110929&view=diff ============================================================================== --- zorg/trunk/lnt/lnt/lnttool/import_data.py (original) +++ zorg/trunk/lnt/lnt/lnttool/import_data.py Thu Aug 12 11:04:04 2010 @@ -17,9 +17,14 @@ default='') parser.add_option("", "--commit", dest="commit", type=int, default=False) - parser.add_option("", "--show-sql", dest="showSQL", action="store_true", + parser.add_option("", "--show-sql", dest="show_sql", action="store_true", default=False) - parser.add_option("", "--show-sample-count", dest="showSampleCount", + parser.add_option("", "--show-sample-count", dest="show_sample_count", + action="store_true", default=False) + parser.add_option("", "--show-raw-result", dest="show_raw_result", + action="store_true", default=False) + parser.add_option("-v", "--verbose", dest="verbose", + help="show verbose test results", action="store_true", default=False) parser.add_option("", "--no-email", dest="noEmail", action="store_true", default=False) @@ -47,11 +52,15 @@ parser.error("invalid database name") # Load the database. - db = PerfDB.PerfDB(db_entry.path, echo=opts.showSQL) + db = PerfDB.PerfDB(db_entry.path, echo=opts.show_sql) for file in args: result = ImportData.import_and_report( config, opts.database, db, file, - opts.format, opts.commit, opts.showSampleCount, + opts.format, opts.commit, opts.show_sample_count, opts.noEmail) - pprint.pprint(result) + if opts.show_raw_result: + pprint.pprint(result) + else: + ImportData.print_report_result(result, sys.stdout, opts.verbose) + Modified: zorg/trunk/lnt/lnt/util/ServerUtil.py URL: http://llvm.org/viewvc/llvm-project/zorg/trunk/lnt/lnt/util/ServerUtil.py?rev=110929&r1=110928&r2=110929&view=diff ============================================================================== --- zorg/trunk/lnt/lnt/util/ServerUtil.py (original) +++ zorg/trunk/lnt/lnt/util/ServerUtil.py Thu Aug 12 11:04:04 2010 @@ -3,21 +3,45 @@ """ import plistlib +import sys import urllib import urllib2 -def submitFile(url, file, commit): +from lnt.util import json +from lnt.util import ImportData + +# FIXME: I used to maintain this file in such a way that it could be used +# separate from LNT to do submission. This could be useful for adapting an older +# system to report to LNT, for example. It might be nice to factor the +# simplified submit code into a separate utility. + +def submitFile(url, file, commit, verbose): values = { 'input_data' : file.read(), 'commit' : ("0","1")[not not commit] } data = urllib.urlencode(values) response = urllib2.urlopen(urllib2.Request(url, data)) - the_page = response.read() + result_data = response.read() + + # The result is expected to be a JSON object. + try: + result = json.loads(result_data) + except: + import traceback + print "Unable to load result, not a valid JSON object." + print + print "Traceback:" + traceback.print_exc() + print + print "Result:" + print result + return - print the_page + # Print the test report. + ImportData.print_report_result(result, sys.stdout, verbose) -def submitFiles(url, files, commit): +def submitFiles(url, files, commit, verbose): for file in files: f = open(file, 'rb') - submitFile(url, f, commit) + submitFile(url, f, commit, verbose) f.close() From daniel at zuster.org Thu Aug 12 11:03:59 2010 From: daniel at zuster.org (Daniel Dunbar) Date: Thu, 12 Aug 2010 16:03:59 -0000 Subject: [llvm-commits] [zorg] r110927 - /zorg/trunk/lnt/lnt/util/NTEmailReport.py Message-ID: <20100812160359.787622A6C12C@llvm.org> Author: ddunbar Date: Thu Aug 12 11:03:59 2010 New Revision: 110927 URL: http://llvm.org/viewvc/llvm-project?rev=110927&view=rev Log: LNT/import: Add individual test results to the import result object. Modified: zorg/trunk/lnt/lnt/util/NTEmailReport.py Modified: zorg/trunk/lnt/lnt/util/NTEmailReport.py URL: http://llvm.org/viewvc/llvm-project/zorg/trunk/lnt/lnt/util/NTEmailReport.py?rev=110927&r1=110926&r2=110927&view=diff ============================================================================== --- zorg/trunk/lnt/lnt/util/NTEmailReport.py (original) +++ zorg/trunk/lnt/lnt/util/NTEmailReport.py Thu Aug 12 11:03:59 2010 @@ -168,6 +168,22 @@ else: unchanged_tests[pset] = (name, cr) + # Collect the simplified results, if desired, for sending back to clients. + if result is not None: + test_results = result['test_results'] = [] + for pset in ts_summary.parameter_sets: + pset_results = [] + for name in test_names: + cr = sri.get_run_comparison_result( + run, run_status_kind, compare_to, compare_to_status_kind, + name, pset, comparison_window) + test_status = cr.get_test_status() + perf_status = cr.get_value_status() + # FIXME: Include additional information about performance + # changes. + pset_results.append( (name, test_status, perf_status) ) + test_results.append({ 'pset' : pset, 'results' : pset_results }) + # Generate the report. report = StringIO.StringIO() html_report = StringIO.StringIO() @@ -400,7 +416,6 @@ """ % locals() return subject, report.getvalue(), html_report - return subject, report.getvalue(), None def getReport(result, db, run, baseurl, was_added, will_commit): report = StringIO.StringIO() From daniel at zuster.org Thu Aug 12 11:04:01 2010 From: daniel at zuster.org (Daniel Dunbar) Date: Thu, 12 Aug 2010 16:04:01 -0000 Subject: [llvm-commits] [zorg] r110928 - /zorg/trunk/lnt/lnt/util/ImportData.py Message-ID: <20100812160402.010862A6C12E@llvm.org> Author: ddunbar Date: Thu Aug 12 11:04:01 2010 New Revision: 110928 URL: http://llvm.org/viewvc/llvm-project?rev=110928&view=rev Log: LNT/import: Add ImportData.print_report_result, which prints a submission result object in a human readable fashion. Actually, it's roughly the 'lit' format, so we can tie it directly to the buildbot 'lit' result parser. Modified: zorg/trunk/lnt/lnt/util/ImportData.py Modified: zorg/trunk/lnt/lnt/util/ImportData.py URL: http://llvm.org/viewvc/llvm-project/zorg/trunk/lnt/lnt/util/ImportData.py?rev=110928&r1=110927&r2=110928&view=diff ============================================================================== --- zorg/trunk/lnt/lnt/util/ImportData.py (original) +++ zorg/trunk/lnt/lnt/util/ImportData.py Thu Aug 12 11:04:01 2010 @@ -1,8 +1,9 @@ -import re, time +import os, re, time from lnt import formats -from lnt.viewer import PerfDB +from lnt.db import runinfo from lnt.util import NTEmailReport +from lnt.viewer import PerfDB def import_and_report(config, db_name, db, file, format, commit=False, show_sample_count=False, disable_email=False): @@ -67,11 +68,12 @@ result['error'] = "import failure: %s" % traceback.format_exc() return result - result['db_import_time'] = time.time() - importStartTime + result['import_time'] = time.time() - importStartTime if not success: # Record the original run this is a duplicate of. result['original_run'] = run.id + reportStartTime = time.time() result['report_to_address'] = toAddress NTEmailReport.emailReport(result, db, run, "%s/db_%s/" % (config.zorgURL, db_name), @@ -89,7 +91,127 @@ else: db.rollback() - result['import_time'] = time.time() - startTime + result['report_time'] = time.time() - importStartTime + result['total_time'] = time.time() - startTime result['success'] = True return result + +def print_report_result(result, out, verbose = True): + """ + import_and_report(result, out) -> None + + Print a human readable form of an import result object to the given output + stream. Test results are printed in 'lit' format. + """ + + # Print the generic import information. + print >>out, "Importing %r" % os.path.basename(result['import_file']) + if result['success']: + print >>out, "Import succeeded." + print >>out + else: + print >>out, "Import Failed:" + print >>out, "--\n%s--\n" % result['error'] + return + + if 'original_run' in result: + print >>out, ("This submission is a duplicate of run %d, " + "already in the database.") % result['original_run'] + print >>out + + if not result['committed']: + print >>out, "NOTE: This run was not committed!" + print >>out + + if result['report_to_address']: + print >>out, "Report emailed to: %r" % result['report_to_address'] + print >>out + + # Print the processing times. + print >>out, "Processing Times" + print >>out, "----------------" + print >>out, "Load : %.2fs" % result['load_time'] + print >>out, "Import : %.2fs" % result['import_time'] + print >>out, "Report : %.2fs" % result['report_time'] + print >>out, "Total : %.2fs" % result['total_time'] + print >>out + + # Print the added database items. + total_added = (result['added_machines'] + result['added_runs'] + + result['added_tests'] + result.get('added_samples', 0)) + if total_added: + print >>out, "Imported Data" + print >>out, "-------------" + if result['added_machines']: + print >>out, "Added Machines: %d" % result['added_machines'] + if result['added_runs']: + print >>out, "Added Runs : %d" % result['added_runs'] + if result['added_tests']: + print >>out, "Added Tests : %d" % result['added_tests'] + if result.get('added_samples', 0): + print >>out, "Added Samples : %.2fs" % result['added_samples'] + print >>out + + # Print the test results. + test_results = result.get('test_results') + if not test_results: + return + + # List the parameter sets, if interesting. + show_pset = len(test_results) > 1 + if show_pset: + print >>out, "Parameter Sets" + print >>out, "--------------" + for i,info in enumerate(test_results): + print >>out, "P%d: %s" % (i, info['pset']) + print >>out + + total_num_tests = sum([len(item['results']) + for item in test_results]) + print >>out, "--- Tested: %d tests --" % total_num_tests + test_index = 0 + for i,item in enumerate(test_results): + pset = item['pset'] + pset_results = item['results'] + + for name,test_status,perf_status in pset_results: + test_index += 1 + + # FIXME: Show extended information for performance changes, previous + # samples, standard deviation, all that. + # + # FIXME: Think longer about mapping to test codes. + result_info = None + if test_status == runinfo.REGRESSED: + result_string = 'FAIL' + elif test_status == runinfo.IMPROVED: + result_string = 'IMPROVED' + result_info = "Test started passing." + elif test_status == runinfo.UNCHANGED_FAIL: + result_string = 'XFAIL' + elif perf_status == None: + # Missing perf status means test was just added or removed. + result_string = 'PASS' + elif perf_status == runinfo.REGRESSED: + result_string = 'REGRESSED' + result_info = 'Performance regressed.' + elif perf_status == runinfo.IMPROVED: + result_string = 'IMPROVED' + result_info = 'Performance improved.' + else: + result_string = 'PASS' + + # Ignore passes unless in verbose mode. + if not verbose and result_string == 'PASS': + continue + + if show_pset: + name = 'P%d :: %s' % (i, name) + print >>out, "%s: %s (%d of %d)" % (result_string, name, test_index, + total_num_tests) + + if result_info: + print >>out, "%s TEST '%s' %s" % ('*'*20, name, '*'*20) + print >>out, result_info + print >>out, "*" * 20 From daniel at zuster.org Thu Aug 12 11:04:08 2010 From: daniel at zuster.org (Daniel Dunbar) Date: Thu, 12 Aug 2010 16:04:08 -0000 Subject: [llvm-commits] [zorg] r110930 - in /zorg/trunk/lnt/tests: DB/Import.py Web/WebSubmit.py Message-ID: <20100812160408.7303B2A6C12C@llvm.org> Author: ddunbar Date: Thu Aug 12 11:04:08 2010 New Revision: 110930 URL: http://llvm.org/viewvc/llvm-project?rev=110930&view=rev Log: LNT/tests: Update some tests for import formatting changs. Modified: zorg/trunk/lnt/tests/DB/Import.py zorg/trunk/lnt/tests/Web/WebSubmit.py Modified: zorg/trunk/lnt/tests/DB/Import.py URL: http://llvm.org/viewvc/llvm-project/zorg/trunk/lnt/tests/DB/Import.py?rev=110930&r1=110929&r2=110930&view=diff ============================================================================== --- zorg/trunk/lnt/tests/DB/Import.py (original) +++ zorg/trunk/lnt/tests/DB/Import.py Thu Aug 12 11:04:08 2010 @@ -4,27 +4,20 @@ # RUN: lnt import %t.install %S/Inputs/sample-a-small.plist --commit=1 --show-sample-count |\ # RUN: FileCheck -check-prefix=IMPORT-A-1 %s -# IMPORT-A-1: ADDED: 1 machines -# IMPORT-A-1: ADDED: 1 runs -# IMPORT-A-1: ADDED: 8 tests -# IMPORT-A-1: ADDED: 8 samples +# IMPORT-A-1: Added Machines: 1 +# IMPORT-A-1: Added Runs : 1 +# IMPORT-A-1: Added Tests : 8 +# IMPORT-A-1: Added Samples : 8 # RUN: lnt import %t.install %S/Inputs/sample-b-small.plist --commit=1 --show-sample-count |\ # RUN: FileCheck -check-prefix=IMPORT-B %s -# IMPORT-B: ADDED: 0 machines -# IMPORT-B: ADDED: 1 runs -# IMPORT-B: ADDED: 0 tests -# IMPORT-B: ADDED: 8 samples +# IMPORT-B: Added Runs : 1 # RUN: lnt import %t.install %S/Inputs/sample-a-small.plist --commit=1 --show-sample-count |\ # RUN: FileCheck -check-prefix=IMPORT-A-2 %s -# IMPORT-A-2: IGNORING DUPLICATE RUN -# IMPORT-A-2: ADDED: 0 machines -# IMPORT-A-2: ADDED: 0 runs -# IMPORT-A-2: ADDED: 0 tests -# IMPORT-A-2: ADDED: 0 samples +# IMPORT-A-2: This submission is a duplicate of run 1 # RUN: python %s %t.install/data/lnt.db Modified: zorg/trunk/lnt/tests/Web/WebSubmit.py URL: http://llvm.org/viewvc/llvm-project/zorg/trunk/lnt/tests/Web/WebSubmit.py?rev=110930&r1=110929&r2=110930&view=diff ============================================================================== --- zorg/trunk/lnt/tests/Web/WebSubmit.py (original) +++ zorg/trunk/lnt/tests/Web/WebSubmit.py Thu Aug 12 11:04:08 2010 @@ -1,18 +1,5 @@ # RUN: lnt submit %base_url/submitRun %S/../DB/Inputs/sample-a-small.plist > %t # RUN: FileCheck %s < %t -# CHECK: STATUS: 0 - -# CHECK: OUTPUT: -# CHECK: IMPORT: {{.*}}/lnt_tmp/{{.*}}.plist -# CHECK: LOAD TIME: {{.*}} -# CHECK: IMPORT TIME: {{.*}} -# CHECK: MACHINE: {{.*}} -# CHECK: START : {{.*}} -# CHECK: END : {{.*}} -# CHECK: INFO : u'tag' = u'nightlytest' -# CHECK: MAILING RESULTS TO: {{.*}} -# CHECK: ADDED: {{[0-9]*}} machines -# CHECK: ADDED: {{[0-9]*}} runs -# CHECK: ADDED: {{[0-9]*}} tests -# CHECK: DISCARDING RESULT: DONE +# CHECK: Importing u'{{.*}}.plist' +# CHECK: Import succeeded. From grosbach at apple.com Thu Aug 12 11:26:16 2010 From: grosbach at apple.com (Jim Grosbach) Date: Thu, 12 Aug 2010 16:26:16 -0000 Subject: [llvm-commits] [llvm-gcc-4.2] r110932 - in /llvm-gcc-4.2/trunk/gcc/config/arm: arm.c arm.h Message-ID: <20100812162617.128582A6C12D@llvm.org> Author: grosbach Date: Thu Aug 12 11:26:16 2010 New Revision: 110932 URL: http://llvm.org/viewvc/llvm-project?rev=110932&view=rev Log: fix v6 defaults and v6m detection. Modified: llvm-gcc-4.2/trunk/gcc/config/arm/arm.c llvm-gcc-4.2/trunk/gcc/config/arm/arm.h Modified: llvm-gcc-4.2/trunk/gcc/config/arm/arm.c URL: http://llvm.org/viewvc/llvm-project/llvm-gcc-4.2/trunk/gcc/config/arm/arm.c?rev=110932&r1=110931&r2=110932&view=diff ============================================================================== --- llvm-gcc-4.2/trunk/gcc/config/arm/arm.c (original) +++ llvm-gcc-4.2/trunk/gcc/config/arm/arm.c Thu Aug 12 11:26:16 2010 @@ -681,9 +681,6 @@ /* Nonzero if this chip supports the ARM 6K extensions. */ int arm_arch6k = 0; -/* Nonzero if this chip supports the ARM 6M extensions. */ -int arm_arch6m = 0; - /* APPLE LOCAL begin 6093388 -mfpu=neon default for v7a */ /* Nonzero if this chip supports the ARM 7A extensions. */ int arm_arch7a = 0; @@ -1474,8 +1471,7 @@ /* v7m and v6m processors don't have ARM mode, so default to thumb mode. Explicitly only set for default so we can error if the user sets -marm or -mno-thumb. */ - if (((insn_flags & FL_FOR_ARCH7M) == FL_FOR_ARCH7M - || (insn_flags & FL_FOR_ARCH6M) == FL_FOR_ARCH6M) + if (((insn_flags & FL_FOR_ARCH7M) == FL_FOR_ARCH7M || arm_tune == cortexm0) && thumb_option < 0) thumb_option = 1; /* LLVM LOCAL end */ @@ -1586,8 +1582,6 @@ arm_arch7a = (insn_flags & FL_FOR_ARCH7A) == FL_FOR_ARCH7A; /* APPLE LOCAL begin v7 support. Merge from mainline */ arm_arch7m = (insn_flags & FL_FOR_ARCH7M) == FL_FOR_ARCH7M; - /* LLVM LOCAL processor support */ - arm_arch6m = (insn_flags & FL_FOR_ARCH6M) == FL_FOR_ARCH6M; arm_arch_notm = (insn_flags & FL_NOTM) != 0; arm_arch_thumb2 = (insn_flags & FL_THUMB2) != 0; /* APPLE LOCAL end v7 support. Merge from mainline */ Modified: llvm-gcc-4.2/trunk/gcc/config/arm/arm.h URL: http://llvm.org/viewvc/llvm-project/llvm-gcc-4.2/trunk/gcc/config/arm/arm.h?rev=110932&r1=110931&r2=110932&view=diff ============================================================================== --- llvm-gcc-4.2/trunk/gcc/config/arm/arm.h (original) +++ llvm-gcc-4.2/trunk/gcc/config/arm/arm.h Thu Aug 12 11:26:16 2010 @@ -3532,7 +3532,7 @@ ? "thumbv7m" \ : (arm_arch_thumb2 \ ? "thumbv6t2" \ - : (arm_arch6m \ + : (arm_tune == cortexm0 \ ? "thumbv6m" \ : (arm_arch6 \ ? "thumbv6" \ @@ -3541,7 +3541,7 @@ : (arm_arch5 \ ? "thumbv5" \ : (arm_arch4t \ - ? "thumbv4t" : "")))))))) \ + ? "thumbv4t" : "")))))))) \ : (arm_arch7a \ ? "armv7" \ : (arm_arch_thumb2 \ From stoklund at 2pi.dk Thu Aug 12 12:07:14 2010 From: stoklund at 2pi.dk (Jakob Stoklund Olesen) Date: Thu, 12 Aug 2010 17:07:14 -0000 Subject: [llvm-commits] [llvm] r110934 - in /llvm/trunk/lib/CodeGen: InlineSpiller.cpp SplitKit.cpp SplitKit.h Message-ID: <20100812170715.065352A6C12E@llvm.org> Author: stoklund Date: Thu Aug 12 12:07:14 2010 New Revision: 110934 URL: http://llvm.org/viewvc/llvm-project?rev=110934&view=rev Log: Implement single block splitting. Before spilling a live range, we split it into a separate range for each basic block where it is used. That way we only get one reload per basic block if the new smaller ranges can allocate to a register. This type of splitting is already present in the standard spiller. Modified: llvm/trunk/lib/CodeGen/InlineSpiller.cpp llvm/trunk/lib/CodeGen/SplitKit.cpp llvm/trunk/lib/CodeGen/SplitKit.h Modified: llvm/trunk/lib/CodeGen/InlineSpiller.cpp URL: http://llvm.org/viewvc/llvm-project/llvm/trunk/lib/CodeGen/InlineSpiller.cpp?rev=110934&r1=110933&r2=110934&view=diff ============================================================================== --- llvm/trunk/lib/CodeGen/InlineSpiller.cpp (original) +++ llvm/trunk/lib/CodeGen/InlineSpiller.cpp Thu Aug 12 12:07:14 2010 @@ -118,6 +118,15 @@ .splitAroundLoop(loop)) return true; } + + // Try splitting into single block intervals. + SplitAnalysis::BlockPtrSet blocks; + if (splitAnalysis_.getMultiUseBlocks(blocks)) { + if (SplitEditor(splitAnalysis_, lis_, vrm_, *newIntervals_) + .splitSingleBlocks(blocks)) + return true; + } + return false; } Modified: llvm/trunk/lib/CodeGen/SplitKit.cpp URL: http://llvm.org/viewvc/llvm-project/llvm/trunk/lib/CodeGen/SplitKit.cpp?rev=110934&r1=110933&r2=110934&view=diff ============================================================================== --- llvm/trunk/lib/CodeGen/SplitKit.cpp (original) +++ llvm/trunk/lib/CodeGen/SplitKit.cpp Thu Aug 12 12:07:14 2010 @@ -279,6 +279,33 @@ return Best; } +/// getMultiUseBlocks - if curli has more than one use in a basic block, it +/// may be an advantage to split curli for the duration of the block. +bool SplitAnalysis::getMultiUseBlocks(BlockPtrSet &Blocks) { + // If curli is local to one block, there is no point to splitting it. + if (usingBlocks_.size() <= 1) + return false; + // Add blocks with multiple uses. + for (BlockCountMap::iterator I = usingBlocks_.begin(), E = usingBlocks_.end(); + I != E; ++I) + switch (I->second) { + case 0: + case 1: + continue; + case 2: { + // It doesn't pay to split a 2-instr block if it redefines curli. + VNInfo *VN1 = curli_->getVNInfoAt(lis_.getMBBStartIdx(I->first)); + VNInfo *VN2 = + curli_->getVNInfoAt(lis_.getMBBEndIdx(I->first).getPrevIndex()); + // live-in and live-out with a different value. + if (VN1 && VN2 && VN1 != VN2) + continue; + } // Fall through. + default: + Blocks.insert(I->first); + } + return !Blocks.empty(); +} //===----------------------------------------------------------------------===// // Split Editor @@ -351,6 +378,27 @@ liveThrough_ = false; } +/// enterIntvBefore - Enter openli before the instruction at Idx. If curli is +/// not live before Idx, a COPY is not inserted. +void SplitEditor::enterIntvBefore(SlotIndex Idx) { + assert(openli_ && "openIntv not called before enterIntvBefore"); + + // Copy from curli_ if it is live. + if (VNInfo *CurVNI = curli_->getVNInfoAt(Idx.getUseIndex())) { + MachineInstr *MI = lis_.getInstructionFromIndex(Idx); + assert(MI && "enterIntvBefore called with invalid index"); + VNInfo *VNI = insertCopy(*openli_, *MI->getParent(), MI); + openli_->addRange(LiveRange(VNI->def, Idx.getDefIndex(), VNI)); + + // Make sure CurVNI is properly mapped. + VNInfo *&mapVNI = valueMap_[CurVNI]; + // We dont have SSA update yet, so only one entry per value is allowed. + assert(!mapVNI && "enterIntvBefore called more than once for the same value"); + mapVNI = VNI; + } + DEBUG(dbgs() << " enterIntvBefore " << Idx << ": " << *openli_ << '\n'); +} + /// enterIntvAtEnd - Enter openli at the end of MBB. /// PhiMBB is a successor inside openli where a PHI value is created. /// Currently, all entries must share the same PhiMBB. @@ -435,6 +483,39 @@ << '\n'); } +/// leaveIntvAfter - Leave openli after the instruction at Idx. +void SplitEditor::leaveIntvAfter(SlotIndex Idx) { + assert(openli_ && "openIntv not called before leaveIntvAfter"); + + const LiveRange *CurLR = curli_->getLiveRangeContaining(Idx.getDefIndex()); + if (!CurLR || CurLR->end <= Idx.getBoundaryIndex()) { + DEBUG(dbgs() << " leaveIntvAfter at " << Idx << ": not live\n"); + return; + } + + // Was this value of curli live through openli? + if (!openli_->liveAt(CurLR->valno->def)) { + DEBUG(dbgs() << " leaveIntvAfter " << Idx << ": using external value\n"); + liveThrough_ = true; + return; + } + + // We are going to insert a back copy, so we must have a dupli_. + LiveRange *DupLR = getDupLI()->getLiveRangeContaining(Idx.getDefIndex()); + assert(DupLR && "dupli not live into black, but curli is?"); + + // Insert the COPY instruction. + MachineBasicBlock::iterator I = lis_.getInstructionFromIndex(Idx); + MachineInstr *MI = BuildMI(*I->getParent(), llvm::next(I), I->getDebugLoc(), + tii_.get(TargetOpcode::COPY), dupli_->reg) + .addReg(openli_->reg); + SlotIndex CopyIdx = lis_.InsertMachineInstrInMaps(MI).getDefIndex(); + openli_->addRange(LiveRange(Idx.getDefIndex(), CopyIdx, + mapValue(CurLR->valno))); + DupLR->valno->def = CopyIdx; + DEBUG(dbgs() << " leaveIntvAfter " << Idx << ": " << *openli_ << '\n'); +} + /// leaveIntvAtTop - Leave the interval at the top of MBB. /// Currently, only one value can leave the interval. void SplitEditor::leaveIntvAtTop(MachineBasicBlock &MBB) { @@ -528,6 +609,7 @@ DEBUG(dbgs() << " dup2 " << *dupli_ << '\n'); } openli_ = 0; + valueMap_.clear(); } /// rewrite - after all the new live ranges have been created, rewrite @@ -620,3 +702,49 @@ return dupli_; } + +//===----------------------------------------------------------------------===// +// Single Block Splitting +//===----------------------------------------------------------------------===// + +/// splitSingleBlocks - Split curli into a separate live interval inside each +/// basic block in Blocks. Return true if curli has been completely replaced, +/// false if curli is still intact, and needs to be spilled or split further. +bool SplitEditor::splitSingleBlocks(const SplitAnalysis::BlockPtrSet &Blocks) { + DEBUG(dbgs() << "splitSingleBlocks for " << Blocks.size() << " blocks.\n"); + // Determine the first and last instruction using curli in each block. + typedef std::pair IndexPair; + typedef DenseMap IndexPairMap; + IndexPairMap MBBRange; + for (SplitAnalysis::InstrPtrSet::const_iterator I = sa_.usingInstrs_.begin(), + E = sa_.usingInstrs_.end(); I != E; ++I) { + const MachineBasicBlock *MBB = (*I)->getParent(); + if (!Blocks.count(MBB)) + continue; + SlotIndex Idx = lis_.getInstructionIndex(*I); + DEBUG(dbgs() << "BB#" << MBB->getNumber() << '\t' << Idx << '\t' << **I); + IndexPair &IP = MBBRange[MBB]; + if (!IP.first.isValid() || Idx < IP.first) + IP.first = Idx; + if (!IP.second.isValid() || Idx > IP.second) + IP.second = Idx; + } + + // Create a new interval for each block. + for (SplitAnalysis::BlockPtrSet::const_iterator I = Blocks.begin(), + E = Blocks.end(); I != E; ++I) { + IndexPair &IP = MBBRange[*I]; + DEBUG(dbgs() << "Splitting for BB#" << (*I)->getNumber() << ": [" + << IP.first << ';' << IP.second << ")\n"); + assert(IP.first.isValid() && IP.second.isValid()); + + openIntv(); + enterIntvBefore(IP.first); + useIntv(IP.first.getBaseIndex(), IP.second.getBoundaryIndex()); + leaveIntvAfter(IP.second); + closeIntv(); + } + rewrite(); + return dupli_; +} + Modified: llvm/trunk/lib/CodeGen/SplitKit.h URL: http://llvm.org/viewvc/llvm-project/llvm/trunk/lib/CodeGen/SplitKit.h?rev=110934&r1=110933&r2=110934&view=diff ============================================================================== --- llvm/trunk/lib/CodeGen/SplitKit.h (original) +++ llvm/trunk/lib/CodeGen/SplitKit.h Thu Aug 12 12:07:14 2010 @@ -37,10 +37,6 @@ const MachineLoopInfo &loops_; const TargetInstrInfo &tii_; -private: - // Current live interval. - const LiveInterval *curli_; - // Instructions using the the current register. typedef SmallPtrSet InstrPtrSet; InstrPtrSet usingInstrs_; @@ -53,6 +49,10 @@ typedef SmallPtrSet LoopPtrSet; LoopPtrSet usingLoops_; +private: + // Current live interval. + const LiveInterval *curli_; + // Sumarize statistics by counting instructions using curli_. void analyzeUses(); @@ -118,6 +118,11 @@ /// getBestSplitLoop - Return the loop where curli may best be split to a /// separate register, or NULL. const MachineLoop *getBestSplitLoop(); + + /// getMultiUseBlocks - Add basic blocks to Blocks that may benefit from + /// having curli split to a new live interval. Return true if Blocks can be + /// passed to SplitEditor::splitSingleBlocks. + bool getMultiUseBlocks(BlockPtrSet &Blocks); }; /// SplitEditor - Edit machine code and LiveIntervals for live range @@ -156,7 +161,7 @@ /// getDupLI - Ensure dupli is created and return it. LiveInterval *getDupLI(); - /// valueMap_ - Map values in dupli to values in openIntv. These are direct 1-1 + /// valueMap_ - Map values in cupli to values in openli. These are direct 1-1 /// mappings, and do not include values created by inserted copies. DenseMap valueMap_; @@ -192,6 +197,10 @@ /// Create a new virtual register and live interval. void openIntv(); + /// enterIntvBefore - Enter openli before the instruction at Idx. If curli is + /// not live before Idx, a COPY is not inserted. + void enterIntvBefore(SlotIndex Idx); + /// enterIntvAtEnd - Enter openli at the end of MBB. /// PhiMBB is a successor inside openli where a PHI value is created. /// Currently, all entries must share the same PhiMBB. @@ -203,6 +212,9 @@ /// useIntv - indicate that all instructions in range should use openli. void useIntv(SlotIndex Start, SlotIndex End); + /// leaveIntvAfter - Leave openli after the instruction at Idx. + void leaveIntvAfter(SlotIndex Idx); + /// leaveIntvAtTop - Leave the interval at the top of MBB. /// Currently, only one value can leave the interval. void leaveIntvAtTop(MachineBasicBlock &MBB); @@ -222,6 +234,10 @@ /// curli is still intact, and needs to be spilled or split further. bool splitAroundLoop(const MachineLoop*); + /// splitSingleBlocks - Split curli into a separate live interval inside each + /// basic block in Blocks. Return true if curli has been completely replaced, + /// false if curli is still intact, and needs to be spilled or split further. + bool splitSingleBlocks(const SplitAnalysis::BlockPtrSet &Blocks); }; From bob.wilson at apple.com Thu Aug 12 12:31:41 2010 From: bob.wilson at apple.com (Bob Wilson) Date: Thu, 12 Aug 2010 17:31:41 -0000 Subject: [llvm-commits] [llvm] r110935 - /llvm/trunk/test/FrontendC/2010-08-12-asm-aggr-arg.c Message-ID: <20100812173141.C9F722A6C12C@llvm.org> Author: bwilson Date: Thu Aug 12 12:31:41 2010 New Revision: 110935 URL: http://llvm.org/viewvc/llvm-project?rev=110935&view=rev Log: Add a test for llvm-gcc svn 110632. Added: llvm/trunk/test/FrontendC/2010-08-12-asm-aggr-arg.c Added: llvm/trunk/test/FrontendC/2010-08-12-asm-aggr-arg.c URL: http://llvm.org/viewvc/llvm-project/llvm/trunk/test/FrontendC/2010-08-12-asm-aggr-arg.c?rev=110935&view=auto ============================================================================== --- llvm/trunk/test/FrontendC/2010-08-12-asm-aggr-arg.c (added) +++ llvm/trunk/test/FrontendC/2010-08-12-asm-aggr-arg.c Thu Aug 12 12:31:41 2010 @@ -0,0 +1,16 @@ +// RUN: %llvmgcc %s -S -O0 -o - | FileCheck %s +// Radar 8288710: A small aggregate can be passed as an integer. Make sure +// we don't get an error with "input constraint with a matching output +// constraint of incompatible type!" + +struct wrapper { + int i; +}; + +// CHECK: xyz +int test(int i) { + struct wrapper w; + w.i = i; + __asm__("xyz" : "=r" (w) : "0" (w)); + return w.i; +} From bob.wilson at apple.com Thu Aug 12 12:33:03 2010 From: bob.wilson at apple.com (Bob Wilson) Date: Thu, 12 Aug 2010 10:33:03 -0700 Subject: [llvm-commits] [llvm-gcc-4.2] r110632 - /llvm-gcc-4.2/trunk/gcc/llvm-convert.cpp In-Reply-To: <56FBB8EF-6D66-4BA8-933B-E039065DCC03@apple.com> References: <20100810001113.BF9CC2A6C12C@llvm.org> <4C62743C.7070409@free.fr> <56FBB8EF-6D66-4BA8-933B-E039065DCC03@apple.com> Message-ID: Nevermind that. I realized I could reproduce the bug without any ARM-specific code at all. I added a testcase in svn 110935. Thanks for prodding me to think about it some more! On Aug 11, 2010, at 10:29 AM, Bob Wilson wrote: > > On Aug 11, 2010, at 2:58 AM, Duncan Sands wrote: > >> Hi Bob, >> >>> Change EmitASM_EXPR to record the original type of an asm input, before the >>> special case of treating small structs and unions as integers. If the >>> operand has a matching constraint and it is tied to one of the outputs >>> (for which small aggregates are not treated as integers), use that original >>> type to compare against the output operand. Radar 8288710. >> >> testcase? > > I was anticipating your request and actually created a testcase yesterday, but then I threw it away because I can't test it. We run the FrontendC tests with the host compiler, which for me is x86. I only have ARM cross compilers. The testcase is also specific to NEON. I might be able to come up with something that only requires VFP instead of NEON, but I don't know of a way to make a FrontendC test conditional on details of the target like that. > _______________________________________________ > llvm-commits mailing list > llvm-commits at cs.uiuc.edu > http://lists.cs.uiuc.edu/mailman/listinfo/llvm-commits From daniel at zuster.org Thu Aug 12 12:38:13 2010 From: daniel at zuster.org (Daniel Dunbar) Date: Thu, 12 Aug 2010 10:38:13 -0700 Subject: [llvm-commits] [PATCH 1/5] ELF entry size support. In-Reply-To: References: Message-ID: OK! - Daniel On Wed, Aug 11, 2010 at 3:20 PM, Matt Fleming wrote: > Some ELF sections contain fixed-sized entries. Provide a way to record > the entry size of a section. > --- > ?include/llvm/MC/MCContext.h ? ?| ? ?3 ++- > ?include/llvm/MC/MCSectionELF.h | ? ?5 +++++ > ?2 files changed, 7 insertions(+), 1 deletions(-) > > diff --git a/include/llvm/MC/MCContext.h b/include/llvm/MC/MCContext.h > index 4db0491..17e79fb 100644 > --- a/include/llvm/MC/MCContext.h > +++ b/include/llvm/MC/MCContext.h > @@ -129,7 +129,8 @@ namespace llvm { > > ? ? const MCSection *getELFSection(StringRef Section, unsigned Type, > ? ? ? ? ? ? ? ? ? ? ? ? ? ? ? ? ? ?unsigned Flags, SectionKind Kind, > - ? ? ? ? ? ? ? ? ? ? ? ? ? ? ? ? ? bool IsExplicit = false); > + ? ? ? ? ? ? ? ? ? ? ? ? ? ? ? ? ? bool IsExplicit = false, > + ? ? ? ? ? ? ? ? ? ? ? ? ? ? ? ? ? unsigned EntrySize = 0); > > ? ? const MCSection *getCOFFSection(StringRef Section, unsigned Characteristics, > ? ? ? ? ? ? ? ? ? ? ? ? ? ? ? ? ? ? int Selection, SectionKind Kind); > diff --git a/include/llvm/MC/MCSectionELF.h b/include/llvm/MC/MCSectionELF.h > index 5fe8171..a90aa38 100644 > --- a/include/llvm/MC/MCSectionELF.h > +++ b/include/llvm/MC/MCSectionELF.h > @@ -35,6 +35,11 @@ class MCSectionELF : public MCSection { > ? /// IsExplicit - Indicates that this section comes from globals with an > ? /// explicit section specified. > ? bool IsExplicit; > + > + ?/// EntrySize - The size of each entry in this section. This size only > + ?/// makes sense for sections that contain fixed-sized entries. If a > + ?/// section does not contain fixed-sized entries 'EntrySize' will be 0. > + ?unsigned EntrySize; > > ?private: > ? friend class MCContext; > -- > 1.6.4.rc0 > > From daniel at zuster.org Thu Aug 12 12:44:05 2010 From: daniel at zuster.org (Daniel Dunbar) Date: Thu, 12 Aug 2010 10:44:05 -0700 Subject: [llvm-commits] [PATCH 0/5] ELF object support In-Reply-To: References: Message-ID: Hi Matt, I scanned the patches, they look reasonable to me. I have more review comments, but I am eager to see this stuff land and I know others are as well. I would rather get it in, and work from there. Assuming this stuff works, and passes some basic sanity checks, can you go ahead and commit it? It would be nice to get some tests for it -- have you thought at all about writing a simple ELF object file dumping tool like we have for Mach-O and COFF? - Daniel On Wed, Aug 11, 2010 at 3:20 PM, Matt Fleming wrote: > This series contains the patches that have been sitting in my github > tree that me and Roman Divacky have been working on for a while now. It > isn't a complete implementation but is enough to get a semi-complete > relocatable ELF file emitted. > > This is version 2 of the series. I've reworked some of the code based on > comments and feedback from the llvm-commits list and Eli Friedman. The > ELF object writer code is now endian safe, many magic numbers have been > replaced with symbols and MCELFStreamer now inherits from > MCObjectStreamer instead of MCStreamer. > > Again, all comments welcome. > > Matt Fleming (5): > ?ELF entry size support. > ?Record a symbol's size which is needed for ELF symbol tables. > ?Layout helper function. > ?Add ELF ObjectWriter and Streamer support. > ?Hookup ELF support for X86. > > ?include/llvm/MC/ELFObjectWriter.h ? | ? 46 ++ > ?include/llvm/MC/MCAssembler.h ? ? ? | ? 16 + > ?include/llvm/MC/MCContext.h ? ? ? ? | ? ?3 +- > ?include/llvm/MC/MCELFSymbolFlags.h ?| ? 54 ++ > ?include/llvm/MC/MCSectionELF.h ? ? ?| ? 10 +- > ?include/llvm/MC/MCStreamer.h ? ? ? ?| ? ?6 + > ?include/llvm/Support/ELF.h ? ? ? ? ?| ? ?6 + > ?lib/MC/CMakeLists.txt ? ? ? ? ? ? ? | ? ?2 + > ?lib/MC/ELFObjectWriter.cpp ? ? ? ? ?| 1032 +++++++++++++++++++++++++++++++++++ > ?lib/MC/MCAssembler.cpp ? ? ? ? ? ? ?| ? 37 ++- > ?lib/MC/MCContext.cpp ? ? ? ? ? ? ? ?| ? ?4 +- > ?lib/MC/MCELFStreamer.cpp ? ? ? ? ? ?| ?401 ++++++++++++++ > ?lib/Target/X86/X86AsmBackend.cpp ? ?| ? 17 +- > ?lib/Target/X86/X86TargetMachine.cpp | ? ?3 +- > ?14 files changed, 1625 insertions(+), 12 deletions(-) > ?create mode 100644 include/llvm/MC/ELFObjectWriter.h > ?create mode 100644 include/llvm/MC/MCELFSymbolFlags.h > ?create mode 100644 lib/MC/ELFObjectWriter.cpp > ?create mode 100644 lib/MC/MCELFStreamer.cpp > > From bruno.cardoso at gmail.com Thu Aug 12 13:20:59 2010 From: bruno.cardoso at gmail.com (Bruno Cardoso Lopes) Date: Thu, 12 Aug 2010 18:20:59 -0000 Subject: [llvm-commits] [llvm] r110937 - in /llvm/trunk/lib/Target/X86: X86InstrSSE.td X86MCInstLower.cpp Message-ID: <20100812182059.705EF2A6C12C@llvm.org> Author: bruno Date: Thu Aug 12 13:20:59 2010 New Revision: 110937 URL: http://llvm.org/viewvc/llvm-project?rev=110937&view=rev Log: Define AVX 128-bit pattern versions of SET0PS/PD. Modified: llvm/trunk/lib/Target/X86/X86InstrSSE.td llvm/trunk/lib/Target/X86/X86MCInstLower.cpp Modified: llvm/trunk/lib/Target/X86/X86InstrSSE.td URL: http://llvm.org/viewvc/llvm-project/llvm/trunk/lib/Target/X86/X86InstrSSE.td?rev=110937&r1=110936&r2=110937&view=diff ============================================================================== --- llvm/trunk/lib/Target/X86/X86InstrSSE.td (original) +++ llvm/trunk/lib/Target/X86/X86InstrSSE.td Thu Aug 12 13:20:59 2010 @@ -2186,12 +2186,21 @@ [(set VR128:$dst, (v4i32 immAllZerosV))]>; } +// The same as done above but for AVX. The 128-bit versions are the +// same, but re-encoded. The 256-bit does not support PI version. let isReMaterializable = 1, isAsCheapAsAMove = 1, canFoldAsLoad = 1, isCodeGenOnly = 1, Predicates = [HasAVX] in { -def V_SET0PSY : PSI<0x57, MRMInitReg, (outs VR256:$dst), (ins), "", - [(set VR256:$dst, (v8f32 immAllZerosV))]>, VEX_4V; -def V_SET0PDY : PDI<0x57, MRMInitReg, (outs VR256:$dst), (ins), "", - [(set VR256:$dst, (v4f64 immAllZerosV))]>, VEX_4V; +def AVX_SET0PS : PSI<0x57, MRMInitReg, (outs VR128:$dst), (ins), "", + [(set VR128:$dst, (v4f32 immAllZerosV))]>, VEX_4V; +def AVX_SET0PD : PDI<0x57, MRMInitReg, (outs VR128:$dst), (ins), "", + [(set VR128:$dst, (v2f64 immAllZerosV))]>, VEX_4V; +def AVX_SET0PSY : PSI<0x57, MRMInitReg, (outs VR256:$dst), (ins), "", + [(set VR256:$dst, (v8f32 immAllZerosV))]>, VEX_4V; +def AVX_SET0PDY : PDI<0x57, MRMInitReg, (outs VR256:$dst), (ins), "", + [(set VR256:$dst, (v4f64 immAllZerosV))]>, VEX_4V; +let ExeDomain = SSEPackedInt in +def AVX_SET0PI : PDI<0xEF, MRMInitReg, (outs VR128:$dst), (ins), "", + [(set VR128:$dst, (v4i32 immAllZerosV))]>; } def : Pat<(v2i64 immAllZerosV), (V_SET0PI)>; Modified: llvm/trunk/lib/Target/X86/X86MCInstLower.cpp URL: http://llvm.org/viewvc/llvm-project/llvm/trunk/lib/Target/X86/X86MCInstLower.cpp?rev=110937&r1=110936&r2=110937&view=diff ============================================================================== --- llvm/trunk/lib/Target/X86/X86MCInstLower.cpp (original) +++ llvm/trunk/lib/Target/X86/X86MCInstLower.cpp Thu Aug 12 13:20:59 2010 @@ -377,11 +377,14 @@ case X86::FsFLD0SS: LowerUnaryToTwoAddr(OutMI, X86::PXORrr); break; case X86::FsFLD0SD: LowerUnaryToTwoAddr(OutMI, X86::PXORrr); break; case X86::V_SET0PS: LowerUnaryToTwoAddr(OutMI, X86::XORPSrr); break; - case X86::V_SET0PSY: LowerUnaryToTwoAddr(OutMI, X86::VXORPSYrr); break; case X86::V_SET0PD: LowerUnaryToTwoAddr(OutMI, X86::XORPDrr); break; - case X86::V_SET0PDY: LowerUnaryToTwoAddr(OutMI, X86::VXORPDYrr); break; case X86::V_SET0PI: LowerUnaryToTwoAddr(OutMI, X86::PXORrr); break; case X86::V_SETALLONES: LowerUnaryToTwoAddr(OutMI, X86::PCMPEQDrr); break; + case X86::AVX_SET0PS: LowerUnaryToTwoAddr(OutMI, X86::VXORPSrr); break; + case X86::AVX_SET0PSY: LowerUnaryToTwoAddr(OutMI, X86::VXORPSYrr); break; + case X86::AVX_SET0PD: LowerUnaryToTwoAddr(OutMI, X86::VXORPDrr); break; + case X86::AVX_SET0PDY: LowerUnaryToTwoAddr(OutMI, X86::VXORPDYrr); break; + case X86::AVX_SET0PI: LowerUnaryToTwoAddr(OutMI, X86::VPXORrr); break; case X86::MOV16r0: LowerSubReg32_Op0(OutMI, X86::MOV32r0); // MOV16r0 -> MOV32r0 From criswell at uiuc.edu Thu Aug 12 13:39:34 2010 From: criswell at uiuc.edu (John Criswell) Date: Thu, 12 Aug 2010 18:39:34 -0000 Subject: [llvm-commits] [poolalloc] r110938 - /poolalloc/trunk/lib/DSA/EquivClassGraphs.cpp Message-ID: <20100812183934.67D6E2A6C12C@llvm.org> Author: criswell Date: Thu Aug 12 13:39:34 2010 New Revision: 110938 URL: http://llvm.org/viewvc/llvm-project?rev=110938&view=rev Log: Improved formatting and commenting. No functionality changes. Modified: poolalloc/trunk/lib/DSA/EquivClassGraphs.cpp Modified: poolalloc/trunk/lib/DSA/EquivClassGraphs.cpp URL: http://llvm.org/viewvc/llvm-project/poolalloc/trunk/lib/DSA/EquivClassGraphs.cpp?rev=110938&r1=110937&r2=110938&view=diff ============================================================================== --- poolalloc/trunk/lib/DSA/EquivClassGraphs.cpp (original) +++ poolalloc/trunk/lib/DSA/EquivClassGraphs.cpp Thu Aug 12 13:39:34 2010 @@ -58,29 +58,68 @@ // that transforms like Automatic Pool Allocation only see one graph for a // call site. // +// After this method is executed, all functions in an equivalence class will +// have the *same* DSGraph. +// void EquivBUDataStructures::mergeGraphsByGlobalECs() { // - // Merge the graphs for each equivalence class. + // Merge the graphs for each equivalence class. We first scan all elements + // in the equivalence classes and look for those elements which are leaders. + // For each leader, we scan through all of its members and merge the DSGraphs + // for members which are functions. // - for (EquivalenceClasses::iterator EQSI = GlobalECs.begin(), - EQSE = GlobalECs.end(); EQSI != EQSE; ++EQSI) { + EquivalenceClasses::iterator EQSI = GlobalECs.begin(); + EquivalenceClasses::iterator EQSE = GlobalECs.end(); + for (;EQSI != EQSE; ++EQSI) { + // + // If this element is not a leader, then skip it. + // if (!EQSI->isLeader()) continue; DSGraph* BaseGraph = 0; std::vector Args; - for (EquivalenceClasses::member_iterator MI = GlobalECs.member_begin(EQSI); - MI != GlobalECs.member_end(); ++MI) { + + // + // Iterate through all members of this equivalence class, looking for + // functions. + // + EquivalenceClasses::member_iterator MI; + for (MI = GlobalECs.member_begin(EQSI); MI != GlobalECs.member_end(); ++MI){ if (const Function* F = dyn_cast(*MI)) { - if(F->isDeclaration()) //ignore functions with no body - continue; + // + // If the function has no body, then it has no DSGraph. + // + // FIXME: I don't believe this is correct; the stdlib pass can assign + // DSGraphs to C standard library functions. + // + if (F->isDeclaration()) + continue; + + // + // We have one of three possibilities: + // 1) This is the first function we've seen. If so, grab its DSGraph + // and the DSNodes for its arguments. + // + // 2) We have already seen this function before. Do nothing. + // + // 3) We haven't seen this function before, and it's not the first one + // we've seen. Merge its DSGraph into the DSGraph we're creating. + // if (!BaseGraph) { BaseGraph = getOrCreateGraph(F); BaseGraph->getFunctionArgumentsForCall(F, Args); } else if (BaseGraph->containsFunction(F)) { - //already merged + // The DSGraph for this function has already been merged. } else { - std::vector NextArgs; + // + // Merge in the DSGraph. + // BaseGraph->cloneInto(getOrCreateGraph(F)); + + // + // Merge the arguments together. + // + std::vector NextArgs; BaseGraph->getFunctionArgumentsForCall(F, NextArgs); unsigned i = 0, e = Args.size(); for (; i != e; ++i) { @@ -89,6 +128,11 @@ } for (e = NextArgs.size(); i != e; ++i) Args.push_back(NextArgs[i]); + + // + // Make this function use the DSGraph that we're creating for all of + // the functions in this equivalence class. + // setDSGraph(*F, BaseGraph); } } From stoklund at 2pi.dk Thu Aug 12 13:50:55 2010 From: stoklund at 2pi.dk (Jakob Stoklund Olesen) Date: Thu, 12 Aug 2010 18:50:55 -0000 Subject: [llvm-commits] [llvm] r110940 - in /llvm/trunk/lib/CodeGen: CalcSpillWeights.cpp SplitKit.cpp Message-ID: <20100812185055.D552F2A6C12C@llvm.org> Author: stoklund Date: Thu Aug 12 13:50:55 2010 New Revision: 110940 URL: http://llvm.org/viewvc/llvm-project?rev=110940&view=rev Log: Clean up debug output. Modified: llvm/trunk/lib/CodeGen/CalcSpillWeights.cpp llvm/trunk/lib/CodeGen/SplitKit.cpp Modified: llvm/trunk/lib/CodeGen/CalcSpillWeights.cpp URL: http://llvm.org/viewvc/llvm-project/llvm/trunk/lib/CodeGen/CalcSpillWeights.cpp?rev=110940&r1=110939&r2=110940&view=diff ============================================================================== --- llvm/trunk/lib/CodeGen/CalcSpillWeights.cpp (original) +++ llvm/trunk/lib/CodeGen/CalcSpillWeights.cpp Thu Aug 12 13:50:55 2010 @@ -201,8 +201,6 @@ // This could happen if reg is only used by COPY instructions, so we may need // to improve on this. if (rcs.empty()) { - DEBUG(dbgs() << "Not inflating unconstrained" << orc->getName() << ":%reg" - << reg << ".\n"); return; } Modified: llvm/trunk/lib/CodeGen/SplitKit.cpp URL: http://llvm.org/viewvc/llvm-project/llvm/trunk/lib/CodeGen/SplitKit.cpp?rev=110940&r1=110939&r2=110940&view=diff ============================================================================== --- llvm/trunk/lib/CodeGen/SplitKit.cpp (original) +++ llvm/trunk/lib/CodeGen/SplitKit.cpp Thu Aug 12 13:50:55 2010 @@ -72,11 +72,10 @@ if (MachineLoop *Loop = loops_.getLoopFor(MBB)) usingLoops_.insert(Loop); } - DEBUG(dbgs() << "Counted " + DEBUG(dbgs() << " counted " << usingInstrs_.size() << " instrs, " << usingBlocks_.size() << " blocks, " - << usingLoops_.size() << " loops in " - << *curli_ << "\n"); + << usingLoops_.size() << " loops.\n"); } // Get three sets of basic blocks surrounding a loop: Blocks inside the loop, @@ -226,7 +225,7 @@ // FIXME: We need an SSA updater to properly handle multiple exit blocks. if (Blocks.Exits.size() > 1) { - DEBUG(dbgs() << "MultipleExits: " << **I); + DEBUG(dbgs() << " multiple exits from " << **I); continue; } @@ -239,15 +238,16 @@ LPS = &SecondLoops; break; case ContainedInLoop: - DEBUG(dbgs() << "ContainedInLoop: " << **I); + DEBUG(dbgs() << " contained in " << **I); continue; case SinglePeripheral: - DEBUG(dbgs() << "SinglePeripheral: " << **I); + DEBUG(dbgs() << " single peripheral use in " << **I); continue; } // Will it be possible to split around this loop? getCriticalExits(Blocks, CriticalExits); - DEBUG(dbgs() << CriticalExits.size() << " critical exits: " << **I); + DEBUG(dbgs() << " " << CriticalExits.size() << " critical exits from " + << **I); if (!canSplitCriticalExits(Blocks, CriticalExits)) continue; // This is a possible split. @@ -255,8 +255,8 @@ LPS->insert(*I); } - DEBUG(dbgs() << "Got " << Loops.size() << " + " << SecondLoops.size() - << " candidate loops\n"); + DEBUG(dbgs() << " getBestSplitLoop found " << Loops.size() << " + " + << SecondLoops.size() << " candidate loops.\n"); // If there are no first class loops available, look at second class loops. if (Loops.empty()) @@ -275,7 +275,7 @@ if (!Best || Idx < BestIdx) Best = *I, BestIdx = Idx; } - DEBUG(dbgs() << "Best: " << *Best); + DEBUG(dbgs() << " getBestSplitLoop found " << *Best); return Best; } @@ -345,7 +345,6 @@ // Create an interval for dupli that is a copy of curli. dupli_ = createInterval(); dupli_->Copy(*curli_, &mri_, lis_.getVNInfoAllocator()); - DEBUG(dbgs() << "SplitEditor DupLI: " << *dupli_ << '\n'); } return dupli_; } @@ -396,7 +395,7 @@ assert(!mapVNI && "enterIntvBefore called more than once for the same value"); mapVNI = VNI; } - DEBUG(dbgs() << " enterIntvBefore " << Idx << ": " << *openli_ << '\n'); + DEBUG(dbgs() << " enterIntvBefore " << Idx << ": " << *openli_ << '\n'); } /// enterIntvAtEnd - Enter openli at the end of MBB. @@ -408,7 +407,7 @@ SlotIndex EndA = lis_.getMBBEndIdx(&A); VNInfo *CurVNIA = curli_->getVNInfoAt(EndA.getPrevIndex()); if (!CurVNIA) { - DEBUG(dbgs() << " ignoring enterIntvAtEnd, curli not live out of BB#" + DEBUG(dbgs() << " enterIntvAtEnd, curli not live out of BB#" << A.getNumber() << ".\n"); return; } @@ -426,7 +425,7 @@ SlotIndex EndB = lis_.getMBBEndIdx(&B); const LiveRange *CurB = curli_->getLiveRangeContaining(StartB); if (!CurB) { - DEBUG(dbgs() << " enterIntvAtEnd: curli not live in to BB#" + DEBUG(dbgs() << " enterIntvAtEnd: curli not live in to BB#" << B.getNumber() << ".\n"); return; } @@ -451,7 +450,7 @@ } - DEBUG(dbgs() << " enterIntvAtEnd: " << *openli_ << '\n'); + DEBUG(dbgs() << " enterIntvAtEnd: " << *openli_ << '\n'); } /// useIntv - indicate that all instructions in MBB should use openli. @@ -479,7 +478,7 @@ for (;I != E && I->start < End; ++I) openli_->addRange(LiveRange(I->start, std::min(End, I->end), mapValue(I->valno))); - DEBUG(dbgs() << " added range [" << Start << ';' << End << "): " << *openli_ + DEBUG(dbgs() << " use [" << Start << ';' << End << "): " << *openli_ << '\n'); } @@ -489,13 +488,13 @@ const LiveRange *CurLR = curli_->getLiveRangeContaining(Idx.getDefIndex()); if (!CurLR || CurLR->end <= Idx.getBoundaryIndex()) { - DEBUG(dbgs() << " leaveIntvAfter at " << Idx << ": not live\n"); + DEBUG(dbgs() << " leaveIntvAfter " << Idx << ": not live\n"); return; } // Was this value of curli live through openli? if (!openli_->liveAt(CurLR->valno->def)) { - DEBUG(dbgs() << " leaveIntvAfter " << Idx << ": using external value\n"); + DEBUG(dbgs() << " leaveIntvAfter " << Idx << ": using external value\n"); liveThrough_ = true; return; } @@ -513,7 +512,7 @@ openli_->addRange(LiveRange(Idx.getDefIndex(), CopyIdx, mapValue(CurLR->valno))); DupLR->valno->def = CopyIdx; - DEBUG(dbgs() << " leaveIntvAfter " << Idx << ": " << *openli_ << '\n'); + DEBUG(dbgs() << " leaveIntvAfter " << Idx << ": " << *openli_ << '\n'); } /// leaveIntvAtTop - Leave the interval at the top of MBB. @@ -526,7 +525,7 @@ // Is curli even live-in to MBB? if (!CurLR) { - DEBUG(dbgs() << " leaveIntvAtTop at " << Start << ": not live\n"); + DEBUG(dbgs() << " leaveIntvAtTop at " << Start << ": not live\n"); return; } @@ -537,7 +536,7 @@ // If MBB is using a value of curli that was defined outside the openli range, // we don't want to copy it back here. if (!isPHIDef && !openli_->liveAt(CurLR->valno->def)) { - DEBUG(dbgs() << " leaveIntvAtTop at " << Start + DEBUG(dbgs() << " leaveIntvAtTop at " << Start << ": using external value\n"); liveThrough_ = true; return; @@ -567,7 +566,7 @@ DupLR->valno->setIsPHIDef(false); } else { // The dupli value was defined somewhere inside the openli range. - DEBUG(dbgs() << " leaveIntvAtTop source value defined at " + DEBUG(dbgs() << " leaveIntvAtTop source value defined at " << DupLR->valno->def << "\n"); // FIXME: We may not need a PHI here if all predecessors have the same // value. @@ -583,7 +582,7 @@ DupLR->valno->setIsPHIDef(false); } - DEBUG(dbgs() << " leaveIntvAtTop at " << Idx << ": " << *openli_ << '\n'); + DEBUG(dbgs() << " leaveIntvAtTop at " << Idx << ": " << *openli_ << '\n'); } /// closeIntv - Indicate that we are done editing the currently open @@ -591,11 +590,11 @@ void SplitEditor::closeIntv() { assert(openli_ && "openIntv not called before closeIntv"); - DEBUG(dbgs() << " closeIntv cleaning up\n"); + DEBUG(dbgs() << " closeIntv cleaning up\n"); DEBUG(dbgs() << " open " << *openli_ << '\n'); if (liveThrough_) { - DEBUG(dbgs() << " value live through region, leaving dupli as is.\n"); + DEBUG(dbgs() << " value live through region, leaving dupli as is.\n"); } else { // live out with copies inserted, or killed by region. Either way we need to // remove the overlapping region from dupli. @@ -638,9 +637,10 @@ break; } } - if (LI) + if (LI) { MO.setReg(LI->reg); - DEBUG(dbgs() << "rewrite " << Idx << '\t' << *MI); + DEBUG(dbgs() << " rewrite " << Idx << '\t' << *MI); + } } // dupli_ goes in last, after rewriting. @@ -655,8 +655,8 @@ LiveInterval &li = *intervals_[i]; vrai.CalculateRegClass(li.reg); vrai.CalculateWeightAndHint(li); - DEBUG(dbgs() << "new intv " << mri_.getRegClass(li.reg)->getName() << ":" - << li << '\n'); + DEBUG(dbgs() << " new interval " << mri_.getRegClass(li.reg)->getName() + << ":" << li << '\n'); } } @@ -711,7 +711,7 @@ /// basic block in Blocks. Return true if curli has been completely replaced, /// false if curli is still intact, and needs to be spilled or split further. bool SplitEditor::splitSingleBlocks(const SplitAnalysis::BlockPtrSet &Blocks) { - DEBUG(dbgs() << "splitSingleBlocks for " << Blocks.size() << " blocks.\n"); + DEBUG(dbgs() << " splitSingleBlocks for " << Blocks.size() << " blocks.\n"); // Determine the first and last instruction using curli in each block. typedef std::pair IndexPair; typedef DenseMap IndexPairMap; @@ -722,7 +722,7 @@ if (!Blocks.count(MBB)) continue; SlotIndex Idx = lis_.getInstructionIndex(*I); - DEBUG(dbgs() << "BB#" << MBB->getNumber() << '\t' << Idx << '\t' << **I); + DEBUG(dbgs() << " BB#" << MBB->getNumber() << '\t' << Idx << '\t' << **I); IndexPair &IP = MBBRange[MBB]; if (!IP.first.isValid() || Idx < IP.first) IP.first = Idx; @@ -734,7 +734,7 @@ for (SplitAnalysis::BlockPtrSet::const_iterator I = Blocks.begin(), E = Blocks.end(); I != E; ++I) { IndexPair &IP = MBBRange[*I]; - DEBUG(dbgs() << "Splitting for BB#" << (*I)->getNumber() << ": [" + DEBUG(dbgs() << " splitting for BB#" << (*I)->getNumber() << ": [" << IP.first << ';' << IP.second << ")\n"); assert(IP.first.isValid() && IP.second.isValid()); From stoklund at 2pi.dk Thu Aug 12 15:01:23 2010 From: stoklund at 2pi.dk (Jakob Stoklund Olesen) Date: Thu, 12 Aug 2010 20:01:23 -0000 Subject: [llvm-commits] [llvm] r110944 - in /llvm/trunk: include/llvm/CodeGen/LiveInterval.h include/llvm/CodeGen/LiveIntervalAnalysis.h lib/CodeGen/LiveInterval.cpp lib/CodeGen/LiveIntervalAnalysis.cpp Message-ID: <20100812200123.CC2EA2A6C12C@llvm.org> Author: stoklund Date: Thu Aug 12 15:01:23 2010 New Revision: 110944 URL: http://llvm.org/viewvc/llvm-project?rev=110944&view=rev Log: Remove trailing whitespace. Modified: llvm/trunk/include/llvm/CodeGen/LiveInterval.h llvm/trunk/include/llvm/CodeGen/LiveIntervalAnalysis.h llvm/trunk/lib/CodeGen/LiveInterval.cpp llvm/trunk/lib/CodeGen/LiveIntervalAnalysis.cpp Modified: llvm/trunk/include/llvm/CodeGen/LiveInterval.h URL: http://llvm.org/viewvc/llvm-project/llvm/trunk/include/llvm/CodeGen/LiveInterval.h?rev=110944&r1=110943&r2=110944&view=diff ============================================================================== --- llvm/trunk/include/llvm/CodeGen/LiveInterval.h (original) +++ llvm/trunk/include/llvm/CodeGen/LiveInterval.h Thu Aug 12 15:01:23 2010 @@ -39,7 +39,7 @@ /// This class holds information about a machine level values, including /// definition and use points. /// - /// Care must be taken in interpreting the def index of the value. The + /// Care must be taken in interpreting the def index of the value. The /// following rules apply: /// /// If the isDefAccurate() method returns false then def does not contain the @@ -108,7 +108,7 @@ /// For a stack interval, returns the reg which this stack interval was /// defined from. - /// For a register interval the behaviour of this method is undefined. + /// For a register interval the behaviour of this method is undefined. unsigned getReg() const { return cr.reg; } /// For a stack interval, set the defining register. /// This method should not be called on register intervals as it may lead @@ -189,7 +189,7 @@ } /// containsRange - Return true if the given range, [S, E), is covered by - /// this range. + /// this range. bool containsRange(SlotIndex S, SlotIndex E) const { assert((S < E) && "Backwards interval?"); return (start <= S && S < end) && (start < E && E <= end); @@ -236,7 +236,7 @@ float weight; // weight of this interval Ranges ranges; // the ranges in which this register is live VNInfoList valnos; // value#'s - + struct InstrSlots { enum { LOAD = 0, @@ -281,7 +281,7 @@ while (I->end <= Pos) ++I; return I; } - + void clear() { valnos.clear(); ranges.clear(); @@ -305,7 +305,7 @@ bool containsOneValue() const { return valnos.size() == 1; } unsigned getNumValNums() const { return (unsigned)valnos.size(); } - + /// getValNumInfo - Returns pointer to the specified val#. /// inline VNInfo *getValNumInfo(unsigned ValNo) { @@ -350,7 +350,7 @@ } return true; } - + /// MergeValueNumberInto - This method is called when two value nubmers /// are found to be equivalent. This eliminates V1, replacing all /// LiveRanges with the V1 value number with the V2 value number. This can @@ -391,7 +391,7 @@ /// except for the register of the interval. void Copy(const LiveInterval &RHS, MachineRegisterInfo *MRI, VNInfo::Allocator &VNInfoAllocator); - + bool empty() const { return ranges.empty(); } /// beginIndex - Return the lowest numbered slot covered by interval. @@ -458,14 +458,14 @@ iterator FindLiveRangeContaining(SlotIndex Idx); /// findDefinedVNInfo - Find the by the specified - /// index (register interval) or defined + /// index (register interval) or defined VNInfo *findDefinedVNInfoForRegInt(SlotIndex Idx) const; /// findDefinedVNInfo - Find the VNInfo that's defined by the specified /// register (stack inteval only). VNInfo *findDefinedVNInfoForStackInt(unsigned Reg) const; - + /// overlaps - Return true if the intersection of the two live intervals is /// not empty. bool overlaps(const LiveInterval& other) const { Modified: llvm/trunk/include/llvm/CodeGen/LiveIntervalAnalysis.h URL: http://llvm.org/viewvc/llvm-project/llvm/trunk/include/llvm/CodeGen/LiveIntervalAnalysis.h?rev=110944&r1=110943&r2=110944&view=diff ============================================================================== --- llvm/trunk/include/llvm/CodeGen/LiveIntervalAnalysis.h (original) +++ llvm/trunk/include/llvm/CodeGen/LiveIntervalAnalysis.h Thu Aug 12 15:01:23 2010 @@ -42,7 +42,7 @@ class TargetInstrInfo; class TargetRegisterClass; class VirtRegMap; - + class LiveIntervals : public MachineFunctionPass { MachineFunction* mf_; MachineRegisterInfo* mri_; @@ -123,7 +123,7 @@ unsigned getFuncInstructionCount() { return indexes_->getFunctionSize(); } - + /// getApproximateInstructionCount - computes an estimate of the number /// of instructions in a given LiveInterval. unsigned getApproximateInstructionCount(LiveInterval& I) { @@ -155,7 +155,7 @@ /// dupInterval - Duplicate a live interval. The caller is responsible for /// managing the allocated memory. LiveInterval *dupInterval(LiveInterval *li); - + /// addLiveRangeToEndOfBlock - Given a register and an instruction, /// adds a live range from that instruction to the end of its MBB. LiveRange addLiveRangeToEndOfBlock(unsigned reg, @@ -187,7 +187,7 @@ SlotIndex getInstructionIndex(const MachineInstr *instr) const { return indexes_->getInstructionIndex(instr); } - + /// Returns the instruction associated with the given index. MachineInstr* getInstructionFromIndex(SlotIndex index) const { return indexes_->getInstructionFromIndex(index); @@ -196,12 +196,12 @@ /// Return the first index in the given basic block. SlotIndex getMBBStartIdx(const MachineBasicBlock *mbb) const { return indexes_->getMBBStartIdx(mbb); - } + } /// Return the last index in the given basic block. SlotIndex getMBBEndIdx(const MachineBasicBlock *mbb) const { return indexes_->getMBBEndIdx(mbb); - } + } bool isLiveInToMBB(const LiveInterval &li, const MachineBasicBlock *mbb) const { @@ -306,7 +306,7 @@ /// within a single basic block. bool intervalIsInOneMBB(const LiveInterval &li) const; - private: + private: /// computeIntervals - Compute live intervals. void computeIntervals(); @@ -320,7 +320,7 @@ /// isPartialRedef - Return true if the specified def at the specific index /// is partially re-defining the specified live interval. A common case of - /// this is a definition of the sub-register. + /// this is a definition of the sub-register. bool isPartialRedef(SlotIndex MIIdx, MachineOperand &MO, LiveInterval &interval); Modified: llvm/trunk/lib/CodeGen/LiveInterval.cpp URL: http://llvm.org/viewvc/llvm-project/llvm/trunk/lib/CodeGen/LiveInterval.cpp?rev=110944&r1=110943&r2=110944&view=diff ============================================================================== --- llvm/trunk/lib/CodeGen/LiveInterval.cpp (original) +++ llvm/trunk/lib/CodeGen/LiveInterval.cpp Thu Aug 12 15:01:23 2010 @@ -309,7 +309,7 @@ return ranges.insert(it, LR); } -/// isInOneLiveRange - Return true if the range specified is entirely in +/// isInOneLiveRange - Return true if the range specified is entirely in /// a single LiveRange of the live interval. bool LiveInterval::isInOneLiveRange(SlotIndex Start, SlotIndex End) { Ranges::iterator I = std::upper_bound(ranges.begin(), ranges.end(), Start); @@ -386,7 +386,7 @@ /// getLiveRangeContaining - Return the live range that contains the /// specified index, or null if there is none. -LiveInterval::const_iterator +LiveInterval::const_iterator LiveInterval::FindLiveRangeContaining(SlotIndex Idx) const { const_iterator It = std::upper_bound(begin(), end(), Idx); if (It != ranges.begin()) { @@ -398,7 +398,7 @@ return end(); } -LiveInterval::iterator +LiveInterval::iterator LiveInterval::FindLiveRangeContaining(SlotIndex Idx) { iterator It = std::upper_bound(begin(), end(), Idx); if (It != begin()) { @@ -406,7 +406,7 @@ if (It->contains(Idx)) return It; } - + return end(); } @@ -438,11 +438,11 @@ /// the intervals are not joinable, this aborts. void LiveInterval::join(LiveInterval &Other, const int *LHSValNoAssignments, - const int *RHSValNoAssignments, + const int *RHSValNoAssignments, SmallVector &NewVNInfo, MachineRegisterInfo *MRI) { // Determine if any of our live range values are mapped. This is uncommon, so - // we want to avoid the interval scan if not. + // we want to avoid the interval scan if not. bool MustMapCurValNos = false; unsigned NumVals = getNumValNums(); unsigned NumNewVals = NewVNInfo.size(); @@ -462,7 +462,7 @@ ++OutIt; for (iterator I = OutIt, E = end(); I != E; ++I) { OutIt->valno = NewVNInfo[LHSValNoAssignments[I->valno->id]]; - + // If this live range has the same value # as its immediate predecessor, // and if they are neighbors, remove one LiveRange. This happens when we // have [0,3:0)[4,7:1) and map 0/1 onto the same value #. @@ -473,12 +473,12 @@ OutIt->start = I->start; OutIt->end = I->end; } - + // Didn't merge, on to the next one. ++OutIt; } } - + // If we merge some live ranges, chop off the end. ranges.erase(OutIt, end()); } @@ -496,7 +496,7 @@ if (VNI) { if (NumValNos >= NumVals) valnos.push_back(VNI); - else + else valnos[NumValNos] = VNI; VNI->id = NumValNos++; // Renumber val#. } @@ -521,7 +521,7 @@ /// interval as the specified value number. The LiveRanges in RHS are /// allowed to overlap with LiveRanges in the current interval, but only if /// the overlapping LiveRanges have the specified value number. -void LiveInterval::MergeRangesInAsValue(const LiveInterval &RHS, +void LiveInterval::MergeRangesInAsValue(const LiveInterval &RHS, VNInfo *LHSValNo) { // TODO: Make this more efficient. iterator InsertPos = begin(); @@ -570,7 +570,7 @@ // If this trimmed away the whole range, ignore it. if (Start == End) continue; } - + // Map the valno in the other live range to the current live range. IP = addRangeFrom(LiveRange(Start, End, LHSValNo), IP); } @@ -585,7 +585,7 @@ if (I->valno == V1) { isDead = false; break; - } + } if (isDead) { // Now that V1 is dead, remove it. markValNoForDeletion(V1); @@ -602,7 +602,7 @@ const LiveInterval &Clobbers, VNInfo::Allocator &VNInfoAllocator) { if (Clobbers.empty()) return; - + DenseMap ValNoMaps; VNInfo *UnusedValNo = 0; iterator IP = begin(); @@ -672,10 +672,10 @@ // for unknown values, use it. VNInfo *ClobberValNo = getNextValue(li_.getInvalidIndex(), 0, false, VNInfoAllocator); - + iterator IP = begin(); IP = std::upper_bound(IP, end(), Start); - + // If the start of this range overlaps with an existing liverange, trim it. if (IP != begin() && IP[-1].end > Start) { Start = IP[-1].end; @@ -688,7 +688,7 @@ // If this trimmed away the whole range, ignore it. if (Start == End) return; } - + // Insert the clobber interval. addRangeFrom(LiveRange(Start, End, ClobberValNo), IP); } @@ -715,7 +715,7 @@ for (iterator I = begin(); I != end(); ) { iterator LR = I++; if (LR->valno != V1) continue; // Not a V1 LiveRange. - + // Okay, we found a V1 live range. If it had a previous, touching, V2 live // range, extend it. if (LR != begin()) { @@ -729,11 +729,11 @@ LR = Prev; } } - + // Okay, now we have a V1 or V2 live range that is maximally merged forward. // Ensure that it is a V2 live-range. LR->valno = V2; - + // If we can merge it into later V2 live ranges, do so now. We ignore any // following V1 live ranges, as they will be merged in subsequent iterations // of the loop. @@ -745,10 +745,10 @@ } } } - + // Now that V1 is dead, remove it. markValNoForDeletion(V1); - + return V2; } Modified: llvm/trunk/lib/CodeGen/LiveIntervalAnalysis.cpp URL: http://llvm.org/viewvc/llvm-project/llvm/trunk/lib/CodeGen/LiveIntervalAnalysis.cpp?rev=110944&r1=110943&r2=110944&view=diff ============================================================================== --- llvm/trunk/lib/CodeGen/LiveIntervalAnalysis.cpp (original) +++ llvm/trunk/lib/CodeGen/LiveIntervalAnalysis.cpp Thu Aug 12 15:01:23 2010 @@ -47,7 +47,7 @@ using namespace llvm; // Hidden options for help debugging. -static cl::opt DisableReMat("disable-rematerialization", +static cl::opt DisableReMat("disable-rematerialization", cl::init(false), cl::Hidden); STATISTIC(numIntervals , "Number of original intervals"); @@ -66,12 +66,12 @@ AU.addRequired(); AU.addPreservedID(MachineLoopInfoID); AU.addPreservedID(MachineDominatorsID); - + if (!StrongPHIElim) { AU.addPreservedID(PHIEliminationID); AU.addRequiredID(PHIEliminationID); } - + AU.addRequiredID(TwoAddressInstructionPassID); AU.addPreserved(); AU.addRequired(); @@ -85,7 +85,7 @@ for (DenseMap::iterator I = r2iMap_.begin(), E = r2iMap_.end(); I != E; ++I) delete I->second; - + r2iMap_.clear(); // Release VNInfo memory regions, VNInfo objects don't need to be dtor'd. @@ -275,7 +275,7 @@ /// isPartialRedef - Return true if the specified def at the specific index is /// partially re-defining the specified live interval. A common case of this is -/// a definition of the sub-register. +/// a definition of the sub-register. bool LiveIntervals::isPartialRedef(SlotIndex MIIdx, MachineOperand &MO, LiveInterval &interval) { if (!MO.getSubReg() || MO.isEarlyClobber()) @@ -415,8 +415,8 @@ // def-and-use register operand. // It may also be partial redef like this: - // 80 %reg1041:6 = VSHRNv4i16 %reg1034, 12, pred:14, pred:%reg0 - // 120 %reg1041:5 = VSHRNv4i16 %reg1039, 12, pred:14, pred:%reg0 + // 80 %reg1041:6 = VSHRNv4i16 %reg1034, 12, pred:14, pred:%reg0 + // 120 %reg1041:5 = VSHRNv4i16 %reg1039, 12, pred:14, pred:%reg0 bool PartReDef = isPartialRedef(MIIdx, MO, interval); if (PartReDef || mi->isRegTiedToUseOperand(MOIdx)) { // If this is a two-address definition, then we have already processed @@ -451,7 +451,7 @@ // A re-def may be a copy. e.g. %reg1030:6 = VMOVD %reg1026, ... if (PartReDef && mi->isCopyLike()) OldValNo->setCopy(&*mi); - + // Add the new live interval which replaces the range for the input copy. LiveRange LR(DefIndex, RedefIndex, ValNo); DEBUG(dbgs() << " replace range with " << LR); @@ -481,7 +481,7 @@ if (mi->isCopyLike()) CopyMI = mi; ValNo = interval.getNextValue(defIndex, CopyMI, true, VNInfoAllocator); - + SlotIndex killIndex = getMBBEndIdx(mbb); LiveRange LR(defIndex, killIndex, ValNo); interval.addRange(LR); @@ -558,10 +558,10 @@ goto exit; } } - + baseIndex = baseIndex.getNextIndex(); } - + // The only case we should have a dead physreg here without a killing or // instruction where we know it's dead is if it is live-in to the function // and never used. Another possible case is the implicit use of the @@ -685,7 +685,7 @@ /// registers. for some ordering of the machine instructions [1,N] a /// live interval is an interval [i, j) where 1 <= i <= j < N for /// which a variable is live -void LiveIntervals::computeIntervals() { +void LiveIntervals::computeIntervals() { DEBUG(dbgs() << "********** COMPUTING LIVE INTERVALS **********\n" << "********** Function: " << ((Value*)mf_->getFunction())->getName() << '\n'); @@ -712,11 +712,11 @@ handleLiveInRegister(MBB, MIIndex, getOrCreateInterval(*AS), true); } - + // Skip over empty initial indices. if (getInstructionFromIndex(MIIndex) == 0) MIIndex = indexes_->getNextNonNullIndex(MIIndex); - + for (MachineBasicBlock::iterator MI = MBB->begin(), miEnd = MBB->end(); MI != miEnd; ++MI) { DEBUG(dbgs() << MIIndex << "\t" << *MI); @@ -735,7 +735,7 @@ else if (MO.isUndef()) UndefUses.push_back(MO.getReg()); } - + // Move to the next instr slot. MIIndex = indexes_->getNextNonNullIndex(MIIndex); } @@ -780,7 +780,7 @@ unsigned Reg = MO.getReg(); if (Reg == 0 || Reg == li.reg) continue; - + if (TargetRegisterInfo::isPhysicalRegister(Reg) && !allocatableRegs_[Reg]) continue; @@ -799,7 +799,7 @@ /// which reaches the given instruction also reaches the specified use index. bool LiveIntervals::isValNoAvailableAt(const LiveInterval &li, MachineInstr *MI, SlotIndex UseIdx) const { - SlotIndex Index = getInstructionIndex(MI); + SlotIndex Index = getInstructionIndex(MI); VNInfo *ValNo = li.FindLiveRangeContaining(Index)->valno; LiveInterval::const_iterator UI = li.FindLiveRangeContaining(UseIdx); return UI != li.end() && UI->valno == ValNo; @@ -904,7 +904,7 @@ } return false; } - + /// tryFoldMemoryOperand - Attempts to fold either a spill / restore from /// slot / to reg or any rematerialized load into ith operand of specified @@ -1024,7 +1024,7 @@ /// for addIntervalsForSpills to rewrite uses / defs for the given live range. bool LiveIntervals:: rewriteInstructionForSpills(const LiveInterval &li, const VNInfo *VNI, - bool TrySplit, SlotIndex index, SlotIndex end, + bool TrySplit, SlotIndex index, SlotIndex end, MachineInstr *MI, MachineInstr *ReMatOrigDefMI, MachineInstr *ReMatDefMI, unsigned Slot, int LdSlot, @@ -1083,7 +1083,7 @@ // keep the src/dst regs pinned. // // Keep track of whether we replace a use and/or def so that we can - // create the spill interval with the appropriate range. + // create the spill interval with the appropriate range. SmallVector Ops; tie(HasUse, HasDef) = MI->readsWritesVirtualRegister(Reg, &Ops); @@ -1145,7 +1145,7 @@ if (mopj.isImplicit()) rewriteImplicitOps(li, MI, NewVReg, vrm); } - + if (CreatedNewVReg) { if (DefIsReMat) { vrm.setVirtIsReMaterialized(NewVReg, ReMatDefMI); @@ -1685,7 +1685,7 @@ if (NeedStackSlot && vrm.getPreSplitReg(li.reg) == 0) { if (vrm.getStackSlot(li.reg) == VirtRegMap::NO_STACK_SLOT) Slot = vrm.assignVirt2StackSlot(li.reg); - + // This case only occurs when the prealloc splitter has already assigned // a stack slot to this vreg. else @@ -1742,7 +1742,7 @@ Ops.push_back(j); if (MO.isDef()) continue; - if (isReMat || + if (isReMat || (!FoundUse && !alsoFoldARestore(Id, index, VReg, RestoreMBBs, RestoreIdxes))) { // MI has two-address uses of the same register. If the use @@ -1887,7 +1887,7 @@ /// getRepresentativeReg - Find the largest super register of the specified /// physical register. unsigned LiveIntervals::getRepresentativeReg(unsigned Reg) const { - // Find the largest super-register that is allocatable. + // Find the largest super-register that is allocatable. unsigned BestReg = Reg; for (const unsigned* AS = tri_->getSuperRegisters(Reg); *AS; ++AS) { unsigned SuperReg = *AS; @@ -2001,7 +2001,7 @@ SlotIndex(getInstructionIndex(startInst).getDefIndex()), getMBBEndIdx(startInst->getParent()), VN); Interval.addRange(LR); - + return LR; } From bruno.cardoso at gmail.com Thu Aug 12 15:20:53 2010 From: bruno.cardoso at gmail.com (Bruno Cardoso Lopes) Date: Thu, 12 Aug 2010 20:20:53 -0000 Subject: [llvm-commits] [llvm] r110946 - in /llvm/trunk: lib/Target/X86/X86InstrInfo.cpp lib/Target/X86/X86InstrSSE.td test/CodeGen/X86/avx-128.ll Message-ID: <20100812202053.4CD3B2A6C12C@llvm.org> Author: bruno Date: Thu Aug 12 15:20:53 2010 New Revision: 110946 URL: http://llvm.org/viewvc/llvm-project?rev=110946&view=rev Log: - Teach SSEDomainFix to switch between different levels of AVX instructions. Here we guess that AVX will have domain issues, so just implement them for consistency and in the future we remove if it's unnecessary. - Make foldMemoryOperandImpl aware of 256-bit zero vectors folding and support the 128-bit counterparts of AVX too. - Make sure MOV[AU]PS instructions are only selected when SSE1 is enabled, and duplicate the patterns to match AVX. - Add a testcase for a simple 128-bit zero vector creation. Added: llvm/trunk/test/CodeGen/X86/avx-128.ll Modified: llvm/trunk/lib/Target/X86/X86InstrInfo.cpp llvm/trunk/lib/Target/X86/X86InstrSSE.td Modified: llvm/trunk/lib/Target/X86/X86InstrInfo.cpp URL: http://llvm.org/viewvc/llvm-project/llvm/trunk/lib/Target/X86/X86InstrInfo.cpp?rev=110946&r1=110945&r2=110946&view=diff ============================================================================== --- llvm/trunk/lib/Target/X86/X86InstrInfo.cpp (original) +++ llvm/trunk/lib/Target/X86/X86InstrInfo.cpp Thu Aug 12 15:20:53 2010 @@ -2380,10 +2380,17 @@ Alignment = (*LoadMI->memoperands_begin())->getAlignment(); else switch (LoadMI->getOpcode()) { + case X86::AVX_SET0PSY: + case X86::AVX_SET0PDY: + Alignment = 32; + break; case X86::V_SET0PS: case X86::V_SET0PD: case X86::V_SET0PI: case X86::V_SETALLONES: + case X86::AVX_SET0PS: + case X86::AVX_SET0PD: + case X86::AVX_SET0PI: Alignment = 16; break; case X86::FsFLD0SD: @@ -2421,6 +2428,11 @@ case X86::V_SET0PD: case X86::V_SET0PI: case X86::V_SETALLONES: + case X86::AVX_SET0PS: + case X86::AVX_SET0PD: + case X86::AVX_SET0PI: + case X86::AVX_SET0PSY: + case X86::AVX_SET0PDY: case X86::FsFLD0SD: case X86::FsFLD0SS: { // Folding a V_SET0P? or V_SETALLONES as a load, to ease register pressure. @@ -2447,10 +2459,13 @@ // Create a constant-pool entry. MachineConstantPool &MCP = *MF.getConstantPool(); const Type *Ty; - if (LoadMI->getOpcode() == X86::FsFLD0SS) + unsigned Opc = LoadMI->getOpcode(); + if (Opc == X86::FsFLD0SS) Ty = Type::getFloatTy(MF.getFunction()->getContext()); - else if (LoadMI->getOpcode() == X86::FsFLD0SD) + else if (Opc == X86::FsFLD0SD) Ty = Type::getDoubleTy(MF.getFunction()->getContext()); + else if (Opc == X86::AVX_SET0PSY || Opc == X86::AVX_SET0PDY) + Ty = VectorType::get(Type::getFloatTy(MF.getFunction()->getContext()), 8); else Ty = VectorType::get(Type::getInt32Ty(MF.getFunction()->getContext()), 4); const Constant *C = LoadMI->getOpcode() == X86::V_SETALLONES ? @@ -2996,6 +3011,22 @@ { X86::V_SET0PS, X86::V_SET0PD, X86::V_SET0PI }, { X86::XORPSrm, X86::XORPDrm, X86::PXORrm }, { X86::XORPSrr, X86::XORPDrr, X86::PXORrr }, + // AVX 128-bit support + { X86::VMOVAPSmr, X86::VMOVAPDmr, X86::VMOVDQAmr }, + { X86::VMOVAPSrm, X86::VMOVAPDrm, X86::VMOVDQArm }, + { X86::VMOVAPSrr, X86::VMOVAPDrr, X86::VMOVDQArr }, + { X86::VMOVUPSmr, X86::VMOVUPDmr, X86::VMOVDQUmr }, + { X86::VMOVUPSrm, X86::VMOVUPDrm, X86::VMOVDQUrm }, + { X86::VMOVNTPSmr, X86::VMOVNTPDmr, X86::VMOVNTDQmr }, + { X86::VANDNPSrm, X86::VANDNPDrm, X86::VPANDNrm }, + { X86::VANDNPSrr, X86::VANDNPDrr, X86::VPANDNrr }, + { X86::VANDPSrm, X86::VANDPDrm, X86::VPANDrm }, + { X86::VANDPSrr, X86::VANDPDrr, X86::VPANDrr }, + { X86::VORPSrm, X86::VORPDrm, X86::VPORrm }, + { X86::VORPSrr, X86::VORPDrr, X86::VPORrr }, + { X86::AVX_SET0PS, X86::AVX_SET0PD, X86::AVX_SET0PI }, + { X86::VXORPSrm, X86::VXORPDrm, X86::VPXORrm }, + { X86::VXORPSrr, X86::VXORPDrr, X86::VPXORrr }, }; // FIXME: Some shuffle and unpack instructions have equivalents in different Modified: llvm/trunk/lib/Target/X86/X86InstrSSE.td URL: http://llvm.org/viewvc/llvm-project/llvm/trunk/lib/Target/X86/X86InstrSSE.td?rev=110946&r1=110945&r2=110946&view=diff ============================================================================== --- llvm/trunk/lib/Target/X86/X86InstrSSE.td (original) +++ llvm/trunk/lib/Target/X86/X86InstrSSE.td Thu Aug 12 15:20:53 2010 @@ -4052,31 +4052,62 @@ (Int_CVTTPD2PIrr VR128:$src)>, Requires<[HasSSE2]>; // Use movaps / movups for SSE integer load / store (one byte shorter). -def : Pat<(alignedloadv4i32 addr:$src), - (MOVAPSrm addr:$src)>; -def : Pat<(loadv4i32 addr:$src), - (MOVUPSrm addr:$src)>; -def : Pat<(alignedloadv2i64 addr:$src), - (MOVAPSrm addr:$src)>; -def : Pat<(loadv2i64 addr:$src), - (MOVUPSrm addr:$src)>; - -def : Pat<(alignedstore (v2i64 VR128:$src), addr:$dst), - (MOVAPSmr addr:$dst, VR128:$src)>; -def : Pat<(alignedstore (v4i32 VR128:$src), addr:$dst), - (MOVAPSmr addr:$dst, VR128:$src)>; -def : Pat<(alignedstore (v8i16 VR128:$src), addr:$dst), - (MOVAPSmr addr:$dst, VR128:$src)>; -def : Pat<(alignedstore (v16i8 VR128:$src), addr:$dst), - (MOVAPSmr addr:$dst, VR128:$src)>; -def : Pat<(store (v2i64 VR128:$src), addr:$dst), - (MOVUPSmr addr:$dst, VR128:$src)>; -def : Pat<(store (v4i32 VR128:$src), addr:$dst), - (MOVUPSmr addr:$dst, VR128:$src)>; -def : Pat<(store (v8i16 VR128:$src), addr:$dst), - (MOVUPSmr addr:$dst, VR128:$src)>; -def : Pat<(store (v16i8 VR128:$src), addr:$dst), - (MOVUPSmr addr:$dst, VR128:$src)>; +let Predicates = [HasSSE1] in { + def : Pat<(alignedloadv4i32 addr:$src), + (MOVAPSrm addr:$src)>; + def : Pat<(loadv4i32 addr:$src), + (MOVUPSrm addr:$src)>; + def : Pat<(alignedloadv2i64 addr:$src), + (MOVAPSrm addr:$src)>; + def : Pat<(loadv2i64 addr:$src), + (MOVUPSrm addr:$src)>; + + def : Pat<(alignedstore (v2i64 VR128:$src), addr:$dst), + (MOVAPSmr addr:$dst, VR128:$src)>; + def : Pat<(alignedstore (v4i32 VR128:$src), addr:$dst), + (MOVAPSmr addr:$dst, VR128:$src)>; + def : Pat<(alignedstore (v8i16 VR128:$src), addr:$dst), + (MOVAPSmr addr:$dst, VR128:$src)>; + def : Pat<(alignedstore (v16i8 VR128:$src), addr:$dst), + (MOVAPSmr addr:$dst, VR128:$src)>; + def : Pat<(store (v2i64 VR128:$src), addr:$dst), + (MOVUPSmr addr:$dst, VR128:$src)>; + def : Pat<(store (v4i32 VR128:$src), addr:$dst), + (MOVUPSmr addr:$dst, VR128:$src)>; + def : Pat<(store (v8i16 VR128:$src), addr:$dst), + (MOVUPSmr addr:$dst, VR128:$src)>; + def : Pat<(store (v16i8 VR128:$src), addr:$dst), + (MOVUPSmr addr:$dst, VR128:$src)>; +} + +// Use vmovaps/vmovups for AVX 128-bit integer load/store (one byte shorter). +let Predicates = [HasAVX] in { + def : Pat<(alignedloadv4i32 addr:$src), + (VMOVAPSrm addr:$src)>; + def : Pat<(loadv4i32 addr:$src), + (VMOVUPSrm addr:$src)>; + def : Pat<(alignedloadv2i64 addr:$src), + (VMOVAPSrm addr:$src)>; + def : Pat<(loadv2i64 addr:$src), + (VMOVUPSrm addr:$src)>; + + def : Pat<(alignedstore (v2i64 VR128:$src), addr:$dst), + (VMOVAPSmr addr:$dst, VR128:$src)>; + def : Pat<(alignedstore (v4i32 VR128:$src), addr:$dst), + (VMOVAPSmr addr:$dst, VR128:$src)>; + def : Pat<(alignedstore (v8i16 VR128:$src), addr:$dst), + (VMOVAPSmr addr:$dst, VR128:$src)>; + def : Pat<(alignedstore (v16i8 VR128:$src), addr:$dst), + (VMOVAPSmr addr:$dst, VR128:$src)>; + def : Pat<(store (v2i64 VR128:$src), addr:$dst), + (VMOVUPSmr addr:$dst, VR128:$src)>; + def : Pat<(store (v4i32 VR128:$src), addr:$dst), + (VMOVUPSmr addr:$dst, VR128:$src)>; + def : Pat<(store (v8i16 VR128:$src), addr:$dst), + (VMOVUPSmr addr:$dst, VR128:$src)>; + def : Pat<(store (v16i8 VR128:$src), addr:$dst), + (VMOVUPSmr addr:$dst, VR128:$src)>; +} //===----------------------------------------------------------------------===// // SSE4.1 - Packed Move with Sign/Zero Extend Added: llvm/trunk/test/CodeGen/X86/avx-128.ll URL: http://llvm.org/viewvc/llvm-project/llvm/trunk/test/CodeGen/X86/avx-128.ll?rev=110946&view=auto ============================================================================== --- llvm/trunk/test/CodeGen/X86/avx-128.ll (added) +++ llvm/trunk/test/CodeGen/X86/avx-128.ll Thu Aug 12 15:20:53 2010 @@ -0,0 +1,12 @@ +; RUN: llc < %s -mtriple=x86_64-apple-darwin -march=x86 -mcpu=corei7 -mattr=avx | FileCheck %s + + at z = common global <4 x float> zeroinitializer, align 16 + +define void @zero() nounwind ssp { +entry: + ; CHECK: vpxor + ; CHECK: vmovaps + store <4 x float> zeroinitializer, <4 x float>* @z, align 16 + ret void +} + From evan.cheng at apple.com Thu Aug 12 15:30:05 2010 From: evan.cheng at apple.com (Evan Cheng) Date: Thu, 12 Aug 2010 20:30:05 -0000 Subject: [llvm-commits] [llvm] r110947 - /llvm/trunk/lib/Target/ARM/ARMConstantIslandPass.cpp Message-ID: <20100812203005.88E8A2A6C12C@llvm.org> Author: evancheng Date: Thu Aug 12 15:30:05 2010 New Revision: 110947 URL: http://llvm.org/viewvc/llvm-project?rev=110947&view=rev Log: Make sure ARM constant island pass does not break up an IT block. If the split point is in the middle of an IT block, it should move it up to just above the IT instruction. rdar://8302637 Modified: llvm/trunk/lib/Target/ARM/ARMConstantIslandPass.cpp Modified: llvm/trunk/lib/Target/ARM/ARMConstantIslandPass.cpp URL: http://llvm.org/viewvc/llvm-project/llvm/trunk/lib/Target/ARM/ARMConstantIslandPass.cpp?rev=110947&r1=110946&r2=110947&view=diff ============================================================================== --- llvm/trunk/lib/Target/ARM/ARMConstantIslandPass.cpp (original) +++ llvm/trunk/lib/Target/ARM/ARMConstantIslandPass.cpp Thu Aug 12 15:30:05 2010 @@ -18,6 +18,7 @@ #include "ARMAddressingModes.h" #include "ARMMachineFunctionInfo.h" #include "ARMInstrInfo.h" +#include "Thumb2InstrInfo.h" #include "llvm/CodeGen/MachineConstantPool.h" #include "llvm/CodeGen/MachineFunctionPass.h" #include "llvm/CodeGen/MachineInstrBuilder.h" @@ -1181,11 +1182,13 @@ MachineBasicBlock::iterator MI = UserMI; ++MI; unsigned CPUIndex = CPUserIndex+1; + unsigned NumCPUsers = CPUsers.size(); + MachineInstr *LastIT = 0; for (unsigned Offset = UserOffset+TII->GetInstSizeInBytes(UserMI); Offset < BaseInsertOffset; Offset += TII->GetInstSizeInBytes(MI), - MI = llvm::next(MI)) { - if (CPUIndex < CPUsers.size() && CPUsers[CPUIndex].MI == MI) { + MI = llvm::next(MI)) { + if (CPUIndex < NumCPUsers && CPUsers[CPUIndex].MI == MI) { CPUser &U = CPUsers[CPUIndex]; if (!OffsetIsInRange(Offset, EndInsertOffset, U.MaxDisp, U.NegOk, U.IsSoImm)) { @@ -1197,9 +1200,23 @@ EndInsertOffset += CPUsers[CPUIndex].CPEMI->getOperand(2).getImm(); CPUIndex++; } + + // Remember the last IT instruction. + if (MI->getOpcode() == ARM::t2IT) + LastIT = MI; } + DEBUG(errs() << "Split in middle of big block\n"); - NewMBB = SplitBlockBeforeInstr(prior(MI)); + --MI; + + // Avoid splitting an IT block. + if (LastIT) { + unsigned PredReg = 0; + ARMCC::CondCodes CC = llvm::getITInstrPredicate(MI, PredReg); + if (CC != ARMCC::AL) + MI = LastIT; + } + NewMBB = SplitBlockBeforeInstr(MI); } } From stoklund at 2pi.dk Thu Aug 12 15:38:03 2010 From: stoklund at 2pi.dk (Jakob Stoklund Olesen) Date: Thu, 12 Aug 2010 20:38:03 -0000 Subject: [llvm-commits] [llvm] r110949 - in /llvm/trunk: include/llvm/CodeGen/LiveInterval.h lib/CodeGen/LiveInterval.cpp lib/CodeGen/SplitKit.cpp Message-ID: <20100812203803.E3B2B2A6C12C@llvm.org> Author: stoklund Date: Thu Aug 12 15:38:03 2010 New Revision: 110949 URL: http://llvm.org/viewvc/llvm-project?rev=110949&view=rev Log: Also recompute HasPHIKill flags in LiveInterval::RenumberValues. If a phi-def value were removed from the interval, the phi-kill flags are no longer valid. Modified: llvm/trunk/include/llvm/CodeGen/LiveInterval.h llvm/trunk/lib/CodeGen/LiveInterval.cpp llvm/trunk/lib/CodeGen/SplitKit.cpp Modified: llvm/trunk/include/llvm/CodeGen/LiveInterval.h URL: http://llvm.org/viewvc/llvm-project/llvm/trunk/include/llvm/CodeGen/LiveInterval.h?rev=110949&r1=110948&r2=110949&view=diff ============================================================================== --- llvm/trunk/include/llvm/CodeGen/LiveInterval.h (original) +++ llvm/trunk/include/llvm/CodeGen/LiveInterval.h Thu Aug 12 15:38:03 2010 @@ -338,7 +338,8 @@ /// RenumberValues - Renumber all values in order of appearance and remove /// unused values. - void RenumberValues(); + /// Recalculate phi-kill flags in case any phi-def values were removed. + void RenumberValues(LiveIntervals &lis); /// isOnlyLROfValNo - Return true if the specified live range is the only /// one defined by the its val#. Modified: llvm/trunk/lib/CodeGen/LiveInterval.cpp URL: http://llvm.org/viewvc/llvm-project/llvm/trunk/lib/CodeGen/LiveInterval.cpp?rev=110949&r1=110948&r2=110949&view=diff ============================================================================== --- llvm/trunk/lib/CodeGen/LiveInterval.cpp (original) +++ llvm/trunk/lib/CodeGen/LiveInterval.cpp Thu Aug 12 15:38:03 2010 @@ -182,8 +182,9 @@ /// RenumberValues - Renumber all values in order of appearance and delete the /// remaining unused values. -void LiveInterval::RenumberValues() { +void LiveInterval::RenumberValues(LiveIntervals &lis) { SmallPtrSet Seen; + bool seenPHIDef = false; valnos.clear(); for (const_iterator I = begin(), E = end(); I != E; ++I) { VNInfo *VNI = I->valno; @@ -192,6 +193,26 @@ assert(!VNI->isUnused() && "Unused valno used by live range"); VNI->id = (unsigned)valnos.size(); valnos.push_back(VNI); + VNI->setHasPHIKill(false); + if (VNI->isPHIDef()) + seenPHIDef = true; + } + + // Recompute phi kill flags. + if (!seenPHIDef) + return; + for (const_vni_iterator I = vni_begin(), E = vni_end(); I != E; ++I) { + VNInfo *VNI = *I; + if (!VNI->isPHIDef()) + continue; + const MachineBasicBlock *PHIBB = lis.getMBBFromIndex(VNI->def); + assert(PHIBB && "No basic block for phi-def"); + for (MachineBasicBlock::const_pred_iterator PI = PHIBB->pred_begin(), + PE = PHIBB->pred_end(); PI != PE; ++PI) { + VNInfo *KVNI = getVNInfoAt(lis.getMBBEndIdx(*PI).getPrevSlot()); + if (KVNI) + KVNI->setHasPHIKill(true); + } } } Modified: llvm/trunk/lib/CodeGen/SplitKit.cpp URL: http://llvm.org/viewvc/llvm-project/llvm/trunk/lib/CodeGen/SplitKit.cpp?rev=110949&r1=110948&r2=110949&view=diff ============================================================================== --- llvm/trunk/lib/CodeGen/SplitKit.cpp (original) +++ llvm/trunk/lib/CodeGen/SplitKit.cpp Thu Aug 12 15:38:03 2010 @@ -645,7 +645,7 @@ // dupli_ goes in last, after rewriting. if (dupli_) { - dupli_->RenumberValues(); + dupli_->RenumberValues(lis_); intervals_.push_back(dupli_); } From johnny.chen at apple.com Thu Aug 12 15:46:17 2010 From: johnny.chen at apple.com (Johnny Chen) Date: Thu, 12 Aug 2010 20:46:17 -0000 Subject: [llvm-commits] [llvm] r110951 - in /llvm/trunk: lib/Target/ARM/ARM.h lib/Target/ARM/ARMAsmPrinter.cpp lib/Target/ARM/ARMInstrInfo.td lib/Target/ARM/AsmPrinter/ARMInstPrinter.cpp lib/Target/ARM/AsmPrinter/ARMInstPrinter.h lib/Target/ARM/Disassembler/ARMDisassemblerCore.cpp test/MC/Disassembler/arm-tests.txt utils/TableGen/EDEmitter.cpp Message-ID: <20100812204617.A3C3B2A6C12D@llvm.org> Author: johnny Date: Thu Aug 12 15:46:17 2010 New Revision: 110951 URL: http://llvm.org/viewvc/llvm-project?rev=110951&view=rev Log: Cleaned up the for-disassembly-only entries in the arm instruction table so that the memory barrier variants (other than 'SY' full system domain read and write) are treated as one instruction with option operand. Modified: llvm/trunk/lib/Target/ARM/ARM.h llvm/trunk/lib/Target/ARM/ARMAsmPrinter.cpp llvm/trunk/lib/Target/ARM/ARMInstrInfo.td llvm/trunk/lib/Target/ARM/AsmPrinter/ARMInstPrinter.cpp llvm/trunk/lib/Target/ARM/AsmPrinter/ARMInstPrinter.h llvm/trunk/lib/Target/ARM/Disassembler/ARMDisassemblerCore.cpp llvm/trunk/test/MC/Disassembler/arm-tests.txt llvm/trunk/utils/TableGen/EDEmitter.cpp Modified: llvm/trunk/lib/Target/ARM/ARM.h URL: http://llvm.org/viewvc/llvm-project/llvm/trunk/lib/Target/ARM/ARM.h?rev=110951&r1=110950&r2=110951&view=diff ============================================================================== --- llvm/trunk/lib/Target/ARM/ARM.h (original) +++ llvm/trunk/lib/Target/ARM/ARM.h Thu Aug 12 15:46:17 2010 @@ -90,6 +90,33 @@ } } +namespace ARM_MB { + // The Memory Barrier Option constants map directly to the 4-bit encoding of + // the option field for memory barrier operations. + enum MemBOpt { + ST = 14, + ISH = 11, + ISHST = 10, + NSH = 7, + NSHST = 6, + OSH = 3, + OSHST = 2 + }; + + inline static const char *MemBOptToString(unsigned val) { + switch (val) { + default: llvm_unreachable("Unknown memory opetion"); + case ST: return "st"; + case ISH: return "ish"; + case ISHST: return "ishst"; + case NSH: return "nsh"; + case NSHST: return "nshst"; + case OSH: return "osh"; + case OSHST: return "oshst"; + } + } +} // namespace ARM_MB + FunctionPass *createARMISelDag(ARMBaseTargetMachine &TM, CodeGenOpt::Level OptLevel); Modified: llvm/trunk/lib/Target/ARM/ARMAsmPrinter.cpp URL: http://llvm.org/viewvc/llvm-project/llvm/trunk/lib/Target/ARM/ARMAsmPrinter.cpp?rev=110951&r1=110950&r2=110951&view=diff ============================================================================== --- llvm/trunk/lib/Target/ARM/ARMAsmPrinter.cpp (original) +++ llvm/trunk/lib/Target/ARM/ARMAsmPrinter.cpp Thu Aug 12 15:46:17 2010 @@ -122,6 +122,8 @@ const char *Modifier = 0); void printBitfieldInvMaskImmOperand(const MachineInstr *MI, int OpNum, raw_ostream &O); + void printMemBOption(const MachineInstr *MI, int OpNum, + raw_ostream &O); void printSatShiftOperand(const MachineInstr *MI, int OpNum, raw_ostream &O); @@ -671,6 +673,13 @@ O << "#" << lsb << ", #" << width; } +void +ARMAsmPrinter::printMemBOption(const MachineInstr *MI, int OpNum, + raw_ostream &O) { + unsigned val = MI->getOperand(OpNum).getImm(); + O << ARM_MB::MemBOptToString(val); +} + void ARMAsmPrinter::printSatShiftOperand(const MachineInstr *MI, int OpNum, raw_ostream &O) { unsigned ShiftOp = MI->getOperand(OpNum).getImm(); Modified: llvm/trunk/lib/Target/ARM/ARMInstrInfo.td URL: http://llvm.org/viewvc/llvm-project/llvm/trunk/lib/Target/ARM/ARMInstrInfo.td?rev=110951&r1=110950&r2=110951&view=diff ============================================================================== --- llvm/trunk/lib/Target/ARM/ARMInstrInfo.td (original) +++ llvm/trunk/lib/Target/ARM/ARMInstrInfo.td Thu Aug 12 15:46:17 2010 @@ -2389,61 +2389,30 @@ } } -// Helper class for multiclass MemB -- for disassembly only -class AMBI - : AInoP<(outs), (ins), MiscFrm, NoItinerary, opc, asm, - [/* For disassembly only; pattern left blank */]>, - Requires<[IsARM, HasV7]> { - let Inst{31-20} = 0xf57; -} - -multiclass MemB op7_4, string opc> { - - def st : AMBI { - let Inst{7-4} = op7_4; - let Inst{3-0} = 0b1110; - } - - def ish : AMBI { - let Inst{7-4} = op7_4; - let Inst{3-0} = 0b1011; - } - - def ishst : AMBI { - let Inst{7-4} = op7_4; - let Inst{3-0} = 0b1010; - } - - def nsh : AMBI { - let Inst{7-4} = op7_4; - let Inst{3-0} = 0b0111; - } - - def nshst : AMBI { - let Inst{7-4} = op7_4; - let Inst{3-0} = 0b0110; - } +// Memory Barrier Operations Variants -- for disassembly only - def osh : AMBI { - let Inst{7-4} = op7_4; - let Inst{3-0} = 0b0011; - } +def memb_opt : Operand { + let PrintMethod = "printMemBOption"; +} - def oshst : AMBI { - let Inst{7-4} = op7_4; - let Inst{3-0} = 0b0010; - } +class AMBI op7_4, string opc> + : AInoP<(outs), (ins memb_opt:$opt), MiscFrm, NoItinerary, opc, "\t$opt", + [/* For disassembly only; pattern left blank */]>, + Requires<[IsARM, HasDB]> { + let Inst{31-8} = 0xf57ff0; + let Inst{7-4} = op7_4; } // These DMB variants are for disassembly only. -defm DMB : MemB<0b0101, "dmb">; +def DMBvar : AMBI<0b0101, "dmb">; // These DSB variants are for disassembly only. -defm DSB : MemB<0b0100, "dsb">; +def DSBvar : AMBI<0b0100, "dsb">; // ISB has only full system option -- for disassembly only -def ISBsy : AMBI<"isb", ""> { - let Inst{7-4} = 0b0110; +def ISBsy : AInoP<(outs), (ins), MiscFrm, NoItinerary, "isb", "", []>, + Requires<[IsARM, HasDB]> { + let Inst{31-4} = 0xf57ff06; let Inst{3-0} = 0b1111; } Modified: llvm/trunk/lib/Target/ARM/AsmPrinter/ARMInstPrinter.cpp URL: http://llvm.org/viewvc/llvm-project/llvm/trunk/lib/Target/ARM/AsmPrinter/ARMInstPrinter.cpp?rev=110951&r1=110950&r2=110951&view=diff ============================================================================== --- llvm/trunk/lib/Target/ARM/AsmPrinter/ARMInstPrinter.cpp (original) +++ llvm/trunk/lib/Target/ARM/AsmPrinter/ARMInstPrinter.cpp Thu Aug 12 15:46:17 2010 @@ -472,6 +472,12 @@ O << '#' << lsb << ", #" << width; } +void ARMInstPrinter::printMemBOption(const MCInst *MI, unsigned OpNum, + raw_ostream &O) { + unsigned val = MI->getOperand(OpNum).getImm(); + O << ARM_MB::MemBOptToString(val); +} + void ARMInstPrinter::printSatShiftOperand(const MCInst *MI, unsigned OpNum, raw_ostream &O) { unsigned ShiftOp = MI->getOperand(OpNum).getImm(); Modified: llvm/trunk/lib/Target/ARM/AsmPrinter/ARMInstPrinter.h URL: http://llvm.org/viewvc/llvm-project/llvm/trunk/lib/Target/ARM/AsmPrinter/ARMInstPrinter.h?rev=110951&r1=110950&r2=110951&view=diff ============================================================================== --- llvm/trunk/lib/Target/ARM/AsmPrinter/ARMInstPrinter.h (original) +++ llvm/trunk/lib/Target/ARM/AsmPrinter/ARMInstPrinter.h Thu Aug 12 15:46:17 2010 @@ -57,6 +57,7 @@ void printBitfieldInvMaskImmOperand(const MCInst *MI, unsigned OpNum, raw_ostream &O); + void printMemBOption(const MCInst *MI, unsigned OpNum, raw_ostream &O); void printSatShiftOperand(const MCInst *MI, unsigned OpNum, raw_ostream &O); void printThumbS4ImmOperand(const MCInst *MI, unsigned OpNum, raw_ostream &O); Modified: llvm/trunk/lib/Target/ARM/Disassembler/ARMDisassemblerCore.cpp URL: http://llvm.org/viewvc/llvm-project/llvm/trunk/lib/Target/ARM/Disassembler/ARMDisassemblerCore.cpp?rev=110951&r1=110950&r2=110951&view=diff ============================================================================== --- llvm/trunk/lib/Target/ARM/Disassembler/ARMDisassemblerCore.cpp (original) +++ llvm/trunk/lib/Target/ARM/Disassembler/ARMDisassemblerCore.cpp Thu Aug 12 15:46:17 2010 @@ -2935,7 +2935,7 @@ // A8.6.49 ISB static inline bool MemBarrierInstr(uint32_t insn) { unsigned op7_4 = slice(insn, 7, 4); - if (slice(insn, 31, 20) == 0xf57 && (op7_4 >= 4 && op7_4 <= 6)) + if (slice(insn, 31, 8) == 0xf57ff0 && (op7_4 >= 4 && op7_4 <= 6)) return true; return false; @@ -2992,8 +2992,15 @@ static bool DisassembleMiscFrm(MCInst &MI, unsigned Opcode, uint32_t insn, unsigned short NumOps, unsigned &NumOpsAdded, BO B) { - if (MemBarrierInstr(insn)) + if (MemBarrierInstr(insn)) { + // DMBsy, DSBsy, and ISBsy instructions have zero operand and are taken care + // of within the generic ARMBasicMCBuilder::BuildIt() method. + // + // Inst{3-0} encodes the memory barrier option for the variants. + MI.addOperand(MCOperand::CreateImm(slice(insn, 3, 0))); + NumOpsAdded = 1; return true; + } switch (Opcode) { case ARM::CLREX: Modified: llvm/trunk/test/MC/Disassembler/arm-tests.txt URL: http://llvm.org/viewvc/llvm-project/llvm/trunk/test/MC/Disassembler/arm-tests.txt?rev=110951&r1=110950&r2=110951&view=diff ============================================================================== --- llvm/trunk/test/MC/Disassembler/arm-tests.txt (original) +++ llvm/trunk/test/MC/Disassembler/arm-tests.txt Thu Aug 12 15:46:17 2010 @@ -21,6 +21,12 @@ # CHECK: dsb 0x4f 0xf0 0x7f 0xf5 +# CHECK: dsb st +0x4e 0xf0 0x7f 0xf5 + +# CHECK: isb +0x6f 0xf0 0x7f 0xf5 + # CHECK: ldclvc p5, cr15, [r8], #-0 0x00 0xf5 0x78 0x7c Modified: llvm/trunk/utils/TableGen/EDEmitter.cpp URL: http://llvm.org/viewvc/llvm-project/llvm/trunk/utils/TableGen/EDEmitter.cpp?rev=110951&r1=110950&r2=110951&view=diff ============================================================================== --- llvm/trunk/utils/TableGen/EDEmitter.cpp (original) +++ llvm/trunk/utils/TableGen/EDEmitter.cpp Thu Aug 12 15:46:17 2010 @@ -599,6 +599,7 @@ IMM("cps_opt"); IMM("vfp_f64imm"); IMM("vfp_f32imm"); + IMM("memb_opt"); IMM("msr_mask"); IMM("neg_zero"); IMM("imm0_31"); From bruno.cardoso at gmail.com Thu Aug 12 15:55:18 2010 From: bruno.cardoso at gmail.com (Bruno Cardoso Lopes) Date: Thu, 12 Aug 2010 20:55:18 -0000 Subject: [llvm-commits] [llvm] r110954 - /llvm/trunk/lib/Target/X86/X86InstrSSE.td Message-ID: <20100812205518.961FD2A6C12C@llvm.org> Author: bruno Date: Thu Aug 12 15:55:18 2010 New Revision: 110954 URL: http://llvm.org/viewvc/llvm-project?rev=110954&view=rev Log: Some small clean-up: use of pseudo instructions Modified: llvm/trunk/lib/Target/X86/X86InstrSSE.td Modified: llvm/trunk/lib/Target/X86/X86InstrSSE.td URL: http://llvm.org/viewvc/llvm-project/llvm/trunk/lib/Target/X86/X86InstrSSE.td?rev=110954&r1=110953&r2=110954&view=diff ============================================================================== --- llvm/trunk/lib/Target/X86/X86InstrSSE.td (original) +++ llvm/trunk/lib/Target/X86/X86InstrSSE.td Thu Aug 12 15:55:18 2010 @@ -2174,33 +2174,33 @@ // Alias instructions that map zero vector to pxor / xorp* for sse. // We set canFoldAsLoad because this can be converted to a constant-pool // load of an all-zeros value if folding it would be beneficial. -// FIXME: Change encoding to pseudo! let isReMaterializable = 1, isAsCheapAsAMove = 1, canFoldAsLoad = 1, isCodeGenOnly = 1 in { -def V_SET0PS : PSI<0x57, MRMInitReg, (outs VR128:$dst), (ins), "", - [(set VR128:$dst, (v4f32 immAllZerosV))]>; -def V_SET0PD : PDI<0x57, MRMInitReg, (outs VR128:$dst), (ins), "", - [(set VR128:$dst, (v2f64 immAllZerosV))]>; -let ExeDomain = SSEPackedInt in -def V_SET0PI : PDI<0xEF, MRMInitReg, (outs VR128:$dst), (ins), "", - [(set VR128:$dst, (v4i32 immAllZerosV))]>; + let Predicates = [HasSSE1] in + def V_SET0PS : I<0, Pseudo, (outs VR128:$dst), (ins), "", + [(set VR128:$dst, (v4f32 immAllZerosV))]>; + let Predicates = [HasSSE2] in { + def V_SET0PD : I<0, Pseudo, (outs VR128:$dst), (ins), "", + [(set VR128:$dst, (v2f64 immAllZerosV))]>; + def V_SET0PI : I<0, Pseudo, (outs VR128:$dst), (ins), "", + [(set VR128:$dst, (v4i32 immAllZerosV))], SSEPackedInt>; + } } // The same as done above but for AVX. The 128-bit versions are the // same, but re-encoded. The 256-bit does not support PI version. let isReMaterializable = 1, isAsCheapAsAMove = 1, canFoldAsLoad = 1, isCodeGenOnly = 1, Predicates = [HasAVX] in { -def AVX_SET0PS : PSI<0x57, MRMInitReg, (outs VR128:$dst), (ins), "", - [(set VR128:$dst, (v4f32 immAllZerosV))]>, VEX_4V; -def AVX_SET0PD : PDI<0x57, MRMInitReg, (outs VR128:$dst), (ins), "", - [(set VR128:$dst, (v2f64 immAllZerosV))]>, VEX_4V; -def AVX_SET0PSY : PSI<0x57, MRMInitReg, (outs VR256:$dst), (ins), "", - [(set VR256:$dst, (v8f32 immAllZerosV))]>, VEX_4V; -def AVX_SET0PDY : PDI<0x57, MRMInitReg, (outs VR256:$dst), (ins), "", - [(set VR256:$dst, (v4f64 immAllZerosV))]>, VEX_4V; -let ExeDomain = SSEPackedInt in -def AVX_SET0PI : PDI<0xEF, MRMInitReg, (outs VR128:$dst), (ins), "", - [(set VR128:$dst, (v4i32 immAllZerosV))]>; +def AVX_SET0PS : I<0, Pseudo, (outs VR128:$dst), (ins), "", + [(set VR128:$dst, (v4f32 immAllZerosV))]>; +def AVX_SET0PD : I<0, Pseudo, (outs VR128:$dst), (ins), "", + [(set VR128:$dst, (v2f64 immAllZerosV))]>; +def AVX_SET0PI : I<0, Pseudo, (outs VR128:$dst), (ins), "", + [(set VR128:$dst, (v4i32 immAllZerosV))], SSEPackedInt>; +def AVX_SET0PSY : I<0, Pseudo, (outs VR256:$dst), (ins), "", + [(set VR256:$dst, (v8f32 immAllZerosV))]>; +def AVX_SET0PDY : I<0, Pseudo, (outs VR256:$dst), (ins), "", + [(set VR256:$dst, (v4f64 immAllZerosV))]>; } def : Pat<(v2i64 immAllZerosV), (V_SET0PI)>; @@ -3249,14 +3249,13 @@ // was introduced with SSE2, it's backward compatible. def PAUSE : I<0x90, RawFrm, (outs), (ins), "pause", []>, REP; -// Alias instructions that map zero vector to pxor / xorp* for sse. +// Alias instructions that map one vector to pcmpeqd for sse2 and above. // We set canFoldAsLoad because this can be converted to a constant-pool // load of an all-ones value if folding it would be beneficial. let isReMaterializable = 1, isAsCheapAsAMove = 1, canFoldAsLoad = 1, - isCodeGenOnly = 1, ExeDomain = SSEPackedInt in - // FIXME: Change encoding to pseudo. - def V_SETALLONES : PDI<0x76, MRMInitReg, (outs VR128:$dst), (ins), "", - [(set VR128:$dst, (v4i32 immAllOnesV))]>; + isCodeGenOnly = 1, Predicates = [HasSSE2] in + def V_SETALLONES : I<0, Pseudo, (outs VR128:$dst), (ins), "", + [(set VR128:$dst, (v4i32 immAllOnesV))], SSEPackedInt>; //===---------------------------------------------------------------------===// // SSE3 - Conversion Instructions From resistor at mac.com Thu Aug 12 17:22:53 2010 From: resistor at mac.com (Owen Anderson) Date: Thu, 12 Aug 2010 22:22:53 -0000 Subject: [llvm-commits] [test-suite] r110960 - /test-suite/trunk/MultiSource/Applications/minisat/Main.cpp Message-ID: <20100812222253.65EC62A6C12C@llvm.org> Author: resistor Date: Thu Aug 12 17:22:53 2010 New Revision: 110960 URL: http://llvm.org/viewvc/llvm-project?rev=110960&view=rev Log: Remove dependence on signal() to improve portability. Modified: test-suite/trunk/MultiSource/Applications/minisat/Main.cpp Modified: test-suite/trunk/MultiSource/Applications/minisat/Main.cpp URL: http://llvm.org/viewvc/llvm-project/test-suite/trunk/MultiSource/Applications/minisat/Main.cpp?rev=110960&r1=110959&r2=110960&view=diff ============================================================================== --- test-suite/trunk/MultiSource/Applications/minisat/Main.cpp (original) +++ test-suite/trunk/MultiSource/Applications/minisat/Main.cpp Thu Aug 12 17:22:53 2010 @@ -22,7 +22,6 @@ #include #include -#include #include #include "Solver.h" @@ -298,8 +297,6 @@ double cpu_time = cpuTime(); solver = &S; - signal(SIGINT,SIGINT_handler); - signal(SIGHUP,SIGINT_handler); if (argc == 1) reportf("Reading from standard input... Use '-h' or '--help' for help.\n"); From sabre at nondot.org Thu Aug 12 17:25:24 2010 From: sabre at nondot.org (Chris Lattner) Date: Thu, 12 Aug 2010 22:25:24 -0000 Subject: [llvm-commits] [llvm] r110962 - in /llvm/trunk: lib/Transforms/Scalar/SCCP.cpp test/Transforms/SCCP/ipsccp-addr-taken.ll Message-ID: <20100812222524.0E7C42A6C12C@llvm.org> Author: lattner Date: Thu Aug 12 17:25:23 2010 New Revision: 110962 URL: http://llvm.org/viewvc/llvm-project?rev=110962&view=rev Log: fix PR7876: If ipsccp decides that a function's address is taken before it rewrites the code, we need to use that in the post-rewrite pass. Added: llvm/trunk/test/Transforms/SCCP/ipsccp-addr-taken.ll Modified: llvm/trunk/lib/Transforms/Scalar/SCCP.cpp Modified: llvm/trunk/lib/Transforms/Scalar/SCCP.cpp URL: http://llvm.org/viewvc/llvm-project/llvm/trunk/lib/Transforms/Scalar/SCCP.cpp?rev=110962&r1=110961&r2=110962&view=diff ============================================================================== --- llvm/trunk/lib/Transforms/Scalar/SCCP.cpp (original) +++ llvm/trunk/lib/Transforms/Scalar/SCCP.cpp Thu Aug 12 17:25:23 2010 @@ -1749,6 +1749,13 @@ bool IPSCCP::runOnModule(Module &M) { SCCPSolver Solver(getAnalysisIfAvailable()); + // AddressTakenFunctions - This set keeps track of the address-taken functions + // that are in the input. As IPSCCP runs through and simplifies code, + // functions that were address taken can end up losing their + // address-taken-ness. Because of this, we keep track of their addresses from + // the first pass so we can use them for the later simplification pass. + SmallPtrSet AddressTakenFunctions; + // Loop over all functions, marking arguments to those with their addresses // taken or that are external as overdefined. // @@ -1764,9 +1771,13 @@ // If this function only has direct calls that we can see, we can track its // arguments and return value aggressively, and can assume it is not called // unless we see evidence to the contrary. - if (F->hasLocalLinkage() && !AddressIsTaken(F)) { - Solver.AddArgumentTrackedFunction(F); - continue; + if (F->hasLocalLinkage()) { + if (AddressIsTaken(F)) + AddressTakenFunctions.insert(F); + else { + Solver.AddArgumentTrackedFunction(F); + continue; + } } // Assume the function is called. @@ -1951,7 +1962,7 @@ continue; // We can only do this if we know that nothing else can call the function. - if (!F->hasLocalLinkage() || AddressIsTaken(F)) + if (!F->hasLocalLinkage() || AddressTakenFunctions.count(F)) continue; for (Function::iterator BB = F->begin(), E = F->end(); BB != E; ++BB) Added: llvm/trunk/test/Transforms/SCCP/ipsccp-addr-taken.ll URL: http://llvm.org/viewvc/llvm-project/llvm/trunk/test/Transforms/SCCP/ipsccp-addr-taken.ll?rev=110962&view=auto ============================================================================== --- llvm/trunk/test/Transforms/SCCP/ipsccp-addr-taken.ll (added) +++ llvm/trunk/test/Transforms/SCCP/ipsccp-addr-taken.ll Thu Aug 12 17:25:23 2010 @@ -0,0 +1,28 @@ +; RUN: opt %s -ipsccp -S | FileCheck %s +; PR7876 +target datalayout = "e-p:64:64:64-i1:8:8-i8:8:8-i16:16:16-i32:32:32-i64:64:64-f32:32:32-f64:64:64-v64:64:64-v128:128:128-a0:0:64-s0:64:64-f80:128:128-n8:16:32:64" +target triple = "x86_64-apple-darwin10.0.0" + +define internal i32 @foo() nounwind noinline ssp { +entry: + ret i32 0 +; CHECK: @foo +; CHECK: entry: +; CHECK: ret i32 0 +} + +declare i32 @bar() + +define internal i32 @test(i32 %c) nounwind noinline ssp { +bb: + %tmp1 = icmp ne i32 %c, 0 ; [#uses=1] + %tmp2 = select i1 %tmp1, i32 ()* @foo, i32 ()* @bar ; [#uses=1] + %tmp3 = tail call i32 %tmp2() nounwind ; [#uses=1] + ret i32 %tmp3 +} + +define i32 @main() nounwind ssp { +bb: + %tmp = tail call i32 @test(i32 1) ; [#uses=1] + ret i32 %tmp +} From evan.cheng at apple.com Thu Aug 12 17:25:25 2010 From: evan.cheng at apple.com (Evan Cheng) Date: Thu, 12 Aug 2010 22:25:25 -0000 Subject: [llvm-commits] [test-suite] r110963 - /test-suite/trunk/MultiSource/Applications/minisat/Main.cpp Message-ID: <20100812222525.2E9012A6C12D@llvm.org> Author: evancheng Date: Thu Aug 12 17:25:24 2010 New Revision: 110963 URL: http://llvm.org/viewvc/llvm-project?rev=110963&view=rev Log: Remove signal handler as well. Modified: test-suite/trunk/MultiSource/Applications/minisat/Main.cpp Modified: test-suite/trunk/MultiSource/Applications/minisat/Main.cpp URL: http://llvm.org/viewvc/llvm-project/test-suite/trunk/MultiSource/Applications/minisat/Main.cpp?rev=110963&r1=110962&r2=110963&view=diff ============================================================================== --- test-suite/trunk/MultiSource/Applications/minisat/Main.cpp (original) +++ test-suite/trunk/MultiSource/Applications/minisat/Main.cpp Thu Aug 12 17:25:24 2010 @@ -201,12 +201,6 @@ } Solver* solver; -static void SIGINT_handler(int signum) { - reportf("\n"); reportf("*** INTERRUPTED ***\n"); - printStats(*solver); - reportf("\n"); reportf("*** INTERRUPTED ***\n"); - exit(1); } - //================================================================================================= // Main: From stoklund at 2pi.dk Thu Aug 12 17:32:13 2010 From: stoklund at 2pi.dk (Jakob Stoklund Olesen) Date: Thu, 12 Aug 2010 15:32:13 -0700 Subject: [llvm-commits] [llvm] r110946 - in /llvm/trunk: lib/Target/X86/X86InstrInfo.cpp lib/Target/X86/X86InstrSSE.td test/CodeGen/X86/avx-128.ll In-Reply-To: <20100812202053.4CD3B2A6C12C@llvm.org> References: <20100812202053.4CD3B2A6C12C@llvm.org> Message-ID: On Aug 12, 2010, at 1:20 PM, Bruno Cardoso Lopes wrote: > - Make sure MOV[AU]PS instructions are only selected when SSE1 is enabled, and duplicate the patterns to match AVX. Hi Bruno, I think you have to do something similar in X86InstrInfo::copyPhysReg. It always creates MOVAPSrr. /jakob From bruno.cardoso at gmail.com Thu Aug 12 17:35:20 2010 From: bruno.cardoso at gmail.com (Bruno Cardoso Lopes) Date: Thu, 12 Aug 2010 15:35:20 -0700 Subject: [llvm-commits] [llvm] r110946 - in /llvm/trunk: lib/Target/X86/X86InstrInfo.cpp lib/Target/X86/X86InstrSSE.td test/CodeGen/X86/avx-128.ll In-Reply-To: References: <20100812202053.4CD3B2A6C12C@llvm.org> Message-ID: On Thu, Aug 12, 2010 at 3:32 PM, Jakob Stoklund Olesen wrote: > > On Aug 12, 2010, at 1:20 PM, Bruno Cardoso Lopes wrote: > >> - Make sure MOV[AU]PS instructions are only selected when SSE1 is enabled, and duplicate the patterns to match AVX. > > Hi Bruno, > > I think you have to do something similar in X86InstrInfo::copyPhysReg. It always creates MOVAPSrr. Nice, thanks for reminding! :) -- Bruno Cardoso Lopes http://www.brunocardoso.cc From stoklund at 2pi.dk Thu Aug 12 18:02:55 2010 From: stoklund at 2pi.dk (Jakob Stoklund Olesen) Date: Thu, 12 Aug 2010 23:02:55 -0000 Subject: [llvm-commits] [llvm] r110975 - in /llvm/trunk/lib/CodeGen: SplitKit.cpp SplitKit.h Message-ID: <20100812230255.89D272A6C12C@llvm.org> Author: stoklund Date: Thu Aug 12 18:02:55 2010 New Revision: 110975 URL: http://llvm.org/viewvc/llvm-project?rev=110975&view=rev Log: Update the SplitAnalysis statistics as uses are moved from curli to the new split intervals. THis means the analysis can be used for multiple splits as long as curli doesn't shrink. Modified: llvm/trunk/lib/CodeGen/SplitKit.cpp llvm/trunk/lib/CodeGen/SplitKit.h Modified: llvm/trunk/lib/CodeGen/SplitKit.cpp URL: http://llvm.org/viewvc/llvm-project/llvm/trunk/lib/CodeGen/SplitKit.cpp?rev=110975&r1=110974&r2=110975&view=diff ============================================================================== --- llvm/trunk/lib/CodeGen/SplitKit.cpp (original) +++ llvm/trunk/lib/CodeGen/SplitKit.cpp Thu Aug 12 18:02:55 2010 @@ -70,7 +70,7 @@ if (usingBlocks_[MBB]++) continue; if (MachineLoop *Loop = loops_.getLoopFor(MBB)) - usingLoops_.insert(Loop); + usingLoops_[Loop]++; } DEBUG(dbgs() << " counted " << usingInstrs_.size() << " instrs, " @@ -78,6 +78,34 @@ << usingLoops_.size() << " loops.\n"); } +/// removeUse - Update statistics by noting that MI no longer uses curli. +void SplitAnalysis::removeUse(const MachineInstr *MI) { + if (!usingInstrs_.erase(MI)) + return; + + // Decrement MBB count. + const MachineBasicBlock *MBB = MI->getParent(); + BlockCountMap::iterator bi = usingBlocks_.find(MBB); + assert(bi != usingBlocks_.end() && "MBB missing"); + assert(bi->second && "0 count in map"); + if (--bi->second) + return; + // No more uses in MBB. + usingBlocks_.erase(bi); + + // Decrement loop count. + MachineLoop *Loop = loops_.getLoopFor(MBB); + if (!Loop) + return; + LoopCountMap::iterator li = usingLoops_.find(Loop); + assert(li != usingLoops_.end() && "Loop missing"); + assert(li->second && "0 count in map"); + if (--li->second) + return; + // No more blocks in Loop. + usingLoops_.erase(li); +} + // Get three sets of basic blocks surrounding a loop: Blocks inside the loop, // predecessor blocks, and exit blocks. void SplitAnalysis::getLoopBlocks(const MachineLoop *Loop, LoopBlocks &Blocks) { @@ -219,13 +247,14 @@ // Find first-class and second class candidate loops. // We prefer to split around loops where curli is used outside the periphery. - for (LoopPtrSet::const_iterator I = usingLoops_.begin(), + for (LoopCountMap::const_iterator I = usingLoops_.begin(), E = usingLoops_.end(); I != E; ++I) { - getLoopBlocks(*I, Blocks); + const MachineLoop *Loop = I->first; + getLoopBlocks(Loop, Blocks); // FIXME: We need an SSA updater to properly handle multiple exit blocks. if (Blocks.Exits.size() > 1) { - DEBUG(dbgs() << " multiple exits from " << **I); + DEBUG(dbgs() << " multiple exits from " << *Loop); continue; } @@ -238,21 +267,21 @@ LPS = &SecondLoops; break; case ContainedInLoop: - DEBUG(dbgs() << " contained in " << **I); + DEBUG(dbgs() << " contained in " << *Loop); continue; case SinglePeripheral: - DEBUG(dbgs() << " single peripheral use in " << **I); + DEBUG(dbgs() << " single peripheral use in " << *Loop); continue; } // Will it be possible to split around this loop? getCriticalExits(Blocks, CriticalExits); DEBUG(dbgs() << " " << CriticalExits.size() << " critical exits from " - << **I); + << *Loop); if (!canSplitCriticalExits(Blocks, CriticalExits)) continue; // This is a possible split. assert(LPS); - LPS->insert(*I); + LPS->insert(Loop); } DEBUG(dbgs() << " getBestSplitLoop found " << Loops.size() << " + " Modified: llvm/trunk/lib/CodeGen/SplitKit.h URL: http://llvm.org/viewvc/llvm-project/llvm/trunk/lib/CodeGen/SplitKit.h?rev=110975&r1=110974&r2=110975&view=diff ============================================================================== --- llvm/trunk/lib/CodeGen/SplitKit.h (original) +++ llvm/trunk/lib/CodeGen/SplitKit.h Thu Aug 12 18:02:55 2010 @@ -45,9 +45,9 @@ typedef DenseMap BlockCountMap; BlockCountMap usingBlocks_; - // Loops where the curent interval is used. - typedef SmallPtrSet LoopPtrSet; - LoopPtrSet usingLoops_; + // The number of basic block using curli in each loop. + typedef DenseMap LoopCountMap; + LoopCountMap usingLoops_; private: // Current live interval. @@ -68,6 +68,9 @@ /// split. void analyze(const LiveInterval *li); + /// removeUse - Update statistics by noting that mi no longer uses curli. + void removeUse(const MachineInstr *mi); + const LiveInterval *getCurLI() { return curli_; } /// clear - clear all data structures so SplitAnalysis is ready to analyze a @@ -75,6 +78,7 @@ void clear(); typedef SmallPtrSet BlockPtrSet; + typedef SmallPtrSet LoopPtrSet; // Sets of basic blocks surrounding a machine loop. struct LoopBlocks { From stoklund at 2pi.dk Thu Aug 12 18:02:57 2010 From: stoklund at 2pi.dk (Jakob Stoklund Olesen) Date: Thu, 12 Aug 2010 23:02:57 -0000 Subject: [llvm-commits] [llvm] r110976 - /llvm/trunk/lib/CodeGen/SplitKit.cpp Message-ID: <20100812230257.DBB022A6C12D@llvm.org> Author: stoklund Date: Thu Aug 12 18:02:57 2010 New Revision: 110976 URL: http://llvm.org/viewvc/llvm-project?rev=110976&view=rev Log: Handle an empty dupli. This can happen if the original interval has been broken into two disconnected parts. Ideally, we should be able to detect when the graph is disconnected and create separate intervals, but that code is not implemented yet. Example: Two basic blocks are both branching to a loop header. Our interval is defined in both basic blocks, and live into the loop along both edges. We decide to split the interval around the loop. The interval is split into an inside part and an outside part. The outside part now has two disconnected segments, one in each basic block. If we later decide to split the outside interval into single blocks, we get one interval per basic block and an empty dupli for the remainder. Modified: llvm/trunk/lib/CodeGen/SplitKit.cpp Modified: llvm/trunk/lib/CodeGen/SplitKit.cpp URL: http://llvm.org/viewvc/llvm-project/llvm/trunk/lib/CodeGen/SplitKit.cpp?rev=110976&r1=110975&r2=110976&view=diff ============================================================================== --- llvm/trunk/lib/CodeGen/SplitKit.cpp (original) +++ llvm/trunk/lib/CodeGen/SplitKit.cpp Thu Aug 12 18:02:57 2010 @@ -674,8 +674,14 @@ // dupli_ goes in last, after rewriting. if (dupli_) { - dupli_->RenumberValues(lis_); - intervals_.push_back(dupli_); + if (dupli_->empty()) { + DEBUG(dbgs() << " dupli became empty?\n"); + lis_.removeInterval(dupli_->reg); + dupli_ = 0; + } else { + dupli_->RenumberValues(lis_); + intervals_.push_back(dupli_); + } } // Calculate spill weight and allocation hints for new intervals. From gohman at apple.com Thu Aug 12 18:46:28 2010 From: gohman at apple.com (Dan Gohman) Date: Thu, 12 Aug 2010 23:46:28 -0000 Subject: [llvm-commits] [llvm] r110981 - /llvm/trunk/lib/VMCore/PassManager.cpp Message-ID: <20100812234628.ED63C2A6C12C@llvm.org> Author: djg Date: Thu Aug 12 18:46:28 2010 New Revision: 110981 URL: http://llvm.org/viewvc/llvm-project?rev=110981&view=rev Log: Use .empty() instead of .size(). Modified: llvm/trunk/lib/VMCore/PassManager.cpp Modified: llvm/trunk/lib/VMCore/PassManager.cpp URL: http://llvm.org/viewvc/llvm-project/llvm/trunk/lib/VMCore/PassManager.cpp?rev=110981&r1=110980&r2=110981&view=diff ============================================================================== --- llvm/trunk/lib/VMCore/PassManager.cpp (original) +++ llvm/trunk/lib/VMCore/PassManager.cpp Thu Aug 12 18:46:28 2010 @@ -737,7 +737,7 @@ AvailableAnalysis[PI] = P; - assert(AvailableAnalysis.size()); + assert(!AvailableAnalysis.empty()); //This pass is the current implementation of all of the interfaces it //implements as well. From gohman at apple.com Thu Aug 12 18:50:08 2010 From: gohman at apple.com (Dan Gohman) Date: Thu, 12 Aug 2010 23:50:08 -0000 Subject: [llvm-commits] [llvm] r110982 - /llvm/trunk/lib/VMCore/PassManager.cpp Message-ID: <20100812235008.DBB2D2A6C12C@llvm.org> Author: djg Date: Thu Aug 12 18:50:08 2010 New Revision: 110982 URL: http://llvm.org/viewvc/llvm-project?rev=110982&view=rev Log: Tidy up whitespace. Modified: llvm/trunk/lib/VMCore/PassManager.cpp Modified: llvm/trunk/lib/VMCore/PassManager.cpp URL: http://llvm.org/viewvc/llvm-project/llvm/trunk/lib/VMCore/PassManager.cpp?rev=110982&r1=110981&r2=110982&view=diff ============================================================================== --- llvm/trunk/lib/VMCore/PassManager.cpp (original) +++ llvm/trunk/lib/VMCore/PassManager.cpp Thu Aug 12 18:50:08 2010 @@ -7,7 +7,7 @@ // //===----------------------------------------------------------------------===// // -// This file implements the LLVM Pass Manager infrastructure. +// This file implements the LLVM Pass Manager infrastructure. // //===----------------------------------------------------------------------===// @@ -96,7 +96,7 @@ } return false; } - + /// This is a utility to check whether a pass should have IR dumped /// before it. @@ -126,9 +126,9 @@ OS << "Releasing pass '"; else OS << "Running pass '"; - + OS << P->getPassName() << "'"; - + if (M) { OS << " on module '" << M->getModuleIdentifier() << "'.\n"; return; @@ -164,7 +164,7 @@ public: static char ID; - explicit BBPassManager(int Depth) + explicit BBPassManager(int Depth) : PMDataManager(Depth), FunctionPass(ID) {} /// Execute all of the passes scheduled for execution. Keep track of @@ -204,8 +204,8 @@ return BP; } - virtual PassManagerType getPassManagerType() const { - return PMT_BasicBlockPassManager; + virtual PassManagerType getPassManagerType() const { + return PMT_BasicBlockPassManager; } }; @@ -225,8 +225,8 @@ bool wasRun; public: static char ID; - explicit FunctionPassManagerImpl(int Depth) : - Pass(PT_PassManager, ID), PMDataManager(Depth), + explicit FunctionPassManagerImpl(int Depth) : + Pass(PT_PassManager, ID), PMDataManager(Depth), PMTopLevelManager(TLM_Function), wasRun(false) { } /// add - Add a pass to the queue of passes to run. This passes ownership of @@ -236,8 +236,8 @@ void add(Pass *P) { schedulePass(P); } - - /// createPrinterPass - Get a function printer pass. + + /// createPrinterPass - Get a function printer pass. Pass *createPrinterPass(raw_ostream &O, const std::string &Banner) const { return createPrintFunctionPass(Banner, &O); } @@ -253,12 +253,12 @@ /// doInitialization - Run all of the initializers for the function passes. /// bool doInitialization(Module &M); - + /// doFinalization - Run all of the finalizers for the function passes. /// bool doFinalization(Module &M); - + virtual PMDataManager *getAsPMDataManager() { return this; } virtual Pass *getAsPass() { return this; } @@ -290,6 +290,7 @@ }; char FunctionPassManagerImpl::ID = 0; + //===----------------------------------------------------------------------===// // MPPassManager // @@ -304,7 +305,7 @@ // Delete on the fly managers. virtual ~MPPassManager() { - for (std::map::iterator + for (std::map::iterator I = OnTheFlyManagers.begin(), E = OnTheFlyManagers.end(); I != E; ++I) { FunctionPassManagerImpl *FPP = I->second; @@ -312,7 +313,7 @@ } } - /// createPrinterPass - Get a module printer pass. + /// createPrinterPass - Get a module printer pass. Pass *createPrinterPass(raw_ostream &O, const std::string &Banner) const { return createPrintModulePass(&O, false, Banner); } @@ -331,7 +332,7 @@ /// through getAnalysis interface. virtual void addLowerLevelRequiredPass(Pass *P, Pass *RequiredPass); - /// Return function pass corresponding to PassInfo PI, that is + /// Return function pass corresponding to PassInfo PI, that is /// required by module pass MP. Instantiate analysis pass, by using /// its runOnFunction() for function F. virtual Pass* getOnTheFlyPass(Pass *MP, AnalysisID PI, Function &F); @@ -362,8 +363,8 @@ return static_cast(PassVector[N]); } - virtual PassManagerType getPassManagerType() const { - return PMT_ModulePassManager; + virtual PassManagerType getPassManagerType() const { + return PMT_ModulePassManager; } private: @@ -386,7 +387,7 @@ static char ID; explicit PassManagerImpl(int Depth) : Pass(PT_PassManager, ID), PMDataManager(Depth), - PMTopLevelManager(TLM_Pass) { } + PMTopLevelManager(TLM_Pass) { } /// add - Add a pass to the queue of passes to run. This passes ownership of /// the Pass to the PassManager. When the PassManager is destroyed, the pass @@ -395,8 +396,8 @@ void add(Pass *P) { schedulePass(P); } - - /// createPrinterPass - Get a module printer pass. + + /// createPrinterPass - Get a module printer pass. Pass *createPrinterPass(raw_ostream &O, const std::string &Banner) const { return createPrintModulePass(&O, false, Banner); } @@ -453,7 +454,7 @@ public: // Use 'create' member to get this. TimingInfo() : TG("... Pass execution timing report ...") {} - + // TimingDtor - Print out information about timing information ~TimingInfo() { // Delete all of the timers, which accumulate their info into the @@ -471,7 +472,7 @@ /// getPassTimer - Return the timer for the specified pass if it exists. Timer *getPassTimer(Pass *P) { - if (P->getAsPMDataManager()) + if (P->getAsPMDataManager()) return 0; sys::SmartScopedLock Lock(*TimingInfoMutex); @@ -501,17 +502,17 @@ FPP->setTopLevelManager(this); addPassManager(FPP); activeStack.push(FPP); - } + } } /// Set pass P as the last user of the given analysis passes. -void PMTopLevelManager::setLastUser(SmallVector &AnalysisPasses, +void PMTopLevelManager::setLastUser(SmallVector &AnalysisPasses, Pass *P) { for (SmallVector::iterator I = AnalysisPasses.begin(), E = AnalysisPasses.end(); I != E; ++I) { Pass *AP = *I; LastUser[AP] = P; - + if (P == AP) continue; @@ -530,7 +531,7 @@ /// Collect passes whose last user is P void PMTopLevelManager::collectLastUses(SmallVector &LastUses, Pass *P) { - DenseMap >::iterator DMI = + DenseMap >::iterator DMI = InversedLastUser.find(P); if (DMI == InversedLastUser.end()) return; @@ -546,7 +547,7 @@ AnalysisUsage *PMTopLevelManager::findAnalysisUsage(Pass *P) { AnalysisUsage *AnUsage = NULL; DenseMap::iterator DMI = AnUsageMap.find(P); - if (DMI != AnUsageMap.end()) + if (DMI != AnUsageMap.end()) AnUsage = DMI->second; else { AnUsage = new AnalysisUsage(); @@ -582,11 +583,11 @@ bool checkAnalysis = true; while (checkAnalysis) { checkAnalysis = false; - + const AnalysisUsage::VectorType &RequiredSet = AnUsage->getRequiredSet(); for (AnalysisUsage::VectorType::const_iterator I = RequiredSet.begin(), E = RequiredSet.end(); I != E; ++I) { - + Pass *AnalysisPass = findAnalysisPass(*I); if (!AnalysisPass) { const PassInfo *PI = PassRegistry::getPassRegistry()->getPassInfo(*I); @@ -604,7 +605,7 @@ checkAnalysis = true; } else - // Do not schedule this analysis. Lower level analsyis + // Do not schedule this analysis. Lower level analsyis // passes are run on the fly. delete AnalysisPass; } @@ -667,7 +668,7 @@ for (unsigned i = 0, e = ImmutablePasses.size(); i != e; ++i) { ImmutablePasses[i]->dumpPassStructure(0); } - + // Every class that derives from PMDataManager also derives from Pass // (sometimes indirectly), but there's no inheritance relationship // between PMDataManager and Pass, so we have to getAsPass to get @@ -693,15 +694,16 @@ for (SmallVector::iterator I = PassManagers.begin(), E = PassManagers.end(); I != E; ++I) (*I)->initializeAnalysisInfo(); - + // Initailize other pass managers - for (SmallVector::iterator I = IndirectPassManagers.begin(), - E = IndirectPassManagers.end(); I != E; ++I) + for (SmallVector::iterator + I = IndirectPassManagers.begin(), E = IndirectPassManagers.end(); + I != E; ++I) (*I)->initializeAnalysisInfo(); for (DenseMap::iterator DMI = LastUser.begin(), DME = LastUser.end(); DMI != DME; ++DMI) { - DenseMap >::iterator InvDMI = + DenseMap >::iterator InvDMI = InversedLastUser.find(DMI->second); if (InvDMI != InversedLastUser.end()) { SmallPtrSet &L = InvDMI->second; @@ -718,7 +720,7 @@ for (SmallVector::iterator I = PassManagers.begin(), E = PassManagers.end(); I != E; ++I) delete *I; - + for (SmallVector::iterator I = ImmutablePasses.begin(), E = ImmutablePasses.end(); I != E; ++I) delete *I; @@ -734,13 +736,13 @@ /// Augement AvailableAnalysis by adding analysis made available by pass P. void PMDataManager::recordAvailableAnalysis(Pass *P) { AnalysisID PI = P->getPassID(); - + AvailableAnalysis[PI] = P; - + assert(!AvailableAnalysis.empty()); - //This pass is the current implementation of all of the interfaces it - //implements as well. + // This pass is the current implementation of all of the interfaces it + // implements as well. const PassInfo *PInf = PassRegistry::getPassRegistry()->getPassInfo(PI); if (PInf == 0) return; const std::vector &II = PInf->getInterfacesImplemented(); @@ -754,18 +756,18 @@ AnalysisUsage *AnUsage = TPM->findAnalysisUsage(P); if (AnUsage->getPreservesAll()) return true; - + const AnalysisUsage::VectorType &PreservedSet = AnUsage->getPreservedSet(); for (SmallVector::iterator I = HigherLevelAnalysis.begin(), E = HigherLevelAnalysis.end(); I != E; ++I) { Pass *P1 = *I; if (P1->getAsImmutablePass() == 0 && std::find(PreservedSet.begin(), PreservedSet.end(), - P1->getPassID()) == + P1->getPassID()) == PreservedSet.end()) return false; } - + return true; } @@ -800,7 +802,7 @@ E = AvailableAnalysis.end(); I != E; ) { std::map::iterator Info = I++; if (Info->second->getAsImmutablePass() == 0 && - std::find(PreservedSet.begin(), PreservedSet.end(), Info->first) == + std::find(PreservedSet.begin(), PreservedSet.end(), Info->first) == PreservedSet.end()) { // Remove this analysis if (PassDebugging >= Details) { @@ -811,7 +813,7 @@ AvailableAnalysis.erase(Info); } } - + // Check inherited analysis also. If P is not preserving analysis // provided by parent manager then remove it here. for (unsigned Index = 0; Index < PMT_Last; ++Index) { @@ -819,12 +821,12 @@ if (!InheritedAnalysis[Index]) continue; - for (std::map::iterator + for (std::map::iterator I = InheritedAnalysis[Index]->begin(), E = InheritedAnalysis[Index]->end(); I != E; ) { std::map::iterator Info = I++; if (Info->second->getAsImmutablePass() == 0 && - std::find(PreservedSet.begin(), PreservedSet.end(), Info->first) == + std::find(PreservedSet.begin(), PreservedSet.end(), Info->first) == PreservedSet.end()) { // Remove this analysis if (PassDebugging >= Details) { @@ -890,7 +892,7 @@ } } -/// Add pass P into the PassVector. Update +/// Add pass P into the PassVector. Update /// AvailableAnalysis appropriately if ProcessAnalysis is true. void PMDataManager::add(Pass *P, bool ProcessAnalysis) { // This manager is going to manage pass P. Set up analysis resolver @@ -915,7 +917,7 @@ unsigned PDepth = this->getDepth(); - collectRequiredAnalysis(RequiredPasses, + collectRequiredAnalysis(RequiredPasses, ReqAnalysisNotAvailable, P); for (SmallVector::iterator I = RequiredPasses.begin(), E = RequiredPasses.end(); I != E; ++I) { @@ -933,7 +935,7 @@ TransferLastUses.push_back(PRequired); // Keep track of higher level analysis used by this manager. HigherLevelAnalysis.push_back(PRequired); - } else + } else llvm_unreachable("Unable to accomodate Required Pass"); } @@ -951,8 +953,8 @@ } // Now, take care of required analysises that are not available. - for (SmallVector::iterator - I = ReqAnalysisNotAvailable.begin(), + for (SmallVector::iterator + I = ReqAnalysisNotAvailable.begin(), E = ReqAnalysisNotAvailable.end() ;I != E; ++I) { const PassInfo *PI = PassRegistry::getPassRegistry()->getPassInfo(*I); Pass *AnalysisPass = PI->createPass(); @@ -977,10 +979,10 @@ Pass *P) { AnalysisUsage *AnUsage = TPM->findAnalysisUsage(P); const AnalysisUsage::VectorType &RequiredSet = AnUsage->getRequiredSet(); - for (AnalysisUsage::VectorType::const_iterator + for (AnalysisUsage::VectorType::const_iterator I = RequiredSet.begin(), E = RequiredSet.end(); I != E; ++I) { if (Pass *AnalysisPass = findAnalysisPass(*I, true)) - RP.push_back(AnalysisPass); + RP.push_back(AnalysisPass); else RP_NotAvail.push_back(*I); } @@ -989,7 +991,7 @@ for (AnalysisUsage::VectorType::const_iterator I = IDs.begin(), E = IDs.end(); I != E; ++I) { if (Pass *AnalysisPass = findAnalysisPass(*I, true)) - RP.push_back(AnalysisPass); + RP.push_back(AnalysisPass); else RP_NotAvail.push_back(*I); } @@ -1030,7 +1032,7 @@ // Search Parents through TopLevelManager if (SearchParent) return TPM->findAnalysisPass(AID); - + return NULL; } @@ -1044,7 +1046,7 @@ return; TPM->collectLastUses(LUses, P); - + for (SmallVector::iterator I = LUses.begin(), E = LUses.end(); I != E; ++I) { llvm::dbgs() << "--" << std::string(Offset*2, ' '); @@ -1108,7 +1110,7 @@ void PMDataManager::dumpRequiredSet(const Pass *P) const { if (PassDebugging < Details) return; - + AnalysisUsage analysisUsage; P->getAnalysisUsage(analysisUsage); dumpAnalysisUsage("Required", P, analysisUsage.getRequiredSet()); @@ -1117,7 +1119,7 @@ void PMDataManager::dumpPreservedSet(const Pass *P) const { if (PassDebugging < Details) return; - + AnalysisUsage analysisUsage; P->getAnalysisUsage(analysisUsage); dumpAnalysisUsage("Preserved", P, analysisUsage.getPreservedSet()); @@ -1147,14 +1149,14 @@ TPM->dumpPasses(); } - // Module Level pass may required Function Level analysis info - // (e.g. dominator info). Pass manager uses on the fly function pass manager - // to provide this on demand. In that case, in Pass manager terminology, + // Module Level pass may required Function Level analysis info + // (e.g. dominator info). Pass manager uses on the fly function pass manager + // to provide this on demand. In that case, in Pass manager terminology, // module level pass is requiring lower level analysis info managed by // lower level pass manager. // When Pass manager is not able to order required analysis info, Pass manager - // checks whether any lower level manager will be able to provide this + // checks whether any lower level manager will be able to provide this // analysis info on demand or not. #ifndef NDEBUG dbgs() << "Unable to schedule '" << RequiredPass->getPassName(); @@ -1182,7 +1184,7 @@ return PM.findAnalysisPass(ID, dir); } -Pass *AnalysisResolver::findImplPass(Pass *P, AnalysisID AnalysisPI, +Pass *AnalysisResolver::findImplPass(Pass *P, AnalysisID AnalysisPI, Function &F) { return PM.getOnTheFlyPass(P, AnalysisPI, F); } @@ -1190,8 +1192,8 @@ //===----------------------------------------------------------------------===// // BBPassManager implementation -/// Execute all of the passes scheduled for execution by invoking -/// runOnBasicBlock method. Keep track of whether any of the passes modifies +/// Execute all of the passes scheduled for execution by invoking +/// runOnBasicBlock method. Keep track of whether any of the passes modifies /// the function, and if so, return true. bool BBPassManager::runOnFunction(Function &F) { if (F.isDeclaration()) @@ -1218,7 +1220,7 @@ } Changed |= LocalChanged; - if (LocalChanged) + if (LocalChanged) dumpPassInfo(BP, MODIFICATION_MSG, ON_BASICBLOCK_MSG, I->getName()); dumpPreservedSet(BP); @@ -1302,7 +1304,7 @@ /// PassManager_X is destroyed, the pass will be destroyed as well, so /// there is no need to delete the pass. (TODO delete passes.) /// This implies that all passes MUST be allocated with 'new'. -void FunctionPassManager::add(Pass *P) { +void FunctionPassManager::add(Pass *P) { // If this is a not a function pass, don't add a printer for it. const void *PassID = P->getPassID(); if (P->getPassKind() == PT_Function) @@ -1422,8 +1424,8 @@ } -/// Execute all of the passes scheduled for execution by invoking -/// runOnFunction method. Keep track of whether any of the passes modifies +/// Execute all of the passes scheduled for execution by invoking +/// runOnFunction method. Keep track of whether any of the passes modifies /// the function, and if so, return true. bool FPPassManager::runOnFunction(Function &F) { if (F.isDeclaration()) @@ -1493,8 +1495,8 @@ //===----------------------------------------------------------------------===// // MPPassManager implementation -/// Execute all of the passes scheduled for execution by invoking -/// runOnModule method. Keep track of whether any of the passes modifies +/// Execute all of the passes scheduled for execution by invoking +/// runOnModule method. Keep track of whether any of the passes modifies /// the module, and if so, return true. bool MPPassManager::runOnModule(Module &M) { @@ -1529,7 +1531,7 @@ dumpPassInfo(MP, MODIFICATION_MSG, ON_MODULE_MSG, M.getModuleIdentifier()); dumpPreservedSet(MP); - + verifyPreservedAnalysis(MP); removeNotPreservedAnalysis(MP); recordAvailableAnalysis(MP); @@ -1555,7 +1557,7 @@ void MPPassManager::addLowerLevelRequiredPass(Pass *P, Pass *RequiredPass) { assert(P->getPotentialPassManagerType() == PMT_ModulePassManager && "Unable to handle Pass that requires lower level Analysis pass"); - assert((P->getPotentialPassManagerType() < + assert((P->getPotentialPassManagerType() < RequiredPass->getPotentialPassManagerType()) && "Unable to handle Pass that requires lower level Analysis pass"); @@ -1575,13 +1577,13 @@ FPP->setLastUser(LU, P); } -/// Return function pass corresponding to PassInfo PI, that is +/// Return function pass corresponding to PassInfo PI, that is /// required by module pass MP. Instantiate analysis pass, by using /// its runOnFunction() for function F. Pass* MPPassManager::getOnTheFlyPass(Pass *MP, AnalysisID PI, Function &F){ FunctionPassManagerImpl *FPP = OnTheFlyManagers[MP]; assert(FPP && "Unable to find on the fly pass"); - + FPP->releaseMemoryOnTheFly(); FPP->run(F); return ((PMTopLevelManager*)FPP)->findAnalysisPass(PI); @@ -1674,7 +1676,7 @@ /// If TimingInfo is enabled then start pass timer. Timer *llvm::getPassTimer(Pass *P) { - if (TheTimeInfo) + if (TheTimeInfo) return TheTimeInfo->getPassTimer(P); return 0; } @@ -1718,11 +1720,11 @@ } /// Find appropriate Module Pass Manager in the PM Stack and -/// add self into that manager. -void ModulePass::assignPassManager(PMStack &PMS, +/// add self into that manager. +void ModulePass::assignPassManager(PMStack &PMS, PassManagerType PreferredType) { // Find Module Pass Manager - while(!PMS.empty()) { + while (!PMS.empty()) { PassManagerType TopPMType = PMS.top()->getPassManagerType(); if (TopPMType == PreferredType) break; // We found desired pass manager @@ -1736,7 +1738,7 @@ } /// Find appropriate Function Pass Manager or Call Graph Pass Manager -/// in the PM Stack and add self into that manager. +/// in the PM Stack and add self into that manager. void FunctionPass::assignPassManager(PMStack &PMS, PassManagerType PreferredType) { @@ -1745,7 +1747,7 @@ if (PMS.top()->getPassManagerType() > PMT_FunctionPassManager) PMS.pop(); else - break; + break; } // Create new Function Pass Manager if needed. @@ -1777,14 +1779,14 @@ } /// Find appropriate Basic Pass Manager or Call Graph Pass Manager -/// in the PM Stack and add self into that manager. +/// in the PM Stack and add self into that manager. void BasicBlockPass::assignPassManager(PMStack &PMS, PassManagerType PreferredType) { BBPassManager *BBP; // Basic Pass Manager is a leaf pass manager. It does not handle // any other pass manager. - if (!PMS.empty() && + if (!PMS.empty() && PMS.top()->getPassManagerType() == PMT_BasicBlockPassManager) { BBP = (BBPassManager *)PMS.top(); } else { From gohman at apple.com Thu Aug 12 18:56:03 2010 From: gohman at apple.com (Dan Gohman) Date: Thu, 12 Aug 2010 23:56:03 -0000 Subject: [llvm-commits] [llvm] r110983 - in /llvm/trunk/lib/VMCore: Pass.cpp PassManager.cpp Message-ID: <20100812235603.67A572A6C12C@llvm.org> Author: djg Date: Thu Aug 12 18:56:03 2010 New Revision: 110983 URL: http://llvm.org/viewvc/llvm-project?rev=110983&view=rev Log: Trim #includes. Modified: llvm/trunk/lib/VMCore/Pass.cpp llvm/trunk/lib/VMCore/PassManager.cpp Modified: llvm/trunk/lib/VMCore/Pass.cpp URL: http://llvm.org/viewvc/llvm-project/llvm/trunk/lib/VMCore/Pass.cpp?rev=110983&r1=110982&r2=110983&view=diff ============================================================================== --- llvm/trunk/lib/VMCore/Pass.cpp (original) +++ llvm/trunk/lib/VMCore/Pass.cpp Thu Aug 12 18:56:03 2010 @@ -14,17 +14,11 @@ //===----------------------------------------------------------------------===// #include "llvm/Pass.h" -#include "llvm/PassManager.h" #include "llvm/PassRegistry.h" -#include "llvm/Module.h" -#include "llvm/ADT/StringMap.h" #include "llvm/Assembly/PrintModulePass.h" #include "llvm/Support/Debug.h" #include "llvm/Support/PassNameParser.h" #include "llvm/Support/raw_ostream.h" -#include "llvm/System/Atomic.h" -#include "llvm/System/Mutex.h" -#include "llvm/System/Threading.h" using namespace llvm; //===----------------------------------------------------------------------===// Modified: llvm/trunk/lib/VMCore/PassManager.cpp URL: http://llvm.org/viewvc/llvm-project/llvm/trunk/lib/VMCore/PassManager.cpp?rev=110983&r1=110982&r2=110983&view=diff ============================================================================== --- llvm/trunk/lib/VMCore/PassManager.cpp (original) +++ llvm/trunk/lib/VMCore/PassManager.cpp Thu Aug 12 18:56:03 2010 @@ -25,7 +25,6 @@ #include "llvm/Support/PassNameParser.h" #include "llvm/Support/raw_ostream.h" #include "llvm/System/Mutex.h" -#include "llvm/System/Threading.h" #include #include #include From natebegeman at mac.com Thu Aug 12 19:16:46 2010 From: natebegeman at mac.com (Nate Begeman) Date: Fri, 13 Aug 2010 00:16:46 -0000 Subject: [llvm-commits] [llvm] r110986 - in /llvm/trunk/lib/VMCore: Instructions.cpp Verifier.cpp Message-ID: <20100813001646.71BA72A6C12C@llvm.org> Author: sampo Date: Thu Aug 12 19:16:46 2010 New Revision: 110986 URL: http://llvm.org/viewvc/llvm-project?rev=110986&view=rev Log: Move some code from Verifier into SVI::isValidOperands. This allows us to catch bad shufflevector operations when they are created, rather than waiting for someone to notice later on. Modified: llvm/trunk/lib/VMCore/Instructions.cpp llvm/trunk/lib/VMCore/Verifier.cpp Modified: llvm/trunk/lib/VMCore/Instructions.cpp URL: http://llvm.org/viewvc/llvm-project/llvm/trunk/lib/VMCore/Instructions.cpp?rev=110986&r1=110985&r2=110986&view=diff ============================================================================== --- llvm/trunk/lib/VMCore/Instructions.cpp (original) +++ llvm/trunk/lib/VMCore/Instructions.cpp Thu Aug 12 19:16:46 2010 @@ -1430,9 +1430,24 @@ return false; const VectorType *MaskTy = dyn_cast(Mask->getType()); - if (!isa(Mask) || MaskTy == 0 || - !MaskTy->getElementType()->isIntegerTy(32)) + if (MaskTy == 0 || !MaskTy->getElementType()->isIntegerTy(32)) return false; + + // Check to see if Mask is valid. + if (const ConstantVector *MV = dyn_cast(Mask)) { + const VectorType *VTy = cast(V1->getType()); + for (unsigned i = 0, e = MV->getNumOperands(); i != e; ++i) { + if (ConstantInt* CI = dyn_cast(MV->getOperand(i))) { + if (CI->uge(VTy->getNumElements()*2)) + return false; + } else if (!isa(MV->getOperand(i))) { + return false; + } + } + } + else if (!isa(Mask) && !isa(Mask)) + return false; + return true; } Modified: llvm/trunk/lib/VMCore/Verifier.cpp URL: http://llvm.org/viewvc/llvm-project/llvm/trunk/lib/VMCore/Verifier.cpp?rev=110986&r1=110985&r2=110986&view=diff ============================================================================== --- llvm/trunk/lib/VMCore/Verifier.cpp (original) +++ llvm/trunk/lib/VMCore/Verifier.cpp Thu Aug 12 19:16:46 2010 @@ -1322,27 +1322,6 @@ Assert1(ShuffleVectorInst::isValidOperands(SV.getOperand(0), SV.getOperand(1), SV.getOperand(2)), "Invalid shufflevector operands!", &SV); - - const VectorType *VTy = dyn_cast(SV.getOperand(0)->getType()); - Assert1(VTy, "Operands are not a vector type", &SV); - - // Check to see if Mask is valid. - if (const ConstantVector *MV = dyn_cast(SV.getOperand(2))) { - for (unsigned i = 0, e = MV->getNumOperands(); i != e; ++i) { - if (ConstantInt* CI = dyn_cast(MV->getOperand(i))) { - Assert1(!CI->uge(VTy->getNumElements()*2), - "Invalid shufflevector shuffle mask!", &SV); - } else { - Assert1(isa(MV->getOperand(i)), - "Invalid shufflevector shuffle mask!", &SV); - } - } - } else { - Assert1(isa(SV.getOperand(2)) || - isa(SV.getOperand(2)), - "Invalid shufflevector shuffle mask!", &SV); - } - visitInstruction(SV); } From natebegeman at mac.com Thu Aug 12 19:17:53 2010 From: natebegeman at mac.com (Nate Begeman) Date: Fri, 13 Aug 2010 00:17:53 -0000 Subject: [llvm-commits] [llvm] r110987 - in /llvm/trunk: lib/Transforms/InstCombine/InstCombineVectorOps.cpp test/Transforms/InstCombine/vec_shuffle.ll Message-ID: <20100813001753.D242E2A6C12C@llvm.org> Author: sampo Date: Thu Aug 12 19:17:53 2010 New Revision: 110987 URL: http://llvm.org/viewvc/llvm-project?rev=110987&view=rev Log: Reapply this transformation now that it is passing the external test which it previously failed. Modified: llvm/trunk/lib/Transforms/InstCombine/InstCombineVectorOps.cpp llvm/trunk/test/Transforms/InstCombine/vec_shuffle.ll Modified: llvm/trunk/lib/Transforms/InstCombine/InstCombineVectorOps.cpp URL: http://llvm.org/viewvc/llvm-project/llvm/trunk/lib/Transforms/InstCombine/InstCombineVectorOps.cpp?rev=110987&r1=110986&r2=110987&view=diff ============================================================================== --- llvm/trunk/lib/Transforms/InstCombine/InstCombineVectorOps.cpp (original) +++ llvm/trunk/lib/Transforms/InstCombine/InstCombineVectorOps.cpp Thu Aug 12 19:17:53 2010 @@ -448,10 +448,8 @@ if (isa(SVI.getOperand(2))) return ReplaceInstUsesWith(SVI, UndefValue::get(SVI.getType())); - unsigned VWidth = cast(SVI.getType())->getNumElements(); - - if (VWidth != cast(LHS->getType())->getNumElements()) - return 0; + unsigned VWidth = Mask.size(); + unsigned LHSWidth = cast(LHS->getType())->getNumElements(); APInt UndefElts(VWidth, 0); APInt AllOnesEltMask(APInt::getAllOnesValue(VWidth)); @@ -464,14 +462,12 @@ // Canonicalize shuffle(x ,x,mask) -> shuffle(x, undef,mask') // Canonicalize shuffle(undef,x,mask) -> shuffle(x, undef,mask'). if (LHS == RHS || isa(LHS)) { - if (isa(LHS) && LHS == RHS) { - // shuffle(undef,undef,mask) -> undef. - return ReplaceInstUsesWith(SVI, LHS); - } + if (isa(LHS) && LHS == RHS) + return ReplaceInstUsesWith(SVI, UndefValue::get(SVI.getType())); // Remap any references to RHS to use LHS. std::vector Elts; - for (unsigned i = 0, e = Mask.size(); i != e; ++i) { + for (unsigned i = 0, e = LHSWidth; i != VWidth; ++i) { if (Mask[i] >= 2*e) Elts.push_back(UndefValue::get(Type::getInt32Ty(SVI.getContext()))); else { @@ -495,67 +491,130 @@ } // Analyze the shuffle, are the LHS or RHS and identity shuffles? - bool isLHSID = true, isRHSID = true; - - for (unsigned i = 0, e = Mask.size(); i != e; ++i) { - if (Mask[i] >= e*2) continue; // Ignore undef values. - // Is this an identity shuffle of the LHS value? - isLHSID &= (Mask[i] == i); + if (VWidth == LHSWidth) { + bool isLHSID = true, isRHSID = true; - // Is this an identity shuffle of the RHS value? - isRHSID &= (Mask[i]-e == i); + for (unsigned i = 0, e = Mask.size(); i != e; ++i) { + if (Mask[i] >= e*2) continue; // Ignore undef values. + // Is this an identity shuffle of the LHS value? + isLHSID &= (Mask[i] == i); + + // Is this an identity shuffle of the RHS value? + isRHSID &= (Mask[i]-e == i); + } + + // Eliminate identity shuffles. + if (isLHSID) return ReplaceInstUsesWith(SVI, LHS); + if (isRHSID) return ReplaceInstUsesWith(SVI, RHS); } - // Eliminate identity shuffles. - if (isLHSID) return ReplaceInstUsesWith(SVI, LHS); - if (isRHSID) return ReplaceInstUsesWith(SVI, RHS); - - // If the LHS is a shufflevector itself, see if we can combine it with this - // one without producing an unusual shuffle. Here we are really conservative: - // we are absolutely afraid of producing a shuffle mask not in the input - // program, because the code gen may not be smart enough to turn a merged - // shuffle into two specific shuffles: it may produce worse code. As such, - // we only merge two shuffles if the result is one of the two input shuffle - // masks. In this case, merging the shuffles just removes one instruction, - // which we know is safe. This is good for things like turning: - // (splat(splat)) -> splat. - if (ShuffleVectorInst *LHSSVI = dyn_cast(LHS)) { - if (isa(RHS)) { - std::vector LHSMask = getShuffleMask(LHSSVI); - - if (LHSMask.size() == Mask.size()) { - std::vector NewMask; - for (unsigned i = 0, e = Mask.size(); i != e; ++i) - if (Mask[i] >= e) - NewMask.push_back(2*e); - else - NewMask.push_back(LHSMask[Mask[i]]); - - // If the result mask is equal to the src shuffle or this - // shuffle mask, do the replacement. - if (NewMask == LHSMask || NewMask == Mask) { - unsigned LHSInNElts = - cast(LHSSVI->getOperand(0)->getType())-> - getNumElements(); - std::vector Elts; - for (unsigned i = 0, e = NewMask.size(); i != e; ++i) { - if (NewMask[i] >= LHSInNElts*2) { - Elts.push_back(UndefValue::get( - Type::getInt32Ty(SVI.getContext()))); - } else { - Elts.push_back(ConstantInt::get( - Type::getInt32Ty(SVI.getContext()), - NewMask[i])); - } - } - return new ShuffleVectorInst(LHSSVI->getOperand(0), - LHSSVI->getOperand(1), - ConstantVector::get(Elts)); - } + // Check for a handful of important shuffle(shuffle()) combinations. + ShuffleVectorInst *LSVI = dyn_cast(LHS); + if (!LSVI) + return MadeChange ? &SVI : 0; + + LHS = LSVI->getOperand(0); + std::vector LHSMask = getShuffleMask(LSVI); + unsigned LHSInNElts = cast(LHS->getType())->getNumElements(); + + // If the LHS is an identity shuffle, or if SVI + LHS form a full unpack + // operation, merge the LHS and SVI shuffles. This allows llvm to emit + // efficient code for matrix transposes written with generic vector ops. + bool isLHSLoExtract = true, isLHSHiExtract = true; + bool isUnpackLo = isPowerOf2_32(VWidth); + bool isUnpackHi = isPowerOf2_32(VWidth); + for (unsigned i = 0, e = LHSMask.size(); i != e; ++i) { + if (LHSMask[i] >= LHSInNElts*2) continue; // Ignore undef values; + isLHSLoExtract &= (LHSMask[i] == i); + isLHSHiExtract &= (LHSMask[i] == i+(LHSInNElts/2)); + isUnpackLo &= (LHSMask[i] == (i/2)); + isUnpackHi &= (LHSMask[i] == (i/2) + (e/2)); + } + for (unsigned i = 0, e = Mask.size(); i != e && (isUnpackLo || isUnpackHi); + i += 2) { + isUnpackLo &= (Mask[i] == i) && (Mask[i+1] == (i/2)+e); + isUnpackHi &= (Mask[i] == i) && (Mask[i+1] == (i/2)+e+(e/2)); + } + if ((isLHSLoExtract || isLHSHiExtract || isUnpackLo || isUnpackHi) && + (isa(RHS) || (LHSWidth == LHSInNElts))) { + std::vector Elts; + for (unsigned i = 0, e = VWidth; i != e; ++i) { + if (Mask[i] >= 2*LHSWidth) + Elts.push_back(UndefValue::get(Type::getInt32Ty(SVI.getContext()))); + else if (Mask[i] >= e) + Elts.push_back(ConstantInt::get(Type::getInt32Ty(SVI.getContext()), + Mask[i])); + else + Elts.push_back(ConstantInt::get(Type::getInt32Ty(SVI.getContext()), + LHSMask[Mask[i]])); + } + if (isa(RHS)) + RHS = UndefValue::get(LHS->getType()); + return new ShuffleVectorInst(LHS, RHS, ConstantVector::get(Elts)); + } + + // If rhs is shuffle + identity, propagate. + if (ShuffleVectorInst *RSVI = dyn_cast(RHS)) { + std::vector RHSMask = getShuffleMask(RSVI); + unsigned RHSInNElts = + cast(RSVI->getOperand(0)->getType())->getNumElements(); + + // If rhs is identity, propagate + bool isRHSLoExtract = true, isRHSHiExtract = true; + for (unsigned i = 0, e = RHSMask.size(); i != e; ++i) { + if (RHSMask[i] >= RHSInNElts*2) continue; // Ignore undef values; + isRHSLoExtract &= (RHSMask[i] == i); + isRHSHiExtract &= (RHSMask[i] == i+(RHSInNElts/2)); + } + if ((isRHSLoExtract || isRHSHiExtract) && (LHSWidth == RHSInNElts)) { + std::vector Elts; + for (unsigned i = 0, e = VWidth; i != e; ++i) { + if (Mask[i] >= 2*LHSWidth) + Elts.push_back(UndefValue::get(Type::getInt32Ty(SVI.getContext()))); + else if (Mask[i] < LHSWidth) + Elts.push_back(ConstantInt::get(Type::getInt32Ty(SVI.getContext()), + Mask[i])); + else + Elts.push_back(ConstantInt::get(Type::getInt32Ty(SVI.getContext()), + RHSMask[Mask[i]-LHSWidth]+LHSWidth)); } + SVI.setOperand(1, RSVI->getOperand(0)); + SVI.setOperand(2, ConstantVector::get(Elts)); + return &SVI; } } + // Be extremely conservative when merging shufflevector instructions. It is + // difficult for the code generator to recognize a merged shuffle, which + // usually leads to worse code from merging a shuffle. + if (!isa(RHS)) + return MadeChange ? &SVI : 0; + + // If the merged shuffle mask is one of the two input shuffle masks, which + // just removes one instruction. This should handle splat(splat) -> splat. + if (LHSMask.size() == Mask.size()) { + std::vector NewMask; + for (unsigned i = 0, e = Mask.size(); i != e; ++i) + if (Mask[i] >= e) + NewMask.push_back(2*e); + else + NewMask.push_back(LHSMask[Mask[i]]); + + // If the result mask is equal to the src shuffle or this shuffle mask, + // do the replacement. + if (NewMask == LHSMask || NewMask == Mask) { + std::vector Elts; + for (unsigned i = 0, e = NewMask.size(); i != e; ++i) { + if (NewMask[i] >= LHSInNElts*2) { + Elts.push_back(UndefValue::get(Type::getInt32Ty(SVI.getContext()))); + } else { + Elts.push_back(ConstantInt::get(Type::getInt32Ty(SVI.getContext()), + NewMask[i])); + } + } + return new ShuffleVectorInst(LHS, LSVI->getOperand(1), + ConstantVector::get(Elts)); + } + } return MadeChange ? &SVI : 0; } - Modified: llvm/trunk/test/Transforms/InstCombine/vec_shuffle.ll URL: http://llvm.org/viewvc/llvm-project/llvm/trunk/test/Transforms/InstCombine/vec_shuffle.ll?rev=110987&r1=110986&r2=110987&view=diff ============================================================================== --- llvm/trunk/test/Transforms/InstCombine/vec_shuffle.ll (original) +++ llvm/trunk/test/Transforms/InstCombine/vec_shuffle.ll Thu Aug 12 19:17:53 2010 @@ -87,3 +87,32 @@ %tmp9 = shufflevector <4 x i8> %tmp7, <4 x i8> undef, <4 x i32> < i32 3, i32 1, i32 2, i32 0 > ; <<4 x i8>> [#uses=1] ret <4 x i8> %tmp9 } + +; Test fold of hi/lo vector halves +; Test fold of unpack operation +define void @test10(<16 x i8>* %out, <16 x i8> %r, <16 x i8> %g, <16 x i8> %b, <16 x i8> %a) nounwind ssp { +; CHECK: @test10 +; CHECK-NEXT: shufflevector +; CHECK-NEXT: shufflevector +; CHECK-NEXT: store +; CHECK-NEXT: getelementptr +; CHECK-NEXT: store +; CHECK-NEXT: ret + %tmp1 = shufflevector <16 x i8> %r, <16 x i8> undef, <8 x i32> ; <<8 x i8>> [#uses=1] + %tmp3 = shufflevector <8 x i8> %tmp1, <8 x i8> undef, <16 x i32> ; <<16 x i8>> [#uses=1] + %tmp4 = shufflevector <16 x i8> undef, <16 x i8> %tmp3, <16 x i32> ; <<16 x i8>> [#uses=1] + %tmp6 = shufflevector <16 x i8> %b, <16 x i8> undef, <8 x i32> ; <<8 x i8>> [#uses=1] + %tmp8 = shufflevector <8 x i8> %tmp6, <8 x i8> undef, <16 x i32> ; <<16 x i8>> [#uses=1] + %tmp9 = shufflevector <16 x i8> %tmp4, <16 x i8> %tmp8, <16 x i32> ; <<16 x i8>> [#uses=1] + %tmp11 = shufflevector <16 x i8> %r, <16 x i8> undef, <8 x i32> ; <<8 x i8>> [#uses=1] + %tmp13 = shufflevector <8 x i8> %tmp11, <8 x i8> undef, <16 x i32> ; <<16 x i8>> [#uses=1] + %tmp14 = shufflevector <16 x i8> undef, <16 x i8> %tmp13, <16 x i32> ; <<16 x i8>> [#uses=1] + %tmp16 = shufflevector <16 x i8> %b, <16 x i8> undef, <8 x i32> ; <<8 x i8>> [#uses=1] + %tmp18 = shufflevector <8 x i8> %tmp16, <8 x i8> undef, <16 x i32> ; <<16 x i8>> [#uses=1] + %tmp19 = shufflevector <16 x i8> %tmp14, <16 x i8> %tmp18, <16 x i32> ; <<16 x i8>> [#uses=1] + %arrayidx = getelementptr inbounds <16 x i8>* %out, i64 0 ; <<16 x i8>*> [#uses=1] + store <16 x i8> %tmp9, <16 x i8>* %arrayidx + %arrayidx24 = getelementptr inbounds <16 x i8>* %out, i64 1 ; <<16 x i8>*> [#uses=1] + store <16 x i8> %tmp19, <16 x i8>* %arrayidx24 + ret void +} From benny.kra at googlemail.com Thu Aug 12 19:29:44 2010 From: benny.kra at googlemail.com (Benjamin Kramer) Date: Fri, 13 Aug 2010 00:29:44 -0000 Subject: [llvm-commits] [llvm] r110991 - /llvm/trunk/include/llvm/ADT/APInt.h Message-ID: <20100813002944.C16472A6C12C@llvm.org> Author: d0k Date: Thu Aug 12 19:29:44 2010 New Revision: 110991 URL: http://llvm.org/viewvc/llvm-project?rev=110991&view=rev Log: Use getAllOnesValue, saves a copy and looks better. Modified: llvm/trunk/include/llvm/ADT/APInt.h Modified: llvm/trunk/include/llvm/ADT/APInt.h URL: http://llvm.org/viewvc/llvm-project/llvm/trunk/include/llvm/ADT/APInt.h?rev=110991&r1=110990&r2=110991&view=diff ============================================================================== --- llvm/trunk/include/llvm/ADT/APInt.h (original) +++ llvm/trunk/include/llvm/ADT/APInt.h Thu Aug 12 19:29:44 2010 @@ -464,7 +464,7 @@ // For small values, return quickly if (numBits <= APINT_BITS_PER_WORD) return APInt(numBits, ~0ULL << shiftAmt); - return (~APInt(numBits, 0)).shl(shiftAmt); + return getAllOnesValue(numBits).shl(shiftAmt); } /// Constructs an APInt value that has the bottom loBitsSet bits set. @@ -481,7 +481,7 @@ // For small values, return quickly. if (numBits < APINT_BITS_PER_WORD) return APInt(numBits, (1ULL << loBitsSet) - 1); - return (~APInt(numBits, 0)).lshr(numBits - loBitsSet); + return getAllOnesValue(numBits).lshr(numBits - loBitsSet); } /// The hash value is computed as the sum of the words and the bit width. From stoklund at 2pi.dk Thu Aug 12 20:05:23 2010 From: stoklund at 2pi.dk (Jakob Stoklund Olesen) Date: Fri, 13 Aug 2010 01:05:23 -0000 Subject: [llvm-commits] [llvm] r110994 - /llvm/trunk/lib/CodeGen/SplitKit.cpp Message-ID: <20100813010523.8EC092A6C12C@llvm.org> Author: stoklund Date: Thu Aug 12 20:05:23 2010 New Revision: 110994 URL: http://llvm.org/viewvc/llvm-project?rev=110994&view=rev Log: Remember to actually update SplitAnalysis statistics now that we have a fancy function to do it. Modified: llvm/trunk/lib/CodeGen/SplitKit.cpp Modified: llvm/trunk/lib/CodeGen/SplitKit.cpp URL: http://llvm.org/viewvc/llvm-project/llvm/trunk/lib/CodeGen/SplitKit.cpp?rev=110994&r1=110993&r2=110994&view=diff ============================================================================== --- llvm/trunk/lib/CodeGen/SplitKit.cpp (original) +++ llvm/trunk/lib/CodeGen/SplitKit.cpp Thu Aug 12 20:05:23 2010 @@ -668,6 +668,7 @@ } if (LI) { MO.setReg(LI->reg); + sa_.removeUse(MI); DEBUG(dbgs() << " rewrite " << Idx << '\t' << *MI); } } From stoklund at 2pi.dk Thu Aug 12 20:05:26 2010 From: stoklund at 2pi.dk (Jakob Stoklund Olesen) Date: Fri, 13 Aug 2010 01:05:26 -0000 Subject: [llvm-commits] [llvm] r110995 - /llvm/trunk/lib/CodeGen/SplitKit.cpp Message-ID: <20100813010526.3D2B42A6C12D@llvm.org> Author: stoklund Date: Thu Aug 12 20:05:26 2010 New Revision: 110995 URL: http://llvm.org/viewvc/llvm-project?rev=110995&view=rev Log: Let LiveInterval::addRange extend existing ranges, it will verify that value numbers match. The old check could accidentally leave holes in openli. Also let useIntv add all ranges for the phi-def value inserted by enterIntvAtEnd. This works as long at the value mapping is established in enterIntvAtEnd. Modified: llvm/trunk/lib/CodeGen/SplitKit.cpp Modified: llvm/trunk/lib/CodeGen/SplitKit.cpp URL: http://llvm.org/viewvc/llvm-project/llvm/trunk/lib/CodeGen/SplitKit.cpp?rev=110995&r1=110994&r2=110995&view=diff ============================================================================== --- llvm/trunk/lib/CodeGen/SplitKit.cpp (original) +++ llvm/trunk/lib/CodeGen/SplitKit.cpp Thu Aug 12 20:05:26 2010 @@ -465,9 +465,6 @@ VNIB = openli_->getNextValue(SlotIndex(StartB, true), 0, false, lis_.getVNInfoAllocator()); VNIB->setIsPHIDef(true); - // Add a minimal range for the new value. - openli_->addRange(LiveRange(VNIB->def, std::min(EndB, CurB->end), VNIB)); - VNInfo *&mapVNI = valueMap_[CurB->valno]; if (mapVNI) { // Multiple copies - must create PHI value. @@ -496,8 +493,8 @@ if (I != B) { --I; - // I begins before Start, but overlaps. openli may already have a value. - if (I->end > Start && !openli_->liveAt(Start)) + // I begins before Start, but overlaps. + if (I->end > Start) openli_->addRange(LiveRange(Start, std::min(End, I->end), mapValue(I->valno))); ++I; From dirty at apple.com Thu Aug 12 20:19:31 2010 From: dirty at apple.com (Cameron Esfahani) Date: Thu, 12 Aug 2010 18:19:31 -0700 Subject: [llvm-commits] Win64 pseudo instruction patch Message-ID: <00C68A18-199E-429D-A0A5-2BBDCC219A03@apple.com> Attached is a patch which fixes some more of the Win64 ABI code gen. Added support for the Windows 64 pseudo instructions like WINTAILJMPd64 and WINCALL64pcrel32. Also, updated a little bit of the coff-dump.py tool to dump the AMD64 relocations. Updated COFF.h to list the AMD64 relocations. Still a bit more to do before Win64 COFFs work... -------------- next part -------------- A non-text attachment was scrubbed... Name: pseudo.patch Type: application/octet-stream Size: 18157 bytes Desc: not available Url : http://lists.cs.uiuc.edu/pipermail/llvm-commits/attachments/20100812/36c975e8/attachment.obj -------------- next part -------------- Cameron Esfahani dirty at apple.com "It is the spirit and not the form of law that keeps justice alive." Earl Warren From dirty at apple.com Thu Aug 12 20:21:48 2010 From: dirty at apple.com (Cameron Esfahani) Date: Thu, 12 Aug 2010 18:21:48 -0700 Subject: [llvm-commits] Win64 pseudo instruction patch In-Reply-To: <00C68A18-199E-429D-A0A5-2BBDCC219A03@apple.com> References: <00C68A18-199E-429D-A0A5-2BBDCC219A03@apple.com> Message-ID: <65130661-7848-4A1E-AABE-10A450BFED22@apple.com> Ugh, ignore this. I just realized that I didn't base my patch on the latest svn... Let me regenerate my patch. On Aug 12, 2010, at 6:19 PM, Cameron Esfahani wrote: > Attached is a patch which fixes some more of the Win64 ABI code gen. Added support for the Windows 64 pseudo instructions like WINTAILJMPd64 and WINCALL64pcrel32. > > Also, updated a little bit of the coff-dump.py tool to dump the AMD64 relocations. Updated COFF.h to list the AMD64 relocations. > > Still a bit more to do before Win64 COFFs work... > > > > Cameron Esfahani > dirty at apple.com > > "It is the spirit and not the form of law that keeps justice alive." > > Earl Warren > > > > _______________________________________________ > llvm-commits mailing list > llvm-commits at cs.uiuc.edu > http://lists.cs.uiuc.edu/mailman/listinfo/llvm-commits Cameron Esfahani dirty at apple.com Imagine how pissed Zander would have been if Jobs pulled the Nano out of his pocket and it started RINGING...and it was Paris Hilton, and she was all like "where you at, bitch?" and Steve was all like "totally rocking a keynote, girlfriend," and then the pirates flew in on their burning sharks and totally wailed. And then he pulled back the curtain to reveal a Beowulf cluster of Nanophones. That's what I'm talking about. From dirty at apple.com Thu Aug 12 20:47:34 2010 From: dirty at apple.com (Cameron Esfahani) Date: Thu, 12 Aug 2010 18:47:34 -0700 Subject: [llvm-commits] Win64 pseudo instruction patch In-Reply-To: <65130661-7848-4A1E-AABE-10A450BFED22@apple.com> References: <00C68A18-199E-429D-A0A5-2BBDCC219A03@apple.com> <65130661-7848-4A1E-AABE-10A450BFED22@apple.com> Message-ID: New patch, based on SVN revision 110995: -------------- next part -------------- A non-text attachment was scrubbed... Name: pseudo.patch Type: application/octet-stream Size: 18157 bytes Desc: not available Url : http://lists.cs.uiuc.edu/pipermail/llvm-commits/attachments/20100812/c83b952c/attachment.obj -------------- next part -------------- On Aug 12, 2010, at 6:21 PM, Cameron Esfahani wrote: > Ugh, ignore this. I just realized that I didn't base my patch on the latest svn... > > Let me regenerate my patch. > > On Aug 12, 2010, at 6:19 PM, Cameron Esfahani wrote: > >> Attached is a patch which fixes some more of the Win64 ABI code gen. Added support for the Windows 64 pseudo instructions like WINTAILJMPd64 and WINCALL64pcrel32. >> >> Also, updated a little bit of the coff-dump.py tool to dump the AMD64 relocations. Updated COFF.h to list the AMD64 relocations. >> >> Still a bit more to do before Win64 COFFs work... >> >> >> >> Cameron Esfahani >> dirty at apple.com >> >> "It is the spirit and not the form of law that keeps justice alive." >> >> Earl Warren >> >> >> >> _______________________________________________ >> llvm-commits mailing list >> llvm-commits at cs.uiuc.edu >> http://lists.cs.uiuc.edu/mailman/listinfo/llvm-commits > > Cameron Esfahani > dirty at apple.com > > Imagine how pissed Zander would have been if Jobs pulled the Nano out of his pocket and it started RINGING...and it was Paris Hilton, and she was all like "where you at, bitch?" and Steve was all like "totally rocking a keynote, girlfriend," and then the pirates flew in on their burning sharks and totally wailed. > > And then he pulled back the curtain to reveal a Beowulf cluster of Nanophones. > > That's what I'm talking about. > > > > > _______________________________________________ > llvm-commits mailing list > llvm-commits at cs.uiuc.edu > http://lists.cs.uiuc.edu/mailman/listinfo/llvm-commits Cameron Esfahani dirty at apple.com "It is the spirit and not the form of law that keeps justice alive." Earl Warren From foldr at codedgers.com Thu Aug 12 21:29:24 2010 From: foldr at codedgers.com (Mikhail Glushenkov) Date: Fri, 13 Aug 2010 02:29:24 -0000 Subject: [llvm-commits] [llvm] r110998 - in /llvm/trunk: test/LLVMC/MultiplePluginPriorities.td test/LLVMC/OutputSuffixHook.td utils/TableGen/LLVMCConfigurationEmitter.cpp Message-ID: <20100813022924.76ABC2A6C12C@llvm.org> Author: foldr Date: Thu Aug 12 21:29:24 2010 New Revision: 110998 URL: http://llvm.org/viewvc/llvm-project?rev=110998&view=rev Log: llvmc: fix two tests, remove XFAILs. Tested on Linux and Darwin; please add platform-specific XFAILs/mail me a bug report if this still fails. Modified: llvm/trunk/test/LLVMC/MultiplePluginPriorities.td llvm/trunk/test/LLVMC/OutputSuffixHook.td llvm/trunk/utils/TableGen/LLVMCConfigurationEmitter.cpp Modified: llvm/trunk/test/LLVMC/MultiplePluginPriorities.td URL: http://llvm.org/viewvc/llvm-project/llvm/trunk/test/LLVMC/MultiplePluginPriorities.td?rev=110998&r1=110997&r2=110998&view=diff ============================================================================== --- llvm/trunk/test/LLVMC/MultiplePluginPriorities.td (original) +++ llvm/trunk/test/LLVMC/MultiplePluginPriorities.td Thu Aug 12 21:29:24 2010 @@ -4,10 +4,6 @@ // Disable for Darwin PPC: // XFAIL: powerpc-apple-darwin -// Generally XFAIL'ed for now, this is (sometimes?) failing on x86_64-apple-darwin10. -// RUN: false -// XFAIL: * - include "llvm/CompilerDriver/Common.td" def Graph : CompilationGraph<[]>; Modified: llvm/trunk/test/LLVMC/OutputSuffixHook.td URL: http://llvm.org/viewvc/llvm-project/llvm/trunk/test/LLVMC/OutputSuffixHook.td?rev=110998&r1=110997&r2=110998&view=diff ============================================================================== --- llvm/trunk/test/LLVMC/OutputSuffixHook.td (original) +++ llvm/trunk/test/LLVMC/OutputSuffixHook.td Thu Aug 12 21:29:24 2010 @@ -2,7 +2,6 @@ // RUN: tblgen -I %p/../../include --gen-llvmc %s -o %t // RUN: FileCheck -input-file %t %s // RUN: %compile_cxx -fexceptions -x c++ %t -// XFAIL: * include "llvm/CompilerDriver/Common.td" @@ -13,7 +12,7 @@ ]>; def dummy_tool : Tool<[ -(cmd_line "dummy_cmd $INFILE"), +(command "dummy_cmd"), (in_language "dummy_lang"), (out_language "dummy_lang"), (actions (case Modified: llvm/trunk/utils/TableGen/LLVMCConfigurationEmitter.cpp URL: http://llvm.org/viewvc/llvm-project/llvm/trunk/utils/TableGen/LLVMCConfigurationEmitter.cpp?rev=110998&r1=110997&r2=110998&view=diff ============================================================================== --- llvm/trunk/utils/TableGen/LLVMCConfigurationEmitter.cpp (original) +++ llvm/trunk/utils/TableGen/LLVMCConfigurationEmitter.cpp Thu Aug 12 21:29:24 2010 @@ -2177,8 +2177,8 @@ << "std::vector > vec;\n"; O.indent(Indent2) << "bool stop_compilation = !HasChildren;\n"; O.indent(Indent2) << "bool no_out_file = false;\n"; - O.indent(Indent2) << "const char* output_suffix = \"" - << D.OutputSuffix << "\";\n"; + O.indent(Indent2) << "std::string output_suffix(\"" + << D.OutputSuffix << "\");\n"; } } @@ -2235,7 +2235,8 @@ O.indent(Indent3) << "out_file = this->OutFilename(" << (IsJoin ? "sys::Path(),\n" : "inFile,\n"); - O.indent(Indent4) << "TempDir, stop_compilation, output_suffix).str();\n\n"; + O.indent(Indent4) << + "TempDir, stop_compilation, output_suffix.c_str()).str();\n\n"; O.indent(Indent3) << "vec.push_back(std::make_pair(65536, out_file));\n"; O.indent(Indent2) << "}\n\n"; From foldr at codedgers.com Thu Aug 12 21:29:35 2010 From: foldr at codedgers.com (Mikhail Glushenkov) Date: Fri, 13 Aug 2010 02:29:35 -0000 Subject: [llvm-commits] [llvm] r110999 - in /llvm/trunk/test/LLVMC: AppendCmdHook.td EmptyCompilationGraph.td EnvParentheses.td ExternOptions.td ForwardAs.td ForwardTransformedValue.td ForwardValue.td HookWithArguments.td HookWithInFile.td Init.td MultiValuedOption.td MultipleCompilationGraphs.td NoActions.td NoCompilationGraph.td OneOrMore.td OptionPreprocessor.td OutputSuffixHook.td Message-ID: <20100813022935.E18172A6C12C@llvm.org> Author: foldr Date: Thu Aug 12 21:29:35 2010 New Revision: 110999 URL: http://llvm.org/viewvc/llvm-project?rev=110999&view=rev Log: Remove -fexceptions from llvmc tests. Modified: llvm/trunk/test/LLVMC/AppendCmdHook.td llvm/trunk/test/LLVMC/EmptyCompilationGraph.td llvm/trunk/test/LLVMC/EnvParentheses.td llvm/trunk/test/LLVMC/ExternOptions.td llvm/trunk/test/LLVMC/ForwardAs.td llvm/trunk/test/LLVMC/ForwardTransformedValue.td llvm/trunk/test/LLVMC/ForwardValue.td llvm/trunk/test/LLVMC/HookWithArguments.td llvm/trunk/test/LLVMC/HookWithInFile.td llvm/trunk/test/LLVMC/Init.td llvm/trunk/test/LLVMC/MultiValuedOption.td llvm/trunk/test/LLVMC/MultipleCompilationGraphs.td llvm/trunk/test/LLVMC/NoActions.td llvm/trunk/test/LLVMC/NoCompilationGraph.td llvm/trunk/test/LLVMC/OneOrMore.td llvm/trunk/test/LLVMC/OptionPreprocessor.td llvm/trunk/test/LLVMC/OutputSuffixHook.td Modified: llvm/trunk/test/LLVMC/AppendCmdHook.td URL: http://llvm.org/viewvc/llvm-project/llvm/trunk/test/LLVMC/AppendCmdHook.td?rev=110999&r1=110998&r2=110999&view=diff ============================================================================== --- llvm/trunk/test/LLVMC/AppendCmdHook.td (original) +++ llvm/trunk/test/LLVMC/AppendCmdHook.td Thu Aug 12 21:29:35 2010 @@ -1,7 +1,7 @@ // Check that hooks can be invoked from 'append_cmd'. // RUN: tblgen -I %p/../../include --gen-llvmc %s -o %t // RUN: FileCheck -input-file %t %s -// RUN: %compile_cxx -fexceptions -x c++ %t +// RUN: %compile_cxx -x c++ %t // XFAIL: vg_leak include "llvm/CompilerDriver/Common.td" Modified: llvm/trunk/test/LLVMC/EmptyCompilationGraph.td URL: http://llvm.org/viewvc/llvm-project/llvm/trunk/test/LLVMC/EmptyCompilationGraph.td?rev=110999&r1=110998&r2=110999&view=diff ============================================================================== --- llvm/trunk/test/LLVMC/EmptyCompilationGraph.td (original) +++ llvm/trunk/test/LLVMC/EmptyCompilationGraph.td Thu Aug 12 21:29:35 2010 @@ -1,6 +1,6 @@ // Check that the compilation graph can be empty. // RUN: tblgen -I %p/../../include --gen-llvmc %s -o %t -// RUN: %compile_cxx -fexceptions -x c++ %t +// RUN: %compile_cxx -x c++ %t // XFAIL: vg_leak include "llvm/CompilerDriver/Common.td" Modified: llvm/trunk/test/LLVMC/EnvParentheses.td URL: http://llvm.org/viewvc/llvm-project/llvm/trunk/test/LLVMC/EnvParentheses.td?rev=110999&r1=110998&r2=110999&view=diff ============================================================================== --- llvm/trunk/test/LLVMC/EnvParentheses.td (original) +++ llvm/trunk/test/LLVMC/EnvParentheses.td Thu Aug 12 21:29:35 2010 @@ -2,7 +2,7 @@ // http://llvm.org/bugs/show_bug.cgi?id=4157 // RUN: tblgen -I %p/../../include --gen-llvmc %s -o %t // RUN: not grep {FOO")));} %t -// RUN: %compile_cxx -fexceptions -x c++ %t +// RUN: %compile_cxx -x c++ %t // XFAIL: vg_leak include "llvm/CompilerDriver/Common.td" Modified: llvm/trunk/test/LLVMC/ExternOptions.td URL: http://llvm.org/viewvc/llvm-project/llvm/trunk/test/LLVMC/ExternOptions.td?rev=110999&r1=110998&r2=110999&view=diff ============================================================================== --- llvm/trunk/test/LLVMC/ExternOptions.td (original) +++ llvm/trunk/test/LLVMC/ExternOptions.td Thu Aug 12 21:29:35 2010 @@ -2,7 +2,7 @@ // The dummy tool and graph are required to silence warnings. // RUN: tblgen -I %p/../../include --gen-llvmc %s -o %t // RUN: FileCheck -input-file %t %s -// RUN: %compile_cxx -fexceptions -x c++ %t +// RUN: %compile_cxx -x c++ %t // XFAIL: vg_leak include "llvm/CompilerDriver/Common.td" Modified: llvm/trunk/test/LLVMC/ForwardAs.td URL: http://llvm.org/viewvc/llvm-project/llvm/trunk/test/LLVMC/ForwardAs.td?rev=110999&r1=110998&r2=110999&view=diff ============================================================================== --- llvm/trunk/test/LLVMC/ForwardAs.td (original) +++ llvm/trunk/test/LLVMC/ForwardAs.td Thu Aug 12 21:29:35 2010 @@ -2,7 +2,7 @@ // http://llvm.org/bugs/show_bug.cgi?id=4159 // RUN: tblgen -I %p/../../include --gen-llvmc %s -o %t // RUN: FileCheck -input-file %t %s -// RUN: %compile_cxx -fexceptions -x c++ %t +// RUN: %compile_cxx -x c++ %t // XFAIL: vg_leak include "llvm/CompilerDriver/Common.td" Modified: llvm/trunk/test/LLVMC/ForwardTransformedValue.td URL: http://llvm.org/viewvc/llvm-project/llvm/trunk/test/LLVMC/ForwardTransformedValue.td?rev=110999&r1=110998&r2=110999&view=diff ============================================================================== --- llvm/trunk/test/LLVMC/ForwardTransformedValue.td (original) +++ llvm/trunk/test/LLVMC/ForwardTransformedValue.td Thu Aug 12 21:29:35 2010 @@ -2,7 +2,7 @@ // The dummy tool and graph are required to silence warnings. // RUN: tblgen -I %p/../../include --gen-llvmc %s -o %t // RUN: FileCheck -input-file %t %s -// RUN: %compile_cxx -fexceptions -x c++ %t +// RUN: %compile_cxx -x c++ %t // XFAIL: vg_leak include "llvm/CompilerDriver/Common.td" Modified: llvm/trunk/test/LLVMC/ForwardValue.td URL: http://llvm.org/viewvc/llvm-project/llvm/trunk/test/LLVMC/ForwardValue.td?rev=110999&r1=110998&r2=110999&view=diff ============================================================================== --- llvm/trunk/test/LLVMC/ForwardValue.td (original) +++ llvm/trunk/test/LLVMC/ForwardValue.td Thu Aug 12 21:29:35 2010 @@ -2,7 +2,7 @@ // The dummy tool and graph are required to silence warnings. // RUN: tblgen -I %p/../../include --gen-llvmc %s -o %t // RUN: FileCheck -input-file %t %s -// RUN: %compile_cxx -fexceptions -x c++ %t +// RUN: %compile_cxx -x c++ %t // XFAIL: vg_leak include "llvm/CompilerDriver/Common.td" Modified: llvm/trunk/test/LLVMC/HookWithArguments.td URL: http://llvm.org/viewvc/llvm-project/llvm/trunk/test/LLVMC/HookWithArguments.td?rev=110999&r1=110998&r2=110999&view=diff ============================================================================== --- llvm/trunk/test/LLVMC/HookWithArguments.td (original) +++ llvm/trunk/test/LLVMC/HookWithArguments.td Thu Aug 12 21:29:35 2010 @@ -1,7 +1,7 @@ // Check that hooks with arguments work. // RUN: tblgen -I %p/../../include --gen-llvmc %s -o %t // RUN: FileCheck -input-file %t %s -// RUN: %compile_cxx -fexceptions -x c++ %t +// RUN: %compile_cxx -x c++ %t // XFAIL: vg_leak include "llvm/CompilerDriver/Common.td" Modified: llvm/trunk/test/LLVMC/HookWithInFile.td URL: http://llvm.org/viewvc/llvm-project/llvm/trunk/test/LLVMC/HookWithInFile.td?rev=110999&r1=110998&r2=110999&view=diff ============================================================================== --- llvm/trunk/test/LLVMC/HookWithInFile.td (original) +++ llvm/trunk/test/LLVMC/HookWithInFile.td Thu Aug 12 21:29:35 2010 @@ -1,7 +1,7 @@ // Check that a hook can be given $INFILE as an argument. // RUN: tblgen -I %p/../../include --gen-llvmc %s -o %t // RUN: FileCheck -input-file %t %s -// RUN: %compile_cxx -fexceptions -x c++ %t +// RUN: %compile_cxx -x c++ %t // XFAIL: vg_leak include "llvm/CompilerDriver/Common.td" Modified: llvm/trunk/test/LLVMC/Init.td URL: http://llvm.org/viewvc/llvm-project/llvm/trunk/test/LLVMC/Init.td?rev=110999&r1=110998&r2=110999&view=diff ============================================================================== --- llvm/trunk/test/LLVMC/Init.td (original) +++ llvm/trunk/test/LLVMC/Init.td Thu Aug 12 21:29:35 2010 @@ -1,7 +1,7 @@ // Check that (init true/false) and (init "str") work. // RUN: tblgen -I %p/../../include --gen-llvmc %s -o %t // RUN: FileCheck -input-file %t %s -// RUN: %compile_cxx -fexceptions -x c++ %t +// RUN: %compile_cxx -x c++ %t // XFAIL: vg_leak include "llvm/CompilerDriver/Common.td" Modified: llvm/trunk/test/LLVMC/MultiValuedOption.td URL: http://llvm.org/viewvc/llvm-project/llvm/trunk/test/LLVMC/MultiValuedOption.td?rev=110999&r1=110998&r2=110999&view=diff ============================================================================== --- llvm/trunk/test/LLVMC/MultiValuedOption.td (original) +++ llvm/trunk/test/LLVMC/MultiValuedOption.td Thu Aug 12 21:29:35 2010 @@ -2,7 +2,7 @@ // The dummy tool and graph are required to silence warnings. // RUN: tblgen -I %p/../../include --gen-llvmc %s -o %t // RUN: FileCheck -input-file %t %s -// RUN: %compile_cxx -fexceptions -x c++ %t +// RUN: %compile_cxx -x c++ %t // XFAIL: vg_leak include "llvm/CompilerDriver/Common.td" Modified: llvm/trunk/test/LLVMC/MultipleCompilationGraphs.td URL: http://llvm.org/viewvc/llvm-project/llvm/trunk/test/LLVMC/MultipleCompilationGraphs.td?rev=110999&r1=110998&r2=110999&view=diff ============================================================================== --- llvm/trunk/test/LLVMC/MultipleCompilationGraphs.td (original) +++ llvm/trunk/test/LLVMC/MultipleCompilationGraphs.td Thu Aug 12 21:29:35 2010 @@ -1,6 +1,6 @@ // Check that multiple compilation graphs are allowed. // RUN: tblgen -I %p/../../include --gen-llvmc %s -o %t -// RUN: %compile_cxx -fexceptions -x c++ %t +// RUN: %compile_cxx -x c++ %t // XFAIL: vg_leak include "llvm/CompilerDriver/Common.td" Modified: llvm/trunk/test/LLVMC/NoActions.td URL: http://llvm.org/viewvc/llvm-project/llvm/trunk/test/LLVMC/NoActions.td?rev=110999&r1=110998&r2=110999&view=diff ============================================================================== --- llvm/trunk/test/LLVMC/NoActions.td (original) +++ llvm/trunk/test/LLVMC/NoActions.td Thu Aug 12 21:29:35 2010 @@ -1,7 +1,7 @@ // Check that tools without associated actions are accepted. // RUN: tblgen -I %p/../../include --gen-llvmc %s -o %t // RUN: FileCheck -input-file %t %s -// RUN: %compile_cxx -fexceptions -x c++ %t +// RUN: %compile_cxx -x c++ %t // XFAIL: vg_leak include "llvm/CompilerDriver/Common.td" Modified: llvm/trunk/test/LLVMC/NoCompilationGraph.td URL: http://llvm.org/viewvc/llvm-project/llvm/trunk/test/LLVMC/NoCompilationGraph.td?rev=110999&r1=110998&r2=110999&view=diff ============================================================================== --- llvm/trunk/test/LLVMC/NoCompilationGraph.td (original) +++ llvm/trunk/test/LLVMC/NoCompilationGraph.td Thu Aug 12 21:29:35 2010 @@ -1,6 +1,6 @@ // Check that the compilation graph is not required. // RUN: tblgen -I %p/../../include --gen-llvmc %s -o %t -// RUN: %compile_cxx -fexceptions -x c++ %t +// RUN: %compile_cxx -x c++ %t // XFAIL: vg_leak include "llvm/CompilerDriver/Common.td" Modified: llvm/trunk/test/LLVMC/OneOrMore.td URL: http://llvm.org/viewvc/llvm-project/llvm/trunk/test/LLVMC/OneOrMore.td?rev=110999&r1=110998&r2=110999&view=diff ============================================================================== --- llvm/trunk/test/LLVMC/OneOrMore.td (original) +++ llvm/trunk/test/LLVMC/OneOrMore.td Thu Aug 12 21:29:35 2010 @@ -2,7 +2,7 @@ // The dummy tool and graph are required to silence warnings. // RUN: tblgen -I %p/../../include --gen-llvmc %s -o %t // RUN: FileCheck -input-file %t %s -// RUN: %compile_cxx -fexceptions -x c++ %t +// RUN: %compile_cxx -x c++ %t // XFAIL: vg_leak include "llvm/CompilerDriver/Common.td" Modified: llvm/trunk/test/LLVMC/OptionPreprocessor.td URL: http://llvm.org/viewvc/llvm-project/llvm/trunk/test/LLVMC/OptionPreprocessor.td?rev=110999&r1=110998&r2=110999&view=diff ============================================================================== --- llvm/trunk/test/LLVMC/OptionPreprocessor.td (original) +++ llvm/trunk/test/LLVMC/OptionPreprocessor.td Thu Aug 12 21:29:35 2010 @@ -1,7 +1,7 @@ // Test for the OptionPreprocessor and related functionality. // RUN: tblgen -I %p/../../include --gen-llvmc %s -o %t // RUN: FileCheck -input-file %t %s -// RUN: %compile_cxx -fexceptions -x c++ %t +// RUN: %compile_cxx -x c++ %t // XFAIL: vg_leak include "llvm/CompilerDriver/Common.td" Modified: llvm/trunk/test/LLVMC/OutputSuffixHook.td URL: http://llvm.org/viewvc/llvm-project/llvm/trunk/test/LLVMC/OutputSuffixHook.td?rev=110999&r1=110998&r2=110999&view=diff ============================================================================== --- llvm/trunk/test/LLVMC/OutputSuffixHook.td (original) +++ llvm/trunk/test/LLVMC/OutputSuffixHook.td Thu Aug 12 21:29:35 2010 @@ -1,7 +1,7 @@ // Check that hooks can be invoked from 'output_suffix'. // RUN: tblgen -I %p/../../include --gen-llvmc %s -o %t // RUN: FileCheck -input-file %t %s -// RUN: %compile_cxx -fexceptions -x c++ %t +// RUN: %compile_cxx -x c++ %t include "llvm/CompilerDriver/Common.td" From echristo at apple.com Thu Aug 12 21:30:00 2010 From: echristo at apple.com (Eric Christopher) Date: Fri, 13 Aug 2010 02:30:00 -0000 Subject: [llvm-commits] [llvm] r111000 - /llvm/trunk/lib/Target/X86/X86CodeEmitter.cpp Message-ID: <20100813023000.8BA722A6C12C@llvm.org> Author: echristo Date: Thu Aug 12 21:30:00 2010 New Revision: 111000 URL: http://llvm.org/viewvc/llvm-project?rev=111000&view=rev Log: Revert r110954 for now, pseudo instructions can't make it through to the JIT. Modified: llvm/trunk/lib/Target/X86/X86CodeEmitter.cpp Modified: llvm/trunk/lib/Target/X86/X86CodeEmitter.cpp URL: http://llvm.org/viewvc/llvm-project/llvm/trunk/lib/Target/X86/X86CodeEmitter.cpp?rev=111000&r1=110999&r2=111000&view=diff ============================================================================== --- llvm/trunk/lib/Target/X86/X86CodeEmitter.cpp (original) +++ llvm/trunk/lib/Target/X86/X86CodeEmitter.cpp Thu Aug 12 21:30:00 2010 @@ -702,6 +702,7 @@ // base address. switch (Opcode) { default: + MI.dump(); llvm_unreachable("psuedo instructions should be removed before code" " emission"); break; From echristo at apple.com Thu Aug 12 21:36:05 2010 From: echristo at apple.com (Eric Christopher) Date: Thu, 12 Aug 2010 19:36:05 -0700 Subject: [llvm-commits] [llvm] r111000 - /llvm/trunk/lib/Target/X86/X86CodeEmitter.cpp In-Reply-To: <20100813023000.8BA722A6C12C@llvm.org> References: <20100813023000.8BA722A6C12C@llvm.org> Message-ID: <5AD00F06-B5CB-4A9D-993D-DE3347D0E5D9@apple.com> On Aug 12, 2010, at 7:30 PM, Eric Christopher wrote: > Author: echristo > Date: Thu Aug 12 21:30:00 2010 > New Revision: 111000 > > URL: http://llvm.org/viewvc/llvm-project?rev=111000&view=rev > Log: > Revert r110954 for now, pseudo instructions can't make it through to the JIT. Uh, wrong commit. I'll fix that. -eric From echristo at apple.com Thu Aug 12 21:37:51 2010 From: echristo at apple.com (Eric Christopher) Date: Fri, 13 Aug 2010 02:37:51 -0000 Subject: [llvm-commits] [llvm] r111001 - in /llvm/trunk/lib/Target/X86: X86CodeEmitter.cpp X86InstrSSE.td Message-ID: <20100813023751.20E9C2A6C12C@llvm.org> Author: echristo Date: Thu Aug 12 21:37:50 2010 New Revision: 111001 URL: http://llvm.org/viewvc/llvm-project?rev=111001&view=rev Log: Revert last patch and r110954 as I meant to. Modified: llvm/trunk/lib/Target/X86/X86CodeEmitter.cpp llvm/trunk/lib/Target/X86/X86InstrSSE.td Modified: llvm/trunk/lib/Target/X86/X86CodeEmitter.cpp URL: http://llvm.org/viewvc/llvm-project/llvm/trunk/lib/Target/X86/X86CodeEmitter.cpp?rev=111001&r1=111000&r2=111001&view=diff ============================================================================== --- llvm/trunk/lib/Target/X86/X86CodeEmitter.cpp (original) +++ llvm/trunk/lib/Target/X86/X86CodeEmitter.cpp Thu Aug 12 21:37:50 2010 @@ -702,7 +702,6 @@ // base address. switch (Opcode) { default: - MI.dump(); llvm_unreachable("psuedo instructions should be removed before code" " emission"); break; Modified: llvm/trunk/lib/Target/X86/X86InstrSSE.td URL: http://llvm.org/viewvc/llvm-project/llvm/trunk/lib/Target/X86/X86InstrSSE.td?rev=111001&r1=111000&r2=111001&view=diff ============================================================================== --- llvm/trunk/lib/Target/X86/X86InstrSSE.td (original) +++ llvm/trunk/lib/Target/X86/X86InstrSSE.td Thu Aug 12 21:37:50 2010 @@ -2174,33 +2174,33 @@ // Alias instructions that map zero vector to pxor / xorp* for sse. // We set canFoldAsLoad because this can be converted to a constant-pool // load of an all-zeros value if folding it would be beneficial. +// FIXME: Change encoding to pseudo! let isReMaterializable = 1, isAsCheapAsAMove = 1, canFoldAsLoad = 1, isCodeGenOnly = 1 in { - let Predicates = [HasSSE1] in - def V_SET0PS : I<0, Pseudo, (outs VR128:$dst), (ins), "", - [(set VR128:$dst, (v4f32 immAllZerosV))]>; - let Predicates = [HasSSE2] in { - def V_SET0PD : I<0, Pseudo, (outs VR128:$dst), (ins), "", - [(set VR128:$dst, (v2f64 immAllZerosV))]>; - def V_SET0PI : I<0, Pseudo, (outs VR128:$dst), (ins), "", - [(set VR128:$dst, (v4i32 immAllZerosV))], SSEPackedInt>; - } +def V_SET0PS : PSI<0x57, MRMInitReg, (outs VR128:$dst), (ins), "", + [(set VR128:$dst, (v4f32 immAllZerosV))]>; +def V_SET0PD : PDI<0x57, MRMInitReg, (outs VR128:$dst), (ins), "", + [(set VR128:$dst, (v2f64 immAllZerosV))]>; +let ExeDomain = SSEPackedInt in +def V_SET0PI : PDI<0xEF, MRMInitReg, (outs VR128:$dst), (ins), "", + [(set VR128:$dst, (v4i32 immAllZerosV))]>; } // The same as done above but for AVX. The 128-bit versions are the // same, but re-encoded. The 256-bit does not support PI version. let isReMaterializable = 1, isAsCheapAsAMove = 1, canFoldAsLoad = 1, isCodeGenOnly = 1, Predicates = [HasAVX] in { -def AVX_SET0PS : I<0, Pseudo, (outs VR128:$dst), (ins), "", - [(set VR128:$dst, (v4f32 immAllZerosV))]>; -def AVX_SET0PD : I<0, Pseudo, (outs VR128:$dst), (ins), "", - [(set VR128:$dst, (v2f64 immAllZerosV))]>; -def AVX_SET0PI : I<0, Pseudo, (outs VR128:$dst), (ins), "", - [(set VR128:$dst, (v4i32 immAllZerosV))], SSEPackedInt>; -def AVX_SET0PSY : I<0, Pseudo, (outs VR256:$dst), (ins), "", - [(set VR256:$dst, (v8f32 immAllZerosV))]>; -def AVX_SET0PDY : I<0, Pseudo, (outs VR256:$dst), (ins), "", - [(set VR256:$dst, (v4f64 immAllZerosV))]>; +def AVX_SET0PS : PSI<0x57, MRMInitReg, (outs VR128:$dst), (ins), "", + [(set VR128:$dst, (v4f32 immAllZerosV))]>, VEX_4V; +def AVX_SET0PD : PDI<0x57, MRMInitReg, (outs VR128:$dst), (ins), "", + [(set VR128:$dst, (v2f64 immAllZerosV))]>, VEX_4V; +def AVX_SET0PSY : PSI<0x57, MRMInitReg, (outs VR256:$dst), (ins), "", + [(set VR256:$dst, (v8f32 immAllZerosV))]>, VEX_4V; +def AVX_SET0PDY : PDI<0x57, MRMInitReg, (outs VR256:$dst), (ins), "", + [(set VR256:$dst, (v4f64 immAllZerosV))]>, VEX_4V; +let ExeDomain = SSEPackedInt in +def AVX_SET0PI : PDI<0xEF, MRMInitReg, (outs VR128:$dst), (ins), "", + [(set VR128:$dst, (v4i32 immAllZerosV))]>; } def : Pat<(v2i64 immAllZerosV), (V_SET0PI)>; @@ -3249,13 +3249,14 @@ // was introduced with SSE2, it's backward compatible. def PAUSE : I<0x90, RawFrm, (outs), (ins), "pause", []>, REP; -// Alias instructions that map one vector to pcmpeqd for sse2 and above. +// Alias instructions that map zero vector to pxor / xorp* for sse. // We set canFoldAsLoad because this can be converted to a constant-pool // load of an all-ones value if folding it would be beneficial. let isReMaterializable = 1, isAsCheapAsAMove = 1, canFoldAsLoad = 1, - isCodeGenOnly = 1, Predicates = [HasSSE2] in - def V_SETALLONES : I<0, Pseudo, (outs VR128:$dst), (ins), "", - [(set VR128:$dst, (v4i32 immAllOnesV))], SSEPackedInt>; + isCodeGenOnly = 1, ExeDomain = SSEPackedInt in + // FIXME: Change encoding to pseudo. + def V_SETALLONES : PDI<0x76, MRMInitReg, (outs VR128:$dst), (ins), "", + [(set VR128:$dst, (v4i32 immAllOnesV))]>; //===---------------------------------------------------------------------===// // SSE3 - Conversion Instructions From foldr at codedgers.com Thu Aug 12 23:15:45 2010 From: foldr at codedgers.com (Mikhail Glushenkov) Date: Fri, 13 Aug 2010 04:15:45 -0000 Subject: [llvm-commits] [llvm] r111004 - /llvm/trunk/test/LLVMC/MultiplePluginPriorities.td Message-ID: <20100813041545.370022A6C12C@llvm.org> Author: foldr Date: Thu Aug 12 23:15:45 2010 New Revision: 111004 URL: http://llvm.org/viewvc/llvm-project?rev=111004&view=rev Log: Add an XFAIL. Modified: llvm/trunk/test/LLVMC/MultiplePluginPriorities.td Modified: llvm/trunk/test/LLVMC/MultiplePluginPriorities.td URL: http://llvm.org/viewvc/llvm-project/llvm/trunk/test/LLVMC/MultiplePluginPriorities.td?rev=111004&r1=111003&r2=111004&view=diff ============================================================================== --- llvm/trunk/test/LLVMC/MultiplePluginPriorities.td (original) +++ llvm/trunk/test/LLVMC/MultiplePluginPriorities.td Thu Aug 12 23:15:45 2010 @@ -4,6 +4,9 @@ // Disable for Darwin PPC: // XFAIL: powerpc-apple-darwin +// This also fails on i386-darwin9 for some reason +// XFAIL: i386-darwin9 + include "llvm/CompilerDriver/Common.td" def Graph : CompilationGraph<[]>; From foldr at codedgers.com Fri Aug 13 01:02:45 2010 From: foldr at codedgers.com (Mikhail Glushenkov) Date: Fri, 13 Aug 2010 06:02:45 -0000 Subject: [llvm-commits] [llvm] r111007 - in /llvm/trunk/utils/TableGen: LLVMCConfigurationEmitter.cpp TableGen.cpp Message-ID: <20100813060245.85F9C2A6C12C@llvm.org> Author: foldr Date: Fri Aug 13 01:02:45 2010 New Revision: 111007 URL: http://llvm.org/viewvc/llvm-project?rev=111007&view=rev Log: Add a workaround for building with Clang. Modified: llvm/trunk/utils/TableGen/LLVMCConfigurationEmitter.cpp llvm/trunk/utils/TableGen/TableGen.cpp Modified: llvm/trunk/utils/TableGen/LLVMCConfigurationEmitter.cpp URL: http://llvm.org/viewvc/llvm-project/llvm/trunk/utils/TableGen/LLVMCConfigurationEmitter.cpp?rev=111007&r1=111006&r2=111007&view=diff ============================================================================== --- llvm/trunk/utils/TableGen/LLVMCConfigurationEmitter.cpp (original) +++ llvm/trunk/utils/TableGen/LLVMCConfigurationEmitter.cpp Fri Aug 13 01:02:45 2010 @@ -17,6 +17,8 @@ #include "llvm/ADT/IntrusiveRefCntPtr.h" #include "llvm/ADT/StringMap.h" #include "llvm/ADT/StringSet.h" +#include "llvm/Support/CommandLine.h" +#include "llvm/System/Path.h" #include #include @@ -27,6 +29,8 @@ using namespace llvm; +extern cl::opt InputFilename; + namespace { //===----------------------------------------------------------------------===// @@ -2974,9 +2978,18 @@ O << "}\n\n"; } +std::string GetPluginName() { + if (!InputFilename.empty()) { + return sys::Path(InputFilename).getBasename(); + } + + return ""; +} + /// EmitRegisterPlugin - Emit code to register this plugin. void EmitRegisterPlugin(int Priority, raw_ostream& O) { - O << "struct Plugin : public llvmc::BasePlugin {\n\n"; + O << "struct Plugin" << GetPluginName() + << " : public llvmc::BasePlugin {\n\n"; O.indent(Indent1) << "int Priority() const { return " << Priority << "; }\n\n"; O.indent(Indent1) << "int PreprocessOptions() const\n"; @@ -2987,7 +3000,8 @@ << "int PopulateCompilationGraph(CompilationGraph& graph) const\n"; O.indent(Indent1) << "{ return PopulateCompilationGraphLocal(graph); }\n" << "};\n\n" - << "static llvmc::RegisterPlugin RP;\n\n"; + << "static llvmc::RegisterPlugin RP;\n\n"; } /// EmitIncludes - Emit necessary #include directives and some Modified: llvm/trunk/utils/TableGen/TableGen.cpp URL: http://llvm.org/viewvc/llvm-project/llvm/trunk/utils/TableGen/TableGen.cpp?rev=111007&r1=111006&r2=111007&view=diff ============================================================================== --- llvm/trunk/utils/TableGen/TableGen.cpp (original) +++ llvm/trunk/utils/TableGen/TableGen.cpp Fri Aug 13 01:02:45 2010 @@ -146,9 +146,6 @@ OutputFilename("o", cl::desc("Output filename"), cl::value_desc("filename"), cl::init("-")); - cl::opt - InputFilename(cl::Positional, cl::desc(""), cl::init("-")); - cl::list IncludeDirs("I", cl::desc("Directory of include files"), cl::value_desc("directory"), cl::Prefix); @@ -161,6 +158,9 @@ // FIXME: Eliminate globals from tblgen. +cl::opt +InputFilename(cl::Positional, cl::desc(""), cl::init("-")); + RecordKeeper llvm::Records; static SourceMgr SrcMgr; From foldr at codedgers.com Fri Aug 13 02:01:55 2010 From: foldr at codedgers.com (Mikhail Glushenkov) Date: Fri, 13 Aug 2010 07:01:55 -0000 Subject: [llvm-commits] [llvm] r111008 - in /llvm/trunk/test/LLVMC: MultiplePluginPriorities.td OutputSuffixHook.td Message-ID: <20100813070155.DD8F42A6C12C@llvm.org> Author: foldr Date: Fri Aug 13 02:01:55 2010 New Revision: 111008 URL: http://llvm.org/viewvc/llvm-project?rev=111008&view=rev Log: More XFAILs. Modified: llvm/trunk/test/LLVMC/MultiplePluginPriorities.td llvm/trunk/test/LLVMC/OutputSuffixHook.td Modified: llvm/trunk/test/LLVMC/MultiplePluginPriorities.td URL: http://llvm.org/viewvc/llvm-project/llvm/trunk/test/LLVMC/MultiplePluginPriorities.td?rev=111008&r1=111007&r2=111008&view=diff ============================================================================== --- llvm/trunk/test/LLVMC/MultiplePluginPriorities.td (original) +++ llvm/trunk/test/LLVMC/MultiplePluginPriorities.td Fri Aug 13 02:01:55 2010 @@ -1,5 +1,6 @@ // Check that multiple plugin priorities are not allowed. // RUN: ignore tblgen -I %p/../../include --gen-llvmc %s |& grep "More than one 'PluginPriority' instance found" +// XFAIL: vg_leak // Disable for Darwin PPC: // XFAIL: powerpc-apple-darwin Modified: llvm/trunk/test/LLVMC/OutputSuffixHook.td URL: http://llvm.org/viewvc/llvm-project/llvm/trunk/test/LLVMC/OutputSuffixHook.td?rev=111008&r1=111007&r2=111008&view=diff ============================================================================== --- llvm/trunk/test/LLVMC/OutputSuffixHook.td (original) +++ llvm/trunk/test/LLVMC/OutputSuffixHook.td Fri Aug 13 02:01:55 2010 @@ -2,6 +2,7 @@ // RUN: tblgen -I %p/../../include --gen-llvmc %s -o %t // RUN: FileCheck -input-file %t %s // RUN: %compile_cxx -x c++ %t +// XFAIL: vg_leak include "llvm/CompilerDriver/Common.td" From foldr at codedgers.com Fri Aug 13 02:03:57 2010 From: foldr at codedgers.com (Mikhail Glushenkov) Date: Fri, 13 Aug 2010 07:03:57 -0000 Subject: [llvm-commits] [llvm] r111010 - /llvm/trunk/test/LLVMC/MultiplePluginPriorities.td Message-ID: <20100813070357.1D6662A6C12C@llvm.org> Author: foldr Date: Fri Aug 13 02:03:56 2010 New Revision: 111010 URL: http://llvm.org/viewvc/llvm-project?rev=111010&view=rev Log: One more XFAIL. Modified: llvm/trunk/test/LLVMC/MultiplePluginPriorities.td Modified: llvm/trunk/test/LLVMC/MultiplePluginPriorities.td URL: http://llvm.org/viewvc/llvm-project/llvm/trunk/test/LLVMC/MultiplePluginPriorities.td?rev=111010&r1=111009&r2=111010&view=diff ============================================================================== --- llvm/trunk/test/LLVMC/MultiplePluginPriorities.td (original) +++ llvm/trunk/test/LLVMC/MultiplePluginPriorities.td Fri Aug 13 02:03:56 2010 @@ -4,6 +4,7 @@ // Disable for Darwin PPC: // XFAIL: powerpc-apple-darwin +// XFAIL: powerpc-darwin9 // This also fails on i386-darwin9 for some reason // XFAIL: i386-darwin9 From anton at korobeynikov.info Fri Aug 13 04:35:05 2010 From: anton at korobeynikov.info (Anton Korobeynikov) Date: Fri, 13 Aug 2010 13:35:05 +0400 Subject: [llvm-commits] Win64 pseudo instruction patch In-Reply-To: <00C68A18-199E-429D-A0A5-2BBDCC219A03@apple.com> References: <00C68A18-199E-429D-A0A5-2BBDCC219A03@apple.com> Message-ID: Hello, Cameron > Attached is a patch which fixes some more of the Win64 ABI code gen. ?Added support for the Windows 64 pseudo instructions like WINTAILJMPd64 and WINCALL64pcrel32. > > Also, updated a little bit of the coff-dump.py tool to dump the AMD64 relocations. ?Updated COFF.h to list the AMD64 relocations. > > Still a bit more to do before Win64 COFFs work... Please next time submit unrelated changes (e.g. MC changes vs tail call stuff changes) as separate patches for the sake of easier review. >+ bool AfterFPPop = Opc == X86::TAILJMPm64 || Opc == X86::TAILJMPm || >+ Opc == X86::WINTAILJMPm64; Is it possible to factor out the predicates of such sort into some external predicate function? Something like "IsTAILJUMPMemOpcode()" or whatever? >- } else if (Subtarget->isTargetWin64()) { >- // We need to always allocate 32 bytes as register spill area. >- // FIXME: We might reuse these 32 bytes for leaf functions. >- StackSize += 32; >- MFI->setStackSize(StackSize); > } As I already mentioned, this part is invalid. Consider the following case: you have two functions A and B with A calling B. B does regs dump into register save area. Since you haven't allocated the space on stack for register save area then B will clobber 16 bytes on local frame of A. This is definitely not what you will want. >- RetOpcode == X86::TCRETURNmi64) { >- bool isMem = RetOpcode == X86::TCRETURNmi || RetOpcode == X86::TCRETURNmi64; >+ RetOpcode == X86::TCRETURNmi64 || >+ RetOpcode == X86::WINTCRETURNri64 || RetOpcode == X86::WINTCRETURNdi64 || >+ RetOpcode == X86::WINTCRETURNmi64) { >+ bool isMem = RetOpcode == X86::TCRETURNmi || RetOpcode == X86::TCRETURNmi64 || >+ RetOpcode == X86::WINTCRETURNmi64; Same as above. > + if (RetOpcode == X86::TCRETURNdi) > + Opcode = X86::TAILJMPd; > + else > + Opcode = (IsWin64 ? X86::WINTAILJMPd64 : X86::TAILJMPd64); Also deserves some helper for such mapping? E.g. "TailCallIMapImmOpcode" ? -- With best regards, Anton Korobeynikov Faculty of Mathematics and Mechanics, Saint Petersburg State University From criswell at uiuc.edu Fri Aug 13 10:20:26 2010 From: criswell at uiuc.edu (John Criswell) Date: Fri, 13 Aug 2010 15:20:26 -0000 Subject: [llvm-commits] [poolalloc] r111014 - /poolalloc/trunk/lib/DSA/CallTargets.cpp Message-ID: <20100813152026.462D62A6C12C@llvm.org> Author: criswell Date: Fri Aug 13 10:20:26 2010 New Revision: 111014 URL: http://llvm.org/viewvc/llvm-project?rev=111014&view=rev Log: Initialize the pass ID value to zero. Modified: poolalloc/trunk/lib/DSA/CallTargets.cpp Modified: poolalloc/trunk/lib/DSA/CallTargets.cpp URL: http://llvm.org/viewvc/llvm-project/poolalloc/trunk/lib/DSA/CallTargets.cpp?rev=111014&r1=111013&r2=111014&view=diff ============================================================================== --- poolalloc/trunk/lib/DSA/CallTargets.cpp (original) +++ poolalloc/trunk/lib/DSA/CallTargets.cpp Fri Aug 13 10:20:26 2010 @@ -38,7 +38,7 @@ RegisterPass X("calltarget","Find Call Targets (uses DSA)"); } -char CallTargetFinder::ID; +char CallTargetFinder::ID = 0; void CallTargetFinder::findIndTargets(Module &M) { From criswell at uiuc.edu Fri Aug 13 10:22:24 2010 From: criswell at uiuc.edu (John Criswell) Date: Fri, 13 Aug 2010 15:22:24 -0000 Subject: [llvm-commits] [poolalloc] r111015 - in /poolalloc/trunk: include/dsa/DataStructure.h lib/DSA/BottomUpClosure.cpp Message-ID: <20100813152224.14E312A6C12C@llvm.org> Author: criswell Date: Fri Aug 13 10:22:23 2010 New Revision: 111015 URL: http://llvm.org/viewvc/llvm-project?rev=111015&view=rev Log: Revert back to the original DSA algorithm described in the PLDI paper. The important feature of this change is that the DSCallGraph is not used to perform bottom-up traversal of the call graph because the DSCallGraph is being computed during the bottom-up traversal process. Modified: poolalloc/trunk/include/dsa/DataStructure.h poolalloc/trunk/lib/DSA/BottomUpClosure.cpp Modified: poolalloc/trunk/include/dsa/DataStructure.h URL: http://llvm.org/viewvc/llvm-project/poolalloc/trunk/include/dsa/DataStructure.h?rev=111015&r1=111014&r2=111015&view=diff ============================================================================== --- poolalloc/trunk/include/dsa/DataStructure.h (original) +++ poolalloc/trunk/include/dsa/DataStructure.h Fri Aug 13 10:22:23 2010 @@ -235,7 +235,16 @@ bool runOnModuleInternal(Module &M); private: + // Private typedefs + typedef std::map TarjanMap; + typedef std::vector TarjanStack; + void mergeSCCs(); + void postOrderInline (Module & M); + unsigned calculateGraphs (const Function *F, + TarjanStack & Stack, + unsigned & NextID, + TarjanMap & ValMap); DSGraph* postOrder(const Function*, svset& marked); Modified: poolalloc/trunk/lib/DSA/BottomUpClosure.cpp URL: http://llvm.org/viewvc/llvm-project/poolalloc/trunk/lib/DSA/BottomUpClosure.cpp?rev=111015&r1=111014&r2=111015&view=diff ============================================================================== --- poolalloc/trunk/lib/DSA/BottomUpClosure.cpp (original) +++ poolalloc/trunk/lib/DSA/BottomUpClosure.cpp Fri Aug 13 10:22:23 2010 @@ -69,14 +69,27 @@ callgraph.buildSCCs(); callgraph.buildRoots(); +#if 0 // // Merge the DSGraphs of functions belonging to an SCC. // mergeSCCs(); +#endif + + // + // Make sure we have a DSGraph for all declared functions in the Module. + // While we may not need them in this DSA pass, a later DSA pass may ask us + // for their DSGraphs, and we want to have them if asked. + // + for (Module::iterator F = M.begin(); F != M.end(); ++F) { + if (!(F->isDeclaration())) + getOrCreateGraph(F); + } // // Do a post-order traversal of the SCC callgraph and do bottom-up inlining. // +#if 0 { //errs() << *DSG.knownRoots.begin() << " -> " << *DSG.knownRoots.rbegin() << "\n"; svset marked; @@ -97,6 +110,9 @@ CloneAuxIntoGlobal(G); } } +#else + postOrderInline (M); +#endif std::vector EntryPoints; @@ -139,6 +155,13 @@ NumCallEdges += callgraph.size(); + // + // Put the callgraph into canonical form by finding SCCs. It has been + // updated since we did this last. + // + callgraph.buildSCCs(); + callgraph.buildRoots(); + return false; } @@ -186,6 +209,271 @@ } // +// Function: GetAllCallees() +// +// Description: +// Given a DSCallSite, add to the list the functions that can be called by +// the call site *if* it is resolvable. +// +static void +GetAllCallees(const DSCallSite &CS, std::vector &Callees) { + // + // FIXME: Should we check for the Unknown flag on indirect call sites? + // + // Direct calls to functions that have bodies are always resolvable. + // Indirect function calls that are for a complete call site (the analysis + // knows everything about the call site) and do not target external functions + // are also resolvable. + // + if (CS.isDirectCall()) { + if (!CS.getCalleeFunc()->isDeclaration()) + Callees.push_back(CS.getCalleeFunc()); + } else if (!CS.getCalleeNode()->isIncompleteNode()) { + // Get all callees. + if (!CS.getCalleeNode()->isExternFuncNode()) + CS.getCalleeNode()->addFullFunctionList(Callees); + } +} + +// +// Function: GetAllAuxCallees() +// +// Description: +// Return a list containing all of the resolvable callees in the auxiliary +// list for the specified graph in the Callees vector. +// +// Inputs: +// G - The DSGraph for which the callers wants a list of resolvable call +// sites. +// +// Outputs: +// Callees - A list of all functions that can be called from resolvable call +// sites. This list is always cleared by this function before any +// functions are added to it. +// +static void +GetAllAuxCallees (DSGraph* G, std::vector & Callees) { + // + // Clear out the list of callees. + // + Callees.clear(); + for (DSGraph::afc_iterator I = G->afc_begin(), E = G->afc_end(); I != E; ++I) + GetAllCallees(*I, Callees); +} + +// +// Method: postOrderInline() +// +// Description: +// This methods does a post order traversal of the call graph and performs +// bottom-up inlining of the DSGraphs. +// +void +BUDataStructures::postOrderInline (Module & M) { + // Variables used for Tarjan SCC-finding algorithm. These are passed into + // the recursive function used to find SCCs. + std::vector Stack; + std::map ValMap; + unsigned NextID = 1; + + // + // Start the post order traversal with the main() function. If there is no + // main() function, don't worry; we'll have a separate traversal for inlining + // graphs for functions not reachable from main(). + // + Function *MainFunc = M.getFunction ("main"); + if (MainFunc && !MainFunc->isDeclaration()) { + calculateGraphs(MainFunc, Stack, NextID, ValMap); + CloneAuxIntoGlobal(getDSGraph(*MainFunc)); + } + + // + // Calculate the graphs for any functions that are unreachable from main... + // + for (Module::iterator I = M.begin(), E = M.end(); I != E; ++I) + if (!I->isDeclaration() && !hasDSGraph(*I)) { + if (MainFunc) + DEBUG(errs() << debugname << ": Function unreachable from main: " + << I->getName() << "\n"); + calculateGraphs(I, Stack, NextID, ValMap); // Calculate all graphs. + CloneAuxIntoGlobal(getDSGraph(*I)); + } + + return; +} + +// +// Method: calculateGraphs() +// +// Description: +// Perform recursive bottom-up inlining of DSGraphs from callee to caller. +// +// Inputs: +// F - The function which should have its callees' DSGraphs merged into its +// own DSGraph. +// Stack - The stack used for Tarjan's SCC-finding algorithm. +// NextID - The nextID value used for Tarjan's SCC-finding algorithm. +// ValMap - The map used for Tarjan's SCC-finding algorithm. +// +// Return value: +// +unsigned +BUDataStructures::calculateGraphs (const Function *F, + TarjanStack & Stack, + unsigned & NextID, + TarjanMap & ValMap) { + assert(!ValMap.count(F) && "Shouldn't revisit functions!"); + unsigned Min = NextID++, MyID = Min; + ValMap[F] = Min; + Stack.push_back(F); + + // + // FIXME: This test should be generalized to be any function that we have + // already processed in the case when there isn't a main() or there are + // unreachable functions! + // + if (F->isDeclaration()) { // sprintf, fprintf, sscanf, etc... + // No callees! + Stack.pop_back(); + ValMap[F] = ~0; + return Min; + } + + // + // Get the DSGraph of the current function. Make one if one doesn't exist. + // + DSGraph* Graph = getOrCreateGraph(F); + + // + // Find all callee functions. Use the DSGraph for this (do not use the call + // graph (DSCallgraph) as we're still in the process of constructing it). + // + std::vector CalleeFunctions; + GetAllAuxCallees(Graph, CalleeFunctions); + + // + // Iterate through each call target (these are the edges out of the current + // node (i.e., the current function) in Tarjan graph parlance). Find the + // minimum assigned ID. + // + for (unsigned i = 0, e = CalleeFunctions.size(); i != e; ++i) { + const Function *Callee = CalleeFunctions[i]; + unsigned M; + // + // If we have not visited this callee before, visit it now (this is the + // post-order component of the Bottom-Up algorithm). Otherwise, look up + // the assigned ID value from the Tarjan Value Map. + // + TarjanMap::iterator It = ValMap.find(Callee); + if (It == ValMap.end()) // No, visit it now. + M = calculateGraphs(Callee, Stack, NextID, ValMap); + else // Yes, get it's number. + M = It->second; + + // + // If we've found a function with a smaller ID than this funtion, record + // that ID as the minimum ID. + // + if (M < Min) Min = M; + } + + assert(ValMap[F] == MyID && "SCC construction assumption wrong!"); + + // + // If the minimum ID found is not this function's ID, then this function is + // part of a larger SCC. + // + if (Min != MyID) + return Min; + + // + // If this is a new SCC, process it now. + // + if (Stack.back() == F) { // Special case the single "SCC" case here. + DEBUG(errs() << "Visiting single node SCC #: " << MyID << " fn: " + << F->getName() << "\n"); + Stack.pop_back(); + DEBUG(errs() << " [BU] Calculating graph for: " << F->getName()<< "\n"); + calculateGraph (Graph); + DEBUG(errs() << " [BU] Done inlining: " << F->getName() << " [" + << Graph->getGraphSize() << "+" << Graph->getAuxFunctionCalls().size() + << "]\n"); + + if (MaxSCC < 1) MaxSCC = 1; + + // + // Should we revisit the graph? Only do it if there are now new resolvable + // callees. + GetAllAuxCallees (Graph, CalleeFunctions); + if (!CalleeFunctions.empty()) { + DEBUG(errs() << "Recalculating " << F->getName() << " due to new knowledge\n"); + ValMap.erase(F); + return calculateGraphs(F, Stack, NextID, ValMap); + } else { + ValMap[F] = ~0U; + } + return MyID; + } else { + // + // SCCFunctions - Keep track of the functions in the current SCC + // + std::vector SCCGraphs; + + unsigned SCCSize = 1; + const Function *NF = Stack.back(); + ValMap[NF] = ~0U; + DSGraph* SCCGraph = getDSGraph(*NF); + + // + // First thing first: collapse all of the DSGraphs into a single graph for + // the entire SCC. Splice all of the graphs into one and discard all of + // the old graphs. + // + while (NF != F) { + Stack.pop_back(); + NF = Stack.back(); + ValMap[NF] = ~0U; + + DSGraph* NFG = getDSGraph(*NF); + + if (NFG != SCCGraph) { + // Update the Function -> DSG map. + for (DSGraph::retnodes_iterator I = NFG->retnodes_begin(), + E = NFG->retnodes_end(); I != E; ++I) + setDSGraph(*I->first, SCCGraph); + + SCCGraph->spliceFrom(NFG); + delete NFG; + ++SCCSize; + } + } + Stack.pop_back(); + + DEBUG(errs() << "Calculating graph for SCC #: " << MyID << " of size: " + << SCCSize << "\n"); + + // Compute the Max SCC Size. + if (MaxSCC < SCCSize) + MaxSCC = SCCSize; + + // Clean up the graph before we start inlining a bunch again... + SCCGraph->removeDeadNodes(DSGraph::KeepUnreachableGlobals); + + // Now that we have one big happy family, resolve all of the call sites in + // the graph... + calculateGraph(SCCGraph); + DEBUG(errs() << " [BU] Done inlining SCC [" << SCCGraph->getGraphSize() + << "+" << SCCGraph->getAuxFunctionCalls().size() << "]\n" + << "DONE with SCC #: " << MyID << "\n"); + + // We never have to revisit "SCC" processed functions... + return MyID; + } + + return MyID; // == Min +} + +// // Method: postOrder() // // Description: @@ -461,6 +749,11 @@ cloneIntoGlobals(Graph); //Graph.writeGraphToFile(cerr, "bu_" + F.getName()); + + // + // Update the callgraph with the new information that we have gleaned. + // + Graph->buildCallGraph(callgraph); } //For Entry Points From grosbach at apple.com Fri Aug 13 11:55:08 2010 From: grosbach at apple.com (Jim Grosbach) Date: Fri, 13 Aug 2010 16:55:08 -0000 Subject: [llvm-commits] [llvm] r111019 - /llvm/trunk/lib/CodeGen/LLVMTargetMachine.cpp Message-ID: <20100813165508.62CCD2A6C12C@llvm.org> Author: grosbach Date: Fri Aug 13 11:55:08 2010 New Revision: 111019 URL: http://llvm.org/viewvc/llvm-project?rev=111019&view=rev Log: tidy up whitespace a bit Modified: llvm/trunk/lib/CodeGen/LLVMTargetMachine.cpp Modified: llvm/trunk/lib/CodeGen/LLVMTargetMachine.cpp URL: http://llvm.org/viewvc/llvm-project/llvm/trunk/lib/CodeGen/LLVMTargetMachine.cpp?rev=111019&r1=111018&r2=111019&view=diff ============================================================================== --- llvm/trunk/lib/CodeGen/LLVMTargetMachine.cpp (original) +++ llvm/trunk/lib/CodeGen/LLVMTargetMachine.cpp Fri Aug 13 11:55:08 2010 @@ -85,7 +85,7 @@ case cl::BOU_UNSET: return TargetMachine::getAsmVerbosityDefault(); case cl::BOU_TRUE: return true; case cl::BOU_FALSE: return false; - } + } } // Enable or disable FastISel. Both options are needed, because @@ -176,12 +176,12 @@ FunctionPass *Printer = getTarget().createAsmPrinter(*this, *AsmStreamer); if (Printer == 0) return true; - + // If successful, createAsmPrinter took ownership of AsmStreamer. AsmStreamer.take(); - + PM.add(Printer); - + // Make sure the code model is set. setCodeModelForStatic(); PM.add(createGCInfoDeleter()); @@ -200,7 +200,7 @@ bool DisableVerify) { // Make sure the code model is set. setCodeModelForJIT(); - + // Add common CodeGen passes. MCContext *Ctx = 0; if (addCommonCodeGenPasses(PM, OptLevel, DisableVerify, Ctx)) @@ -317,13 +317,12 @@ PM.add(createVerifierPass()); // Standard Lower-Level Passes. - + // Install a MachineModuleInfo class, which is an immutable pass that holds // all the per-module stuff we're generating, including MCContext. MachineModuleInfo *MMI = new MachineModuleInfo(*getMCAsmInfo()); PM.add(MMI); OutContext = &MMI->getContext(); // Return the MCContext specifically by-ref. - // Set up a MachineFunction for the rest of CodeGen to work on. PM.add(new MachineFunctionAnalysis(*this, OptLevel)); From bruno.cardoso at gmail.com Fri Aug 13 12:44:10 2010 From: bruno.cardoso at gmail.com (Bruno Cardoso Lopes) Date: Fri, 13 Aug 2010 17:44:10 -0000 Subject: [llvm-commits] [llvm] r111021 - /llvm/trunk/lib/Target/X86/X86InstrSSE.td Message-ID: <20100813174410.A14B32A6C12C@llvm.org> Author: bruno Date: Fri Aug 13 12:44:10 2010 New Revision: 111021 URL: http://llvm.org/viewvc/llvm-project?rev=111021&view=rev Log: Improve comment to make explicit why not to touch this could before JIT goes MC Modified: llvm/trunk/lib/Target/X86/X86InstrSSE.td Modified: llvm/trunk/lib/Target/X86/X86InstrSSE.td URL: http://llvm.org/viewvc/llvm-project/llvm/trunk/lib/Target/X86/X86InstrSSE.td?rev=111021&r1=111020&r2=111021&view=diff ============================================================================== --- llvm/trunk/lib/Target/X86/X86InstrSSE.td (original) +++ llvm/trunk/lib/Target/X86/X86InstrSSE.td Fri Aug 13 12:44:10 2010 @@ -2174,7 +2174,9 @@ // Alias instructions that map zero vector to pxor / xorp* for sse. // We set canFoldAsLoad because this can be converted to a constant-pool // load of an all-zeros value if folding it would be beneficial. -// FIXME: Change encoding to pseudo! +// FIXME: Change encoding to pseudo! This is blocked right now by the x86 +// JIT implementatioan, it does not expand the instructions below like +// X86MCInstLower does. let isReMaterializable = 1, isAsCheapAsAMove = 1, canFoldAsLoad = 1, isCodeGenOnly = 1 in { def V_SET0PS : PSI<0x57, MRMInitReg, (outs VR128:$dst), (ins), "", @@ -2188,6 +2190,9 @@ // The same as done above but for AVX. The 128-bit versions are the // same, but re-encoded. The 256-bit does not support PI version. +// FIXME: Change encoding to pseudo! This is blocked right now by the x86 +// JIT implementatioan, it does not expand the instructions below like +// X86MCInstLower does. let isReMaterializable = 1, isAsCheapAsAMove = 1, canFoldAsLoad = 1, isCodeGenOnly = 1, Predicates = [HasAVX] in { def AVX_SET0PS : PSI<0x57, MRMInitReg, (outs VR128:$dst), (ins), "", From bruno.cardoso at gmail.com Fri Aug 13 12:50:47 2010 From: bruno.cardoso at gmail.com (Bruno Cardoso Lopes) Date: Fri, 13 Aug 2010 17:50:47 -0000 Subject: [llvm-commits] [llvm] r111022 - /llvm/trunk/lib/Target/X86/X86ISelLowering.cpp Message-ID: <20100813175047.C75CF2A6C12C@llvm.org> Author: bruno Date: Fri Aug 13 12:50:47 2010 New Revision: 111022 URL: http://llvm.org/viewvc/llvm-project?rev=111022&view=rev Log: Fix comment to reflect code, and remove an unused argument Modified: llvm/trunk/lib/Target/X86/X86ISelLowering.cpp Modified: llvm/trunk/lib/Target/X86/X86ISelLowering.cpp URL: http://llvm.org/viewvc/llvm-project/llvm/trunk/lib/Target/X86/X86ISelLowering.cpp?rev=111022&r1=111021&r2=111022&view=diff ============================================================================== --- llvm/trunk/lib/Target/X86/X86ISelLowering.cpp (original) +++ llvm/trunk/lib/Target/X86/X86ISelLowering.cpp Fri Aug 13 12:50:47 2010 @@ -3513,9 +3513,8 @@ return DAG.getVectorShuffle(VT, dl, V1, V2, &Mask[0]); } -/// PromoteSplat - Promote a splat of v4f32, v8i16 or v16i8 to v4i32. -static SDValue PromoteSplat(ShuffleVectorSDNode *SV, SelectionDAG &DAG, - bool HasSSE2) { +/// PromoteSplat - Promote a splat of v4i32, v8i16 or v16i8 to v4f32. +static SDValue PromoteSplat(ShuffleVectorSDNode *SV, SelectionDAG &DAG) { if (SV->getValueType(0).getVectorNumElements() <= 4) return SDValue(SV, 0); @@ -4796,7 +4795,7 @@ if (SVOp->isSplat()) { if (isMMX || NumElems < 4) return Op; - return PromoteSplat(SVOp, DAG, Subtarget->hasSSE2()); + return PromoteSplat(SVOp, DAG); } // If the shuffle can be profitably rewritten as a narrower shuffle, then From matt at console-pimps.org Fri Aug 13 13:29:49 2010 From: matt at console-pimps.org (Matt Fleming) Date: Fri, 13 Aug 2010 19:29:49 +0100 Subject: [llvm-commits] [PATCH 0/5] ELF object support In-Reply-To: References: Message-ID: <20100813182949.GA3979@console-pimps.org> On Thu, Aug 12, 2010 at 10:44:05AM -0700, Daniel Dunbar wrote: > Hi Matt, > > I scanned the patches, they look reasonable to me. I have more review > comments, but I am eager to see this stuff land and I know others are > as well. I would rather get it in, and work from there. I was hoping this would be the case ;-) The idea was to get this stuff in as the first hurdle is the biggest. Incremental fix ups on top of that should be easier. > Assuming this stuff works, and passes some basic sanity checks, can > you go ahead and commit it? Sure thing. It passes some basic tests I have and.... > It would be nice to get some tests for it -- have you thought at all > about writing a simple ELF object file dumping tool like we have for > Mach-O and COFF? ... I was planning on committing some ELF tests after the basic support went in just because I haven't written them yet. I hadn't thought about writing a dumping tool for ELF but I can certainly do that. Should I commit this series then? From dalej at apple.com Fri Aug 13 13:43:46 2010 From: dalej at apple.com (Dale Johannesen) Date: Fri, 13 Aug 2010 18:43:46 -0000 Subject: [llvm-commits] [llvm] r111028 - in /llvm/trunk: lib/Target/X86/X86InstrSSE.td test/CodeGen/X86/2010-08-06-cmpsd.ll Message-ID: <20100813184346.3FBA62A6C12F@llvm.org> Author: johannes Date: Fri Aug 13 13:43:45 2010 New Revision: 111028 URL: http://llvm.org/viewvc/llvm-project?rev=111028&view=rev Log: Revert 110491. While not wrong, it was based on a misanalysis and is undesirable. Removed: llvm/trunk/test/CodeGen/X86/2010-08-06-cmpsd.ll Modified: llvm/trunk/lib/Target/X86/X86InstrSSE.td Modified: llvm/trunk/lib/Target/X86/X86InstrSSE.td URL: http://llvm.org/viewvc/llvm-project/llvm/trunk/lib/Target/X86/X86InstrSSE.td?rev=111028&r1=111027&r2=111028&view=diff ============================================================================== --- llvm/trunk/lib/Target/X86/X86InstrSSE.td (original) +++ llvm/trunk/lib/Target/X86/X86InstrSSE.td Fri Aug 13 13:43:45 2010 @@ -1206,36 +1206,31 @@ "cmpsd\t{$src2, $src, $dst|$dst, $src, $src2}">, XD; } -multiclass sse12_cmp_scalar_int { +multiclass sse12_cmp_scalar_int { def rr : SIi8<0xC2, MRMSrcReg, (outs VR128:$dst), (ins VR128:$src1, VR128:$src, SSECC:$cc), asm, [(set VR128:$dst, (Int VR128:$src1, VR128:$src, imm:$cc))]>; def rm : SIi8<0xC2, MRMSrcMem, (outs VR128:$dst), - (ins VR128:$src1, memopr:$src, SSECC:$cc), asm, + (ins VR128:$src1, f32mem:$src, SSECC:$cc), asm, [(set VR128:$dst, (Int VR128:$src1, - mem_cpat:$src, imm:$cc))]>; + (load addr:$src), imm:$cc))]>; } // Aliases to match intrinsics which expect XMM operand(s). - let isAsmParserOnly = 1 in { - defm Int_VCMPSS : sse12_cmp_scalar_int, XS, VEX_4V; - defm Int_VCMPSD : sse12_cmp_scalar_int, XD, VEX_4V; } let Constraints = "$src1 = $dst" in { - defm Int_CMPSS : sse12_cmp_scalar_int, XS; - defm Int_CMPSD : sse12_cmp_scalar_int, XD; } Removed: llvm/trunk/test/CodeGen/X86/2010-08-06-cmpsd.ll URL: http://llvm.org/viewvc/llvm-project/llvm/trunk/test/CodeGen/X86/2010-08-06-cmpsd.ll?rev=111027&view=auto ============================================================================== --- llvm/trunk/test/CodeGen/X86/2010-08-06-cmpsd.ll (original) +++ llvm/trunk/test/CodeGen/X86/2010-08-06-cmpsd.ll (removed) @@ -1,27 +0,0 @@ -; RUN: llc < %s -mtriple=x86_64-applecl-darwin11 | FileCheck %s -; 8193553 - -define void @__math_kernel_Vectorized_wrapper(<4 x double> addrspace(1)* %a, <4 x double> addrspace(1)* %b, i64 addrspace(1)* %c, i64 addrspace(1)* %d) nounwind { -entry.i: ; preds = %entry.i, %loop -; CHECK: math_kernel_Vectorized_wrapper -; CHECK-NOT: cmpordsd (%rsi), - %0 = alloca i8 - %1 = alloca i8 - %2 = alloca i8 - %tmp213.i = load <4 x double> addrspace(1)* %a ; <<4 x double>> [#uses=4] - %extract25.i = extractelement <4 x double> %tmp213.i, i32 1 ; [#uses=1] - %tmp723.i = load <4 x double> addrspace(1)* %b ; <<4 x double>> [#uses=4] - %extract29.i = extractelement <4 x double> %tmp723.i, i32 1 ; [#uses=1] - %tmp2.i26 = insertelement <2 x double> undef, double %extract25.i, i32 0 ; <<2 x double>> [#uses=1] - %tmp5.i27 = insertelement <2 x double> undef, double %extract29.i, i32 1 ; <<2 x double>> [#uses=1] - %cmpsd.i.i28 = call <2 x double> @llvm.x86.sse2.cmp.sd(<2 x double> %tmp2.i26, <2 x double> %tmp5.i27, i8 7) nounwind ; <<2 x double>> [#uses=1] - %3 = bitcast <2 x double> %cmpsd.i.i28 to <4 x i32> ; <<4 x i32>> [#uses=1] - %tmp12.i29 = extractelement <4 x i32> %3, i32 0 ; [#uses=1] - %and.i30 = and i32 %tmp12.i29, 1 ; [#uses=1] - %conv937.i36 = zext i32 %and.i30 to i64 ; [#uses=1] - store i64 %conv937.i36, i64 addrspace(1)* %d - ret void -; CHECK: ret -} - -declare <2 x double> @llvm.x86.sse2.cmp.sd(<2 x double>, <2 x double>, i8) nounwind readnone From bob.wilson at apple.com Fri Aug 13 14:04:21 2010 From: bob.wilson at apple.com (Bob Wilson) Date: Fri, 13 Aug 2010 19:04:21 -0000 Subject: [llvm-commits] [llvm] r111029 - /llvm/trunk/lib/Target/ARM/Disassembler/ThumbDisassemblerCore.h Message-ID: <20100813190421.5EE562A6C12E@llvm.org> Author: bwilson Date: Fri Aug 13 14:04:21 2010 New Revision: 111029 URL: http://llvm.org/viewvc/llvm-project?rev=111029&view=rev Log: Refactor the code for disassembling Thumb2 saturate instructions along the same lines as the change I made for ARM saturate instructions. Modified: llvm/trunk/lib/Target/ARM/Disassembler/ThumbDisassemblerCore.h Modified: llvm/trunk/lib/Target/ARM/Disassembler/ThumbDisassemblerCore.h URL: http://llvm.org/viewvc/llvm-project/llvm/trunk/lib/Target/ARM/Disassembler/ThumbDisassemblerCore.h?rev=111029&r1=111028&r2=111029&view=diff ============================================================================== --- llvm/trunk/lib/Target/ARM/Disassembler/ThumbDisassemblerCore.h (original) +++ llvm/trunk/lib/Target/ARM/Disassembler/ThumbDisassemblerCore.h Fri Aug 13 14:04:21 2010 @@ -1470,22 +1470,36 @@ } } -static inline unsigned decodeThumb2SaturatePos(unsigned Opcode, uint32_t insn) { - switch (Opcode) { - case ARM::t2SSATlsl: - case ARM::t2SSATasr: - return slice(insn, 4, 0) + 1; - case ARM::t2SSAT16: - return slice(insn, 3, 0) + 1; - case ARM::t2USATlsl: - case ARM::t2USATasr: - return slice(insn, 4, 0); - case ARM::t2USAT16: - return slice(insn, 3, 0); - default: - assert(0 && "Unexpected opcode"); - return 0; +/// DisassembleThumb2Sat - Disassemble Thumb2 saturate instructions: +/// o t2SSAT[lsl|asr], t2USAT[lsl|asr]: Rs sat_pos Rn shamt +/// o t2SSAT16, t2USAT16: Rs sat_pos Rn +static bool DisassembleThumb2Sat(MCInst &MI, unsigned Opcode, uint32_t insn, + unsigned &NumOpsAdded, BO B) { + const TargetInstrDesc &TID = ARMInsts[Opcode]; + NumOpsAdded = TID.getNumOperands() - 2; // ignore predicate operands + + // Disassemble the register def. + MI.addOperand(MCOperand::CreateReg(getRegisterEnum(B, ARM::rGPRRegClassID, + decodeRs(insn)))); + + unsigned Pos = slice(insn, 4, 0); + if (Opcode == ARM::t2SSATlsl || + Opcode == ARM::t2SSATasr || + Opcode == ARM::t2SSAT16) + Pos += 1; + MI.addOperand(MCOperand::CreateImm(Pos)); + + MI.addOperand(MCOperand::CreateReg(getRegisterEnum(B, ARM::rGPRRegClassID, + decodeRn(insn)))); + + if (NumOpsAdded == 4) { + // Inst{14-12:7-6} encodes the imm5 shift amount. + unsigned ShAmt = slice(insn, 14, 12) << 2 | slice(insn, 7, 6); + if ((Opcode == ARM::t2SSATasr || Opcode == ARM::t2USATasr) && ShAmt == 0) + ShAmt = 32; + MI.addOperand(MCOperand::CreateImm(ShAmt)); } + return true; } // A6.3.3 Data-processing (plain binary immediate) @@ -1499,11 +1513,6 @@ // o t2SBFX (SBFX): Rs Rn lsb width // o t2UBFX (UBFX): Rs Rn lsb width // o t2BFI (BFI): Rs Rn lsb width -// -// [Signed|Unsigned] Saturate [16] -// -// o t2SSAT[lsl|asr], t2USAT[lsl|asr]: Rs sat_pos Rn shamt -// o t2SSAT16, t2USAT16: Rs sat_pos Rn static bool DisassembleThumb2DPBinImm(MCInst &MI, unsigned Opcode, uint32_t insn, unsigned short NumOps, unsigned &NumOpsAdded, BO B) { @@ -1528,30 +1537,6 @@ decodeRs(insn)))); ++OpIdx; - // t2SSAT/t2SSAT16/t2USAT/t2USAT16 has imm operand after Rd. - if (Thumb2SaturateOpcode(Opcode)) { - MI.addOperand(MCOperand::CreateImm(decodeThumb2SaturatePos(Opcode, insn))); - - MI.addOperand(MCOperand::CreateReg(getRegisterEnum(B, RnRegClassID, - decodeRn(insn)))); - - if (Opcode == ARM::t2SSAT16 || Opcode == ARM::t2USAT16) { - OpIdx += 2; - return true; - } - - // For SSAT operand reg (Rn) has been disassembled above. - // Now disassemble the shift amount. - - // Inst{14-12:7-6} encodes the imm5 shift amount. - unsigned ShAmt = slice(insn, 14, 12) << 2 | slice(insn, 7, 6); - - MI.addOperand(MCOperand::CreateImm(ShAmt)); - - OpIdx += 3; - return true; - } - if (TwoReg) { assert(NumOps >= 3 && "Expect >= 3 operands"); int Idx; @@ -2163,22 +2148,20 @@ break; case 2: if (op == 0) { - if (slice(op2, 5, 5) == 0) { + if (slice(op2, 5, 5) == 0) // Data-processing (modified immediate) return DisassembleThumb2DPModImm(MI, Opcode, insn, NumOps, NumOpsAdded, B); - } else { - // Data-processing (plain binary immediate) - return DisassembleThumb2DPBinImm(MI, Opcode, insn, NumOps, NumOpsAdded, - B); - } - } else { - // Branches and miscellaneous control on page A6-20. - return DisassembleThumb2BrMiscCtrl(MI, Opcode, insn, NumOps, NumOpsAdded, - B); - } + if (Thumb2SaturateOpcode(Opcode)) + return DisassembleThumb2Sat(MI, Opcode, insn, NumOpsAdded, B); - break; + // Data-processing (plain binary immediate) + return DisassembleThumb2DPBinImm(MI, Opcode, insn, NumOps, NumOpsAdded, + B); + } + // Branches and miscellaneous control on page A6-20. + return DisassembleThumb2BrMiscCtrl(MI, Opcode, insn, NumOps, NumOpsAdded, + B); case 3: switch (slice(op2, 6, 5)) { case 0: From criswell at uiuc.edu Fri Aug 13 14:32:00 2010 From: criswell at uiuc.edu (John Criswell) Date: Fri, 13 Aug 2010 19:32:00 -0000 Subject: [llvm-commits] [poolalloc] r111030 - in /poolalloc/trunk/lib/DSA: CallTargets.cpp Local.cpp Message-ID: <20100813193200.EB3472A6C12C@llvm.org> Author: criswell Date: Fri Aug 13 14:32:00 2010 New Revision: 111030 URL: http://llvm.org/viewvc/llvm-project?rev=111030&view=rev Log: Replaced older code to strip off pointer casts to use the Value::stripPointerCasts() method. Added some code in CallTargets to strip off pointer casts when looking for direct function calls. Modified: poolalloc/trunk/lib/DSA/CallTargets.cpp poolalloc/trunk/lib/DSA/Local.cpp Modified: poolalloc/trunk/lib/DSA/CallTargets.cpp URL: http://llvm.org/viewvc/llvm-project/poolalloc/trunk/lib/DSA/CallTargets.cpp?rev=111030&r1=111029&r2=111030&view=diff ============================================================================== --- poolalloc/trunk/lib/DSA/CallTargets.cpp (original) +++ poolalloc/trunk/lib/DSA/CallTargets.cpp Fri Aug 13 14:32:00 2010 @@ -51,15 +51,18 @@ CallSite cs = CallSite::get(B); AllSites.push_back(cs); Function* CF = cs.getCalledFunction(); - // If the called function is casted from one function type to another, peer - // into the cast instruction and pull out the actual function being called. - if (ConstantExpr *CE = dyn_cast(cs.getCalledValue())) - if (CE->getOpcode() == Instruction::BitCast && - isa(CE->getOperand(0))) - CF = cast(CE->getOperand(0)); - + + // + // If the called function is casted from one function type to + // another, peer into the cast instruction and pull out the actual + // function being called. + // + if (!CF) + CF = dyn_cast(cs.getCalledValue()->stripPointerCasts()); + + Value * calledValue = cs.getCalledValue()->stripPointerCasts(); if (!CF) { - if (isa(cs.getCalledValue())) { + if (isa(calledValue)) { ++DirCall; CompleteSites.insert(cs); } else { Modified: poolalloc/trunk/lib/DSA/Local.cpp URL: http://llvm.org/viewvc/llvm-project/poolalloc/trunk/lib/DSA/Local.cpp?rev=111030&r1=111029&r2=111030&view=diff ============================================================================== --- poolalloc/trunk/lib/DSA/Local.cpp (original) +++ poolalloc/trunk/lib/DSA/Local.cpp Fri Aug 13 14:32:00 2010 @@ -850,7 +850,10 @@ } void GraphBuilder::visitCallSite(CallSite CS) { - Value *Callee = CS.getCalledValue(); + // + // Get the called value. Strip off any casts which are lossless. + // + Value *Callee = CS.getCalledValue()->stripPointerCasts(); // Special case handling of certain libc allocation functions here. if (Function *F = dyn_cast(Callee)) @@ -861,7 +864,7 @@ return; //Can't do much about inline asm (yet!) - if (isa(CS.getCalledValue())) { + if (isa (Callee)) { ++NumAsmCall; DSNodeHandle RetVal; Instruction *I = CS.getInstruction(); @@ -878,7 +881,7 @@ } //uninteresting direct call - if (CS.getCalledFunction() && !DSCallGraph::hasPointers(CS)) { + if (isa(Callee) && !DSCallGraph::hasPointers(CS)) { ++NumBoringCall; return; } @@ -889,11 +892,6 @@ if (isa(I->getType())) RetVal = getValueDest(I); - if (!isa(Callee)) - if (ConstantExpr* EX = dyn_cast(Callee)) - if (EX->isCast() && isa(EX->getOperand(0))) - Callee = cast(EX->getOperand(0)); - DSNode *CalleeNode = 0; if (!isa(Callee)) { CalleeNode = getValueDest(Callee).getNode(); From gohman at apple.com Fri Aug 13 15:03:15 2010 From: gohman at apple.com (Dan Gohman) Date: Fri, 13 Aug 2010 20:03:15 -0000 Subject: [llvm-commits] [llvm] r111031 - /llvm/trunk/include/llvm/Analysis/ScalarEvolutionExpressions.h Message-ID: <20100813200315.2FDF72A6C12C@llvm.org> Author: djg Date: Fri Aug 13 15:03:15 2010 New Revision: 111031 URL: http://llvm.org/viewvc/llvm-project?rev=111031&view=rev Log: Implement hasComputableLoopEvolution for Add, Mul, and Trunc operators, since they can support trivial implementations. This avoids potentially expensive traversals of the operands. Modified: llvm/trunk/include/llvm/Analysis/ScalarEvolutionExpressions.h Modified: llvm/trunk/include/llvm/Analysis/ScalarEvolutionExpressions.h URL: http://llvm.org/viewvc/llvm-project/llvm/trunk/include/llvm/Analysis/ScalarEvolutionExpressions.h?rev=111031&r1=111030&r2=111031&view=diff ============================================================================== --- llvm/trunk/include/llvm/Analysis/ScalarEvolutionExpressions.h (original) +++ llvm/trunk/include/llvm/Analysis/ScalarEvolutionExpressions.h Fri Aug 13 15:03:15 2010 @@ -126,6 +126,12 @@ public: virtual void print(raw_ostream &OS) const; + virtual bool hasComputableLoopEvolution(const Loop *QL) const { + // Not computable. A truncate of an addrec is always folded into + // the addrec. + return false; + } + /// Methods for support type inquiry through isa, cast, and dyn_cast: static inline bool classof(const SCEVTruncateExpr *S) { return true; } static inline bool classof(const SCEV *S) { @@ -294,6 +300,12 @@ } public: + virtual bool hasComputableLoopEvolution(const Loop *QL) const { + // Not computable. An add of an addrec is always folded into the addrec + // if the other operands are loop-variant or loop-computable. + return false; + } + virtual const char *getOperationStr() const { return " + "; } virtual const Type *getType() const { @@ -322,6 +334,12 @@ } public: + virtual bool hasComputableLoopEvolution(const Loop *QL) const { + // Not computable. A mul of an addrec is always folded into the addrec + // if the other operands are loop-variant or loop-computable. + return false; + } + virtual const char *getOperationStr() const { return " * "; } /// Methods for support type inquiry through isa, cast, and dyn_cast: From foldr at codedgers.com Fri Aug 13 15:08:53 2010 From: foldr at codedgers.com (Mikhail Glushenkov) Date: Fri, 13 Aug 2010 20:08:53 -0000 Subject: [llvm-commits] [llvm] r111032 - in /llvm/trunk/utils/TableGen: LLVMCConfigurationEmitter.cpp TableGen.cpp Message-ID: <20100813200853.C49BD2A6C12C@llvm.org> Author: foldr Date: Fri Aug 13 15:08:53 2010 New Revision: 111032 URL: http://llvm.org/viewvc/llvm-project?rev=111032&view=rev Log: Revert r111007. Apparently, this is now fixed in Clang. Modified: llvm/trunk/utils/TableGen/LLVMCConfigurationEmitter.cpp llvm/trunk/utils/TableGen/TableGen.cpp Modified: llvm/trunk/utils/TableGen/LLVMCConfigurationEmitter.cpp URL: http://llvm.org/viewvc/llvm-project/llvm/trunk/utils/TableGen/LLVMCConfigurationEmitter.cpp?rev=111032&r1=111031&r2=111032&view=diff ============================================================================== --- llvm/trunk/utils/TableGen/LLVMCConfigurationEmitter.cpp (original) +++ llvm/trunk/utils/TableGen/LLVMCConfigurationEmitter.cpp Fri Aug 13 15:08:53 2010 @@ -17,8 +17,6 @@ #include "llvm/ADT/IntrusiveRefCntPtr.h" #include "llvm/ADT/StringMap.h" #include "llvm/ADT/StringSet.h" -#include "llvm/Support/CommandLine.h" -#include "llvm/System/Path.h" #include #include @@ -29,8 +27,6 @@ using namespace llvm; -extern cl::opt InputFilename; - namespace { //===----------------------------------------------------------------------===// @@ -2978,18 +2974,9 @@ O << "}\n\n"; } -std::string GetPluginName() { - if (!InputFilename.empty()) { - return sys::Path(InputFilename).getBasename(); - } - - return ""; -} - /// EmitRegisterPlugin - Emit code to register this plugin. void EmitRegisterPlugin(int Priority, raw_ostream& O) { - O << "struct Plugin" << GetPluginName() - << " : public llvmc::BasePlugin {\n\n"; + O << "struct Plugin : public llvmc::BasePlugin {\n\n"; O.indent(Indent1) << "int Priority() const { return " << Priority << "; }\n\n"; O.indent(Indent1) << "int PreprocessOptions() const\n"; @@ -3000,8 +2987,7 @@ << "int PopulateCompilationGraph(CompilationGraph& graph) const\n"; O.indent(Indent1) << "{ return PopulateCompilationGraphLocal(graph); }\n" << "};\n\n" - << "static llvmc::RegisterPlugin RP;\n\n"; + << "static llvmc::RegisterPlugin RP;\n\n"; } /// EmitIncludes - Emit necessary #include directives and some Modified: llvm/trunk/utils/TableGen/TableGen.cpp URL: http://llvm.org/viewvc/llvm-project/llvm/trunk/utils/TableGen/TableGen.cpp?rev=111032&r1=111031&r2=111032&view=diff ============================================================================== --- llvm/trunk/utils/TableGen/TableGen.cpp (original) +++ llvm/trunk/utils/TableGen/TableGen.cpp Fri Aug 13 15:08:53 2010 @@ -146,6 +146,9 @@ OutputFilename("o", cl::desc("Output filename"), cl::value_desc("filename"), cl::init("-")); + cl::opt + InputFilename(cl::Positional, cl::desc(""), cl::init("-")); + cl::list IncludeDirs("I", cl::desc("Directory of include files"), cl::value_desc("directory"), cl::Prefix); @@ -158,9 +161,6 @@ // FIXME: Eliminate globals from tblgen. -cl::opt -InputFilename(cl::Positional, cl::desc(""), cl::init("-")); - RecordKeeper llvm::Records; static SourceMgr SrcMgr; From grosbach at apple.com Fri Aug 13 15:08:59 2010 From: grosbach at apple.com (Jim Grosbach) Date: Fri, 13 Aug 2010 20:08:59 -0000 Subject: [llvm-commits] [llvm] r111033 - /llvm/trunk/include/llvm/CodeGen/MachineFrameInfo.h Message-ID: <20100813200859.EAB002A6C12D@llvm.org> Author: grosbach Date: Fri Aug 13 15:08:59 2010 New Revision: 111033 URL: http://llvm.org/viewvc/llvm-project?rev=111033&view=rev Log: tidy up 80 column and whitespace Modified: llvm/trunk/include/llvm/CodeGen/MachineFrameInfo.h Modified: llvm/trunk/include/llvm/CodeGen/MachineFrameInfo.h URL: http://llvm.org/viewvc/llvm-project/llvm/trunk/include/llvm/CodeGen/MachineFrameInfo.h?rev=111033&r1=111032&r2=111033&view=diff ============================================================================== --- llvm/trunk/include/llvm/CodeGen/MachineFrameInfo.h (original) +++ llvm/trunk/include/llvm/CodeGen/MachineFrameInfo.h Fri Aug 13 15:08:59 2010 @@ -30,15 +30,15 @@ class BitVector; /// The CalleeSavedInfo class tracks the information need to locate where a -/// callee saved register in the current frame. +/// callee saved register in the current frame. class CalleeSavedInfo { unsigned Reg; int FrameIdx; - + public: explicit CalleeSavedInfo(unsigned R, int FI = 0) : Reg(R), FrameIdx(FI) {} - + // Accessors. unsigned getReg() const { return Reg; } int getFrameIdx() const { return FrameIdx; } @@ -81,7 +81,7 @@ // SPOffset - The offset of this object from the stack pointer on entry to // the function. This field has no meaning for a variable sized element. int64_t SPOffset; - + // The size of this object on the stack. 0 means a variable sized object, // ~0ULL means a dead object. uint64_t Size; @@ -138,7 +138,7 @@ /// to be allocated on entry to the function. /// uint64_t StackSize; - + /// OffsetAdjustment - The amount that a frame offset needs to be adjusted to /// have the actual offset from the stack/frame pointer. The exact usage of /// this is target-dependent, but it is typically used to adjust between @@ -149,10 +149,10 @@ /// TargetRegisterInfo::getFrameIndexOffset); when generating code, the /// corresponding adjustments are performed directly. int OffsetAdjustment; - - /// MaxAlignment - The prolog/epilog code inserter may process objects + + /// MaxAlignment - The prolog/epilog code inserter may process objects /// that require greater alignment than the default alignment the target - /// provides. To handle this, MaxAlignment is set to the maximum alignment + /// provides. To handle this, MaxAlignment is set to the maximum alignment /// needed by the objects on the current frame. If this is greater than the /// native alignment maintained by the compiler, dynamic alignment code will /// be needed. @@ -177,7 +177,7 @@ /// insertion. /// unsigned MaxCallFrameSize; - + /// CSInfo - The prolog/epilog code inserter fills in this vector with each /// callee saved register saved in the frame. Beyond its use by the prolog/ /// epilog code inserter, this data used for debug info and exception @@ -231,8 +231,8 @@ bool isFrameAddressTaken() const { return FrameAddressTaken; } void setFrameAddressIsTaken(bool T) { FrameAddressTaken = T; } - /// isReturnAddressTaken - This method may be called any time after instruction - /// selection is complete to determine if there is a call to + /// isReturnAddressTaken - This method may be called any time after + /// instruction selection is complete to determine if there is a call to /// \@llvm.returnaddress in this function. bool isReturnAddressTaken() const { return ReturnAddressTaken; } void setReturnAddressIsTaken(bool s) { ReturnAddressTaken = s; } @@ -321,21 +321,21 @@ /// setStackSize - Set the size of the stack... /// void setStackSize(uint64_t Size) { StackSize = Size; } - + /// getOffsetAdjustment - Return the correction for frame offsets. /// int getOffsetAdjustment() const { return OffsetAdjustment; } - + /// setOffsetAdjustment - Set the correction for frame offsets. /// void setOffsetAdjustment(int Adj) { OffsetAdjustment = Adj; } - /// getMaxAlignment - Return the alignment in bytes that this function must be - /// aligned to, which is greater than the default stack alignment provided by + /// getMaxAlignment - Return the alignment in bytes that this function must be + /// aligned to, which is greater than the default stack alignment provided by /// the target. /// unsigned getMaxAlignment() const { return MaxAlignment; } - + /// setMaxAlignment - Set the preferred alignment. /// void setMaxAlignment(unsigned Align) { MaxAlignment = Align; } @@ -364,8 +364,8 @@ /// index with a negative value. /// int CreateFixedObject(uint64_t Size, int64_t SPOffset, bool Immutable); - - + + /// isFixedObjectIndex - Returns true if the specified index corresponds to a /// fixed stack object. bool isFixedObjectIndex(int ObjectIdx) const { From gohman at apple.com Fri Aug 13 15:11:40 2010 From: gohman at apple.com (Dan Gohman) Date: Fri, 13 Aug 2010 20:11:40 -0000 Subject: [llvm-commits] [llvm] r111034 - /llvm/trunk/lib/Analysis/ScalarEvolution.cpp Message-ID: <20100813201140.2622D2A6C12C@llvm.org> Author: djg Date: Fri Aug 13 15:11:39 2010 New Revision: 111034 URL: http://llvm.org/viewvc/llvm-project?rev=111034&view=rev Log: An add recurrence is loop-invariant in any loop inside of its associated loop. This avoids potentially expensive traversals of the add recurrence's operands. Modified: llvm/trunk/lib/Analysis/ScalarEvolution.cpp Modified: llvm/trunk/lib/Analysis/ScalarEvolution.cpp URL: http://llvm.org/viewvc/llvm-project/llvm/trunk/lib/Analysis/ScalarEvolution.cpp?rev=111034&r1=111033&r2=111034&view=diff ============================================================================== --- llvm/trunk/lib/Analysis/ScalarEvolution.cpp (original) +++ llvm/trunk/lib/Analysis/ScalarEvolution.cpp Fri Aug 13 15:11:39 2010 @@ -303,6 +303,10 @@ if (QueryLoop->contains(L)) return false; + // This recurrence is invariant w.r.t. QueryLoop if L contains QueryLoop. + if (L->contains(QueryLoop)) + return true; + // This recurrence is variant w.r.t. QueryLoop if any of its operands // are variant. for (unsigned i = 0, e = getNumOperands(); i != e; ++i) From gohman at apple.com Fri Aug 13 15:17:14 2010 From: gohman at apple.com (Dan Gohman) Date: Fri, 13 Aug 2010 20:17:14 -0000 Subject: [llvm-commits] [llvm] r111037 - /llvm/trunk/lib/Analysis/ScalarEvolution.cpp Message-ID: <20100813201714.850FE2A6C12C@llvm.org> Author: djg Date: Fri Aug 13 15:17:14 2010 New Revision: 111037 URL: http://llvm.org/viewvc/llvm-project?rev=111037&view=rev Log: When creating a symmetric SCEV with a constant operand, put the constant operand on the left, as that's where ScalarEvolution will end up canonicalizing to. Modified: llvm/trunk/lib/Analysis/ScalarEvolution.cpp Modified: llvm/trunk/lib/Analysis/ScalarEvolution.cpp URL: http://llvm.org/viewvc/llvm-project/llvm/trunk/lib/Analysis/ScalarEvolution.cpp?rev=111037&r1=111036&r2=111037&view=diff ============================================================================== --- llvm/trunk/lib/Analysis/ScalarEvolution.cpp (original) +++ llvm/trunk/lib/Analysis/ScalarEvolution.cpp Fri Aug 13 15:17:14 2010 @@ -1383,7 +1383,7 @@ // Found a match, merge the two values into a multiply, and add any // remaining values to the result. const SCEV *Two = getConstant(Ty, 2); - const SCEV *Mul = getMulExpr(Ops[i], Two); + const SCEV *Mul = getMulExpr(Two, Ops[i]); if (Ops.size() == 2) return Mul; Ops[i] = Mul; @@ -1530,7 +1530,7 @@ InnerMul = getMulExpr(MulOps); } const SCEV *One = getConstant(Ty, 1); - const SCEV *AddOne = getAddExpr(InnerMul, One); + const SCEV *AddOne = getAddExpr(One, InnerMul); const SCEV *OuterMul = getMulExpr(AddOne, MulOpSCEV); if (Ops.size() == 2) return OuterMul; if (AddOp < Idx) { @@ -3538,7 +3538,7 @@ const SCEV *LDiff = getMinusSCEV(LA, LS); const SCEV *RDiff = getMinusSCEV(RA, One); if (LDiff == RDiff) - return getAddExpr(getUMaxExpr(LS, One), LDiff); + return getAddExpr(getUMaxExpr(One, LS), LDiff); } break; case ICmpInst::ICMP_EQ: @@ -3553,7 +3553,7 @@ const SCEV *LDiff = getMinusSCEV(LA, One); const SCEV *RDiff = getMinusSCEV(RA, LS); if (LDiff == RDiff) - return getAddExpr(getUMaxExpr(LS, One), LDiff); + return getAddExpr(getUMaxExpr(One, LS), LDiff); } break; default: From gohman at apple.com Fri Aug 13 15:17:27 2010 From: gohman at apple.com (Dan Gohman) Date: Fri, 13 Aug 2010 20:17:27 -0000 Subject: [llvm-commits] [llvm] r111038 - /llvm/trunk/lib/Analysis/ScalarEvolution.cpp Message-ID: <20100813201727.EFAF62A6C12C@llvm.org> Author: djg Date: Fri Aug 13 15:17:27 2010 New Revision: 111038 URL: http://llvm.org/viewvc/llvm-project?rev=111038&view=rev Log: Add a const. Modified: llvm/trunk/lib/Analysis/ScalarEvolution.cpp Modified: llvm/trunk/lib/Analysis/ScalarEvolution.cpp URL: http://llvm.org/viewvc/llvm-project/llvm/trunk/lib/Analysis/ScalarEvolution.cpp?rev=111038&r1=111037&r2=111038&view=diff ============================================================================== --- llvm/trunk/lib/Analysis/ScalarEvolution.cpp (original) +++ llvm/trunk/lib/Analysis/ScalarEvolution.cpp Fri Aug 13 15:17:27 2010 @@ -523,7 +523,7 @@ /// than the complexity of the RHS. This comparator is used to canonicalize /// expressions. class SCEVComplexityCompare { - const LoopInfo *LI; + const LoopInfo *const LI; public: explicit SCEVComplexityCompare(const LoopInfo *li) : LI(li) {} From gohman at apple.com Fri Aug 13 15:23:25 2010 From: gohman at apple.com (Dan Gohman) Date: Fri, 13 Aug 2010 20:23:25 -0000 Subject: [llvm-commits] [llvm] r111039 - /llvm/trunk/lib/Analysis/ScalarEvolution.cpp Message-ID: <20100813202325.D583E2A6C12C@llvm.org> Author: djg Date: Fri Aug 13 15:23:25 2010 New Revision: 111039 URL: http://llvm.org/viewvc/llvm-project?rev=111039&view=rev Log: When testing whether one loop contains another, test this directly rather than testing whether the loop contains the other's header. Modified: llvm/trunk/lib/Analysis/ScalarEvolution.cpp Modified: llvm/trunk/lib/Analysis/ScalarEvolution.cpp URL: http://llvm.org/viewvc/llvm-project/llvm/trunk/lib/Analysis/ScalarEvolution.cpp?rev=111039&r1=111038&r2=111039&view=diff ============================================================================== --- llvm/trunk/lib/Analysis/ScalarEvolution.cpp (original) +++ llvm/trunk/lib/Analysis/ScalarEvolution.cpp Fri Aug 13 15:23:25 2010 @@ -2047,9 +2047,9 @@ // Canonicalize nested AddRecs in by nesting them in order of loop depth. if (const SCEVAddRecExpr *NestedAR = dyn_cast(Operands[0])) { const Loop *NestedLoop = NestedAR->getLoop(); - if (L->contains(NestedLoop->getHeader()) ? + if (L->contains(NestedLoop) ? (L->getLoopDepth() < NestedLoop->getLoopDepth()) : - (!NestedLoop->contains(L->getHeader()) && + (!NestedLoop->contains(L) && DT->dominates(L->getHeader(), NestedLoop->getHeader()))) { SmallVector NestedOperands(NestedAR->op_begin(), NestedAR->op_end()); From grosbach at apple.com Fri Aug 13 15:32:35 2010 From: grosbach at apple.com (Jim Grosbach) Date: Fri, 13 Aug 2010 20:32:35 -0000 Subject: [llvm-commits] [llvm] r111040 - /llvm/trunk/include/llvm/CodeGen/MachineFrameInfo.h Message-ID: <20100813203235.A4CE42A6C12C@llvm.org> Author: grosbach Date: Fri Aug 13 15:32:35 2010 New Revision: 111040 URL: http://llvm.org/viewvc/llvm-project?rev=111040&view=rev Log: tidy up comments Modified: llvm/trunk/include/llvm/CodeGen/MachineFrameInfo.h Modified: llvm/trunk/include/llvm/CodeGen/MachineFrameInfo.h URL: http://llvm.org/viewvc/llvm-project/llvm/trunk/include/llvm/CodeGen/MachineFrameInfo.h?rev=111040&r1=111039&r2=111040&view=diff ============================================================================== --- llvm/trunk/include/llvm/CodeGen/MachineFrameInfo.h (original) +++ llvm/trunk/include/llvm/CodeGen/MachineFrameInfo.h Fri Aug 13 15:32:35 2010 @@ -245,10 +245,10 @@ /// int getObjectIndexEnd() const { return (int)Objects.size()-NumFixedObjects; } - /// getNumFixedObjects() - Return the number of fixed objects. + /// getNumFixedObjects - Return the number of fixed objects. unsigned getNumFixedObjects() const { return NumFixedObjects; } - /// getNumObjects() - Return the number of objects. + /// getNumObjects - Return the number of objects. /// unsigned getNumObjects() const { return Objects.size(); } From bruno.cardoso at gmail.com Fri Aug 13 15:39:01 2010 From: bruno.cardoso at gmail.com (Bruno Cardoso Lopes) Date: Fri, 13 Aug 2010 20:39:01 -0000 Subject: [llvm-commits] [llvm] r111041 - /llvm/trunk/lib/Target/X86/X86InstrFragmentsSIMD.td Message-ID: <20100813203901.544C42A6C12C@llvm.org> Author: bruno Date: Fri Aug 13 15:39:01 2010 New Revision: 111041 URL: http://llvm.org/viewvc/llvm-project?rev=111041&view=rev Log: Add comments to some pattern fragments in x86 Modified: llvm/trunk/lib/Target/X86/X86InstrFragmentsSIMD.td Modified: llvm/trunk/lib/Target/X86/X86InstrFragmentsSIMD.td URL: http://llvm.org/viewvc/llvm-project/llvm/trunk/lib/Target/X86/X86InstrFragmentsSIMD.td?rev=111041&r1=111040&r2=111041&view=diff ============================================================================== --- llvm/trunk/lib/Target/X86/X86InstrFragmentsSIMD.td (original) +++ llvm/trunk/lib/Target/X86/X86InstrFragmentsSIMD.td Fri Aug 13 15:39:01 2010 @@ -149,12 +149,13 @@ // SSE pattern fragments //===----------------------------------------------------------------------===// +// 128-bit load pattern fragments def loadv4f32 : PatFrag<(ops node:$ptr), (v4f32 (load node:$ptr))>; def loadv2f64 : PatFrag<(ops node:$ptr), (v2f64 (load node:$ptr))>; def loadv4i32 : PatFrag<(ops node:$ptr), (v4i32 (load node:$ptr))>; def loadv2i64 : PatFrag<(ops node:$ptr), (v2i64 (load node:$ptr))>; -// FIXME: move this to a more appropriate place after all AVX is done. +// 256-bit load pattern fragments def loadv8f32 : PatFrag<(ops node:$ptr), (v8f32 (load node:$ptr))>; def loadv4f64 : PatFrag<(ops node:$ptr), (v4f64 (load node:$ptr))>; def loadv8i32 : PatFrag<(ops node:$ptr), (v8i32 (load node:$ptr))>; @@ -175,6 +176,8 @@ (f32 (alignedload node:$ptr))>; def alignedloadfsf64 : PatFrag<(ops node:$ptr), (f64 (alignedload node:$ptr))>; + +// 128-bit aligned load pattern fragments def alignedloadv4f32 : PatFrag<(ops node:$ptr), (v4f32 (alignedload node:$ptr))>; def alignedloadv2f64 : PatFrag<(ops node:$ptr), @@ -184,7 +187,7 @@ def alignedloadv2i64 : PatFrag<(ops node:$ptr), (v2i64 (alignedload node:$ptr))>; -// FIXME: move this to a more appropriate place after all AVX is done. +// 256-bit aligned load pattern fragments def alignedloadv8f32 : PatFrag<(ops node:$ptr), (v8f32 (alignedload node:$ptr))>; def alignedloadv4f64 : PatFrag<(ops node:$ptr), @@ -207,13 +210,15 @@ def memopfsf32 : PatFrag<(ops node:$ptr), (f32 (memop node:$ptr))>; def memopfsf64 : PatFrag<(ops node:$ptr), (f64 (memop node:$ptr))>; + +// 128-bit memop pattern fragments def memopv4f32 : PatFrag<(ops node:$ptr), (v4f32 (memop node:$ptr))>; def memopv2f64 : PatFrag<(ops node:$ptr), (v2f64 (memop node:$ptr))>; def memopv4i32 : PatFrag<(ops node:$ptr), (v4i32 (memop node:$ptr))>; def memopv2i64 : PatFrag<(ops node:$ptr), (v2i64 (memop node:$ptr))>; def memopv16i8 : PatFrag<(ops node:$ptr), (v16i8 (memop node:$ptr))>; -// FIXME: move this to a more appropriate place after all AVX is done. +// 256-bit memop pattern fragments def memopv32i8 : PatFrag<(ops node:$ptr), (v32i8 (memop node:$ptr))>; def memopv8f32 : PatFrag<(ops node:$ptr), (v8f32 (memop node:$ptr))>; def memopv4f64 : PatFrag<(ops node:$ptr), (v4f64 (memop node:$ptr))>; @@ -258,6 +263,7 @@ return false; }]>; +// 128-bit bitconvert pattern fragments def bc_v4f32 : PatFrag<(ops node:$in), (v4f32 (bitconvert node:$in))>; def bc_v2f64 : PatFrag<(ops node:$in), (v2f64 (bitconvert node:$in))>; def bc_v16i8 : PatFrag<(ops node:$in), (v16i8 (bitconvert node:$in))>; @@ -265,7 +271,7 @@ def bc_v4i32 : PatFrag<(ops node:$in), (v4i32 (bitconvert node:$in))>; def bc_v2i64 : PatFrag<(ops node:$in), (v2i64 (bitconvert node:$in))>; -// FIXME: move this to a more appropriate place after all AVX is done. +// 256-bit bitconvert pattern fragments def bc_v8i32 : PatFrag<(ops node:$in), (v8i32 (bitconvert node:$in))>; def vzmovl_v2i64 : PatFrag<(ops node:$src), From gohman at apple.com Fri Aug 13 16:17:19 2010 From: gohman at apple.com (Dan Gohman) Date: Fri, 13 Aug 2010 21:17:19 -0000 Subject: [llvm-commits] [llvm] r111042 - /llvm/trunk/lib/Transforms/Scalar/LoopStrengthReduce.cpp Message-ID: <20100813211719.330892A6C12C@llvm.org> Author: djg Date: Fri Aug 13 16:17:19 2010 New Revision: 111042 URL: http://llvm.org/viewvc/llvm-project?rev=111042&view=rev Log: Fix LSR's ExtractImmediate and ExtractSymbol to avoid calling ScalarEvolution::getAddExpr, which can be pretty expensive, when nothing has changed, which is pretty common. Modified: llvm/trunk/lib/Transforms/Scalar/LoopStrengthReduce.cpp Modified: llvm/trunk/lib/Transforms/Scalar/LoopStrengthReduce.cpp URL: http://llvm.org/viewvc/llvm-project/llvm/trunk/lib/Transforms/Scalar/LoopStrengthReduce.cpp?rev=111042&r1=111041&r2=111042&view=diff ============================================================================== --- llvm/trunk/lib/Transforms/Scalar/LoopStrengthReduce.cpp (original) +++ llvm/trunk/lib/Transforms/Scalar/LoopStrengthReduce.cpp Fri Aug 13 16:17:19 2010 @@ -505,12 +505,14 @@ } else if (const SCEVAddExpr *Add = dyn_cast(S)) { SmallVector NewOps(Add->op_begin(), Add->op_end()); int64_t Result = ExtractImmediate(NewOps.front(), SE); - S = SE.getAddExpr(NewOps); + if (Result != 0) + S = SE.getAddExpr(NewOps); return Result; } else if (const SCEVAddRecExpr *AR = dyn_cast(S)) { SmallVector NewOps(AR->op_begin(), AR->op_end()); int64_t Result = ExtractImmediate(NewOps.front(), SE); - S = SE.getAddRecExpr(NewOps, AR->getLoop()); + if (Result != 0) + S = SE.getAddRecExpr(NewOps, AR->getLoop()); return Result; } return 0; @@ -528,12 +530,14 @@ } else if (const SCEVAddExpr *Add = dyn_cast(S)) { SmallVector NewOps(Add->op_begin(), Add->op_end()); GlobalValue *Result = ExtractSymbol(NewOps.back(), SE); - S = SE.getAddExpr(NewOps); + if (Result) + S = SE.getAddExpr(NewOps); return Result; } else if (const SCEVAddRecExpr *AR = dyn_cast(S)) { SmallVector NewOps(AR->op_begin(), AR->op_end()); GlobalValue *Result = ExtractSymbol(NewOps.front(), SE); - S = SE.getAddRecExpr(NewOps, AR->getLoop()); + if (Result) + S = SE.getAddRecExpr(NewOps, AR->getLoop()); return Result; } return 0; From stoklund at 2pi.dk Fri Aug 13 16:18:48 2010 From: stoklund at 2pi.dk (Jakob Stoklund Olesen) Date: Fri, 13 Aug 2010 21:18:48 -0000 Subject: [llvm-commits] [llvm] r111043 - in /llvm/trunk/lib/CodeGen: InlineSpiller.cpp SplitKit.cpp SplitKit.h Message-ID: <20100813211848.EDA822A6C12C@llvm.org> Author: stoklund Date: Fri Aug 13 16:18:48 2010 New Revision: 111043 URL: http://llvm.org/viewvc/llvm-project?rev=111043&view=rev Log: Implement splitting inside a single block. When a live range is contained a single block, we can split it around instruction clusters. The current approach is very primitive, splitting before and after the largest gap between uses. Modified: llvm/trunk/lib/CodeGen/InlineSpiller.cpp llvm/trunk/lib/CodeGen/SplitKit.cpp llvm/trunk/lib/CodeGen/SplitKit.h Modified: llvm/trunk/lib/CodeGen/InlineSpiller.cpp URL: http://llvm.org/viewvc/llvm-project/llvm/trunk/lib/CodeGen/InlineSpiller.cpp?rev=111043&r1=111042&r2=111043&view=diff ============================================================================== --- llvm/trunk/lib/CodeGen/InlineSpiller.cpp (original) +++ llvm/trunk/lib/CodeGen/InlineSpiller.cpp Fri Aug 13 16:18:48 2010 @@ -106,10 +106,6 @@ /// split - try splitting the current interval into pieces that may allocate /// separately. Return true if successful. bool InlineSpiller::split() { - // FIXME: Add intra-MBB splitting. - if (lis_.intervalIsInOneMBB(*li_)) - return false; - splitAnalysis_.analyze(li_); if (const MachineLoop *loop = splitAnalysis_.getBestSplitLoop()) { @@ -127,6 +123,15 @@ return true; } + // Try splitting inside a basic block. + if (const MachineBasicBlock *MBB = splitAnalysis_.getBlockForInsideSplit()) { + if (SplitEditor(splitAnalysis_, lis_, vrm_, *newIntervals_) + .splitInsideBlock(MBB)) + return true; + } + + // We may have been able to split out some uses, but the original interval is + // intact, and it should still be spilled. return false; } Modified: llvm/trunk/lib/CodeGen/SplitKit.cpp URL: http://llvm.org/viewvc/llvm-project/llvm/trunk/lib/CodeGen/SplitKit.cpp?rev=111043&r1=111042&r2=111043&view=diff ============================================================================== --- llvm/trunk/lib/CodeGen/SplitKit.cpp (original) +++ llvm/trunk/lib/CodeGen/SplitKit.cpp Fri Aug 13 16:18:48 2010 @@ -781,3 +781,78 @@ return dupli_; } + +//===----------------------------------------------------------------------===// +// Sub Block Splitting +//===----------------------------------------------------------------------===// + +/// getBlockForInsideSplit - If curli is contained inside a single basic block, +/// and it wou pay to subdivide the interval inside that block, return it. +/// Otherwise return NULL. The returned block can be passed to +/// SplitEditor::splitInsideBlock. +const MachineBasicBlock *SplitAnalysis::getBlockForInsideSplit() { + // The interval must be exclusive to one block. + if (usingBlocks_.size() != 1) + return 0; + // Don't to this for less than 4 instructions. We want to be sure that + // splitting actually reduces the instruction count per interval. + if (usingInstrs_.size() < 4) + return 0; + return usingBlocks_.begin()->first; +} + +/// splitInsideBlock - Split curli into multiple intervals inside MBB. Return +/// true if curli has been completely replaced, false if curli is still +/// intact, and needs to be spilled or split further. +bool SplitEditor::splitInsideBlock(const MachineBasicBlock *MBB) { + SmallVector Uses; + Uses.reserve(sa_.usingInstrs_.size()); + for (SplitAnalysis::InstrPtrSet::const_iterator I = sa_.usingInstrs_.begin(), + E = sa_.usingInstrs_.end(); I != E; ++I) + if ((*I)->getParent() == MBB) + Uses.push_back(lis_.getInstructionIndex(*I)); + DEBUG(dbgs() << " splitInsideBlock BB#" << MBB->getNumber() << " for " + << Uses.size() << " instructions.\n"); + assert(Uses.size() >= 3 && "Need at least 3 instructions"); + array_pod_sort(Uses.begin(), Uses.end()); + + // Simple algorithm: Find the largest gap between uses as determined by slot + // indices. Create new intervals for instructions before the gap and after the + // gap. + unsigned bestPos = 0; + int bestGap = 0; + DEBUG(dbgs() << " dist (" << Uses[0]); + for (unsigned i = 1, e = Uses.size(); i != e; ++i) { + int g = Uses[i-1].distance(Uses[i]); + DEBUG(dbgs() << ") -" << g << "- (" << Uses[i]); + if (g > bestGap) + bestPos = i, bestGap = g; + } + DEBUG(dbgs() << "), best: -" << bestGap << "-\n"); + + // bestPos points to the first use after the best gap. + assert(bestPos > 0 && "Invalid gap"); + + // FIXME: Don't create intervals for low densities. + + // First interval before the gap. Don't create single-instr intervals. + if (bestPos > 1) { + openIntv(); + enterIntvBefore(Uses.front()); + useIntv(Uses.front().getBaseIndex(), Uses[bestPos-1].getBoundaryIndex()); + leaveIntvAfter(Uses[bestPos-1]); + closeIntv(); + } + + // Second interval after the gap. + if (bestPos < Uses.size()-1) { + openIntv(); + enterIntvBefore(Uses[bestPos]); + useIntv(Uses[bestPos].getBaseIndex(), Uses.back().getBoundaryIndex()); + leaveIntvAfter(Uses.back()); + closeIntv(); + } + + rewrite(); + return dupli_; +} Modified: llvm/trunk/lib/CodeGen/SplitKit.h URL: http://llvm.org/viewvc/llvm-project/llvm/trunk/lib/CodeGen/SplitKit.h?rev=111043&r1=111042&r2=111043&view=diff ============================================================================== --- llvm/trunk/lib/CodeGen/SplitKit.h (original) +++ llvm/trunk/lib/CodeGen/SplitKit.h Fri Aug 13 16:18:48 2010 @@ -127,6 +127,12 @@ /// having curli split to a new live interval. Return true if Blocks can be /// passed to SplitEditor::splitSingleBlocks. bool getMultiUseBlocks(BlockPtrSet &Blocks); + + /// getBlockForInsideSplit - If curli is contained inside a single basic block, + /// and it wou pay to subdivide the interval inside that block, return it. + /// Otherwise return NULL. The returned block can be passed to + /// SplitEditor::splitInsideBlock. + const MachineBasicBlock *getBlockForInsideSplit(); }; /// SplitEditor - Edit machine code and LiveIntervals for live range @@ -242,7 +248,11 @@ /// basic block in Blocks. Return true if curli has been completely replaced, /// false if curli is still intact, and needs to be spilled or split further. bool splitSingleBlocks(const SplitAnalysis::BlockPtrSet &Blocks); -}; + /// splitInsideBlock - Split curli into multiple intervals inside MBB. Return + /// true if curli has been completely replaced, false if curli is still + /// intact, and needs to be spilled or split further. + bool splitInsideBlock(const MachineBasicBlock *); +}; } From gohman at apple.com Fri Aug 13 16:24:58 2010 From: gohman at apple.com (Dan Gohman) Date: Fri, 13 Aug 2010 21:24:58 -0000 Subject: [llvm-commits] [llvm] r111045 - /llvm/trunk/lib/Analysis/ScalarEvolution.cpp Message-ID: <20100813212458.D7E212A6C12C@llvm.org> Author: djg Date: Fri Aug 13 16:24:58 2010 New Revision: 111045 URL: http://llvm.org/viewvc/llvm-project?rev=111045&view=rev Log: Various optimizations. Don't compare two loops' depths when they are the same loop. Don't compare two instructions' loop depths when they are in the same block. Modified: llvm/trunk/lib/Analysis/ScalarEvolution.cpp Modified: llvm/trunk/lib/Analysis/ScalarEvolution.cpp URL: http://llvm.org/viewvc/llvm-project/llvm/trunk/lib/Analysis/ScalarEvolution.cpp?rev=111045&r1=111044&r2=111045&view=diff ============================================================================== --- llvm/trunk/lib/Analysis/ScalarEvolution.cpp (original) +++ llvm/trunk/lib/Analysis/ScalarEvolution.cpp Fri Aug 13 16:24:58 2010 @@ -545,40 +545,45 @@ // not as complete as it could be. if (const SCEVUnknown *LU = dyn_cast(LHS)) { const SCEVUnknown *RU = cast(RHS); + const Value *LV = LU->getValue(), *RV = RU->getValue(); // Order pointer values after integer values. This helps SCEVExpander // form GEPs. - bool LIsPointer = LU->getType()->isPointerTy(), - RIsPointer = RU->getType()->isPointerTy(); + bool LIsPointer = LV->getType()->isPointerTy(), + RIsPointer = RV->getType()->isPointerTy(); if (LIsPointer != RIsPointer) return RIsPointer; // Compare getValueID values. - unsigned LID = LU->getValue()->getValueID(), - RID = RU->getValue()->getValueID(); + unsigned LID = LV->getValueID(), + RID = RV->getValueID(); if (LID != RID) return LID < RID; // Sort arguments by their position. - if (const Argument *LA = dyn_cast(LU->getValue())) { - const Argument *RA = cast(RU->getValue()); + if (const Argument *LA = dyn_cast(LV)) { + const Argument *RA = cast(RV); return LA->getArgNo() < RA->getArgNo(); } // For instructions, compare their loop depth, and their opcode. // This is pretty loose. - if (const Instruction *LV = dyn_cast(LU->getValue())) { - const Instruction *RV = cast(RU->getValue()); + if (const Instruction *LInst = dyn_cast(LV)) { + const Instruction *RInst = cast(RV); // Compare loop depths. - unsigned LDepth = LI->getLoopDepth(LV->getParent()), - RDepth = LI->getLoopDepth(RV->getParent()); - if (LDepth != RDepth) - return LDepth < RDepth; + const BasicBlock *LParent = LInst->getParent(), + *RParent = RInst->getParent(); + if (LParent != RParent) { + unsigned LDepth = LI->getLoopDepth(LParent), + RDepth = LI->getLoopDepth(RParent); + if (LDepth != RDepth) + return LDepth < RDepth; + } // Compare the number of operands. - unsigned LNumOps = LV->getNumOperands(), - RNumOps = RV->getNumOperands(); + unsigned LNumOps = LInst->getNumOperands(), + RNumOps = RInst->getNumOperands(); if (LNumOps != RNumOps) return LNumOps < RNumOps; } @@ -600,10 +605,13 @@ // Compare addrec loop depths. if (const SCEVAddRecExpr *LA = dyn_cast(LHS)) { const SCEVAddRecExpr *RA = cast(RHS); - unsigned LDepth = LA->getLoop()->getLoopDepth(), - RDepth = RA->getLoop()->getLoopDepth(); - if (LDepth != RDepth) - return LDepth < RDepth; + const Loop *LLoop = LA->getLoop(), *RLoop = RA->getLoop(); + if (LLoop != RLoop) { + unsigned LDepth = LLoop->getLoopDepth(), + RDepth = RLoop->getLoopDepth(); + if (LDepth != RDepth) + return LDepth < RDepth; + } } // Lexicographically compare n-ary expressions. From criswell at uiuc.edu Fri Aug 13 16:41:26 2010 From: criswell at uiuc.edu (John Criswell) Date: Fri, 13 Aug 2010 21:41:26 -0000 Subject: [llvm-commits] [poolalloc] r111046 - in /poolalloc/trunk: include/assistDS/Devirt.h lib/AssistDS/Devirt.cpp Message-ID: <20100813214126.2F4C72A6C12C@llvm.org> Author: criswell Date: Fri Aug 13 16:41:26 2010 New Revision: 111046 URL: http://llvm.org/viewvc/llvm-project?rev=111046&view=rev Log: Enhanced the devirtualizer to cache and reuse bounce functions when possible. This greatly reduces the number of bounce functions created (1538 to 34 for 254.gap) despite the fact that the function call target list much match exactly for two call sites to share the same bounce function. Modified: poolalloc/trunk/include/assistDS/Devirt.h poolalloc/trunk/lib/AssistDS/Devirt.cpp Modified: poolalloc/trunk/include/assistDS/Devirt.h URL: http://llvm.org/viewvc/llvm-project/poolalloc/trunk/include/assistDS/Devirt.h?rev=111046&r1=111045&r2=111046&view=diff ============================================================================== --- poolalloc/trunk/include/assistDS/Devirt.h (original) +++ poolalloc/trunk/include/assistDS/Devirt.h Fri Aug 13 16:41:26 2010 @@ -46,9 +46,14 @@ // Worklist of call sites to transform std::vector Worklist; + // A cache of indirect call targets that have been converted already + std::map > bounceCache; + protected: void makeDirectCall (CallSite & CS); Function* buildBounce (CallSite cs,std::vector& Targets); + const Function* findInCache (const CallSite & CS, + std::set& Targets); public: static char ID; Modified: poolalloc/trunk/lib/AssistDS/Devirt.cpp URL: http://llvm.org/viewvc/llvm-project/poolalloc/trunk/lib/AssistDS/Devirt.cpp?rev=111046&r1=111045&r2=111046&view=diff ============================================================================== --- poolalloc/trunk/lib/AssistDS/Devirt.cpp (original) +++ poolalloc/trunk/lib/AssistDS/Devirt.cpp Fri Aug 13 16:41:26 2010 @@ -75,6 +75,56 @@ } // +// Method: findInCache() +// +// Description: +// This method looks through the cache of bounce functions to see if there +// exists a bounce function for the specified call site. +// +// Return value: +// 0 - No usable bounce function has been created. +// Otherwise, a pointer to a bounce that can replace the call site is +// returned. +// +const Function * +Devirtualize::findInCache (const CallSite & CS, + std::set& Targets) { + // + // Iterate through all of the existing bounce functions to see if one of them + // can be resued. + // + std::map >::iterator I; + for (I = bounceCache.begin(); I != bounceCache.end(); ++I) { + // + // If the bounce function and the function pointer have different types, + // then skip this bounce function because it is incompatible. + // + const Function * bounceFunc = I->first; + + // Check the return type + if (CS.getType() != bounceFunc->getReturnType()) + continue; + + // Check the type of the function pointer and the arguments + if (CS.getCalledValue()->stripPointerCasts()->getType() != + bounceFunc->arg_begin()->getType()) + continue; + + // + // Determine whether the targets are identical. If so, then this function + // can be used as a bounce function for this call site. + // + if (Targets == I->second) + return I->first; + } + + // + // No suiteable bounce function was found. + // + return 0; +} + +// // Method: buildBounce() // // Description: @@ -252,10 +302,21 @@ // if (Targets.size() > 0) { // - // Build a function which will implement a switch statement. The switch - // statement will determine which function target to call and call it. + // Determine if an existing bounce function can be used for this call site. + // + std::set targetSet (Targets.begin(), Targets.end()); + const Function * NF = findInCache (CS, targetSet); + + // + // If no cached bounce function was found, build a function which will + // implement a switch statement. The switch statement will determine which + // function target to call and call it. // - Function* NF = buildBounce (CS, Targets); + if (!NF) { + // Build the bounce function and add it to the cache + NF = buildBounce (CS, Targets); + bounceCache[NF] = targetSet; + } // // Replace the original call with a call to the bounce function. @@ -263,7 +324,7 @@ if (CallInst* CI = dyn_cast(CS.getInstruction())) { std::vector Params (CI->op_begin(), CI->op_end()); std::string name = CI->hasName() ? CI->getNameStr() + ".dv" : ""; - CallInst* CN = CallInst::Create (NF, + CallInst* CN = CallInst::Create ((Value *) NF, Params.begin(), Params.end(), name, @@ -273,7 +334,7 @@ } else if (InvokeInst* CI = dyn_cast(CS.getInstruction())) { std::vector Params (CI->op_begin(), CI->op_end()); std::string name = CI->hasName() ? CI->getNameStr() + ".dv" : ""; - InvokeInst* CN = InvokeInst::Create(NF, + InvokeInst* CN = InvokeInst::Create((Value *) NF, CI->getNormalDest(), CI->getUnwindDest(), Params.begin(), From bob.wilson at apple.com Fri Aug 13 16:48:10 2010 From: bob.wilson at apple.com (Bob Wilson) Date: Fri, 13 Aug 2010 21:48:10 -0000 Subject: [llvm-commits] [llvm] r111047 - in /llvm/trunk: lib/Target/ARM/ARMInstrThumb2.td lib/Target/ARM/Disassembler/ThumbDisassemblerCore.h test/MC/Disassembler/thumb-tests.txt Message-ID: <20100813214810.555A32A6C12C@llvm.org> Author: bwilson Date: Fri Aug 13 16:48:10 2010 New Revision: 111047 URL: http://llvm.org/viewvc/llvm-project?rev=111047&view=rev Log: Move the Thumb2 SSAT and USAT optional shift operator out of the instruction opcode. This fixes part of PR7792. Modified: llvm/trunk/lib/Target/ARM/ARMInstrThumb2.td llvm/trunk/lib/Target/ARM/Disassembler/ThumbDisassemblerCore.h llvm/trunk/test/MC/Disassembler/thumb-tests.txt Modified: llvm/trunk/lib/Target/ARM/ARMInstrThumb2.td URL: http://llvm.org/viewvc/llvm-project/llvm/trunk/lib/Target/ARM/ARMInstrThumb2.td?rev=111047&r1=111046&r2=111047&view=diff ============================================================================== --- llvm/trunk/lib/Target/ARM/ARMInstrThumb2.td (original) +++ llvm/trunk/lib/Target/ARM/ARMInstrThumb2.td Fri Aug 13 16:48:10 2010 @@ -1510,24 +1510,13 @@ // Signed/Unsigned saturate -- for disassembly only -def t2SSATlsl:T2I<(outs rGPR:$dst), (ins i32imm:$bit_pos,rGPR:$a,i32imm:$shamt), - NoItinerary, "ssat", "\t$dst, $bit_pos, $a, lsl $shamt", - [/* For disassembly only; pattern left blank */]> { - let Inst{31-27} = 0b11110; - let Inst{25-22} = 0b1100; - let Inst{20} = 0; - let Inst{15} = 0; - let Inst{21} = 0; // sh = '0' -} - -def t2SSATasr:T2I<(outs rGPR:$dst), (ins i32imm:$bit_pos,rGPR:$a,i32imm:$shamt), - NoItinerary, "ssat", "\t$dst, $bit_pos, $a, asr $shamt", - [/* For disassembly only; pattern left blank */]> { +def t2SSAT: T2I<(outs rGPR:$dst), (ins i32imm:$bit_pos, rGPR:$a, sat_shift:$sh), + NoItinerary, "ssat", "\t$dst, $bit_pos, $a$sh", + [/* For disassembly only; pattern left blank */]> { let Inst{31-27} = 0b11110; let Inst{25-22} = 0b1100; let Inst{20} = 0; let Inst{15} = 0; - let Inst{21} = 1; // sh = '1' } def t2SSAT16: T2I<(outs rGPR:$dst), (ins i32imm:$bit_pos, rGPR:$a), NoItinerary, @@ -1542,24 +1531,13 @@ let Inst{7-6} = 0b00; // imm2 = '00' } -def t2USATlsl:T2I<(outs rGPR:$dst), (ins i32imm:$bit_pos,rGPR:$a,i32imm:$shamt), - NoItinerary, "usat", "\t$dst, $bit_pos, $a, lsl $shamt", - [/* For disassembly only; pattern left blank */]> { - let Inst{31-27} = 0b11110; - let Inst{25-22} = 0b1110; - let Inst{20} = 0; - let Inst{15} = 0; - let Inst{21} = 0; // sh = '0' -} - -def t2USATasr:T2I<(outs rGPR:$dst), (ins i32imm:$bit_pos,rGPR:$a,i32imm:$shamt), - NoItinerary, "usat", "\t$dst, $bit_pos, $a, asr $shamt", - [/* For disassembly only; pattern left blank */]> { +def t2USAT: T2I<(outs rGPR:$dst), (ins i32imm:$bit_pos, rGPR:$a, sat_shift:$sh), + NoItinerary, "usat", "\t$dst, $bit_pos, $a$sh", + [/* For disassembly only; pattern left blank */]> { let Inst{31-27} = 0b11110; let Inst{25-22} = 0b1110; let Inst{20} = 0; let Inst{15} = 0; - let Inst{21} = 1; // sh = '1' } def t2USAT16: T2I<(outs rGPR:$dst), (ins i32imm:$bit_pos, rGPR:$a), NoItinerary, @@ -1574,8 +1552,8 @@ let Inst{7-6} = 0b00; // imm2 = '00' } -def : T2Pat<(int_arm_ssat GPR:$a, imm:$pos), (t2SSATlsl imm:$pos, GPR:$a, 0)>; -def : T2Pat<(int_arm_usat GPR:$a, imm:$pos), (t2USATlsl imm:$pos, GPR:$a, 0)>; +def : T2Pat<(int_arm_ssat GPR:$a, imm:$pos), (t2SSAT imm:$pos, GPR:$a, 0)>; +def : T2Pat<(int_arm_usat GPR:$a, imm:$pos), (t2USAT imm:$pos, GPR:$a, 0)>; //===----------------------------------------------------------------------===// // Shift and rotate Instructions. Modified: llvm/trunk/lib/Target/ARM/Disassembler/ThumbDisassemblerCore.h URL: http://llvm.org/viewvc/llvm-project/llvm/trunk/lib/Target/ARM/Disassembler/ThumbDisassemblerCore.h?rev=111047&r1=111046&r2=111047&view=diff ============================================================================== --- llvm/trunk/lib/Target/ARM/Disassembler/ThumbDisassemblerCore.h (original) +++ llvm/trunk/lib/Target/ARM/Disassembler/ThumbDisassemblerCore.h Fri Aug 13 16:48:10 2010 @@ -1462,8 +1462,8 @@ static inline bool Thumb2SaturateOpcode(unsigned Opcode) { switch (Opcode) { - case ARM::t2SSATlsl: case ARM::t2SSATasr: case ARM::t2SSAT16: - case ARM::t2USATlsl: case ARM::t2USATasr: case ARM::t2USAT16: + case ARM::t2SSAT: case ARM::t2SSAT16: + case ARM::t2USAT: case ARM::t2USAT16: return true; default: return false; @@ -1471,7 +1471,7 @@ } /// DisassembleThumb2Sat - Disassemble Thumb2 saturate instructions: -/// o t2SSAT[lsl|asr], t2USAT[lsl|asr]: Rs sat_pos Rn shamt +/// o t2SSAT, t2USAT: Rs sat_pos Rn shamt /// o t2SSAT16, t2USAT16: Rs sat_pos Rn static bool DisassembleThumb2Sat(MCInst &MI, unsigned Opcode, uint32_t insn, unsigned &NumOpsAdded, BO B) { @@ -1483,9 +1483,7 @@ decodeRs(insn)))); unsigned Pos = slice(insn, 4, 0); - if (Opcode == ARM::t2SSATlsl || - Opcode == ARM::t2SSATasr || - Opcode == ARM::t2SSAT16) + if (Opcode == ARM::t2SSAT || Opcode == ARM::t2SSAT16) Pos += 1; MI.addOperand(MCOperand::CreateImm(Pos)); @@ -1493,11 +1491,17 @@ decodeRn(insn)))); if (NumOpsAdded == 4) { + ARM_AM::ShiftOpc Opc = (slice(insn, 21, 21) != 0 ? + ARM_AM::asr : ARM_AM::lsl); // Inst{14-12:7-6} encodes the imm5 shift amount. unsigned ShAmt = slice(insn, 14, 12) << 2 | slice(insn, 7, 6); - if ((Opcode == ARM::t2SSATasr || Opcode == ARM::t2USATasr) && ShAmt == 0) - ShAmt = 32; - MI.addOperand(MCOperand::CreateImm(ShAmt)); + if (ShAmt == 0) { + if (Opc == ARM_AM::asr) + ShAmt = 32; + else + Opc = ARM_AM::no_shift; + } + MI.addOperand(MCOperand::CreateImm(ARM_AM::getSORegOpc(Opc, ShAmt))); } return true; } Modified: llvm/trunk/test/MC/Disassembler/thumb-tests.txt URL: http://llvm.org/viewvc/llvm-project/llvm/trunk/test/MC/Disassembler/thumb-tests.txt?rev=111047&r1=111046&r2=111047&view=diff ============================================================================== --- llvm/trunk/test/MC/Disassembler/thumb-tests.txt (original) +++ llvm/trunk/test/MC/Disassembler/thumb-tests.txt Fri Aug 13 16:48:10 2010 @@ -51,6 +51,10 @@ # CHECK: rsbs r0, r0, #0 0x40 0x42 +# CHECK-NOT: ssat r0, #17, r12, lsl #0 +# CHECK: ssat r0, #17, r12 +0x0c 0xf3 0x10 0x00 + # CHECK: strd r0, [r7, #64] 0xc7 0xe9 0x10 0x01 From bob.wilson at apple.com Fri Aug 13 17:08:58 2010 From: bob.wilson at apple.com (Bob Wilson) Date: Fri, 13 Aug 2010 22:08:58 -0000 Subject: [llvm-commits] [llvm-gcc-4.2] r111048 - in /llvm-gcc-4.2/trunk/gcc: ChangeLog.apple config/i386/darwin.h config/rs6000/darwin.h Message-ID: <20100813220858.D52F92A6C12C@llvm.org> Author: bwilson Date: Fri Aug 13 17:08:58 2010 New Revision: 111048 URL: http://llvm.org/viewvc/llvm-project?rev=111048&view=rev Log: Radar 8309184: Merge fix for from gcc-4.2. Modified: llvm-gcc-4.2/trunk/gcc/ChangeLog.apple llvm-gcc-4.2/trunk/gcc/config/i386/darwin.h llvm-gcc-4.2/trunk/gcc/config/rs6000/darwin.h Modified: llvm-gcc-4.2/trunk/gcc/ChangeLog.apple URL: http://llvm.org/viewvc/llvm-project/llvm-gcc-4.2/trunk/gcc/ChangeLog.apple?rev=111048&r1=111047&r2=111048&view=diff ============================================================================== --- llvm-gcc-4.2/trunk/gcc/ChangeLog.apple (original) +++ llvm-gcc-4.2/trunk/gcc/ChangeLog.apple Fri Aug 13 17:08:58 2010 @@ -1,3 +1,10 @@ +2010-08-13 Bob Wilson + + Radar 8307333 + * config/i386/darwin.h (DARWIN_IPHONEOS_LIBGCC_SPEC): Do not link + against libgcc_s.10.5.dylib. + * config/rs6000/darwin.h (DARWIN_IPHONEOS_LIBGCC_SPEC): Likewise. + 2010-08-06 Jim Grosbach * config/arm/arm.c(arm_override_options): v7m only has thumb mode. Modified: llvm-gcc-4.2/trunk/gcc/config/i386/darwin.h URL: http://llvm.org/viewvc/llvm-project/llvm-gcc-4.2/trunk/gcc/config/i386/darwin.h?rev=111048&r1=111047&r2=111048&view=diff ============================================================================== --- llvm-gcc-4.2/trunk/gcc/config/i386/darwin.h (original) +++ llvm-gcc-4.2/trunk/gcc/config/i386/darwin.h Fri Aug 13 17:08:58 2010 @@ -138,8 +138,8 @@ #define DARWIN_DEFAULT_VERSION_TYPE DARWIN_VERSION_MACOSX /* APPLE LOCAL end ARM 5683689 */ -/* APPLE LOCAL ARM 5681645 */ -#define DARWIN_IPHONEOS_LIBGCC_SPEC "-lgcc_s.10.5 -lgcc" +/* APPLE LOCAL ARM 5681645 8307333 */ +#define DARWIN_IPHONEOS_LIBGCC_SPEC "-lgcc" /* APPLE LOCAL begin link optimizations 6499452 */ #undef DARWIN_CRT1_SPEC Modified: llvm-gcc-4.2/trunk/gcc/config/rs6000/darwin.h URL: http://llvm.org/viewvc/llvm-project/llvm-gcc-4.2/trunk/gcc/config/rs6000/darwin.h?rev=111048&r1=111047&r2=111048&view=diff ============================================================================== --- llvm-gcc-4.2/trunk/gcc/config/rs6000/darwin.h (original) +++ llvm-gcc-4.2/trunk/gcc/config/rs6000/darwin.h Fri Aug 13 17:08:58 2010 @@ -168,8 +168,8 @@ #define DARWIN_DEFAULT_VERSION_TYPE DARWIN_VERSION_MACOSX /* APPLE LOCAL end ARM 5683689 */ -/* APPLE LOCAL ARM 5681645 */ -#define DARWIN_IPHONEOS_LIBGCC_SPEC "-lgcc_s.10.5 -lgcc" +/* APPLE LOCAL ARM 5681645 8307333 */ +#define DARWIN_IPHONEOS_LIBGCC_SPEC "-lgcc" /* APPLE LOCAL begin 5342595 */ /* LLVM LOCAL begin */ From bob.wilson at apple.com Fri Aug 13 17:43:34 2010 From: bob.wilson at apple.com (Bob Wilson) Date: Fri, 13 Aug 2010 22:43:34 -0000 Subject: [llvm-commits] [llvm] r111050 - in /llvm/trunk: ./ lib/Target/ARM/ARMISelLowering.cpp test/CodeGen/ARM/2010-06-21-nondarwin-tc.ll test/CodeGen/ARM/call-tc.ll test/CodeGen/Thumb2/thumb2-call-tc.ll test/CodeGen/Thumb2/thumb2-ifcvt1-tc.ll Message-ID: <20100813224334.2C9982A6C12C@llvm.org> Author: bwilson Date: Fri Aug 13 17:43:33 2010 New Revision: 111050 URL: http://llvm.org/viewvc/llvm-project?rev=111050&view=rev Log: Temporarily disable tail calls on ARM to work around some linker problems. Modified: llvm/trunk/ (props changed) llvm/trunk/lib/Target/ARM/ARMISelLowering.cpp llvm/trunk/test/CodeGen/ARM/2010-06-21-nondarwin-tc.ll llvm/trunk/test/CodeGen/ARM/call-tc.ll llvm/trunk/test/CodeGen/Thumb2/thumb2-call-tc.ll llvm/trunk/test/CodeGen/Thumb2/thumb2-ifcvt1-tc.ll Propchange: llvm/trunk/ ------------------------------------------------------------------------------ svn:mergeinfo = /llvm/branches/Apple/Pertwee:110850,110961 Modified: llvm/trunk/lib/Target/ARM/ARMISelLowering.cpp URL: http://llvm.org/viewvc/llvm-project/llvm/trunk/lib/Target/ARM/ARMISelLowering.cpp?rev=111050&r1=111049&r2=111050&view=diff ============================================================================== --- llvm/trunk/lib/Target/ARM/ARMISelLowering.cpp (original) +++ llvm/trunk/lib/Target/ARM/ARMISelLowering.cpp Fri Aug 13 17:43:33 2010 @@ -51,6 +51,12 @@ STATISTIC(NumTailCalls, "Number of tail calls"); +// This option should go away when tail calls fully work. +static cl::opt +EnableARMTailCalls("arm-tail-calls", cl::Hidden, + cl::desc("Generate tail calls (TEMPORARY OPTION)."), + cl::init(false)); + // This option should go away when Machine LICM is smart enough to hoist a // reg-to-reg VDUP. static cl::opt @@ -1117,6 +1123,9 @@ MachineFunction &MF = DAG.getMachineFunction(); bool IsStructRet = (Outs.empty()) ? false : Outs[0].Flags.isSRet(); bool IsSibCall = false; + // Temporarily disable tail calls so things don't break. + if (!EnableARMTailCalls) + isTailCall = false; if (isTailCall) { // Check if it's really possible to do a tail call. isTailCall = IsEligibleForTailCallOptimization(Callee, CallConv, Modified: llvm/trunk/test/CodeGen/ARM/2010-06-21-nondarwin-tc.ll URL: http://llvm.org/viewvc/llvm-project/llvm/trunk/test/CodeGen/ARM/2010-06-21-nondarwin-tc.ll?rev=111050&r1=111049&r2=111050&view=diff ============================================================================== --- llvm/trunk/test/CodeGen/ARM/2010-06-21-nondarwin-tc.ll (original) +++ llvm/trunk/test/CodeGen/ARM/2010-06-21-nondarwin-tc.ll Fri Aug 13 17:43:33 2010 @@ -1,5 +1,6 @@ ; RUN: llc < %s -march=arm -mtriple=armv4t-unknown-linux-gnueabi | FileCheck %s ; PR 7433 +; XFAIL: * %0 = type { i8*, i8* } %1 = type { i8*, i8*, i8* } Modified: llvm/trunk/test/CodeGen/ARM/call-tc.ll URL: http://llvm.org/viewvc/llvm-project/llvm/trunk/test/CodeGen/ARM/call-tc.ll?rev=111050&r1=111049&r2=111050&view=diff ============================================================================== --- llvm/trunk/test/CodeGen/ARM/call-tc.ll (original) +++ llvm/trunk/test/CodeGen/ARM/call-tc.ll Fri Aug 13 17:43:33 2010 @@ -2,6 +2,7 @@ ; RUN: llc < %s -march=arm -mtriple=arm-apple-darwin -mattr=+v5t | FileCheck %s -check-prefix=CHECKV5 ; RUN: llc < %s -march=arm -mtriple=arm-linux-gnueabi\ ; RUN: -relocation-model=pic | FileCheck %s -check-prefix=CHECKELF +; XFAIL: * @t = weak global i32 ()* null ; [#uses=1] Modified: llvm/trunk/test/CodeGen/Thumb2/thumb2-call-tc.ll URL: http://llvm.org/viewvc/llvm-project/llvm/trunk/test/CodeGen/Thumb2/thumb2-call-tc.ll?rev=111050&r1=111049&r2=111050&view=diff ============================================================================== --- llvm/trunk/test/CodeGen/Thumb2/thumb2-call-tc.ll (original) +++ llvm/trunk/test/CodeGen/Thumb2/thumb2-call-tc.ll Fri Aug 13 17:43:33 2010 @@ -1,5 +1,6 @@ ; RUN: llc < %s -mtriple=thumbv7-apple-darwin -mattr=+thumb2 | FileCheck %s -check-prefix=DARWIN ; RUN: llc < %s -mtriple=thumbv7-linux -mattr=+thumb2 | FileCheck %s -check-prefix=LINUX +; XFAIL: * @t = weak global i32 ()* null ; [#uses=1] Modified: llvm/trunk/test/CodeGen/Thumb2/thumb2-ifcvt1-tc.ll URL: http://llvm.org/viewvc/llvm-project/llvm/trunk/test/CodeGen/Thumb2/thumb2-ifcvt1-tc.ll?rev=111050&r1=111049&r2=111050&view=diff ============================================================================== --- llvm/trunk/test/CodeGen/Thumb2/thumb2-ifcvt1-tc.ll (original) +++ llvm/trunk/test/CodeGen/Thumb2/thumb2-ifcvt1-tc.ll Fri Aug 13 17:43:33 2010 @@ -1,4 +1,5 @@ ; RUN: llc < %s -mtriple=thumbv7-apple-darwin | FileCheck %s +; XFAIL: * define i32 @t1(i32 %a, i32 %b, i32 %c, i32 %d) nounwind { ; CHECK: t1: From stoklund at 2pi.dk Fri Aug 13 17:56:53 2010 From: stoklund at 2pi.dk (Jakob Stoklund Olesen) Date: Fri, 13 Aug 2010 22:56:53 -0000 Subject: [llvm-commits] [llvm] r111055 - in /llvm/trunk/lib/CodeGen: InlineSpiller.cpp RegAllocLinearScan.cpp Spiller.cpp Spiller.h SplitKit.cpp SplitKit.h Message-ID: <20100813225653.CC14D2A6C12C@llvm.org> Author: stoklund Date: Fri Aug 13 17:56:53 2010 New Revision: 111055 URL: http://llvm.org/viewvc/llvm-project?rev=111055&view=rev Log: Clean up the Spiller.h interface. The earliestStart argument is entirely specific to linear scan allocation, and can be easily calculated by RegAllocLinearScan. Replace std::vector with SmallVector. Modified: llvm/trunk/lib/CodeGen/InlineSpiller.cpp llvm/trunk/lib/CodeGen/RegAllocLinearScan.cpp llvm/trunk/lib/CodeGen/Spiller.cpp llvm/trunk/lib/CodeGen/Spiller.h llvm/trunk/lib/CodeGen/SplitKit.cpp llvm/trunk/lib/CodeGen/SplitKit.h Modified: llvm/trunk/lib/CodeGen/InlineSpiller.cpp URL: http://llvm.org/viewvc/llvm-project/llvm/trunk/lib/CodeGen/InlineSpiller.cpp?rev=111055&r1=111054&r2=111055&view=diff ============================================================================== --- llvm/trunk/lib/CodeGen/InlineSpiller.cpp (original) +++ llvm/trunk/lib/CodeGen/InlineSpiller.cpp Fri Aug 13 17:56:53 2010 @@ -45,7 +45,7 @@ // Variables that are valid during spill(), but used by multiple methods. LiveInterval *li_; - std::vector *newIntervals_; + SmallVectorImpl *newIntervals_; const TargetRegisterClass *rc_; int stackSlot_; const SmallVectorImpl *spillIs_; @@ -75,9 +75,8 @@ splitAnalysis_(mf, lis_, loops_) {} void spill(LiveInterval *li, - std::vector &newIntervals, - SmallVectorImpl &spillIs, - SlotIndex *earliestIndex); + SmallVectorImpl &newIntervals, + SmallVectorImpl &spillIs); private: bool split(); @@ -388,9 +387,8 @@ } void InlineSpiller::spill(LiveInterval *li, - std::vector &newIntervals, - SmallVectorImpl &spillIs, - SlotIndex *earliestIndex) { + SmallVectorImpl &newIntervals, + SmallVectorImpl &spillIs) { DEBUG(dbgs() << "Inline spilling " << *li << "\n"); assert(li->isSpillable() && "Attempting to spill already spilled value."); assert(!li->isStackSlot() && "Trying to spill a stack slot."); Modified: llvm/trunk/lib/CodeGen/RegAllocLinearScan.cpp URL: http://llvm.org/viewvc/llvm-project/llvm/trunk/lib/CodeGen/RegAllocLinearScan.cpp?rev=111055&r1=111054&r2=111055&view=diff ============================================================================== --- llvm/trunk/lib/CodeGen/RegAllocLinearScan.cpp (original) +++ llvm/trunk/lib/CodeGen/RegAllocLinearScan.cpp Fri Aug 13 17:56:53 2010 @@ -1202,8 +1202,7 @@ // linearscan. if (cur->weight != HUGE_VALF && cur->weight <= minWeight) { DEBUG(dbgs() << "\t\t\tspilling(c): " << *cur << '\n'); - SmallVector spillIs; - std::vector added; + SmallVector spillIs, added; spiller_->spill(cur, added, spillIs); std::sort(added.begin(), added.end(), LISorter()); @@ -1268,25 +1267,31 @@ // in handled we need to roll back assert(!spillIs.empty() && "No spill intervals?"); SlotIndex earliestStart = spillIs[0]->beginIndex(); - + // Spill live intervals of virtual regs mapped to the physical register we // want to clear (and its aliases). We only spill those that overlap with the // current interval as the rest do not affect its allocation. we also keep // track of the earliest start of all spilled live intervals since this will // mark our rollback point. - std::vector added; + SmallVector added; while (!spillIs.empty()) { LiveInterval *sli = spillIs.back(); spillIs.pop_back(); DEBUG(dbgs() << "\t\t\tspilling(a): " << *sli << '\n'); if (sli->beginIndex() < earliestStart) earliestStart = sli->beginIndex(); - - spiller_->spill(sli, added, spillIs, &earliestStart); + spiller_->spill(sli, added, spillIs); addStackInterval(sli, ls_, li_, mri_, *vrm_); spilled.insert(sli->reg); } + // Include any added intervals in earliestStart. + for (unsigned i = 0, e = added.size(); i != e; ++i) { + SlotIndex SI = added[i]->beginIndex(); + if (SI < earliestStart) + earliestStart = SI; + } + DEBUG(dbgs() << "\t\trolling back to: " << earliestStart << '\n'); // Scan handled in reverse order up to the earliest start of a Modified: llvm/trunk/lib/CodeGen/Spiller.cpp URL: http://llvm.org/viewvc/llvm-project/llvm/trunk/lib/CodeGen/Spiller.cpp?rev=111055&r1=111054&r2=111055&view=diff ============================================================================== --- llvm/trunk/lib/CodeGen/Spiller.cpp (original) +++ llvm/trunk/lib/CodeGen/Spiller.cpp Fri Aug 13 17:56:53 2010 @@ -74,7 +74,7 @@ /// immediately before each use, and stores after each def. No folding or /// remat is attempted. void trivialSpillEverywhere(LiveInterval *li, - std::vector &newIntervals) { + SmallVectorImpl &newIntervals) { DEBUG(dbgs() << "Spilling everywhere " << *li << "\n"); assert(li->weight != HUGE_VALF && @@ -181,9 +181,8 @@ : SpillerBase(pass, mf, vrm) {} void spill(LiveInterval *li, - std::vector &newIntervals, - SmallVectorImpl &, - SlotIndex*) { + SmallVectorImpl &newIntervals, + SmallVectorImpl &) { // Ignore spillIs - we don't use it. trivialSpillEverywhere(li, newIntervals); } @@ -208,9 +207,8 @@ /// Falls back on LiveIntervals::addIntervalsForSpills. void spill(LiveInterval *li, - std::vector &newIntervals, - SmallVectorImpl &spillIs, - SlotIndex*) { + SmallVectorImpl &newIntervals, + SmallVectorImpl &spillIs) { std::vector added = lis->addIntervalsForSpills(*li, spillIs, loopInfo, *vrm); newIntervals.insert(newIntervals.end(), added.begin(), added.end()); @@ -236,13 +234,12 @@ } void spill(LiveInterval *li, - std::vector &newIntervals, - SmallVectorImpl &spillIs, - SlotIndex *earliestStart) { + SmallVectorImpl &newIntervals, + SmallVectorImpl &spillIs) { if (worthTryingToSplit(li)) - tryVNISplit(li, earliestStart); + tryVNISplit(li); else - StandardSpiller::spill(li, newIntervals, spillIs, earliestStart); + StandardSpiller::spill(li, newIntervals, spillIs); } private: @@ -257,8 +254,7 @@ } /// Try to break a LiveInterval into its component values. - std::vector tryVNISplit(LiveInterval *li, - SlotIndex *earliestStart) { + std::vector tryVNISplit(LiveInterval *li) { DEBUG(dbgs() << "Trying VNI split of %reg" << *li << "\n"); @@ -282,10 +278,6 @@ DEBUG(dbgs() << *splitInterval << "\n"); added.push_back(splitInterval); alreadySplit.insert(splitInterval); - if (earliestStart != 0) { - if (splitInterval->beginIndex() < *earliestStart) - *earliestStart = splitInterval->beginIndex(); - } } else { DEBUG(dbgs() << "0\n"); } @@ -298,10 +290,6 @@ if (!li->empty()) { added.push_back(li); alreadySplit.insert(li); - if (earliestStart != 0) { - if (li->beginIndex() < *earliestStart) - *earliestStart = li->beginIndex(); - } } return added; Modified: llvm/trunk/lib/CodeGen/Spiller.h URL: http://llvm.org/viewvc/llvm-project/llvm/trunk/lib/CodeGen/Spiller.h?rev=111055&r1=111054&r2=111055&view=diff ============================================================================== --- llvm/trunk/lib/CodeGen/Spiller.h (original) +++ llvm/trunk/lib/CodeGen/Spiller.h Fri Aug 13 17:56:53 2010 @@ -11,7 +11,6 @@ #define LLVM_CODEGEN_SPILLER_H #include "llvm/ADT/SmallVector.h" -#include namespace llvm { @@ -36,12 +35,9 @@ /// @param spillIs A list of intervals that are about to be spilled, /// and so cannot be used for remat etc. /// @param newIntervals The newly created intervals will be appended here. - /// @param earliestIndex The earliest point for splitting. (OK, it's another - /// pointer to the allocator guts). virtual void spill(LiveInterval *li, - std::vector &newIntervals, - SmallVectorImpl &spillIs, - SlotIndex *earliestIndex = 0) = 0; + SmallVectorImpl &newIntervals, + SmallVectorImpl &spillIs) = 0; }; Modified: llvm/trunk/lib/CodeGen/SplitKit.cpp URL: http://llvm.org/viewvc/llvm-project/llvm/trunk/lib/CodeGen/SplitKit.cpp?rev=111055&r1=111054&r2=111055&view=diff ============================================================================== --- llvm/trunk/lib/CodeGen/SplitKit.cpp (original) +++ llvm/trunk/lib/CodeGen/SplitKit.cpp Fri Aug 13 17:56:53 2010 @@ -342,7 +342,7 @@ /// Create a new SplitEditor for editing the LiveInterval analyzed by SA. SplitEditor::SplitEditor(SplitAnalysis &sa, LiveIntervals &lis, VirtRegMap &vrm, - std::vector &intervals) + SmallVectorImpl &intervals) : sa_(sa), lis_(lis), vrm_(vrm), mri_(vrm.getMachineFunction().getRegInfo()), tii_(*vrm.getMachineFunction().getTarget().getInstrInfo()), Modified: llvm/trunk/lib/CodeGen/SplitKit.h URL: http://llvm.org/viewvc/llvm-project/llvm/trunk/lib/CodeGen/SplitKit.h?rev=111055&r1=111054&r2=111055&view=diff ============================================================================== --- llvm/trunk/lib/CodeGen/SplitKit.h (original) +++ llvm/trunk/lib/CodeGen/SplitKit.h Fri Aug 13 17:56:53 2010 @@ -183,7 +183,7 @@ bool liveThrough_; /// All the new intervals created for this split are added to intervals_. - std::vector &intervals_; + SmallVectorImpl &intervals_; /// The index into intervals_ of the first interval we added. There may be /// others from before we got it. @@ -199,7 +199,7 @@ /// Create a new SplitEditor for editing the LiveInterval analyzed by SA. /// Newly created intervals will be appended to newIntervals. SplitEditor(SplitAnalysis &SA, LiveIntervals&, VirtRegMap&, - std::vector &newIntervals); + SmallVectorImpl &newIntervals); /// getAnalysis - Get the corresponding analysis. SplitAnalysis &getAnalysis() { return sa_; } From bob.wilson at apple.com Fri Aug 13 18:24:25 2010 From: bob.wilson at apple.com (Bob Wilson) Date: Fri, 13 Aug 2010 23:24:25 -0000 Subject: [llvm-commits] [llvm] r111057 - in /llvm/trunk: lib/Target/ARM/ARMInstrThumb2.td test/MC/Disassembler/thumb-tests.txt Message-ID: <20100813232425.DCC952A6C12C@llvm.org> Author: bwilson Date: Fri Aug 13 18:24:25 2010 New Revision: 111057 URL: http://llvm.org/viewvc/llvm-project?rev=111057&view=rev Log: Add a Thumb2 t2RSBrr instruction for disassembly only. This fixes another part of PR7792. Modified: llvm/trunk/lib/Target/ARM/ARMInstrThumb2.td llvm/trunk/test/MC/Disassembler/thumb-tests.txt Modified: llvm/trunk/lib/Target/ARM/ARMInstrThumb2.td URL: http://llvm.org/viewvc/llvm-project/llvm/trunk/lib/Target/ARM/ARMInstrThumb2.td?rev=111057&r1=111056&r2=111057&view=diff ============================================================================== --- llvm/trunk/lib/Target/ARM/ARMInstrThumb2.td (original) +++ llvm/trunk/lib/Target/ARM/ARMInstrThumb2.td Fri Aug 13 18:24:25 2010 @@ -259,9 +259,9 @@ T2I_bin_irs; /// T2I_rbin_is - Same as T2I_bin_irs except the order of operands are -/// reversed. It doesn't define the 'rr' form since it's handled by its -/// T2I_bin_irs counterpart. -multiclass T2I_rbin_is opcod, string opc, PatFrag opnode> { +/// reversed. The 'rr' form is only defined for the disassembler; for codegen +/// it is equivalent to the T2I_bin_irs counterpart. +multiclass T2I_rbin_irs opcod, string opc, PatFrag opnode> { // shifted imm def ri : T2sI<(outs rGPR:$dst), (ins rGPR:$rhs, t2_so_imm:$lhs), IIC_iALUi, opc, ".w\t$dst, $rhs, $lhs", @@ -272,6 +272,18 @@ let Inst{20} = ?; // The S bit. let Inst{15} = 0; } + // register + def rr : T2sI<(outs rGPR:$dst), (ins rGPR:$rhs, rGPR:$lhs), IIC_iALUr, + opc, "\t$dst, $rhs, $lhs", + [(set rGPR:$dst, (opnode rGPR:$lhs, rGPR:$rhs))]> { + let Inst{31-27} = 0b11101; + let Inst{26-25} = 0b01; + let Inst{24-21} = opcod; + let Inst{20} = ?; // The S bit. + let Inst{14-12} = 0b000; // imm3 + let Inst{7-6} = 0b00; // imm2 + let Inst{5-4} = 0b00; // type + } // shifted register def rs : T2sI<(outs rGPR:$dst), (ins rGPR:$rhs, t2_so_reg:$lhs), IIC_iALUsi, opc, "\t$dst, $rhs, $lhs", @@ -461,7 +473,8 @@ } } -/// T2I_rbin_s_is - Same as T2I_rbin_is except sets 's' bit. +/// T2I_rbin_s_is - Same as T2I_rbin_irs except sets 's' bit and the register +/// version is not needed since this is only for codegen. let Defs = [CPSR] in { multiclass T2I_rbin_s_is opcod, string opc, PatFrag opnode> { // shifted imm @@ -1387,7 +1400,7 @@ BinOpFrag<(sube_live_carry node:$LHS, node:$RHS)>>; // RSB -defm t2RSB : T2I_rbin_is <0b1110, "rsb", +defm t2RSB : T2I_rbin_irs <0b1110, "rsb", BinOpFrag<(sub node:$LHS, node:$RHS)>>; defm t2RSBS : T2I_rbin_s_is <0b1110, "rsb", BinOpFrag<(subc node:$LHS, node:$RHS)>>; Modified: llvm/trunk/test/MC/Disassembler/thumb-tests.txt URL: http://llvm.org/viewvc/llvm-project/llvm/trunk/test/MC/Disassembler/thumb-tests.txt?rev=111057&r1=111056&r2=111057&view=diff ============================================================================== --- llvm/trunk/test/MC/Disassembler/thumb-tests.txt (original) +++ llvm/trunk/test/MC/Disassembler/thumb-tests.txt Fri Aug 13 18:24:25 2010 @@ -51,6 +51,10 @@ # CHECK: rsbs r0, r0, #0 0x40 0x42 +# CHECK-NOT: rsb r0, r2, r0, lsl #0 +# CHECK: rsb r0, r2, r0 +0xc2 0xeb 0x00 0x00 + # CHECK-NOT: ssat r0, #17, r12, lsl #0 # CHECK: ssat r0, #17, r12 0x0c 0xf3 0x10 0x00 From deeppatel1987 at gmail.com Fri Aug 13 18:28:22 2010 From: deeppatel1987 at gmail.com (Sandeep Patel) Date: Fri, 13 Aug 2010 23:28:22 +0000 Subject: [llvm-commits] [llvm] r111050 - in /llvm/trunk: ./ lib/Target/ARM/ARMISelLowering.cpp test/CodeGen/ARM/2010-06-21-nondarwin-tc.ll test/CodeGen/ARM/call-tc.ll test/CodeGen/Thumb2/thumb2-call-tc.ll test/CodeGen/Thumb2/thumb2-ifcvt1-tc.ll In-Reply-To: <20100813224334.2C9982A6C12C@llvm.org> References: <20100813224334.2C9982A6C12C@llvm.org> Message-ID: This is only a problem with the Darwin linker, right? deep On Fri, Aug 13, 2010 at 10:43 PM, Bob Wilson wrote: > Author: bwilson > Date: Fri Aug 13 17:43:33 2010 > New Revision: 111050 > > URL: http://llvm.org/viewvc/llvm-project?rev=111050&view=rev > Log: > Temporarily disable tail calls on ARM to work around some linker problems. > > Modified: > ? ?llvm/trunk/ ? (props changed) > ? ?llvm/trunk/lib/Target/ARM/ARMISelLowering.cpp > ? ?llvm/trunk/test/CodeGen/ARM/2010-06-21-nondarwin-tc.ll > ? ?llvm/trunk/test/CodeGen/ARM/call-tc.ll > ? ?llvm/trunk/test/CodeGen/Thumb2/thumb2-call-tc.ll > ? ?llvm/trunk/test/CodeGen/Thumb2/thumb2-ifcvt1-tc.ll > > Propchange: llvm/trunk/ > ------------------------------------------------------------------------------ > ? ?svn:mergeinfo = /llvm/branches/Apple/Pertwee:110850,110961 > > Modified: llvm/trunk/lib/Target/ARM/ARMISelLowering.cpp > URL: http://llvm.org/viewvc/llvm-project/llvm/trunk/lib/Target/ARM/ARMISelLowering.cpp?rev=111050&r1=111049&r2=111050&view=diff > ============================================================================== > --- llvm/trunk/lib/Target/ARM/ARMISelLowering.cpp (original) > +++ llvm/trunk/lib/Target/ARM/ARMISelLowering.cpp Fri Aug 13 17:43:33 2010 > @@ -51,6 +51,12 @@ > > ?STATISTIC(NumTailCalls, "Number of tail calls"); > > +// This option should go away when tail calls fully work. > +static cl::opt > +EnableARMTailCalls("arm-tail-calls", cl::Hidden, > + ?cl::desc("Generate tail calls (TEMPORARY OPTION)."), > + ?cl::init(false)); > + > ?// This option should go away when Machine LICM is smart enough to hoist a > ?// reg-to-reg VDUP. > ?static cl::opt > @@ -1117,6 +1123,9 @@ > ? MachineFunction &MF = DAG.getMachineFunction(); > ? bool IsStructRet ? ?= (Outs.empty()) ? false : Outs[0].Flags.isSRet(); > ? bool IsSibCall = false; > + ?// Temporarily disable tail calls so things don't break. > + ?if (!EnableARMTailCalls) > + ? ?isTailCall = false; > ? if (isTailCall) { > ? ? // Check if it's really possible to do a tail call. > ? ? isTailCall = IsEligibleForTailCallOptimization(Callee, CallConv, > > Modified: llvm/trunk/test/CodeGen/ARM/2010-06-21-nondarwin-tc.ll > URL: http://llvm.org/viewvc/llvm-project/llvm/trunk/test/CodeGen/ARM/2010-06-21-nondarwin-tc.ll?rev=111050&r1=111049&r2=111050&view=diff > ============================================================================== > --- llvm/trunk/test/CodeGen/ARM/2010-06-21-nondarwin-tc.ll (original) > +++ llvm/trunk/test/CodeGen/ARM/2010-06-21-nondarwin-tc.ll Fri Aug 13 17:43:33 2010 > @@ -1,5 +1,6 @@ > ?; RUN: llc < %s -march=arm -mtriple=armv4t-unknown-linux-gnueabi ?| FileCheck %s > ?; PR 7433 > +; XFAIL: * > > ?%0 = type { i8*, i8* } > ?%1 = type { i8*, i8*, i8* } > > Modified: llvm/trunk/test/CodeGen/ARM/call-tc.ll > URL: http://llvm.org/viewvc/llvm-project/llvm/trunk/test/CodeGen/ARM/call-tc.ll?rev=111050&r1=111049&r2=111050&view=diff > ============================================================================== > --- llvm/trunk/test/CodeGen/ARM/call-tc.ll (original) > +++ llvm/trunk/test/CodeGen/ARM/call-tc.ll Fri Aug 13 17:43:33 2010 > @@ -2,6 +2,7 @@ > ?; RUN: llc < %s -march=arm -mtriple=arm-apple-darwin -mattr=+v5t | FileCheck %s -check-prefix=CHECKV5 > ?; RUN: llc < %s -march=arm -mtriple=arm-linux-gnueabi\ > ?; RUN: ? -relocation-model=pic | FileCheck %s -check-prefix=CHECKELF > +; XFAIL: * > > ?@t = weak global i32 ()* null ? ? ? ? ? ; [#uses=1] > > > Modified: llvm/trunk/test/CodeGen/Thumb2/thumb2-call-tc.ll > URL: http://llvm.org/viewvc/llvm-project/llvm/trunk/test/CodeGen/Thumb2/thumb2-call-tc.ll?rev=111050&r1=111049&r2=111050&view=diff > ============================================================================== > --- llvm/trunk/test/CodeGen/Thumb2/thumb2-call-tc.ll (original) > +++ llvm/trunk/test/CodeGen/Thumb2/thumb2-call-tc.ll Fri Aug 13 17:43:33 2010 > @@ -1,5 +1,6 @@ > ?; RUN: llc < %s -mtriple=thumbv7-apple-darwin -mattr=+thumb2 | FileCheck %s -check-prefix=DARWIN > ?; RUN: llc < %s -mtriple=thumbv7-linux -mattr=+thumb2 | FileCheck %s -check-prefix=LINUX > +; XFAIL: * > > ?@t = weak global i32 ()* null ? ? ? ? ? ; [#uses=1] > > > Modified: llvm/trunk/test/CodeGen/Thumb2/thumb2-ifcvt1-tc.ll > URL: http://llvm.org/viewvc/llvm-project/llvm/trunk/test/CodeGen/Thumb2/thumb2-ifcvt1-tc.ll?rev=111050&r1=111049&r2=111050&view=diff > ============================================================================== > --- llvm/trunk/test/CodeGen/Thumb2/thumb2-ifcvt1-tc.ll (original) > +++ llvm/trunk/test/CodeGen/Thumb2/thumb2-ifcvt1-tc.ll Fri Aug 13 17:43:33 2010 > @@ -1,4 +1,5 @@ > ?; RUN: llc < %s -mtriple=thumbv7-apple-darwin | FileCheck %s > +; XFAIL: * > > ?define i32 @t1(i32 %a, i32 %b, i32 %c, i32 %d) nounwind { > ?; CHECK: t1: > > > _______________________________________________ > llvm-commits mailing list > llvm-commits at cs.uiuc.edu > http://lists.cs.uiuc.edu/mailman/listinfo/llvm-commits > From dalej at apple.com Fri Aug 13 18:37:50 2010 From: dalej at apple.com (Dale Johannesen) Date: Fri, 13 Aug 2010 16:37:50 -0700 Subject: [llvm-commits] [llvm] r111050 - in /llvm/trunk: ./ lib/Target/ARM/ARMISelLowering.cpp test/CodeGen/ARM/2010-06-21-nondarwin-tc.ll test/CodeGen/ARM/call-tc.ll test/CodeGen/Thumb2/thumb2-call-tc.ll test/CodeGen/Thumb2/thumb2-ifcvt1-tc.ll In-Reply-To: References: <20100813224334.2C9982A6C12C@llvm.org> Message-ID: On Aug 13, 2010, at 4:28 PMPDT, Sandeep Patel wrote: > This is only a problem with the Darwin linker, right? > > deep Yes. If somebody wants to conditionally enable it for non-Darwin, that will probably work OK. We can't test it here though. > On Fri, Aug 13, 2010 at 10:43 PM, Bob Wilson > wrote: >> Author: bwilson >> Date: Fri Aug 13 17:43:33 2010 >> New Revision: 111050 >> >> URL: http://llvm.org/viewvc/llvm-project?rev=111050&view=rev >> Log: >> Temporarily disable tail calls on ARM to work around some linker >> problems. >> >> Modified: >> llvm/trunk/ (props changed) >> llvm/trunk/lib/Target/ARM/ARMISelLowering.cpp >> llvm/trunk/test/CodeGen/ARM/2010-06-21-nondarwin-tc.ll >> llvm/trunk/test/CodeGen/ARM/call-tc.ll >> llvm/trunk/test/CodeGen/Thumb2/thumb2-call-tc.ll >> llvm/trunk/test/CodeGen/Thumb2/thumb2-ifcvt1-tc.ll >> >> Propchange: llvm/trunk/ >> ------------------------------------------------------------------------------ >> svn:mergeinfo = /llvm/branches/Apple/Pertwee:110850,110961 >> >> Modified: llvm/trunk/lib/Target/ARM/ARMISelLowering.cpp >> URL: http://llvm.org/viewvc/llvm-project/llvm/trunk/lib/Target/ARM/ARMISelLowering.cpp?rev=111050&r1=111049&r2=111050&view=diff >> = >> = >> = >> = >> = >> = >> = >> = >> = >> ===================================================================== >> --- llvm/trunk/lib/Target/ARM/ARMISelLowering.cpp (original) >> +++ llvm/trunk/lib/Target/ARM/ARMISelLowering.cpp Fri Aug 13 >> 17:43:33 2010 >> @@ -51,6 +51,12 @@ >> >> STATISTIC(NumTailCalls, "Number of tail calls"); >> >> +// This option should go away when tail calls fully work. >> +static cl::opt >> +EnableARMTailCalls("arm-tail-calls", cl::Hidden, >> + cl::desc("Generate tail calls (TEMPORARY OPTION)."), >> + cl::init(false)); >> + >> // This option should go away when Machine LICM is smart enough to >> hoist a >> // reg-to-reg VDUP. >> static cl::opt >> @@ -1117,6 +1123,9 @@ >> MachineFunction &MF = DAG.getMachineFunction(); >> bool IsStructRet = (Outs.empty()) ? false : >> Outs[0].Flags.isSRet(); >> bool IsSibCall = false; >> + // Temporarily disable tail calls so things don't break. >> + if (!EnableARMTailCalls) >> + isTailCall = false; >> if (isTailCall) { >> // Check if it's really possible to do a tail call. >> isTailCall = IsEligibleForTailCallOptimization(Callee, CallConv, >> >> Modified: llvm/trunk/test/CodeGen/ARM/2010-06-21-nondarwin-tc.ll >> URL: http://llvm.org/viewvc/llvm-project/llvm/trunk/test/CodeGen/ARM/2010-06-21-nondarwin-tc.ll?rev=111050&r1=111049&r2=111050&view=diff >> = >> = >> = >> = >> = >> = >> = >> = >> = >> ===================================================================== >> --- llvm/trunk/test/CodeGen/ARM/2010-06-21-nondarwin-tc.ll (original) >> +++ llvm/trunk/test/CodeGen/ARM/2010-06-21-nondarwin-tc.ll Fri Aug >> 13 17:43:33 2010 >> @@ -1,5 +1,6 @@ >> ; RUN: llc < %s -march=arm -mtriple=armv4t-unknown-linux-gnueabi >> | FileCheck %s >> ; PR 7433 >> +; XFAIL: * >> >> %0 = type { i8*, i8* } >> %1 = type { i8*, i8*, i8* } >> >> Modified: llvm/trunk/test/CodeGen/ARM/call-tc.ll >> URL: http://llvm.org/viewvc/llvm-project/llvm/trunk/test/CodeGen/ARM/call-tc.ll?rev=111050&r1=111049&r2=111050&view=diff >> = >> = >> = >> = >> = >> = >> = >> = >> = >> ===================================================================== >> --- llvm/trunk/test/CodeGen/ARM/call-tc.ll (original) >> +++ llvm/trunk/test/CodeGen/ARM/call-tc.ll Fri Aug 13 17:43:33 2010 >> @@ -2,6 +2,7 @@ >> ; RUN: llc < %s -march=arm -mtriple=arm-apple-darwin -mattr=+v5t | >> FileCheck %s -check-prefix=CHECKV5 >> ; RUN: llc < %s -march=arm -mtriple=arm-linux-gnueabi\ >> ; RUN: -relocation-model=pic | FileCheck %s -check-prefix=CHECKELF >> +; XFAIL: * >> >> @t = weak global i32 ()* null ; [#uses=1] >> >> >> Modified: llvm/trunk/test/CodeGen/Thumb2/thumb2-call-tc.ll >> URL: http://llvm.org/viewvc/llvm-project/llvm/trunk/test/CodeGen/Thumb2/thumb2-call-tc.ll?rev=111050&r1=111049&r2=111050&view=diff >> = >> = >> = >> = >> = >> = >> = >> = >> = >> ===================================================================== >> --- llvm/trunk/test/CodeGen/Thumb2/thumb2-call-tc.ll (original) >> +++ llvm/trunk/test/CodeGen/Thumb2/thumb2-call-tc.ll Fri Aug 13 >> 17:43:33 2010 >> @@ -1,5 +1,6 @@ >> ; RUN: llc < %s -mtriple=thumbv7-apple-darwin -mattr=+thumb2 | >> FileCheck %s -check-prefix=DARWIN >> ; RUN: llc < %s -mtriple=thumbv7-linux -mattr=+thumb2 | FileCheck >> %s -check-prefix=LINUX >> +; XFAIL: * >> >> @t = weak global i32 ()* null ; [#uses=1] >> >> >> Modified: llvm/trunk/test/CodeGen/Thumb2/thumb2-ifcvt1-tc.ll >> URL: http://llvm.org/viewvc/llvm-project/llvm/trunk/test/CodeGen/Thumb2/thumb2-ifcvt1-tc.ll?rev=111050&r1=111049&r2=111050&view=diff >> = >> = >> = >> = >> = >> = >> = >> = >> = >> ===================================================================== >> --- llvm/trunk/test/CodeGen/Thumb2/thumb2-ifcvt1-tc.ll (original) >> +++ llvm/trunk/test/CodeGen/Thumb2/thumb2-ifcvt1-tc.ll Fri Aug 13 >> 17:43:33 2010 >> @@ -1,4 +1,5 @@ >> ; RUN: llc < %s -mtriple=thumbv7-apple-darwin | FileCheck %s >> +; XFAIL: * >> >> define i32 @t1(i32 %a, i32 %b, i32 %c, i32 %d) nounwind { >> ; CHECK: t1: >> >> >> _______________________________________________ >> llvm-commits mailing list >> llvm-commits at cs.uiuc.edu >> http://lists.cs.uiuc.edu/mailman/listinfo/llvm-commits >> > > _______________________________________________ > llvm-commits mailing list > llvm-commits at cs.uiuc.edu > http://lists.cs.uiuc.edu/mailman/listinfo/llvm-commits From dirty at apple.com Fri Aug 13 18:44:24 2010 From: dirty at apple.com (Cameron Esfahani) Date: Fri, 13 Aug 2010 16:44:24 -0700 Subject: [llvm-commits] Win64 pseudo instruction patch In-Reply-To: References: <00C68A18-199E-429D-A0A5-2BBDCC219A03@apple.com> <65130661-7848-4A1E-AABE-10A450BFED22@apple.com> Message-ID: <2551EF63-6AD8-412F-976E-41AF7B7951ED@apple.com> New patch, based on svn 111057: > Hello, Cameron > > > Attached is a patch which fixes some more of the Win64 ABI code gen. Added support for the Windows 64 pseudo instructions like WINTAILJMPd64 and WINCALL64pcrel32. > > > > Also, updated a little bit of the coff-dump.py tool to dump the AMD64 relocations. Updated COFF.h to list the AMD64 relocations. > > > > Still a bit more to do before Win64 COFFs work... > Please next time submit unrelated changes (e.g. MC changes vs tail > call stuff changes) as separate patches for the sake of easier review. > > >+ bool AfterFPPop = Opc == X86::TAILJMPm64 || Opc == X86::TAILJMPm || > >+ Opc == X86::WINTAILJMPm64; > Is it possible to factor out the predicates of such sort into some > external predicate function? Something like "IsTAILJUMPMemOpcode()" or > whatever? > Done. I've created some helper routines to manage the different flavors of the TAILJUMP AND TCRETURN pseudo opcodes. > >- } else if (Subtarget->isTargetWin64()) { > >- // We need to always allocate 32 bytes as register spill area. > >- // FIXME: We might reuse these 32 bytes for leaf functions. > >- StackSize += 32; > >- MFI->setStackSize(StackSize); > > } > As I already mentioned, this part is invalid. Consider the following > case: you have two functions A and B with A calling B. B does regs > dump into register save area. Since you haven't allocated the space on > stack for register save area then B will clobber 16 bytes on local > frame of A. This is definitely not what you will want. > Ok, I've backed this out. There were some weird things I saw when generating Win64 code, which is why I took it out in the first place. I'll try and figure it out in the future. > >- RetOpcode == X86::TCRETURNmi64) { > >- bool isMem = RetOpcode == X86::TCRETURNmi || RetOpcode == X86::TCRETURNmi64; > >+ RetOpcode == X86::TCRETURNmi64 || > >+ RetOpcode == X86::WINTCRETURNri64 || RetOpcode == X86::WINTCRETURNdi64 || > >+ RetOpcode == X86::WINTCRETURNmi64) { > >+ bool isMem = RetOpcode == X86::TCRETURNmi || RetOpcode == X86::TCRETURNmi64 || > >+ RetOpcode == X86::WINTCRETURNmi64; > Same as above. > > > + if (RetOpcode == X86::TCRETURNdi) > > + Opcode = X86::TAILJMPd; > > + else > > + Opcode = (IsWin64 ? X86::WINTAILJMPd64 : X86::TAILJMPd64); > Also deserves some helper for such mapping? E.g. "TailCallIMapImmOpcode" ? > This should be resolved with the new helper routines. > -- > With best regards, Anton Korobeynikov > Faculty of Mathematics and Mechanics, Saint Petersburg State University On Aug 12, 2010, at 6:47 PM, Cameron Esfahani wrote: > New patch, based on SVN revision 110995: > > Cameron Esfahani dirty at apple.com "All that is necessary for the triumph of evil is that good men do nothing." Edmund Burke -------------- next part -------------- An HTML attachment was scrubbed... URL: http://lists.cs.uiuc.edu/pipermail/llvm-commits/attachments/20100813/1d04cb36/attachment.html -------------- next part -------------- A non-text attachment was scrubbed... Name: pseudo2.patch Type: application/octet-stream Size: 20878 bytes Desc: not available Url : http://lists.cs.uiuc.edu/pipermail/llvm-commits/attachments/20100813/1d04cb36/attachment.obj -------------- next part -------------- An HTML attachment was scrubbed... URL: http://lists.cs.uiuc.edu/pipermail/llvm-commits/attachments/20100813/1d04cb36/attachment-0001.html From gohman at apple.com Fri Aug 13 18:56:29 2010 From: gohman at apple.com (Dan Gohman) Date: Fri, 13 Aug 2010 23:56:29 -0000 Subject: [llvm-commits] [llvm] r111058 - in /llvm/trunk: lib/Analysis/Lint.cpp test/Other/lint.ll Message-ID: <20100813235629.1A6BA2A6C12C@llvm.org> Author: djg Date: Fri Aug 13 18:56:28 2010 New Revision: 111058 URL: http://llvm.org/viewvc/llvm-project?rev=111058&view=rev Log: Add a lint check for an indirectbr destination which has not had its address taken. Modified: llvm/trunk/lib/Analysis/Lint.cpp llvm/trunk/test/Other/lint.ll Modified: llvm/trunk/lib/Analysis/Lint.cpp URL: http://llvm.org/viewvc/llvm-project/llvm/trunk/lib/Analysis/Lint.cpp?rev=111058&r1=111057&r2=111058&view=diff ============================================================================== --- llvm/trunk/lib/Analysis/Lint.cpp (original) +++ llvm/trunk/lib/Analysis/Lint.cpp Fri Aug 13 18:56:28 2010 @@ -521,6 +521,12 @@ Assert1(I.getNumDestinations() != 0, "Undefined behavior: indirectbr with no destinations", &I); + + for (unsigned i = 0, e = I.getNumDestinations(); i != e; ++i) + Assert1(I.getDestination(i)->hasAddressTaken(), + "Unusual: indirectbr destination has not " + "had its address taken", + &I); } void Lint::visitExtractElementInst(ExtractElementInst &I) { Modified: llvm/trunk/test/Other/lint.ll URL: http://llvm.org/viewvc/llvm-project/llvm/trunk/test/Other/lint.ll?rev=111058&r1=111057&r2=111058&view=diff ============================================================================== --- llvm/trunk/test/Other/lint.ll (original) +++ llvm/trunk/test/Other/lint.ll Fri Aug 13 18:56:28 2010 @@ -102,6 +102,7 @@ } ; CHECK: Undefined behavior: Branch to non-blockaddress +; CHECK: Unusual: indirectbr destination has not had its address taken define void @use_indbr() { indirectbr i8* bitcast (i32()* @foo to i8*), [label %block] block: From grosbach at apple.com Fri Aug 13 19:15:52 2010 From: grosbach at apple.com (Jim Grosbach) Date: Sat, 14 Aug 2010 00:15:52 -0000 Subject: [llvm-commits] [llvm] r111059 - in /llvm/trunk: include/llvm/CodeGen/MachineFrameInfo.h include/llvm/CodeGen/Passes.h lib/CodeGen/CMakeLists.txt lib/CodeGen/LLVMTargetMachine.cpp lib/CodeGen/LocalStackSlotAllocation.cpp lib/CodeGen/PrologEpilogInserter.cpp Message-ID: <20100814001552.62BB92A6C12C@llvm.org> Author: grosbach Date: Fri Aug 13 19:15:52 2010 New Revision: 111059 URL: http://llvm.org/viewvc/llvm-project?rev=111059&view=rev Log: Add a local stack object block allocation pass. This is still an experimental pass that allocates locals relative to one another before register allocation and then assigns them to actual stack slots as a block later in PEI. This will eventually allow targets with limited index offset range to allocate additional base registers (not just FP and SP) to more efficiently reference locals, as well as handle situations where locals cannot be referenced via SP or FP at all (dynamic stack realignment together with variable sized objects, for example). It's currently incomplete and almost certainly buggy. Work in progress. Disabled by default and gated via the -enable-local-stack-alloc command line option. rdar://8277890 Added: llvm/trunk/lib/CodeGen/LocalStackSlotAllocation.cpp Modified: llvm/trunk/include/llvm/CodeGen/MachineFrameInfo.h llvm/trunk/include/llvm/CodeGen/Passes.h llvm/trunk/lib/CodeGen/CMakeLists.txt llvm/trunk/lib/CodeGen/LLVMTargetMachine.cpp llvm/trunk/lib/CodeGen/PrologEpilogInserter.cpp Modified: llvm/trunk/include/llvm/CodeGen/MachineFrameInfo.h URL: http://llvm.org/viewvc/llvm-project/llvm/trunk/include/llvm/CodeGen/MachineFrameInfo.h?rev=111059&r1=111058&r2=111059&view=diff ============================================================================== --- llvm/trunk/include/llvm/CodeGen/MachineFrameInfo.h (original) +++ llvm/trunk/include/llvm/CodeGen/MachineFrameInfo.h Fri Aug 13 19:15:52 2010 @@ -15,6 +15,7 @@ #define LLVM_CODEGEN_MACHINEFRAMEINFO_H #include "llvm/ADT/SmallVector.h" +//#include "llvm/ADT/IndexedMap.h" #include "llvm/System/DataTypes.h" #include #include @@ -103,10 +104,14 @@ // protector. bool MayNeedSP; + // PreAllocated - If true, the object was mapped into the local frame + // block and doesn't need additional handling for allocation beyond that. + bool PreAllocated; + StackObject(uint64_t Sz, unsigned Al, int64_t SP, bool IM, bool isSS, bool NSP) : SPOffset(SP), Size(Sz), Alignment(Al), isImmutable(IM), - isSpillSlot(isSS), MayNeedSP(NSP) {} + isSpillSlot(isSS), MayNeedSP(NSP), PreAllocated(false) {} }; /// Objects - The list of stack objects allocated... @@ -195,8 +200,20 @@ /// const TargetFrameInfo &TFI; + /// LocalFrameObjects - References to frame indices which are mapped + /// into the local frame allocation block. + SmallVector, 32> LocalFrameObjects; + + /// LocalFrameSize - Size of the pre-allocated local frame block. + int64_t LocalFrameSize; + + /// LocalFrameBaseOffset - The base offset from the stack pointer at + /// function entry of the local frame blob. Set by PEI for use by + /// target in eliminateFrameIndex(). + int64_t LocalFrameBaseOffset; + public: - explicit MachineFrameInfo(const TargetFrameInfo &tfi) : TFI(tfi) { + explicit MachineFrameInfo(const TargetFrameInfo &tfi) : TFI(tfi) { StackSize = NumFixedObjects = OffsetAdjustment = MaxAlignment = 0; HasVarSizedObjects = false; FrameAddressTaken = false; @@ -206,6 +223,8 @@ StackProtectorIdx = -1; MaxCallFrameSize = 0; CSIValid = false; + LocalFrameSize = 0; + LocalFrameBaseOffset = 0; } /// hasStackObjects - Return true if there are any stack objects in this @@ -252,6 +271,42 @@ /// unsigned getNumObjects() const { return Objects.size(); } + /// mapLocalFrameObject - Map a frame index into the local object block + void mapLocalFrameObject(int ObjectIndex, int64_t Offset) { + LocalFrameObjects.push_back(std::pair(ObjectIndex, Offset)); + Objects[ObjectIndex + NumFixedObjects].PreAllocated = true; + } + + /// getLocalFrameObjectMap - Get the local offset mapping for a for an object + std::pair getLocalFrameObjectMap(int i) { + assert (i >= 0 && (unsigned)i < LocalFrameObjects.size() && + "Invalid local object reference!"); + return LocalFrameObjects[i]; + } + + /// getLocalFrameObjectCount - Return the number of objects allocated into + /// the local object block. + int64_t getLocalFrameObjectCount() { return LocalFrameObjects.size(); } + + /// setLocalFrameBaseOffset - Set the base SP offset of the local frame + /// blob. + void setLocalFrameBaseOffset(int64_t o) { LocalFrameBaseOffset = o; } + + /// getLocalFrameBaseOffset - Get the base SP offset of the local frame + /// blob. + int64_t getLocalFrameBaseOffset() const { return LocalFrameBaseOffset; } + + /// getLocalFrameSize - Get the size of the local object blob. + int64_t getLocalFrameSize() const { return LocalFrameSize; } + + /// isObjectPreAllocated - Return true if the object was pre-allocated into + /// the local block. + bool isObjectPreAllocated(int ObjectIdx) const { + assert(unsigned(ObjectIdx+NumFixedObjects) < Objects.size() && + "Invalid Object Idx!"); + return Objects[ObjectIdx+NumFixedObjects].PreAllocated; + } + /// getObjectSize - Return the size of the specified object. /// int64_t getObjectSize(int ObjectIdx) const { Modified: llvm/trunk/include/llvm/CodeGen/Passes.h URL: http://llvm.org/viewvc/llvm-project/llvm/trunk/include/llvm/CodeGen/Passes.h?rev=111059&r1=111058&r2=111059&view=diff ============================================================================== --- llvm/trunk/include/llvm/CodeGen/Passes.h (original) +++ llvm/trunk/include/llvm/CodeGen/Passes.h Fri Aug 13 19:15:52 2010 @@ -198,6 +198,13 @@ /// the GCC-style builtin setjmp/longjmp (sjlj) to handling EH control flow. FunctionPass *createSjLjEHPass(const TargetLowering *tli); + /// createLocalStackSlotAllocationPass - This pass assigns local frame + /// indices to stack slots relative to one another and allocates + /// base registers to access them when it is estimated by the target to + /// be out of range of normal frame pointer or stack pointer index + /// addressing. + FunctionPass *createLocalStackSlotAllocationPass(); + } // End llvm namespace #endif Modified: llvm/trunk/lib/CodeGen/CMakeLists.txt URL: http://llvm.org/viewvc/llvm-project/llvm/trunk/lib/CodeGen/CMakeLists.txt?rev=111059&r1=111058&r2=111059&view=diff ============================================================================== --- llvm/trunk/lib/CodeGen/CMakeLists.txt (original) +++ llvm/trunk/lib/CodeGen/CMakeLists.txt Fri Aug 13 19:15:52 2010 @@ -22,6 +22,7 @@ LiveIntervalAnalysis.cpp LiveStackAnalysis.cpp LiveVariables.cpp + LocalStackAllocation.cpp LowerSubregs.cpp MachineBasicBlock.cpp MachineCSE.cpp Modified: llvm/trunk/lib/CodeGen/LLVMTargetMachine.cpp URL: http://llvm.org/viewvc/llvm-project/llvm/trunk/lib/CodeGen/LLVMTargetMachine.cpp?rev=111059&r1=111058&r2=111059&view=diff ============================================================================== --- llvm/trunk/lib/CodeGen/LLVMTargetMachine.cpp (original) +++ llvm/trunk/lib/CodeGen/LLVMTargetMachine.cpp Fri Aug 13 19:15:52 2010 @@ -74,6 +74,16 @@ static cl::opt VerifyMachineCode("verify-machineinstrs", cl::Hidden, cl::desc("Verify generated machine code"), cl::init(getenv("LLVM_VERIFY_MACHINEINSTRS")!=NULL)); +// Enabled or disable local stack object block allocation. This is an +// experimental pass that allocates locals relative to one another before +// register allocation and then assigns them to actual stack slots as a block +// later in PEI. This will eventually allow targets with limited index offset +// range to allocate additional base registers (not just FP and SP) to +// more efficiently reference locals, as well as handle situations where +// locals cannot be referenced via SP or FP at all (dynamic stack realignment +// together with variable sized objects, for example). +cl::opt EnableLocalStackAlloc("enable-local-stack-alloc", cl::init(false), + cl::Hidden, cl::desc("Enable pre-regalloc stack frame index allocation")); static cl::opt AsmVerbose("asm-verbose", cl::desc("Add comments to directives."), @@ -344,6 +354,12 @@ if (OptLevel != CodeGenOpt::None) PM.add(createOptimizePHIsPass()); + // Assign local variables to stack slots relative to one another and simplify + // frame index references where possible. Final stack slot locations will be + // assigned in PEI. + if (EnableLocalStackAlloc) + PM.add(createLocalStackSlotAllocationPass()); + if (OptLevel != CodeGenOpt::None) { // With optimization, dead code should already be eliminated. However // there is one known exception: lowered code for arguments that are only Added: llvm/trunk/lib/CodeGen/LocalStackSlotAllocation.cpp URL: http://llvm.org/viewvc/llvm-project/llvm/trunk/lib/CodeGen/LocalStackSlotAllocation.cpp?rev=111059&view=auto ============================================================================== --- llvm/trunk/lib/CodeGen/LocalStackSlotAllocation.cpp (added) +++ llvm/trunk/lib/CodeGen/LocalStackSlotAllocation.cpp Fri Aug 13 19:15:52 2010 @@ -0,0 +1,169 @@ +//===- LocalStackSlotAllocation.cpp - Pre-allocate locals to stack slots --===// +// +// The LLVM Compiler Infrastructure +// +// This file is distributed under the University of Illinois Open Source +// License. See LICENSE.TXT for details. +// +//===----------------------------------------------------------------------===// +// +// This pass assigns local frame indices to stack slots relative to one another +// and allocates additional base registers to access them when the target +// estimates the are likely to be out of range of stack pointer and frame +// pointer relative addressing. +// +//===----------------------------------------------------------------------===// + +#define DEBUG_TYPE "localstackalloc" +#include "llvm/Constants.h" +#include "llvm/DerivedTypes.h" +#include "llvm/Instructions.h" +#include "llvm/Intrinsics.h" +#include "llvm/ADT/Statistic.h" +#include "llvm/LLVMContext.h" +#include "llvm/Module.h" +#include "llvm/Pass.h" +#include "llvm/ADT/SmallSet.h" +#include "llvm/CodeGen/MachineFrameInfo.h" +#include "llvm/CodeGen/MachineFunction.h" +#include "llvm/CodeGen/MachineFunctionPass.h" +#include "llvm/CodeGen/Passes.h" +#include "llvm/Support/Debug.h" +#include "llvm/Support/ErrorHandling.h" +#include "llvm/Support/raw_ostream.h" +#include "llvm/Target/TargetRegisterInfo.h" +#include "llvm/Target/TargetFrameInfo.h" + +using namespace llvm; + +STATISTIC(NumAllocations, "Number of frame indices processed"); + +namespace { + class LocalStackSlotPass: public MachineFunctionPass { + int64_t LocalStackSize; + + void calculateFrameObjectOffsets(MachineFunction &Fn); + public: + static char ID; // Pass identification, replacement for typeid + explicit LocalStackSlotPass() : MachineFunctionPass(ID) { } + bool runOnMachineFunction(MachineFunction &MF); + + virtual void getAnalysisUsage(AnalysisUsage &AU) const { + AU.setPreservesCFG(); + MachineFunctionPass::getAnalysisUsage(AU); + } + const char *getPassName() const { + return "Local Stack Slot Allocation"; + } + + private: + }; +} // end anonymous namespace + +char LocalStackSlotPass::ID = 0; + +FunctionPass *llvm::createLocalStackSlotAllocationPass() { + return new LocalStackSlotPass(); +} + +bool LocalStackSlotPass::runOnMachineFunction(MachineFunction &MF) { + calculateFrameObjectOffsets(MF); + DEBUG(dbgs() << LocalStackSize << " bytes of local storage pre-allocated\n"); + return true; +} + +/// AdjustStackOffset - Helper function used to adjust the stack frame offset. +static inline void +AdjustStackOffset(MachineFrameInfo *MFI, int FrameIdx, int64_t &Offset, + unsigned &MaxAlign) { + unsigned Align = MFI->getObjectAlignment(FrameIdx); + + // If the alignment of this object is greater than that of the stack, then + // increase the stack alignment to match. + MaxAlign = std::max(MaxAlign, Align); + + // Adjust to alignment boundary. + Offset = (Offset + Align - 1) / Align * Align; + + DEBUG(dbgs() << "Allocate FI(" << FrameIdx << ") to local offset " + << Offset << "\n"); + MFI->mapLocalFrameObject(FrameIdx, Offset); + Offset += MFI->getObjectSize(FrameIdx); + + ++NumAllocations; +} + +/// calculateFrameObjectOffsets - Calculate actual frame offsets for all of the +/// abstract stack objects. +/// +void LocalStackSlotPass::calculateFrameObjectOffsets(MachineFunction &Fn) { + const TargetFrameInfo &TFI = *Fn.getTarget().getFrameInfo(); + + // Loop over all of the stack objects, assigning sequential addresses... + MachineFrameInfo *MFI = Fn.getFrameInfo(); + int64_t Offset = 0; + unsigned MaxAlign = MFI->getMaxAlignment(); + + // Make sure that the stack protector comes before the local variables on the + // stack. + SmallSet LargeStackObjs; + if (MFI->getStackProtectorIndex() >= 0) { + AdjustStackOffset(MFI, MFI->getStackProtectorIndex(), Offset, MaxAlign); + + // Assign large stack objects first. + for (unsigned i = 0, e = MFI->getObjectIndexEnd(); i != e; ++i) { + if (MFI->isDeadObjectIndex(i)) + continue; + if (MFI->getStackProtectorIndex() == (int)i) + continue; + if (!MFI->MayNeedStackProtector(i)) + continue; + + AdjustStackOffset(MFI, i, Offset, MaxAlign); + LargeStackObjs.insert(i); + } + } + + // Then assign frame offsets to stack objects that are not used to spill + // callee saved registers. + for (unsigned i = 0, e = MFI->getObjectIndexEnd(); i != e; ++i) { + if (MFI->isDeadObjectIndex(i)) + continue; + if (MFI->getStackProtectorIndex() == (int)i) + continue; + if (LargeStackObjs.count(i)) + continue; + + AdjustStackOffset(MFI, i, Offset, MaxAlign); + } + + const TargetRegisterInfo *RegInfo = Fn.getTarget().getRegisterInfo(); + if (!RegInfo->targetHandlesStackFrameRounding()) { + // If we have reserved argument space for call sites in the function + // immediately on entry to the current function, count it as part of the + // overall stack size. + if (MFI->adjustsStack() && RegInfo->hasReservedCallFrame(Fn)) + Offset += MFI->getMaxCallFrameSize(); + + // Round up the size to a multiple of the alignment. If the function has + // any calls or alloca's, align to the target's StackAlignment value to + // ensure that the callee's frame or the alloca data is suitably aligned; + // otherwise, for leaf functions, align to the TransientStackAlignment + // value. + unsigned StackAlign; + if (MFI->adjustsStack() || MFI->hasVarSizedObjects() || + (RegInfo->needsStackRealignment(Fn) && MFI->getObjectIndexEnd() != 0)) + StackAlign = TFI.getStackAlignment(); + else + StackAlign = TFI.getTransientStackAlignment(); + + // If the frame pointer is eliminated, all frame offsets will be relative to + // SP not FP. Align to MaxAlign so this works. + StackAlign = std::max(StackAlign, MaxAlign); + unsigned AlignMask = StackAlign - 1; + Offset = (Offset + AlignMask) & ~uint64_t(AlignMask); + } + + // Remember how big this blob of stack space is + LocalStackSize = Offset; +} Modified: llvm/trunk/lib/CodeGen/PrologEpilogInserter.cpp URL: http://llvm.org/viewvc/llvm-project/llvm/trunk/lib/CodeGen/PrologEpilogInserter.cpp?rev=111059&r1=111058&r2=111059&view=diff ============================================================================== --- llvm/trunk/lib/CodeGen/PrologEpilogInserter.cpp (original) +++ llvm/trunk/lib/CodeGen/PrologEpilogInserter.cpp Fri Aug 13 19:15:52 2010 @@ -19,6 +19,7 @@ // //===----------------------------------------------------------------------===// +#define DEBUG_TYPE "pei" #include "PrologEpilogInserter.h" #include "llvm/CodeGen/MachineDominators.h" #include "llvm/CodeGen/MachineLoopInfo.h" @@ -32,6 +33,7 @@ #include "llvm/Target/TargetInstrInfo.h" #include "llvm/Support/CommandLine.h" #include "llvm/Support/Compiler.h" +#include "llvm/Support/Debug.h" #include "llvm/ADT/IndexedMap.h" #include "llvm/ADT/SmallSet.h" #include "llvm/ADT/STLExtras.h" @@ -39,6 +41,10 @@ using namespace llvm; +// FIXME: For testing purposes only. Remove once the pre-allocation pass +// is done. +extern cl::opt EnableLocalStackAlloc; + char PEI::ID = 0; INITIALIZE_PASS(PEI, "prologepilog", @@ -462,8 +468,10 @@ Offset = (Offset + Align - 1) / Align * Align; if (StackGrowsDown) { + DEBUG(dbgs() << "alloc FI(" << FrameIdx << ") at SP[" << -Offset << "]\n"); MFI->setObjectOffset(FrameIdx, -Offset); // Set the computed offset } else { + DEBUG(dbgs() << "alloc FI(" << FrameIdx << ") at SP[" << Offset << "]\n"); MFI->setObjectOffset(FrameIdx, Offset); Offset += MFI->getObjectSize(FrameIdx); } @@ -548,6 +556,26 @@ AdjustStackOffset(MFI, SFI, StackGrowsDown, Offset, MaxAlign); } + // Store the offset of the start of the local allocation block. This + // will be used later when resolving frame base virtual register pseudos. + MFI->setLocalFrameBaseOffset(Offset); + if (EnableLocalStackAlloc) { + // Allocate the local block + Offset += MFI->getLocalFrameSize(); + + // Resolve offsets for objects in the local block. + for (unsigned i = 0, e = MFI->getLocalFrameObjectCount(); i != e; ++i) { + std::pair Entry = MFI->getLocalFrameObjectMap(i); + int64_t FIOffset = MFI->getLocalFrameBaseOffset() + Entry.second; + + AdjustStackOffset(MFI, Entry.first, StackGrowsDown, FIOffset, MaxAlign); + } + } + // FIXME: Allocate locals. Once the block allocation pass is turned on, + // this simplifies to just the second loop, since all of the large objects + // will have already been handled. The second loop can also simplify a + // bit, as the conditionals inside aren't all necessary. + // Make sure that the stack protector comes before the local variables on the // stack. SmallSet LargeStackObjs; @@ -557,6 +585,8 @@ // Assign large stack objects first. for (unsigned i = 0, e = MFI->getObjectIndexEnd(); i != e; ++i) { + if (MFI->isObjectPreAllocated(i)) + continue; if (i >= MinCSFrameIndex && i <= MaxCSFrameIndex) continue; if (RS && (int)i == RS->getScavengingFrameIndex()) @@ -576,6 +606,8 @@ // Then assign frame offsets to stack objects that are not used to spill // callee saved registers. for (unsigned i = 0, e = MFI->getObjectIndexEnd(); i != e; ++i) { + if (MFI->isObjectPreAllocated(i)) + continue; if (i >= MinCSFrameIndex && i <= MaxCSFrameIndex) continue; if (RS && (int)i == RS->getScavengingFrameIndex()) From gohman at apple.com Fri Aug 13 19:29:42 2010 From: gohman at apple.com (Dan Gohman) Date: Sat, 14 Aug 2010 00:29:42 -0000 Subject: [llvm-commits] [llvm] r111060 - in /llvm/trunk: include/llvm/Transforms/Utils/Local.h lib/Transforms/Scalar/SimplifyCFGPass.cpp lib/Transforms/Utils/Local.cpp lib/Transforms/Utils/SimplifyCFG.cpp test/Transforms/SimplifyCFG/basictest.ll test/Transforms/SimplifyCFG/indirectbr.ll Message-ID: <20100814002942.B101D2A6C12C@llvm.org> Author: djg Date: Fri Aug 13 19:29:42 2010 New Revision: 111060 URL: http://llvm.org/viewvc/llvm-project?rev=111060&view=rev Log: Teach SimplifyCFG how to simplify indirectbr instructions. - Eliminate redundant successors. - Convert an indirectbr with one successor into a direct branch. Also, generalize SimplifyCFG to be able to be run on a function entry block. It knows quite a few simplifications which are applicable to the entry block, and it only needs a few checks to avoid trouble with the entry block. Added: llvm/trunk/test/Transforms/SimplifyCFG/indirectbr.ll Modified: llvm/trunk/include/llvm/Transforms/Utils/Local.h llvm/trunk/lib/Transforms/Scalar/SimplifyCFGPass.cpp llvm/trunk/lib/Transforms/Utils/Local.cpp llvm/trunk/lib/Transforms/Utils/SimplifyCFG.cpp llvm/trunk/test/Transforms/SimplifyCFG/basictest.ll Modified: llvm/trunk/include/llvm/Transforms/Utils/Local.h URL: http://llvm.org/viewvc/llvm-project/llvm/trunk/include/llvm/Transforms/Utils/Local.h?rev=111060&r1=111059&r2=111060&view=diff ============================================================================== --- llvm/trunk/include/llvm/Transforms/Utils/Local.h (original) +++ llvm/trunk/include/llvm/Transforms/Utils/Local.h Fri Aug 13 19:29:42 2010 @@ -118,8 +118,6 @@ /// of the CFG. It returns true if a modification was made, possibly deleting /// the basic block that was pointed to. /// -/// WARNING: The entry node of a method may not be simplified. -/// bool SimplifyCFG(BasicBlock *BB, const TargetData *TD = 0); /// FoldBranchToCommonDest - If this basic block is ONLY a setcc and a branch, Modified: llvm/trunk/lib/Transforms/Scalar/SimplifyCFGPass.cpp URL: http://llvm.org/viewvc/llvm-project/llvm/trunk/lib/Transforms/Scalar/SimplifyCFGPass.cpp?rev=111060&r1=111059&r2=111060&view=diff ============================================================================== --- llvm/trunk/lib/Transforms/Scalar/SimplifyCFGPass.cpp (original) +++ llvm/trunk/lib/Transforms/Scalar/SimplifyCFGPass.cpp Fri Aug 13 19:29:42 2010 @@ -285,10 +285,9 @@ while (LocalChange) { LocalChange = false; - // Loop over all of the basic blocks (except the first one) and remove them - // if they are unneeded... + // Loop over all of the basic blocks and remove them if they are unneeded... // - for (Function::iterator BBIt = ++F.begin(); BBIt != F.end(); ) { + for (Function::iterator BBIt = F.begin(); BBIt != F.end(); ) { if (SimplifyCFG(BBIt++, TD)) { LocalChange = true; ++NumSimpl; Modified: llvm/trunk/lib/Transforms/Utils/Local.cpp URL: http://llvm.org/viewvc/llvm-project/llvm/trunk/lib/Transforms/Utils/Local.cpp?rev=111060&r1=111059&r2=111060&view=diff ============================================================================== --- llvm/trunk/lib/Transforms/Utils/Local.cpp (original) +++ llvm/trunk/lib/Transforms/Utils/Local.cpp Fri Aug 13 19:29:42 2010 @@ -490,6 +490,9 @@ /// rewriting all the predecessors to branch to the successor block and return /// true. If we can't transform, return false. bool llvm::TryToSimplifyUncondBranchFromEmptyBlock(BasicBlock *BB) { + assert(BB != &BB->getParent()->getEntryBlock() && + "TryToSimplifyUncondBranchFromEmptyBlock called on entry block!"); + // We can't eliminate infinite loops. BasicBlock *Succ = cast(BB->getTerminator())->getSuccessor(0); if (BB == Succ) return false; Modified: llvm/trunk/lib/Transforms/Utils/SimplifyCFG.cpp URL: http://llvm.org/viewvc/llvm-project/llvm/trunk/lib/Transforms/Utils/SimplifyCFG.cpp?rev=111060&r1=111059&r2=111060&view=diff ============================================================================== --- llvm/trunk/lib/Transforms/Utils/SimplifyCFG.cpp (original) +++ llvm/trunk/lib/Transforms/Utils/SimplifyCFG.cpp Fri Aug 13 19:29:42 2010 @@ -1724,12 +1724,12 @@ assert(BB && BB->getParent() && "Block not embedded in function!"); assert(BB->getTerminator() && "Degenerate basic block encountered!"); - assert(&BB->getParent()->getEntryBlock() != BB && - "Can't Simplify entry block!"); - // Remove basic blocks that have no predecessors... or that just have themself - // as a predecessor. These are unreachable. - if (pred_begin(BB) == pred_end(BB) || BB->getSinglePredecessor() == BB) { + // Remove basic blocks that have no predecessors (except the entry block)... + // or that just have themself as a predecessor. These are unreachable. + if ((pred_begin(BB) == pred_end(BB) && + &BB->getParent()->getEntryBlock() != BB) || + BB->getSinglePredecessor() == BB) { DEBUG(dbgs() << "Removing BB: \n" << *BB); DeleteDeadBlock(BB); return true; @@ -1880,8 +1880,9 @@ while (isa(BBI)) ++BBI; if (BBI->isTerminator()) // Terminator is the only non-phi instruction! - if (TryToSimplifyUncondBranchFromEmptyBlock(BB)) - return true; + if (BB != &BB->getParent()->getEntryBlock()) + if (TryToSimplifyUncondBranchFromEmptyBlock(BB)) + return true; } else { // Conditional branch if (isValueEqualityComparison(BI)) { @@ -2049,12 +2050,37 @@ } // If this block is now dead, remove it. - if (pred_begin(BB) == pred_end(BB)) { + if (pred_begin(BB) == pred_end(BB) && + BB != &BB->getParent()->getEntryBlock()) { // We know there are no successors, so just nuke the block. M->getBasicBlockList().erase(BB); return true; } } + } else if (IndirectBrInst *IBI = dyn_cast(BB->getTerminator())) { + // Eliminate redundant destinations. + SmallPtrSet Succs; + for (unsigned i = 0, e = IBI->getNumDestinations(); i != e; ++i) { + BasicBlock *Dest = IBI->getDestination(i); + if (!Succs.insert(Dest)) { + Dest->removePredecessor(BB); + IBI->removeDestination(i); + --i; --e; + Changed = true; + } + } + + if (IBI->getNumDestinations() == 0) { + // If the indirectbr has no successors, change it to unreachable. + new UnreachableInst(IBI->getContext(), IBI); + IBI->eraseFromParent(); + Changed = true; + } else if (IBI->getNumDestinations() == 1) { + // If the indirectbr has one successor, change it to a direct branch. + BranchInst::Create(IBI->getDestination(0), IBI); + IBI->eraseFromParent(); + Changed = true; + } } // Merge basic blocks into their predecessor if there is only one distinct @@ -2068,12 +2094,15 @@ // is a conditional branch, see if we can hoist any code from this block up // into our predecessor. pred_iterator PI(pred_begin(BB)), PE(pred_end(BB)); - BasicBlock *OnlyPred = *PI++; - for (; PI != PE; ++PI) // Search all predecessors, see if they are all same - if (*PI != OnlyPred) { + BasicBlock *OnlyPred = 0; + for (; PI != PE; ++PI) { // Search all predecessors, see if they are all same + if (!OnlyPred) + OnlyPred = *PI; + else if (*PI != OnlyPred) { OnlyPred = 0; // There are multiple different predecessors... break; } + } if (OnlyPred) if (BranchInst *BI = dyn_cast(OnlyPred->getTerminator())) @@ -2172,8 +2201,6 @@ /// eliminates unreachable basic blocks, and does other "peephole" optimization /// of the CFG. It returns true if a modification was made. /// -/// WARNING: The entry node of a function may not be simplified. -/// bool llvm::SimplifyCFG(BasicBlock *BB, const TargetData *TD) { return SimplifyCFGOpt(TD).run(BB); } Modified: llvm/trunk/test/Transforms/SimplifyCFG/basictest.ll URL: http://llvm.org/viewvc/llvm-project/llvm/trunk/test/Transforms/SimplifyCFG/basictest.ll?rev=111060&r1=111059&r2=111060&view=diff ============================================================================== --- llvm/trunk/test/Transforms/SimplifyCFG/basictest.ll (original) +++ llvm/trunk/test/Transforms/SimplifyCFG/basictest.ll Fri Aug 13 19:29:42 2010 @@ -54,6 +54,5 @@ return: ; preds = %entry ret void ; CHECK: @test5 -; CHECK-NEXT: bb: ; CHECK-NEXT: ret void } Added: llvm/trunk/test/Transforms/SimplifyCFG/indirectbr.ll URL: http://llvm.org/viewvc/llvm-project/llvm/trunk/test/Transforms/SimplifyCFG/indirectbr.ll?rev=111060&view=auto ============================================================================== --- llvm/trunk/test/Transforms/SimplifyCFG/indirectbr.ll (added) +++ llvm/trunk/test/Transforms/SimplifyCFG/indirectbr.ll Fri Aug 13 19:29:42 2010 @@ -0,0 +1,51 @@ +; RUN: opt -S -simplifycfg < %s | FileCheck %s + +; SimplifyCFG should eliminate redundant indirectbr edges. + +; CHECK: indbrtest0 +; CHECK: indirectbr i8* %t, [label %BB0, label %BB1, label %BB2] +; CHECK: %x = phi i32 [ 0, %BB0 ], [ 1, %entry ] + +declare void @foo() +declare void @A() +declare void @B(i32) +declare void @C() + +define void @indbrtest0(i8** %P, i8** %Q) { +entry: + store i8* blockaddress(@indbrtest0, %BB0), i8** %P + store i8* blockaddress(@indbrtest0, %BB1), i8** %P + store i8* blockaddress(@indbrtest0, %BB2), i8** %P + call void @foo() + %t = load i8** %Q + indirectbr i8* %t, [label %BB0, label %BB1, label %BB2, label %BB0, label %BB1, label %BB2] +BB0: + call void @A() + br label %BB1 +BB1: + %x = phi i32 [ 0, %BB0 ], [ 1, %entry ], [ 1, %entry ] + call void @B(i32 %x) + ret void +BB2: + call void @C() + ret void +} + +; SimplifyCFG should convert the indirectbr into a directbr. It would be even +; better if it removed the branch altogether, but simplifycfdg currently misses +; that because the predecessor is the entry block. + +; CHECK: indbrtest1 +; CHECK: br label %BB0 + +define void @indbrtest1(i8** %P, i8** %Q) { +entry: + store i8* blockaddress(@indbrtest1, %BB0), i8** %P + call void @foo() + %t = load i8** %Q + indirectbr i8* %t, [label %BB0, label %BB0] +BB0: + call void @A() + ret void +} + From gohman at apple.com Fri Aug 13 19:43:09 2010 From: gohman at apple.com (Dan Gohman) Date: Sat, 14 Aug 2010 00:43:09 -0000 Subject: [llvm-commits] [llvm] r111061 - in /llvm/trunk: lib/Transforms/Utils/LoopSimplify.cpp test/Transforms/LoopSimplify/indirectbr-backedge.ll Message-ID: <20100814004309.DA4042A6C12C@llvm.org> Author: djg Date: Fri Aug 13 19:43:09 2010 New Revision: 111061 URL: http://llvm.org/viewvc/llvm-project?rev=111061&view=rev Log: LoopSimplify shouldn't split loop backedges that use indirectbr. PR7867. Added: llvm/trunk/test/Transforms/LoopSimplify/indirectbr-backedge.ll Modified: llvm/trunk/lib/Transforms/Utils/LoopSimplify.cpp Modified: llvm/trunk/lib/Transforms/Utils/LoopSimplify.cpp URL: http://llvm.org/viewvc/llvm-project/llvm/trunk/lib/Transforms/Utils/LoopSimplify.cpp?rev=111061&r1=111060&r2=111061&view=diff ============================================================================== --- llvm/trunk/lib/Transforms/Utils/LoopSimplify.cpp (original) +++ llvm/trunk/lib/Transforms/Utils/LoopSimplify.cpp Fri Aug 13 19:43:09 2010 @@ -622,6 +622,11 @@ std::vector BackedgeBlocks; for (pred_iterator I = pred_begin(Header), E = pred_end(Header); I != E; ++I){ BasicBlock *P = *I; + + // Indirectbr edges cannot be split, so we must fail if we find one. + if (isa(P->getTerminator())) + return 0; + if (P != Preheader) BackedgeBlocks.push_back(P); } Added: llvm/trunk/test/Transforms/LoopSimplify/indirectbr-backedge.ll URL: http://llvm.org/viewvc/llvm-project/llvm/trunk/test/Transforms/LoopSimplify/indirectbr-backedge.ll?rev=111061&view=auto ============================================================================== --- llvm/trunk/test/Transforms/LoopSimplify/indirectbr-backedge.ll (added) +++ llvm/trunk/test/Transforms/LoopSimplify/indirectbr-backedge.ll Fri Aug 13 19:43:09 2010 @@ -0,0 +1,35 @@ +; RUN: opt -loopsimplify -S < %s | FileCheck %s + +; LoopSimplify shouldn't split loop backedges that use indirectbr. + +; CHECK: bb1: ; preds = %bb5, %bb +; CHECK-NEXT: indirectbr + +; CHECK: bb5: ; preds = %bb1 +; CHECK-NEXT: br label %bb1{{$}} + +define void @foo(i8* %p) nounwind { +bb: + br label %bb1 + +bb1: ; preds = %bb5, %bb1, %bb + indirectbr i8* %p, [label %bb6, label %bb7, label %bb1, label %bb2, label %bb3, label %bb5, label %bb4] + +bb2: ; preds = %bb1 + ret void + +bb3: ; preds = %bb1 + ret void + +bb4: ; preds = %bb1 + ret void + +bb5: ; preds = %bb1 + br label %bb1 + +bb6: ; preds = %bb1 + ret void + +bb7: ; preds = %bb1 + ret void +} From kremenek at apple.com Fri Aug 13 20:55:09 2010 From: kremenek at apple.com (Ted Kremenek) Date: Sat, 14 Aug 2010 01:55:09 -0000 Subject: [llvm-commits] [llvm] r111063 - /llvm/trunk/lib/CodeGen/CMakeLists.txt Message-ID: <20100814015509.4A2742A6C12C@llvm.org> Author: kremenek Date: Fri Aug 13 20:55:09 2010 New Revision: 111063 URL: http://llvm.org/viewvc/llvm-project?rev=111063&view=rev Log: Update CMake build. Modified: llvm/trunk/lib/CodeGen/CMakeLists.txt Modified: llvm/trunk/lib/CodeGen/CMakeLists.txt URL: http://llvm.org/viewvc/llvm-project/llvm/trunk/lib/CodeGen/CMakeLists.txt?rev=111063&r1=111062&r2=111063&view=diff ============================================================================== --- llvm/trunk/lib/CodeGen/CMakeLists.txt (original) +++ llvm/trunk/lib/CodeGen/CMakeLists.txt Fri Aug 13 20:55:09 2010 @@ -22,7 +22,7 @@ LiveIntervalAnalysis.cpp LiveStackAnalysis.cpp LiveVariables.cpp - LocalStackAllocation.cpp + LocalStackSlotAllocation.cpp LowerSubregs.cpp MachineBasicBlock.cpp MachineCSE.cpp From bob.wilson at apple.com Fri Aug 13 22:18:29 2010 From: bob.wilson at apple.com (Bob Wilson) Date: Sat, 14 Aug 2010 03:18:29 -0000 Subject: [llvm-commits] [llvm] r111068 - /llvm/trunk/lib/Target/ARM/ARMInstrThumb2.td Message-ID: <20100814031829.99FAE2A6C12F@llvm.org> Author: bwilson Date: Fri Aug 13 22:18:29 2010 New Revision: 111068 URL: http://llvm.org/viewvc/llvm-project?rev=111068&view=rev Log: T2I_rbin_irs rr variant is for disassembly only, so don't provide a pattern. Modified: llvm/trunk/lib/Target/ARM/ARMInstrThumb2.td Modified: llvm/trunk/lib/Target/ARM/ARMInstrThumb2.td URL: http://llvm.org/viewvc/llvm-project/llvm/trunk/lib/Target/ARM/ARMInstrThumb2.td?rev=111068&r1=111067&r2=111068&view=diff ============================================================================== --- llvm/trunk/lib/Target/ARM/ARMInstrThumb2.td (original) +++ llvm/trunk/lib/Target/ARM/ARMInstrThumb2.td Fri Aug 13 22:18:29 2010 @@ -275,7 +275,7 @@ // register def rr : T2sI<(outs rGPR:$dst), (ins rGPR:$rhs, rGPR:$lhs), IIC_iALUr, opc, "\t$dst, $rhs, $lhs", - [(set rGPR:$dst, (opnode rGPR:$lhs, rGPR:$rhs))]> { + [/* For disassembly only; pattern left blank */]> { let Inst{31-27} = 0b11101; let Inst{26-25} = 0b01; let Inst{24-21} = opcod; From nicolas.geoffray at gmail.com Sat Aug 14 00:51:46 2010 From: nicolas.geoffray at gmail.com (nicolas geoffray) Date: Sat, 14 Aug 2010 07:51:46 +0200 Subject: [llvm-commits] [llvm] r110564 - /llvm/trunk/lib/ExecutionEngine/JIT/JIT.cpp In-Reply-To: References: <20100809072020.4A8062A6C12C@llvm.org> Message-ID: I'm very much in favor of Will's suggestion. Nick can you fix it? Thanks, Nicolas On Tue, Aug 10, 2010 at 12:19 AM, Will Dietz wrote: > On Mon, Aug 9, 2010 at 2:20 AM, Nick Lewycky wrote: > > Author: nicholas > > Date: Mon Aug 9 02:20:20 2010 > > New Revision: 110564 > > > > URL: http://llvm.org/viewvc/llvm-project?rev=110564&view=rev > > Log: > > Stop the JIT from refusing to work just because the program it was > compiled into > > was built with -static. > > > > This change breaks looking up symbols defined in the program itself, > at least here it does. > > Perhaps the right fix is to make reinstate the call removed in this > commit, but don't abort/return if it fails? > > ~Will > > _______________________________________________ > llvm-commits mailing list > llvm-commits at cs.uiuc.edu > http://lists.cs.uiuc.edu/mailman/listinfo/llvm-commits > -------------- next part -------------- An HTML attachment was scrubbed... URL: http://lists.cs.uiuc.edu/pipermail/llvm-commits/attachments/20100814/3e92095f/attachment.html From grosser at fim.uni-passau.de Sat Aug 14 07:00:55 2010 From: grosser at fim.uni-passau.de (Tobias Grosser) Date: Sat, 14 Aug 2010 14:00:55 +0200 Subject: [llvm-commits] [PATCH] Disable instruction hoisting Message-ID: <4C668577.9010302@fim.uni-passau.de> Hi, I would like to contribute a patch that allows to disable instruction hoisting in the SCEVExpander. It does not change the current behaviour of any code, but will allow polly to use it to generate so called independent blocks. I already had a discussion with Dan that there might be a solution that does not require to patch the SCEVExpander. However I did not find one. Therefore I will explain how we use the SCEVExpander with disabled instruction hoisting. Hope someone can help me to either find a solution, that does not need a patched SCEVExpander, or if there is no practical one someone could approve this patch. The idea is if there is e.g. a cfg region that looks like this. foo (int Parameter) { for i for j { { BB 1: temp = i + j + Parameter; A [temp] = 0; } { BB 2: temp2 = temp + 2i; B[temp2] = 0; } } } We want to move those bbs into a completely different loop nest and possible change the order of the basic blocks. This works easily for BB 1, as it is only referencing either loop ivs, that will be provided externally or parameters, which are also available. BB 2 however is referencing a scalar value, that is not available, if BB 2 is either eliminated or moved to another place: foo (int Parameter) { for x for y for z { { i = x + y; j = floord(x + 14z, 5); } { BB 2: temp2 = temp + 2i; << temp is not yet defined. B[temp2] = 0; } { BB 1: temp = i + j; A [temp] = 0; } } The solution we used was to SCEVExpand all scalars into the same basic block. Such that the trivial calculations needed to recalulate a variable from a set of induction variables and/or parameters are always available. In this example the code with the updated BB 2 looks like this. foo (int Parameter) { for i for j { { BB 1: temp = i + j + Parameter; A [temp] = 0; } { BB 2: auto_temp = i + j + Parameter; temp2 = auto_temp + 2i; B[temp2] = 0; } } } It can easily be moved in a new loop nest without taking care of any trivial scalar dependences. foo (int Parameter) { for x for y for z { { i = min(x,y); j = floord(x + 14z, 5); } { BB 2: auto_temp = i + j + Parameter; temp2 = auto_temp + 2i; << No problem any more. B[temp2] = 0; } { BB 1: temp = i + j; A [temp] = 0; } } A solution that would work without patch scev expander is to somehow change the scevs describing the original statements. Looking at this code: void independent_blocks() { int i; int temp; for (i = 0; i < N; i++) { temp = i; A[temp] = 1; } } Relevant LLVM-IR produces this SCEVs: %indvar = phi i64 [ %indvar.next, %3 ], [ 0, %0 ] ; [#uses=3] --> {0,+,1}<%1> Exits: 1024 %scevgep = getelementptr [1024 x i32]* @A, i64 0, i64 %indvar ; [#uses=1] --> {@A,+,4}<%1> Exits: (4096 + @A) %indvar.next = add i64 %indvar, 1 ; [#uses=1] --> {1,+,1}<%1> Exits: 1025 In this example I would like to generate a SCEV that has the same value as e.g. {@A,+,4}<%1>, but does not depend on any loops. Instead it contains a reference to some new instructions %new_i that contains the loop iteration value. Is there a good way to achieve this or do you know any other feasible solution to achieve this? In case there is no good one, I would love to hear some comments about the patch proposed. Thanks a lot Tobi -------------- next part -------------- A non-text attachment was scrubbed... Name: 0001-SCEVExpander-Allow-to-disable-instruction-hoisting.patch Type: text/x-diff Size: 9111 bytes Desc: not available Url : http://lists.cs.uiuc.edu/pipermail/llvm-commits/attachments/20100814/1e9e1cef/attachment.bin From sabre at nondot.org Sat Aug 14 12:26:09 2010 From: sabre at nondot.org (Chris Lattner) Date: Sat, 14 Aug 2010 17:26:09 -0000 Subject: [llvm-commits] [llvm] r111073 - /llvm/trunk/lib/Target/X86/X86ISelLowering.cpp Message-ID: <20100814172609.D2FAC2A6C12C@llvm.org> Author: lattner Date: Sat Aug 14 12:26:09 2010 New Revision: 111073 URL: http://llvm.org/viewvc/llvm-project?rev=111073&view=rev Log: improve indentation Modified: llvm/trunk/lib/Target/X86/X86ISelLowering.cpp Modified: llvm/trunk/lib/Target/X86/X86ISelLowering.cpp URL: http://llvm.org/viewvc/llvm-project/llvm/trunk/lib/Target/X86/X86ISelLowering.cpp?rev=111073&r1=111072&r2=111073&view=diff ============================================================================== --- llvm/trunk/lib/Target/X86/X86ISelLowering.cpp (original) +++ llvm/trunk/lib/Target/X86/X86ISelLowering.cpp Sat Aug 14 12:26:09 2010 @@ -7713,26 +7713,25 @@ } unsigned isDev = cast(Op.getOperand(5))->getZExtValue(); - if(!isDev) + if (!isDev) return DAG.getNode(X86ISD::MEMBARRIER, dl, MVT::Other, Op.getOperand(0)); - else { - unsigned Op1 = cast(Op.getOperand(1))->getZExtValue(); - unsigned Op2 = cast(Op.getOperand(2))->getZExtValue(); - unsigned Op3 = cast(Op.getOperand(3))->getZExtValue(); - unsigned Op4 = cast(Op.getOperand(4))->getZExtValue(); - - // def : Pat<(membarrier (i8 0), (i8 0), (i8 0), (i8 1), (i8 1)), (SFENCE)>; - if (!Op1 && !Op2 && !Op3 && Op4) - return DAG.getNode(X86ISD::SFENCE, dl, MVT::Other, Op.getOperand(0)); - - // def : Pat<(membarrier (i8 1), (i8 0), (i8 0), (i8 0), (i8 1)), (LFENCE)>; - if (Op1 && !Op2 && !Op3 && !Op4) - return DAG.getNode(X86ISD::LFENCE, dl, MVT::Other, Op.getOperand(0)); - - // def : Pat<(membarrier (i8 imm), (i8 imm), (i8 imm), (i8 imm), (i8 1)), - // (MFENCE)>; - return DAG.getNode(X86ISD::MFENCE, dl, MVT::Other, Op.getOperand(0)); - } + + unsigned Op1 = cast(Op.getOperand(1))->getZExtValue(); + unsigned Op2 = cast(Op.getOperand(2))->getZExtValue(); + unsigned Op3 = cast(Op.getOperand(3))->getZExtValue(); + unsigned Op4 = cast(Op.getOperand(4))->getZExtValue(); + + // def : Pat<(membarrier (i8 0), (i8 0), (i8 0), (i8 1), (i8 1)), (SFENCE)>; + if (!Op1 && !Op2 && !Op3 && Op4) + return DAG.getNode(X86ISD::SFENCE, dl, MVT::Other, Op.getOperand(0)); + + // def : Pat<(membarrier (i8 1), (i8 0), (i8 0), (i8 0), (i8 1)), (LFENCE)>; + if (Op1 && !Op2 && !Op3 && !Op4) + return DAG.getNode(X86ISD::LFENCE, dl, MVT::Other, Op.getOperand(0)); + + // def : Pat<(membarrier (i8 imm), (i8 imm), (i8 imm), (i8 imm), (i8 1)), + // (MFENCE)>; + return DAG.getNode(X86ISD::MFENCE, dl, MVT::Other, Op.getOperand(0)); } SDValue X86TargetLowering::LowerCMP_SWAP(SDValue Op, SelectionDAG &DAG) const { From akyrtzi at gmail.com Sat Aug 14 16:35:10 2010 From: akyrtzi at gmail.com (Argyrios Kyrtzidis) Date: Sat, 14 Aug 2010 21:35:10 -0000 Subject: [llvm-commits] [llvm] r111082 - in /llvm/trunk: lib/Analysis/InstCount.cpp lib/Bitcode/Reader/BitcodeReader.cpp lib/Linker/LinkModules.cpp lib/Target/X86/X86MCCodeEmitter.cpp lib/VMCore/Verifier.cpp utils/unittest/googletest/include/gtest/internal/gtest-port.h Message-ID: <20100814213510.BCF402A6C12C@llvm.org> Author: akirtzidis Date: Sat Aug 14 16:35:10 2010 New Revision: 111082 URL: http://llvm.org/viewvc/llvm-project?rev=111082&view=rev Log: Add ATTRIBUTE_UNUSED to methods that are not supposed to be used. Modified: llvm/trunk/lib/Analysis/InstCount.cpp llvm/trunk/lib/Bitcode/Reader/BitcodeReader.cpp llvm/trunk/lib/Linker/LinkModules.cpp llvm/trunk/lib/Target/X86/X86MCCodeEmitter.cpp llvm/trunk/lib/VMCore/Verifier.cpp llvm/trunk/utils/unittest/googletest/include/gtest/internal/gtest-port.h Modified: llvm/trunk/lib/Analysis/InstCount.cpp URL: http://llvm.org/viewvc/llvm-project/llvm/trunk/lib/Analysis/InstCount.cpp?rev=111082&r1=111081&r2=111082&view=diff ============================================================================== --- llvm/trunk/lib/Analysis/InstCount.cpp (original) +++ llvm/trunk/lib/Analysis/InstCount.cpp Sat Aug 14 16:35:10 2010 @@ -45,7 +45,7 @@ #include "llvm/Instruction.def" - void visitInstruction(Instruction &I) { + void visitInstruction(Instruction &I) ATTRIBUTE_UNUSED { errs() << "Instruction Count does not know about " << I; llvm_unreachable(0); } Modified: llvm/trunk/lib/Bitcode/Reader/BitcodeReader.cpp URL: http://llvm.org/viewvc/llvm-project/llvm/trunk/lib/Bitcode/Reader/BitcodeReader.cpp?rev=111082&r1=111081&r2=111082&view=diff ============================================================================== --- llvm/trunk/lib/Bitcode/Reader/BitcodeReader.cpp (original) +++ llvm/trunk/lib/Bitcode/Reader/BitcodeReader.cpp Sat Aug 14 16:35:10 2010 @@ -135,8 +135,8 @@ /// @brief A class for maintaining the slot number definition /// as a placeholder for the actual definition for forward constants defs. class ConstantPlaceHolder : public ConstantExpr { - ConstantPlaceHolder(); // DO NOT IMPLEMENT - void operator=(const ConstantPlaceHolder &); // DO NOT IMPLEMENT + ConstantPlaceHolder() ATTRIBUTE_UNUSED; // DO NOT IMPLEMENT + void operator=(const ConstantPlaceHolder &) ATTRIBUTE_UNUSED;//NOT IMPLEMENT public: // allocate space for exactly one operand void *operator new(size_t s) { Modified: llvm/trunk/lib/Linker/LinkModules.cpp URL: http://llvm.org/viewvc/llvm-project/llvm/trunk/lib/Linker/LinkModules.cpp?rev=111082&r1=111081&r2=111082&view=diff ============================================================================== --- llvm/trunk/lib/Linker/LinkModules.cpp (original) +++ llvm/trunk/lib/Linker/LinkModules.cpp Sat Aug 14 16:35:10 2010 @@ -78,8 +78,8 @@ typedef DenseMap TheMapTy; TheMapTy TheMap; - LinkerTypeMap(const LinkerTypeMap&); // DO NOT IMPLEMENT - void operator=(const LinkerTypeMap&); // DO NOT IMPLEMENT + LinkerTypeMap(const LinkerTypeMap&) ATTRIBUTE_UNUSED; // DO NOT IMPLEMENT + void operator=(const LinkerTypeMap&) ATTRIBUTE_UNUSED; // DO NOT IMPLEMENT public: LinkerTypeMap() {} ~LinkerTypeMap() { Modified: llvm/trunk/lib/Target/X86/X86MCCodeEmitter.cpp URL: http://llvm.org/viewvc/llvm-project/llvm/trunk/lib/Target/X86/X86MCCodeEmitter.cpp?rev=111082&r1=111081&r2=111082&view=diff ============================================================================== --- llvm/trunk/lib/Target/X86/X86MCCodeEmitter.cpp (original) +++ llvm/trunk/lib/Target/X86/X86MCCodeEmitter.cpp Sat Aug 14 16:35:10 2010 @@ -19,12 +19,13 @@ #include "llvm/MC/MCExpr.h" #include "llvm/MC/MCInst.h" #include "llvm/Support/raw_ostream.h" +#include "llvm/Support/Compiler.h" using namespace llvm; namespace { class X86MCCodeEmitter : public MCCodeEmitter { - X86MCCodeEmitter(const X86MCCodeEmitter &); // DO NOT IMPLEMENT - void operator=(const X86MCCodeEmitter &); // DO NOT IMPLEMENT + X86MCCodeEmitter(const X86MCCodeEmitter &) ATTRIBUTE_UNUSED; // DONT IMPLEMENT + void operator=(const X86MCCodeEmitter &) ATTRIBUTE_UNUSED; // DO NOT IMPLEMENT const TargetMachine &TM; const TargetInstrInfo &TII; MCContext &Ctx; Modified: llvm/trunk/lib/VMCore/Verifier.cpp URL: http://llvm.org/viewvc/llvm-project/llvm/trunk/lib/VMCore/Verifier.cpp?rev=111082&r1=111081&r2=111082&view=diff ============================================================================== --- llvm/trunk/lib/VMCore/Verifier.cpp (original) +++ llvm/trunk/lib/VMCore/Verifier.cpp Sat Aug 14 16:35:10 2010 @@ -151,8 +151,8 @@ SmallSetVector Types; // Disallow copying. - TypeSet(const TypeSet &); - TypeSet &operator=(const TypeSet &); + TypeSet(const TypeSet &) ATTRIBUTE_UNUSED; + TypeSet &operator=(const TypeSet &) ATTRIBUTE_UNUSED; }; struct Verifier : public FunctionPass, public InstVisitor { Modified: llvm/trunk/utils/unittest/googletest/include/gtest/internal/gtest-port.h URL: http://llvm.org/viewvc/llvm-project/llvm/trunk/utils/unittest/googletest/include/gtest/internal/gtest-port.h?rev=111082&r1=111081&r2=111082&view=diff ============================================================================== --- llvm/trunk/utils/unittest/googletest/include/gtest/internal/gtest-port.h (original) +++ llvm/trunk/utils/unittest/googletest/include/gtest/internal/gtest-port.h Sat Aug 14 16:35:10 2010 @@ -556,12 +556,12 @@ // A macro to disallow operator= // This should be used in the private: declarations for a class. #define GTEST_DISALLOW_ASSIGN_(type)\ - void operator=(type const &) + void operator=(type const &) GTEST_ATTRIBUTE_UNUSED_ // A macro to disallow copy constructor and operator= // This should be used in the private: declarations for a class. #define GTEST_DISALLOW_COPY_AND_ASSIGN_(type)\ - type(type const &);\ + type(type const &) GTEST_ATTRIBUTE_UNUSED_;\ GTEST_DISALLOW_ASSIGN_(type) // Tell the compiler to warn about unused return values for functions declared From echristo at apple.com Sat Aug 14 16:51:50 2010 From: echristo at apple.com (Eric Christopher) Date: Sat, 14 Aug 2010 21:51:50 -0000 Subject: [llvm-commits] [llvm] r111083 - in /llvm/trunk/lib/Target/X86: X86ISelLowering.cpp X86InstrInfo.td Message-ID: <20100814215151.286362A6C12C@llvm.org> Author: echristo Date: Sat Aug 14 16:51:50 2010 New Revision: 111083 URL: http://llvm.org/viewvc/llvm-project?rev=111083&view=rev Log: Rework how the non-sse2 memory barrier is lowered so that the encoding is correct for the built-in assembler. Based on a patch from Chris. Modified: llvm/trunk/lib/Target/X86/X86ISelLowering.cpp llvm/trunk/lib/Target/X86/X86InstrInfo.td Modified: llvm/trunk/lib/Target/X86/X86ISelLowering.cpp URL: http://llvm.org/viewvc/llvm-project/llvm/trunk/lib/Target/X86/X86ISelLowering.cpp?rev=111083&r1=111082&r2=111083&view=diff ============================================================================== --- llvm/trunk/lib/Target/X86/X86ISelLowering.cpp (original) +++ llvm/trunk/lib/Target/X86/X86ISelLowering.cpp Sat Aug 14 16:51:50 2010 @@ -7706,10 +7706,22 @@ DebugLoc dl = Op.getDebugLoc(); if (!Subtarget->hasSSE2()) { - SDValue Zero = DAG.getConstant(0, + SDValue Chain = Op.getOperand(0); + SDValue Zero = DAG.getConstant(0, Subtarget->is64Bit() ? MVT::i64 : MVT::i32); - return DAG.getNode(X86ISD::MEMBARRIER, dl, MVT::Other, Op.getOperand(0), - Zero); + SDValue Ops[] = { + DAG.getRegister(X86::ESP, MVT::i32), // Base + DAG.getTargetConstant(1, MVT::i8), // Scale + DAG.getRegister(0, MVT::i32), // Index + DAG.getTargetConstant(0, MVT::i32), // Disp + DAG.getRegister(0, MVT::i32), // Segment. + Zero, + Chain + }; + SDNode *Res = + DAG.getMachineNode(X86::OR32mrLocked, dl, MVT::Other, Ops, + array_lengthof(Ops)); + return SDValue(Res, 0); } unsigned isDev = cast(Op.getOperand(5))->getZExtValue(); Modified: llvm/trunk/lib/Target/X86/X86InstrInfo.td URL: http://llvm.org/viewvc/llvm-project/llvm/trunk/lib/Target/X86/X86InstrInfo.td?rev=111083&r1=111082&r2=111083&view=diff ============================================================================== --- llvm/trunk/lib/Target/X86/X86InstrInfo.td (original) +++ llvm/trunk/lib/Target/X86/X86InstrInfo.td Sat Aug 14 16:51:50 2010 @@ -3928,18 +3928,17 @@ // // Memory barriers + +// TODO: Get this to fold the constant into the instruction. +def OR32mrLocked : I<0x09, MRMDestMem, (outs), (ins i32mem:$dst, GR32:$zero), + "lock\n\t" + "or{l}\t{$zero, $dst|$dst, $zero}", + []>, Requires<[In32BitMode]>, LOCK; + let hasSideEffects = 1 in { def Int_MemBarrier : I<0, Pseudo, (outs), (ins), "#MEMBARRIER", [(X86MemBarrier)]>, Requires<[HasSSE2]>; - -// TODO: Get this to fold the constant into the instruction. -let Defs = [ESP] in -def Int_MemBarrierNoSSE : I<0x09, MRM1r, (outs), (ins GR32:$zero), - "lock\n\t" - "or{l}\t{$zero, (%esp)|(%esp), $zero}", - [(X86MemBarrierNoSSE GR32:$zero)]>, - Requires<[In32BitMode]>, LOCK; } // Atomic swap. These are just normal xchg instructions. But since a memory From foldr at codedgers.com Sun Aug 15 02:07:13 2010 From: foldr at codedgers.com (Mikhail Glushenkov) Date: Sun, 15 Aug 2010 07:07:13 -0000 Subject: [llvm-commits] [llvm] r111094 - in /llvm/trunk: ./ autoconf/ include/llvm/CompilerDriver/ lib/CompilerDriver/ tools/llvmc/ tools/llvmc/driver/ tools/llvmc/plugins/ tools/llvmc/plugins/Base/ tools/llvmc/plugins/Clang/ tools/llvmc/src/ utils/TableGen/ Message-ID: <20100815070713.683B82A6C12C@llvm.org> Author: foldr Date: Sun Aug 15 02:07:12 2010 New Revision: 111094 URL: http://llvm.org/viewvc/llvm-project?rev=111094&view=rev Log: llvmc: remove dynamic plugins. Added: llvm/trunk/include/llvm/CompilerDriver/AutoGenerated.h llvm/trunk/include/llvm/CompilerDriver/Main.h - copied, changed from r111083, llvm/trunk/tools/llvmc/driver/Main.cpp llvm/trunk/tools/llvmc/src/ llvm/trunk/tools/llvmc/src/AutoGenerated.td - copied, changed from r111083, llvm/trunk/tools/llvmc/driver/Main.cpp llvm/trunk/tools/llvmc/src/Base.td.in - copied, changed from r111083, llvm/trunk/tools/llvmc/plugins/Base/Base.td.in llvm/trunk/tools/llvmc/src/Clang.td - copied, changed from r111083, llvm/trunk/tools/llvmc/plugins/Clang/Clang.td llvm/trunk/tools/llvmc/src/Hooks.cpp - copied, changed from r111083, llvm/trunk/tools/llvmc/plugins/Base/Hooks.cpp llvm/trunk/tools/llvmc/src/Main.cpp - copied, changed from r111083, llvm/trunk/tools/llvmc/driver/Main.cpp llvm/trunk/tools/llvmc/src/Makefile - copied, changed from r111083, llvm/trunk/tools/llvmc/driver/Makefile Removed: llvm/trunk/include/llvm/CompilerDriver/ForceLinkage.h llvm/trunk/include/llvm/CompilerDriver/ForceLinkageMacros.h llvm/trunk/include/llvm/CompilerDriver/Plugin.h llvm/trunk/lib/CompilerDriver/Plugin.cpp llvm/trunk/tools/llvmc/driver/Main.cpp llvm/trunk/tools/llvmc/driver/Makefile llvm/trunk/tools/llvmc/plugins/Base/Base.td.in llvm/trunk/tools/llvmc/plugins/Base/Hooks.cpp llvm/trunk/tools/llvmc/plugins/Base/Makefile llvm/trunk/tools/llvmc/plugins/Base/PluginMain.cpp llvm/trunk/tools/llvmc/plugins/Clang/Clang.td llvm/trunk/tools/llvmc/plugins/Clang/Makefile llvm/trunk/tools/llvmc/plugins/Clang/PluginMain.cpp llvm/trunk/tools/llvmc/plugins/Makefile Modified: llvm/trunk/Makefile llvm/trunk/Makefile.rules llvm/trunk/autoconf/configure.ac llvm/trunk/include/llvm/CompilerDriver/Common.td llvm/trunk/include/llvm/CompilerDriver/Main.inc llvm/trunk/lib/CompilerDriver/Main.cpp llvm/trunk/lib/CompilerDriver/Makefile llvm/trunk/tools/llvmc/CMakeLists.txt llvm/trunk/tools/llvmc/Makefile llvm/trunk/utils/TableGen/LLVMCConfigurationEmitter.cpp Modified: llvm/trunk/Makefile URL: http://llvm.org/viewvc/llvm-project/llvm/trunk/Makefile?rev=111094&r1=111093&r2=111094&view=diff ============================================================================== --- llvm/trunk/Makefile (original) +++ llvm/trunk/Makefile Sun Aug 15 02:07:12 2010 @@ -170,7 +170,7 @@ include/llvm/Config/AsmParsers.def \ include/llvm/Config/Disassemblers.def \ include/llvm/System/DataTypes.h \ - tools/llvmc/plugins/Base/Base.td + tools/llvmc/src/Base.td FilesToConfigPATH := $(addprefix $(LLVM_OBJ_ROOT)/,$(FilesToConfig)) all-local:: $(FilesToConfigPATH) Modified: llvm/trunk/Makefile.rules URL: http://llvm.org/viewvc/llvm-project/llvm/trunk/Makefile.rules?rev=111094&r1=111093&r2=111094&view=diff ============================================================================== --- llvm/trunk/Makefile.rules (original) +++ llvm/trunk/Makefile.rules Sun Aug 15 02:07:12 2010 @@ -196,57 +196,15 @@ install-bytecode:: install-bytecode-local ############################################################################### -# LLVMC: Provide rules for compiling llvmc plugins +# LLVMC: Provide rules for compiling llvmc-based driver ############################################################################### -ifdef LLVMC_PLUGIN - -LIBRARYNAME := $(patsubst %,plugin_llvmc_%,$(LLVMC_PLUGIN)) -CPP.Flags += -DLLVMC_PLUGIN_NAME=$(LLVMC_PLUGIN) - -ifeq ($(ENABLE_LLVMC_DYNAMIC),1) - LD.Flags += -lCompilerDriver -endif - -# Build a dynamic library if the user runs `make` directly from the plugin -# directory. -ifndef LLVMC_BUILTIN_PLUGIN - LOADABLE_MODULE = 1 -endif - -# TableGen stuff... -ifneq ($(BUILT_SOURCES),) - LLVMC_BUILD_AUTOGENERATED_INC=1 -endif - -endif # LLVMC_PLUGIN - ifdef LLVMC_BASED_DRIVER TOOLNAME = $(LLVMC_BASED_DRIVER) -ifeq ($(ENABLE_LLVMC_DYNAMIC),1) - LD.Flags += -lCompilerDriver -else - LLVMLIBS = CompilerDriver.a - LINK_COMPONENTS = support system -endif - -# Preprocessor magic that generates references to static variables in built-in -# plugins. -ifneq ($(LLVMC_BUILTIN_PLUGINS),) - -USEDLIBS += $(patsubst %,plugin_llvmc_%.a,$(LLVMC_BUILTIN_PLUGINS)) - -LLVMC_BUILTIN_PLUGINS.pre := \ - $(patsubst %,-DLLVMC_BUILTIN_PLUGIN_%=, \ - 1 2 3 4 5 6 7 8 9 10) - -CPP.Flags += \ - $(filter-out $(LLVMC_BUILTIN_PLUGINS.pre) $(LLVMC_BUILTIN_PLUGINS), \ - $(join $(LLVMC_BUILTIN_PLUGINS.pre), $(LLVMC_BUILTIN_PLUGINS))) - -endif +LLVMLIBS = CompilerDriver.a +LINK_COMPONENTS = support system endif # LLVMC_BASED_DRIVER @@ -1601,7 +1559,7 @@ TABLEGEN_INC_FILES_COMMON = 1 endif -ifdef LLVMC_BUILD_AUTOGENERATED_INC +ifdef LLVMC_BASED_DRIVER TABLEGEN_INC_FILES_COMMON = 1 endif @@ -1725,20 +1683,26 @@ endif # TARGET -ifdef LLVMC_BUILD_AUTOGENERATED_INC +ifdef LLVMC_BASED_DRIVER + +TDSrc := $(sort $(strip $(wildcard $(PROJ_SRC_DIR)/*.td)) \ + $(strip $(wildcard $(PROJ_OBJ_DIR)/*.td))) -LLVMCPluginSrc := $(sort $(strip $(wildcard $(PROJ_SRC_DIR)/*.td)) \ - $(strip $(wildcard $(PROJ_OBJ_DIR)/*.td))) +TDCommon := $(strip $(wildcard \ + $(LLVM_SRC_ROOT)/include/llvm/CompilerDriver/*.td)) -TDFiles := $(LLVMCPluginSrc) \ - $(strip $(wildcard $(LLVM_SRC_ROOT)/include/llvm/CompilerDriver/*.td)) +TDFiles := $(TDSrc) $(TDCommon) -$(ObjDir)/AutoGenerated.inc.tmp: $(LLVMCPluginSrc) $(ObjDir)/.dir \ - $(TBLGEN) $(TD_COMMON) - $(Echo) "Building LLVMC configuration library with tblgen" +$(INCTMPFiles) : $(TBLGEN) $(TDFiles) + +$(ObjDir)/%.inc.tmp: %.td $(ObjDir)/.dir + $(Echo) "Building LLVMC compilation graph description with tblgen" $(Verb) $(TableGen) -gen-llvmc -o $(call SYSPATH, $@) $< -endif # LLVMC_BUILD_AUTOGENERATED_INC +clean-local:: + -$(Verb) $(RM) -f $(INCFiles) + +endif # LLVMC_BASED_DRIVER ############################################################################### # OTHER RULES: Other rules needed Modified: llvm/trunk/autoconf/configure.ac URL: http://llvm.org/viewvc/llvm-project/llvm/trunk/autoconf/configure.ac?rev=111094&r1=111093&r2=111094&view=diff ============================================================================== --- llvm/trunk/autoconf/configure.ac (original) +++ llvm/trunk/autoconf/configure.ac Sun Aug 15 02:07:12 2010 @@ -858,35 +858,6 @@ esac], llvm_cv_enable_libffi=no) -dnl Only Windows needs dynamic libCompilerDriver to support plugins. -if test "$llvm_cv_os_type" = "Win32" ; then - llvmc_dynamic="yes" -else - llvmc_dynamic="no" -fi - -dnl --enable-llvmc-dynamic : should LLVMC link libCompilerDriver dynamically? -AC_ARG_ENABLE(llvmc-dynamic,AS_HELP_STRING( ---enable-llvmc-dynamic, -[Link LLVMC dynamically (default is NO, unless on Win32)]),, -enableval=$llvmc_dynamic) -if test ${enableval} = "yes" && test "$ENABLE_PIC" -eq 1 ; then - AC_SUBST(ENABLE_LLVMC_DYNAMIC,[[ENABLE_LLVMC_DYNAMIC=1]]) -else - AC_SUBST(ENABLE_LLVMC_DYNAMIC,[[]]) -fi - -dnl --enable-llvmc-dynamic-plugins : should LLVMC support dynamic plugins? -AC_ARG_ENABLE(llvmc-dynamic-plugins,AS_HELP_STRING( ---enable-llvmc-dynamic-plugins, -[Enable dynamic LLVMC plugins (default is YES)]),, -enableval=yes) -if test ${enableval} = "yes" ; then - AC_SUBST(ENABLE_LLVMC_DYNAMIC_PLUGINS,[[ENABLE_LLVMC_DYNAMIC_PLUGINS=1]]) -else - AC_SUBST(ENABLE_LLVMC_DYNAMIC_PLUGINS,[[]]) -fi - dnl===-----------------------------------------------------------------------=== dnl=== dnl=== SECTION 4: Check for programs we need and that they are the right version @@ -1601,7 +1572,7 @@ AC_CONFIG_FILES([llvm.spec]) dnl Configure llvmc's Base plugin -AC_CONFIG_FILES([tools/llvmc/plugins/Base/Base.td]) +AC_CONFIG_FILES([tools/llvmc/src/Base.td]) dnl Do the first stage of configuration for llvm-config.in. AC_CONFIG_FILES([tools/llvm-config/llvm-config.in]) Added: llvm/trunk/include/llvm/CompilerDriver/AutoGenerated.h URL: http://llvm.org/viewvc/llvm-project/llvm/trunk/include/llvm/CompilerDriver/AutoGenerated.h?rev=111094&view=auto ============================================================================== --- llvm/trunk/include/llvm/CompilerDriver/AutoGenerated.h (added) +++ llvm/trunk/include/llvm/CompilerDriver/AutoGenerated.h Sun Aug 15 02:07:12 2010 @@ -0,0 +1,40 @@ +//===--- AutoGenerated.h - The LLVM Compiler Driver -------------*- C++ -*-===// +// +// The LLVM Compiler Infrastructure +// +// This file is distributed under the University of Illinois Open +// Source License. See LICENSE.TXT for details. +// +//===----------------------------------------------------------------------===// +// +// Interface to the autogenerated driver code. +// +//===----------------------------------------------------------------------===// + +#ifndef LLVM_INCLUDE_COMPILER_DRIVER_AUTOGENERATED_H +#define LLVM_INCLUDE_COMPILER_DRIVER_AUTOGENERATED_H + +namespace llvmc { + class LanguageMap; + class CompilationGraph; + + namespace autogenerated { + + int PreprocessOptions(); + int PopulateLanguageMap(LanguageMap& langMap); + int PopulateCompilationGraph(CompilationGraph& graph); + + inline int RunInitialization (LanguageMap& M, CompilationGraph& G) { + if (int ret = PreprocessOptions()) + return ret; + if (int ret = PopulateLanguageMap(M)) + return ret; + if (int ret = PopulateCompilationGraph(G)) + return ret; + + return 0; + } + } +} + +#endif // LLVM_INCLUDE_COMPILER_DRIVER_AUTOGENERATED_H Modified: llvm/trunk/include/llvm/CompilerDriver/Common.td URL: http://llvm.org/viewvc/llvm-project/llvm/trunk/include/llvm/CompilerDriver/Common.td?rev=111094&r1=111093&r2=111094&view=diff ============================================================================== --- llvm/trunk/include/llvm/CompilerDriver/Common.td (original) +++ llvm/trunk/include/llvm/CompilerDriver/Common.td Sun Aug 15 02:07:12 2010 @@ -40,7 +40,6 @@ // Possible option properties. -def extern; def help; def hidden; def init; @@ -101,11 +100,6 @@ // Empty DAG marker. def empty_dag_marker; -// Used to specify plugin priority. -class PluginPriority { - int priority = p; -} - // Option list - a single place to specify options. class OptionList l> { list options = l; Removed: llvm/trunk/include/llvm/CompilerDriver/ForceLinkage.h URL: http://llvm.org/viewvc/llvm-project/llvm/trunk/include/llvm/CompilerDriver/ForceLinkage.h?rev=111093&view=auto ============================================================================== --- llvm/trunk/include/llvm/CompilerDriver/ForceLinkage.h (original) +++ llvm/trunk/include/llvm/CompilerDriver/ForceLinkage.h (removed) @@ -1,122 +0,0 @@ -//===--- ForceLinkage.h - The LLVM Compiler Driver --------------*- C++ -*-===// -// -// The LLVM Compiler Infrastructure -// -// This file is distributed under the University of Illinois Open -// Source License. See LICENSE.TXT for details. -// -//===----------------------------------------------------------------------===// -// -// A bit of preprocessor magic to force references to static libraries. Needed -// because plugin initialization is done via static variables. -// -//===----------------------------------------------------------------------===// - -#ifndef LLVM_INCLUDE_COMPILER_DRIVER_FORCE_LINKAGE_H -#define LLVM_INCLUDE_COMPILER_DRIVER_FORCE_LINKAGE_H - -#include "llvm/CompilerDriver/ForceLinkageMacros.h" - -namespace llvmc { - -// Declare all ForceLinkage$(PluginName) functions. - -#ifdef LLVMC_BUILTIN_PLUGIN_1 - LLVMC_FORCE_LINKAGE_DECL(LLVMC_BUILTIN_PLUGIN_1); -#endif - -#ifdef LLVMC_BUILTIN_PLUGIN_2 - LLVMC_FORCE_LINKAGE_DECL(LLVMC_BUILTIN_PLUGIN_2); -#endif - -#ifdef LLVMC_BUILTIN_PLUGIN_3 - LLVMC_FORCE_LINKAGE_DECL(LLVMC_BUILTIN_PLUGIN_3); -#endif - -#ifdef LLVMC_BUILTIN_PLUGIN_4 - LLVMC_FORCE_LINKAGE_DECL(LLVMC_BUILTIN_PLUGIN_4); -#endif - -#ifdef LLVMC_BUILTIN_PLUGIN_5 - LLVMC_FORCE_LINKAGE_DECL(LLVMC_BUILTIN_PLUGIN_5); -#endif - -#ifdef LLVMC_BUILTIN_PLUGIN_6 - LLVMC_FORCE_LINKAGE_DECL(LLVMC_BUILTIN_PLUGIN_6); -#endif - -#ifdef LLVMC_BUILTIN_PLUGIN_7 - LLVMC_FORCE_LINKAGE_DECL(LLVMC_BUILTIN_PLUGIN_7); -#endif - -#ifdef LLVMC_BUILTIN_PLUGIN_8 - LLVMC_FORCE_LINKAGE_DECL(LLVMC_BUILTIN_PLUGIN_8); -#endif - -#ifdef LLVMC_BUILTIN_PLUGIN_9 - LLVMC_FORCE_LINKAGE_DECL(LLVMC_BUILTIN_PLUGIN_9); -#endif - -#ifdef LLVMC_BUILTIN_PLUGIN_10 - LLVMC_FORCE_LINKAGE_DECL(LLVMC_BUILTIN_PLUGIN_10); -#endif - -namespace force_linkage { - - struct LinkageForcer { - - LinkageForcer() { - -// Call all ForceLinkage$(PluginName) functions. -#ifdef LLVMC_BUILTIN_PLUGIN_1 - LLVMC_FORCE_LINKAGE_CALL(LLVMC_BUILTIN_PLUGIN_1); -#endif - -#ifdef LLVMC_BUILTIN_PLUGIN_2 - LLVMC_FORCE_LINKAGE_CALL(LLVMC_BUILTIN_PLUGIN_2); -#endif - -#ifdef LLVMC_BUILTIN_PLUGIN_3 - LLVMC_FORCE_LINKAGE_CALL(LLVMC_BUILTIN_PLUGIN_3); -#endif - -#ifdef LLVMC_BUILTIN_PLUGIN_4 - LLVMC_FORCE_LINKAGE_CALL(LLVMC_BUILTIN_PLUGIN_4); -#endif - -#ifdef LLVMC_BUILTIN_PLUGIN_5 - LLVMC_FORCE_LINKAGE_CALL(LLVMC_BUILTIN_PLUGIN_5); -#endif - -#ifdef LLVMC_BUILTIN_PLUGIN_6 - LLVMC_FORCE_LINKAGE_CALL(LLVMC_BUILTIN_PLUGIN_6); -#endif - -#ifdef LLVMC_BUILTIN_PLUGIN_7 - LLVMC_FORCE_LINKAGE_CALL(LLVMC_BUILTIN_PLUGIN_7); -#endif - -#ifdef LLVMC_BUILTIN_PLUGIN_8 - LLVMC_FORCE_LINKAGE_CALL(LLVMC_BUILTIN_PLUGIN_8); -#endif - -#ifdef LLVMC_BUILTIN_PLUGIN_9 - LLVMC_FORCE_LINKAGE_CALL(LLVMC_BUILTIN_PLUGIN_9); -#endif - -#ifdef LLVMC_BUILTIN_PLUGIN_10 - LLVMC_FORCE_LINKAGE_CALL(LLVMC_BUILTIN_PLUGIN_10); -#endif - - } - }; -} // End namespace force_linkage. - -// The only externally used bit. -void ForceLinkage() { - force_linkage::LinkageForcer dummy; -} - -} // End namespace llvmc. - -#endif // LLVM_INCLUDE_COMPILER_DRIVER_FORCE_LINKAGE_H Removed: llvm/trunk/include/llvm/CompilerDriver/ForceLinkageMacros.h URL: http://llvm.org/viewvc/llvm-project/llvm/trunk/include/llvm/CompilerDriver/ForceLinkageMacros.h?rev=111093&view=auto ============================================================================== --- llvm/trunk/include/llvm/CompilerDriver/ForceLinkageMacros.h (original) +++ llvm/trunk/include/llvm/CompilerDriver/ForceLinkageMacros.h (removed) @@ -1,29 +0,0 @@ -//===--- ForceLinkageMacros.h - The LLVM Compiler Driver --------*- C++ -*-===// -// -// The LLVM Compiler Infrastructure -// -// This file is distributed under the University of Illinois Open -// Source License. See LICENSE.TXT for details. -// -//===----------------------------------------------------------------------===// -// -// Preprocessor magic that forces references to static libraries - common -// macros used by both driver and plugins. -// -//===----------------------------------------------------------------------===// - -#ifndef LLVM_INCLUDE_COMPILER_DRIVER_FORCE_LINKAGE_MACROS_H -#define LLVM_INCLUDE_COMPILER_DRIVER_FORCE_LINKAGE_MACROS_H - -#define LLVMC_FORCE_LINKAGE_PREFIX(PluginName) ForceLinkage ## PluginName - -#define LLVMC_FORCE_LINKAGE_FUN(PluginName) \ - LLVMC_FORCE_LINKAGE_PREFIX(PluginName) - -#define LLVMC_FORCE_LINKAGE_DECL(PluginName) \ - void LLVMC_FORCE_LINKAGE_FUN(PluginName) () - -#define LLVMC_FORCE_LINKAGE_CALL(PluginName) \ - LLVMC_FORCE_LINKAGE_FUN(PluginName) () - -#endif // LLVM_INCLUDE_COMPILER_DRIVER_FORCE_LINKAGE_MACROS_H Copied: llvm/trunk/include/llvm/CompilerDriver/Main.h (from r111083, llvm/trunk/tools/llvmc/driver/Main.cpp) URL: http://llvm.org/viewvc/llvm-project/llvm/trunk/include/llvm/CompilerDriver/Main.h?p2=llvm/trunk/include/llvm/CompilerDriver/Main.h&p1=llvm/trunk/tools/llvmc/driver/Main.cpp&r1=111083&r2=111094&rev=111094&view=diff ============================================================================== --- llvm/trunk/tools/llvmc/driver/Main.cpp (original) +++ llvm/trunk/include/llvm/CompilerDriver/Main.h Sun Aug 15 02:07:12 2010 @@ -1,4 +1,4 @@ -//===--- Main.cpp - The LLVM Compiler Driver -------------------*- C++ -*-===// +//===--- Main.h - The LLVM Compiler Driver ----------------------*- C++ -*-===// // // The LLVM Compiler Infrastructure // @@ -7,8 +7,15 @@ // //===----------------------------------------------------------------------===// // -// Just include CompilerDriver/Main.inc. +// Entry point for the driver executable. // //===----------------------------------------------------------------------===// -#include "llvm/CompilerDriver/Main.inc" +#ifndef LLVM_INCLUDE_COMPILER_DRIVER_MAIN_H +#define LLVM_INCLUDE_COMPILER_DRIVER_MAIN_H + +namespace llvmc { + int Main(int argc, char** argv); +} + +#endif // LLVM_INCLUDE_COMPILER_DRIVER_MAIN_H Modified: llvm/trunk/include/llvm/CompilerDriver/Main.inc URL: http://llvm.org/viewvc/llvm-project/llvm/trunk/include/llvm/CompilerDriver/Main.inc?rev=111094&r1=111093&r2=111094&view=diff ============================================================================== --- llvm/trunk/include/llvm/CompilerDriver/Main.inc (original) +++ llvm/trunk/include/llvm/CompilerDriver/Main.inc Sun Aug 15 02:07:12 2010 @@ -7,26 +7,16 @@ // //===----------------------------------------------------------------------===// // -// This tool provides a single point of access to the LLVM -// compilation tools. It has many options. To discover the options -// supported please refer to the tools' manual page or run the tool -// with the -help option. -// -// This file provides the default entry point for the driver executable. +// Default main() for the driver executable. // //===----------------------------------------------------------------------===// #ifndef LLVM_INCLUDE_COMPILER_DRIVER_MAIN_INC #define LLVM_INCLUDE_COMPILER_DRIVER_MAIN_INC -#include "llvm/CompilerDriver/ForceLinkage.h" - -namespace llvmc { - int Main(int argc, char** argv); -} +#include "llvm/CompilerDriver/Main.h" int main(int argc, char** argv) { - llvmc::ForceLinkage(); return llvmc::Main(argc, argv); } Removed: llvm/trunk/include/llvm/CompilerDriver/Plugin.h URL: http://llvm.org/viewvc/llvm-project/llvm/trunk/include/llvm/CompilerDriver/Plugin.h?rev=111093&view=auto ============================================================================== --- llvm/trunk/include/llvm/CompilerDriver/Plugin.h (original) +++ llvm/trunk/include/llvm/CompilerDriver/Plugin.h (removed) @@ -1,81 +0,0 @@ -//===--- Plugin.h - The LLVM Compiler Driver --------------------*- C++ -*-===// -// -// The LLVM Compiler Infrastructure -// -// This file is distributed under the University of Illinois Open -// Source License. See LICENSE.TXT for details. -// -//===----------------------------------------------------------------------===// -// -// Plugin support for llvmc. -// -//===----------------------------------------------------------------------===// - -#ifndef LLVM_INCLUDE_COMPILER_DRIVER_PLUGIN_H -#define LLVM_INCLUDE_COMPILER_DRIVER_PLUGIN_H - -#include "llvm/Support/Registry.h" - -namespace llvmc { - - class LanguageMap; - class CompilationGraph; - - /// BasePlugin - An abstract base class for all LLVMC plugins. - struct BasePlugin { - - /// Priority - Plugin priority, useful for handling dependencies - /// between plugins. Plugins with lower priorities are loaded - /// first. - virtual int Priority() const { return 0; } - - /// PreprocessOptions - The auto-generated function that performs various - /// consistency checks on options (like ensuring that -O2 and -O3 are not - /// used together). - virtual int PreprocessOptions() const = 0; - - /// PopulateLanguageMap - The auto-generated function that fills in - /// the language map (map from file extensions to language names). - virtual int PopulateLanguageMap(LanguageMap&) const = 0; - - /// PopulateCompilationGraph - The auto-generated function that - /// populates the compilation graph with nodes and edges. - virtual int PopulateCompilationGraph(CompilationGraph&) const = 0; - - /// Needed to avoid a compiler warning. - virtual ~BasePlugin() {} - }; - - typedef llvm::Registry PluginRegistry; - - template - struct RegisterPlugin - : public PluginRegistry::Add

{ - typedef PluginRegistry::Add

Base; - - RegisterPlugin(const char* Name = "Nameless", - const char* Desc = "Auto-generated plugin") - : Base(Name, Desc) {} - }; - - - /// PluginLoader - Helper class used by the main program for - /// lifetime management. - struct PluginLoader { - PluginLoader(); - ~PluginLoader(); - - /// RunInitialization - Calls PreprocessOptions, PopulateLanguageMap and - /// PopulateCompilationGraph methods of all plugins. This populates the - /// global language map and the compilation graph. - int RunInitialization(LanguageMap& langMap, CompilationGraph& graph) const; - - private: - // noncopyable - PluginLoader(const PluginLoader& other); - const PluginLoader& operator=(const PluginLoader& other); - }; - -} - -#endif // LLVM_INCLUDE_COMPILER_DRIVER_PLUGIN_H Modified: llvm/trunk/lib/CompilerDriver/Main.cpp URL: http://llvm.org/viewvc/llvm-project/llvm/trunk/lib/CompilerDriver/Main.cpp?rev=111094&r1=111093&r2=111094&view=diff ============================================================================== --- llvm/trunk/lib/CompilerDriver/Main.cpp (original) +++ llvm/trunk/lib/CompilerDriver/Main.cpp Sun Aug 15 02:07:12 2010 @@ -11,10 +11,10 @@ // //===----------------------------------------------------------------------===// +#include "llvm/CompilerDriver/AutoGenerated.h" #include "llvm/CompilerDriver/BuiltinOptions.h" #include "llvm/CompilerDriver/CompilationGraph.h" #include "llvm/CompilerDriver/Error.h" -#include "llvm/CompilerDriver/Plugin.h" #include "llvm/Support/raw_ostream.h" #include "llvm/System/Path.h" @@ -62,7 +62,8 @@ return 0; } - /// BuildTargets - A small wrapper for CompilationGraph::Build. Returns non-zero value + /// BuildTargets - A small wrapper for CompilationGraph::Build. Returns + /// non-zero value in case of error. int BuildTargets(CompilationGraph& graph, const LanguageMap& langMap) { int ret; sys::Path tempDir; @@ -87,7 +88,7 @@ *GlobalTimeLog << "# " << cmd << ' ' << time << '\n'; } -// Sometimes plugins want to condition on the value in argv[0]. +// Sometimes user code wants to access the argv[0] value. const char* ProgramName; int Main(int argc, char** argv) { @@ -98,11 +99,11 @@ ProgramName = argv[0]; cl::ParseCommandLineOptions - (argc, argv, "LLVM Compiler Driver (Work In Progress)", + (argc, argv, + /* Overview = */ "LLVM Compiler Driver (Work In Progress)", /* ReadResponseFiles = */ false); - PluginLoader Plugins; - if (int ret = Plugins.RunInitialization(langMap, graph)) + if (int ret = autogenerated::RunInitialization(langMap, graph)) return ret; if (CheckGraph) { Modified: llvm/trunk/lib/CompilerDriver/Makefile URL: http://llvm.org/viewvc/llvm-project/llvm/trunk/lib/CompilerDriver/Makefile?rev=111094&r1=111093&r2=111094&view=diff ============================================================================== --- llvm/trunk/lib/CompilerDriver/Makefile (original) +++ llvm/trunk/lib/CompilerDriver/Makefile Sun Aug 15 02:07:12 2010 @@ -12,34 +12,7 @@ # We don't want this library to appear in `llvm-config --libs` output, so its # name doesn't start with "LLVM". -ifeq ($(ENABLE_LLVMC_DYNAMIC),1) - LIBRARYNAME = libCompilerDriver - LLVMLIBS = LLVMSupport.a LLVMSystem.a - LOADABLE_MODULE := 1 -else - LIBRARYNAME = CompilerDriver - LINK_COMPONENTS = support system -endif +LIBRARYNAME = CompilerDriver +LINK_COMPONENTS = support system include $(LEVEL)/Makefile.common - -ifeq ($(ENABLE_LLVMC_DYNAMIC_PLUGINS), 1) - CPP.Flags += -DENABLE_LLVMC_DYNAMIC_PLUGINS -endif - -# Copy libCompilerDriver to the bin dir so that llvmc can find it. -ifeq ($(ENABLE_LLVMC_DYNAMIC),1) - -FullLibName = $(LIBRARYNAME)$(SHLIBEXT) - -all-local:: $(ToolDir)/$(FullLibName) - -$(ToolDir)/$(FullLibName): $(LibDir)/$(FullLibName) $(ToolDir)/.dir - $(Echo) Copying $(BuildMode) Shared Library $(FullLibName) to $@ - -$(Verb) $(CP) $< $@ - -clean-local:: - $(Echo) Removing $(BuildMode) Shared Library $(FullLibName) \ - from $(ToolDir) - -$(Verb) $(RM) -f $(ToolDir)/$(FullLibName) -endif Removed: llvm/trunk/lib/CompilerDriver/Plugin.cpp URL: http://llvm.org/viewvc/llvm-project/llvm/trunk/lib/CompilerDriver/Plugin.cpp?rev=111093&view=auto ============================================================================== --- llvm/trunk/lib/CompilerDriver/Plugin.cpp (original) +++ llvm/trunk/lib/CompilerDriver/Plugin.cpp (removed) @@ -1,83 +0,0 @@ -//===--- Plugin.cpp - The LLVM Compiler Driver ------------------*- C++ -*-===// -// -// The LLVM Compiler Infrastructure -// -// This file is distributed under the University of Illinois Open -// Source License. See LICENSE.TXT for details. -// -//===----------------------------------------------------------------------===// -// -// Plugin support. -// -//===----------------------------------------------------------------------===// - -#include "llvm/CompilerDriver/Plugin.h" -#include "llvm/Support/ManagedStatic.h" -#include "llvm/System/Mutex.h" -#include -#include - -namespace { - - // Registry::Add<> does not do lifetime management (probably issues - // with static constructor/destructor ordering), so we have to - // implement it here. - // - // All this static registration/life-before-main model seems - // unnecessary convoluted to me. - - static bool pluginListInitialized = false; - typedef std::vector PluginList; - static PluginList Plugins; - static llvm::ManagedStatic > PluginMutex; - - struct ByPriority { - bool operator()(const llvmc::BasePlugin* lhs, - const llvmc::BasePlugin* rhs) { - return lhs->Priority() < rhs->Priority(); - } - }; -} - -namespace llvmc { - - PluginLoader::PluginLoader() { - llvm::sys::SmartScopedLock Lock(*PluginMutex); - if (!pluginListInitialized) { - for (PluginRegistry::iterator B = PluginRegistry::begin(), - E = PluginRegistry::end(); B != E; ++B) - Plugins.push_back(B->instantiate()); - std::sort(Plugins.begin(), Plugins.end(), ByPriority()); - } - pluginListInitialized = true; - } - - PluginLoader::~PluginLoader() { - llvm::sys::SmartScopedLock Lock(*PluginMutex); - if (pluginListInitialized) { - for (PluginList::iterator B = Plugins.begin(), E = Plugins.end(); - B != E; ++B) - delete (*B); - } - pluginListInitialized = false; - } - - int PluginLoader::RunInitialization(LanguageMap& langMap, - CompilationGraph& graph) const - { - llvm::sys::SmartScopedLock Lock(*PluginMutex); - for (PluginList::iterator B = Plugins.begin(), E = Plugins.end(); - B != E; ++B) { - const BasePlugin* BP = *B; - if (int ret = BP->PreprocessOptions()) - return ret; - if (int ret = BP->PopulateLanguageMap(langMap)) - return ret; - if (int ret = BP->PopulateCompilationGraph(graph)) - return ret; - } - - return 0; - } - -} Modified: llvm/trunk/tools/llvmc/CMakeLists.txt URL: http://llvm.org/viewvc/llvm-project/llvm/trunk/tools/llvmc/CMakeLists.txt?rev=111094&r1=111093&r2=111094&view=diff ============================================================================== --- llvm/trunk/tools/llvmc/CMakeLists.txt (original) +++ llvm/trunk/tools/llvmc/CMakeLists.txt Sun Aug 15 02:07:12 2010 @@ -1,4 +1,4 @@ -# add_subdirectory(driver) +# add_subdirectory(src) # TODO: support plugins and user-configured builds. # See ./doc/LLVMC-Reference.rst "Customizing LLVMC: the compilation graph" Modified: llvm/trunk/tools/llvmc/Makefile URL: http://llvm.org/viewvc/llvm-project/llvm/trunk/tools/llvmc/Makefile?rev=111094&r1=111093&r2=111094&view=diff ============================================================================== --- llvm/trunk/tools/llvmc/Makefile (original) +++ llvm/trunk/tools/llvmc/Makefile Sun Aug 15 02:07:12 2010 @@ -9,9 +9,6 @@ LEVEL = ../.. -export LLVMC_BASED_DRIVER_NAME = llvmc -export LLVMC_BUILTIN_PLUGINS = Base Clang - -DIRS = plugins driver +DIRS = src include $(LEVEL)/Makefile.common Removed: llvm/trunk/tools/llvmc/driver/Main.cpp URL: http://llvm.org/viewvc/llvm-project/llvm/trunk/tools/llvmc/driver/Main.cpp?rev=111093&view=auto ============================================================================== --- llvm/trunk/tools/llvmc/driver/Main.cpp (original) +++ llvm/trunk/tools/llvmc/driver/Main.cpp (removed) @@ -1,14 +0,0 @@ -//===--- Main.cpp - The LLVM Compiler Driver -------------------*- C++ -*-===// -// -// The LLVM Compiler Infrastructure -// -// This file is distributed under the University of Illinois Open -// Source License. See LICENSE.TXT for details. -// -//===----------------------------------------------------------------------===// -// -// Just include CompilerDriver/Main.inc. -// -//===----------------------------------------------------------------------===// - -#include "llvm/CompilerDriver/Main.inc" Removed: llvm/trunk/tools/llvmc/driver/Makefile URL: http://llvm.org/viewvc/llvm-project/llvm/trunk/tools/llvmc/driver/Makefile?rev=111093&view=auto ============================================================================== --- llvm/trunk/tools/llvmc/driver/Makefile (original) +++ llvm/trunk/tools/llvmc/driver/Makefile (removed) @@ -1,13 +0,0 @@ -##===- tools/llvmc/driver/Makefile -------------------------*- Makefile -*-===## -# -# The LLVM Compiler Infrastructure -# -# This file is distributed under the University of Illinois Open -# Source License. See LICENSE.TXT for details. -# -##===----------------------------------------------------------------------===## - -LEVEL = ../../.. -LLVMC_BASED_DRIVER = $(LLVMC_BASED_DRIVER_NAME) - -include $(LEVEL)/Makefile.common Removed: llvm/trunk/tools/llvmc/plugins/Base/Base.td.in URL: http://llvm.org/viewvc/llvm-project/llvm/trunk/tools/llvmc/plugins/Base/Base.td.in?rev=111093&view=auto ============================================================================== --- llvm/trunk/tools/llvmc/plugins/Base/Base.td.in (original) +++ llvm/trunk/tools/llvmc/plugins/Base/Base.td.in (removed) @@ -1,377 +0,0 @@ -//===- Base.td - LLVMC toolchain descriptions --------------*- tablegen -*-===// -// -// The LLVM Compiler Infrastructure -// -// This file is distributed under the University of Illinois Open Source -// License. See LICENSE.TXT for details. -// -//===----------------------------------------------------------------------===// -// -// This file contains compilation graph description used by llvmc. -// -//===----------------------------------------------------------------------===// - -include "llvm/CompilerDriver/Common.td" - -// Options - -def OptList : OptionList<[ - (switch_option "emit-llvm", - (help "Emit LLVM .ll files instead of native object files")), - (switch_option "E", - (help "Stop after the preprocessing stage, do not run the compiler")), - (switch_option "fsyntax-only", - (help "Stop after checking the input for syntax errors")), - (switch_option "opt", - (help "Enable opt")), - (switch_option "O0", - (help "Turn off optimization"), (zero_or_more)), - (switch_option "O1", - (help "Optimization level 1"), (zero_or_more)), - (switch_option "O2", - (help "Optimization level 2"), (zero_or_more)), - (switch_option "O3", - (help "Optimization level 3"), (zero_or_more)), - (switch_option "S", - (help "Stop after compilation, do not assemble")), - (switch_option "c", - (help "Compile and assemble, but do not link")), - (switch_option "pthread", - (help "Enable threads")), - (switch_option "m32", - (help "Generate code for a 32-bit environment"), (hidden)), - (switch_option "m64", - (help "Generate code for a 64-bit environment"), (hidden)), - (switch_option "fPIC", - (help "Relocation model: PIC"), (hidden)), - (switch_option "mdynamic-no-pic", - (help "Relocation model: dynamic-no-pic"), (hidden)), - (switch_option "shared", - (help "Create a DLL instead of the regular executable")), - (parameter_option "linker", - (help "Choose linker (possible values: gcc, g++)")), - (parameter_option "mtune", - (help "Target a specific CPU type"), (hidden), (forward_not_split)), - - // TODO: Add a conditional compilation mechanism to make Darwin-only options - // like '-arch' really Darwin-only. - - (parameter_option "arch", - (help "Compile for the specified target architecture"), (hidden)), - (parameter_option "march", - (help "A synonym for -mtune"), (hidden), (forward_not_split)), - (parameter_option "mcpu", - (help "A deprecated synonym for -mtune"), (hidden), (forward_not_split)), - (switch_option "mfix-and-continue", - (help "Needed by gdb to load .o files dynamically"), (hidden)), - (parameter_option "MF", - (help "Specify a file to write dependencies to"), (hidden)), - (parameter_list_option "MT", - (help "Change the name of the rule emitted by dependency generation"), - (hidden)), - (parameter_list_option "include", - (help "Include the named file prior to preprocessing")), - (parameter_list_option "iquote", - (help "Search dir only for files requested with #inlcude \"file\""), - (hidden)), - (parameter_list_option "framework", - (help "Specifies a framework to link against")), - (parameter_list_option "weak_framework", - (help "Specifies a framework to weakly link against"), (hidden)), - (parameter_option "filelist", (hidden), - (help "Link the files listed in file")), - (prefix_list_option "F", - (help "Add a directory to framework search path")), - (prefix_list_option "I", - (help "Add a directory to include path")), - (prefix_list_option "D", - (help "Define a macro")), - (parameter_list_option "Xpreprocessor", (hidden), - (help "Pass options to preprocessor")), - (prefix_list_option "Wa,", (comma_separated), - (help "Pass options to assembler")), - (parameter_list_option "Xassembler", (hidden), - (help "Pass options to assembler")), - (prefix_list_option "Wllc,", (comma_separated), - (help "Pass options to llc")), - (prefix_list_option "L", - (help "Add a directory to link path")), - (prefix_list_option "l", - (help "Search a library when linking")), - (prefix_list_option "Wl,", - (help "Pass options to linker")), - (parameter_list_option "Xlinker", (hidden), - (help "Pass options to linker")), - (prefix_list_option "Wo,", (comma_separated), - (help "Pass options to opt")), - (prefix_list_option "m", - (help "Enable or disable various extensions (-mmmx, -msse, etc.)"), - (hidden)), - (switch_option "dynamiclib", (hidden), - (help "Produce a dynamic library")), - (switch_option "prebind", (hidden), - (help "Prebind all undefined symbols")), - (switch_option "dead_strip", (hidden), - (help "Remove unreachable blocks of code")), - (switch_option "single_module", (hidden), - (help "Build the library so it contains only one module")), - (parameter_option "install_name", (hidden), - (help "File name the library will be installed in")), - (parameter_option "compatibility_version", (hidden), - (help "Compatibility version number")), - (parameter_option "current_version", (hidden), - (help "Current version number")) -]>; - -// Option preprocessor. - -def Preprocess : OptionPreprocessor< -(case (not (any_switch_on ["O0", "O1", "O2", "O3"])), - (set_option "O2"), - (and (switch_on "O3"), (any_switch_on ["O0", "O1", "O2"])), - (unset_option ["O0", "O1", "O2"]), - (and (switch_on "O2"), (any_switch_on ["O0", "O1"])), - (unset_option ["O0", "O1"]), - (switch_on ["O1", "O0"]), - (unset_option "O0")) ->; - -// Tools - -class llvm_gcc_based : Tool< -[(in_language in_lang), - (out_language "llvm-bitcode"), - (output_suffix out_lang), - (command cmd_prefix), - (actions - (case - (and (not_empty "o"), - (multiple_input_files), (or (switch_on "S"), (switch_on "c"))), - (error "cannot specify -o with -c or -S with multiple files"), - (switch_on "E"), - [(forward "E"), (stop_compilation), (output_suffix E_ext)], - (and (switch_on "E"), (empty "o")), (no_out_file), - (switch_on ["emit-llvm", "S"]), - [(output_suffix "ll"), (stop_compilation)], - (switch_on ["emit-llvm", "c"]), (stop_compilation), - (switch_on "fsyntax-only"), [(forward "fsyntax-only"), - (no_out_file), (stop_compilation)], - (switch_on ["S", "emit-llvm"]), [(forward "S"), (forward "emit-llvm")], - (not (or (switch_on ["S", "emit-llvm"]), (switch_on "fsyntax-only"))), - [(append_cmd "-c"), (append_cmd "-emit-llvm")], - - // Forwards - (not_empty "Xpreprocessor"), (forward "Xpreprocessor"), - (not_empty "include"), (forward "include"), - (not_empty "iquote"), (forward "iquote"), - (not_empty "save-temps"), (append_cmd "-save-temps"), - (not_empty "I"), (forward "I"), - (not_empty "F"), (forward "F"), - (not_empty "D"), (forward "D"), - (not_empty "arch"), (forward "arch"), - (not_empty "march"), (forward "march"), - (not_empty "mtune"), (forward "mtune"), - (not_empty "mcpu"), (forward "mcpu"), - (not_empty "m"), (forward "m"), - (switch_on "mfix-and-continue"), (forward "mfix-and-continue"), - (switch_on "m32"), (forward "m32"), - (switch_on "m64"), (forward "m64"), - (switch_on "O0"), (forward "O0"), - (switch_on "O1"), (forward "O1"), - (switch_on "O2"), (forward "O2"), - (switch_on "O3"), (forward "O3"), - (switch_on "fPIC"), (forward "fPIC"), - (switch_on "mdynamic-no-pic"), (forward "mdynamic-no-pic"), - (not_empty "MF"), (forward "MF"), - (not_empty "MT"), (forward "MT"))), - (sink) -]>; - -def llvm_gcc_c : llvm_gcc_based<"@LLVMGCCCOMMAND@ -x c", "c", "i", "bc">; -def llvm_gcc_cpp : llvm_gcc_based<"@LLVMGXXCOMMAND@ -x c++", "c++", "i", "bc">; -def llvm_gcc_m : llvm_gcc_based<"@LLVMGCCCOMMAND@ -x objective-c", - "objective-c", "mi", "bc">; -def llvm_gcc_mxx : llvm_gcc_based<"@LLVMGCCCOMMAND@ -x objective-c++", - "objective-c++", "mi", "bc">; - -def llvm_gcc_c_pch : llvm_gcc_based<"@LLVMGCCCOMMAND@ -x c-header", - "c-header", "i", "gch">; -def llvm_gcc_cpp_pch : llvm_gcc_based<"@LLVMGXXCOMMAND@ -x c++-header", - "c++-header", - "i", "gch">; -def llvm_gcc_m_pch : llvm_gcc_based<"@LLVMGCCCOMMAND@ -x objective-c-header", - "objective-c-header", - "mi", "gch">; -def llvm_gcc_mxx_pch - : llvm_gcc_based<"@LLVMGCCCOMMAND@ -x objective-c++-header", - "objective-c++-header", "mi", "gch">; - -def opt : Tool< -[(in_language "llvm-bitcode"), - (out_language "llvm-bitcode"), - (output_suffix "bc"), - (actions (case (not_empty "Wo,"), (forward_value "Wo,"), - (switch_on "O1"), (forward "O1"), - (switch_on "O2"), (forward "O2"), - (switch_on "O3"), (forward "O3"))), - (command "opt -f") -]>; - -def llvm_as : Tool< -[(in_language "llvm-assembler"), - (out_language "llvm-bitcode"), - (output_suffix "bc"), - (command "llvm-as"), - (actions (case (switch_on "emit-llvm"), (stop_compilation))) -]>; - -def llvm_gcc_assembler : Tool< -[(in_language "assembler"), - (out_language "object-code"), - (output_suffix "o"), - (command "@LLVMGCCCOMMAND@ -c -x assembler"), - (actions (case - (switch_on "c"), (stop_compilation), - (not_empty "arch"), (forward "arch"), - (not_empty "Xassembler"), (forward "Xassembler"), - (switch_on "m32"), (forward "m32"), - (switch_on "m64"), (forward "m64"), - (not_empty "Wa,"), (forward "Wa,"))) -]>; - -def llc : Tool< -[(in_language ["llvm-bitcode", "llvm-assembler"]), - (out_language "assembler"), - (output_suffix "s"), - (command "llc"), - (actions (case - (switch_on "S"), (stop_compilation), - (switch_on "O0"), (forward "O0"), - (switch_on "O1"), (forward "O1"), - (switch_on "O2"), (forward "O2"), - (switch_on "O3"), (forward "O3"), - (switch_on "fPIC"), (append_cmd "-relocation-model=pic"), - (switch_on "mdynamic-no-pic"), - (append_cmd "-relocation-model=dynamic-no-pic"), - (not_empty "march"), (forward_as "mtune", "-mcpu"), - (not_empty "mtune"), (forward_as "mtune", "-mcpu"), - (not_empty "mcpu"), (forward "mcpu"), - (not_empty "m"), (forward_transformed_value "m", "ConvertToMAttr"), - (not_empty "Wllc,"), (forward_value "Wllc,"))) -]>; - -// Base class for linkers -class llvm_gcc_based_linker : Tool< -[(in_language ["object-code", "static-library"]), - (out_language "executable"), - (output_suffix "out"), - (command cmd_prefix), - (works_on_empty (case (and (not_empty "filelist"), on_empty), true, - (default), false)), - (join), - (actions (case - (switch_on "pthread"), (append_cmd "-lpthread"), - (not_empty "L"), (forward "L"), - (not_empty "F"), (forward "F"), - (not_empty "arch"), (forward "arch"), - (not_empty "framework"), (forward "framework"), - (not_empty "weak_framework"), (forward "weak_framework"), - (not_empty "filelist"), (forward "filelist"), - (switch_on "m32"), (forward "m32"), - (switch_on "m64"), (forward "m64"), - (not_empty "l"), (forward "l"), - (not_empty "Xlinker"), (forward "Xlinker"), - (not_empty "Wl,"), (forward "Wl,"), - (switch_on "shared"), (forward "shared"), - (switch_on "dynamiclib"), (forward "dynamiclib"), - (switch_on "prebind"), (forward "prebind"), - (switch_on "dead_strip"), (forward "dead_strip"), - (switch_on "single_module"), (forward "single_module"), - (not_empty "compatibility_version"), - (forward "compatibility_version"), - (not_empty "current_version"), (forward "current_version"), - (not_empty "install_name"), (forward "install_name"))) -]>; - -// Default linker -def llvm_gcc_linker : llvm_gcc_based_linker<"@LLVMGCCCOMMAND@", - (not (or (parameter_equals "linker", "g++"), - (parameter_equals "linker", "c++")))>; -// Alternative linker for C++ -def llvm_gcc_cpp_linker : llvm_gcc_based_linker<"@LLVMGXXCOMMAND@", - (or (parameter_equals "linker", "g++"), - (parameter_equals "linker", "c++"))>; - -// Language map - -def LanguageMap : LanguageMap< - [LangToSuffixes<"c++", ["cc", "cp", "cxx", "cpp", "CPP", "c++", "C"]>, - LangToSuffixes<"c++-header", ["hpp"]>, - LangToSuffixes<"c", ["c"]>, - LangToSuffixes<"c-header", ["h"]>, - LangToSuffixes<"c-cpp-output", ["i"]>, - LangToSuffixes<"objective-c-cpp-output", ["mi"]>, - LangToSuffixes<"objective-c++", ["mm"]>, - LangToSuffixes<"objective-c++-header", ["hmm"]>, - LangToSuffixes<"objective-c", ["m"]>, - LangToSuffixes<"objective-c-header", ["hm"]>, - LangToSuffixes<"assembler", ["s"]>, - LangToSuffixes<"assembler-with-cpp", ["S"]>, - LangToSuffixes<"llvm-assembler", ["ll"]>, - LangToSuffixes<"llvm-bitcode", ["bc"]>, - LangToSuffixes<"object-code", ["o", "*empty*"]>, - LangToSuffixes<"static-library", ["a", "lib"]>, - LangToSuffixes<"executable", ["out"]> - ]>; - -// Compilation graph - -def CompilationGraph : CompilationGraph<[ - Edge<"root", "llvm_gcc_c">, - Edge<"root", "llvm_gcc_assembler">, - Edge<"root", "llvm_gcc_cpp">, - Edge<"root", "llvm_gcc_m">, - Edge<"root", "llvm_gcc_mxx">, - Edge<"root", "llc">, - - Edge<"root", "llvm_gcc_c_pch">, - Edge<"root", "llvm_gcc_cpp_pch">, - Edge<"root", "llvm_gcc_m_pch">, - Edge<"root", "llvm_gcc_mxx_pch">, - - Edge<"llvm_gcc_c", "llc">, - Edge<"llvm_gcc_cpp", "llc">, - Edge<"llvm_gcc_m", "llc">, - Edge<"llvm_gcc_mxx", "llc">, - Edge<"llvm_as", "llc">, - - OptionalEdge<"root", "llvm_as", - (case (switch_on "emit-llvm"), (inc_weight))>, - OptionalEdge<"llvm_gcc_c", "opt", (case (switch_on "opt"), (inc_weight))>, - OptionalEdge<"llvm_gcc_cpp", "opt", (case (switch_on "opt"), (inc_weight))>, - OptionalEdge<"llvm_gcc_m", "opt", (case (switch_on "opt"), (inc_weight))>, - OptionalEdge<"llvm_gcc_mxx", "opt", (case (switch_on "opt"), (inc_weight))>, - OptionalEdge<"llvm_as", "opt", (case (switch_on "opt"), (inc_weight))>, - Edge<"opt", "llc">, - - Edge<"llc", "llvm_gcc_assembler">, - Edge<"llvm_gcc_assembler", "llvm_gcc_linker">, - OptionalEdge<"llvm_gcc_assembler", "llvm_gcc_cpp_linker", - (case - (or (input_languages_contain "c++"), - (input_languages_contain "objective-c++")), - (inc_weight), - (or (parameter_equals "linker", "g++"), - (parameter_equals "linker", "c++")), (inc_weight))>, - - - Edge<"root", "llvm_gcc_linker">, - OptionalEdge<"root", "llvm_gcc_cpp_linker", - (case - (or (input_languages_contain "c++"), - (input_languages_contain "objective-c++")), - (inc_weight), - (or (parameter_equals "linker", "g++"), - (parameter_equals "linker", "c++")), (inc_weight))> - ]>; Removed: llvm/trunk/tools/llvmc/plugins/Base/Hooks.cpp URL: http://llvm.org/viewvc/llvm-project/llvm/trunk/tools/llvmc/plugins/Base/Hooks.cpp?rev=111093&view=auto ============================================================================== --- llvm/trunk/tools/llvmc/plugins/Base/Hooks.cpp (original) +++ llvm/trunk/tools/llvmc/plugins/Base/Hooks.cpp (removed) @@ -1,33 +0,0 @@ -#include -#include - -namespace hooks { -typedef std::vector StrVec; - -/// ConvertToMAttr - Convert -m* and -mno-* to -mattr=+*,-* -std::string ConvertToMAttr(const StrVec& Opts) { - std::string out("-mattr="); - - bool firstIter = true; - for (StrVec::const_iterator B = Opts.begin(), E = Opts.end(); B!=E; ++B) { - const std::string& Arg = *B; - - if (firstIter) - firstIter = false; - else - out += ","; - - if (Arg.find("no-") == 0 && Arg[3] != 0) { - out += '-'; - out += Arg.c_str() + 3; - } - else { - out += '+'; - out += Arg; - } - } - - return out; -} - -} Removed: llvm/trunk/tools/llvmc/plugins/Base/Makefile URL: http://llvm.org/viewvc/llvm-project/llvm/trunk/tools/llvmc/plugins/Base/Makefile?rev=111093&view=auto ============================================================================== --- llvm/trunk/tools/llvmc/plugins/Base/Makefile (original) +++ llvm/trunk/tools/llvmc/plugins/Base/Makefile (removed) @@ -1,15 +0,0 @@ -##===- tools/llvmc/plugins/Base/Makefile -------------------*- Makefile -*-===## -# -# The LLVM Compiler Infrastructure -# -# This file is distributed under the University of Illinois Open Source -# License. See LICENSE.TXT for details. -# -##===----------------------------------------------------------------------===## - -LEVEL = ../../../.. - -LLVMC_PLUGIN = Base -BUILT_SOURCES = AutoGenerated.inc - -include $(LEVEL)/Makefile.common Removed: llvm/trunk/tools/llvmc/plugins/Base/PluginMain.cpp URL: http://llvm.org/viewvc/llvm-project/llvm/trunk/tools/llvmc/plugins/Base/PluginMain.cpp?rev=111093&view=auto ============================================================================== --- llvm/trunk/tools/llvmc/plugins/Base/PluginMain.cpp (original) +++ llvm/trunk/tools/llvmc/plugins/Base/PluginMain.cpp (removed) @@ -1 +0,0 @@ -#include "AutoGenerated.inc" Removed: llvm/trunk/tools/llvmc/plugins/Clang/Clang.td URL: http://llvm.org/viewvc/llvm-project/llvm/trunk/tools/llvmc/plugins/Clang/Clang.td?rev=111093&view=auto ============================================================================== --- llvm/trunk/tools/llvmc/plugins/Clang/Clang.td (original) +++ llvm/trunk/tools/llvmc/plugins/Clang/Clang.td (removed) @@ -1,101 +0,0 @@ -include "llvm/CompilerDriver/Common.td" - -def Priority : PluginPriority<1>; - -def Options : OptionList<[ -// Extern options -(switch_option "E", (extern)), -(switch_option "S", (extern)), -(switch_option "c", (extern)), -(switch_option "fsyntax-only", (extern)), -(switch_option "emit-llvm", (extern)), -(switch_option "pthread", (extern)), -(parameter_list_option "I", (extern)), -(parameter_list_option "include", (extern)), -(parameter_list_option "L", (extern)), -(parameter_list_option "l", (extern)), -(prefix_list_option "Wa,", (extern)), -(prefix_list_option "Wl,", (extern)), - -(switch_option "clang", (help "Use Clang instead of llvm-gcc")) -]>; - -class clang_based : Tool< -[(in_language language), - (out_language "llvm-bitcode"), - (output_suffix "bc"), - (command cmd), - (actions (case (switch_on "E"), - [(forward "E"), (stop_compilation), (output_suffix ext_E)], - (and (switch_on "E"), (empty "o")), (no_out_file), - (switch_on "fsyntax-only"), (stop_compilation), - (switch_on ["S", "emit-llvm"]), - [(append_cmd "-emit-llvm"), - (stop_compilation), (output_suffix "ll")], - (not (switch_on ["S", "emit-llvm"])), - (append_cmd "-emit-llvm-bc"), - (switch_on ["c", "emit-llvm"]), - (stop_compilation), - (not_empty "include"), (forward "include"), - (not_empty "I"), (forward "I"))), - (sink) -]>; - -def clang_c : clang_based<"c", "clang -x c", "i">; -def clang_cpp : clang_based<"c++", "clang -x c++", "i">; -def clang_objective_c : clang_based<"objective-c", - "clang -x objective-c", "mi">; -def clang_objective_cpp : clang_based<"objective-c++", - "clang -x objective-c++", "mi">; - -def as : Tool< -[(in_language "assembler"), - (out_language "object-code"), - (output_suffix "o"), - (command "as"), - (actions (case (not_empty "Wa,"), (forward_value "Wa,"), - (switch_on "c"), (stop_compilation))) -]>; - -// Default linker -def llvm_ld : Tool< -[(in_language "object-code"), - (out_language "executable"), - (output_suffix "out"), - (command "llvm-ld -native -disable-internalize"), - (actions (case - (switch_on "pthread"), (append_cmd "-lpthread"), - (not_empty "L"), (forward "L"), - (not_empty "l"), (forward "l"), - (not_empty "Wl,"), (forward_value "Wl,"))), - (join) -]>; - -// Language map - -def LanguageMap : LanguageMap<[ - LangToSuffixes<"c++", ["cc", "cp", "cxx", "cpp", "CPP", "c++", "C"]>, - LangToSuffixes<"c", ["c"]>, - LangToSuffixes<"objective-c", ["m"]>, - LangToSuffixes<"c-cpp-output", ["i"]>, - LangToSuffixes<"objective-c-cpp-output", ["mi"]> -]>; - -// Compilation graph - -def CompilationGraph : CompilationGraph<[ - OptionalEdge<"root", "clang_c", - (case (switch_on "clang"), (inc_weight))>, - OptionalEdge<"root", "clang_cpp", - (case (switch_on "clang"), (inc_weight))>, - OptionalEdge<"root", "clang_objective_c", - (case (switch_on "clang"), (inc_weight))>, - OptionalEdge<"root", "clang_objective_cpp", - (case (switch_on "clang"), (inc_weight))>, - Edge<"clang_c", "llc">, - Edge<"clang_cpp", "llc">, - Edge<"clang_objective_c", "llc">, - Edge<"clang_objective_cpp", "llc">, - OptionalEdge<"llc", "as", (case (switch_on "clang"), (inc_weight))>, - Edge<"as", "llvm_ld"> -]>; Removed: llvm/trunk/tools/llvmc/plugins/Clang/Makefile URL: http://llvm.org/viewvc/llvm-project/llvm/trunk/tools/llvmc/plugins/Clang/Makefile?rev=111093&view=auto ============================================================================== --- llvm/trunk/tools/llvmc/plugins/Clang/Makefile (original) +++ llvm/trunk/tools/llvmc/plugins/Clang/Makefile (removed) @@ -1,15 +0,0 @@ -##===- tools/llvmc/plugins/Clang/Makefile ------------------*- Makefile -*-===## -# -# The LLVM Compiler Infrastructure -# -# This file is distributed under the University of Illinois Open Source -# License. See LICENSE.TXT for details. -# -##===----------------------------------------------------------------------===## - -LEVEL = ../../../.. - -LLVMC_PLUGIN = Clang -BUILT_SOURCES = AutoGenerated.inc - -include $(LEVEL)/Makefile.common Removed: llvm/trunk/tools/llvmc/plugins/Clang/PluginMain.cpp URL: http://llvm.org/viewvc/llvm-project/llvm/trunk/tools/llvmc/plugins/Clang/PluginMain.cpp?rev=111093&view=auto ============================================================================== --- llvm/trunk/tools/llvmc/plugins/Clang/PluginMain.cpp (original) +++ llvm/trunk/tools/llvmc/plugins/Clang/PluginMain.cpp (removed) @@ -1 +0,0 @@ -#include "AutoGenerated.inc" Removed: llvm/trunk/tools/llvmc/plugins/Makefile URL: http://llvm.org/viewvc/llvm-project/llvm/trunk/tools/llvmc/plugins/Makefile?rev=111093&view=auto ============================================================================== --- llvm/trunk/tools/llvmc/plugins/Makefile (original) +++ llvm/trunk/tools/llvmc/plugins/Makefile (removed) @@ -1,18 +0,0 @@ -##===- tools/llvmc/plugins/Makefile ------------------------*- Makefile -*-===## -# -# The LLVM Compiler Infrastructure -# -# This file is distributed under the University of Illinois Open -# Source License. See LICENSE.TXT for details. -# -##===----------------------------------------------------------------------===## - -LEVEL = ../../.. - -ifneq ($(LLVMC_BUILTIN_PLUGINS),) -DIRS = $(LLVMC_BUILTIN_PLUGINS) -endif - -export LLVMC_BUILTIN_PLUGIN=1 - -include $(LEVEL)/Makefile.common Copied: llvm/trunk/tools/llvmc/src/AutoGenerated.td (from r111083, llvm/trunk/tools/llvmc/driver/Main.cpp) URL: http://llvm.org/viewvc/llvm-project/llvm/trunk/tools/llvmc/src/AutoGenerated.td?p2=llvm/trunk/tools/llvmc/src/AutoGenerated.td&p1=llvm/trunk/tools/llvmc/driver/Main.cpp&r1=111083&r2=111094&rev=111094&view=diff ============================================================================== --- llvm/trunk/tools/llvmc/driver/Main.cpp (original) +++ llvm/trunk/tools/llvmc/src/AutoGenerated.td Sun Aug 15 02:07:12 2010 @@ -1,14 +1,17 @@ -//===--- Main.cpp - The LLVM Compiler Driver -------------------*- C++ -*-===// +//===- AutoGenerated.td - LLVMC toolchain descriptions -----*- tablegen -*-===// // // The LLVM Compiler Infrastructure // -// This file is distributed under the University of Illinois Open -// Source License. See LICENSE.TXT for details. +// This file is distributed under the University of Illinois Open Source +// License. See LICENSE.TXT for details. // //===----------------------------------------------------------------------===// // -// Just include CompilerDriver/Main.inc. +// This file contains compilation graph description used by llvmc. // //===----------------------------------------------------------------------===// -#include "llvm/CompilerDriver/Main.inc" +include "llvm/CompilerDriver/Common.td" + +include "Base.td" +include "Clang.td" Copied: llvm/trunk/tools/llvmc/src/Base.td.in (from r111083, llvm/trunk/tools/llvmc/plugins/Base/Base.td.in) URL: http://llvm.org/viewvc/llvm-project/llvm/trunk/tools/llvmc/src/Base.td.in?p2=llvm/trunk/tools/llvmc/src/Base.td.in&p1=llvm/trunk/tools/llvmc/plugins/Base/Base.td.in&r1=111083&r2=111094&rev=111094&view=diff ============================================================================== --- llvm/trunk/tools/llvmc/plugins/Base/Base.td.in (original) +++ llvm/trunk/tools/llvmc/src/Base.td.in Sun Aug 15 02:07:12 2010 @@ -11,7 +11,6 @@ // //===----------------------------------------------------------------------===// -include "llvm/CompilerDriver/Common.td" // Options Copied: llvm/trunk/tools/llvmc/src/Clang.td (from r111083, llvm/trunk/tools/llvmc/plugins/Clang/Clang.td) URL: http://llvm.org/viewvc/llvm-project/llvm/trunk/tools/llvmc/src/Clang.td?p2=llvm/trunk/tools/llvmc/src/Clang.td&p1=llvm/trunk/tools/llvmc/plugins/Clang/Clang.td&r1=111083&r2=111094&rev=111094&view=diff ============================================================================== --- llvm/trunk/tools/llvmc/plugins/Clang/Clang.td (original) +++ llvm/trunk/tools/llvmc/src/Clang.td Sun Aug 15 02:07:12 2010 @@ -1,22 +1,18 @@ -include "llvm/CompilerDriver/Common.td" +//===- Clang.td - LLVMC toolchain descriptions -------------*- tablegen -*-===// +// +// The LLVM Compiler Infrastructure +// +// This file is distributed under the University of Illinois Open Source +// License. See LICENSE.TXT for details. +// +//===----------------------------------------------------------------------===// +// +// This file contains compilation graph description used by llvmc. +// +//===----------------------------------------------------------------------===// -def Priority : PluginPriority<1>; def Options : OptionList<[ -// Extern options -(switch_option "E", (extern)), -(switch_option "S", (extern)), -(switch_option "c", (extern)), -(switch_option "fsyntax-only", (extern)), -(switch_option "emit-llvm", (extern)), -(switch_option "pthread", (extern)), -(parameter_list_option "I", (extern)), -(parameter_list_option "include", (extern)), -(parameter_list_option "L", (extern)), -(parameter_list_option "l", (extern)), -(prefix_list_option "Wa,", (extern)), -(prefix_list_option "Wl,", (extern)), - (switch_option "clang", (help "Use Clang instead of llvm-gcc")) ]>; @@ -71,19 +67,9 @@ (join) ]>; -// Language map - -def LanguageMap : LanguageMap<[ - LangToSuffixes<"c++", ["cc", "cp", "cxx", "cpp", "CPP", "c++", "C"]>, - LangToSuffixes<"c", ["c"]>, - LangToSuffixes<"objective-c", ["m"]>, - LangToSuffixes<"c-cpp-output", ["i"]>, - LangToSuffixes<"objective-c-cpp-output", ["mi"]> -]>; - // Compilation graph -def CompilationGraph : CompilationGraph<[ +def ClangCompilationGraph : CompilationGraph<[ OptionalEdge<"root", "clang_c", (case (switch_on "clang"), (inc_weight))>, OptionalEdge<"root", "clang_cpp", Copied: llvm/trunk/tools/llvmc/src/Hooks.cpp (from r111083, llvm/trunk/tools/llvmc/plugins/Base/Hooks.cpp) URL: http://llvm.org/viewvc/llvm-project/llvm/trunk/tools/llvmc/src/Hooks.cpp?p2=llvm/trunk/tools/llvmc/src/Hooks.cpp&p1=llvm/trunk/tools/llvmc/plugins/Base/Hooks.cpp&r1=111083&r2=111094&rev=111094&view=diff ============================================================================== (empty) Copied: llvm/trunk/tools/llvmc/src/Main.cpp (from r111083, llvm/trunk/tools/llvmc/driver/Main.cpp) URL: http://llvm.org/viewvc/llvm-project/llvm/trunk/tools/llvmc/src/Main.cpp?p2=llvm/trunk/tools/llvmc/src/Main.cpp&p1=llvm/trunk/tools/llvmc/driver/Main.cpp&r1=111083&r2=111094&rev=111094&view=diff ============================================================================== --- llvm/trunk/tools/llvmc/driver/Main.cpp (original) +++ llvm/trunk/tools/llvmc/src/Main.cpp Sun Aug 15 02:07:12 2010 @@ -7,8 +7,10 @@ // //===----------------------------------------------------------------------===// // -// Just include CompilerDriver/Main.inc. +// Just include AutoGenerated.inc and CompilerDriver/Main.inc. // //===----------------------------------------------------------------------===// +#include "AutoGenerated.inc" + #include "llvm/CompilerDriver/Main.inc" Copied: llvm/trunk/tools/llvmc/src/Makefile (from r111083, llvm/trunk/tools/llvmc/driver/Makefile) URL: http://llvm.org/viewvc/llvm-project/llvm/trunk/tools/llvmc/src/Makefile?p2=llvm/trunk/tools/llvmc/src/Makefile&p1=llvm/trunk/tools/llvmc/driver/Makefile&r1=111083&r2=111094&rev=111094&view=diff ============================================================================== --- llvm/trunk/tools/llvmc/driver/Makefile (original) +++ llvm/trunk/tools/llvmc/src/Makefile Sun Aug 15 02:07:12 2010 @@ -8,6 +8,7 @@ ##===----------------------------------------------------------------------===## LEVEL = ../../.. -LLVMC_BASED_DRIVER = $(LLVMC_BASED_DRIVER_NAME) +LLVMC_BASED_DRIVER = llvmc +BUILT_SOURCES = AutoGenerated.inc include $(LEVEL)/Makefile.common Modified: llvm/trunk/utils/TableGen/LLVMCConfigurationEmitter.cpp URL: http://llvm.org/viewvc/llvm-project/llvm/trunk/utils/TableGen/LLVMCConfigurationEmitter.cpp?rev=111094&r1=111093&r2=111094&view=diff ============================================================================== --- llvm/trunk/utils/TableGen/LLVMCConfigurationEmitter.cpp (original) +++ llvm/trunk/utils/TableGen/LLVMCConfigurationEmitter.cpp Sun Aug 15 02:07:12 2010 @@ -234,10 +234,9 @@ namespace OptionDescriptionFlags { enum OptionDescriptionFlags { Required = 0x1, Hidden = 0x2, - ReallyHidden = 0x4, Extern = 0x8, - OneOrMore = 0x10, Optional = 0x20, - CommaSeparated = 0x40, ForwardNotSplit = 0x80, - ZeroOrMore = 0x100 }; + ReallyHidden = 0x4, OneOrMore = 0x8, + Optional = 0x10, CommaSeparated = 0x20, + ForwardNotSplit = 0x40, ZeroOrMore = 0x80 }; } /// OptionDescription - Represents data contained in a single @@ -279,9 +278,6 @@ bool isCommaSeparated() const; void setCommaSeparated(); - bool isExtern() const; - void setExtern(); - bool isForwardNotSplit() const; void setForwardNotSplit(); @@ -372,13 +368,6 @@ Flags |= OptionDescriptionFlags::ForwardNotSplit; } -bool OptionDescription::isExtern() const { - return Flags & OptionDescriptionFlags::Extern; -} -void OptionDescription::setExtern() { - Flags |= OptionDescriptionFlags::Extern; -} - bool OptionDescription::isRequired() const { return Flags & OptionDescriptionFlags::Required; } @@ -653,7 +642,6 @@ : optDesc_(OD) { if (!staticMembersInitialized_) { - AddHandler("extern", &CollectOptionProperties::onExtern); AddHandler("help", &CollectOptionProperties::onHelp); AddHandler("hidden", &CollectOptionProperties::onHidden); AddHandler("init", &CollectOptionProperties::onInit); @@ -682,11 +670,6 @@ /// Option property handlers -- /// Methods that handle option properties such as (help) or (hidden). - void onExtern (const DagInit& d) { - CheckNumberOfArguments(d, 0); - optDesc_.setExtern(); - } - void onHelp (const DagInit& d) { CheckNumberOfArguments(d, 1); optDesc_.Help = EscapeQuotes(InitPtrToString(d.getArg(0))); @@ -799,16 +782,17 @@ OptionDescription OD(Type, Name); - if (!OD.isExtern()) - CheckNumberOfArguments(d, 2); + + CheckNumberOfArguments(d, 2); if (OD.isAlias()) { // Aliases store the aliased option name in the 'Help' field. OD.Help = InitPtrToString(d.getArg(1)); } - else if (!OD.isExtern()) { + else { processOptionProperties(d, OD); } + OptDescs_.InsertDescription(OD); } @@ -1043,22 +1027,6 @@ } } -/// CalculatePriority - Calculate the priority of this plugin. -int CalculatePriority(RecordVector::const_iterator B, - RecordVector::const_iterator E) { - int priority = 0; - - if (B != E) { - priority = static_cast((*B)->getValueAsInt("priority")); - - if (++B != E) - throw "More than one 'PluginPriority' instance found: " - "most probably an error!"; - } - - return priority; -} - /// NotInGraph - Helper function object for FilterNotInGraph. struct NotInGraph { private: @@ -2382,8 +2350,7 @@ /// EmitOptionDefinitions - Iterate over a list of option descriptions /// and emit registration code. void EmitOptionDefinitions (const OptionDescriptions& descs, - bool HasSink, bool HasExterns, - raw_ostream& O) + bool HasSink, raw_ostream& O) { std::vector Aliases; @@ -2397,17 +2364,9 @@ continue; } - if (val.isExtern()) - O << "extern "; - O << val.GenTypeDeclaration() << ' ' << val.GenVariableName(); - if (val.isExtern()) { - O << ";\n"; - continue; - } - O << "(\"" << val.Name << "\"\n"; if (val.Type == OptionType::Prefix || val.Type == OptionType::PrefixList) @@ -2468,9 +2427,7 @@ // Emit the sink option. if (HasSink) - O << (HasExterns ? "extern cl" : "cl") - << "::list " << SinkOptionName - << (HasExterns ? ";\n" : "(cl::Sink);\n"); + O << "cl" << "::list " << SinkOptionName << "(cl::Sink);\n"; O << '\n'; } @@ -2629,11 +2586,11 @@ }; -/// EmitPreprocessOptions - Emit the PreprocessOptionsLocal() function. +/// EmitPreprocessOptions - Emit the PreprocessOptions() function. void EmitPreprocessOptions (const RecordKeeper& Records, const OptionDescriptions& OptDecs, raw_ostream& O) { - O << "int PreprocessOptionsLocal() {\n"; + O << "int PreprocessOptions () {\n"; const RecordVector& OptionPreprocessors = Records.getAllDerivedDefinitions("OptionPreprocessor"); @@ -2651,12 +2608,13 @@ O << "}\n\n"; } -/// EmitPopulateLanguageMap - Emit the PopulateLanguageMapLocal() function. +/// EmitPopulateLanguageMap - Emit the PopulateLanguageMap() function. void EmitPopulateLanguageMap (const RecordKeeper& Records, raw_ostream& O) { - O << "int PopulateLanguageMapLocal(LanguageMap& langMap) {\n"; + O << "int PopulateLanguageMap (LanguageMap& langMap) {\n"; // Get the relevant field out of RecordKeeper + // TODO: change this to getAllDerivedDefinitions. const Record* LangMapRecord = Records.getDef("LanguageMap"); // It is allowed for a plugin to have no language map. @@ -2758,13 +2716,12 @@ } } -/// EmitPopulateCompilationGraph - Emit the PopulateCompilationGraphLocal() -/// function. +/// EmitPopulateCompilationGraph - Emit the PopulateCompilationGraph() function. void EmitPopulateCompilationGraph (const RecordVector& EdgeVector, const ToolDescriptions& ToolDescs, raw_ostream& O) { - O << "int PopulateCompilationGraphLocal(CompilationGraph& G) {\n"; + O << "int PopulateCompilationGraph (CompilationGraph& G) {\n"; for (ToolDescriptions::const_iterator B = ToolDescs.begin(), E = ToolDescs.end(); B != E; ++B) @@ -2974,30 +2931,12 @@ O << "}\n\n"; } -/// EmitRegisterPlugin - Emit code to register this plugin. -void EmitRegisterPlugin(int Priority, raw_ostream& O) { - O << "struct Plugin : public llvmc::BasePlugin {\n\n"; - O.indent(Indent1) << "int Priority() const { return " - << Priority << "; }\n\n"; - O.indent(Indent1) << "int PreprocessOptions() const\n"; - O.indent(Indent1) << "{ return PreprocessOptionsLocal(); }\n\n"; - O.indent(Indent1) << "int PopulateLanguageMap(LanguageMap& langMap) const\n"; - O.indent(Indent1) << "{ return PopulateLanguageMapLocal(langMap); }\n\n"; - O.indent(Indent1) - << "int PopulateCompilationGraph(CompilationGraph& graph) const\n"; - O.indent(Indent1) << "{ return PopulateCompilationGraphLocal(graph); }\n" - << "};\n\n" - << "static llvmc::RegisterPlugin RP;\n\n"; -} - /// EmitIncludes - Emit necessary #include directives and some /// additional declarations. void EmitIncludes(raw_ostream& O) { O << "#include \"llvm/CompilerDriver/BuiltinOptions.h\"\n" << "#include \"llvm/CompilerDriver/CompilationGraph.h\"\n" << "#include \"llvm/CompilerDriver/Error.h\"\n" - << "#include \"llvm/CompilerDriver/ForceLinkageMacros.h\"\n" - << "#include \"llvm/CompilerDriver/Plugin.h\"\n" << "#include \"llvm/CompilerDriver/Tool.h\"\n\n" << "#include \"llvm/Support/CommandLine.h\"\n" @@ -3022,10 +2961,8 @@ struct PluginData { OptionDescriptions OptDescs; bool HasSink; - bool HasExterns; ToolDescriptions ToolDescs; RecordVector Edges; - int Priority; }; /// HasSink - Go through the list of tool descriptions and check if @@ -3039,19 +2976,8 @@ return false; } -/// HasExterns - Go through the list of option descriptions and check -/// if there are any external options. -bool HasExterns(const OptionDescriptions& OptDescs) { - for (OptionDescriptions::const_iterator B = OptDescs.begin(), - E = OptDescs.end(); B != E; ++B) - if (B->second.isExtern()) - return true; - - return false; -} - -/// CollectPluginData - Collect tool and option properties, -/// compilation graph edges and plugin priority from the parse tree. +/// CollectPluginData - Collect compilation graph edges, tool properties and +/// option properties from the parse tree. void CollectPluginData (const RecordKeeper& Records, PluginData& Data) { // Collect option properties. const RecordVector& OptionLists = @@ -3063,18 +2989,12 @@ const RecordVector& Tools = Records.getAllDerivedDefinitions("Tool"); CollectToolDescriptions(Tools.begin(), Tools.end(), Data.ToolDescs); Data.HasSink = HasSink(Data.ToolDescs); - Data.HasExterns = HasExterns(Data.OptDescs); // Collect compilation graph edges. const RecordVector& CompilationGraphs = Records.getAllDerivedDefinitions("CompilationGraph"); FillInEdgeVector(CompilationGraphs.begin(), CompilationGraphs.end(), Data.Edges); - - // Calculate the priority of this plugin. - const RecordVector& Priorities = - Records.getAllDerivedDefinitions("PluginPriority"); - Data.Priority = CalculatePriority(Priorities.begin(), Priorities.end()); } /// CheckPluginData - Perform some sanity checks on the collected data. @@ -3095,20 +3015,13 @@ EmitIncludes(O); // Emit global option registration code. - EmitOptionDefinitions(Data.OptDescs, Data.HasSink, Data.HasExterns, O); + EmitOptionDefinitions(Data.OptDescs, Data.HasSink, O); // Emit hook declarations. EmitHookDeclarations(Data.ToolDescs, Data.OptDescs, O); O << "namespace {\n\n"; - // Emit PreprocessOptionsLocal() function. - EmitPreprocessOptions(Records, Data.OptDescs, O); - - // Emit PopulateLanguageMapLocal() function - // (language map maps from file extensions to language names). - EmitPopulateLanguageMap(Records, O); - // Emit Tool classes. for (ToolDescriptions::const_iterator B = Data.ToolDescs.begin(), E = Data.ToolDescs.end(); B!=E; ++B) @@ -3117,18 +3030,23 @@ // Emit Edge# classes. EmitEdgeClasses(Data.Edges, Data.OptDescs, O); - // Emit PopulateCompilationGraphLocal() function. - EmitPopulateCompilationGraph(Data.Edges, Data.ToolDescs, O); - - // Emit code for plugin registration. - EmitRegisterPlugin(Data.Priority, O); - O << "} // End anonymous namespace.\n\n"; - // Force linkage magic. O << "namespace llvmc {\n"; - O << "LLVMC_FORCE_LINKAGE_DECL(LLVMC_PLUGIN_NAME) {}\n"; - O << "}\n"; + O << "namespace autogenerated {\n\n"; + + // Emit PreprocessOptions() function. + EmitPreprocessOptions(Records, Data.OptDescs, O); + + // Emit PopulateLanguageMap() function + // (language map maps from file extensions to language names). + EmitPopulateLanguageMap(Records, O); + + // Emit PopulateCompilationGraph() function. + EmitPopulateCompilationGraph(Data.Edges, Data.ToolDescs, O); + + O << "} // End namespace autogenerated.\n"; + O << "} // End namespace llvmc.\n\n"; // EOF } From foldr at codedgers.com Sun Aug 15 02:07:17 2010 From: foldr at codedgers.com (Mikhail Glushenkov) Date: Sun, 15 Aug 2010 07:07:17 -0000 Subject: [llvm-commits] [llvm] r111095 - /llvm/trunk/configure Message-ID: <20100815070717.4C1752A6C12D@llvm.org> Author: foldr Date: Sun Aug 15 02:07:17 2010 New Revision: 111095 URL: http://llvm.org/viewvc/llvm-project?rev=111095&view=rev Log: Regenerate. Modified: llvm/trunk/configure Modified: llvm/trunk/configure URL: http://llvm.org/viewvc/llvm-project/llvm/trunk/configure?rev=111095&r1=111094&r2=111095&view=diff ============================================================================== --- llvm/trunk/configure (original) +++ llvm/trunk/configure Sun Aug 15 02:07:17 2010 @@ -703,8 +703,6 @@ OPTIMIZE_OPTION EXTRA_OPTIONS BINUTILS_INCDIR -ENABLE_LLVMC_DYNAMIC -ENABLE_LLVMC_DYNAMIC_PLUGINS CXX CXXFLAGS ac_ct_CXX @@ -1423,10 +1421,6 @@ --enable-bindings Build specific language bindings: all,auto,none,{binding-name} (default=auto) --enable-libffi Check for the presence of libffi (default is NO) - --enable-llvmc-dynamic Link LLVMC dynamically (default is NO, unless on - Win32) - --enable-llvmc-dynamic-plugins - Enable dynamic LLVMC plugins (default is YES) --enable-ltdl-install install libltdl Optional Packages: @@ -5378,42 +5372,6 @@ fi -if test "$llvm_cv_os_type" = "Win32" ; then - llvmc_dynamic="yes" -else - llvmc_dynamic="no" -fi - -# Check whether --enable-llvmc-dynamic was given. -if test "${enable_llvmc_dynamic+set}" = set; then - enableval=$enable_llvmc_dynamic; -else - enableval=$llvmc_dynamic -fi - -if test ${enableval} = "yes" && test "$ENABLE_PIC" -eq 1 ; then - ENABLE_LLVMC_DYNAMIC=ENABLE_LLVMC_DYNAMIC=1 - -else - ENABLE_LLVMC_DYNAMIC= - -fi - -# Check whether --enable-llvmc-dynamic-plugins was given. -if test "${enable_llvmc_dynamic_plugins+set}" = set; then - enableval=$enable_llvmc_dynamic_plugins; -else - enableval=yes -fi - -if test ${enableval} = "yes" ; then - ENABLE_LLVMC_DYNAMIC_PLUGINS=ENABLE_LLVMC_DYNAMIC_PLUGINS=1 - -else - ENABLE_LLVMC_DYNAMIC_PLUGINS= - -fi - ac_ext=c ac_cpp='$CPP $CPPFLAGS' @@ -11420,7 +11378,7 @@ lt_dlunknown=0; lt_dlno_uscore=1; lt_dlneed_uscore=2 lt_status=$lt_dlunknown cat > conftest.$ac_ext <&5 From foldr at codedgers.com Sun Aug 15 02:07:24 2010 From: foldr at codedgers.com (Mikhail Glushenkov) Date: Sun, 15 Aug 2010 07:07:24 -0000 Subject: [llvm-commits] [llvm] r111096 - in /llvm/trunk: test/LLVMC/ExternOptions.td test/LLVMC/ForwardAs.td test/LLVMC/ForwardTransformedValue.td test/LLVMC/ForwardValue.td test/LLVMC/MultiValuedOption.td test/LLVMC/MultiplePluginPriorities.td test/LLVMC/TestWarnings.td tools/llvmc/src/Makefile Message-ID: <20100815070724.5852E2A6C12C@llvm.org> Author: foldr Date: Sun Aug 15 02:07:24 2010 New Revision: 111096 URL: http://llvm.org/viewvc/llvm-project?rev=111096&view=rev Log: Update tests. Removed: llvm/trunk/test/LLVMC/ExternOptions.td llvm/trunk/test/LLVMC/MultiplePluginPriorities.td Modified: llvm/trunk/test/LLVMC/ForwardAs.td llvm/trunk/test/LLVMC/ForwardTransformedValue.td llvm/trunk/test/LLVMC/ForwardValue.td llvm/trunk/test/LLVMC/MultiValuedOption.td llvm/trunk/test/LLVMC/TestWarnings.td llvm/trunk/tools/llvmc/src/Makefile Removed: llvm/trunk/test/LLVMC/ExternOptions.td URL: http://llvm.org/viewvc/llvm-project/llvm/trunk/test/LLVMC/ExternOptions.td?rev=111095&view=auto ============================================================================== --- llvm/trunk/test/LLVMC/ExternOptions.td (original) +++ llvm/trunk/test/LLVMC/ExternOptions.td (removed) @@ -1,26 +0,0 @@ -// Check that extern options work. -// The dummy tool and graph are required to silence warnings. -// RUN: tblgen -I %p/../../include --gen-llvmc %s -o %t -// RUN: FileCheck -input-file %t %s -// RUN: %compile_cxx -x c++ %t -// XFAIL: vg_leak - -include "llvm/CompilerDriver/Common.td" - -// CHECK: extern cl::opt AutoGeneratedSwitch_Wall - -def OptList : OptionList<[(switch_option "Wall", (extern)), - (parameter_option "std", (extern)), - (prefix_list_option "L", (extern))]>; - -def dummy_tool : Tool<[ -(command "dummy_cmd"), -(in_language "dummy"), -(out_language "dummy"), -(actions (case - (switch_on "Wall"), (stop_compilation), - (not_empty "std"), (stop_compilation), - (not_empty "L"), (stop_compilation))) -]>; - -def DummyGraph : CompilationGraph<[SimpleEdge<"root", "dummy_tool">]>; Modified: llvm/trunk/test/LLVMC/ForwardAs.td URL: http://llvm.org/viewvc/llvm-project/llvm/trunk/test/LLVMC/ForwardAs.td?rev=111096&r1=111095&r2=111096&view=diff ============================================================================== --- llvm/trunk/test/LLVMC/ForwardAs.td (original) +++ llvm/trunk/test/LLVMC/ForwardAs.td Sun Aug 15 02:07:24 2010 @@ -7,7 +7,7 @@ include "llvm/CompilerDriver/Common.td" -def OptList : OptionList<[(parameter_option "dummy", (extern))]>; +def OptList : OptionList<[(parameter_option "dummy", (help "dummmy"))]>; def dummy_tool : Tool<[ (command "dummy_cmd"), Modified: llvm/trunk/test/LLVMC/ForwardTransformedValue.td URL: http://llvm.org/viewvc/llvm-project/llvm/trunk/test/LLVMC/ForwardTransformedValue.td?rev=111096&r1=111095&r2=111096&view=diff ============================================================================== --- llvm/trunk/test/LLVMC/ForwardTransformedValue.td (original) +++ llvm/trunk/test/LLVMC/ForwardTransformedValue.td Sun Aug 15 02:07:24 2010 @@ -7,8 +7,8 @@ include "llvm/CompilerDriver/Common.td" -def OptList : OptionList<[(parameter_option "a", (extern)), - (prefix_list_option "b", (extern))]>; +def OptList : OptionList<[(parameter_option "a", (help "dummy")), + (prefix_list_option "b", (help "dummy"))]>; // CHECK: std::string HookA // CHECK: std::string HookB Modified: llvm/trunk/test/LLVMC/ForwardValue.td URL: http://llvm.org/viewvc/llvm-project/llvm/trunk/test/LLVMC/ForwardValue.td?rev=111096&r1=111095&r2=111096&view=diff ============================================================================== --- llvm/trunk/test/LLVMC/ForwardValue.td (original) +++ llvm/trunk/test/LLVMC/ForwardValue.td Sun Aug 15 02:07:24 2010 @@ -7,8 +7,8 @@ include "llvm/CompilerDriver/Common.td" -def OptList : OptionList<[(parameter_option "a", (extern)), - (prefix_list_option "b", (extern))]>; +def OptList : OptionList<[(parameter_option "a", (help "dummy")), + (prefix_list_option "b", (help "dummy"))]>; def dummy_tool : Tool<[ (command "dummy_cmd"), Modified: llvm/trunk/test/LLVMC/MultiValuedOption.td URL: http://llvm.org/viewvc/llvm-project/llvm/trunk/test/LLVMC/MultiValuedOption.td?rev=111096&r1=111095&r2=111096&view=diff ============================================================================== --- llvm/trunk/test/LLVMC/MultiValuedOption.td (original) +++ llvm/trunk/test/LLVMC/MultiValuedOption.td Sun Aug 15 02:07:24 2010 @@ -10,7 +10,7 @@ def OptList : OptionList<[ // CHECK: cl::multi_val(2) (prefix_list_option "foo", (multi_val 2)), - (parameter_list_option "baz", (multi_val 2), (extern))]>; + (parameter_list_option "baz", (multi_val 2))]>; def dummy_tool : Tool<[ (command "dummy_cmd"), Removed: llvm/trunk/test/LLVMC/MultiplePluginPriorities.td URL: http://llvm.org/viewvc/llvm-project/llvm/trunk/test/LLVMC/MultiplePluginPriorities.td?rev=111095&view=auto ============================================================================== --- llvm/trunk/test/LLVMC/MultiplePluginPriorities.td (original) +++ llvm/trunk/test/LLVMC/MultiplePluginPriorities.td (removed) @@ -1,18 +0,0 @@ -// Check that multiple plugin priorities are not allowed. -// RUN: ignore tblgen -I %p/../../include --gen-llvmc %s |& grep "More than one 'PluginPriority' instance found" -// XFAIL: vg_leak - -// Disable for Darwin PPC: -// XFAIL: powerpc-apple-darwin -// XFAIL: powerpc-darwin9 - -// This also fails on i386-darwin9 for some reason -// XFAIL: i386-darwin9 - -include "llvm/CompilerDriver/Common.td" - -def Graph : CompilationGraph<[]>; - -def Priority1 : PluginPriority<1>; - -def Priority2 : PluginPriority<2>; Modified: llvm/trunk/test/LLVMC/TestWarnings.td URL: http://llvm.org/viewvc/llvm-project/llvm/trunk/test/LLVMC/TestWarnings.td?rev=111096&r1=111095&r2=111096&view=diff ============================================================================== --- llvm/trunk/test/LLVMC/TestWarnings.td (original) +++ llvm/trunk/test/LLVMC/TestWarnings.td Sun Aug 15 02:07:24 2010 @@ -5,4 +5,4 @@ include "llvm/CompilerDriver/Common.td" -def OptList : OptionList<[(switch_option "Wall", (extern))]>; +def OptList : OptionList<[(switch_option "Wall", (help "dummy"))]>; Modified: llvm/trunk/tools/llvmc/src/Makefile URL: http://llvm.org/viewvc/llvm-project/llvm/trunk/tools/llvmc/src/Makefile?rev=111096&r1=111095&r2=111096&view=diff ============================================================================== --- llvm/trunk/tools/llvmc/src/Makefile (original) +++ llvm/trunk/tools/llvmc/src/Makefile Sun Aug 15 02:07:24 2010 @@ -1,4 +1,4 @@ -##===- tools/llvmc/driver/Makefile -------------------------*- Makefile -*-===## +##===- tools/llvmc/src/Makefile ----------------------------*- Makefile -*-===## # # The LLVM Compiler Infrastructure # From akyrtzi at gmail.com Sun Aug 15 05:27:23 2010 From: akyrtzi at gmail.com (Argyrios Kyrtzidis) Date: Sun, 15 Aug 2010 10:27:23 -0000 Subject: [llvm-commits] [llvm] r111102 - in /llvm/trunk: lib/Analysis/InstCount.cpp lib/Bitcode/Reader/BitcodeReader.cpp lib/Linker/LinkModules.cpp lib/Target/X86/X86MCCodeEmitter.cpp lib/VMCore/Verifier.cpp utils/unittest/googletest/include/gtest/internal/gtest-port.h Message-ID: <20100815102724.11B6D2A6C12C@llvm.org> Author: akirtzidis Date: Sun Aug 15 05:27:23 2010 New Revision: 111102 URL: http://llvm.org/viewvc/llvm-project?rev=111102&view=rev Log: Revert r111082. No warnings for this common pattern. Modified: llvm/trunk/lib/Analysis/InstCount.cpp llvm/trunk/lib/Bitcode/Reader/BitcodeReader.cpp llvm/trunk/lib/Linker/LinkModules.cpp llvm/trunk/lib/Target/X86/X86MCCodeEmitter.cpp llvm/trunk/lib/VMCore/Verifier.cpp llvm/trunk/utils/unittest/googletest/include/gtest/internal/gtest-port.h Modified: llvm/trunk/lib/Analysis/InstCount.cpp URL: http://llvm.org/viewvc/llvm-project/llvm/trunk/lib/Analysis/InstCount.cpp?rev=111102&r1=111101&r2=111102&view=diff ============================================================================== --- llvm/trunk/lib/Analysis/InstCount.cpp (original) +++ llvm/trunk/lib/Analysis/InstCount.cpp Sun Aug 15 05:27:23 2010 @@ -45,7 +45,7 @@ #include "llvm/Instruction.def" - void visitInstruction(Instruction &I) ATTRIBUTE_UNUSED { + void visitInstruction(Instruction &I) { errs() << "Instruction Count does not know about " << I; llvm_unreachable(0); } Modified: llvm/trunk/lib/Bitcode/Reader/BitcodeReader.cpp URL: http://llvm.org/viewvc/llvm-project/llvm/trunk/lib/Bitcode/Reader/BitcodeReader.cpp?rev=111102&r1=111101&r2=111102&view=diff ============================================================================== --- llvm/trunk/lib/Bitcode/Reader/BitcodeReader.cpp (original) +++ llvm/trunk/lib/Bitcode/Reader/BitcodeReader.cpp Sun Aug 15 05:27:23 2010 @@ -135,8 +135,8 @@ /// @brief A class for maintaining the slot number definition /// as a placeholder for the actual definition for forward constants defs. class ConstantPlaceHolder : public ConstantExpr { - ConstantPlaceHolder() ATTRIBUTE_UNUSED; // DO NOT IMPLEMENT - void operator=(const ConstantPlaceHolder &) ATTRIBUTE_UNUSED;//NOT IMPLEMENT + ConstantPlaceHolder(); // DO NOT IMPLEMENT + void operator=(const ConstantPlaceHolder &); // DO NOT IMPLEMENT public: // allocate space for exactly one operand void *operator new(size_t s) { Modified: llvm/trunk/lib/Linker/LinkModules.cpp URL: http://llvm.org/viewvc/llvm-project/llvm/trunk/lib/Linker/LinkModules.cpp?rev=111102&r1=111101&r2=111102&view=diff ============================================================================== --- llvm/trunk/lib/Linker/LinkModules.cpp (original) +++ llvm/trunk/lib/Linker/LinkModules.cpp Sun Aug 15 05:27:23 2010 @@ -78,8 +78,8 @@ typedef DenseMap TheMapTy; TheMapTy TheMap; - LinkerTypeMap(const LinkerTypeMap&) ATTRIBUTE_UNUSED; // DO NOT IMPLEMENT - void operator=(const LinkerTypeMap&) ATTRIBUTE_UNUSED; // DO NOT IMPLEMENT + LinkerTypeMap(const LinkerTypeMap&); // DO NOT IMPLEMENT + void operator=(const LinkerTypeMap&); // DO NOT IMPLEMENT public: LinkerTypeMap() {} ~LinkerTypeMap() { Modified: llvm/trunk/lib/Target/X86/X86MCCodeEmitter.cpp URL: http://llvm.org/viewvc/llvm-project/llvm/trunk/lib/Target/X86/X86MCCodeEmitter.cpp?rev=111102&r1=111101&r2=111102&view=diff ============================================================================== --- llvm/trunk/lib/Target/X86/X86MCCodeEmitter.cpp (original) +++ llvm/trunk/lib/Target/X86/X86MCCodeEmitter.cpp Sun Aug 15 05:27:23 2010 @@ -19,13 +19,12 @@ #include "llvm/MC/MCExpr.h" #include "llvm/MC/MCInst.h" #include "llvm/Support/raw_ostream.h" -#include "llvm/Support/Compiler.h" using namespace llvm; namespace { class X86MCCodeEmitter : public MCCodeEmitter { - X86MCCodeEmitter(const X86MCCodeEmitter &) ATTRIBUTE_UNUSED; // DONT IMPLEMENT - void operator=(const X86MCCodeEmitter &) ATTRIBUTE_UNUSED; // DO NOT IMPLEMENT + X86MCCodeEmitter(const X86MCCodeEmitter &); // DO NOT IMPLEMENT + void operator=(const X86MCCodeEmitter &); // DO NOT IMPLEMENT const TargetMachine &TM; const TargetInstrInfo &TII; MCContext &Ctx; Modified: llvm/trunk/lib/VMCore/Verifier.cpp URL: http://llvm.org/viewvc/llvm-project/llvm/trunk/lib/VMCore/Verifier.cpp?rev=111102&r1=111101&r2=111102&view=diff ============================================================================== --- llvm/trunk/lib/VMCore/Verifier.cpp (original) +++ llvm/trunk/lib/VMCore/Verifier.cpp Sun Aug 15 05:27:23 2010 @@ -151,8 +151,8 @@ SmallSetVector Types; // Disallow copying. - TypeSet(const TypeSet &) ATTRIBUTE_UNUSED; - TypeSet &operator=(const TypeSet &) ATTRIBUTE_UNUSED; + TypeSet(const TypeSet &); + TypeSet &operator=(const TypeSet &); }; struct Verifier : public FunctionPass, public InstVisitor { Modified: llvm/trunk/utils/unittest/googletest/include/gtest/internal/gtest-port.h URL: http://llvm.org/viewvc/llvm-project/llvm/trunk/utils/unittest/googletest/include/gtest/internal/gtest-port.h?rev=111102&r1=111101&r2=111102&view=diff ============================================================================== --- llvm/trunk/utils/unittest/googletest/include/gtest/internal/gtest-port.h (original) +++ llvm/trunk/utils/unittest/googletest/include/gtest/internal/gtest-port.h Sun Aug 15 05:27:23 2010 @@ -556,12 +556,12 @@ // A macro to disallow operator= // This should be used in the private: declarations for a class. #define GTEST_DISALLOW_ASSIGN_(type)\ - void operator=(type const &) GTEST_ATTRIBUTE_UNUSED_ + void operator=(type const &) // A macro to disallow copy constructor and operator= // This should be used in the private: declarations for a class. #define GTEST_DISALLOW_COPY_AND_ASSIGN_(type)\ - type(type const &) GTEST_ATTRIBUTE_UNUSED_;\ + type(type const &);\ GTEST_DISALLOW_ASSIGN_(type) // Tell the compiler to warn about unused return values for functions declared From geek4civic at gmail.com Sun Aug 15 06:19:23 2010 From: geek4civic at gmail.com (NAKAMURA Takumi) Date: Sun, 15 Aug 2010 20:19:23 +0900 Subject: [llvm-commits] [LLVMdev] [PATCH] Capability of Win32.DLL with ENABLE_SHARED In-Reply-To: References: Message-ID: This additional patch enables "make unittests" on enable-shared/mingw. (still unittests would fail in some points. see also my other patches) It is intended to apply with previous r110016-shlib-dll-2.diff.txt. Thank you in advance...Takumi -------------- next part -------------- diff --git a/unittests/Makefile.unittest b/unittests/Makefile.unittest index 2a701a0..9a75b2c 100644 --- a/unittests/Makefile.unittest +++ b/unittests/Makefile.unittest @@ -37,10 +37,10 @@ TESTLIBS = -lGoogleTest -lUnitTestMain ifeq ($(ENABLE_SHARED), 1) # Add the absolute path to the dynamic library. This is ok because # we'll never install unittests. - LD.Flags += $(RPATH) -Wl,$(LibDir) + LD.Flags += $(RPATH) -Wl,$(SharedLibDir) # Also set {DYLD,LD}_LIBRARY_PATH because OSX ignores the rpath most # of the time. - Run.Shared := $(SHLIBPATH_VAR)="$(LibDir)$${$(SHLIBPATH_VAR):+:}$$$(SHLIBPATH_VAR)" + Run.Shared := $(SHLIBPATH_VAR)="$(SharedLibDir)$${$(SHLIBPATH_VAR):+:}$$$(SHLIBPATH_VAR)" endif $(LLVMUnitTestExe): $(ObjectsO) $(ProjLibsPaths) $(LLVMLibsPaths) From geek4civic at gmail.com Sun Aug 15 06:34:46 2010 From: geek4civic at gmail.com (NAKAMURA Takumi) Date: Sun, 15 Aug 2010 20:34:46 +0900 Subject: [llvm-commits] [Patch Proposal] add to unittests/JIT, capability of looking up an indirect symbol Message-ID: Good evening! Win32.DLL resolves function entries with IAT(indirect pointer call/jmp). In opposite, llvm::getPointerToNamedFunction() gets the address of function entries directly in DLL. At comparing pointers, this patch enables trying fetching indirect pointer value when the function entry is indirect "jmp *XXX". TODO: it should be enhanced for Win x64. ...Takumi -------------- next part -------------- diff --git a/unittests/ExecutionEngine/JIT/MultiJITTest.cpp b/unittests/ExecutionEngine/JIT/MultiJITTest.cpp index 8997d39..374ecdc 100644 --- a/unittests/ExecutionEngine/JIT/MultiJITTest.cpp +++ b/unittests/ExecutionEngine/JIT/MultiJITTest.cpp @@ -157,8 +157,20 @@ TEST(MultiJitTest, JitPool) { EXPECT_EQ(getPointerToNamedFunction("foo2"), foo2); // Symbol search - EXPECT_EQ((intptr_t)getPointerToNamedFunction("getPointerToNamedFunction"), - (intptr_t)&getPointerToNamedFunction); + intptr_t + sa = (intptr_t)getPointerToNamedFunction("getPointerToNamedFunction"); + EXPECT_TRUE(sa != 0); + static intptr_t fa = (intptr_t)&getPointerToNamedFunction; + EXPECT_TRUE(fa != 0); +#ifdef __i386__ + // FF 25 xxxxxxxx: jmp *xxxxxxxx + if (sa != fa && memcmp((char *)fa, "\xFF\x25", 2) == 0) { + fa = *(intptr_t *)(fa + 2); + EXPECT_TRUE(fa != 0); + fa = *(intptr_t *)fa; + } +#endif + EXPECT_TRUE(sa == fa); } } // anonymous namespace From ofv at wanadoo.es Sun Aug 15 10:08:27 2010 From: ofv at wanadoo.es (Oscar Fuentes) Date: Sun, 15 Aug 2010 15:08:27 -0000 Subject: [llvm-commits] [llvm] r111104 - /llvm/trunk/cmake/modules/LLVMConfig.cmake Message-ID: <20100815150827.B6EC52A6C12C@llvm.org> Author: ofv Date: Sun Aug 15 10:08:27 2010 New Revision: 111104 URL: http://llvm.org/viewvc/llvm-project?rev=111104&view=rev Log: Updated the GenLibDeps -> LLVMLibDeps.cmake transformation example. Modified: llvm/trunk/cmake/modules/LLVMConfig.cmake Modified: llvm/trunk/cmake/modules/LLVMConfig.cmake URL: http://llvm.org/viewvc/llvm-project/llvm/trunk/cmake/modules/LLVMConfig.cmake?rev=111104&r1=111103&r2=111104&view=diff ============================================================================== --- llvm/trunk/cmake/modules/LLVMConfig.cmake (original) +++ llvm/trunk/cmake/modules/LLVMConfig.cmake Sun Aug 15 10:08:27 2010 @@ -151,13 +151,13 @@ # The format generated by GenLibDeps.pl -# LLVMARMAsmPrinter.o: LLVMARMCodeGen.o libLLVMAsmPrinter.a libLLVMCodeGen.a libLLVMCore.a libLLVMSupport.a libLLVMTarget.a +# libLLVMARMAsmPrinter.a: libLLVMMC.a libLLVMSupport.a # is translated to: -# set(MSVC_LIB_DEPS_LLVMARMAsmPrinter LLVMARMCodeGen LLVMAsmPrinter LLVMCodeGen LLVMCore LLVMSupport LLVMTarget) +# set(MSVC_LIB_DEPS_LLVMARMAsmPrinter LLVMMC LLVMSupport) -# It is necessary to remove the `lib' prefix and the `.a'. +# It is necessary to remove the `lib' prefix and the `.a' suffix. # This 'sed' script should do the trick: # sed -e s'#\.a##g' -e 's#libLLVM#LLVM#g' -e 's#: # #' -e 's#\(.*\)#set(MSVC_LIB_DEPS_\1)#' ~/llvm/tools/llvm-config/LibDeps.txt From daniel at zuster.org Sun Aug 15 10:40:08 2010 From: daniel at zuster.org (Daniel Dunbar) Date: Sun, 15 Aug 2010 08:40:08 -0700 Subject: [llvm-commits] [PATCH 0/5] ELF object support In-Reply-To: <20100813182949.GA3979@console-pimps.org> References: <20100813182949.GA3979@console-pimps.org> Message-ID: On Fri, Aug 13, 2010 at 11:29 AM, Matt Fleming wrote: > On Thu, Aug 12, 2010 at 10:44:05AM -0700, Daniel Dunbar wrote: >> Hi Matt, >> >> I scanned the patches, they look reasonable to me. I have more review >> comments, but I am eager to see this stuff land and I know others are >> as well. I would rather get it in, and work from there. > > I was hoping this would be the case ;-) The idea was to get this stuff > in as the first hurdle is the biggest. Incremental fix ups on top of > that should be easier. > >> Assuming this stuff works, and passes some basic sanity checks, can >> you go ahead and commit it? > > Sure thing. It passes some basic tests I have and.... > >> It would be nice to get some tests for it -- have you thought at all >> about writing a simple ELF object file dumping tool like we have for >> Mach-O and COFF? > > ... I was planning on committing some ELF tests after the basic support > went in just because I haven't written them yet. I hadn't thought about > writing a dumping tool for ELF but I can certainly do that. > > Should I commit this series then? Yes, please! - Daniel > From dalej at apple.com Sun Aug 15 14:40:29 2010 From: dalej at apple.com (Dale Johannesen) Date: Sun, 15 Aug 2010 19:40:29 -0000 Subject: [llvm-commits] [llvm] r111108 - /llvm/trunk/test/CodeGen/X86/sibcall.ll Message-ID: <20100815194029.3C03C2A6C12C@llvm.org> Author: johannes Date: Sun Aug 15 14:40:29 2010 New Revision: 111108 URL: http://llvm.org/viewvc/llvm-project?rev=111108&view=rev Log: Mark as XFAIL on darwin 8. PR 7886. Modified: llvm/trunk/test/CodeGen/X86/sibcall.ll Modified: llvm/trunk/test/CodeGen/X86/sibcall.ll URL: http://llvm.org/viewvc/llvm-project/llvm/trunk/test/CodeGen/X86/sibcall.ll?rev=111108&r1=111107&r2=111108&view=diff ============================================================================== --- llvm/trunk/test/CodeGen/X86/sibcall.ll (original) +++ llvm/trunk/test/CodeGen/X86/sibcall.ll Sun Aug 15 14:40:29 2010 @@ -1,5 +1,7 @@ ; RUN: llc < %s -march=x86 -mattr=+sse2 -asm-verbose=false | FileCheck %s -check-prefix=32 ; RUN: llc < %s -march=x86-64 -mattr=+sse2 -asm-verbose=false | FileCheck %s -check-prefix=64 +; Darwin 8 generates stubs, which don't match +; XFAIL: apple-darwin8 define void @t1(i32 %x) nounwind ssp { entry: From benny.kra at googlemail.com Sun Aug 15 15:42:56 2010 From: benny.kra at googlemail.com (Benjamin Kramer) Date: Sun, 15 Aug 2010 20:42:56 -0000 Subject: [llvm-commits] [llvm] r111109 - in /llvm/trunk/test/CodeGen/X86: 2010-01-18-DbgValue.ll 2010-05-25-DotDebugLoc.ll Message-ID: <20100815204256.BF74E2A6C12C@llvm.org> Author: d0k Date: Sun Aug 15 15:42:56 2010 New Revision: 111109 URL: http://llvm.org/viewvc/llvm-project?rev=111109&view=rev Log: Restore arch on these test, they fail on arm. Modified: llvm/trunk/test/CodeGen/X86/2010-01-18-DbgValue.ll llvm/trunk/test/CodeGen/X86/2010-05-25-DotDebugLoc.ll Modified: llvm/trunk/test/CodeGen/X86/2010-01-18-DbgValue.ll URL: http://llvm.org/viewvc/llvm-project/llvm/trunk/test/CodeGen/X86/2010-01-18-DbgValue.ll?rev=111109&r1=111108&r2=111109&view=diff ============================================================================== --- llvm/trunk/test/CodeGen/X86/2010-01-18-DbgValue.ll (original) +++ llvm/trunk/test/CodeGen/X86/2010-01-18-DbgValue.ll Sun Aug 15 15:42:56 2010 @@ -1,4 +1,4 @@ -; RUN: llc -O0 < %s | FileCheck %s +; RUN: llc -march=x86 -O0 < %s | FileCheck %s ; Currently, dbg.declare generates a DEBUG_VALUE comment. Eventually it will ; generate DWARF and this test will need to be modified or removed. Modified: llvm/trunk/test/CodeGen/X86/2010-05-25-DotDebugLoc.ll URL: http://llvm.org/viewvc/llvm-project/llvm/trunk/test/CodeGen/X86/2010-05-25-DotDebugLoc.ll?rev=111109&r1=111108&r2=111109&view=diff ============================================================================== --- llvm/trunk/test/CodeGen/X86/2010-05-25-DotDebugLoc.ll (original) +++ llvm/trunk/test/CodeGen/X86/2010-05-25-DotDebugLoc.ll Sun Aug 15 15:42:56 2010 @@ -1,4 +1,4 @@ -; RUN: llc -O2 < %s | grep debug_loc12 +; RUN: llc -march=x86 -O2 < %s | grep debug_loc12 ; Test to check .debug_loc support. This test case emits 13 debug_loc entries. %0 = type { double } From ofv at wanadoo.es Sun Aug 15 17:14:36 2010 From: ofv at wanadoo.es (Oscar Fuentes) Date: Sun, 15 Aug 2010 22:14:36 -0000 Subject: [llvm-commits] [llvm] r111111 - /llvm/trunk/tools/llvm-config/CMakeLists.txt Message-ID: <20100815221436.2DCE02A6C12C@llvm.org> Author: ofv Date: Sun Aug 15 17:14:36 2010 New Revision: 111111 URL: http://llvm.org/viewvc/llvm-project?rev=111111&view=rev Log: CMake: Improved COMMENT on a custom command Modified: llvm/trunk/tools/llvm-config/CMakeLists.txt Modified: llvm/trunk/tools/llvm-config/CMakeLists.txt URL: http://llvm.org/viewvc/llvm-project/llvm/trunk/tools/llvm-config/CMakeLists.txt?rev=111111&r1=111110&r2=111111&view=diff ============================================================================== --- llvm/trunk/tools/llvm-config/CMakeLists.txt (original) +++ llvm/trunk/tools/llvm-config/CMakeLists.txt Sun Aug 15 17:14:36 2010 @@ -78,7 +78,7 @@ add_custom_command(OUTPUT ${LIBDEPS} COMMAND ${CMAKE_COMMAND} -E copy_if_different ${LIBDEPS_TMP} ${LIBDEPS} DEPENDS ${LIBDEPS_TMP} - COMMENT "Updated ${LIBDEPS} because dependencies changed") + COMMENT "Updating ${LIBDEPS} if necessary...") add_custom_command(OUTPUT ${FINAL_LIBDEPS} COMMAND ${PERL_EXECUTABLE} ${CMAKE_CURRENT_SOURCE_DIR}/find-cycles.pl < ${LIBDEPS} > ${FINAL_LIBDEPS} || ${CMAKE_COMMAND} -E remove -f ${FINAL_LIBDEPS} From ofv at wanadoo.es Sun Aug 15 17:14:42 2010 From: ofv at wanadoo.es (Oscar Fuentes) Date: Sun, 15 Aug 2010 22:14:42 -0000 Subject: [llvm-commits] [llvm] r111112 - /llvm/trunk/cmake/modules/LLVMLibDeps.cmake Message-ID: <20100815221442.94D792A6C12D@llvm.org> Author: ofv Date: Sun Aug 15 17:14:42 2010 New Revision: 111112 URL: http://llvm.org/viewvc/llvm-project?rev=111112&view=rev Log: Updated LLVMLibDeps.cmake Modified: llvm/trunk/cmake/modules/LLVMLibDeps.cmake Modified: llvm/trunk/cmake/modules/LLVMLibDeps.cmake URL: http://llvm.org/viewvc/llvm-project/llvm/trunk/cmake/modules/LLVMLibDeps.cmake?rev=111112&r1=111111&r2=111112&view=diff ============================================================================== --- llvm/trunk/cmake/modules/LLVMLibDeps.cmake (original) +++ llvm/trunk/cmake/modules/LLVMLibDeps.cmake Sun Aug 15 17:14:42 2010 @@ -1,4 +1,4 @@ -set(MSVC_LIB_DEPS_LLVMARMAsmParser LLVMARMInfo LLVMMCParser LLVMSupport LLVMTarget) +set(MSVC_LIB_DEPS_LLVMARMAsmParser LLVMARMInfo LLVMMC LLVMMCParser LLVMSupport LLVMTarget) set(MSVC_LIB_DEPS_LLVMARMAsmPrinter LLVMMC LLVMSupport) set(MSVC_LIB_DEPS_LLVMARMCodeGen LLVMARMInfo LLVMAnalysis LLVMAsmPrinter LLVMCodeGen LLVMCore LLVMMC LLVMSelectionDAG LLVMSupport LLVMSystem LLVMTarget) set(MSVC_LIB_DEPS_LLVMARMInfo LLVMSupport) @@ -43,7 +43,6 @@ set(MSVC_LIB_DEPS_LLVMMipsAsmPrinter LLVMAsmPrinter LLVMCodeGen LLVMCore LLVMMC LLVMMipsCodeGen LLVMMipsInfo LLVMSupport LLVMTarget) set(MSVC_LIB_DEPS_LLVMMipsCodeGen LLVMCodeGen LLVMCore LLVMMC LLVMMipsInfo LLVMSelectionDAG LLVMSupport LLVMSystem LLVMTarget) set(MSVC_LIB_DEPS_LLVMMipsInfo LLVMSupport) -set(MSVC_LIB_DEPS_LLVMPIC16 LLVMAnalysis LLVMCodeGen LLVMCore LLVMMC LLVMPIC16CodeGen LLVMPIC16Info LLVMSelectionDAG LLVMSupport LLVMTarget) set(MSVC_LIB_DEPS_LLVMPIC16AsmPrinter LLVMAsmPrinter LLVMCodeGen LLVMCore LLVMMC LLVMPIC16CodeGen LLVMPIC16Info LLVMSupport LLVMTarget) set(MSVC_LIB_DEPS_LLVMPIC16CodeGen LLVMAnalysis LLVMCodeGen LLVMCore LLVMMC LLVMPIC16Info LLVMSelectionDAG LLVMSupport LLVMTarget) set(MSVC_LIB_DEPS_LLVMPIC16Info LLVMSupport) @@ -67,7 +66,6 @@ set(MSVC_LIB_DEPS_LLVMX86CodeGen LLVMAnalysis LLVMAsmPrinter LLVMCodeGen LLVMCore LLVMMC LLVMSelectionDAG LLVMSupport LLVMSystem LLVMTarget LLVMX86AsmPrinter LLVMX86Info) set(MSVC_LIB_DEPS_LLVMX86Disassembler LLVMMC LLVMSupport LLVMX86Info) set(MSVC_LIB_DEPS_LLVMX86Info LLVMSupport) -set(MSVC_LIB_DEPS_LLVMXCore LLVMCodeGen LLVMCore LLVMMC LLVMSelectionDAG LLVMSupport LLVMTarget LLVMXCoreCodeGen LLVMXCoreInfo) set(MSVC_LIB_DEPS_LLVMXCoreAsmPrinter LLVMAsmPrinter LLVMCodeGen LLVMCore LLVMMC LLVMSupport LLVMTarget LLVMXCoreInfo) set(MSVC_LIB_DEPS_LLVMXCoreCodeGen LLVMCodeGen LLVMCore LLVMMC LLVMSelectionDAG LLVMSupport LLVMTarget LLVMXCoreInfo) set(MSVC_LIB_DEPS_LLVMXCoreInfo LLVMSupport) From nicholas at mxc.ca Sun Aug 15 18:07:26 2010 From: nicholas at mxc.ca (Nick Lewycky) Date: Sun, 15 Aug 2010 16:07:26 -0700 Subject: [llvm-commits] [patch][Target/PTX] Create PTX backend In-Reply-To: References: Message-ID: <4C68732E.20103@mxc.ca> Hi Che-Liang, I appreciate that you're doing this one small patch at a time. That's really the right approach, but in this case we have two competing backends for a PTX target. Is there any way we could see the full source to yours so we can take a look and decide whether we want to invest time in reviewing yours, or Helge's or both? Nick Che-Liang Chiou wrote: > SVN revision: 110776 > > This patch is a part of upstream work of a PTX backend using LLVM code > generator. > > Change list summary: > - Add an empty backend that is merely compilable > - Add PTX entry to autoconf/configure.ac and include/llvm/ADT/Triple.h > > Outcome: > $ ./configure --enable-targets=ptx > $ make > $ llc -version | grep ptx > ptx - PTX > > Misc: > - Diff of auto-generated files are put in a separated patch > - The autotool version on my machine is newer than > autoconf/AutoGegen.sh requires, so the diff of auto-gen'd files might > be differ with that on your machine > > Cheers, > Che-Liang > > > > _______________________________________________ > llvm-commits mailing list > llvm-commits at cs.uiuc.edu > http://lists.cs.uiuc.edu/mailman/listinfo/llvm-commits From benny.kra at googlemail.com Sun Aug 15 18:32:03 2010 From: benny.kra at googlemail.com (Benjamin Kramer) Date: Sun, 15 Aug 2010 23:32:03 -0000 Subject: [llvm-commits] [llvm] r111115 - /llvm/trunk/test/CodeGen/X86/2010-05-25-DotDebugLoc.ll Message-ID: <20100815233203.911F02A6C12C@llvm.org> Author: d0k Date: Sun Aug 15 18:32:03 2010 New Revision: 111115 URL: http://llvm.org/viewvc/llvm-project?rev=111115&view=rev Log: Test expects SSE, give him SSE. Modified: llvm/trunk/test/CodeGen/X86/2010-05-25-DotDebugLoc.ll Modified: llvm/trunk/test/CodeGen/X86/2010-05-25-DotDebugLoc.ll URL: http://llvm.org/viewvc/llvm-project/llvm/trunk/test/CodeGen/X86/2010-05-25-DotDebugLoc.ll?rev=111115&r1=111114&r2=111115&view=diff ============================================================================== --- llvm/trunk/test/CodeGen/X86/2010-05-25-DotDebugLoc.ll (original) +++ llvm/trunk/test/CodeGen/X86/2010-05-25-DotDebugLoc.ll Sun Aug 15 18:32:03 2010 @@ -1,4 +1,4 @@ -; RUN: llc -march=x86 -O2 < %s | grep debug_loc12 +; RUN: llc -march=x86-64 -O2 < %s | grep debug_loc12 ; Test to check .debug_loc support. This test case emits 13 debug_loc entries. %0 = type { double }