[llvm-commits] [llvm] r44786 - /llvm/trunk/lib/CodeGen/StrongPHIElimination.cpp
Author: resistor Date: Mon Dec 10 02:07:09 2007 New Revision: 44786 URL: http://llvm.org/viewvc/llvm-project?rev=44786&view=rev Log: A little more progress on StrongPHIElimination, now that I have a better sense of how the CodeGen machinery works. Modified: llvm/trunk/lib/CodeGen/StrongPHIElimination.cpp Modified: llvm/trunk/lib/CodeGen/StrongPHIElimination.cpp URL: http://llvm.org/viewvc/llvm-project/llvm/trunk/lib/CodeGen/StrongPHIElimination.cpp?rev=44786&r1=44785&r2=44786&view=diff == --- llvm/trunk/lib/CodeGen/StrongPHIElimination.cpp (original) +++ llvm/trunk/lib/CodeGen/StrongPHIElimination.cpp Mon Dec 10 02:07:09 2007 @@ -39,6 +39,9 @@ static char ID; // Pass identification, replacement for typeid StrongPHIElimination() : MachineFunctionPass((intptr_t)&ID) {} +DenseMap, 2> > Waiting; + bool runOnMachineFunction(MachineFunction &Fn); virtual void getAnalysisUsage(AnalysisUsage &AU) const { @@ -263,6 +266,8 @@ while (P->getOpcode() == TargetInstrInfo::PHI) { LiveVariables::VarInfo& PHIInfo = LV.getVarInfo(P->getOperand(0).getReg()); +unsigned DestReg = P->getOperand(0).getReg(); + // Hold the names that are currently in the candidate set. std::set PHIUnion; std::set UnionedBlocks; @@ -271,17 +276,17 @@ unsigned SrcReg = P->getOperand(i-1).getReg(); LiveVariables::VarInfo& SrcInfo = LV.getVarInfo(SrcReg); - if (isLiveIn(SrcInfo, P->getParent())) { + // Check for trivial interferences + if (isLiveIn(SrcInfo, P->getParent()) || + isLiveOut(PHIInfo, SrcInfo.DefInst->getParent()) || + ( PHIInfo.DefInst->getOpcode() == TargetInstrInfo::PHI && +isLiveIn(PHIInfo, SrcInfo.DefInst->getParent()) ) || + ProcessedNames.count(SrcReg) || + UnionedBlocks.count(SrcInfo.DefInst->getParent())) { + // add a copy from a_i to p in Waiting[From[a_i]] - } else if (isLiveOut(PHIInfo, SrcInfo.DefInst->getParent())) { -// add a copy to Waiting[From[a_i]] - } else if (PHIInfo.DefInst->getOpcode() == TargetInstrInfo::PHI && - isLiveIn(PHIInfo, SrcInfo.DefInst->getParent())) { -// add a copy to Waiting[From[a_i]] - } else if (ProcessedNames.count(SrcReg)) { -// add a copy to Waiting[From[a_i]] - } else if (UnionedBlocks.count(SrcInfo.DefInst->getParent())) { -// add a copy to Waiting[From[a_i]] +MachineBasicBlock* From = P->getOperand(i).getMachineBasicBlock(); +Waiting[From].push_back(std::make_pair(SrcReg, DestReg)); } else { PHIUnion.insert(SrcReg); UnionedBlocks.insert(SrcInfo.DefInst->getParent()); @@ -291,7 +296,7 @@ std::vector DF = computeDomForest(PHIUnion); -// DO STUFF HERE +// Walk DomForest to resolve interferences ProcessedNames.insert(PHIUnion.begin(), PHIUnion.end()); ++P; ___ llvm-commits mailing list llvm-commits@cs.uiuc.edu http://lists.cs.uiuc.edu/mailman/listinfo/llvm-commits
[llvm-commits] [llvm] r44791 - /llvm/trunk/lib/ExecutionEngine/Interpreter/ExternalFunctions.cpp
Author: baldrick Date: Mon Dec 10 08:43:10 2007 New Revision: 44791 URL: http://llvm.org/viewvc/llvm-project?rev=44791&view=rev Log: It looks like this has been broken for some time - get it to compile. Modified: llvm/trunk/lib/ExecutionEngine/Interpreter/ExternalFunctions.cpp Modified: llvm/trunk/lib/ExecutionEngine/Interpreter/ExternalFunctions.cpp URL: http://llvm.org/viewvc/llvm-project/llvm/trunk/lib/ExecutionEngine/Interpreter/ExternalFunctions.cpp?rev=44791&r1=44790&r2=44791&view=diff == --- llvm/trunk/lib/ExecutionEngine/Interpreter/ExternalFunctions.cpp (original) +++ llvm/trunk/lib/ExecutionEngine/Interpreter/ExternalFunctions.cpp Mon Dec 10 08:43:10 2007 @@ -246,14 +246,14 @@ GenericValue lle_X_lrand48(FunctionType *FT, const vector &Args) { assert(Args.size() == 0); GenericValue GV; - GV.Int32Val = lrand48(); + GV.IntVal = APInt(32, lrand48()); return GV; } // void srand48(long) GenericValue lle_X_srand48(FunctionType *FT, const vector &Args) { assert(Args.size() == 1); - srand48(Args[0].Int32Val); + srand48(Args[0].IntVal.getZExtValue()); return GenericValue(); } ___ llvm-commits mailing list llvm-commits@cs.uiuc.edu http://lists.cs.uiuc.edu/mailman/listinfo/llvm-commits
Re: [llvm-commits] [llvm] r44687 - in /llvm/trunk: include/llvm/CodeGen/Passes.h lib/CodeGen/LLVMTargetMachine.cpp lib/CodeGen/MachineLICM.cpp lib/Target/PowerPC/PPCInstrInfo.td
> Thanks for pointing this out. I'll go over it when I'm doing the load/ > store instructions in my pass. Hi Bill, How involved will MachineLICM be? After LLVM's main LICM pass runs, it seems all that's left for MachineLICM to do are just the constant-pool loads, immediates, etc. that aren't exposed in the main LLVM IR, things that don't require alias analysis. And if that's all it's doing, MachineLICM's traversal could be simplified a little. Instead of visiting each loop individually, taking care to avoid revisiting to blocks within inner loops, the pass could just traverse entire outer-most loops, which will implicitly include the blocks of any inner loops. Instructions nested deep in inner loops can then be hoisted all the way out of the outer-most loop in a single step instead of being hoisted out one loop at a time. Dan -- Dan Gohman, Cray Inc. ___ llvm-commits mailing list llvm-commits@cs.uiuc.edu http://lists.cs.uiuc.edu/mailman/listinfo/llvm-commits
[llvm-commits] [llvm] r44792 - /llvm/trunk/lib/Target/X86/X86JITInfo.cpp
Author: asl Date: Mon Dec 10 08:54:42 2007 New Revision: 44792 URL: http://llvm.org/viewvc/llvm-project?rev=44792&view=rev Log: Annotate JIT callback function with call frame infromation. This will allow us (theoretically) to unwind through JITer. The code wasn't verified, so I'm pretty sure offsets are wrong :) Modified: llvm/trunk/lib/Target/X86/X86JITInfo.cpp Modified: llvm/trunk/lib/Target/X86/X86JITInfo.cpp URL: http://llvm.org/viewvc/llvm-project/llvm/trunk/lib/Target/X86/X86JITInfo.cpp?rev=44792&r1=44791&r2=44792&view=diff == --- llvm/trunk/lib/Target/X86/X86JITInfo.cpp (original) +++ llvm/trunk/lib/Target/X86/X86JITInfo.cpp Mon Dec 10 08:54:42 2007 @@ -116,11 +116,18 @@ ".align 8\n" ".globl " ASMPREFIX "X86CompilationCallback\n" ASMPREFIX "X86CompilationCallback:\n" +".cfi_startproc\n" "pushl %ebp\n" +".cfi_def_cfa_offset 8\n" +".cfi_offset ebp, -8\n" "movl%esp, %ebp\n"// Standard prologue +".cfi_def_cfa_register ebp\n" "pushl %eax\n" +".cfi_rel_offset eax, 0\n" "pushl %edx\n" // Save EAX/EDX/ECX +".cfi_rel_offset edx, 4\n" "pushl %ecx\n" +".cfi_rel_offset ecx, 8\n" #if defined(__APPLE__) "andl$-16, %esp\n"// Align ESP on 16-byte boundary #endif @@ -130,12 +137,23 @@ "movl%ebp, (%esp)\n" "call" ASMPREFIX "X86CompilationCallback2\n" "movl%ebp, %esp\n"// Restore ESP +".cfi_def_cfa_register esp\n" "subl$12, %esp\n" +".cfi_adjust_cfa_offset 12\n" "popl%ecx\n" +".cfi_adjust_cfa_offset -4\n" +".cfi_restore ecx\n" "popl%edx\n" +".cfi_adjust_cfa_offset -4\n" +".cfi_restore edx\n" "popl%eax\n" +".cfi_adjust_cfa_offset -4\n" +".cfi_restore eax\n" "popl%ebp\n" -"ret\n"); +".cfi_adjust_cfa_offset -4\n" +".cfi_restore ebp\n" +"ret\n" +".cfi_endproc\n"); // Same as X86CompilationCallback but also saves XMM argument registers. void X86CompilationCallback_SSE(void); ___ llvm-commits mailing list llvm-commits@cs.uiuc.edu http://lists.cs.uiuc.edu/mailman/listinfo/llvm-commits
[llvm-commits] [llvm] r44793 - /llvm/trunk/lib/Target/X86/X86JITInfo.cpp
Author: asl Date: Mon Dec 10 09:13:55 2007 New Revision: 44793 URL: http://llvm.org/viewvc/llvm-project?rev=44793&view=rev Log: Provide annotation for SSE version of callback. It's even more broken, because doesn't mark xmm regs properly Modified: llvm/trunk/lib/Target/X86/X86JITInfo.cpp Modified: llvm/trunk/lib/Target/X86/X86JITInfo.cpp URL: http://llvm.org/viewvc/llvm-project/llvm/trunk/lib/Target/X86/X86JITInfo.cpp?rev=44793&r1=44792&r2=44793&view=diff == --- llvm/trunk/lib/Target/X86/X86JITInfo.cpp (original) +++ llvm/trunk/lib/Target/X86/X86JITInfo.cpp Mon Dec 10 09:13:55 2007 @@ -162,14 +162,24 @@ ".align 8\n" ".globl " ASMPREFIX "X86CompilationCallback_SSE\n" ASMPREFIX "X86CompilationCallback_SSE:\n" +".cfi_startproc\n" "pushl %ebp\n" +".cfi_def_cfa_offset 8\n" +".cfi_offset ebp, -8\n" "movl%esp, %ebp\n"// Standard prologue +".cfi_def_cfa_register ebp\n" "pushl %eax\n" +".cfi_rel_offset eax, 0\n" "pushl %edx\n" // Save EAX/EDX/ECX +".cfi_rel_offset edx, 4\n" "pushl %ecx\n" +".cfi_rel_offset ecx, 8\n" "andl$-16, %esp\n"// Align ESP on 16-byte boundary // Save all XMM arg registers "subl$64, %esp\n" +// FIXME: provide frame move information for xmm registers. +// This can be tricky, because CFA register is ebp (unaligned) +// and we need to produce offsets relative to it. "movaps %xmm0, (%esp)\n" "movaps %xmm1, 16(%esp)\n" "movaps %xmm2, 32(%esp)\n" @@ -181,16 +191,31 @@ "call" ASMPREFIX "X86CompilationCallback2\n" "addl$16, %esp\n" "movaps 48(%esp), %xmm3\n" +".cfi_restore xmm3\n" "movaps 32(%esp), %xmm2\n" +".cfi_restore xmm2\n" "movaps 16(%esp), %xmm1\n" +".cfi_restore xmm1\n" "movaps (%esp), %xmm0\n" +".cfi_restore xmm0\n" "movl%ebp, %esp\n"// Restore ESP +".cfi_def_cfa_register esp\n" "subl$12, %esp\n" +".cfi_adjust_cfa_offset 12\n" "popl%ecx\n" +".cfi_adjust_cfa_offset -4\n" +".cfi_restore ecx\n" "popl%edx\n" +".cfi_adjust_cfa_offset -4\n" +".cfi_restore edx\n" "popl%eax\n" +".cfi_adjust_cfa_offset -4\n" +".cfi_restore eax\n" "popl%ebp\n" -"ret\n"); +".cfi_adjust_cfa_offset -4\n" +".cfi_restore ebp\n" +"ret\n" +".cfi_endproc\n"); #else void X86CompilationCallback2(void); ___ llvm-commits mailing list llvm-commits@cs.uiuc.edu http://lists.cs.uiuc.edu/mailman/listinfo/llvm-commits
[llvm-commits] [llvm] r44794 - /llvm/trunk/lib/Target/X86/X86JITInfo.cpp
Author: asl Date: Mon Dec 10 09:27:07 2007 New Revision: 44794 URL: http://llvm.org/viewvc/llvm-project?rev=44794&view=rev Log: And finally annotate X86-64 version of callback. All bad stuff from SSE version is implicitely inherited :) Modified: llvm/trunk/lib/Target/X86/X86JITInfo.cpp Modified: llvm/trunk/lib/Target/X86/X86JITInfo.cpp URL: http://llvm.org/viewvc/llvm-project/llvm/trunk/lib/Target/X86/X86JITInfo.cpp?rev=44794&r1=44793&r2=44794&view=diff == --- llvm/trunk/lib/Target/X86/X86JITInfo.cpp (original) +++ llvm/trunk/lib/Target/X86/X86JITInfo.cpp Mon Dec 10 09:27:07 2007 @@ -58,17 +58,27 @@ ".align 8\n" ".globl " ASMPREFIX "X86CompilationCallback\n" ASMPREFIX "X86CompilationCallback:\n" +".cfi_startproc\n" // Save RBP "pushq %rbp\n" +".cfi_def_cfa_offset 16\n" +".cfi_offset %rbp, -16\n" // Save RSP "movq%rsp, %rbp\n" +".cfi_def_cfa_register %rbp\n" // Save all int arg registers "pushq %rdi\n" +".cfi_rel_offset %rdi, 0\n" "pushq %rsi\n" +".cfi_rel_offset %rsi, 8\n" "pushq %rdx\n" +".cfi_rel_offset %rdx, 16\n" "pushq %rcx\n" +".cfi_rel_offset %rcx, 24\n" "pushq %r8\n" +".cfi_rel_offset %r8, 32\n" "pushq %r9\n" +".cfi_rel_offset %r9, 40\n" // Align stack on 16-byte boundary. ESP might not be properly aligned // (8 byte) if this is called from an indirect stub. "andq$-16, %rsp\n" @@ -97,17 +107,34 @@ "movaps (%rsp), %xmm0\n" // Restore RSP "movq%rbp, %rsp\n" +".cfi_def_cfa_register esp\n" // Restore all int arg registers "subq$48, %rsp\n" +".cfi_adjust_cfa_offset 48\n" "popq%r9\n" +".cfi_adjust_cfa_offset -8\n" +".cfi_restore %r9\n" "popq%r8\n" +".cfi_adjust_cfa_offset -8\n" +".cfi_restore %r8\n" "popq%rcx\n" +".cfi_adjust_cfa_offset -8\n" +".cfi_restore %rcx\n" "popq%rdx\n" +".cfi_adjust_cfa_offset -8\n" +".cfi_restore %rdx\n" "popq%rsi\n" +".cfi_adjust_cfa_offset -8\n" +".cfi_restore %rsi\n" "popq%rdi\n" +".cfi_adjust_cfa_offset -8\n" +".cfi_restore %rdi\n" // Restore RBP "popq%rbp\n" -"ret\n"); +".cfi_adjust_cfa_offset -8\n" +".cfi_restore %rbp\n" +"ret\n" +".cfi_endproc\n"); #elif defined(__i386__) || defined(i386) || defined(_M_IX86) #ifndef _MSC_VER void X86CompilationCallback(void); @@ -119,15 +146,15 @@ ".cfi_startproc\n" "pushl %ebp\n" ".cfi_def_cfa_offset 8\n" -".cfi_offset ebp, -8\n" +".cfi_offset %ebp, -8\n" "movl%esp, %ebp\n"// Standard prologue -".cfi_def_cfa_register ebp\n" +".cfi_def_cfa_register %ebp\n" "pushl %eax\n" -".cfi_rel_offset eax, 0\n" +".cfi_rel_offset %eax, 0\n" "pushl %edx\n" // Save EAX/EDX/ECX -".cfi_rel_offset edx, 4\n" +".cfi_rel_offset %edx, 4\n" "pushl %ecx\n" -".cfi_rel_offset ecx, 8\n" +".cfi_rel_offset %ecx, 8\n" #if defined(__APPLE__) "andl$-16, %esp\n"// Align ESP on 16-byte boundary #endif @@ -137,21 +164,21 @@ "movl%ebp, (%esp)\n" "call" ASMPREFIX "X86CompilationCallback2\n" "movl%ebp, %esp\n"// Restore ESP -".cfi_def_cfa_register esp\n" +".cfi_def_cfa_register %esp\n" "subl$12, %esp\n" ".cfi_adjust_cfa_offset 12\n" "popl%ecx\n" ".cfi_adjust_cfa_offset -4\n" -".cfi_restore ecx\n" +".cfi_restore %ecx\n" "popl%edx\n" ".cfi_adjust_cfa_offset -4\n" -".cfi_restore edx\n" +".cfi_restore %edx\n" "popl%eax\n" ".cfi_adjust_cfa_offset -4\n" -".cfi_restore eax\n" +".cfi_restore %eax\n" "popl%ebp\n" ".cfi_adjust_cfa_offset -4\n" -".cfi_restore ebp\n" +".cfi_restore %ebp\n" "ret\n" ".cfi_endproc\n"); @@ -165,15 +192,15 @@ ".cfi_startproc\n" "pushl %ebp\n" ".cfi_def_cfa_offset 8\n" -".cfi_offset ebp, -8\n" +".cfi_offset %ebp, -8\n" "movl%esp, %ebp\n"// Standard prologue -".cfi_def_cfa_register ebp\n" +".cfi_def_cfa_register %ebp\n" "pushl %eax\n" -".cfi_rel_offset eax, 0\n" +".cfi_rel_offset %eax, 0\n" "pushl %edx\n" // Save EAX/EDX/ECX -".cfi_rel_offset edx, 4\n" +".cfi_rel_offset %edx, 4\n" "pushl %ecx\n" -".cfi_rel_offset ecx, 8\n" +".cfi_rel_offset %ecx, 8\n" "andl$-16, %esp\n"// Align ESP on 16-byte boundary // Save all XMM arg registers "subl$64, %esp\n" @@ -191,29 +218,29 @@ "call" ASMPREFIX "X86CompilationCallback2\n" "addl$16, %esp\n" "movaps 48(%esp), %xmm3\n" -".cfi_restore xmm3\n" +".cfi_restore %xmm3\n" "movaps 32(%esp), %xmm2\n" -".cfi_restore xmm2\n" +".cfi_restore %xmm2\n" "movaps 16(%esp), %xmm1\n" -".cfi_re
[llvm-commits] [llvm] r44796 - in /llvm/trunk: autoconf/configure.ac configure include/llvm/Config/config.h.in include/llvm/Target/TargetData.h lib/ExecutionEngine/ExecutionEngine.cpp test/ExecutionEn
Author: baldrick Date: Mon Dec 10 11:43:13 2007 New Revision: 44796 URL: http://llvm.org/viewvc/llvm-project?rev=44796&view=rev Log: Fix PR1836: in the interpreter, read and write apints using the minimum possible number of bytes. For little endian targets run on little endian machines, apints are stored in memory from LSB to MSB as before. For big endian targets on big endian machines they are stored from MSB to LSB which wasn't always the case before (if the target and host endianness doesn't match values are stored according to the host's endianness). Doing this requires knowing the endianness of the host, which is determined when configuring - thanks go to Anton for this. Only having access to little endian machines I was unable to properly test the big endian part, which is also the most complicated... Added: llvm/trunk/test/ExecutionEngine/2007-12-10-APIntLoadStore.ll Modified: llvm/trunk/autoconf/configure.ac llvm/trunk/configure llvm/trunk/include/llvm/Config/config.h.in llvm/trunk/include/llvm/Target/TargetData.h llvm/trunk/lib/ExecutionEngine/ExecutionEngine.cpp Modified: llvm/trunk/autoconf/configure.ac URL: http://llvm.org/viewvc/llvm-project/llvm/trunk/autoconf/configure.ac?rev=44796&r1=44795&r2=44796&view=diff == --- llvm/trunk/autoconf/configure.ac (original) +++ llvm/trunk/autoconf/configure.ac Mon Dec 10 11:43:13 2007 @@ -227,7 +227,10 @@ AC_SUBST(ARCH,$llvm_cv_target_arch) dnl Check for the endianness of the target -AC_C_BIGENDIAN(AC_SUBST([ENDIAN],[big]),AC_SUBST([ENDIAN],[little])) +AC_C_BIGENDIAN([AC_SUBST([ENDIAN],[big]), +AC_DEFINE([MSB_FIRST], [1], [Define if this target is big endian])], + [AC_SUBST([ENDIAN],[little]), +AC_DEFINE([LSB_FIRST], [1], [Define if this target is little endian])]) dnl Check for build platform executable suffix if we're crosscompiling if test "$cross_compiling" = yes; then Modified: llvm/trunk/configure URL: http://llvm.org/viewvc/llvm-project/llvm/trunk/configure?rev=44796&r1=44795&r2=44796&view=diff == --- llvm/trunk/configure (original) +++ llvm/trunk/configure Mon Dec 10 11:43:13 2007 @@ -828,7 +828,6 @@ LLVM_ON_UNIX LLVM_ON_WIN32 ARCH -ENDIAN CC CFLAGS LDFLAGS @@ -839,6 +838,7 @@ CPP GREP EGREP +ENDIAN LLVM_CROSS_COMPILING BUILD_CC BUILD_EXEEXT @@ -4183,9 +4183,19 @@ case $ac_cv_c_bigendian in yes) ENDIAN=big +, + +cat >>confdefs.h <<\_ACEOF +#define MSB_FIRST 1 +_ACEOF ;; no) ENDIAN=little +, + +cat >>confdefs.h <<\_ACEOF +#define LSB_FIRST 1 +_ACEOF ;; *) { { echo "$as_me:$LINENO: error: unknown endianness @@ -8220,7 +8230,9 @@ fi - if test x"${enable_ltdl_install-no}" != xno; then + + +if test x"${enable_ltdl_install-no}" != xno; then INSTALL_LTDL_TRUE= INSTALL_LTDL_FALSE='#' else @@ -8228,7 +8240,9 @@ INSTALL_LTDL_FALSE= fi - if test x"${enable_ltdl_convenience-no}" != xno; then + + +if test x"${enable_ltdl_convenience-no}" != xno; then CONVENIENCE_LTDL_TRUE= CONVENIENCE_LTDL_FALSE='#' else @@ -9867,7 +9881,7 @@ lt_dlunknown=0; lt_dlno_uscore=1; lt_dlneed_uscore=2 lt_status=$lt_dlunknown cat > conftest.$ac_ext < conftest.$ac_ext + echo '#line 11819 "configure"' > conftest.$ac_ext if { (eval echo "$as_me:$LINENO: \"$ac_compile\"") >&5 (eval $ac_compile) 2>&5 ac_status=$? @@ -13442,11 +13456,11 @@ -e 's:.*FLAGS}\{0,1\} :&$lt_compiler_flag :; t' \ -e 's: [^ ]*conftest\.: $lt_compiler_flag&:; t' \ -e 's:$: $lt_compiler_flag:'` - (eval echo "\"\$as_me:13445: $lt_compile\"" >&5) + (eval echo "\"\$as_me:13459: $lt_compile\"" >&5) (eval "$lt_compile" 2>conftest.err) ac_status=$? cat conftest.err >&5 - echo "$as_me:13449: \$? = $ac_status" >&5 + echo "$as_me:13463: \$? = $ac_status" >&5 if (exit $ac_status) && test -s "$ac_outfile"; then # The compiler can only warn and ignore the option if not recognized # So say no if there are warnings other than the usual output. @@ -13710,11 +13724,11 @@ -e 's:.*FLAGS}\{0,1\} :&$lt_compiler_flag :; t' \ -e 's: [^ ]*conftest\.: $lt_compiler_flag&:; t' \ -e 's:$: $lt_compiler_flag:'` - (eval echo "\"\$as_me:13713: $lt_compile\"" >&5) + (eval echo "\"\$as_me:13727: $lt_compile\"" >&5) (eval "$lt_compile" 2>conftest.err) ac_status=$? cat conftest.err >&5 - echo "$as_me:13717: \$? = $ac_status" >&5 + echo "$as_me:13731: \$? = $ac_status" >&5 if (exit $ac_status) && test -s "$ac_outfile"; then # The compiler can only warn and ignore the option if not recognized # So say no if there are warnings other than the usual output. @@ -13814,11 +13828,11 @@ -e 's:.*FLAGS}\{0,1\} :&$lt_compiler_flag :; t' \ -e 's: [^ ]*conftest\.: $lt_compiler_flag&:; t' \ -e 's:$: $lt_compiler_flag:'` - (eval echo "\"\
[llvm-commits] [llvm] r44802 - in /llvm/trunk: include/llvm/Function.h include/llvm/Instructions.h lib/Transforms/IPO/PruneEH.cpp lib/Transforms/Scalar/SimplifyCFG.cpp test/Transforms/PruneEH/simpleno
Author: baldrick Date: Mon Dec 10 13:09:40 2007 New Revision: 44802 URL: http://llvm.org/viewvc/llvm-project?rev=44802&view=rev Log: Make PruneEH update the nounwind/noreturn attributes on functions as it calculates them. Added: llvm/trunk/test/Transforms/PruneEH/simpletest.ll Removed: llvm/trunk/test/Transforms/PruneEH/simpletest.llx Modified: llvm/trunk/include/llvm/Function.h llvm/trunk/include/llvm/Instructions.h llvm/trunk/lib/Transforms/IPO/PruneEH.cpp llvm/trunk/lib/Transforms/Scalar/SimplifyCFG.cpp llvm/trunk/test/Transforms/PruneEH/simplenoreturntest.ll Modified: llvm/trunk/include/llvm/Function.h URL: http://llvm.org/viewvc/llvm-project/llvm/trunk/include/llvm/Function.h?rev=44802&r1=44801&r2=44802&view=diff == --- llvm/trunk/include/llvm/Function.h (original) +++ llvm/trunk/include/llvm/Function.h Mon Dec 10 13:09:40 2007 @@ -165,6 +165,16 @@ return ParamAttrs && ParamAttrs->paramHasAttr(i, attr); } + /// @brief Determine if the function cannot return. + bool isNoReturn() const { +return paramHasAttr(0, ParamAttr::NoReturn); + } + + /// @brief Determine if the function cannot unwind. + bool isNoUnwind() const { +return paramHasAttr(0, ParamAttr::NoUnwind); + } + /// @brief Determine if the function does not access memory. bool doesNotAccessMemory() const { return paramHasAttr(0, ParamAttr::ReadNone); Modified: llvm/trunk/include/llvm/Instructions.h URL: http://llvm.org/viewvc/llvm-project/llvm/trunk/include/llvm/Instructions.h?rev=44802&r1=44801&r2=44802&view=diff == --- llvm/trunk/include/llvm/Instructions.h (original) +++ llvm/trunk/include/llvm/Instructions.h Mon Dec 10 13:09:40 2007 @@ -937,6 +937,11 @@ return doesNotAccessMemory() || paramHasAttr(0, ParamAttr::ReadOnly); } + /// @brief Determine if the call cannot return. + bool isNoReturn() const { +return paramHasAttr(0, ParamAttr::NoReturn); + } + /// @brief Determine if the call cannot unwind. bool isNoUnwind() const { return paramHasAttr(0, ParamAttr::NoUnwind); @@ -1736,6 +1741,11 @@ return doesNotAccessMemory() || paramHasAttr(0, ParamAttr::ReadOnly); } + /// @brief Determine if the call cannot return. + bool isNoReturn() const { +return paramHasAttr(0, ParamAttr::NoReturn); + } + /// @brief Determine if the call cannot unwind. bool isNoUnwind() const { return paramHasAttr(0, ParamAttr::NoUnwind); Modified: llvm/trunk/lib/Transforms/IPO/PruneEH.cpp URL: http://llvm.org/viewvc/llvm-project/llvm/trunk/lib/Transforms/IPO/PruneEH.cpp?rev=44802&r1=44801&r2=44802&view=diff == --- llvm/trunk/lib/Transforms/IPO/PruneEH.cpp (original) +++ llvm/trunk/lib/Transforms/IPO/PruneEH.cpp Mon Dec 10 13:09:40 2007 @@ -9,8 +9,8 @@ // // This file implements a simple interprocedural pass which walks the // call-graph, turning invoke instructions into calls, iff the callee cannot -// throw an exception. It implements this as a bottom-up traversal of the -// call-graph. +// throw an exception, and marking functions 'nounwind' if they cannot throw. +// It implements this as a bottom-up traversal of the call-graph. // //===--===// @@ -19,7 +19,6 @@ #include "llvm/CallGraphSCCPass.h" #include "llvm/Constants.h" #include "llvm/Function.h" -#include "llvm/Intrinsics.h" #include "llvm/Instructions.h" #include "llvm/Analysis/CallGraph.h" #include "llvm/ADT/SmallVector.h" @@ -38,14 +37,6 @@ static char ID; // Pass identification, replacement for typeid PruneEH() : CallGraphSCCPass((intptr_t)&ID) {} -/// DoesNotUnwind - This set contains all of the functions which we have -/// determined cannot unwind. -std::set DoesNotUnwind; - -/// DoesNotReturn - This set contains all of the functions which we have -/// determined cannot return normally (but might unwind). -std::set DoesNotReturn; - // runOnSCC - Analyze the SCC, performing the transformation if possible. bool runOnSCC(const std::vector &SCC); @@ -79,33 +70,41 @@ for (unsigned i = 0, e = SCC.size(); (!SCCMightUnwind || !SCCMightReturn) && i != e; ++i) { Function *F = SCC[i]->getFunction(); -if (F == 0 || (F->isDeclaration() && !F->getIntrinsicID())) { +if (F == 0) { SCCMightUnwind = true; SCCMightReturn = true; +} else if (F->isDeclaration()) { + SCCMightUnwind |= !F->isNoUnwind(); + SCCMightReturn |= !F->isNoReturn(); } else { - if (F->isDeclaration()) -SCCMightReturn = true; + bool CheckUnwind = !SCCMightUnwind && !F->isNoUnwind(); + bool CheckReturn = !SCCMightReturn && !F->isNoReturn(); + + if (!CheckUnwind && !CheckReturn) +continue;
[llvm-commits] [llvm] r44803 - /llvm/trunk/lib/Target/X86/X86JITInfo.cpp
Author: lattner Date: Mon Dec 10 13:10:18 2007 New Revision: 44803 URL: http://llvm.org/viewvc/llvm-project?rev=44803&view=rev Log: Disable cfi directives for now, darwin does't support them. These should probably be something like: CFI(".cfi_def_cfa_offset 16\n") where CFI is defined to a noop on darwin and other platforms that don't support those directives. Modified: llvm/trunk/lib/Target/X86/X86JITInfo.cpp Modified: llvm/trunk/lib/Target/X86/X86JITInfo.cpp URL: http://llvm.org/viewvc/llvm-project/llvm/trunk/lib/Target/X86/X86JITInfo.cpp?rev=44803&r1=44802&r2=44803&view=diff == --- llvm/trunk/lib/Target/X86/X86JITInfo.cpp (original) +++ llvm/trunk/lib/Target/X86/X86JITInfo.cpp Mon Dec 10 13:10:18 2007 @@ -58,27 +58,27 @@ ".align 8\n" ".globl " ASMPREFIX "X86CompilationCallback\n" ASMPREFIX "X86CompilationCallback:\n" -".cfi_startproc\n" +//".cfi_startproc\n" // Save RBP "pushq %rbp\n" -".cfi_def_cfa_offset 16\n" -".cfi_offset %rbp, -16\n" +//".cfi_def_cfa_offset 16\n" +//".cfi_offset %rbp, -16\n" // Save RSP "movq%rsp, %rbp\n" -".cfi_def_cfa_register %rbp\n" +//".cfi_def_cfa_register %rbp\n" // Save all int arg registers "pushq %rdi\n" -".cfi_rel_offset %rdi, 0\n" +//".cfi_rel_offset %rdi, 0\n" "pushq %rsi\n" -".cfi_rel_offset %rsi, 8\n" +//".cfi_rel_offset %rsi, 8\n" "pushq %rdx\n" -".cfi_rel_offset %rdx, 16\n" +//".cfi_rel_offset %rdx, 16\n" "pushq %rcx\n" -".cfi_rel_offset %rcx, 24\n" +//".cfi_rel_offset %rcx, 24\n" "pushq %r8\n" -".cfi_rel_offset %r8, 32\n" +//".cfi_rel_offset %r8, 32\n" "pushq %r9\n" -".cfi_rel_offset %r9, 40\n" +//".cfi_rel_offset %r9, 40\n" // Align stack on 16-byte boundary. ESP might not be properly aligned // (8 byte) if this is called from an indirect stub. "andq$-16, %rsp\n" @@ -107,34 +107,35 @@ "movaps (%rsp), %xmm0\n" // Restore RSP "movq%rbp, %rsp\n" -".cfi_def_cfa_register esp\n" +//".cfi_def_cfa_register esp\n" // Restore all int arg registers "subq$48, %rsp\n" -".cfi_adjust_cfa_offset 48\n" +//".cfi_adjust_cfa_offset 48\n" "popq%r9\n" -".cfi_adjust_cfa_offset -8\n" -".cfi_restore %r9\n" +//".cfi_adjust_cfa_offset -8\n" +//".cfi_restore %r9\n" "popq%r8\n" -".cfi_adjust_cfa_offset -8\n" -".cfi_restore %r8\n" +//".cfi_adjust_cfa_offset -8\n" +//".cfi_restore %r8\n" "popq%rcx\n" -".cfi_adjust_cfa_offset -8\n" -".cfi_restore %rcx\n" +//".cfi_adjust_cfa_offset -8\n" +//".cfi_restore %rcx\n" "popq%rdx\n" -".cfi_adjust_cfa_offset -8\n" -".cfi_restore %rdx\n" +//".cfi_adjust_cfa_offset -8\n" +//".cfi_restore %rdx\n" "popq%rsi\n" -".cfi_adjust_cfa_offset -8\n" -".cfi_restore %rsi\n" +//".cfi_adjust_cfa_offset -8\n" +//".cfi_restore %rsi\n" "popq%rdi\n" -".cfi_adjust_cfa_offset -8\n" -".cfi_restore %rdi\n" +//".cfi_adjust_cfa_offset -8\n" +//".cfi_restore %rdi\n" // Restore RBP "popq%rbp\n" -".cfi_adjust_cfa_offset -8\n" -".cfi_restore %rbp\n" +//".cfi_adjust_cfa_offset -8\n" +//".cfi_restore %rbp\n" "ret\n" -".cfi_endproc\n"); +//".cfi_endproc\n" + ); #elif defined(__i386__) || defined(i386) || defined(_M_IX86) #ifndef _MSC_VER void X86CompilationCallback(void); @@ -143,18 +144,18 @@ ".align 8\n" ".globl " ASMPREFIX "X86CompilationCallback\n" ASMPREFIX "X86CompilationCallback:\n" -".cfi_startproc\n" +//".cfi_startproc\n" "pushl %ebp\n" -".cfi_def_cfa_offset 8\n" -".cfi_offset %ebp, -8\n" +//".cfi_def_cfa_offset 8\n" +//".cfi_offset %ebp, -8\n" "movl%esp, %ebp\n"// Standard prologue -".cfi_def_cfa_register %ebp\n" +//".cfi_def_cfa_register %ebp\n" "pushl %eax\n" -".cfi_rel_offset %eax, 0\n" +//".cfi_rel_offset %eax, 0\n" "pushl %edx\n" // Save EAX/EDX/ECX -".cfi_rel_offset %edx, 4\n" +//".cfi_rel_offset %edx, 4\n" "pushl %ecx\n" -".cfi_rel_offset %ecx, 8\n" +//".cfi_rel_offset %ecx, 8\n" #if defined(__APPLE__) "andl$-16, %esp\n"// Align ESP on 16-byte boundary #endif @@ -164,23 +165,24 @@ "movl%ebp, (%esp)\n" "call" ASMPREFIX "X86CompilationCallback2\n" "movl%ebp, %esp\n"// Restore ESP -".cfi_def_cfa_register %esp\n" +//".cfi_def_cfa_register %esp\n" "subl$12, %esp\n" -".cfi_adjust_cfa_offset 12\n" +//".cfi_adjust_cfa_offset 12\n" "popl%ecx\n" -".cfi_adjust_cfa_offset -4\n" -".cfi_restore %ecx\n" +//".cfi_adjust_cfa_offset -4\n" +//".cfi_restore %ecx\n" "popl%edx\n" -".cfi_adjust_cfa_offset -4\n" -".cfi_restore %edx\n" +//".cfi_
[llvm-commits] [llvm] r44805 - in /llvm/trunk/win32: CodeGen/CodeGen.vcproj Support/Support.vcproj
Author: cfr Date: Mon Dec 10 13:31:09 2007 New Revision: 44805 URL: http://llvm.org/viewvc/llvm-project?rev=44805&view=rev Log: Add StringPool + new CodeGen files to win32 build Modified: llvm/trunk/win32/CodeGen/CodeGen.vcproj llvm/trunk/win32/Support/Support.vcproj Modified: llvm/trunk/win32/CodeGen/CodeGen.vcproj URL: http://llvm.org/viewvc/llvm-project/llvm/trunk/win32/CodeGen/CodeGen.vcproj?rev=44805&r1=44804&r2=44805&view=diff == --- llvm/trunk/win32/CodeGen/CodeGen.vcproj (original) +++ llvm/trunk/win32/CodeGen/CodeGen.vcproj Mon Dec 10 13:31:09 2007 @@ -476,6 +476,26 @@ > + + + + + + + + + + @@ -551,6 +571,10 @@ > + + Modified: llvm/trunk/win32/Support/Support.vcproj URL: http://llvm.org/viewvc/llvm-project/llvm/trunk/win32/Support/Support.vcproj?rev=44805&r1=44804&r2=44805&view=diff == --- llvm/trunk/win32/Support/Support.vcproj (original) +++ llvm/trunk/win32/Support/Support.vcproj Mon Dec 10 13:31:09 2007 @@ -409,6 +409,10 @@ > + + @@ -567,6 +571,10 @@ > + + ___ llvm-commits mailing list llvm-commits@cs.uiuc.edu http://lists.cs.uiuc.edu/mailman/listinfo/llvm-commits
Re: [llvm-commits] [llvm] r44687 - in /llvm/trunk: include/llvm/CodeGen/Passes.h lib/CodeGen/LLVMTargetMachine.cpp lib/CodeGen/MachineLICM.cpp lib/Target/PowerPC/PPCInstrInfo.td
On Dec 10, 2007, at 6:47 AM, Dan Gohman wrote: >> Thanks for pointing this out. I'll go over it when I'm doing the >> load/ >> store instructions in my pass. > > Hi Bill, > > How involved will MachineLICM be? After LLVM's main LICM pass runs, it > seems all that's left for MachineLICM to do are just the constant-pool > loads, immediates, etc. that aren't exposed in the main LLVM IR, > things > that don't require alias analysis. I think this is probably true. I'd be surprised if machine level LICM would require alias analysis. > > > And if that's all it's doing, MachineLICM's traversal could be > simplified > a little. Instead of visiting each loop individually, taking care to > avoid > revisiting to blocks within inner loops, the pass could just traverse > entire outer-most loops, which will implicitly include the blocks of > any > inner loops. Instructions nested deep in inner loops can then be > hoisted > all the way out of the outer-most loop in a single step instead of > being > hoisted out one loop at a time. I don't think lifting loop invariant from inner loop all the way out of outer-most loop is a good idea. That will increase register pressure in basic blocks where it is not used. Evan > > > Dan > > -- > Dan Gohman, Cray Inc. > ___ > llvm-commits mailing list > llvm-commits@cs.uiuc.edu > http://lists.cs.uiuc.edu/mailman/listinfo/llvm-commits ___ llvm-commits mailing list llvm-commits@cs.uiuc.edu http://lists.cs.uiuc.edu/mailman/listinfo/llvm-commits
[llvm-commits] [llvm] r44810 - /llvm/trunk/docs/WritingAnLLVMPass.html
Author: criswell Date: Mon Dec 10 14:26:29 2007 New Revision: 44810 URL: http://llvm.org/viewvc/llvm-project?rev=44810&view=rev Log: Fix some wording. Modified: llvm/trunk/docs/WritingAnLLVMPass.html Modified: llvm/trunk/docs/WritingAnLLVMPass.html URL: http://llvm.org/viewvc/llvm-project/llvm/trunk/docs/WritingAnLLVMPass.html?rev=44810&r1=44809&r2=44810&view=diff == --- llvm/trunk/docs/WritingAnLLVMPass.html (original) +++ llvm/trunk/docs/WritingAnLLVMPass.html Mon Dec 10 14:26:29 2007 @@ -1376,7 +1376,8 @@ traversing the entire program. It reduces the memory consumption of compiler, because, for example, only one http://llvm.org/doxygen/classllvm_1_1DominatorSet.html";>DominatorSet -needs to be calculated at a time. This also makes it possible some interesting enhancements in the future. ___ llvm-commits mailing list llvm-commits@cs.uiuc.edu http://lists.cs.uiuc.edu/mailman/listinfo/llvm-commits
Re: [llvm-commits] [llvm] r44687 - in /llvm/trunk: include/llvm/CodeGen/Passes.h lib/CodeGen/LLVMTargetMachine.cpp lib/CodeGen/MachineLICM.cpp lib/Target/PowerPC/PPCInstrInfo.td
On Dec 10, 2007 6:47 AM, Dan Gohman <[EMAIL PROTECTED]> wrote: > > Thanks for pointing this out. I'll go over it when I'm doing the load/ > > store instructions in my pass. > > Hi Bill, > > How involved will MachineLICM be? After LLVM's main LICM pass runs, it > seems all that's left for MachineLICM to do are just the constant-pool > loads, immediates, etc. that aren't exposed in the main LLVM IR, things > that don't require alias analysis. > Good point. I was just leaving the option of needing AA open just in case. But I won't use it if not needed, of course. > And if that's all it's doing, MachineLICM's traversal could be simplified > a little. Instead of visiting each loop individually, taking care to avoid > revisiting to blocks within inner loops, the pass could just traverse > entire outer-most loops, which will implicitly include the blocks of any > inner loops. Instructions nested deep in inner loops can then be hoisted > all the way out of the outer-most loop in a single step instead of being > hoisted out one loop at a time. > I just want to make sure we're visiting all defs before uses. This way, we won't be hoisting things that shouldn't be, and, of course, that we hoist things which we should be hoisting. Take, for example, an invariant in a subloop that is itself part of the body of a conditional statement. Of course, we want to hoist the instruction to the pre-header of the subloop, but not to the pre-header of the outer loop. To make sure we do this without visiting the subloops first, I think we would have to have a lot more checking. -bw ___ llvm-commits mailing list llvm-commits@cs.uiuc.edu http://lists.cs.uiuc.edu/mailman/listinfo/llvm-commits
Re: [llvm-commits] [llvm] r44687 - in /llvm/trunk: include/llvm/CodeGen/Passes.h lib/CodeGen/LLVMTargetMachine.cpp lib/CodeGen/MachineLICM.cpp lib/Target/PowerPC/PPCInstrInfo.td
On Dec 10, 2007 11:36 AM, Evan Cheng <[EMAIL PROTECTED]> wrote: > On Dec 10, 2007, at 6:47 AM, Dan Gohman wrote: > > And if that's all it's doing, MachineLICM's traversal could be > > simplified > > a little. Instead of visiting each loop individually, taking care to > > avoid > > revisiting to blocks within inner loops, the pass could just traverse > > entire outer-most loops, which will implicitly include the blocks of > > any > > inner loops. Instructions nested deep in inner loops can then be > > hoisted > > all the way out of the outer-most loop in a single step instead of > > being > > hoisted out one loop at a time. > > I don't think lifting loop invariant from inner loop all the way out > of outer-most loop is a good idea. That will increase register > pressure in basic blocks where it is not used. > This is going to happen with the current pass, though. Each loop is going to see the hoisted instructions from the previous iteration and try to re-hoist them. Is there some heuristic we should apply to prevent it from hoisting instructions too far? -bw ___ llvm-commits mailing list llvm-commits@cs.uiuc.edu http://lists.cs.uiuc.edu/mailman/listinfo/llvm-commits
[llvm-commits] [llvm] r44811 - /llvm/tags/Apple/llvmCore-2003/
Author: void Date: Mon Dec 10 15:49:16 2007 New Revision: 44811 URL: http://llvm.org/viewvc/llvm-project?rev=44811&view=rev Log: Creating llvmCore-2003. Added: llvm/tags/Apple/llvmCore-2003/ - copied from r44810, llvm/trunk/ ___ llvm-commits mailing list llvm-commits@cs.uiuc.edu http://lists.cs.uiuc.edu/mailman/listinfo/llvm-commits
[llvm-commits] [llvm-gcc-4.2] r44812 - /llvm-gcc-4.2/tags/Apple/llvmgcc42-2002/
Author: void Date: Mon Dec 10 15:50:11 2007 New Revision: 44812 URL: http://llvm.org/viewvc/llvm-project?rev=44812&view=rev Log: Creating llvmgcc42-2002 Added: llvm-gcc-4.2/tags/Apple/llvmgcc42-2002/ - copied from r44811, llvm-gcc-4.2/trunk/ ___ llvm-commits mailing list llvm-commits@cs.uiuc.edu http://lists.cs.uiuc.edu/mailman/listinfo/llvm-commits
[llvm-commits] [llvm] r44814 - /llvm/trunk/include/llvm/Instruction.h
Author: lattner Date: Mon Dec 10 16:18:53 2007 New Revision: 44814 URL: http://llvm.org/viewvc/llvm-project?rev=44814&view=rev Log: split isBinaryOp into a static and member version. Modified: llvm/trunk/include/llvm/Instruction.h Modified: llvm/trunk/include/llvm/Instruction.h URL: http://llvm.org/viewvc/llvm-project/llvm/trunk/include/llvm/Instruction.h?rev=44814&r1=44813&r2=44814&view=diff == --- llvm/trunk/include/llvm/Instruction.h (original) +++ llvm/trunk/include/llvm/Instruction.h Mon Dec 10 16:18:53 2007 @@ -102,21 +102,22 @@ /// one of the enums that is coming soon (down below)... /// unsigned getOpcode() const { return getValueID() - InstructionVal; } - const char *getOpcodeName() const { -return getOpcodeName(getOpcode()); - } + const char *getOpcodeName() const { return getOpcodeName(getOpcode()); } + bool isTerminator() const { return isTerminator(getOpcode()); } + bool isBinaryOp() const { return isBinaryOp(getOpcode()); } + bool isShift() { return isShift(getOpcode()); } + bool isCast() const { return isCast(getOpcode()); } + + + static const char* getOpcodeName(unsigned OpCode); static inline bool isTerminator(unsigned OpCode) { return OpCode >= TermOpsBegin && OpCode < TermOpsEnd; } - inline bool isTerminator() const { // Instance of TerminatorInst? -return isTerminator(getOpcode()); - } - - inline bool isBinaryOp() const { -return getOpcode() >= BinaryOpsBegin && getOpcode() < BinaryOpsEnd; + static inline bool isBinaryOp(unsigned Opcode) { +return Opcode >= BinaryOpsBegin && Opcode < BinaryOpsEnd; } /// @brief Determine if the Opcode is one of the shift instructions. @@ -124,10 +125,6 @@ return Opcode >= Shl && Opcode <= AShr; } - /// @brief Determine if the instruction's opcode is one of the shift - /// instructions. - inline bool isShift() { return isShift(getOpcode()); } - /// isLogicalShift - Return true if this is a logical shift left or a logical /// shift right. inline bool isLogicalShift() { @@ -145,11 +142,6 @@ return OpCode >= CastOpsBegin && OpCode < CastOpsEnd; } - /// @brief Determine if this is one of the CastInst instructions. - inline bool isCast() const { -return isCast(getOpcode()); - } - /// isAssociative - Return true if the instruction is associative: /// /// Associative operators satisfy: x op (y op z) === (x op y) op z ___ llvm-commits mailing list llvm-commits@cs.uiuc.edu http://lists.cs.uiuc.edu/mailman/listinfo/llvm-commits
[llvm-commits] [llvm] r44815 - /llvm/trunk/include/llvm/ADT/BitVector.h
Author: kremenek Date: Mon Dec 10 16:28:35 2007 New Revision: 44815 URL: http://llvm.org/viewvc/llvm-project?rev=44815&view=rev Log: Added two bounds checks to the BitVector class to detect out-of-bounds bit accesses. The checks are only performed in a Debug build. Modified: llvm/trunk/include/llvm/ADT/BitVector.h Modified: llvm/trunk/include/llvm/ADT/BitVector.h URL: http://llvm.org/viewvc/llvm-project/llvm/trunk/include/llvm/ADT/BitVector.h?rev=44815&r1=44814&r2=44815&view=diff == --- llvm/trunk/include/llvm/ADT/BitVector.h (original) +++ llvm/trunk/include/llvm/ADT/BitVector.h Mon Dec 10 16:28:35 2007 @@ -245,10 +245,12 @@ // Indexing. reference operator[](unsigned Idx) { +assert (Idx < Size && "Out-of-bounds Bit access."); return reference(*this, Idx); } bool operator[](unsigned Idx) const { +assert (Idx < Size && "Out-of-bounds Bit access."); BitWord Mask = 1L << (Idx % BITWORD_SIZE); return (Bits[Idx / BITWORD_SIZE] & Mask) != 0; } @@ -375,6 +377,8 @@ // Destroy the old bits. delete[] Bits; Bits = NewBits; + +clear_unused_bits(); } void init_words(BitWord *B, unsigned NumWords, bool t) { ___ llvm-commits mailing list llvm-commits@cs.uiuc.edu http://lists.cs.uiuc.edu/mailman/listinfo/llvm-commits
[llvm-commits] [llvm] r44817 - in /llvm/trunk: include/llvm/Analysis/ConstantFolding.h lib/Analysis/ConstantFolding.cpp lib/Analysis/ScalarEvolution.cpp lib/Transforms/Utils/CloneFunction.cpp lib/VMCo
Author: lattner Date: Mon Dec 10 16:53:04 2007 New Revision: 44817 URL: http://llvm.org/viewvc/llvm-project?rev=44817&view=rev Log: Fix PR1850 by removing an unsafe transformation from VMCore/ConstantFold.cpp. Reimplement the xform in Analysis/ConstantFolding.cpp where we can use targetdata to validate that it is safe. While I'm in there, fix some const correctness issues and generalize the interface to the "operand folder". Added: llvm/trunk/test/Transforms/InstCombine/2007-12-10-ConstFoldCompare.ll Modified: llvm/trunk/include/llvm/Analysis/ConstantFolding.h llvm/trunk/lib/Analysis/ConstantFolding.cpp llvm/trunk/lib/Analysis/ScalarEvolution.cpp llvm/trunk/lib/Transforms/Utils/CloneFunction.cpp llvm/trunk/lib/VMCore/ConstantFold.cpp llvm/trunk/test/Assembler/ConstantExprFold.llx Modified: llvm/trunk/include/llvm/Analysis/ConstantFolding.h URL: http://llvm.org/viewvc/llvm-project/llvm/trunk/include/llvm/Analysis/ConstantFolding.h?rev=44817&r1=44816&r2=44817&view=diff == --- llvm/trunk/include/llvm/Analysis/ConstantFolding.h (original) +++ llvm/trunk/include/llvm/Analysis/ConstantFolding.h Mon Dec 10 16:53:04 2007 @@ -21,6 +21,7 @@ class Instruction; class TargetData; class Function; + class Type; /// ConstantFoldInstruction - Attempt to constant fold the specified /// instruction. If successful, the constant result is returned, if not, null @@ -35,12 +36,17 @@ /// fold instructions like loads and stores, which have no constant expression /// form. /// -Constant *ConstantFoldInstOperands( - const Instruction *I, ///< The model instruction - Constant** Ops, ///< The array of constant operands to use. - unsigned NumOps, ///< The number of operands provided. - const TargetData *TD = 0 ///< Optional target information. -); +Constant *ConstantFoldInstOperands(unsigned Opcode, const Type *DestTy, + Constant*const * Ops, unsigned NumOps, + const TargetData *TD = 0); + +/// ConstantFoldCompareInstOperands - Attempt to constant fold a compare +/// instruction (icmp/fcmp) with the specified operands. If it fails, it +/// returns a constant expression of the specified operands. +/// +Constant *ConstantFoldCompareInstOperands(unsigned Predicate, + Constant*const * Ops, unsigned NumOps, + const TargetData *TD = 0); /// ConstantFoldLoadThroughGEPConstantExpr - Given a constant and a @@ -55,7 +61,7 @@ /// ConstantFoldCall - Attempt to constant fold a call to the specified function /// with the specified arguments, returning null if unsuccessful. Constant * -ConstantFoldCall(Function *F, Constant** Operands, unsigned NumOperands); +ConstantFoldCall(Function *F, Constant* const* Operands, unsigned NumOperands); } #endif Modified: llvm/trunk/lib/Analysis/ConstantFolding.cpp URL: http://llvm.org/viewvc/llvm-project/llvm/trunk/lib/Analysis/ConstantFolding.cpp?rev=44817&r1=44816&r2=44817&view=diff == --- llvm/trunk/lib/Analysis/ConstantFolding.cpp (original) +++ llvm/trunk/lib/Analysis/ConstantFolding.cpp Mon Dec 10 16:53:04 2007 @@ -55,7 +55,8 @@ if (CE->getOpcode() == Instruction::GetElementPtr) { // Cannot compute this if the element type of the pointer is missing size // info. -if (!cast(CE->getOperand(0)->getType())->getElementType()->isSized()) +if (!cast(CE->getOperand(0)->getType()) + ->getElementType()->isSized()) return false; // If the base isn't a global+constant, we aren't either. @@ -117,7 +118,7 @@ /// SymbolicallyEvaluateGEP - If we can symbolically evaluate the specified GEP /// constant expression, do so. -static Constant *SymbolicallyEvaluateGEP(Constant** Ops, unsigned NumOps, +static Constant *SymbolicallyEvaluateGEP(Constant* const* Ops, unsigned NumOps, const Type *ResultTy, const TargetData *TD) { Constant *Ptr = Ops[0]; @@ -181,7 +182,12 @@ else return 0; // All operands not constant! - return ConstantFoldInstOperands(I, &Ops[0], Ops.size(), TD); + if (const CmpInst *CI = dyn_cast(I)) +return ConstantFoldCompareInstOperands(CI->getPredicate(), + &Ops[0], Ops.size(), TD); + else +return ConstantFoldInstOperands(I->getOpcode(), I->getType(), +&Ops[0], Ops.size(), TD); } /// ConstantFoldInstOperands - Attempt to constant fold an instruction with the @@ -190,23 +196,19 @@ /// attempting to fold instructions like loads and stores, which have no /// constant expression form. /// -Constant *llvm::ConstantFoldInstOperands(const Instruction* I, -
[llvm-commits] [llvm] r44818 - /llvm/trunk/lib/Target/X86/X86JITInfo.cpp
Author: asl Date: Mon Dec 10 17:04:38 2007 New Revision: 44818 URL: http://llvm.org/viewvc/llvm-project?rev=44818&view=rev Log: Provide convenient way to disable CFI stuff for old/broken assemblers. Use it for Darwin. Modified: llvm/trunk/lib/Target/X86/X86JITInfo.cpp Modified: llvm/trunk/lib/Target/X86/X86JITInfo.cpp URL: http://llvm.org/viewvc/llvm-project/llvm/trunk/lib/Target/X86/X86JITInfo.cpp?rev=44818&r1=44817&r2=44818&view=diff == --- llvm/trunk/lib/Target/X86/X86JITInfo.cpp (original) +++ llvm/trunk/lib/Target/X86/X86JITInfo.cpp Mon Dec 10 17:04:38 2007 @@ -47,6 +47,12 @@ #define GETASMPREFIX(X) GETASMPREFIX2(X) #define ASMPREFIX GETASMPREFIX(__USER_LABEL_PREFIX__) +#if defined(__APPLE__) +# define CFI(x) +#else +# define CFI(x) x +#endif + // Provide a wrapper for X86CompilationCallback2 that saves non-traditional // callee saved registers, for the fastcc calling convention. extern "C" { @@ -58,27 +64,27 @@ ".align 8\n" ".globl " ASMPREFIX "X86CompilationCallback\n" ASMPREFIX "X86CompilationCallback:\n" -//".cfi_startproc\n" +CFI(".cfi_startproc\n") // Save RBP "pushq %rbp\n" -//".cfi_def_cfa_offset 16\n" -//".cfi_offset %rbp, -16\n" +CFI(".cfi_def_cfa_offset 16\n") +CFI(".cfi_offset %rbp, -16\n") // Save RSP "movq%rsp, %rbp\n" -//".cfi_def_cfa_register %rbp\n" +CFI(".cfi_def_cfa_register %rbp\n") // Save all int arg registers "pushq %rdi\n" -//".cfi_rel_offset %rdi, 0\n" +CFI(".cfi_rel_offset %rdi, 0\n") "pushq %rsi\n" -//".cfi_rel_offset %rsi, 8\n" +CFI(".cfi_rel_offset %rsi, 8\n") "pushq %rdx\n" -//".cfi_rel_offset %rdx, 16\n" +CFI(".cfi_rel_offset %rdx, 16\n") "pushq %rcx\n" -//".cfi_rel_offset %rcx, 24\n" +CFI(".cfi_rel_offset %rcx, 24\n") "pushq %r8\n" -//".cfi_rel_offset %r8, 32\n" +CFI(".cfi_rel_offset %r8, 32\n") "pushq %r9\n" -//".cfi_rel_offset %r9, 40\n" +CFI(".cfi_rel_offset %r9, 40\n") // Align stack on 16-byte boundary. ESP might not be properly aligned // (8 byte) if this is called from an indirect stub. "andq$-16, %rsp\n" @@ -107,35 +113,35 @@ "movaps (%rsp), %xmm0\n" // Restore RSP "movq%rbp, %rsp\n" -//".cfi_def_cfa_register esp\n" +CFI(".cfi_def_cfa_register esp\n") // Restore all int arg registers "subq$48, %rsp\n" -//".cfi_adjust_cfa_offset 48\n" +CFI(".cfi_adjust_cfa_offset 48\n") "popq%r9\n" -//".cfi_adjust_cfa_offset -8\n" -//".cfi_restore %r9\n" +CFI(".cfi_adjust_cfa_offset -8\n") +CFI(".cfi_restore %r9\n") "popq%r8\n" -//".cfi_adjust_cfa_offset -8\n" -//".cfi_restore %r8\n" +CFI(".cfi_adjust_cfa_offset -8\n") +CFI(".cfi_restore %r8\n") "popq%rcx\n" -//".cfi_adjust_cfa_offset -8\n" -//".cfi_restore %rcx\n" +CFI(".cfi_adjust_cfa_offset -8\n") +CFI(".cfi_restore %rcx\n") "popq%rdx\n" -//".cfi_adjust_cfa_offset -8\n" -//".cfi_restore %rdx\n" +CFI(".cfi_adjust_cfa_offset -8\n") +CFI(".cfi_restore %rdx\n") "popq%rsi\n" -//".cfi_adjust_cfa_offset -8\n" -//".cfi_restore %rsi\n" +CFI(".cfi_adjust_cfa_offset -8\n") +CFI(".cfi_restore %rsi\n") "popq%rdi\n" -//".cfi_adjust_cfa_offset -8\n" -//".cfi_restore %rdi\n" +CFI(".cfi_adjust_cfa_offset -8\n") +CFI(".cfi_restore %rdi\n") // Restore RBP "popq%rbp\n" -//".cfi_adjust_cfa_offset -8\n" -//".cfi_restore %rbp\n" +CFI(".cfi_adjust_cfa_offset -8\n") +CFI(".cfi_restore %rbp\n") "ret\n" -//".cfi_endproc\n" - ); +CFI(".cfi_endproc\n") + ); #elif defined(__i386__) || defined(i386) || defined(_M_IX86) #ifndef _MSC_VER void X86CompilationCallback(void); @@ -144,18 +150,18 @@ ".align 8\n" ".globl " ASMPREFIX "X86CompilationCallback\n" ASMPREFIX "X86CompilationCallback:\n" -//".cfi_startproc\n" +CFI(".cfi_startproc\n") "pushl %ebp\n" -//".cfi_def_cfa_offset 8\n" -//".cfi_offset %ebp, -8\n" +CFI(".cfi_def_cfa_offset 8\n") +CFI(".cfi_offset %ebp, -8\n") "movl%esp, %ebp\n"// Standard prologue -//".cfi_def_cfa_register %ebp\n" +CFI(".cfi_def_cfa_register %ebp\n") "pushl %eax\n" -//".cfi_rel_offset %eax, 0\n" +CFI(".cfi_rel_offset %eax, 0\n") "pushl %edx\n" // Save EAX/EDX/ECX -//".cfi_rel_offset %edx, 4\n" +CFI(".cfi_rel_offset %edx, 4\n") "pushl %ecx\n" -//".cfi_rel_offset %ecx, 8\n" +CFI(".cfi_rel_offset %ecx, 8\n") #if defined(__APPLE__) "andl$-16, %esp\n"// Align ESP on 16-byte boundary #endif @@ -165,24 +171,24 @@ "movl%ebp, (%esp)\n" "call" ASMPREFIX "X86CompilationCallback2\n" "movl%ebp, %esp\n"// Restore ESP -//".cfi_def_cfa_register %esp\n" +CFI(
[llvm-commits] [llvm] r44819 - /llvm/trunk/lib/Target/X86/X86JITInfo.cpp
Author: asl Date: Mon Dec 10 17:08:35 2007 New Revision: 44819 URL: http://llvm.org/viewvc/llvm-project?rev=44819&view=rev Log: Clarify the need of CFI() stuff Modified: llvm/trunk/lib/Target/X86/X86JITInfo.cpp Modified: llvm/trunk/lib/Target/X86/X86JITInfo.cpp URL: http://llvm.org/viewvc/llvm-project/llvm/trunk/lib/Target/X86/X86JITInfo.cpp?rev=44819&r1=44818&r2=44819&view=diff == --- llvm/trunk/lib/Target/X86/X86JITInfo.cpp (original) +++ llvm/trunk/lib/Target/X86/X86JITInfo.cpp Mon Dec 10 17:08:35 2007 @@ -47,6 +47,9 @@ #define GETASMPREFIX(X) GETASMPREFIX2(X) #define ASMPREFIX GETASMPREFIX(__USER_LABEL_PREFIX__) +// Provide a convenient way for disable usage of CFI directives. +// This is needed for old/broken assemblers (for example, gas on +// Darwin is pretty old and doesn't support these directives) #if defined(__APPLE__) # define CFI(x) #else ___ llvm-commits mailing list llvm-commits@cs.uiuc.edu http://lists.cs.uiuc.edu/mailman/listinfo/llvm-commits
[llvm-commits] [llvm] r44820 - /llvm/trunk/lib/Target/X86/X86JITInfo.cpp
Author: asl Date: Mon Dec 10 17:10:20 2007 New Revision: 44820 URL: http://llvm.org/viewvc/llvm-project?rev=44820&view=rev Log: Hey, English is not my native language :) Modified: llvm/trunk/lib/Target/X86/X86JITInfo.cpp Modified: llvm/trunk/lib/Target/X86/X86JITInfo.cpp URL: http://llvm.org/viewvc/llvm-project/llvm/trunk/lib/Target/X86/X86JITInfo.cpp?rev=44820&r1=44819&r2=44820&view=diff == --- llvm/trunk/lib/Target/X86/X86JITInfo.cpp (original) +++ llvm/trunk/lib/Target/X86/X86JITInfo.cpp Mon Dec 10 17:10:20 2007 @@ -47,7 +47,7 @@ #define GETASMPREFIX(X) GETASMPREFIX2(X) #define ASMPREFIX GETASMPREFIX(__USER_LABEL_PREFIX__) -// Provide a convenient way for disable usage of CFI directives. +// Provide a convenient way for disabling usage of CFI directives. // This is needed for old/broken assemblers (for example, gas on // Darwin is pretty old and doesn't support these directives) #if defined(__APPLE__) ___ llvm-commits mailing list llvm-commits@cs.uiuc.edu http://lists.cs.uiuc.edu/mailman/listinfo/llvm-commits
Re: [llvm-commits] Another GC patch for review
On Dec 9, 2007, at 8:01 PM, Gordon Henriksen wrote: Here's the next patch. This jiggers around the GC data structures, but the compiler still doesn't call into them, so they're inert. gc-6-redux.patch (+424 -295): include/llvm/CodeGen/Passes.h (+18) include/llvm/CodeGen/Collector.h (+43 -43) include/llvm/CodeGen/CollectorMetadata.h (+30 -31) include/llvm/CodeGen/Collectors.h (+3) lib/CodeGen/Collector.cpp (+125 -80) lib/CodeGen/CollectorMetadata.cpp (+61 -31) docs/GarbageCollection.html (+144 -110) CollectorMetadata and Collector are rejiggered to get along with per-function collector model. Collector is now the factory for CollectorMetadata, so the latter may be subclassed. Looks reasonable to me, please apply, -Chris___ llvm-commits mailing list llvm-commits@cs.uiuc.edu http://lists.cs.uiuc.edu/mailman/listinfo/llvm-commits
Re: [llvm-commits] [llvm] r44687 - in /llvm/trunk: include/llvm/CodeGen/Passes.h lib/CodeGen/LLVMTargetMachine.cpp lib/CodeGen/MachineLICM.cpp lib/Target/PowerPC/PPCInstrInfo.td
On Dec 10, 2007, at 1:23 PM, Bill Wendling wrote: > On Dec 10, 2007 11:36 AM, Evan Cheng <[EMAIL PROTECTED]> wrote: >> On Dec 10, 2007, at 6:47 AM, Dan Gohman wrote: >>> And if that's all it's doing, MachineLICM's traversal could be >>> simplified >>> a little. Instead of visiting each loop individually, taking care to >>> avoid >>> revisiting to blocks within inner loops, the pass could just >>> traverse >>> entire outer-most loops, which will implicitly include the blocks of >>> any >>> inner loops. Instructions nested deep in inner loops can then be >>> hoisted >>> all the way out of the outer-most loop in a single step instead of >>> being >>> hoisted out one loop at a time. >> >> I don't think lifting loop invariant from inner loop all the way out >> of outer-most loop is a good idea. That will increase register >> pressure in basic blocks where it is not used. >> > This is going to happen with the current pass, though. Each loop is > going to see the hoisted instructions from the previous iteration and > try to re-hoist them. Is there some heuristic we should apply to > prevent it from hoisting instructions too far? > I am not sure. :-) For innermost loops, hoisting invariants out into the preheader always make sense. Intuitively, hoisting invariants from inner loops out of the outermost loop only makes sense when all (or a lot, whatever that means :-) of the inner loops use it. Or at least the first inner loop use it. What does the LLVM level LICM do? Evan > -bw > ___ > llvm-commits mailing list > llvm-commits@cs.uiuc.edu > http://lists.cs.uiuc.edu/mailman/listinfo/llvm-commits ___ llvm-commits mailing list llvm-commits@cs.uiuc.edu http://lists.cs.uiuc.edu/mailman/listinfo/llvm-commits
[llvm-commits] [llvm] r44824 - in /llvm/trunk: bindings/ocaml/Makefile bindings/ocaml/bitreader/ bindings/ocaml/bitreader/Makefile bindings/ocaml/bitreader/bitreader_ocaml.c bindings/ocaml/bitreader/l
Author: gordon Date: Mon Dec 10 18:20:48 2007 New Revision: 44824 URL: http://llvm.org/viewvc/llvm-project?rev=44824&view=rev Log: Adding Ocaml bindings for the bitreader as requested by Sarah Thompson. Usage should be something like this: open Llvm open Llvm_bitreader match read_bitcode_file fn with | Bitreader_failure msg -> prerr_endline msg | Bitreader_success m -> ...; dispose_module m Compile with: ocamlc llvm.cma llvm_bitreader.cma ocamlopt llvm.cmxa llvm_bitreader.cmxa Added: llvm/trunk/bindings/ocaml/bitreader/ (with props) llvm/trunk/bindings/ocaml/bitreader/Makefile llvm/trunk/bindings/ocaml/bitreader/bitreader_ocaml.c llvm/trunk/bindings/ocaml/bitreader/llvm_bitreader.ml llvm/trunk/bindings/ocaml/bitreader/llvm_bitreader.mli llvm/trunk/include/llvm-c/BitReader.h llvm/trunk/lib/Bitcode/Reader/BitReader.cpp llvm/trunk/test/Bindings/Ocaml/bitreader.ml Modified: llvm/trunk/bindings/ocaml/Makefile Modified: llvm/trunk/bindings/ocaml/Makefile URL: http://llvm.org/viewvc/llvm-project/llvm/trunk/bindings/ocaml/Makefile?rev=44824&r1=44823&r2=44824&view=diff == --- llvm/trunk/bindings/ocaml/Makefile (original) +++ llvm/trunk/bindings/ocaml/Makefile Mon Dec 10 18:20:48 2007 @@ -8,6 +8,6 @@ ##===--===## LEVEL := ../.. -DIRS = llvm bitwriter analysis +DIRS = llvm bitreader bitwriter analysis include $(LEVEL)/Makefile.common Propchange: llvm/trunk/bindings/ocaml/bitreader/ -- --- svn:ignore (added) +++ svn:ignore Mon Dec 10 18:20:48 2007 @@ -0,0 +1,2 @@ +Debug +Release Added: llvm/trunk/bindings/ocaml/bitreader/Makefile URL: http://llvm.org/viewvc/llvm-project/llvm/trunk/bindings/ocaml/bitreader/Makefile?rev=44824&view=auto == --- llvm/trunk/bindings/ocaml/bitreader/Makefile (added) +++ llvm/trunk/bindings/ocaml/bitreader/Makefile Mon Dec 10 18:20:48 2007 @@ -0,0 +1,20 @@ +##===- bindings/ocaml/bitreader/Makefile ---*- Makefile -*-===## +# +# The LLVM Compiler Infrastructure +# +# This file was developed by Gordon Henriksen and is distributed under the +# University of Illinois Open Source License. See LICENSE.TXT for details. +# +##===--===## +# +# This is the makefile for the Objective Caml Llvm_bitreader interface. +# +##===--===## + +LEVEL := ../../.. +LIBRARYNAME := llvm_bitreader +DONT_BUILD_RELINKED := 1 +UsedComponents := bitreader +UsedOcamlInterfaces := llvm + +include ../Makefile.ocaml Added: llvm/trunk/bindings/ocaml/bitreader/bitreader_ocaml.c URL: http://llvm.org/viewvc/llvm-project/llvm/trunk/bindings/ocaml/bitreader/bitreader_ocaml.c?rev=44824&view=auto == --- llvm/trunk/bindings/ocaml/bitreader/bitreader_ocaml.c (added) +++ llvm/trunk/bindings/ocaml/bitreader/bitreader_ocaml.c Mon Dec 10 18:20:48 2007 @@ -0,0 +1,46 @@ +/*===-- bitwriter_ocaml.c - LLVM Ocaml Glue -*- C++ -*-===*\ +|* *| +|* The LLVM Compiler Infrastructure *| +|* *| +|* This file was developed by Gordon Henriksen and is distributed under the *| +|* University of Illinois Open Source License. See LICENSE.TXT for details. *| +|* *| +|*===--===*| +|* *| +|* This file glues LLVM's ocaml interface to its C interface. These functions *| +|* are by and large transparent wrappers to the corresponding C functions. *| +|* *| +\*===--===*/ + +#include "llvm-c/BitReader.h" +#include "caml/alloc.h" +#include "caml/mlvalues.h" +#include "caml/memory.h" + +/*===-- Modules ---===*/ + +/* string -> bitreader_result + + type bitreader_result = + | Bitreader_success of Llvm.llmodule + | Bitreader_failure of string + */ +CAMLprim value llvm_read_bitcode_file(value Path) { + LLVMModuleRef M; + char *Message; + CAMLparam1(Path); + CAMLlocal2(Variant, MessageVal); + + if (LLVMReadBitcodeFromFile(String_val(Path), &M, &Message)) { +MessageVal = copy_string(Mess
[llvm-commits] [llvm] r44825 - in /llvm/trunk: include/llvm/Target/TargetData.h lib/Target/TargetData.cpp
Author: lattner Date: Mon Dec 10 18:28:59 2007 New Revision: 44825 URL: http://llvm.org/viewvc/llvm-project?rev=44825&view=rev Log: Move TargetData::hostIsLittleEndian out of line, which means we don't have to #include config.h in it. #including config.h breaks other projects that have their own autoconf stuff and try to #include the llvm headers. One obscure example is llvm-gcc. 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=44825&r1=44824&r2=44825&view=diff == --- llvm/trunk/include/llvm/Target/TargetData.h (original) +++ llvm/trunk/include/llvm/Target/TargetData.h Mon Dec 10 18:28:59 2007 @@ -23,7 +23,6 @@ #include "llvm/Pass.h" #include "llvm/Support/DataTypes.h" #include "llvm/ADT/SmallVector.h" -#include "llvm/Config/config.h" #include namespace llvm { @@ -143,14 +142,8 @@ bool isLittleEndian() const { return LittleEndian; } bool isBigEndian() const { return!LittleEndian; } - /// Host endianness... - bool hostIsLittleEndian() const { -#ifdef LSB_FIRST -return true; -#else -return false; -#endif - } + /// Host endianness. + bool hostIsLittleEndian() const; bool hostIsBigEndian() const { return !hostIsLittleEndian(); } /// getStringRepresentation - Return the string representation of the Modified: llvm/trunk/lib/Target/TargetData.cpp URL: http://llvm.org/viewvc/llvm-project/llvm/trunk/lib/Target/TargetData.cpp?rev=44825&r1=44824&r2=44825&view=diff == --- llvm/trunk/lib/Target/TargetData.cpp (original) +++ llvm/trunk/lib/Target/TargetData.cpp Mon Dec 10 18:28:59 2007 @@ -25,6 +25,7 @@ #include "llvm/Support/ManagedStatic.h" #include "llvm/ADT/DenseMap.h" #include "llvm/ADT/StringExtras.h" +#include "llvm/Config/config.h" #include #include #include @@ -132,6 +133,14 @@ // TargetData Class Implementation //===--===// +bool TargetData::hostIsLittleEndian() const { +#ifdef LSB_FIRST + return true; +#else + return false; +#endif +} + /*! A TargetDescription string consists of a sequence of hyphen-delimited specifiers for target endianness, pointer size and alignments, and various ___ llvm-commits mailing list llvm-commits@cs.uiuc.edu http://lists.cs.uiuc.edu/mailman/listinfo/llvm-commits
[llvm-commits] [llvm] r44826 - /llvm/trunk/Xcode/LLVM.xcodeproj/project.pbxproj
Author: gordon Date: Mon Dec 10 18:29:16 2007 New Revision: 44826 URL: http://llvm.org/viewvc/llvm-project?rev=44826&view=rev Log: Project file maintenance. Modified: llvm/trunk/Xcode/LLVM.xcodeproj/project.pbxproj Modified: llvm/trunk/Xcode/LLVM.xcodeproj/project.pbxproj URL: http://llvm.org/viewvc/llvm-project/llvm/trunk/Xcode/LLVM.xcodeproj/project.pbxproj?rev=44826&r1=44825&r2=44826&view=diff == --- llvm/trunk/Xcode/LLVM.xcodeproj/project.pbxproj (original) +++ llvm/trunk/Xcode/LLVM.xcodeproj/project.pbxproj Mon Dec 10 18:29:16 2007 @@ -79,6 +79,16 @@ 84115FFF0B66D89B00E1293E /* PPCMachOWriterInfo.cpp */ = {isa = PBXFileReference; fileEncoding = 30; lastKnownFileType = sourcecode.cpp.cpp; path = PPCMachOWriterInfo.cpp; sourceTree = ""; }; 84116B66D8AC00E1293E /* PPCMachOWriterInfo.h */ = {isa = PBXFileReference; fileEncoding = 30; lastKnownFileType = sourcecode.c.h; path = PPCMachOWriterInfo.h; sourceTree = ""; }; 8443EF210B66B62D00959964 /* TargetMachOWriterInfo.h */ = {isa = PBXFileReference; fileEncoding = 30; lastKnownFileType = sourcecode.c.h; path = TargetMachOWriterInfo.h; sourceTree = ""; }; + 9F4B0E5E0D0E02580061F270 /* bitreader_ocaml.c */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.c.c; path = bitreader_ocaml.c; sourceTree = ""; }; + 9F4B0E5F0D0E02580061F270 /* llvm_bitreader.ml */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = text; path = llvm_bitreader.ml; sourceTree = ""; }; + 9F4B0E600D0E02580061F270 /* llvm_bitreader.mli */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = text; path = llvm_bitreader.mli; sourceTree = ""; }; + 9F4B0E8C0D0E05ED0061F270 /* BitReader.cpp */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.cpp.cpp; path = BitReader.cpp; sourceTree = ""; }; + 9F4B0E8D0D0E05ED0061F270 /* DeserializeAPFloat.cpp */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.cpp.cpp; path = DeserializeAPFloat.cpp; sourceTree = ""; }; + 9F5B90CB0D0CE87100CDFDEA /* StringPool.cpp */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.cpp.cpp; path = StringPool.cpp; sourceTree = ""; }; + 9F5B90CE0D0CE89300CDFDEA /* AlignOf.h */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.c.h; path = AlignOf.h; sourceTree = ""; }; + 9F5B90CF0D0CE89300CDFDEA /* Registry.h */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.c.h; path = Registry.h; sourceTree = ""; }; + 9F5B90D00D0CE89300CDFDEA /* StringPool.h */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.c.h; path = StringPool.h; sourceTree = ""; }; + 9F5B90E70D0DF19100CDFDEA /* BitReader.h */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.c.h; path = BitReader.h; sourceTree = ""; }; 9F68EB010C77AD02004AA152 /* LoopPass.cpp */ = {isa = PBXFileReference; fileEncoding = 30; lastKnownFileType = sourcecode.cpp.cpp; path = LoopPass.cpp; sourceTree = ""; }; 9F68EB020C77AD02004AA152 /* MemoryDependenceAnalysis.cpp */ = {isa = PBXFileReference; fileEncoding = 30; lastKnownFileType = sourcecode.cpp.cpp; path = MemoryDependenceAnalysis.cpp; sourceTree = ""; }; 9F68EB060C77AD2C004AA152 /* BitcodeReader.cpp */ = {isa = PBXFileReference; fileEncoding = 30; lastKnownFileType = sourcecode.cpp.cpp; path = BitcodeReader.cpp; sourceTree = ""; }; @@ -1099,6 +1109,16 @@ name = Products; sourceTree = ""; }; + 9F4B0E5D0D0E02580061F270 /* bitreader */ = { + isa = PBXGroup; + children = ( + 9F4B0E5E0D0E02580061F270 /* bitreader_ocaml.c */, + 9F4B0E5F0D0E02580061F270 /* llvm_bitreader.ml */, + 9F4B0E600D0E02580061F270 /* llvm_bitreader.mli */, + ); + path = bitreader; + sourceTree = ""; + }; 9F68EB030C77AD2C004AA152 /* lib/Bitcode */ = { isa = PBXGroup; children = ( @@ -1112,10 +1132,12 @@ 9F68EB050C77AD2C004AA152 /* Reader */ = { isa = PBXGroup; children = ( - 354CF6D10CD299440059AF3E /* DeserializeAPInt.cpp */, 35A9CDF00CD0F6D5008ABC1D /* Deserialize.cpp */, + 9F4B0E8D0D0E05ED0061F270 /* DeserializeAPFloat.cpp */, + 354CF6D10CD299440059A
[llvm-commits] [llvm] r44827 - in /llvm/trunk: docs/GarbageCollection.html include/llvm/CodeGen/Collector.h include/llvm/CodeGen/CollectorMetadata.h include/llvm/CodeGen/Collectors.h include/llvm/Code
Author: gordon Date: Mon Dec 10 18:30:17 2007 New Revision: 44827 URL: http://llvm.org/viewvc/llvm-project?rev=44827&view=rev Log: CollectorMetadata and Collector are rejiggered to get along with per-function collector model. Collector is now the factory for CollectorMetadata, so the latter may be subclassed. Modified: llvm/trunk/docs/GarbageCollection.html llvm/trunk/include/llvm/CodeGen/Collector.h llvm/trunk/include/llvm/CodeGen/CollectorMetadata.h llvm/trunk/include/llvm/CodeGen/Collectors.h llvm/trunk/include/llvm/CodeGen/Passes.h llvm/trunk/lib/CodeGen/Collector.cpp llvm/trunk/lib/CodeGen/CollectorMetadata.cpp Modified: llvm/trunk/docs/GarbageCollection.html URL: http://llvm.org/viewvc/llvm-project/llvm/trunk/docs/GarbageCollection.html?rev=44827&r1=44826&r2=44827&view=diff == --- llvm/trunk/docs/GarbageCollection.html (original) +++ llvm/trunk/docs/GarbageCollection.html Mon Dec 10 18:30:17 2007 @@ -36,8 +36,10 @@ - Collection intrinsics + Core support +Specifying GC code generation: + gc "..." Identifying GC roots on the stack: llvm.gcroot Reading and writing references in the heap @@ -198,11 +200,12 @@ Emitting compatible code, including initialization in the main - program. + program if necessary. Loading a compiler plugin if the collector is not statically linked with your compiler. For llc, use the -load option. - Selecting the collection algorithm with llc -gc= or by setting - llvm::TheCollector. + Selecting the collection algorithm by applying the gc "..." + attribute to your garbage collected functions, or equivalently with + the setCollector method. Linking your final executable with the garbage collector runtime. @@ -211,7 +214,7 @@ Collector -llc arguments +gc attribute Linkage gcroot gcread @@ -219,7 +222,7 @@ SemiSpace --gc=shadow-stack +gc "shadow-stack" TODO FIXME required optional @@ -227,7 +230,7 @@ Ocaml --gc=ocaml +gc "ocaml" provided by ocamlopt required optional @@ -252,11 +255,12 @@ -The ShadowStack collector is invoked with llc -gc=shadow-stack. +The ShadowStack backend is invoked with the gc "shadow-stack" +function attribute. Unlike many collectors which rely on a cooperative code generator to generate stack maps, this algorithm carefully maintains a linked list of stack root descriptors [Henderson2002]. This so-called "shadow -stack," mirrors the machine stack. Maintaining this data structure is slower +stack" mirrors the machine stack. Maintaining this data structure is slower than using stack maps, but has a significant portability advantage because it requires no special support from the target code generator. @@ -264,7 +268,7 @@ program may use load and store instead of llvm.gcread and llvm.gcwrite. -The ShadowStack collector is a compiler plugin only. It must be paired with a +ShadowStack is a code generator plugin only. It must be paired with a compatible runtime. @@ -277,8 +281,7 @@ The SemiSpace runtime implements with the suggested -runtime interface and is compatible the ShadowStack collector's code -generation. +runtime interface and is compatible the ShadowStack backend. SemiSpace is a very simple copying collector. When it starts up, it allocates two blocks of memory for the heap. It uses a simple bump-pointer @@ -302,7 +305,8 @@ -The ocaml collector is invoked with llc -gc=ocaml. It supports the +The ocaml backend is invoked with the gc "ocaml" function attribute. +It supports the http://caml.inria.fr/";>Objective Caml language runtime by emitting a type-accurate stack map in the form of an ocaml 3.10.0-compatible frametable. The linkage requirements are satisfied automatically by the ocamlopt @@ -317,7 +321,7 @@ - Collection intrinsics + Core support @@ -337,6 +341,27 @@ + Specifying GC code generation: gc "..." + + + + define ty @name(...) gc "collector" { ... + + + + +The gc function attribute is used to specify the desired collector +algorithm to the compiler. It is equivalent to specify the collector name +programmatically using the setCollector method of +Function. + +Specifying the collector on a per-function basis allows LLVM to link together +programs which use different garbage collection algorithms. + + + + + Identifying GC roots on the stack: llvm.gcroot @@ -591,6 +616,10 @@ +User code specifies which collector plugin to use with the gc +function attribute or, equivalently, with the setCollector method of +Function. + To implement a collector plugin, it is necessary to subclass llvm::Collector, which can be accomplished in a few lines of boilerplate code. LLVM's infrastructure provides access to several important @@ -616,7 +645,7 @@ }; CollectorRegis
Re: [llvm-commits] [llvm] r44687 - in /llvm/trunk: include/llvm/CodeGen/Passes.h lib/CodeGen/LLVMTargetMachine.cpp lib/CodeGen/MachineLICM.cpp lib/Target/PowerPC/PPCInstrInfo.td
On Dec 10, 2007 3:44 PM, Evan Cheng <[EMAIL PROTECTED]> wrote: > On Dec 10, 2007, at 1:23 PM, Bill Wendling wrote: > > On Dec 10, 2007 11:36 AM, Evan Cheng <[EMAIL PROTECTED]> wrote: > >> I don't think lifting loop invariant from inner loop all the way out > >> of outer-most loop is a good idea. That will increase register > >> pressure in basic blocks where it is not used. > >> > > This is going to happen with the current pass, though. Each loop is > > going to see the hoisted instructions from the previous iteration and > > try to re-hoist them. Is there some heuristic we should apply to > > prevent it from hoisting instructions too far? > > > > I am not sure. :-) > > For innermost loops, hoisting invariants out into the preheader always > make sense. Intuitively, hoisting invariants from inner loops out of > the outermost loop only makes sense when all (or a lot, whatever that > means :-) of the inner loops use it. Or at least the first inner loop > use it. > > What does the LLVM level LICM do? > It does the same thing that Machine LICM does...tries to hoist things as far as possible. -bw ___ llvm-commits mailing list llvm-commits@cs.uiuc.edu http://lists.cs.uiuc.edu/mailman/listinfo/llvm-commits
Re: [llvm-commits] [llvm] r44825 - in /llvm/trunk: include/llvm/Target/TargetData.h lib/Target/TargetData.cpp
> URL: http://llvm.org/viewvc/llvm-project?rev=44825&view=rev > Log: > Move TargetData::hostIsLittleEndian out of line, which means we > don't have to #include config.h in it. #including config.h breaks > other projects that have their own autoconf stuff and try to #include > the llvm headers. One obscure example is llvm-gcc. Duncan, this patch gets llvm-gcc to build, but it still doesn't answer the big question: why does TargetData contain information about the host? I don't think this is the right approach. Also, you can get the host endianness without autoconf by using something simple like: bool islittleendian() { union { int i; char c; }; i = 1; return c; } -Chris ___ llvm-commits mailing list llvm-commits@cs.uiuc.edu http://lists.cs.uiuc.edu/mailman/listinfo/llvm-commits
[llvm-commits] [llvm-gcc-4.2] r44828 - /llvm-gcc-4.2/trunk/README.LLVM
Author: pingbak Date: Mon Dec 10 18:35:46 2007 New Revision: 44828 URL: http://llvm.org/viewvc/llvm-project?rev=44828&view=rev Log: Add a blurb about installing a link to libstdc++.6.dylib so that C++ executables link correctly when the compiler is installed in a nonstandard place. Modified: llvm-gcc-4.2/trunk/README.LLVM Modified: llvm-gcc-4.2/trunk/README.LLVM URL: http://llvm.org/viewvc/llvm-project/llvm-gcc-4.2/trunk/README.LLVM?rev=44828&r1=44827&r2=44828&view=diff == --- llvm-gcc-4.2/trunk/README.LLVM (original) +++ llvm-gcc-4.2/trunk/README.LLVM Mon Dec 10 18:35:46 2007 @@ -126,6 +126,11 @@ --enable-llvm=$LLVMOBJDIR --enable-languages=c,c++$EXTRALANGS $TARGETOPTIONS $ make $BUILDOPTIONS $ make install +$ ln -sf /usr/lib/libstdc++.6.dylib `pwd`/../install/lib + +That last step, "ln -sf ..." is required so that the linker (collect2) can find +libstdc++ ('-lstdc++') and subsequently link C++ executables link correctly. + Note that if you prefer to bootstrap llvm-gcc (so that the final llvm-gcc executables have been compiled with llvm-gcc itself), replace "make" with ___ llvm-commits mailing list llvm-commits@cs.uiuc.edu http://lists.cs.uiuc.edu/mailman/listinfo/llvm-commits
Re: [llvm-commits] [llvm] r44687 - in /llvm/trunk: include/llvm/CodeGen/Passes.h lib/CodeGen/LLVMTargetMachine.cpp lib/CodeGen/MachineLICM.cpp lib/Target/PowerPC/PPCInstrInfo.td
On Dec 10, 2007, at 3:44 PM, Evan Cheng wrote: >> This is going to happen with the current pass, though. Each loop is >> going to see the hoisted instructions from the previous iteration and >> try to re-hoist them. Is there some heuristic we should apply to >> prevent it from hoisting instructions too far? >> > > For innermost loops, hoisting invariants out into the preheader always > make sense. Intuitively, hoisting invariants from inner loops out of > the outermost loop only makes sense when all (or a lot, whatever that > means :-) of the inner loops use it. Or at least the first inner loop > use it. We discussed this today: I'm strongly of the opinion that licm should hoist aggressively and not "think" about register pressure. It should assume that remat is capable of resinking stuff into the loop when possible. This means that we shouldn't have ad-hoc hacks in LICM to avoid "increasing register pressure", but I'm fine with making LICM aware of what remat is able to sink, and having it not hoist things that it can't handle yet. With that said, licm should hoist things as far out as possible. The LLVM LICM pass is structured the way it is in order to hoist loads out, which require checking alias information at each level of a loop nest. We don't have short-term plans to hoist out loops (which will require extensive machine aliasing support), so switching to a model like dan describes (single pass over all bb's in outermost loops, hoisting instructions once instead of iteratively) makes sense to me. -Chris ___ llvm-commits mailing list llvm-commits@cs.uiuc.edu http://lists.cs.uiuc.edu/mailman/listinfo/llvm-commits
[llvm-commits] [llvm-gcc-4.2] r44829 - /llvm-gcc-4.2/trunk/README.LLVM
Author: pingbak Date: Mon Dec 10 18:43:14 2007 New Revision: 44829 URL: http://llvm.org/viewvc/llvm-project?rev=44829&view=rev Log: Fix typo. Modified: llvm-gcc-4.2/trunk/README.LLVM Modified: llvm-gcc-4.2/trunk/README.LLVM URL: http://llvm.org/viewvc/llvm-project/llvm-gcc-4.2/trunk/README.LLVM?rev=44829&r1=44828&r2=44829&view=diff == --- llvm-gcc-4.2/trunk/README.LLVM (original) +++ llvm-gcc-4.2/trunk/README.LLVM Mon Dec 10 18:43:14 2007 @@ -129,8 +129,7 @@ $ ln -sf /usr/lib/libstdc++.6.dylib `pwd`/../install/lib That last step, "ln -sf ..." is required so that the linker (collect2) can find -libstdc++ ('-lstdc++') and subsequently link C++ executables link correctly. - +libstdc++ ('-lstdc++') and subsequently link C++ executables correctly. Note that if you prefer to bootstrap llvm-gcc (so that the final llvm-gcc executables have been compiled with llvm-gcc itself), replace "make" with ___ llvm-commits mailing list llvm-commits@cs.uiuc.edu http://lists.cs.uiuc.edu/mailman/listinfo/llvm-commits
Re: [llvm-commits] [llvm] r44687 - in /llvm/trunk: include/llvm/CodeGen/Passes.h lib/CodeGen/LLVMTargetMachine.cpp lib/CodeGen/MachineLICM.cpp lib/Target/PowerPC/PPCInstrInfo.td
On Dec 10, 2007 4:38 PM, Chris Lattner <[EMAIL PROTECTED]> wrote: > With that said, licm should hoist things as far out as possible. The > LLVM LICM pass is structured the way it is in order to hoist loads > out, which require checking alias information at each level of a loop > nest. We don't have short-term plans to hoist out loops (which will > require extensive machine aliasing support), so switching to a model > like dan describes (single pass over all bb's in outermost loops, > hoisting instructions once instead of iteratively) makes sense to me. > I'm confused. If we do that, we won't be able to hoist things in inner loops into their pre-header blocks. Or are you suggesting that the machine LICM pass looks for loop-invariant instructions. If they can be hoisted all of the way out, then do that. Otherwise, find each containing loop and try to hoist to that pre-header? -bw ___ llvm-commits mailing list llvm-commits@cs.uiuc.edu http://lists.cs.uiuc.edu/mailman/listinfo/llvm-commits
[llvm-commits] [llvm] r44832 - /llvm/tags/Apple/llvmCore-2004/
Author: void Date: Mon Dec 10 19:04:05 2007 New Revision: 44832 URL: http://llvm.org/viewvc/llvm-project?rev=44832&view=rev Log: Retagging with the config.h fix. Added: llvm/tags/Apple/llvmCore-2004/ - copied from r44831, llvm/trunk/ ___ llvm-commits mailing list llvm-commits@cs.uiuc.edu http://lists.cs.uiuc.edu/mailman/listinfo/llvm-commits
[llvm-commits] [llvm] r44835 - /llvm/trunk/lib/Target/X86/X86ISelLowering.cpp
Author: sampo Date: Mon Dec 10 19:41:33 2007 New Revision: 44835 URL: http://llvm.org/viewvc/llvm-project?rev=44835&view=rev Log: x86 doesn't actually want to custom lower v3i32 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=44835&r1=44834&r2=44835&view=diff == --- llvm/trunk/lib/Target/X86/X86ISelLowering.cpp (original) +++ llvm/trunk/lib/Target/X86/X86ISelLowering.cpp Mon Dec 10 19:41:33 2007 @@ -600,6 +600,9 @@ // Custom lower build_vector, vector_shuffle, and extract_vector_elt. for (unsigned VT = (unsigned)MVT::v16i8; VT != (unsigned)MVT::v2i64; VT++) { + // Do not attempt to custom lower non-power-of-2 vectors + if (!isPowerOf2_32(MVT::getVectorNumElements(VT))) +continue; setOperationAction(ISD::BUILD_VECTOR,(MVT::ValueType)VT, Custom); setOperationAction(ISD::VECTOR_SHUFFLE, (MVT::ValueType)VT, Custom); setOperationAction(ISD::EXTRACT_VECTOR_ELT, (MVT::ValueType)VT, Custom); ___ llvm-commits mailing list llvm-commits@cs.uiuc.edu http://lists.cs.uiuc.edu/mailman/listinfo/llvm-commits
[llvm-commits] [llvm] r44836 - in /llvm/trunk: lib/Target/X86/X86ISelLowering.cpp test/CodeGen/X86/vec_shuffle-12.ll test/CodeGen/X86/vec_shuffle-13.ll
Author: evancheng Date: Mon Dec 10 19:46:18 2007 New Revision: 44836 URL: http://llvm.org/viewvc/llvm-project?rev=44836&view=rev Log: - Improved v8i16 shuffle lowering. It now uses pshuflw and pshufhw as much as possible before resorting to pextrw and pinsrw. - Better codegen for v4i32 shuffles masquerading as v8i16 or v16i8 shuffles. - Improves (i16 extract_vector_element 0) codegen by recognizing (i32 extract_vector_element 0) does not require a pextrw. Added: llvm/trunk/test/CodeGen/X86/vec_shuffle-13.ll Modified: llvm/trunk/lib/Target/X86/X86ISelLowering.cpp llvm/trunk/test/CodeGen/X86/vec_shuffle-12.ll Modified: llvm/trunk/lib/Target/X86/X86ISelLowering.cpp URL: http://llvm.org/viewvc/llvm-project/llvm/trunk/lib/Target/X86/X86ISelLowering.cpp?rev=44836&r1=44835&r2=44836&view=diff == --- llvm/trunk/lib/Target/X86/X86ISelLowering.cpp (original) +++ llvm/trunk/lib/Target/X86/X86ISelLowering.cpp Mon Dec 10 19:46:18 2007 @@ -23,6 +23,7 @@ #include "llvm/GlobalVariable.h" #include "llvm/Function.h" #include "llvm/Intrinsics.h" +#include "llvm/ADT/BitVector.h" #include "llvm/ADT/VectorExtras.h" #include "llvm/Analysis/ScalarEvolutionExpressions.h" #include "llvm/CodeGen/CallingConvLower.h" @@ -35,6 +36,7 @@ #include "llvm/Support/CommandLine.h" #include "llvm/Support/Debug.h" #include "llvm/Target/TargetOptions.h" +#include "llvm/ADT/SmallSet.h" #include "llvm/ADT/StringExtras.h" #include "llvm/ParameterAttributes.h" using namespace llvm; @@ -2714,7 +2716,7 @@ if (Arg.getOpcode() == ISD::UNDEF) continue; assert(isa(Arg) && "Invalid VECTOR_SHUFFLE mask!"); unsigned Val = cast(Arg)->getValue(); -if (Val > 4) +if (Val >= 4) return false; } @@ -3130,6 +3132,8 @@ return V; } +/// is4WideVector - Returns true if the specific v8i16 or v16i8 vector is +/// actually just a 4 wide vector. e.g. SDOperand X86TargetLowering::LowerBUILD_VECTOR(SDOperand Op, SelectionDAG &DAG) { // All zero's are handled with pxor, all one's are handled with pcmpeqd. @@ -3154,7 +3158,7 @@ unsigned NumNonZero = 0; unsigned NonZeros = 0; unsigned NumNonZeroImms = 0; - std::set Values; + SmallSet Values; for (unsigned i = 0; i < NumElems; ++i) { SDOperand Elt = Op.getOperand(i); if (Elt.getOpcode() != ISD::UNDEF) { @@ -3314,59 +3318,179 @@ SDOperand LowerVECTOR_SHUFFLEv8i16(SDOperand V1, SDOperand V2, SDOperand PermMask, SelectionDAG &DAG, TargetLowering &TLI) { + SDOperand NewV; MVT::ValueType MaskVT = MVT::getIntVectorWithNumElements(8); MVT::ValueType MaskEVT = MVT::getVectorElementType(MaskVT); - if (isPSHUFHW_PSHUFLWMask(PermMask.Val)) { -// Handle v8i16 shuffle high / low shuffle node pair. + MVT::ValueType PtrVT = TLI.getPointerTy(); + SmallVector MaskElts(PermMask.Val->op_begin(), + PermMask.Val->op_end()); + + // First record which half of which vector the low elements come from. + SmallVector LowQuad(4); + for (unsigned i = 0; i < 4; ++i) { +SDOperand Elt = MaskElts[i]; +if (Elt.getOpcode() == ISD::UNDEF) + continue; +unsigned EltIdx = cast(Elt)->getValue(); +int QuadIdx = EltIdx / 4; +++LowQuad[QuadIdx]; + } + int BestLowQuad = -1; + unsigned MaxQuad = 1; + for (unsigned i = 0; i < 4; ++i) { +if (LowQuad[i] > MaxQuad) { + BestLowQuad = i; + MaxQuad = LowQuad[i]; +} + } + + // Record which half of which vector the high elements come from. + SmallVector HighQuad(4); + for (unsigned i = 4; i < 8; ++i) { +SDOperand Elt = MaskElts[i]; +if (Elt.getOpcode() == ISD::UNDEF) + continue; +unsigned EltIdx = cast(Elt)->getValue(); +int QuadIdx = EltIdx / 4; +++HighQuad[QuadIdx]; + } + int BestHighQuad = -1; + MaxQuad = 1; + for (unsigned i = 0; i < 4; ++i) { +if (HighQuad[i] > MaxQuad) { + BestHighQuad = i; + MaxQuad = HighQuad[i]; +} + } + + // If it's possible to sort parts of either half with PSHUF{H|L}W, then do it. + if (BestLowQuad != -1 || BestHighQuad != -1) { +// First sort the 4 chunks in order using shufpd. SmallVector MaskVec; -for (unsigned i = 0; i != 4; ++i) - MaskVec.push_back(PermMask.getOperand(i)); -for (unsigned i = 4; i != 8; ++i) - MaskVec.push_back(DAG.getConstant(i, MaskEVT)); -SDOperand Mask = DAG.getNode(ISD::BUILD_VECTOR, MaskVT, &MaskVec[0], 8); -V1 = DAG.getNode(ISD::VECTOR_SHUFFLE, MVT::v8i16, V1, V2, Mask); -MaskVec.clear(); -for (unsigned i = 0; i != 4; ++i) - MaskVec.push_back(DAG.getConstant(i, MaskEVT)); -for (unsigned i = 4; i != 8; ++i) - MaskVec.push_back(PermMask.getOperand(i)); -Mask = DAG.getNode(ISD::BUILD_VECTOR, MaskVT, &MaskVec[0], 8); -return DAG.getNode(ISD::VECTOR_SHUFFLE, MVT::v8i16, V1, V2, Mask); +if (BestLowQuad != -1) + M
[llvm-commits] [llvm] r44837 - /llvm/trunk/lib/CodeGen/SelectionDAG/SelectionDAG.cpp
Author: evancheng Date: Mon Dec 10 20:08:35 2007 New Revision: 44837 URL: http://llvm.org/viewvc/llvm-project?rev=44837&view=rev Log: Pretty print shuffle mask operand. Modified: llvm/trunk/lib/CodeGen/SelectionDAG/SelectionDAG.cpp Modified: llvm/trunk/lib/CodeGen/SelectionDAG/SelectionDAG.cpp URL: http://llvm.org/viewvc/llvm-project/llvm/trunk/lib/CodeGen/SelectionDAG/SelectionDAG.cpp?rev=44837&r1=44836&r2=44837&view=diff == --- llvm/trunk/lib/CodeGen/SelectionDAG/SelectionDAG.cpp (original) +++ llvm/trunk/lib/CodeGen/SelectionDAG/SelectionDAG.cpp Mon Dec 10 20:08:35 2007 @@ -3855,6 +3855,19 @@ cerr << ":" << RN; } + if (!isTargetOpcode() && getOpcode() == ISD::VECTOR_SHUFFLE) { +SDNode *Mask = getOperand(2).Val; +cerr << "<"; +for (unsigned i = 0, e = Mask->getNumOperands(); i != e; ++i) { + if (i) cerr << ","; + if (Mask->getOperand(i).getOpcode() == ISD::UNDEF) +cerr << "u"; + else +cerr << cast(Mask->getOperand(i))->getValue(); +} +cerr << ">"; + } + if (const ConstantSDNode *CSDN = dyn_cast(this)) { cerr << "<" << CSDN->getValue() << ">"; } else if (const ConstantFPSDNode *CSDN = dyn_cast(this)) { ___ llvm-commits mailing list llvm-commits@cs.uiuc.edu http://lists.cs.uiuc.edu/mailman/listinfo/llvm-commits
[llvm-commits] [llvm] r44838 - in /llvm/trunk: include/llvm/CodeGen/LiveIntervalAnalysis.h lib/CodeGen/LiveIntervalAnalysis.cpp lib/CodeGen/RegAllocLinearScan.cpp lib/CodeGen/SimpleRegisterCoalescing.
Author: evancheng Date: Mon Dec 10 20:09:15 2007 New Revision: 44838 URL: http://llvm.org/viewvc/llvm-project?rev=44838&view=rev Log: Switch over to MachineLoopInfo. Modified: llvm/trunk/include/llvm/CodeGen/LiveIntervalAnalysis.h llvm/trunk/lib/CodeGen/LiveIntervalAnalysis.cpp llvm/trunk/lib/CodeGen/RegAllocLinearScan.cpp llvm/trunk/lib/CodeGen/SimpleRegisterCoalescing.cpp llvm/trunk/lib/CodeGen/SimpleRegisterCoalescing.h Modified: llvm/trunk/include/llvm/CodeGen/LiveIntervalAnalysis.h URL: http://llvm.org/viewvc/llvm-project/llvm/trunk/include/llvm/CodeGen/LiveIntervalAnalysis.h?rev=44838&r1=44837&r2=44838&view=diff == --- llvm/trunk/include/llvm/CodeGen/LiveIntervalAnalysis.h (original) +++ llvm/trunk/include/llvm/CodeGen/LiveIntervalAnalysis.h Mon Dec 10 20:09:15 2007 @@ -32,7 +32,7 @@ namespace llvm { class LiveVariables; - class LoopInfo; + class MachineLoopInfo; class MRegisterInfo; class SSARegMap; class TargetInstrInfo; @@ -231,7 +231,7 @@ /// the given interval. std::vector addIntervalsForSpills(const LiveInterval& i, - const LoopInfo *loopInfo, VirtRegMap& vrm); + const MachineLoopInfo *loopInfo, VirtRegMap& vrm); /// isReMaterializable - Returns true if every definition of MI of every /// val# of the specified interval is re-materializable. Also returns true @@ -321,7 +321,8 @@ bool isLoad, bool isLoadSS, bool DefIsReMat, bool CanDelete, VirtRegMap &vrm, SSARegMap *RegMap, const TargetRegisterClass* rc, SmallVector &ReMatIds, -unsigned &NewVReg, bool &HasDef, bool &HasUse, const LoopInfo *loopInfo, +unsigned &NewVReg, bool &HasDef, bool &HasUse, +const MachineLoopInfo *loopInfo, std::map &MBBVRegsMap, std::vector &NewLIs); void rewriteInstructionsForSpills(const LiveInterval &li, bool TrySplit, @@ -329,7 +330,7 @@ MachineInstr *OrigDefMI, MachineInstr *DefMI, unsigned Slot, int LdSlot, bool isLoad, bool isLoadSS, bool DefIsReMat, bool CanDelete, VirtRegMap &vrm, SSARegMap *RegMap, const TargetRegisterClass* rc, -SmallVector &ReMatIds, const LoopInfo *loopInfo, +SmallVector &ReMatIds, const MachineLoopInfo *loopInfo, BitVector &SpillMBBs, std::map > &SpillIdxes, BitVector &RestoreMBBs, Modified: llvm/trunk/lib/CodeGen/LiveIntervalAnalysis.cpp URL: http://llvm.org/viewvc/llvm-project/llvm/trunk/lib/CodeGen/LiveIntervalAnalysis.cpp?rev=44838&r1=44837&r2=44838&view=diff == --- llvm/trunk/lib/CodeGen/LiveIntervalAnalysis.cpp (original) +++ llvm/trunk/lib/CodeGen/LiveIntervalAnalysis.cpp Mon Dec 10 20:09:15 2007 @@ -19,10 +19,10 @@ #include "llvm/CodeGen/LiveIntervalAnalysis.h" #include "VirtRegMap.h" #include "llvm/Value.h" -#include "llvm/Analysis/LoopInfo.h" #include "llvm/CodeGen/LiveVariables.h" #include "llvm/CodeGen/MachineFrameInfo.h" #include "llvm/CodeGen/MachineInstr.h" +#include "llvm/CodeGen/MachineLoopInfo.h" #include "llvm/CodeGen/Passes.h" #include "llvm/CodeGen/SSARegMap.h" #include "llvm/Target/MRegisterInfo.h" @@ -765,7 +765,7 @@ const TargetRegisterClass* rc, SmallVector &ReMatIds, unsigned &NewVReg, bool &HasDef, bool &HasUse, - const LoopInfo *loopInfo, + const MachineLoopInfo *loopInfo, std::map &MBBVRegsMap, std::vector &NewLIs) { bool CanFold = false; @@ -962,7 +962,7 @@ VirtRegMap &vrm, SSARegMap *RegMap, const TargetRegisterClass* rc, SmallVector &ReMatIds, -const LoopInfo *loopInfo, +const MachineLoopInfo *loopInfo, BitVector &SpillMBBs, std::map > &SpillIdxes, BitVector &RestoreMBBs, @@ -1119,7 +1119,7 @@ } // Update spill weight. -unsigned loopDepth = loopInfo->getLoopDepth(MBB->getBasicBlock()); +unsigned loopDepth = loopInfo->getLoopDepth(MBB); nI.weight += getSpillWeight(HasDef, HasUse, loopDepth); } @@ -1158,7 +1158,7 @@ std::vector LiveIntervals:: addIntervalsForSpills(const LiveInterval &li, - const LoopInfo *loopInfo, VirtRegMap &vrm) { + const MachineLoopInfo *loopInfo, VirtRegMap &vrm) { // Since this is called after the analysis is done we don't know if // LiveVariables is available lv_ = getAnalysisToUpdate(); Modified: llvm/trunk/lib/CodeGen/RegAllocLinearScan.cpp URL: http://llvm.org/viewvc/llvm-project/llvm/trunk/lib/CodeGen/RegAllocLinearScan.cpp?rev=44838&r1=44837&r2=44838&view=diff == -
[llvm-commits] [support] r44846 - /support/trunk/autoconf/m4/want_level.m4
Author: reid Date: Mon Dec 10 23:27:47 2007 New Revision: 44846 URL: http://llvm.org/viewvc/llvm-project?rev=44846&view=rev Log: Allow some additional values for levels that are non-numeric. Modified: support/trunk/autoconf/m4/want_level.m4 Modified: support/trunk/autoconf/m4/want_level.m4 URL: http://llvm.org/viewvc/llvm-project/support/trunk/autoconf/m4/want_level.m4?rev=44846&r1=44845&r2=44846&view=diff == --- support/trunk/autoconf/m4/want_level.m4 (original) +++ support/trunk/autoconf/m4/want_level.m4 Mon Dec 10 23:27:47 2007 @@ -9,6 +9,12 @@ m4_define([allcapsname],translit($1,a-z-,A-Z_)) AC_ARG_ENABLE([$1], AS_HELP_STRING([--enable-$1],[$2 ($3)]),,enableval="$3") + case "$enableval" in +yes) enableval="1" ;; +no) enableval="0" ;; +[0-9]*) ;; +*) enableval="0" ;; + esac digits=`echo "$enableval" | sed 's/[^0-9]//'` if test -z "$digits" ; then AC_MSG_ERROR([Expected numeric value for --enable-$1.]) ___ llvm-commits mailing list llvm-commits@cs.uiuc.edu http://lists.cs.uiuc.edu/mailman/listinfo/llvm-commits
[llvm-commits] [support] r44847 - /support/trunk/include/llvm/ADT/
Author: reid Date: Mon Dec 10 23:33:05 2007 New Revision: 44847 URL: http://llvm.org/viewvc/llvm-project?rev=44847&view=rev Log: Prepare for update by deleting everything. Removed: support/trunk/include/llvm/ADT/ ___ llvm-commits mailing list llvm-commits@cs.uiuc.edu http://lists.cs.uiuc.edu/mailman/listinfo/llvm-commits
[llvm-commits] [support] r44848 - /support/trunk/include/llvm/ADT/
Author: reid Date: Mon Dec 10 23:36:40 2007 New Revision: 44848 URL: http://llvm.org/viewvc/llvm-project?rev=44848&view=rev Log: Add latest ADT header from llvm module to support module. Added: support/trunk/include/llvm/ADT/ - copied from r44847, llvm/trunk/include/llvm/ADT/ ___ llvm-commits mailing list llvm-commits@cs.uiuc.edu http://lists.cs.uiuc.edu/mailman/listinfo/llvm-commits
[llvm-commits] [llvm] r44849 - /llvm/trunk/lib/VMCore/ConstantFold.cpp
Author: lattner Date: Mon Dec 10 23:55:02 2007 New Revision: 44849 URL: http://llvm.org/viewvc/llvm-project?rev=44849&view=rev Log: refactor some code, no functionality change. Modified: llvm/trunk/lib/VMCore/ConstantFold.cpp Modified: llvm/trunk/lib/VMCore/ConstantFold.cpp URL: http://llvm.org/viewvc/llvm-project/llvm/trunk/lib/VMCore/ConstantFold.cpp?rev=44849&r1=44848&r2=44849&view=diff == --- llvm/trunk/lib/VMCore/ConstantFold.cpp (original) +++ llvm/trunk/lib/VMCore/ConstantFold.cpp Mon Dec 10 23:55:02 2007 @@ -138,6 +138,101 @@ Type::Int64Ty); } +static Constant *FoldBitCast(Constant *V, const Type *DestTy) { + const Type *SrcTy = V->getType(); + if (SrcTy == DestTy) +return V; // no-op cast + + // Check to see if we are casting a pointer to an aggregate to a pointer to + // the first element. If so, return the appropriate GEP instruction. + if (const PointerType *PTy = dyn_cast(V->getType())) +if (const PointerType *DPTy = dyn_cast(DestTy)) { + SmallVector IdxList; + IdxList.push_back(Constant::getNullValue(Type::Int32Ty)); + const Type *ElTy = PTy->getElementType(); + while (ElTy != DPTy->getElementType()) { +if (const StructType *STy = dyn_cast(ElTy)) { + if (STy->getNumElements() == 0) break; + ElTy = STy->getElementType(0); + IdxList.push_back(Constant::getNullValue(Type::Int32Ty)); +} else if (const SequentialType *STy = dyn_cast(ElTy)) { + if (isa(ElTy)) break; // Can't index into pointers! + ElTy = STy->getElementType(); + IdxList.push_back(IdxList[0]); +} else { + break; +} + } + + if (ElTy == DPTy->getElementType()) +return ConstantExpr::getGetElementPtr(V, &IdxList[0], IdxList.size()); +} + + // Handle casts from one vector constant to another. We know that the src + // and dest type have the same size (otherwise its an illegal cast). + if (const VectorType *DestPTy = dyn_cast(DestTy)) { +if (const VectorType *SrcTy = dyn_cast(V->getType())) { + assert(DestPTy->getBitWidth() == SrcTy->getBitWidth() && + "Not cast between same sized vectors!"); + // First, check for null. Undef is already handled. + if (isa(V)) +return Constant::getNullValue(DestTy); + + if (const ConstantVector *CV = dyn_cast(V)) { +// This is a cast from a ConstantVector of one type to a +// ConstantVector of another type. Check to see if all elements of +// the input are simple. +bool AllSimpleConstants = true; +for (unsigned i = 0, e = CV->getNumOperands(); i != e; ++i) { + if (!isa(CV->getOperand(i)) && + !isa(CV->getOperand(i))) { +AllSimpleConstants = false; +break; + } +} + +// If all of the elements are simple constants, we can fold this. +if (AllSimpleConstants) + return CastConstantVector(const_cast(CV), DestPTy); + } +} + } + + // Finally, implement bitcast folding now. The code below doesn't handle + // bitcast right. + if (isa(V)) // ptr->ptr cast. +return ConstantPointerNull::get(cast(DestTy)); + + // Handle integral constant input. + if (const ConstantInt *CI = dyn_cast(V)) { +if (DestTy->isInteger()) + // Integral -> Integral. This is a no-op because the bit widths must + // be the same. Consequently, we just fold to V. + return V; + +if (DestTy->isFloatingPoint()) { + assert((DestTy == Type::DoubleTy || DestTy == Type::FloatTy) && + "Unknown FP type!"); + return ConstantFP::get(DestTy, APFloat(CI->getValue())); +} +// Otherwise, can't fold this (vector?) +return 0; + } + + // Handle ConstantFP input. + if (const ConstantFP *FP = dyn_cast(V)) { +// FP -> Integral. +if (DestTy == Type::Int32Ty) { + return ConstantInt::get(FP->getValueAPF().convertToAPInt()); +} else { + assert(DestTy == Type::Int64Ty && "only support f32/f64 for now!"); + return ConstantInt::get(FP->getValueAPF().convertToAPInt()); +} + } + return 0; +} + + Constant *llvm::ConstantFoldCastInstruction(unsigned opc, const Constant *V, const Type *DestTy) { const Type *SrcTy = V->getType(); @@ -268,100 +363,7 @@ } return 0; case Instruction::BitCast: -if (SrcTy == DestTy) - return (Constant*)V; // no-op cast - -// Check to see if we are casting a pointer to an aggregate to a pointer to -// the first element. If so, return the appropriate GEP instruction. -if (const PointerType *PTy = dyn_cast(V->getType())) - if (const PointerType *DPTy = dyn_cast(DestTy)) { -SmallVector IdxList; -IdxList.push_back(Constant::getNullValue(Type::Int32Ty)
[llvm-commits] [llvm] r44850 - /llvm/trunk/lib/VMCore/ConstantFold.cpp
Author: lattner Date: Tue Dec 11 00:07:39 2007 New Revision: 44850 URL: http://llvm.org/viewvc/llvm-project?rev=44850&view=rev Log: significantly simplify some code, no functionality change. Modified: llvm/trunk/lib/VMCore/ConstantFold.cpp Modified: llvm/trunk/lib/VMCore/ConstantFold.cpp URL: http://llvm.org/viewvc/llvm-project/llvm/trunk/lib/VMCore/ConstantFold.cpp?rev=44850&r1=44849&r2=44850&view=diff == --- llvm/trunk/lib/VMCore/ConstantFold.cpp (original) +++ llvm/trunk/lib/VMCore/ConstantFold.cpp Tue Dec 11 00:07:39 2007 @@ -36,81 +36,31 @@ //ConstantFold*Instruction Implementations //===--===// -/// CastConstantVector - Convert the specified ConstantVector node to the +/// BitCastConstantVector - Convert the specified ConstantVector node to the /// specified vector type. At this point, we know that the elements of the /// input vector constant are all simple integer or FP values. -static Constant *CastConstantVector(ConstantVector *CV, -const VectorType *DstTy) { - unsigned SrcNumElts = CV->getType()->getNumElements(); - unsigned DstNumElts = DstTy->getNumElements(); - const Type *SrcEltTy = CV->getType()->getElementType(); - const Type *DstEltTy = DstTy->getElementType(); +static Constant *BitCastConstantVector(ConstantVector *CV, + const VectorType *DstTy) { + // If this cast changes element count then we can't handle it here: + // doing so requires endianness information. This should be handled by + // Analysis/ConstantFolding.cpp + unsigned NumElts = DstTy->getNumElements(); + if (NumElts != CV->getNumOperands()) +return 0; - // If both vectors have the same number of elements (thus, the elements - // are the same size), perform the conversion now. - if (SrcNumElts == DstNumElts) { -std::vector Result; - -// If the src and dest elements are both integers, or both floats, we can -// just BitCast each element because the elements are the same size. -if ((SrcEltTy->isInteger() && DstEltTy->isInteger()) || -(SrcEltTy->isFloatingPoint() && DstEltTy->isFloatingPoint())) { - for (unsigned i = 0; i != SrcNumElts; ++i) -Result.push_back( - ConstantExpr::getBitCast(CV->getOperand(i), DstEltTy)); - return ConstantVector::get(Result); -} - -// If this is an int-to-fp cast .. -if (SrcEltTy->isInteger()) { - // Ensure that it is int-to-fp cast - assert(DstEltTy->isFloatingPoint()); - if (DstEltTy->getTypeID() == Type::DoubleTyID) { -for (unsigned i = 0; i != SrcNumElts; ++i) { - ConstantInt *CI = cast(CV->getOperand(i)); - double V = CI->getValue().bitsToDouble(); - Result.push_back(ConstantFP::get(Type::DoubleTy, APFloat(V))); -} -return ConstantVector::get(Result); - } - assert(DstEltTy == Type::FloatTy && "Unknown fp type!"); - for (unsigned i = 0; i != SrcNumElts; ++i) { -ConstantInt *CI = cast(CV->getOperand(i)); -float V = CI->getValue().bitsToFloat(); -Result.push_back(ConstantFP::get(Type::FloatTy, APFloat(V))); - } - return ConstantVector::get(Result); -} - -// Otherwise, this is an fp-to-int cast. -assert(SrcEltTy->isFloatingPoint() && DstEltTy->isInteger()); - -if (SrcEltTy->getTypeID() == Type::DoubleTyID) { - for (unsigned i = 0; i != SrcNumElts; ++i) { -uint64_t V = cast(CV->getOperand(i))-> - getValueAPF().convertToAPInt().getZExtValue(); -Constant *C = ConstantInt::get(Type::Int64Ty, V); -Result.push_back(ConstantExpr::getBitCast(C, DstEltTy )); - } - return ConstantVector::get(Result); -} - -assert(SrcEltTy->getTypeID() == Type::FloatTyID); -for (unsigned i = 0; i != SrcNumElts; ++i) { - uint32_t V = (uint32_t)cast(CV->getOperand(i))-> - getValueAPF().convertToAPInt().getZExtValue(); - Constant *C = ConstantInt::get(Type::Int32Ty, V); - Result.push_back(ConstantExpr::getBitCast(C, DstEltTy)); -} -return ConstantVector::get(Result); + // Check to verify that all elements of the input are simple. + for (unsigned i = 0; i != NumElts; ++i) { +if (!isa(CV->getOperand(i)) && +!isa(CV->getOperand(i))) + return 0; } - - // Otherwise, this is a cast that changes element count and size. Handle - // casts which shrink the elements here. - - // FIXME: We need to know endianness to do this! - - return 0; + + // Bitcast each element now. + std::vector Result; + const Type *DstEltTy = DstTy->getElementType(); + for (unsigned i = 0; i != NumElts; ++i) +Result.push_back(ConstantExpr::getBitCast(CV->getOperand(i), DstEltTy)); + return ConstantVector::get(Result); } ///
[llvm-commits] [llvm] r44851 - /llvm/trunk/include/llvm/ADT/Trie.h
Author: asl Date: Tue Dec 11 00:53:44 2007 New Revision: 44851 URL: http://llvm.org/viewvc/llvm-project?rev=44851&view=rev Log: Add first and really dirty version of generic Trie structure Added: llvm/trunk/include/llvm/ADT/Trie.h Added: llvm/trunk/include/llvm/ADT/Trie.h URL: http://llvm.org/viewvc/llvm-project/llvm/trunk/include/llvm/ADT/Trie.h?rev=44851&view=auto == --- llvm/trunk/include/llvm/ADT/Trie.h (added) +++ llvm/trunk/include/llvm/ADT/Trie.h Tue Dec 11 00:53:44 2007 @@ -0,0 +1,223 @@ +//===- llvm/ADT/Trie.h Generic trie structure --*- C++ -*-===// +// +// The LLVM Compiler Infrastructure +// +// This file was developed by Anton Korobeynikov and is distributed under +// the University of Illinois Open Source License. See LICENSE.TXT for details. +// +//===--===// +// +// This class defines a generic trie structure. The trie structure +// is immutable after creation, but the payload contained within it is not. +// +//===--===// + +#ifndef LLVM_ADT_TRIE_H +#define LLVM_ADT_TRIE_H + +#include +#include + +namespace llvm { + +// FIXME: +// - Labels are usually small, maybe it's better to use SmallString +// - Something efficient for child storage +// - Should we use char* during construction? +// - GraphTraits interface +// - Eliminate Edge class, which is ok for debugging, but not for end code + +template +class Trie { + class Edge; + class Node; + + class Edge { +std::string Label; +Node *Parent, *Child; + + public: +typedef enum { + Same = -3, + StringIsPrefix = -2, + LabelIsPrefix = -1, + DontMatch = 0, + HaveCommonPart +} QueryResult; + +inline explicit Edge(std::string label = "", + Node* parent = NULL, Node* child = NULL): + Label(label), Parent(parent), Child(child) { } + +inline void setParent(Node* parent) { Parent = parent; } +inline Node* getParent() const { return Parent; } +inline void setChild(Node* child) { Child = child; } +inline Node* getChild() const { return Child; } +inline void setLabel(const std::string& label) { Label = label; } +inline const std::string& getLabel() const { return Label; } + +QueryResult query(const std::string& string) const { + unsigned i, l; + unsigned l1 = string.length(); + unsigned l2 = Label.length(); + + // Find the length of common part + l = std::min(l1, l2); + i = 0; + while ((i < l) && (string[i] == Label[i])) +++i; + + if (i == l) { // One is prefix of another, find who is who +if (l1 == l2) + return Same; +else if (i == l1) + return StringIsPrefix; +else + return LabelIsPrefix; + } else // String and Label just have common part, return its length +return (QueryResult)i; +} + }; + + class Node { +friend class Trie; + +std::map Edges; +Payload Data; + public: +inline explicit Node(const Payload& data):Data(data) { } +inline Node(const Node& n) { + Data = n.Data; + Edges = n.Edges; +} +inline Node& operator=(const Node& n) { + if (&n != this) { +Data = n.Data; +Edges = n.Edges; + } + + return *this; +} + +inline bool isLeaf() const { return Edges.empty(); } + +inline const Payload& getData() const { return Data; } +inline void setData(const Payload& data) { Data = data; } + +inline Edge* addEdge(const std::string& Label) { + if (!Edges.insert(std::make_pair(Label[0], + Edge(Label, this))).second) { +assert(0 && "Edge already exists!"); +return NULL; + } else +return &Edges[Label[0]]; +} + }; + + std::vector Nodes; + Payload Empty; + + inline Node* addNode(const Payload& data) { +Node* N = new Node(data); +Nodes.push_back(N); +return N; + } + + inline Node* splitEdge(Edge& cEdge, size_t index) { +const std::string& l = cEdge.getLabel(); +assert(index < l.length() && "Trying to split too far!"); + +std::string l1 = l.substr(0, index); +std::string l2 = l.substr(index); + +Node* nNode = addNode(Empty); +Edge* nEdge = nNode->addEdge(l2); +nEdge->setChild(cEdge.getChild()); +cEdge.setChild(nNode); +cEdge.setLabel(l1); + +return nNode; + } + +public: + inline explicit Trie(const Payload& empty):Empty(empty) { +addNode(Empty); + } + inline ~Trie() { +for (unsigned i = 0, e = Nodes.size(); i != e; ++i) + delete Nodes[i]; + } + + inline Node* getRoot() const { return Nodes[0]; } + + bool addString(const std::string& s, const Payload& data) { +Node* cNode = getRoot(); +Edge* nEdge = NULL; +std::string s1(s); + +
[llvm-commits] [llvm] r44852 - /llvm/trunk/lib/Support/APInt.cpp
Author: reid Date: Tue Dec 11 00:53:58 2007 New Revision: 44852 URL: http://llvm.org/viewvc/llvm-project?rev=44852&view=rev Log: Don't have APInt.cpp depend upon DerivedTypes.h. This helps with splitting the Support libraries separately into their own module. Modified: llvm/trunk/lib/Support/APInt.cpp Modified: llvm/trunk/lib/Support/APInt.cpp URL: http://llvm.org/viewvc/llvm-project/llvm/trunk/lib/Support/APInt.cpp?rev=44852&r1=44851&r2=44852&view=diff == --- llvm/trunk/lib/Support/APInt.cpp (original) +++ llvm/trunk/lib/Support/APInt.cpp Tue Dec 11 00:53:58 2007 @@ -14,7 +14,6 @@ #define DEBUG_TYPE "apint" #include "llvm/ADT/APInt.h" -#include "llvm/DerivedTypes.h" #include "llvm/Support/Debug.h" #include "llvm/Support/MathExtras.h" #include @@ -25,6 +24,16 @@ using namespace llvm; + +/// This enumeration just provides for internal constants used in this +/// translation unit. +enum { + MIN_INT_BITS = 1,///< Minimum number of bits that can be specified + ///< Note that this must remain synchronized with IntegerType::MIN_INT_BITS + MAX_INT_BITS = (1<<23)-1 ///< Maximum number of bits that can be specified + ///< Note that this must remain synchronized with IntegerType::MAX_INT_BITS +}; + /// A utility function for allocating memory, checking for allocation failures, /// and ensuring the contents are zeroed. inline static uint64_t* getClearedMemory(uint32_t numWords) { @@ -44,8 +53,8 @@ APInt::APInt(uint32_t numBits, uint64_t val, bool isSigned) : BitWidth(numBits), VAL(0) { - assert(BitWidth >= IntegerType::MIN_INT_BITS && "bitwidth too small"); - assert(BitWidth <= IntegerType::MAX_INT_BITS && "bitwidth too large"); + assert(BitWidth >= MIN_INT_BITS && "bitwidth too small"); + assert(BitWidth <= MAX_INT_BITS && "bitwidth too large"); if (isSingleWord()) VAL = val; else { @@ -60,8 +69,8 @@ APInt::APInt(uint32_t numBits, uint32_t numWords, const uint64_t bigVal[]) : BitWidth(numBits), VAL(0) { - assert(BitWidth >= IntegerType::MIN_INT_BITS && "bitwidth too small"); - assert(BitWidth <= IntegerType::MAX_INT_BITS && "bitwidth too large"); + assert(BitWidth >= MIN_INT_BITS && "bitwidth too small"); + assert(BitWidth <= MAX_INT_BITS && "bitwidth too large"); assert(bigVal && "Null pointer detected!"); if (isSingleWord()) VAL = bigVal[0]; @@ -80,23 +89,23 @@ APInt::APInt(uint32_t numbits, const char StrStart[], uint32_t slen, uint8_t radix) : BitWidth(numbits), VAL(0) { - assert(BitWidth >= IntegerType::MIN_INT_BITS && "bitwidth too small"); - assert(BitWidth <= IntegerType::MAX_INT_BITS && "bitwidth too large"); + assert(BitWidth >= MIN_INT_BITS && "bitwidth too small"); + assert(BitWidth <= MAX_INT_BITS && "bitwidth too large"); fromString(numbits, StrStart, slen, radix); } APInt::APInt(uint32_t numbits, const std::string& Val, uint8_t radix) : BitWidth(numbits), VAL(0) { - assert(BitWidth >= IntegerType::MIN_INT_BITS && "bitwidth too small"); - assert(BitWidth <= IntegerType::MAX_INT_BITS && "bitwidth too large"); + assert(BitWidth >= MIN_INT_BITS && "bitwidth too small"); + assert(BitWidth <= MAX_INT_BITS && "bitwidth too large"); assert(!Val.empty() && "String empty?"); fromString(numbits, Val.c_str(), Val.size(), radix); } APInt::APInt(const APInt& that) : BitWidth(that.BitWidth), VAL(0) { - assert(BitWidth >= IntegerType::MIN_INT_BITS && "bitwidth too small"); - assert(BitWidth <= IntegerType::MAX_INT_BITS && "bitwidth too large"); + assert(BitWidth >= MIN_INT_BITS && "bitwidth too small"); + assert(BitWidth <= MAX_INT_BITS && "bitwidth too large"); if (isSingleWord()) VAL = that.VAL; else { @@ -943,7 +952,7 @@ // Truncate to new width. APInt &APInt::trunc(uint32_t width) { assert(width < BitWidth && "Invalid APInt Truncate request"); - assert(width >= IntegerType::MIN_INT_BITS && "Can't truncate to 0 bits"); + assert(width >= MIN_INT_BITS && "Can't truncate to 0 bits"); uint32_t wordsBefore = getNumWords(); BitWidth = width; uint32_t wordsAfter = getNumWords(); @@ -966,7 +975,7 @@ // Sign extend to a new width. APInt &APInt::sext(uint32_t width) { assert(width > BitWidth && "Invalid APInt SignExtend request"); - assert(width <= IntegerType::MAX_INT_BITS && "Too many bits"); + assert(width <= MAX_INT_BITS && "Too many bits"); // If the sign bit isn't set, this is the same as zext. if (!isNegative()) { zext(width); @@ -1014,7 +1023,7 @@ // Zero extend to a new width. APInt &APInt::zext(uint32_t width) { assert(width > BitWidth && "Invalid APInt ZeroExtend request"); - assert(width <= IntegerType::MAX_INT_BITS && "Too many bits"); + assert(width <= MAX_INT_BITS && "Too many bits"); uint32_t wordsBefore = getNumWords(); BitWidth = width; uint32_t wordsAfter = getNumWords(); ___ llvm-commits
[llvm-commits] [support] r44854 - /support/trunk/lib/Support/APInt.cpp
Author: reid Date: Tue Dec 11 00:59:17 2007 New Revision: 44854 URL: http://llvm.org/viewvc/llvm-project?rev=44854&view=rev Log: Update new version of APInt.cpp. Added: support/trunk/lib/Support/APInt.cpp - copied unchanged from r44853, llvm/trunk/lib/Support/APInt.cpp ___ llvm-commits mailing list llvm-commits@cs.uiuc.edu http://lists.cs.uiuc.edu/mailman/listinfo/llvm-commits
[llvm-commits] [llvm] r44855 - in /llvm/trunk: lib/Analysis/ConstantFolding.cpp test/Transforms/InstCombine/bitcast-vector-fold.ll
Author: lattner Date: Tue Dec 11 01:29:44 2007 New Revision: 44855 URL: http://llvm.org/viewvc/llvm-project?rev=44855&view=rev Log: Implement constant folding if vector<->vector bitcasts where the number of source/dest elements changes. This implements test/Transforms/InstCombine/bitcast-vector-fold.ll Added: llvm/trunk/test/Transforms/InstCombine/bitcast-vector-fold.ll Modified: llvm/trunk/lib/Analysis/ConstantFolding.cpp Modified: llvm/trunk/lib/Analysis/ConstantFolding.cpp URL: http://llvm.org/viewvc/llvm-project/llvm/trunk/lib/Analysis/ConstantFolding.cpp?rev=44855&r1=44854&r2=44855&view=diff == --- llvm/trunk/lib/Analysis/ConstantFolding.cpp (original) +++ llvm/trunk/lib/Analysis/ConstantFolding.cpp Tue Dec 11 01:29:44 2007 @@ -145,6 +145,122 @@ return 0; } +/// FoldBitCast - Constant fold bitcast, symbolically evaluating it with +/// targetdata. Return 0 if unfoldable. +static Constant *FoldBitCast(Constant *C, const Type *DestTy, + const TargetData &TD) { + // If this is a bitcast from constant vector -> vector, fold it. + if (ConstantVector *CV = dyn_cast(C)) { +if (const VectorType *DestVTy = dyn_cast(DestTy)) { + // If the element types match, VMCore can fold it. + unsigned NumDstElt = DestVTy->getNumElements(); + unsigned NumSrcElt = CV->getNumOperands(); + if (NumDstElt == NumSrcElt) +return 0; + + const Type *SrcEltTy = CV->getType()->getElementType(); + const Type *DstEltTy = DestVTy->getElementType(); + + // Otherwise, we're changing the number of elements in a vector, which + // requires endianness information to do the right thing. For example, + //bitcast (<2 x i64> to <4 x i32>) + // folds to (little endian): + //<4 x i32> + // and to (big endian): + //<4 x i32> + + // First thing is first. We only want to think about integer here, so if + // we have something in FP form, recast it as integer. + if (DstEltTy->isFloatingPoint()) { +// Fold to an vector of integers with same size as our FP type. +unsigned FPWidth = DstEltTy->getPrimitiveSizeInBits(); +const Type *DestIVTy = VectorType::get(IntegerType::get(FPWidth), + NumDstElt); +// Recursively handle this integer conversion, if possible. +C = FoldBitCast(C, DestIVTy, TD); +if (!C) return 0; + +// Finally, VMCore can handle this now that #elts line up. +return ConstantExpr::getBitCast(C, DestTy); + } + + // Okay, we know the destination is integer, if the input is FP, convert + // it to integer first. + if (SrcEltTy->isFloatingPoint()) { +unsigned FPWidth = SrcEltTy->getPrimitiveSizeInBits(); +const Type *SrcIVTy = VectorType::get(IntegerType::get(FPWidth), + NumSrcElt); +// Ask VMCore to do the conversion now that #elts line up. +C = ConstantExpr::getBitCast(C, SrcIVTy); +CV = dyn_cast(C); +if (!CV) return 0; // If VMCore wasn't able to fold it, bail out. + } + + // Now we know that the input and output vectors are both integer vectors + // of the same size, and that their #elements is not the same. Do the + // conversion here, which depends on whether the input or output has + // more elements. + bool isLittleEndian = TD.isLittleEndian(); + + SmallVector Result; + if (NumDstElt < NumSrcElt) { +// Handle: bitcast (<4 x i32> to <2 x i64>) +Constant *Zero = Constant::getNullValue(DstEltTy); +unsigned Ratio = NumSrcElt/NumDstElt; +unsigned SrcBitSize = SrcEltTy->getPrimitiveSizeInBits(); +unsigned SrcElt = 0; +for (unsigned i = 0; i != NumDstElt; ++i) { + // Build each element of the result. + Constant *Elt = Zero; + unsigned ShiftAmt = isLittleEndian ? 0 : SrcBitSize*(Ratio-1); + for (unsigned j = 0; j != Ratio; ++j) { +Constant *Src = dyn_cast(CV->getOperand(SrcElt++)); +if (!Src) return 0; // Reject constantexpr elements. + +// Zero extend the element to the right size. +Src = ConstantExpr::getZExt(Src, Elt->getType()); + +// Shift it to the right place, depending on endianness. +Src = ConstantExpr::getShl(Src, +ConstantInt::get(Src->getType(), ShiftAmt)); +ShiftAmt += isLittleEndian ? SrcBitSize : -SrcBitSize; + +// Mix it in. +Elt = ConstantExpr::getOr(Elt, Src); + } + Result.push_back(Elt); +} + } else { +// Handle: bitcast (<2 x i64> to <4 x i32>) +unsigned Ratio = NumDstElt/NumSrcElt;
[llvm-commits] [llvm] r44856 - /llvm/trunk/lib/VMCore/ConstantFold.cpp
Author: lattner Date: Tue Dec 11 01:49:37 2007 New Revision: 44856 URL: http://llvm.org/viewvc/llvm-project?rev=44856&view=rev Log: Teach VMCore to constant fold shufflevectors with constant operands. This allows us to compile: #include typedef __m128i VSInt16; typedef short vSInt16 __attribute__ ((__vector_size__ (16))); VSInt16 t3() { return (VSInt16)((vSInt16)_mm_set1_epi16(6518)); } into: _t3: movaps LCPI1_0, %xmm0 ret instead of: _t3: movl$6518, %eax movd%eax, %xmm0 pextrw $0, %xmm0, %eax xorps %xmm0, %xmm0 pinsrw $0, %eax, %xmm0 punpcklwd %xmm0, %xmm0 pshufd $0, %xmm0, %xmm0 ret Modified: llvm/trunk/lib/VMCore/ConstantFold.cpp Modified: llvm/trunk/lib/VMCore/ConstantFold.cpp URL: http://llvm.org/viewvc/llvm-project/llvm/trunk/lib/VMCore/ConstantFold.cpp?rev=44856&r1=44855&r2=44856&view=diff == --- llvm/trunk/lib/VMCore/ConstantFold.cpp (original) +++ llvm/trunk/lib/VMCore/ConstantFold.cpp Tue Dec 11 01:49:37 2007 @@ -396,11 +396,54 @@ return 0; } +/// GetVectorElement - If C is a ConstantVector, ConstantAggregateZero or Undef +/// return the specified element value. Otherwise return null. +static Constant *GetVectorElement(const Constant *C, unsigned EltNo) { + if (const ConstantVector *CV = dyn_cast(C)) +return const_cast(CV->getOperand(EltNo)); + + const Type *EltTy = cast(C->getType())->getElementType(); + if (isa(C)) +return Constant::getNullValue(EltTy); + if (isa(C)) +return UndefValue::get(EltTy); + return 0; +} + Constant *llvm::ConstantFoldShuffleVectorInstruction(const Constant *V1, const Constant *V2, const Constant *Mask) { - // TODO: - return 0; + // Undefined shuffle mask -> undefined value. + if (isa(Mask)) return UndefValue::get(V1->getType()); + + unsigned NumElts = cast(V1->getType())->getNumElements(); + const Type *EltTy = cast(V1->getType())->getElementType(); + + // Loop over the shuffle mask, evaluating each element. + SmallVector Result; + for (unsigned i = 0; i != NumElts; ++i) { +Constant *InElt = GetVectorElement(Mask, i); +if (InElt == 0) return 0; + +if (isa(InElt)) + InElt = UndefValue::get(EltTy); +else if (ConstantInt *CI = dyn_cast(InElt)) { + unsigned Elt = CI->getZExtValue(); + if (Elt >= NumElts*2) +InElt = UndefValue::get(EltTy); + else if (Elt >= NumElts) +InElt = GetVectorElement(V2, Elt-NumElts); + else +InElt = GetVectorElement(V1, Elt); + if (InElt == 0) return 0; +} else { + // Unknown value. + return 0; +} +Result.push_back(InElt); + } + + return ConstantVector::get(&Result[0], Result.size()); } /// EvalVectorOp - Given two vector constants and a function pointer, apply the ___ llvm-commits mailing list llvm-commits@cs.uiuc.edu http://lists.cs.uiuc.edu/mailman/listinfo/llvm-commits