From nicholas at mxc.ca Mon Oct 3 00:15:00 2011 From: nicholas at mxc.ca (Nick Lewycky) Date: Mon, 03 Oct 2011 05:15:00 -0000 Subject: [llvm-commits] [llvm] r140980 - in /llvm/trunk: lib/Analysis/ScalarEvolution.cpp test/Analysis/ScalarEvolution/max-trip-count.ll Message-ID: <20111003051500.B8CE62A6C12C@llvm.org> Author: nicholas Date: Mon Oct 3 00:14:59 2011 New Revision: 140980 URL: http://llvm.org/viewvc/llvm-project?rev=140980&view=rev Log: Revert r140979 due to reports of bootstrap failure. Modified: llvm/trunk/lib/Analysis/ScalarEvolution.cpp llvm/trunk/test/Analysis/ScalarEvolution/max-trip-count.ll Modified: llvm/trunk/lib/Analysis/ScalarEvolution.cpp URL: http://llvm.org/viewvc/llvm-project/llvm/trunk/lib/Analysis/ScalarEvolution.cpp?rev=140980&r1=140979&r2=140980&view=diff ============================================================================== --- llvm/trunk/lib/Analysis/ScalarEvolution.cpp (original) +++ llvm/trunk/lib/Analysis/ScalarEvolution.cpp Mon Oct 3 00:14:59 2011 @@ -5119,7 +5119,7 @@ // Compute the two solutions for the quadratic formula. // The divisions must be performed as signed divisions. APInt NegB(-B); - APInt TwoA(A << 1); + APInt TwoA( A << 1 ); if (TwoA.isMinValue()) { const SCEV *CNC = SE.getCouldNotCompute(); return std::make_pair(CNC, CNC); @@ -5134,7 +5134,7 @@ return std::make_pair(SE.getConstant(Solution1), SE.getConstant(Solution2)); - } // end APIntOps namespace + } // end APIntOps namespace } /// HowFarToZero - Return the number of times a backedge comparing the specified @@ -5228,12 +5228,8 @@ // Handle unitary steps, which cannot wraparound. // 1*N = -Start; -1*N = Start (mod 2^BW), so: // N = Distance (as unsigned) - if (StepC->getValue()->equalsInt(1) || StepC->getValue()->isAllOnesValue()) { - ConstantRange CR = getUnsignedRange(Start); - const SCEV *MaxBECount = getConstant(CountDown ? CR.getUnsignedMax() - : ~CR.getUnsignedMin()); - return ExitLimit(Distance, MaxBECount); - } + if (StepC->getValue()->equalsInt(1) || StepC->getValue()->isAllOnesValue()) + return Distance; // If the recurrence is known not to wraparound, unsigned divide computes the // back edge count. We know that the value will either become zero (and thus Modified: llvm/trunk/test/Analysis/ScalarEvolution/max-trip-count.ll URL: http://llvm.org/viewvc/llvm-project/llvm/trunk/test/Analysis/ScalarEvolution/max-trip-count.ll?rev=140980&r1=140979&r2=140980&view=diff ============================================================================== --- llvm/trunk/test/Analysis/ScalarEvolution/max-trip-count.ll (original) +++ llvm/trunk/test/Analysis/ScalarEvolution/max-trip-count.ll Mon Oct 3 00:14:59 2011 @@ -70,31 +70,3 @@ } declare i32 @printf(i8*, ...) - -define void @test(i8* %a, i32 %n) nounwind { -entry: - %cmp1 = icmp sgt i32 %n, 0 - br i1 %cmp1, label %for.body.lr.ph, label %for.end - -for.body.lr.ph: ; preds = %entry - %tmp = zext i32 %n to i64 - br label %for.body - -for.body: ; preds = %for.body, %for.body.lr.ph - %indvar = phi i64 [ %indvar.next, %for.body ], [ 0, %for.body.lr.ph ] - %arrayidx = getelementptr i8* %a, i64 %indvar - store i8 0, i8* %arrayidx, align 1 - %indvar.next = add i64 %indvar, 1 - %exitcond = icmp ne i64 %indvar.next, %tmp - br i1 %exitcond, label %for.body, label %for.cond.for.end_crit_edge - -for.cond.for.end_crit_edge: ; preds = %for.body - br label %for.end - -for.end: ; preds = %for.cond.for.end_crit_edge, %entry - ret void -} - -; CHECK: Determining loop execution counts for: @test -; CHECK-NEXT: backedge-taken count is -; CHECK-NEXT: max backedge-taken count is -1 From edwintorok at gmail.com Mon Oct 3 01:41:46 2011 From: edwintorok at gmail.com (Torok Edwin) Date: Mon, 03 Oct 2011 06:41:46 -0000 Subject: [llvm-commits] [llvm] r140991 - in /llvm/trunk: bindings/ocaml/llvm/llvm.ml bindings/ocaml/llvm/llvm.mli bindings/ocaml/llvm/llvm_ocaml.c test/Bindings/Ocaml/vmcore.ml Message-ID: <20111003064149.69FAC2A6C12C@llvm.org> Author: edwin Date: Mon Oct 3 01:41:46 2011 New Revision: 140991 URL: http://llvm.org/viewvc/llvm-project?rev=140991&view=rev Log: attempt to fix ocaml bindings: landing pads Modified: llvm/trunk/bindings/ocaml/llvm/llvm.ml llvm/trunk/bindings/ocaml/llvm/llvm.mli llvm/trunk/bindings/ocaml/llvm/llvm_ocaml.c llvm/trunk/test/Bindings/Ocaml/vmcore.ml Modified: llvm/trunk/bindings/ocaml/llvm/llvm.ml URL: http://llvm.org/viewvc/llvm-project/llvm/trunk/bindings/ocaml/llvm/llvm.ml?rev=140991&r1=140990&r2=140991&view=diff ============================================================================== --- llvm/trunk/bindings/ocaml/llvm/llvm.ml (original) +++ llvm/trunk/bindings/ocaml/llvm/llvm.ml Mon Oct 3 01:41:46 2011 @@ -820,6 +820,9 @@ external build_invoke : llvalue -> llvalue array -> llbasicblock -> llbasicblock -> string -> llbuilder -> llvalue = "llvm_build_invoke_bc" "llvm_build_invoke_nat" +external build_landingpad : lltype -> llvalue -> int -> string -> llbuilder -> + llvalue = "llvm_build_landingpad" +external set_cleanup : llvalue -> bool -> unit = "llvm_set_cleanup" external build_unreachable : llbuilder -> llvalue = "llvm_build_unreachable" (*--... Arithmetic .........................................................--*) Modified: llvm/trunk/bindings/ocaml/llvm/llvm.mli URL: http://llvm.org/viewvc/llvm-project/llvm/trunk/bindings/ocaml/llvm/llvm.mli?rev=140991&r1=140990&r2=140991&view=diff ============================================================================== --- llvm/trunk/bindings/ocaml/llvm/llvm.mli (original) +++ llvm/trunk/bindings/ocaml/llvm/llvm.mli Mon Oct 3 01:41:46 2011 @@ -339,7 +339,7 @@ See the method [llvm::FunctionType::get]. *) val function_type : lltype -> lltype array -> lltype -(** [va_arg_function_type ret_ty param_tys] is just like +(** [var_arg_function_type ret_ty param_tys] is just like [function_type ret_ty param_tys] except that it returns the function type which also takes a variable number of arguments. See the method [llvm::FunctionType::get]. *) @@ -1615,6 +1615,16 @@ val build_invoke : llvalue -> llvalue array -> llbasicblock -> llbasicblock -> string -> llbuilder -> llvalue +(** [build_landingpad ty persfn numclauses name b] creates an + [landingpad] + instruction at the position specified by the instruction builder [b]. + See the method [llvm::LLVMBuilder::CreateLandingPad]. *) +val build_landingpad : lltype -> llvalue -> int -> string -> llbuilder -> + llvalue + +(** [set_cleanup lp] sets the cleanup flag in the [landingpad]instruction. + See the method [llvm::LandingPadInst::setCleanup]. *) +val set_cleanup : llvalue -> bool -> unit (** [build_unreachable b] creates an [unreachable] Modified: llvm/trunk/bindings/ocaml/llvm/llvm_ocaml.c URL: http://llvm.org/viewvc/llvm-project/llvm/trunk/bindings/ocaml/llvm/llvm_ocaml.c?rev=140991&r1=140990&r2=140991&view=diff ============================================================================== --- llvm/trunk/bindings/ocaml/llvm/llvm_ocaml.c (original) +++ llvm/trunk/bindings/ocaml/llvm/llvm_ocaml.c Mon Oct 3 01:41:46 2011 @@ -1212,6 +1212,19 @@ Args[4], Args[5]); } +CAMLprim LLVMValueRef llvm_build_landingpad(LLVMTypeRef Ty, LLVMValueRef PersFn, + value NumClauses, value Name, + value B) { + return LLVMBuildLandingPad(Builder_val(B), Ty, PersFn, Int_val(NumClauses), + String_val(Name)); +} + +CAMLprim value llvm_set_cleanup(LLVMValueRef LandingPadInst, value flag) +{ + LLVMSetCleanup(LandingPadInst, Bool_val(flag)); + return Val_unit; +} + /* llbuilder -> llvalue */ CAMLprim LLVMValueRef llvm_build_unreachable(value B) { return LLVMBuildUnreachable(Builder_val(B)); Modified: llvm/trunk/test/Bindings/Ocaml/vmcore.ml URL: http://llvm.org/viewvc/llvm-project/llvm/trunk/test/Bindings/Ocaml/vmcore.ml?rev=140991&r1=140990&r2=140991&view=diff ============================================================================== --- llvm/trunk/test/Bindings/Ocaml/vmcore.ml (original) +++ llvm/trunk/test/Bindings/Ocaml/vmcore.ml Mon Oct 3 01:41:46 2011 @@ -834,7 +834,17 @@ let bb00 = append_block context "Bb00" fn in ignore (build_unreachable (builder_at_end context bb00)); - + + let bblpad = append_block context "Bblpad" fn in + let rt = struct_type context [| pointer_type i8_type; i32_type |] in + let ft = var_arg_function_type i32_type [||] in + let personality = declare_function "__gxx_personality_v0" ft m in begin + let lp = build_landingpad rt personality 0 "lpad" + (builder_at_end context bblpad) in + set_cleanup lp true; + ignore (build_unreachable (builder_at_end context bblpad)); + end; + group "ret"; begin (* RUN: grep {ret.*P1} < %t.ll *) @@ -891,11 +901,11 @@ group "invoke"; begin (* RUN: grep {build_invoke.*invoke.*P1.*P2} < %t.ll - * RUN: grep {to.*Bb04.*unwind.*Bb00} < %t.ll + * RUN: grep {to.*Bb04.*unwind.*Bblpad} < %t.ll *) let bb04 = append_block context "Bb04" fn in let b = builder_at_end context bb04 in - ignore (build_invoke fn [| p1; p2 |] bb04 bb00 "build_invoke" b) + ignore (build_invoke fn [| p1; p2 |] bb04 bblpad "build_invoke" b) end; group "unreachable"; begin From edwintorok at gmail.com Mon Oct 3 01:45:07 2011 From: edwintorok at gmail.com (=?ISO-8859-1?Q?T=F6r=F6k_Edwin?=) Date: Mon, 03 Oct 2011 09:45:07 +0300 Subject: [llvm-commits] fixing the OCaml bindings for 3.0 In-Reply-To: <553D8D40-6AD8-4794-B645-FE89535F4E74@apple.com> References: <4E870429.4000006@gmail.com> <4E888C95.7090108@gmail.com> <553D8D40-6AD8-4794-B645-FE89535F4E74@apple.com> Message-ID: <4E8959F3.2070509@gmail.com> On 10/03/2011 01:28 AM, Cameron Zwarich wrote: > On Oct 2, 2011, at 9:08 AM, T?r?k Edwin wrote: > >> On 10/01/2011 03:14 PM, T?r?k Edwin wrote: >>> Hi, >>> >>> I noticed that currently the OCaml bindings don't pass the testsuite. >>> First problem is due to exception handling changes: invoke must point to a basic block with a landingpad, >>> otherwise verifier rejects it. >>> >>> Attach patch tries to address that by exposing LLVMBuildLandingPad, and calling it: the verifier passes now. >>> There are still many grep failures left though, I'll probably go through these in the next days and try to figure what is wrong. >>> >>> Some help would be appreciated, there are currently 158 grep failures (even after applying this patch), see log.gz. >> >> Looks like I misinterpreted the output from lit: it shows all greps regardless if they failed or not. >> There was really only one failure, attached patch makes all Bindings/Ocaml tests pass! >> >> OK to commit? > > I don't have experience with the Ocaml bindings, but it looks good to me. > Thanks, committed. --Edwin From nicholas at mxc.ca Mon Oct 3 02:10:46 2011 From: nicholas at mxc.ca (Nick Lewycky) Date: Mon, 03 Oct 2011 07:10:46 -0000 Subject: [llvm-commits] [llvm] r140992 - in /llvm/trunk: lib/Analysis/ScalarEvolution.cpp test/Analysis/ScalarEvolution/max-trip-count.ll Message-ID: <20111003071046.6E0E02A6C12C@llvm.org> Author: nicholas Date: Mon Oct 3 02:10:45 2011 New Revision: 140992 URL: http://llvm.org/viewvc/llvm-project?rev=140992&view=rev Log: Reapply r140979 with fix! We never did get a testcase, but careful review of the logic by David Meyer revealed this bug. Modified: llvm/trunk/lib/Analysis/ScalarEvolution.cpp llvm/trunk/test/Analysis/ScalarEvolution/max-trip-count.ll Modified: llvm/trunk/lib/Analysis/ScalarEvolution.cpp URL: http://llvm.org/viewvc/llvm-project/llvm/trunk/lib/Analysis/ScalarEvolution.cpp?rev=140992&r1=140991&r2=140992&view=diff ============================================================================== --- llvm/trunk/lib/Analysis/ScalarEvolution.cpp (original) +++ llvm/trunk/lib/Analysis/ScalarEvolution.cpp Mon Oct 3 02:10:45 2011 @@ -5119,7 +5119,7 @@ // Compute the two solutions for the quadratic formula. // The divisions must be performed as signed divisions. APInt NegB(-B); - APInt TwoA( A << 1 ); + APInt TwoA(A << 1); if (TwoA.isMinValue()) { const SCEV *CNC = SE.getCouldNotCompute(); return std::make_pair(CNC, CNC); @@ -5134,7 +5134,7 @@ return std::make_pair(SE.getConstant(Solution1), SE.getConstant(Solution2)); - } // end APIntOps namespace + } // end APIntOps namespace } /// HowFarToZero - Return the number of times a backedge comparing the specified @@ -5228,8 +5228,19 @@ // Handle unitary steps, which cannot wraparound. // 1*N = -Start; -1*N = Start (mod 2^BW), so: // N = Distance (as unsigned) - if (StepC->getValue()->equalsInt(1) || StepC->getValue()->isAllOnesValue()) - return Distance; + if (StepC->getValue()->equalsInt(1) || StepC->getValue()->isAllOnesValue()) { + ConstantRange CR = getUnsignedRange(Start); + const SCEV *MaxBECount; + if (!CountDown && CR.getUnsignedMin().isMinValue()) + // When counting up, the worst starting value is 1, not 0. + MaxBECount = CR.getUnsignedMax().isMinValue() + ? getConstant(APInt::getMinValue(CR.getBitWidth())) + : getConstant(APInt::getMaxValue(CR.getBitWidth())); + else + MaxBECount = getConstant(CountDown ? CR.getUnsignedMax() + : -CR.getUnsignedMin()); + return ExitLimit(Distance, MaxBECount); + } // If the recurrence is known not to wraparound, unsigned divide computes the // back edge count. We know that the value will either become zero (and thus Modified: llvm/trunk/test/Analysis/ScalarEvolution/max-trip-count.ll URL: http://llvm.org/viewvc/llvm-project/llvm/trunk/test/Analysis/ScalarEvolution/max-trip-count.ll?rev=140992&r1=140991&r2=140992&view=diff ============================================================================== --- llvm/trunk/test/Analysis/ScalarEvolution/max-trip-count.ll (original) +++ llvm/trunk/test/Analysis/ScalarEvolution/max-trip-count.ll Mon Oct 3 02:10:45 2011 @@ -70,3 +70,31 @@ } declare i32 @printf(i8*, ...) + +define void @test(i8* %a, i32 %n) nounwind { +entry: + %cmp1 = icmp sgt i32 %n, 0 + br i1 %cmp1, label %for.body.lr.ph, label %for.end + +for.body.lr.ph: ; preds = %entry + %tmp = zext i32 %n to i64 + br label %for.body + +for.body: ; preds = %for.body, %for.body.lr.ph + %indvar = phi i64 [ %indvar.next, %for.body ], [ 0, %for.body.lr.ph ] + %arrayidx = getelementptr i8* %a, i64 %indvar + store i8 0, i8* %arrayidx, align 1 + %indvar.next = add i64 %indvar, 1 + %exitcond = icmp ne i64 %indvar.next, %tmp + br i1 %exitcond, label %for.body, label %for.cond.for.end_crit_edge + +for.cond.for.end_crit_edge: ; preds = %for.body + br label %for.end + +for.end: ; preds = %for.cond.for.end_crit_edge, %entry + ret void +} + +; CHECK: Determining loop execution counts for: @test +; CHECK-NEXT: backedge-taken count is +; CHECK-NEXT: max backedge-taken count is -1 From craig.topper at gmail.com Mon Oct 3 02:51:10 2011 From: craig.topper at gmail.com (Craig Topper) Date: Mon, 03 Oct 2011 07:51:10 -0000 Subject: [llvm-commits] [llvm] r140993 - /llvm/trunk/lib/Target/X86/Disassembler/X86DisassemblerDecoder.c Message-ID: <20111003075115.2D8D8312800A@llvm.org> Author: ctopper Date: Mon Oct 3 02:51:09 2011 New Revision: 140993 URL: http://llvm.org/viewvc/llvm-project?rev=140993&view=rev Log: Fix VEX disassembling to ignore REX.RXBW bits in 32-bit mode. Modified: llvm/trunk/lib/Target/X86/Disassembler/X86DisassemblerDecoder.c Modified: llvm/trunk/lib/Target/X86/Disassembler/X86DisassemblerDecoder.c URL: http://llvm.org/viewvc/llvm-project/llvm/trunk/lib/Target/X86/Disassembler/X86DisassemblerDecoder.c?rev=140993&r1=140992&r2=140993&view=diff ============================================================================== --- llvm/trunk/lib/Target/X86/Disassembler/X86DisassemblerDecoder.c (original) +++ llvm/trunk/lib/Target/X86/Disassembler/X86DisassemblerDecoder.c Mon Oct 3 02:51:09 2011 @@ -406,12 +406,14 @@ consumeByte(insn, &insn->vexPrefix[2]); /* We simulate the REX prefix for simplicity's sake */ - - insn->rexPrefix = 0x40 - | (wFromVEX3of3(insn->vexPrefix[2]) << 3) - | (rFromVEX2of3(insn->vexPrefix[1]) << 2) - | (xFromVEX2of3(insn->vexPrefix[1]) << 1) - | (bFromVEX2of3(insn->vexPrefix[1]) << 0); + + if (insn->mode == MODE_64BIT) { + insn->rexPrefix = 0x40 + | (wFromVEX3of3(insn->vexPrefix[2]) << 3) + | (rFromVEX2of3(insn->vexPrefix[1]) << 2) + | (xFromVEX2of3(insn->vexPrefix[1]) << 1) + | (bFromVEX2of3(insn->vexPrefix[1]) << 0); + } switch (ppFromVEX3of3(insn->vexPrefix[2])) { @@ -444,8 +446,10 @@ insn->vexPrefix[0] = byte; consumeByte(insn, &insn->vexPrefix[1]); - insn->rexPrefix = 0x40 - | (rFromVEX2of2(insn->vexPrefix[1]) << 2); + if (insn->mode == MODE_64BIT) { + insn->rexPrefix = 0x40 + | (rFromVEX2of2(insn->vexPrefix[1]) << 2); + } switch (ppFromVEX2of2(insn->vexPrefix[1])) { @@ -763,7 +767,7 @@ break; } - if (wFromVEX3of3(insn->vexPrefix[2])) + if (insn->mode == MODE_64BIT && wFromVEX3of3(insn->vexPrefix[2])) attrMask |= ATTR_REXW; if (lFromVEX3of3(insn->vexPrefix[2])) attrMask |= ATTR_VEXL; From craig.topper at gmail.com Mon Oct 3 02:53:59 2011 From: craig.topper at gmail.com (Craig Topper) Date: Mon, 03 Oct 2011 07:53:59 -0000 Subject: [llvm-commits] [llvm] r140994 - /llvm/trunk/test/MC/Disassembler/X86/x86-32.txt Message-ID: <20111003075359.69AB0312800A@llvm.org> Author: ctopper Date: Mon Oct 3 02:53:59 2011 New Revision: 140994 URL: http://llvm.org/viewvc/llvm-project?rev=140994&view=rev Log: Test updates that were supposed to go with r140993. Modified: llvm/trunk/test/MC/Disassembler/X86/x86-32.txt Modified: llvm/trunk/test/MC/Disassembler/X86/x86-32.txt URL: http://llvm.org/viewvc/llvm-project/llvm/trunk/test/MC/Disassembler/X86/x86-32.txt?rev=140994&r1=140993&r2=140994&view=diff ============================================================================== --- llvm/trunk/test/MC/Disassembler/X86/x86-32.txt (original) +++ llvm/trunk/test/MC/Disassembler/X86/x86-32.txt Mon Oct 3 02:53:59 2011 @@ -102,13 +102,13 @@ # CHECK: movw $47416, -66(%ebp) 0x66 0xc7 0x45 0xbe 0x38 0xb9 -# CHECK: vaddpd %ymm13, %ymm1, %ymm0 +# CHECK: vaddpd %ymm5, %ymm1, %ymm0 0xc4 0xc1 0x75 0x58 0xc5 # CHECK: vaddps %ymm3, %ymm1, %ymm0 0xc5 0xf4 0x58 0xc3 -# CHECK: vandpd %ymm13, %ymm1, %ymm0 +# CHECK: vandpd %ymm5, %ymm1, %ymm0 0xc4 0xc1 0x75 0x54 0xc5 # CHECK: vandps %ymm3, %ymm1, %ymm0 @@ -129,8 +129,8 @@ # CHECK: vcvtsd2si %xmm0, %eax 0xc5 0xfb 0x2d 0xc0 -# CHECK: vcvtsd2si %xmm0, %rax -0xc4 0xe1 0xfb 0x2d 0xc0 +# CHECK: vcvtsd2si %xmm0, %eax +0xc4 0xe1 0x7b 0x2d 0xc0 # CHECK: vmaskmovpd %xmm0, %xmm1, (%eax) 0xc4 0xe2 0x71 0x2f 0x00 From craig.topper at gmail.com Mon Oct 3 03:14:31 2011 From: craig.topper at gmail.com (Craig Topper) Date: Mon, 03 Oct 2011 08:14:31 -0000 Subject: [llvm-commits] [llvm] r140997 - in /llvm/trunk: lib/Target/X86/Disassembler/X86DisassemblerDecoder.c test/MC/Disassembler/X86/simple-tests.txt test/MC/Disassembler/X86/x86-32.txt Message-ID: <20111003081431.E9F8D312800A@llvm.org> Author: ctopper Date: Mon Oct 3 03:14:29 2011 New Revision: 140997 URL: http://llvm.org/viewvc/llvm-project?rev=140997&view=rev Log: Treat VEX.vvvv as a 3-bit field outside of 64-bit mode. Prevents access to registers xmm8-xmm15 outside 64-bit mode. Modified: llvm/trunk/lib/Target/X86/Disassembler/X86DisassemblerDecoder.c llvm/trunk/test/MC/Disassembler/X86/simple-tests.txt llvm/trunk/test/MC/Disassembler/X86/x86-32.txt Modified: llvm/trunk/lib/Target/X86/Disassembler/X86DisassemblerDecoder.c URL: http://llvm.org/viewvc/llvm-project/llvm/trunk/lib/Target/X86/Disassembler/X86DisassemblerDecoder.c?rev=140997&r1=140996&r2=140997&view=diff ============================================================================== --- llvm/trunk/lib/Target/X86/Disassembler/X86DisassemblerDecoder.c (original) +++ llvm/trunk/lib/Target/X86/Disassembler/X86DisassemblerDecoder.c Mon Oct 3 03:14:29 2011 @@ -1491,6 +1491,9 @@ else return -1; + if (insn->mode != MODE_64BIT) + insn->vvvv &= 0x7; + return 0; } Modified: llvm/trunk/test/MC/Disassembler/X86/simple-tests.txt URL: http://llvm.org/viewvc/llvm-project/llvm/trunk/test/MC/Disassembler/X86/simple-tests.txt?rev=140997&r1=140996&r2=140997&view=diff ============================================================================== --- llvm/trunk/test/MC/Disassembler/X86/simple-tests.txt (original) +++ llvm/trunk/test/MC/Disassembler/X86/simple-tests.txt Mon Oct 3 03:14:29 2011 @@ -365,3 +365,6 @@ # CHECK: testq $0, %rax 0x48 0xa9 0x00 0x00 0x00 0x00 + +# CHECK: vaddps %xmm3, %xmm15, %xmm0 +0xc4 0xe1 0x00 0x58 0xc3 Modified: llvm/trunk/test/MC/Disassembler/X86/x86-32.txt URL: http://llvm.org/viewvc/llvm-project/llvm/trunk/test/MC/Disassembler/X86/x86-32.txt?rev=140997&r1=140996&r2=140997&view=diff ============================================================================== --- llvm/trunk/test/MC/Disassembler/X86/x86-32.txt (original) +++ llvm/trunk/test/MC/Disassembler/X86/x86-32.txt Mon Oct 3 03:14:29 2011 @@ -384,3 +384,6 @@ # CHECK: movl %eax, 0 0xa3 0x00 0x00 0x00 0x00 + +# CHECK: vaddps %xmm3, %xmm7, %xmm0 +0xc4 0xe1 0x00 0x58 0xc3 From edwintorok at gmail.com Mon Oct 3 08:38:59 2011 From: edwintorok at gmail.com (=?ISO-8859-1?Q?T=F6r=F6k_Edwin?=) Date: Mon, 03 Oct 2011 16:38:59 +0300 Subject: [llvm-commits] Fix opcodes in C bindings Message-ID: <4E89BAF3.2040905@gmail.com> Hi, LLVMOpcode is out of sync with getOpcode() right now (was ok in 2.9 AFAICT). Attached patch introduces a function to map between Instruction::* opcodes and the opcodes declared in llvm-c/Core.h. It does that by using the macros in Instruction.def, so that it will always be up-to-date as internal opcodes change. When a new opcode is introduced you'll get a compile error in Core.cpp and will have to add it to llvm-c/Core.h as well (at the end of the other opcodes). This way the C API opcodes can't get out-of-sync. The 2nd patch adds an LLVMGetInstructionOpcode to the C API, to allow it to inspect, not just create instructions. Best regards, --Edwin -------------- next part -------------- A non-text attachment was scrubbed... Name: 0001-Don-t-require-C-bindings-opcode-numbers-to-be-kept-i.patch Type: text/x-patch Size: 3486 bytes Desc: not available Url : http://lists.cs.uiuc.edu/pipermail/llvm-commits/attachments/20111003/d904b22b/attachment.bin -------------- next part -------------- A non-text attachment was scrubbed... Name: add_getopcode.patch Type: text/x-patch Size: 1153 bytes Desc: not available Url : http://lists.cs.uiuc.edu/pipermail/llvm-commits/attachments/20111003/d904b22b/attachment-0001.bin From rafael.espindola at gmail.com Mon Oct 3 09:45:38 2011 From: rafael.espindola at gmail.com (Rafael Espindola) Date: Mon, 03 Oct 2011 14:45:38 -0000 Subject: [llvm-commits] [llvm] r141001 - in /llvm/trunk: docs/LangRef.html include/llvm/Attributes.h lib/AsmParser/LLLexer.cpp lib/AsmParser/LLParser.cpp lib/AsmParser/LLToken.h lib/Target/CppBackend/CPPBackend.cpp lib/VMCore/Attributes.cpp test/Transforms/Mem2Reg/2007-08-27-VolatileLoadsStores.ll test/Transforms/TailCallElim/setjmp.ll Message-ID: <20111003144541.503492A6C12C@llvm.org> Author: rafael Date: Mon Oct 3 09:45:37 2011 New Revision: 141001 URL: http://llvm.org/viewvc/llvm-project?rev=141001&view=rev Log: Add the returns_twice attribute to LLVM. Modified: llvm/trunk/docs/LangRef.html llvm/trunk/include/llvm/Attributes.h llvm/trunk/lib/AsmParser/LLLexer.cpp llvm/trunk/lib/AsmParser/LLParser.cpp llvm/trunk/lib/AsmParser/LLToken.h llvm/trunk/lib/Target/CppBackend/CPPBackend.cpp llvm/trunk/lib/VMCore/Attributes.cpp llvm/trunk/test/Transforms/Mem2Reg/2007-08-27-VolatileLoadsStores.ll llvm/trunk/test/Transforms/TailCallElim/setjmp.ll Modified: llvm/trunk/docs/LangRef.html URL: http://llvm.org/viewvc/llvm-project/llvm/trunk/docs/LangRef.html?rev=141001&r1=141000&r2=141001&view=diff ============================================================================== --- llvm/trunk/docs/LangRef.html (original) +++ llvm/trunk/docs/LangRef.html Mon Oct 3 09:45:37 2011 @@ -1262,6 +1262,11 @@ the ELF x86-64 abi, but it can be disabled for some compilation units. +
returns_twice
+
This attribute indicates that this function can return + twice. The C setjmp is an example of such a function. + The compiler disables some optimizations (like tail calls) in the caller of + these functions.
Modified: llvm/trunk/include/llvm/Attributes.h URL: http://llvm.org/viewvc/llvm-project/llvm/trunk/include/llvm/Attributes.h?rev=141001&r1=141000&r2=141001&view=diff ============================================================================== --- llvm/trunk/include/llvm/Attributes.h (original) +++ llvm/trunk/include/llvm/Attributes.h Mon Oct 3 09:45:37 2011 @@ -65,8 +65,7 @@ ///of alignment with +1 bias ///0 means unaligned (different from ///alignstack(1)) -const Attributes Hotpatch = 1<<29; ///< Function should have special - ///'hotpatch' sequence in prologue +const Attributes ReturnsTwice = 1<<29; ///< Function can return twice const Attributes UWTable = 1<<30; ///< Function must be in a unwind ///table const Attributes NonLazyBind = 1U<<31; ///< Function is called early and/or @@ -93,7 +92,7 @@ const Attributes FunctionOnly = NoReturn | NoUnwind | ReadNone | ReadOnly | NoInline | AlwaysInline | OptimizeForSize | StackProtect | StackProtectReq | NoRedZone | NoImplicitFloat | Naked | InlineHint | StackAlignment | - Hotpatch | UWTable | NonLazyBind; + UWTable | NonLazyBind | ReturnsTwice; /// @brief Parameter attributes that do not apply to vararg call arguments. const Attributes VarArgsIncompatible = StructRet; Modified: llvm/trunk/lib/AsmParser/LLLexer.cpp URL: http://llvm.org/viewvc/llvm-project/llvm/trunk/lib/AsmParser/LLLexer.cpp?rev=141001&r1=141000&r2=141001&view=diff ============================================================================== --- llvm/trunk/lib/AsmParser/LLLexer.cpp (original) +++ llvm/trunk/lib/AsmParser/LLLexer.cpp Mon Oct 3 09:45:37 2011 @@ -558,6 +558,7 @@ KEYWORD(readnone); KEYWORD(readonly); KEYWORD(uwtable); + KEYWORD(returns_twice); KEYWORD(inlinehint); KEYWORD(noinline); Modified: llvm/trunk/lib/AsmParser/LLParser.cpp URL: http://llvm.org/viewvc/llvm-project/llvm/trunk/lib/AsmParser/LLParser.cpp?rev=141001&r1=141000&r2=141001&view=diff ============================================================================== --- llvm/trunk/lib/AsmParser/LLParser.cpp (original) +++ llvm/trunk/lib/AsmParser/LLParser.cpp Mon Oct 3 09:45:37 2011 @@ -911,6 +911,7 @@ case lltok::kw_noreturn: Attrs |= Attribute::NoReturn; break; case lltok::kw_nounwind: Attrs |= Attribute::NoUnwind; break; case lltok::kw_uwtable: Attrs |= Attribute::UWTable; break; + case lltok::kw_returns_twice: Attrs |= Attribute::ReturnsTwice; break; case lltok::kw_noinline: Attrs |= Attribute::NoInline; break; case lltok::kw_readnone: Attrs |= Attribute::ReadNone; break; case lltok::kw_readonly: Attrs |= Attribute::ReadOnly; break; @@ -922,7 +923,6 @@ case lltok::kw_noredzone: Attrs |= Attribute::NoRedZone; break; case lltok::kw_noimplicitfloat: Attrs |= Attribute::NoImplicitFloat; break; case lltok::kw_naked: Attrs |= Attribute::Naked; break; - case lltok::kw_hotpatch: Attrs |= Attribute::Hotpatch; break; case lltok::kw_nonlazybind: Attrs |= Attribute::NonLazyBind; break; case lltok::kw_alignstack: { Modified: llvm/trunk/lib/AsmParser/LLToken.h URL: http://llvm.org/viewvc/llvm-project/llvm/trunk/lib/AsmParser/LLToken.h?rev=141001&r1=141000&r2=141001&view=diff ============================================================================== --- llvm/trunk/lib/AsmParser/LLToken.h (original) +++ llvm/trunk/lib/AsmParser/LLToken.h Mon Oct 3 09:45:37 2011 @@ -90,6 +90,7 @@ kw_readnone, kw_readonly, kw_uwtable, + kw_returns_twice, kw_inlinehint, kw_noinline, Modified: llvm/trunk/lib/Target/CppBackend/CPPBackend.cpp URL: http://llvm.org/viewvc/llvm-project/llvm/trunk/lib/Target/CppBackend/CPPBackend.cpp?rev=141001&r1=141000&r2=141001&view=diff ============================================================================== --- llvm/trunk/lib/Target/CppBackend/CPPBackend.cpp (original) +++ llvm/trunk/lib/Target/CppBackend/CPPBackend.cpp Mon Oct 3 09:45:37 2011 @@ -470,7 +470,7 @@ HANDLE_ATTR(NoImplicitFloat); HANDLE_ATTR(Naked); HANDLE_ATTR(InlineHint); - HANDLE_ATTR(Hotpatch); + HANDLE_ATTR(ReturnsTwice); HANDLE_ATTR(UWTable); HANDLE_ATTR(NonLazyBind); #undef HANDLE_ATTR Modified: llvm/trunk/lib/VMCore/Attributes.cpp URL: http://llvm.org/viewvc/llvm-project/llvm/trunk/lib/VMCore/Attributes.cpp?rev=141001&r1=141000&r2=141001&view=diff ============================================================================== --- llvm/trunk/lib/VMCore/Attributes.cpp (original) +++ llvm/trunk/lib/VMCore/Attributes.cpp Mon Oct 3 09:45:37 2011 @@ -38,6 +38,8 @@ Result += "nounwind "; if (Attrs & Attribute::UWTable) Result += "uwtable "; + if (Attrs & Attribute::ReturnsTwice) + Result += "returns_twice "; if (Attrs & Attribute::InReg) Result += "inreg "; if (Attrs & Attribute::NoAlias) @@ -72,8 +74,6 @@ Result += "noimplicitfloat "; if (Attrs & Attribute::Naked) Result += "naked "; - if (Attrs & Attribute::Hotpatch) - Result += "hotpatch "; if (Attrs & Attribute::NonLazyBind) Result += "nonlazybind "; if (Attrs & Attribute::StackAlignment) { Modified: llvm/trunk/test/Transforms/Mem2Reg/2007-08-27-VolatileLoadsStores.ll URL: http://llvm.org/viewvc/llvm-project/llvm/trunk/test/Transforms/Mem2Reg/2007-08-27-VolatileLoadsStores.ll?rev=141001&r1=141000&r2=141001&view=diff ============================================================================== --- llvm/trunk/test/Transforms/Mem2Reg/2007-08-27-VolatileLoadsStores.ll (original) +++ llvm/trunk/test/Transforms/Mem2Reg/2007-08-27-VolatileLoadsStores.ll Mon Oct 3 09:45:37 2011 @@ -42,6 +42,6 @@ ret i32 %retval8 } -declare i32 @_setjmp(%struct.__jmp_buf_tag*) +declare i32 @_setjmp(%struct.__jmp_buf_tag*) returns_twice declare void @g() Modified: llvm/trunk/test/Transforms/TailCallElim/setjmp.ll URL: http://llvm.org/viewvc/llvm-project/llvm/trunk/test/Transforms/TailCallElim/setjmp.ll?rev=141001&r1=141000&r2=141001&view=diff ============================================================================== --- llvm/trunk/test/Transforms/TailCallElim/setjmp.ll (original) +++ llvm/trunk/test/Transforms/TailCallElim/setjmp.ll Mon Oct 3 09:45:37 2011 @@ -11,6 +11,6 @@ ret void } -declare i32 @setjmp(i32*) +declare i32 @setjmp(i32*) returns_twice declare void @bar() From edwintorok at gmail.com Mon Oct 3 10:04:13 2011 From: edwintorok at gmail.com (=?ISO-8859-1?Q?T=F6r=F6k_Edwin?=) Date: Mon, 03 Oct 2011 18:04:13 +0300 Subject: [llvm-commits] [llvm] r141001 - in /llvm/trunk: docs/LangRef.html include/llvm/Attributes.h lib/AsmParser/LLLexer.cpp lib/AsmParser/LLParser.cpp lib/AsmParser/LLToken.h lib/Target/CppBackend/CPPBackend.cpp lib/VMCore/Attributes.cpp test/Transforms/Mem2Reg/2007-08-27-VolatileLoadsStores.ll test/Transforms/TailCallElim/setjmp.ll In-Reply-To: <20111003144541.503492A6C12C@llvm.org> References: <20111003144541.503492A6C12C@llvm.org> Message-ID: <4E89CEED.6010207@gmail.com> On 10/03/2011 05:45 PM, Rafael Espindola wrote: > Author: rafael > Date: Mon Oct 3 09:45:37 2011 > New Revision: 141001 > > URL: http://llvm.org/viewvc/llvm-project?rev=141001&view=rev > Log: > Add the returns_twice attribute to LLVM. > > Modified: > llvm/trunk/docs/LangRef.html > llvm/trunk/include/llvm/Attributes.h > llvm/trunk/lib/AsmParser/LLLexer.cpp > llvm/trunk/lib/AsmParser/LLParser.cpp > llvm/trunk/lib/AsmParser/LLToken.h > llvm/trunk/lib/Target/CppBackend/CPPBackend.cpp > llvm/trunk/lib/VMCore/Attributes.cpp > llvm/trunk/test/Transforms/Mem2Reg/2007-08-27-VolatileLoadsStores.ll > llvm/trunk/test/Transforms/TailCallElim/setjmp.ll > > Modified: llvm/trunk/docs/LangRef.html > URL: http://llvm.org/viewvc/llvm-project/llvm/trunk/docs/LangRef.html?rev=141001&r1=141000&r2=141001&view=diff > ============================================================================== > --- llvm/trunk/docs/LangRef.html (original) > +++ llvm/trunk/docs/LangRef.html Mon Oct 3 09:45:37 2011 > @@ -1262,6 +1262,11 @@ > the ELF x86-64 abi, but it can be disabled for some compilation > units. > > +
returns_twice
> +
This attribute indicates that this function can return > + twice. The C setjmp is an example of such a function. > + The compiler disables some optimizations (like tail calls) in the caller of > + these functions.
> > > > > Modified: llvm/trunk/include/llvm/Attributes.h > URL: http://llvm.org/viewvc/llvm-project/llvm/trunk/include/llvm/Attributes.h?rev=141001&r1=141000&r2=141001&view=diff > ============================================================================== > --- llvm/trunk/include/llvm/Attributes.h (original) > +++ llvm/trunk/include/llvm/Attributes.h Mon Oct 3 09:45:37 2011 > @@ -65,8 +65,7 @@ > ///of alignment with +1 bias > ///0 means unaligned (different from > ///alignstack(1)) > -const Attributes Hotpatch = 1<<29; ///< Function should have special > - ///'hotpatch' sequence in prologue > +const Attributes ReturnsTwice = 1<<29; ///< Function can return twice LangRef still refers to the hotpatch attribute, if you intend to drop it you should probably remove it from there as well. Did we run out of bits for attributes? Best regards, --Edwin From echristo at apple.com Mon Oct 3 10:44:54 2011 From: echristo at apple.com (Eric Christopher) Date: Mon, 03 Oct 2011 08:44:54 -0700 Subject: [llvm-commits] [llvm] r140924 - in /llvm/trunk/lib/Target/ARM: ARMBaseRegisterInfo.cpp ARMFrameLowering.cpp Thumb1FrameLowering.cpp In-Reply-To: <20111001020318.A290E2A6C12C@llvm.org> References: <20111001020318.A290E2A6C12C@llvm.org> Message-ID: On Sep 30, 2011, at 7:03 PM, Chad Rosier wrote: > Attempt to fix dynamic stack realignment for thumb1 functions. It is in fact > useful if an optimization assumes the stack has been realigned. Credit to > Eli for his assistance. > rdar://10043857 Testcase? -eric -------------- next part -------------- An HTML attachment was scrubbed... URL: http://lists.cs.uiuc.edu/pipermail/llvm-commits/attachments/20111003/4b668b2b/attachment.html From echristo at apple.com Mon Oct 3 10:49:20 2011 From: echristo at apple.com (Eric Christopher) Date: Mon, 03 Oct 2011 15:49:20 -0000 Subject: [llvm-commits] [llvm] r141005 - /llvm/trunk/lib/CodeGen/AsmPrinter/DwarfCompileUnit.cpp Message-ID: <20111003154920.A04F22A6C12D@llvm.org> Author: echristo Date: Mon Oct 3 10:49:20 2011 New Revision: 141005 URL: http://llvm.org/viewvc/llvm-project?rev=141005&view=rev Log: Whitespace. Modified: llvm/trunk/lib/CodeGen/AsmPrinter/DwarfCompileUnit.cpp Modified: llvm/trunk/lib/CodeGen/AsmPrinter/DwarfCompileUnit.cpp URL: http://llvm.org/viewvc/llvm-project/llvm/trunk/lib/CodeGen/AsmPrinter/DwarfCompileUnit.cpp?rev=141005&r1=141004&r2=141005&view=diff ============================================================================== --- llvm/trunk/lib/CodeGen/AsmPrinter/DwarfCompileUnit.cpp (original) +++ llvm/trunk/lib/CodeGen/AsmPrinter/DwarfCompileUnit.cpp Mon Oct 3 10:49:20 2011 @@ -1236,7 +1236,7 @@ return VariableDie; } - // Check if variable is described by a DBG_VALUE instruction. + // Check if variable is described by a DBG_VALUE instruction. if (const MachineInstr *DVInsn = DV->getMInsn()) { bool updated = false; if (DVInsn->getNumOperands() == 3) { From echristo at apple.com Mon Oct 3 10:49:16 2011 From: echristo at apple.com (Eric Christopher) Date: Mon, 03 Oct 2011 15:49:16 -0000 Subject: [llvm-commits] [llvm] r141004 - /llvm/trunk/lib/CodeGen/AsmPrinter/DwarfDebug.cpp Message-ID: <20111003154917.E17422A6C12C@llvm.org> Author: echristo Date: Mon Oct 3 10:49:16 2011 New Revision: 141004 URL: http://llvm.org/viewvc/llvm-project?rev=141004&view=rev Log: Typo. Modified: llvm/trunk/lib/CodeGen/AsmPrinter/DwarfDebug.cpp Modified: llvm/trunk/lib/CodeGen/AsmPrinter/DwarfDebug.cpp URL: http://llvm.org/viewvc/llvm-project/llvm/trunk/lib/CodeGen/AsmPrinter/DwarfDebug.cpp?rev=141004&r1=141003&r2=141004&view=diff ============================================================================== --- llvm/trunk/lib/CodeGen/AsmPrinter/DwarfDebug.cpp (original) +++ llvm/trunk/lib/CodeGen/AsmPrinter/DwarfDebug.cpp Mon Oct 3 10:49:16 2011 @@ -386,7 +386,7 @@ TheCU->constructVariableDIE(ArgDV, Scope->isAbstractScope())) Children.push_back(Arg); - // Collect lexical scope childrens first. + // Collect lexical scope children first. const SmallVector &Variables = ScopeVariables.lookup(Scope); for (unsigned i = 0, N = Variables.size(); i < N; ++i) if (DIE *Variable = From echristo at apple.com Mon Oct 3 11:40:47 2011 From: echristo at apple.com (Eric Christopher) Date: Mon, 03 Oct 2011 09:40:47 -0700 Subject: [llvm-commits] [llvm] r140924 - in /llvm/trunk/lib/Target/ARM: ARMBaseRegisterInfo.cpp ARMFrameLowering.cpp Thumb1FrameLowering.cpp In-Reply-To: References: <20111001020318.A290E2A6C12C@llvm.org> Message-ID: <12BB28DC-68E0-4577-A6A1-9332A6021CF7@apple.com> On Oct 3, 2011, at 8:44 AM, Eric Christopher wrote: > > On Sep 30, 2011, at 7:03 PM, Chad Rosier wrote: > >> Attempt to fix dynamic stack realignment for thumb1 functions. It is in fact >> useful if an optimization assumes the stack has been realigned. Credit to >> Eli for his assistance. >> rdar://10043857 > > Testcase? Nevermind, I saw you pulled it back out. Might want a test case when you recommit though :) -eric -------------- next part -------------- An HTML attachment was scrubbed... URL: http://lists.cs.uiuc.edu/pipermail/llvm-commits/attachments/20111003/ba227502/attachment.html From mcrosier at apple.com Mon Oct 3 11:43:35 2011 From: mcrosier at apple.com (Chad Rosier) Date: Mon, 03 Oct 2011 09:43:35 -0700 Subject: [llvm-commits] [llvm] r140924 - in /llvm/trunk/lib/Target/ARM: ARMBaseRegisterInfo.cpp ARMFrameLowering.cpp Thumb1FrameLowering.cpp In-Reply-To: <12BB28DC-68E0-4577-A6A1-9332A6021CF7@apple.com> References: <20111001020318.A290E2A6C12C@llvm.org> <12BB28DC-68E0-4577-A6A1-9332A6021CF7@apple.com> Message-ID: On Oct 3, 2011, at 9:40 AM, Eric Christopher wrote: > > On Oct 3, 2011, at 8:44 AM, Eric Christopher wrote: > >> >> On Sep 30, 2011, at 7:03 PM, Chad Rosier wrote: >> >>> Attempt to fix dynamic stack realignment for thumb1 functions. It is in fact >>> useful if an optimization assumes the stack has been realigned. Credit to >>> Eli for his assistance. >>> rdar://10043857 >> >> Testcase? > > Nevermind, I saw you pulled it back out. Might want a test case when you recommit though :) I will make sure to include one. Chad > -eric > -------------- next part -------------- An HTML attachment was scrubbed... URL: http://lists.cs.uiuc.edu/pipermail/llvm-commits/attachments/20111003/eef1e6ae/attachment.html From stoklund at 2pi.dk Mon Oct 3 11:50:42 2011 From: stoklund at 2pi.dk (Jakob Stoklund Olesen) Date: Mon, 03 Oct 2011 09:50:42 -0700 Subject: [llvm-commits] patch: chrec * chrec = chrec. In-Reply-To: <4E88F8E3.3050506@mxc.ca> References: <4E88F8E3.3050506@mxc.ca> Message-ID: <7AD2AE23-DD82-4D4E-A75B-FCB290144F4D@2pi.dk> On Oct 2, 2011, at 4:50 PM, Nick Lewycky wrote: > This patch is a follow-up to r139133 which corrected SCEV's getMulExpr when given two chrec arguments. Here I extend it to correctly multiply chrecs of any length. Hi Nick, I can't really comment on the SCEV stuff, but +static unsigned Choose(unsigned n, unsigned k, bool &Overflow) { + // This method can overflow internally even if the final result would fit. + + if (n == 0) return 1; + if (k >= n) return 1; + + if (k > n/2) + k = n-k; + + unsigned r = 1; + for (unsigned i = 1; i <= k; ++i) { + r = umul_ov(r, n-(i-1), Overflow); + r /= i; + } + return r; +} Please add a comment that this function is computing a binomial coefficient, and how it does it. In particular, it wasn't immediately clear to me that the division never truncates. Are binomial coefficients defined for k > n? If so, shouldn't the value be 0? + const SCEV *CoeffTerm = getConstant(Ty, Coeff1*Coeff2); Can this multiplication overflow? Finally, your x,y,z loop is O(N^4) in the number of SCEV operands. I don't know if this is a problem in practice. The Choose() calls in that loop are computing the same intermediate results over and over. You could get an O(N^3) computation by reusing those binomials. /jakob From craig.topper at gmail.com Mon Oct 3 12:28:24 2011 From: craig.topper at gmail.com (Craig Topper) Date: Mon, 03 Oct 2011 17:28:24 -0000 Subject: [llvm-commits] [llvm] r141007 - in /llvm/trunk: lib/Target/X86/X86.td lib/Target/X86/X86InstrInfo.td lib/Target/X86/X86InstrSSE.td lib/Target/X86/X86Subtarget.cpp lib/Target/X86/X86Subtarget.h test/MC/Disassembler/X86/simple-tests.txt test/MC/Disassembler/X86/x86-32.txt Message-ID: <20111003172825.485C52A6C12C@llvm.org> Author: ctopper Date: Mon Oct 3 12:28:23 2011 New Revision: 141007 URL: http://llvm.org/viewvc/llvm-project?rev=141007&view=rev Log: Add support for MOVBE and RDRAND instructions for the assembler and disassembler. Includes feature flag checking, but no instrinsic support. Fixes PR10832, PR11026 and PR11027. Modified: llvm/trunk/lib/Target/X86/X86.td llvm/trunk/lib/Target/X86/X86InstrInfo.td llvm/trunk/lib/Target/X86/X86InstrSSE.td llvm/trunk/lib/Target/X86/X86Subtarget.cpp llvm/trunk/lib/Target/X86/X86Subtarget.h llvm/trunk/test/MC/Disassembler/X86/simple-tests.txt llvm/trunk/test/MC/Disassembler/X86/x86-32.txt Modified: llvm/trunk/lib/Target/X86/X86.td URL: http://llvm.org/viewvc/llvm-project/llvm/trunk/lib/Target/X86/X86.td?rev=141007&r1=141006&r2=141007&view=diff ============================================================================== --- llvm/trunk/lib/Target/X86/X86.td (original) +++ llvm/trunk/lib/Target/X86/X86.td Mon Oct 3 12:28:23 2011 @@ -96,6 +96,10 @@ "Allow unaligned memory operands on vector/SIMD instructions">; def FeatureAES : SubtargetFeature<"aes", "HasAES", "true", "Enable AES instructions">; +def FeatureMOVBE : SubtargetFeature<"movbe", "HasMOVBE", "true", + "Support MOVBE instruction">; +def FeatureRDRAND : SubtargetFeature<"rdrand", "HasRDRAND", "true", + "Support RDRAND instruction">; //===----------------------------------------------------------------------===// // X86 processors supported. Modified: llvm/trunk/lib/Target/X86/X86InstrInfo.td URL: http://llvm.org/viewvc/llvm-project/llvm/trunk/lib/Target/X86/X86InstrInfo.td?rev=141007&r1=141006&r2=141007&view=diff ============================================================================== --- llvm/trunk/lib/Target/X86/X86InstrInfo.td (original) +++ llvm/trunk/lib/Target/X86/X86InstrInfo.td Mon Oct 3 12:28:23 2011 @@ -473,6 +473,8 @@ def HasCLMUL : Predicate<"Subtarget->hasCLMUL()">; def HasFMA3 : Predicate<"Subtarget->hasFMA3()">; def HasFMA4 : Predicate<"Subtarget->hasFMA4()">; +def HasMOVBE : Predicate<"Subtarget->hasMOVBE()">; +def HasRDRAND : Predicate<"Subtarget->hasRDRAND()">; def FPStackf32 : Predicate<"!Subtarget->hasXMM()">; def FPStackf64 : Predicate<"!Subtarget->hasXMMInt()">; def HasCmpxchg16b: Predicate<"Subtarget->hasCmpxchg16b()">; @@ -1297,6 +1299,36 @@ "arpl\t{$src, $dst|$dst, $src}", []>, Requires<[In32BitMode]>; //===----------------------------------------------------------------------===// +// MOVBE Instructions +// +let Predicates = [HasMOVBE] in { + def MOVBE16rm : I<0xF0, MRMSrcMem, (outs GR16:$dst), (ins i16mem:$src), + "movbe{w}\t{$src, $dst|$dst, $src}", []>, OpSize, T8; + def MOVBE32rm : I<0xF0, MRMSrcMem, (outs GR32:$dst), (ins i32mem:$src), + "movbe{l}\t{$src, $dst|$dst, $src}", []>, T8; + def MOVBE64rm : RI<0xF0, MRMSrcMem, (outs GR64:$dst), (ins i64mem:$src), + "movbe{q}\t{$src, $dst|$dst, $src}", []>, T8; + def MOVBE16mr : I<0xF1, MRMDestMem, (outs), (ins i16mem:$dst, GR16:$src), + "movbe{w}\t{$src, $dst|$dst, $src}", []>, OpSize, T8; + def MOVBE32mr : I<0xF1, MRMDestMem, (outs), (ins i32mem:$dst, GR32:$src), + "movbe{l}\t{$src, $dst|$dst, $src}", []>, T8; + def MOVBE64mr : RI<0xF1, MRMDestMem, (outs), (ins i64mem:$dst, GR64:$src), + "movbe{q}\t{$src, $dst|$dst, $src}", []>, T8; +} + +//===----------------------------------------------------------------------===// +// RDRAND Instruction +// +let Predicates = [HasRDRAND], Defs = [EFLAGS] in { + def RDRAND16r : I<0xC7, MRM6r, (outs GR16:$dst), (ins), + "rdrand{w}\t$dst", []>, OpSize, TB; + def RDRAND32r : I<0xC7, MRM6r, (outs GR32:$dst), (ins), + "rdrand{l}\t$dst", []>, TB; + def RDRAND64r : RI<0xC7, MRM6r, (outs GR64:$dst), (ins), + "rdrand{q}\t$dst", []>, TB; +} + +//===----------------------------------------------------------------------===// // Subsystems. //===----------------------------------------------------------------------===// Modified: llvm/trunk/lib/Target/X86/X86InstrSSE.td URL: http://llvm.org/viewvc/llvm-project/llvm/trunk/lib/Target/X86/X86InstrSSE.td?rev=141007&r1=141006&r2=141007&view=diff ============================================================================== --- llvm/trunk/lib/Target/X86/X86InstrSSE.td (original) +++ llvm/trunk/lib/Target/X86/X86InstrSSE.td Mon Oct 3 12:28:23 2011 @@ -6748,4 +6748,3 @@ def VZEROUPPER : I<0x77, RawFrm, (outs), (ins), "vzeroupper", [(int_x86_avx_vzeroupper)]>, TB, VEX, Requires<[HasAVX]>; } - Modified: llvm/trunk/lib/Target/X86/X86Subtarget.cpp URL: http://llvm.org/viewvc/llvm-project/llvm/trunk/lib/Target/X86/X86Subtarget.cpp?rev=141007&r1=141006&r2=141007&view=diff ============================================================================== --- llvm/trunk/lib/Target/X86/X86Subtarget.cpp (original) +++ llvm/trunk/lib/Target/X86/X86Subtarget.cpp Mon Oct 3 12:28:23 2011 @@ -203,8 +203,10 @@ HasCLMUL = IsIntel && ((ECX >> 1) & 0x1); ToggleFeature(X86::FeatureCLMUL); HasFMA3 = IsIntel && ((ECX >> 12) & 0x1); ToggleFeature(X86::FeatureFMA3); + HasMOVBE = IsIntel && ((ECX >> 22) & 0x1); ToggleFeature(X86::FeatureMOVBE); HasPOPCNT = IsIntel && ((ECX >> 23) & 0x1); ToggleFeature(X86::FeaturePOPCNT); HasAES = IsIntel && ((ECX >> 25) & 0x1); ToggleFeature(X86::FeatureAES); + HasRDRAND = IsIntel && ((ECX >> 30) & 0x1); ToggleFeature(X86::FeatureRDRAND); HasCmpxchg16b = ((ECX >> 13) & 0x1); ToggleFeature(X86::FeatureCMPXCHG16B); if (IsIntel || IsAMD) { @@ -254,6 +256,8 @@ , HasCLMUL(false) , HasFMA3(false) , HasFMA4(false) + , HasMOVBE(false) + , HasRDRAND(false) , IsBTMemSlow(false) , IsUAMemFast(false) , HasVectorUAMem(false) Modified: llvm/trunk/lib/Target/X86/X86Subtarget.h URL: http://llvm.org/viewvc/llvm-project/llvm/trunk/lib/Target/X86/X86Subtarget.h?rev=141007&r1=141006&r2=141007&view=diff ============================================================================== --- llvm/trunk/lib/Target/X86/X86Subtarget.h (original) +++ llvm/trunk/lib/Target/X86/X86Subtarget.h Mon Oct 3 12:28:23 2011 @@ -90,6 +90,12 @@ /// HasFMA4 - Target has 4-operand fused multiply-add bool HasFMA4; + /// HasMOVBE - True if the processor has the MOVBE instruction; + bool HasMOVBE; + + /// HasRDRAND - True if the processor has the RDRAND instruction; + bool HasRDRAND; + /// IsBTMemSlow - True if BT (bit test) of memory instructions are slow. bool IsBTMemSlow; @@ -172,6 +178,8 @@ bool hasCLMUL() const { return HasCLMUL; } bool hasFMA3() const { return HasFMA3; } bool hasFMA4() const { return HasFMA4; } + bool hasMOVBE() const { return HasMOVBE; } + bool hasRDRAND() const { return HasRDRAND; } bool isBTMemSlow() const { return IsBTMemSlow; } bool isUnalignedMemAccessFast() const { return IsUAMemFast; } bool hasVectorUAMem() const { return HasVectorUAMem; } Modified: llvm/trunk/test/MC/Disassembler/X86/simple-tests.txt URL: http://llvm.org/viewvc/llvm-project/llvm/trunk/test/MC/Disassembler/X86/simple-tests.txt?rev=141007&r1=141006&r2=141007&view=diff ============================================================================== --- llvm/trunk/test/MC/Disassembler/X86/simple-tests.txt (original) +++ llvm/trunk/test/MC/Disassembler/X86/simple-tests.txt Mon Oct 3 12:28:23 2011 @@ -368,3 +368,30 @@ # CHECK: vaddps %xmm3, %xmm15, %xmm0 0xc4 0xe1 0x00 0x58 0xc3 + +# CHECK: movbel (%rax), %eax +0x0f 0x38 0xf0 0x00 + +# CHECK: movbel %eax, (%rax) +0x0f 0x38 0xf1 0x00 + +# CHECK: movbew (%rax), %ax +0x66 0x0f 0x38 0xf0 0x00 + +# CHECK: movbew %ax, (%rax) +0x66 0x0f 0x38 0xf1 0x00 + +# CHECK: movbeq (%rax), %rax +0x48 0x0f 0x38 0xf0 0x00 + +# CHECK: movbeq %rax, (%rax) +0x48 0x0f 0x38 0xf1 0x00 + +# CHECK: rdrandw %ax +0x66 0x0f 0xc7 0xf0 + +# CHECK: rdrandl %eax +0x0f 0xc7 0xf0 + +# CHECK: rdrandq %rax +0x48 0x0f 0xc7 0xf0 Modified: llvm/trunk/test/MC/Disassembler/X86/x86-32.txt URL: http://llvm.org/viewvc/llvm-project/llvm/trunk/test/MC/Disassembler/X86/x86-32.txt?rev=141007&r1=141006&r2=141007&view=diff ============================================================================== --- llvm/trunk/test/MC/Disassembler/X86/x86-32.txt (original) +++ llvm/trunk/test/MC/Disassembler/X86/x86-32.txt Mon Oct 3 12:28:23 2011 @@ -387,3 +387,21 @@ # CHECK: vaddps %xmm3, %xmm7, %xmm0 0xc4 0xe1 0x00 0x58 0xc3 + +# CHECK: movbel (%eax), %eax +0x0f 0x38 0xf0 0x00 + +# CHECK: movbel %eax, (%eax) +0x0f 0x38 0xf1 0x00 + +# CHECK: movbew (%eax), %ax +0x66 0x0f 0x38 0xf0 0x00 + +# CHECK: movbew %ax, (%eax) +0x66 0x0f 0x38 0xf1 0x00 + +# CHECK: rdrandw %ax +0x66 0x0f 0xc7 0xf0 + +# CHECK: rdrandl %eax +0x0f 0xc7 0xf0 From clattner at apple.com Mon Oct 3 12:52:00 2011 From: clattner at apple.com (Chris Lattner) Date: Mon, 03 Oct 2011 10:52:00 -0700 Subject: [llvm-commits] [llvm] r140951 - in /llvm/trunk: ./ include/llvm/TableGen/ lib/ lib/TableGen/ utils/TableGen/ In-Reply-To: <20111001164115.E37E82A6C12C@llvm.org> References: <20111001164115.E37E82A6C12C@llvm.org> Message-ID: On Oct 1, 2011, at 9:41 AM, Peter Collingbourne wrote: > Author: pcc > Date: Sat Oct 1 11:41:13 2011 > New Revision: 140951 > > URL: http://llvm.org/viewvc/llvm-project?rev=140951&view=rev > Log: > Move TableGen's parser and entry point into a library > > This is the first step towards splitting LLVM and Clang's tblgen executables. Hi Peter, Thanks for working on this. Doing this right is going to require some work though: 1. All of the 'main' code and the top-level cl::opt's should be in utils/tablegen, not in TableGen/Main.h 2. The tablegen headers (like the rest of it :) are a mess, they are not split properly between public and private headers. 3. The tblgen code uses RTTI and EH, which none of the rest of the LLVM libraries do. So long as RTTI and EH don't invade tools other than the utils/TableGen executable, I'm ok with continuing to forget about #3, but #1 and #2 are pretty important. Are you committed to fixing these problems as follow-ons? What direction are you going here? -Chris From grosbach at apple.com Mon Oct 3 12:59:31 2011 From: grosbach at apple.com (Jim Grosbach) Date: Mon, 03 Oct 2011 17:59:31 -0000 Subject: [llvm-commits] [llvm] r141010 - /llvm/trunk/test/MC/ARM/neon-mov-encoding.s Message-ID: <20111003175931.E6DD22A6C12C@llvm.org> Author: grosbach Date: Mon Oct 3 12:59:31 2011 New Revision: 141010 URL: http://llvm.org/viewvc/llvm-project?rev=141010&view=rev Log: Tidy up a bit. Formatting. Modified: llvm/trunk/test/MC/ARM/neon-mov-encoding.s Modified: llvm/trunk/test/MC/ARM/neon-mov-encoding.s URL: http://llvm.org/viewvc/llvm-project/llvm/trunk/test/MC/ARM/neon-mov-encoding.s?rev=141010&r1=141009&r2=141010&view=diff ============================================================================== --- llvm/trunk/test/MC/ARM/neon-mov-encoding.s (original) +++ llvm/trunk/test/MC/ARM/neon-mov-encoding.s Mon Oct 3 12:59:31 2011 @@ -1,117 +1,131 @@ @ RUN: llvm-mc -mcpu=cortex-a8 -triple arm-unknown-unknown -show-encoding < %s | FileCheck %s @ XFAIL: * -@ CHECK: vmov.i8 d16, #0x8 @ encoding: [0x18,0x0e,0xc0,0xf2] - vmov.i8 d16, #0x8 -@ CHECK: vmov.i16 d16, #0x10 @ encoding: [0x10,0x08,0xc1,0xf2] + vmov.i8 d16, #0x8 vmov.i16 d16, #0x10 -@ CHECK: vmov.i16 d16, #0x1000 @ encoding: [0x10,0x0a,0xc1,0xf2] vmov.i16 d16, #0x1000 -@ CHECK: vmov.i32 d16, #0x20 @ encoding: [0x10,0x00,0xc2,0xf2] vmov.i32 d16, #0x20 -@ CHECK: vmov.i32 d16, #0x2000 @ encoding: [0x10,0x02,0xc2,0xf2] vmov.i32 d16, #0x2000 -@ CHECK: vmov.i32 d16, #0x200000 @ encoding: [0x10,0x04,0xc2,0xf2] vmov.i32 d16, #0x200000 -@ CHECK: vmov.i32 d16, #0x20000000 @ encoding: [0x10,0x06,0xc2,0xf2] vmov.i32 d16, #0x20000000 -@ CHECK: vmov.i32 d16, #0x20FF @ encoding: [0x10,0x0c,0xc2,0xf2] vmov.i32 d16, #0x20FF -@ CHECK: vmov.i32 d16, #0x20FFFF @ encoding: [0x10,0x0d,0xc2,0xf2] vmov.i32 d16, #0x20FFFF -@ CHECK: vmov.i64 d16, #0xFF0000FF0000FFFF @ encoding: [0x33,0x0e,0xc1,0xf3] vmov.i64 d16, #0xFF0000FF0000FFFF -@ CHECK: vmov.i8 q8, #0x8 @ encoding: [0x58,0x0e,0xc0,0xf2] - vmov.i8 q8, #0x8 -@ CHECK: vmov.i16 q8, #0x10 @ encoding: [0x50,0x08,0xc1,0xf2] + +@ CHECK: vmov.i8 d16, #0x8 @ encoding: [0x18,0x0e,0xc0,0xf2] +@ CHECK: vmov.i16 d16, #0x10 @ encoding: [0x10,0x08,0xc1,0xf2] +@ CHECK: vmov.i16 d16, #0x1000 @ encoding: [0x10,0x0a,0xc1,0xf2] +@ CHECK: vmov.i32 d16, #0x20 @ encoding: [0x10,0x00,0xc2,0xf2] +@ CHECK: vmov.i32 d16, #0x2000 @ encoding: [0x10,0x02,0xc2,0xf2] +@ CHECK: vmov.i32 d16, #0x200000 @ encoding: [0x10,0x04,0xc2,0xf2] +@ CHECK: vmov.i32 d16, #0x20000000 @ encoding: [0x10,0x06,0xc2,0xf2] +@ CHECK: vmov.i32 d16, #0x20FF @ encoding: [0x10,0x0c,0xc2,0xf2] +@ CHECK: vmov.i32 d16, #0x20FFFF @ encoding: [0x10,0x0d,0xc2,0xf2] +@ CHECK: vmov.i64 d16, #0xFF0000FF0000FFFF @ encoding: [0x33,0x0e,0xc1,0xf3] + + + + vmov.i8 q8, #0x8 vmov.i16 q8, #0x10 -@ CHECK: vmov.i16 q8, #0x1000 @ encoding: [0x50,0x0a,0xc1,0xf2] vmov.i16 q8, #0x1000 -@ CHECK: vmov.i32 q8, #0x20 @ encoding: [0x50,0x00,0xc2,0xf2] vmov.i32 q8, #0x20 -@ CHECK: vmov.i32 q8, #0x2000 @ encoding: [0x50,0x02,0xc2,0xf2] vmov.i32 q8, #0x2000 -@ CHECK: vmov.i32 q8, #0x200000 @ encoding: [0x50,0x04,0xc2,0xf2] vmov.i32 q8, #0x200000 -@ CHECK: vmov.i32 q8, #0x20000000 @ encoding: [0x50,0x06,0xc2,0xf2] vmov.i32 q8, #0x20000000 -@ CHECK: vmov.i32 q8, #0x20FF @ encoding: [0x50,0x0c,0xc2,0xf2] vmov.i32 q8, #0x20FF -@ CHECK: vmov.i32 q8, #0x20FFFF @ encoding: [0x50,0x0d,0xc2,0xf2] vmov.i32 q8, #0x20FFFF -@ CHECK: vmov.i64 q8, #0xFF0000FF0000FFFF @ encoding: [0x73,0x0e,0xc1,0xf3] vmov.i64 q8, #0xFF0000FF0000FFFF -@ CHECK: vmvn.i16 d16, #0x10 @ encoding: [0x30,0x08,0xc1,0xf2] + +@ CHECK: vmov.i8 q8, #0x8 @ encoding: [0x58,0x0e,0xc0,0xf2] +@ CHECK: vmov.i16 q8, #0x10 @ encoding: [0x50,0x08,0xc1,0xf2] +@ CHECK: vmov.i16 q8, #0x1000 @ encoding: [0x50,0x0a,0xc1,0xf2] +@ CHECK: vmov.i32 q8, #0x20 @ encoding: [0x50,0x00,0xc2,0xf2] +@ CHECK: vmov.i32 q8, #0x2000 @ encoding: [0x50,0x02,0xc2,0xf2] +@ CHECK: vmov.i32 q8, #0x200000 @ encoding: [0x50,0x04,0xc2,0xf2] +@ CHECK: vmov.i32 q8, #0x20000000 @ encoding: [0x50,0x06,0xc2,0xf2] +@ CHECK: vmov.i32 q8, #0x20FF @ encoding: [0x50,0x0c,0xc2,0xf2] +@ CHECK: vmov.i32 q8, #0x20FFFF @ encoding: [0x50,0x0d,0xc2,0xf2] +@ CHECK: vmov.i64 q8, #0xFF0000FF0000FFFF @ encoding: [0x73,0x0e,0xc1,0xf3] + vmvn.i16 d16, #0x10 -@ CHECK: vmvn.i16 d16, #0x1000 @ encoding: [0x30,0x0a,0xc1,0xf2] vmvn.i16 d16, #0x1000 -@ CHECK: vmvn.i32 d16, #0x20 @ encoding: [0x30,0x00,0xc2,0xf2] vmvn.i32 d16, #0x20 -@ CHECK: vmvn.i32 d16, #0x2000 @ encoding: [0x30,0x02,0xc2,0xf2] vmvn.i32 d16, #0x2000 -@ CHECK: vmvn.i32 d16, #0x200000 @ encoding: [0x30,0x04,0xc2,0xf2] vmvn.i32 d16, #0x200000 -@ CHECK: vmvn.i32 d16, #0x20000000 @ encoding: [0x30,0x06,0xc2,0xf2] vmvn.i32 d16, #0x20000000 -@ CHECK: vmvn.i32 d16, #0x20FF @ encoding: [0x30,0x0c,0xc2,0xf2] vmvn.i32 d16, #0x20FF -@ CHECK: vmvn.i32 d16, #0x20FFFF @ encoding: [0x30,0x0d,0xc2,0xf2] vmvn.i32 d16, #0x20FFFF -@ CHECK: vmovl.s8 q8, d16 @ encoding: [0x30,0x0a,0xc8,0xf2] + +@ CHECK: vmvn.i16 d16, #0x10 @ encoding: [0x30,0x08,0xc1,0xf2] +@ CHECK: vmvn.i16 d16, #0x1000 @ encoding: [0x30,0x0a,0xc1,0xf2] +@ CHECK: vmvn.i32 d16, #0x20 @ encoding: [0x30,0x00,0xc2,0xf2] +@ CHECK: vmvn.i32 d16, #0x2000 @ encoding: [0x30,0x02,0xc2,0xf2] +@ CHECK: vmvn.i32 d16, #0x200000 @ encoding: [0x30,0x04,0xc2,0xf2] +@ CHECK: vmvn.i32 d16, #0x20000000 @ encoding: [0x30,0x06,0xc2,0xf2] +@ CHECK: vmvn.i32 d16, #0x20FF @ encoding: [0x30,0x0c,0xc2,0xf2] +@ CHECK: vmvn.i32 d16, #0x20FFFF @ encoding: [0x30,0x0d,0xc2,0xf2] + vmovl.s8 q8, d16 -@ CHECK: vmovl.s16 q8, d16 @ encoding: [0x30,0x0a,0xd0,0xf2] vmovl.s16 q8, d16 -@ CHECK: vmovl.s32 q8, d16 @ encoding: [0x30,0x0a,0xe0,0xf2] vmovl.s32 q8, d16 -@ CHECK: vmovl.u8 q8, d16 @ encoding: [0x30,0x0a,0xc8,0xf3] vmovl.u8 q8, d16 -@ CHECK: vmovl.u16 q8, d16 @ encoding: [0x30,0x0a,0xd0,0xf3] vmovl.u16 q8, d16 -@ CHECK: vmovl.u32 q8, d16 @ encoding: [0x30,0x0a,0xe0,0xf3] vmovl.u32 q8, d16 -@ CHECK: vmovn.i16 d16, q8 @ encoding: [0x20,0x02,0xf2,0xf3] + +@ CHECK: vmovl.s8 q8, d16 @ encoding: [0x30,0x0a,0xc8,0xf2] +@ CHECK: vmovl.s16 q8, d16 @ encoding: [0x30,0x0a,0xd0,0xf2] +@ CHECK: vmovl.s32 q8, d16 @ encoding: [0x30,0x0a,0xe0,0xf2] +@ CHECK: vmovl.u8 q8, d16 @ encoding: [0x30,0x0a,0xc8,0xf3] +@ CHECK: vmovl.u16 q8, d16 @ encoding: [0x30,0x0a,0xd0,0xf3] +@ CHECK: vmovl.u32 q8, d16 @ encoding: [0x30,0x0a,0xe0,0xf3] + + vmovn.i16 d16, q8 -@ CHECK: vmovn.i32 d16, q8 @ encoding: [0x20,0x02,0xf6,0xf3] vmovn.i32 d16, q8 -@ CHECK: vmovn.i64 d16, q8 @ encoding: [0x20,0x02,0xfa,0xf3] vmovn.i64 d16, q8 -@ CHECK: vqmovn.s16 d16, q8 @ encoding: [0xa0,0x02,0xf2,0xf3] vqmovn.s16 d16, q8 -@ CHECK: vqmovn.s32 d16, q8 @ encoding: [0xa0,0x02,0xf6,0xf3] vqmovn.s32 d16, q8 -@ CHECK: vqmovn.s64 d16, q8 @ encoding: [0xa0,0x02,0xfa,0xf3] vqmovn.s64 d16, q8 -@ CHECK: vqmovn.u16 d16, q8 @ encoding: [0xe0,0x02,0xf2,0xf3] vqmovn.u16 d16, q8 -@ CHECK: vqmovn.u32 d16, q8 @ encoding: [0xe0,0x02,0xf6,0xf3] vqmovn.u32 d16, q8 -@ CHECK: vqmovn.u64 d16, q8 @ encoding: [0xe0,0x02,0xfa,0xf3] vqmovn.u64 d16, q8 -@ CHECK: vqmovun.s16 d16, q8 @ encoding: [0x60,0x02,0xf2,0xf3] vqmovun.s16 d16, q8 -@ CHECK: vqmovun.s32 d16, q8 @ encoding: [0x60,0x02,0xf6,0xf3] vqmovun.s32 d16, q8 -@ CHECK: vqmovun.s64 d16, q8 @ encoding: [0x60,0x02,0xfa,0xf3] vqmovun.s64 d16, q8 -@ CHECK: vmov.s8 r0, d16[1] @ encoding: [0xb0,0x0b,0x50,0xee] - vmov.s8 r0, d16[1] -@ CHECK: vmov.s16 r0, d16[1] @ encoding: [0xf0,0x0b,0x10,0xee] + +@ CHECK: vmovn.i16 d16, q8 @ encoding: [0x20,0x02,0xf2,0xf3] +@ CHECK: vmovn.i32 d16, q8 @ encoding: [0x20,0x02,0xf6,0xf3] +@ CHECK: vmovn.i64 d16, q8 @ encoding: [0x20,0x02,0xfa,0xf3] +@ CHECK: vqmovn.s16 d16, q8 @ encoding: [0xa0,0x02,0xf2,0xf3] +@ CHECK: vqmovn.s32 d16, q8 @ encoding: [0xa0,0x02,0xf6,0xf3] +@ CHECK: vqmovn.s64 d16, q8 @ encoding: [0xa0,0x02,0xfa,0xf3] +@ CHECK: vqmovn.u16 d16, q8 @ encoding: [0xe0,0x02,0xf2,0xf3] +@ CHECK: vqmovn.u32 d16, q8 @ encoding: [0xe0,0x02,0xf6,0xf3] +@ CHECK: vqmovn.u64 d16, q8 @ encoding: [0xe0,0x02,0xfa,0xf3] +@ CHECK: vqmovun.s16 d16, q8 @ encoding: [0x60,0x02,0xf2,0xf3] +@ CHECK: vqmovun.s32 d16, q8 @ encoding: [0x60,0x02,0xf6,0xf3] +@ CHECK: vqmovun.s64 d16, q8 @ encoding: [0x60,0x02,0xfa,0xf3] + + vmov.s8 r0, d16[1] vmov.s16 r0, d16[1] -@ CHECK: vmov.u8 r0, d16[1] @ encoding: [0xb0,0x0b,0xd0,0xee] - vmov.u8 r0, d16[1] -@ CHECK: vmov.u16 r0, d16[1] @ encoding: [0xf0,0x0b,0x90,0xee] + vmov.u8 r0, d16[1] vmov.u16 r0, d16[1] -@ CHECK: vmov.32 r0, d16[1] @ encoding: [0x90,0x0b,0x30,0xee] - vmov.32 r0, d16[1] -@ CHECK: vmov.8 d16[1], r1 @ encoding: [0xb0,0x1b,0x40,0xee] + vmov.32 r0, d16[1] vmov.8 d16[1], r1 -@ CHECK: vmov.16 d16[1], r1 @ encoding: [0xf0,0x1b,0x00,0xee] vmov.16 d16[1], r1 -@ CHECK: vmov.32 d16[1], r1 @ encoding: [0x90,0x1b,0x20,0xee] vmov.32 d16[1], r1 -@ CHECK: vmov.8 d18[1], r1 @ encoding: [0xb0,0x1b,0x42,0xee] vmov.8 d18[1], r1 -@ CHECK: vmov.16 d18[1], r1 @ encoding: [0xf0,0x1b,0x02,0xee] vmov.16 d18[1], r1 -@ CHECK: vmov.32 d18[1], r1 @ encoding: [0x90,0x1b,0x22,0xee] vmov.32 d18[1], r1 + +@ CHECK: vmov.s8 r0, d16[1] @ encoding: [0xb0,0x0b,0x50,0xee] +@ CHECK: vmov.s16 r0, d16[1] @ encoding: [0xf0,0x0b,0x10,0xee] +@ CHECK: vmov.u8 r0, d16[1] @ encoding: [0xb0,0x0b,0xd0,0xee] +@ CHECK: vmov.u16 r0, d16[1] @ encoding: [0xf0,0x0b,0x90,0xee] +@ CHECK: vmov.32 r0, d16[1] @ encoding: [0x90,0x0b,0x30,0xee] +@ CHECK: vmov.8 d16[1], r1 @ encoding: [0xb0,0x1b,0x40,0xee] +@ CHECK: vmov.16 d16[1], r1 @ encoding: [0xf0,0x1b,0x00,0xee] +@ CHECK: vmov.32 d16[1], r1 @ encoding: [0x90,0x1b,0x20,0xee] +@ CHECK: vmov.8 d18[1], r1 @ encoding: [0xb0,0x1b,0x42,0xee] +@ CHECK: vmov.16 d18[1], r1 @ encoding: [0xf0,0x1b,0x02,0xee] +@ CHECK: vmov.32 d18[1], r1 @ encoding: [0x90,0x1b,0x22,0xee] From cdavis at mymail.mines.edu Mon Oct 3 13:22:54 2011 From: cdavis at mymail.mines.edu (Charles Davis) Date: Mon, 3 Oct 2011 12:22:54 -0600 Subject: [llvm-commits] [llvm] r141001 - in /llvm/trunk: docs/LangRef.html include/llvm/Attributes.h lib/AsmParser/LLLexer.cpp lib/AsmParser/LLParser.cpp lib/AsmParser/LLToken.h lib/Target/CppBackend/CPPBackend.cpp lib/VMCore/Attributes.cpp test/Transforms/Mem2Reg/2007-08-27-VolatileLoadsStores.ll test/Transforms/TailCallElim/setjmp.ll In-Reply-To: <4E89CEED.6010207@gmail.com> References: <20111003144541.503492A6C12C@llvm.org> <4E89CEED.6010207@gmail.com> Message-ID: <30C532CC-0907-4DAB-8D06-2D826955D2E7@mymail.mines.edu> On Oct 3, 2011, at 9:04 AM, T?r?k Edwin wrote: > Did we run out of bits for attributes? Yes, we did (cf. thread "Function attribute size limit" on LLVMdev). > > Best regards, > --Edwin > _______________________________________________ > llvm-commits mailing list > llvm-commits at cs.uiuc.edu > http://lists.cs.uiuc.edu/mailman/listinfo/llvm-commits From apazos at codeaurora.org Mon Oct 3 13:31:24 2011 From: apazos at codeaurora.org (Ana Pazos) Date: Mon, 3 Oct 2011 11:31:24 -0700 Subject: [llvm-commits] LLVM patch to optimize integer ABS idiom for ARM target In-Reply-To: References: <000b01cc7408$25f9a5a0$71ecf0e0$@org> <000f01cc74d5$b9edd790$2dc986b0$@org> <659E20BB-A99D-43CD-BE21-D5AC8C71834F@apple.com> <000001cc7d7a$328a7a80$979f6f80$@org> <94F98DFD-CEA6-41E1-84EB-FAC72B292492@apple.com> <016e01cc7ec9$6c4550b0$44cff210$@org> Message-ID: <006601cc81fa$a7d59020$f780b060$@org> Attached is the updated iabs.ll test patch for ARM and Thumb to match the new codegen. Thanks! Ana. From: Evan Cheng [mailto:evan.cheng at apple.com] Sent: Friday, September 30, 2011 9:44 PM To: Ana Pazos Cc: llvm-commits at cs.uiuc.edu; rajav at codeaurora.org; apazos at codeaurora.org Subject: Re: [llvm-commits] LLVM patch to optimize integer ABS idiom for ARM target The patch looks fine to me. But please update the failing tests to match the new codegen. Feel free to get it committed after the update. Evan On Sep 29, 2011, at 10:01 AM, Ana Pazos wrote: Hi folks, Find attached the updated patch that optimizes integer ABS idiom for the ARM target. Let me know what you think. Thank you! Ana. From: Evan Cheng [mailto:evan.cheng at apple.com] Sent: Wednesday, September 28, 2011 5:20 PM To: Ana Pazos Cc: 'Eli Friedman'; rajav at codeaurora.org Subject: Re: [llvm-commits] LLVM patch to optimize integer ABS idiom for ARM target Hi Ana, The patch looks much cleaner. There are some minor stylistic issues though: + BuildMI(*SinkBB, SinkBB->begin(), dl, + TII->get(ARM::PHI), ABSDstReg) + .addReg(NewRsbDstReg).addMBB(RSBBB) + .addReg(NewMovDstReg).addMBB(BB); Indentation. + if (DisableARMIntABS){ + return NULL; + } Please make sure there is a space before '{'. Also note in general LLVM code doesn't use { } for single statement if - else clauses. Please send the patch to llvm-commits for larger audience. Thanks. Evan On Sep 27, 2011, at 6:01 PM, Ana Pazos wrote: Hello Evan, I have updated the patch following your comments 1-4 and suggestions 1-2. I have defined separate ARM ABS and t2ABS nodes and have moved the lowering of these nodes (to movs + rsbmi machine instructions) to pre-RA scheduling time. The updated patch only modifies ARM target-dependent files. The "bonuses" features imply changes to LLVM target-independent code which I am not able to address right away. I have also rerun the llvm/test and llvm/projects/test-suite tests and the results are attached. Please let me know what you think and if further changes are needed. Note: - The DAGCombiner lowers SELECT_CC as ASR/ADD/XOR instruction BEFORE each target has a chance to choose its preferred idiom. The code change in ARMISelDAGToDAG.cpp is to convert ASR/ADD/XOR representing integer ABS into an ARM ABS/t2ABS node. This was done to avoid changing LLVM target-independent code. - ABS nodes take a source operand and a destination operand (V1 = ABS V0). The comparison against 0 and the predicated computation of the absolute value are implicit in the node. That is why the ABS nodes are declared as defining CPSR. Thanks a lot! Ana. From: Evan Cheng [mailto:evan.cheng at apple.com] Sent: Sunday, September 18, 2011 11:22 AM To: Ana Pazos Cc: rajav at codeaurora.org Subject: Re: [llvm-commits] LLVM patch to optimize integer ABS idiom for ARM target On Sep 16, 2011, at 6:04 PM, Ana Pazos wrote: Hi Evan, Thanks for the great feedback. I think I can immediately improve the patch by addressing your points 1-4 and suggestions 1-2 and deliver these changes soon. The ?bonuses? suggestions imply changes to LLVM target-independent code which I might not be able to address right away. Would this plan be ok with you? Yes. Thanks. Please see my comments below. Talk to you again soon! Thanks a lot, Ana. From: Evan Cheng [mailto:evan.cheng at apple.com] Sent: Friday, September 16, 2011 11:32 AM To: Ana Pazos Cc: Commit Messages and Patches for LLVM Subject: Re: [llvm-commits] LLVM patch to optimize integer ABS idiom for ARM target Hi Ana, Thanks for working on this. It does look like an important peephole optimization. Unfortunately I think this patch has some problems. 1. The instruction selection pattern is looking for a very specific case. Does it still work if the source is not a function argument? For example, if it's the return value of a function call, or a result of a computation, I don't think it will work with this patch. [apazos] Yes, it still works if the source is not a function argument. Maybe the test case confused you. The ASR/ADD/XOR pattern that implements integer ABS is searched for in the DAG and can happen in any place in the function code. Once it is found, it is replaced with the pseudoABS node using as source operand the ADD instruction first source operand (which is the same as SRA instruction first source operand). Later when pseudoABS node is lowered, it becomes movs/conditional rsbmi using as source and destination register the pseudoABS instruction destination register. So there is nothing in the patch that restricts the operand to be ?r0?. Ok. I'm just concerned about looking for specific patterns could be fragile which is why I suggest adding a ABS isel opcode. 2. MOVrs and RSBccri are not needed. You can expand into MOVr with the optional def set to CPSR and a RSBri with the predicate operand filled in. [apazos] Probably my inexperience with *.td file definitions. I will find out how to use the existing MOVr and RSBri instruction definitions. Ok. 3. We want to avoid pseudo instructions that expands into multiple instructions. As you have noticed, this messes up scheduling. Probably the right solution is to expand the instructions at pre-RA scheduling time. [apazos] I understand why you want to avoid pseudo instructions that expand into multiple instructions. It was my concern too. I have a version of the patch that implements the optimization at pre-RA scheduling time. For that, I had to add a PHI node in the DAG (to be able to add the conditional execution path that computes RSB). The problem with this alternative solution is that LLVM decided to spill both input operands to the PHI nodes, and the final code was very inefficient. I was not using the latest LLVM source code. I will try this solution again with the LLVM svn tip. Will let you know if I see the problem again. Ok. 4. It's a bad idea to have a single instruction that's used for both ARM and Thumb2 mode. [apazos] There is nothing special we need to do handle Thumb2 mode. I built EEMBC benchmarks in Thumb2 mode and the ABS optimization worked just fine. Note that in Thumb2 mode conditional execution is implemented with IT instructions. There is no need to explicitly write IT instructions though. The assembler/code emitter inserts it for you where necessary changing the pattern movs rsbmi into movs itmi rsbmi. So I am not sure we need t2ABSri type of node. You still need pseudo nodes for ARM and Thumb2. We do not allow two modes to share an opcode. My suggestion: 1. ISel should match to an instruction (say ABS, t2ABSri) that's marked with usesCustomInserter = 1. 2. Add support to lower ABS to MOVr and RSBri with optional def and predicate operands filled in. Please do the same for the Thumb2 variant. [apazos] I think I understood what you meant. Let me give it a try. Bonuses: 1. Is this sufficient to generate the best code sequence? e.g. movs r0, r0 rsbmi r0, r0, #0 This is the best if r0 is a function input. But how about? add r0, r1 movs r0, r0 rsbmi r0, r0, #0 Shouldn't we copy propagate the movs? adds r0, r1 rsbmi r0, r0, #0 One possibility is the scheduler custom expansion code look for the instruction that defines the source and tack the optional def on that instruction. Any other ideas? 2. How to make the instruction selection code match more cases? My suggestion is to add a new target independent opcode ABS. For targets where this node is legal, i.e. ARM, dag combine can form this instruction rather than the sra + sub sequence. This way, you can write a simple pattern to match the instruction instead of C++ selection code. [apazos] So instead of ARM/Thumb-specific DAG nodes create a new target independent ABS DAG node? SELECT_CC DAG nodes that represent integer ABS patterns are transformed into target independent ABS DAG nodes. And then ARM/Thumb target lowers it as movs/rsbmi and the other targets lower it as sra + add + xor sequence. No, other targets will not generate ABS dag nodes since it will not be legal. The problem with this solution is that it will imply changes to target-independent LLVM code. In my current solution I strived to not change any target-independent LLVM code. I believe this is a less fragile solution. [apazos] Let me give more thought to the 2 bonuses suggestions above. [apazos] But immediately I can address the other points. Ok. Thanks. Evan Evan On Sep 15, 2011, at 5:32 PM, Ana Pazos wrote: Hello, I worked on an LLVM patch to optimize integer ABS idiom for the ARM target and would like to submit it to your review. I experimented with EEMBC benchmarks, in particular MPEG encoding, and noted integer ABS computation happens frequently. Significant speed up was achieved with the optimized idiom for ARM (20% for MPEG encoding). Patch details: LLVM lowers SELECT_CC nodes that represent an integer ABS pattern into ASR/ADD/XOR instructions. It is possible to create an optimized machine idiom for integer ABS on ARM formed by MOVs/RSBmi predicated instructions. This patch modifies ARM-specific files to implement the above optimized machine idiom for integer ABS. Generation of the optimized integer ABS idiom is turned on by default. To turn this feature off set -disable-arm-int-abs feature flag. abspatch.diff Changes to ARM-specific files to implement optimized integer ABS idiom. abstestpatch.diff ARM/iabs.ll and Thumb/iabs.ll tests check for the non-optimized integer ABS idiom (ASR/ADD/XOR). When applying abspatch.diff these tests fail. So patched the tests to set -disable-arm-int-abs flag to prevent the compiler from generating optimized integer ABS pattern and allow the non-optimized idiom to be checked. iabsopt.ll Similar to ARM/iabs.ll and Thumb/iabs.ll tests except that it checks for the optimized integer ABS idiom and checks for all possible test conditions. failures.txt Failure report and explanation from running llvm/test and projects/test-suite on ARM. I noted failures running llvm/test (svn version 139318) and projects/test-suite (svn revision 139319) on ARM. Are these failures expected? Thank you, Ana. _______________________________________________ llvm-commits mailing list llvm-commits at cs.uiuc.edu http://lists.cs.uiuc.edu/mailman/listinfo/llvm-commits -------------- next part -------------- An HTML attachment was scrubbed... URL: http://lists.cs.uiuc.edu/pipermail/llvm-commits/attachments/20111003/dc8aceef/attachment-0001.html -------------- next part -------------- A non-text attachment was scrubbed... Name: abstestpatch.diff Type: application/octet-stream Size: 1429 bytes Desc: not available Url : http://lists.cs.uiuc.edu/pipermail/llvm-commits/attachments/20111003/dc8aceef/attachment-0001.obj From bob.wilson at apple.com Mon Oct 3 13:48:17 2011 From: bob.wilson at apple.com (Bob Wilson) Date: Mon, 03 Oct 2011 18:48:17 -0000 Subject: [llvm-commits] [llvm] r141013 - /llvm/trunk/utils/buildit/build_llvm Message-ID: <20111003184817.6C32C2A6C12C@llvm.org> Author: bwilson Date: Mon Oct 3 13:48:16 2011 New Revision: 141013 URL: http://llvm.org/viewvc/llvm-project?rev=141013&view=rev Log: Find the strip tool that works with the specified SDKROOT. rdar://10165908 Modified: llvm/trunk/utils/buildit/build_llvm Modified: llvm/trunk/utils/buildit/build_llvm URL: http://llvm.org/viewvc/llvm-project/llvm/trunk/utils/buildit/build_llvm?rev=141013&r1=141012&r2=141013&view=diff ============================================================================== --- llvm/trunk/utils/buildit/build_llvm (original) +++ llvm/trunk/utils/buildit/build_llvm Mon Oct 3 13:48:16 2011 @@ -201,14 +201,20 @@ echo "#define LLVM_VERSION ${RC_ProjectSourceVersion}" > $DEST_DIR$DEST_ROOT/include/llvm/Version.h echo "#define LLVM_MINOR_VERSION ${RC_ProjectSourceSubversion}" >> $DEST_DIR$DEST_ROOT/include/llvm/Version.h +# Find the right version of strip to use. +STRIP=strip +if [ -n "$SDKROOT" ]; then + STRIP=`xcrun -sdk $SDKROOT -find strip` +fi + if [ "x$LLVM_DEBUG" != "x1" ]; then # Strip local symbols from llvm libraries. # # Use '-l' to strip i386 modules. N.B. that flag doesn't work with kext or # PPC objects! - strip -Sl $DEST_DIR$DEST_ROOT/lib/*.[oa] + $STRIP -Sl $DEST_DIR$DEST_ROOT/lib/*.[oa] for f in `ls $DEST_DIR$DEST_ROOT/lib/*.so`; do - strip -Sxl $f + $STRIP -Sxl $f done fi @@ -297,7 +303,7 @@ # Use '-l' to strip i386 modules. N.B. that flag doesn't work with kext or # PPC objects! - strip -arch all -Sl $DT_HOME/lib/libLTO.dylib + $STRIP -arch all -Sl $DT_HOME/lib/libLTO.dylib if [ "x$DISABLE_USR_LINKS" == "x" ]; then # Add a symlink in /usr/lib for B&I. @@ -327,7 +333,7 @@ # PPC objects! find $DEST_DIR -perm -0111 -type f \ ! \( -name '*.la' -o -name gccas -o -name gccld -o -name llvm-config \) \ - -print | xargs -n 1 -P ${SYSCTL} strip -arch all -Sl + -print | xargs -n 1 -P ${SYSCTL} $STRIP -arch all -Sl chgrp -h -R wheel $DEST_DIR chgrp -R wheel $DEST_DIR From dnicacios at gmail.com Mon Oct 3 14:23:34 2011 From: dnicacios at gmail.com (=?ISO-8859-1?Q?Daniel_Nic=E1cio?=) Date: Mon, 3 Oct 2011 12:23:34 -0700 Subject: [llvm-commits] [patch] ThreeStageLoopUnroll In-Reply-To: <72EBDCAC-85C1-48EC-91FA-500022E126F1@apple.com> References: <36610B20-AAAC-4A37-88EF-DAE333CFA740@apple.com> <72EBDCAC-85C1-48EC-91FA-500022E126F1@apple.com> Message-ID: Thanks for the reply guys, I will fix what you pointed out. And I will work on it to improve it further. On Tue, Sep 27, 2011 at 2:55 PM, Devang Patel wrote: > > On Sep 27, 2011, at 2:48 PM, David Blaikie wrote: > > 2) General llvm convention is to avoid >> >> + bool candidate = L->isThreeStageUnrollCandidate(L, LI); >> + if(candidate) { >> ?. >> >> and do >> >> + if (bool candidate = ? ) { >> + } >> >> if candidate is not used outside "if". >> > > At that point you might as well just write: > > if (L->isThreeStageUnrollCandidate(L, LI)) { > } > > > Yes, if candidate is not used inside "if". > - > Devang > -------------- next part -------------- An HTML attachment was scrubbed... URL: http://lists.cs.uiuc.edu/pipermail/llvm-commits/attachments/20111003/7dcab735/attachment.html From ahatanaka at mips.com Mon Oct 3 14:28:50 2011 From: ahatanaka at mips.com (Akira Hatanaka) Date: Mon, 03 Oct 2011 19:28:50 -0000 Subject: [llvm-commits] [llvm] r141015 - in /llvm/trunk/lib/Target/Mips: Mips64InstrInfo.td MipsInstrInfo.td Message-ID: <20111003192850.402DB2A6C12C@llvm.org> Author: ahatanak Date: Mon Oct 3 14:28:44 2011 New Revision: 141015 URL: http://llvm.org/viewvc/llvm-project?rev=141015&view=rev Log: Add definitions of instructions which move values between 64-bit integer registers and 64-bit HI and LO registers. Fix encoding of the 32-bit versions of the instructions. Modified: llvm/trunk/lib/Target/Mips/Mips64InstrInfo.td llvm/trunk/lib/Target/Mips/MipsInstrInfo.td Modified: llvm/trunk/lib/Target/Mips/Mips64InstrInfo.td URL: http://llvm.org/viewvc/llvm-project/llvm/trunk/lib/Target/Mips/Mips64InstrInfo.td?rev=141015&r1=141014&r2=141015&view=diff ============================================================================== --- llvm/trunk/lib/Target/Mips/Mips64InstrInfo.td (original) +++ llvm/trunk/lib/Target/Mips/Mips64InstrInfo.td Mon Oct 3 14:28:44 2011 @@ -90,6 +90,19 @@ let shamt = _shamt; } +// Move from Hi/Lo +let shamt = 0 in { +let rs = 0, rt = 0 in +class MoveFromLOHI64 func, string instr_asm>: + FR<0x00, func, (outs CPU64Regs:$dst), (ins), + !strconcat(instr_asm, "\t$dst"), [], IIHiLo>; + +let rt = 0, rd = 0 in +class MoveToLOHI64 func, string instr_asm>: + FR<0x00, func, (outs), (ins CPU64Regs:$src), + !strconcat(instr_asm, "\t$src"), [], IIHiLo>; +} + //===----------------------------------------------------------------------===// // Instruction definition //===----------------------------------------------------------------------===// @@ -126,6 +139,16 @@ def DROTRV : LogicR_shift_rotate_reg64<0x16, 0x01, "drotrv", rotr>; } +let Defs = [HI64] in + def MTHI64 : MoveToLOHI64<0x11, "mthi">; +let Defs = [LO64] in + def MTLO64 : MoveToLOHI64<0x13, "mtlo">; + +let Uses = [HI64] in + def MFHI64 : MoveFromLOHI64<0x10, "mfhi">; +let Uses = [LO64] in + def MFLO64 : MoveFromLOHI64<0x12, "mflo">; + //===----------------------------------------------------------------------===// // Arbitrary patterns that map to one or more instructions //===----------------------------------------------------------------------===// Modified: llvm/trunk/lib/Target/Mips/MipsInstrInfo.td URL: http://llvm.org/viewvc/llvm-project/llvm/trunk/lib/Target/Mips/MipsInstrInfo.td?rev=141015&r1=141014&r2=141015&view=diff ============================================================================== --- llvm/trunk/lib/Target/Mips/MipsInstrInfo.td (original) +++ llvm/trunk/lib/Target/Mips/MipsInstrInfo.td Mon Oct 3 14:28:44 2011 @@ -359,13 +359,17 @@ } // Move from Hi/Lo +let shamt = 0 in { +let rs = 0, rt = 0 in class MoveFromLOHI func, string instr_asm>: FR<0x00, func, (outs CPURegs:$dst), (ins), !strconcat(instr_asm, "\t$dst"), [], IIHiLo>; +let rt = 0, rd = 0 in class MoveToLOHI func, string instr_asm>: FR<0x00, func, (outs), (ins CPURegs:$src), !strconcat(instr_asm, "\t$src"), [], IIHiLo>; +} class EffectiveAddress : FI<0x09, (outs CPURegs:$dst), (ins mem_ea:$addr), From ahatanaka at mips.com Mon Oct 3 15:01:11 2011 From: ahatanaka at mips.com (Akira Hatanaka) Date: Mon, 03 Oct 2011 20:01:11 -0000 Subject: [llvm-commits] [llvm] r141017 - in /llvm/trunk: lib/Target/Mips/Mips64InstrInfo.td lib/Target/Mips/MipsISelDAGToDAG.cpp test/CodeGen/Mips/mips64instrs.ll Message-ID: <20111003200111.E32702A6C12C@llvm.org> Author: ahatanak Date: Mon Oct 3 15:01:11 2011 New Revision: 141017 URL: http://llvm.org/viewvc/llvm-project?rev=141017&view=rev Log: Add support for 64-bit integer multiply instructions. Modified: llvm/trunk/lib/Target/Mips/Mips64InstrInfo.td llvm/trunk/lib/Target/Mips/MipsISelDAGToDAG.cpp llvm/trunk/test/CodeGen/Mips/mips64instrs.ll Modified: llvm/trunk/lib/Target/Mips/Mips64InstrInfo.td URL: http://llvm.org/viewvc/llvm-project/llvm/trunk/lib/Target/Mips/Mips64InstrInfo.td?rev=141017&r1=141016&r2=141017&view=diff ============================================================================== --- llvm/trunk/lib/Target/Mips/Mips64InstrInfo.td (original) +++ llvm/trunk/lib/Target/Mips/Mips64InstrInfo.td Mon Oct 3 15:01:11 2011 @@ -90,6 +90,14 @@ let shamt = _shamt; } +// Mul, Div +let Defs = [HI64, LO64] in { + let isCommutable = 1 in + class Mul64 func, string instr_asm, InstrItinClass itin>: + FR<0x00, func, (outs), (ins CPU64Regs:$a, CPU64Regs:$b), + !strconcat(instr_asm, "\t$a, $b"), [], itin>; +} + // Move from Hi/Lo let shamt = 0 in { let rs = 0, rt = 0 in @@ -139,6 +147,10 @@ def DROTRV : LogicR_shift_rotate_reg64<0x16, 0x01, "drotrv", rotr>; } +/// Multiply and Divide Instructions. +def DMULT : Mul64<0x1c, "dmult", IIImul>; +def DMULTu : Mul64<0x1d, "dmultu", IIImul>; + let Defs = [HI64] in def MTHI64 : MoveToLOHI64<0x11, "mthi">; let Defs = [LO64] in Modified: llvm/trunk/lib/Target/Mips/MipsISelDAGToDAG.cpp URL: http://llvm.org/viewvc/llvm-project/llvm/trunk/lib/Target/Mips/MipsISelDAGToDAG.cpp?rev=141017&r1=141016&r2=141017&view=diff ============================================================================== --- llvm/trunk/lib/Target/Mips/MipsISelDAGToDAG.cpp (original) +++ llvm/trunk/lib/Target/Mips/MipsISelDAGToDAG.cpp Mon Oct 3 15:01:11 2011 @@ -237,6 +237,8 @@ /// Mul with two results case ISD::SMUL_LOHI: case ISD::UMUL_LOHI: { + assert(Node->getValueType(0) != MVT::i64 && + "64-bit multiplication with two results not handled."); SDValue Op1 = Node->getOperand(0); SDValue Op2 = Node->getOperand(1); @@ -262,21 +264,29 @@ /// Special Muls case ISD::MUL: - if (Subtarget.hasMips32()) + // Mips32 has a 32-bit three operand mul instruction. + if (Subtarget.hasMips32() && Node->getValueType(0) == MVT::i32) break; case ISD::MULHS: case ISD::MULHU: { + assert((Opcode == ISD::MUL || Node->getValueType(0) != MVT::i64) && + "64-bit MULH* not handled."); + EVT Ty = Node->getValueType(0); SDValue MulOp1 = Node->getOperand(0); SDValue MulOp2 = Node->getOperand(1); - unsigned MulOp = (Opcode == ISD::MULHU ? Mips::MULTu : Mips::MULT); + unsigned MulOp = (Opcode == ISD::MULHU ? + Mips::MULTu : + (Ty == MVT::i32 ? Mips::MULT : Mips::DMULT)); SDNode *MulNode = CurDAG->getMachineNode(MulOp, dl, MVT::Glue, MulOp1, MulOp2); SDValue InFlag = SDValue(MulNode, 0); - if (Opcode == ISD::MUL) - return CurDAG->getMachineNode(Mips::MFLO, dl, MVT::i32, InFlag); + if (Opcode == ISD::MUL) { + unsigned Opc = (Ty == MVT::i32 ? Mips::MFLO : Mips::MFLO64); + return CurDAG->getMachineNode(Opc, dl, Ty, InFlag); + } else return CurDAG->getMachineNode(Mips::MFHI, dl, MVT::i32, InFlag); } Modified: llvm/trunk/test/CodeGen/Mips/mips64instrs.ll URL: http://llvm.org/viewvc/llvm-project/llvm/trunk/test/CodeGen/Mips/mips64instrs.ll?rev=141017&r1=141016&r2=141017&view=diff ============================================================================== --- llvm/trunk/test/CodeGen/Mips/mips64instrs.ll (original) +++ llvm/trunk/test/CodeGen/Mips/mips64instrs.ll Mon Oct 3 15:01:11 2011 @@ -70,3 +70,16 @@ ret i64 %xor } +define i64 @f12(i64 %a, i64 %b) nounwind readnone { +entry: +; CHECK: mult + %mul = mul nsw i64 %b, %a + ret i64 %mul +} + +define i64 @f13(i64 %a, i64 %b) nounwind readnone { +entry: +; CHECK: mult + %mul = mul i64 %b, %a + ret i64 %mul +} From nlewycky at google.com Mon Oct 3 15:03:29 2011 From: nlewycky at google.com (Nick Lewycky) Date: Mon, 3 Oct 2011 13:03:29 -0700 Subject: [llvm-commits] patch: chrec * chrec = chrec. In-Reply-To: <7AD2AE23-DD82-4D4E-A75B-FCB290144F4D@2pi.dk> References: <4E88F8E3.3050506@mxc.ca> <7AD2AE23-DD82-4D4E-A75B-FCB290144F4D@2pi.dk> Message-ID: On 3 October 2011 09:50, Jakob Stoklund Olesen wrote: > > On Oct 2, 2011, at 4:50 PM, Nick Lewycky wrote: > > > This patch is a follow-up to r139133 which corrected SCEV's getMulExpr > when given two chrec arguments. Here I extend it to correctly multiply > chrecs of any length. > > Hi Nick, > > I can't really comment on the SCEV stuff, but > > +static unsigned Choose(unsigned n, unsigned k, bool &Overflow) { > + // This method can overflow internally even if the final result would > fit. > + > + if (n == 0) return 1; > + if (k >= n) return 1; > + > + if (k > n/2) > + k = n-k; > + > + unsigned r = 1; > + for (unsigned i = 1; i <= k; ++i) { > + r = umul_ov(r, n-(i-1), Overflow); > + r /= i; > + } > + return r; > +} > > Please add a comment that this function is computing a binomial > coefficient, and how it does it. > Sure. I was relying on the reader understanding "n choose k". In particular, it wasn't immediately clear to me that the division never > truncates. > > Are binomial coefficients defined for k > n? If so, shouldn't the value be > 0? > Yes, k > n should be zero. > + const SCEV *CoeffTerm = getConstant(Ty, > Coeff1*Coeff2); > > Can this multiplication overflow? > Oh good point. I spent all this time thinking about what if Ty is an i3 and Coeff1*Coeff2 doesn't fit there, but not the case where Ty is larger than unsigned. The most straight-forward thing to do is reuse umul_ov. Finally, your x,y,z loop is O(N^4) in the number of SCEV operands. I don't > know if this is a problem in practice. > > The Choose() calls in that loop are computing the same intermediate results > over and over. You could get an O(N^3) computation by reusing those > binomials. > Both true, but not yet observed to be problems in practice. One alternative approach would be to allocate a binomial-coefficient scratch space and then use the recursive algorithm. I was really hoping to avoid putting more complex implementation for Choose into this patch, there's enough gnarly math in there as it is. Nick -------------- next part -------------- An HTML attachment was scrubbed... URL: http://lists.cs.uiuc.edu/pipermail/llvm-commits/attachments/20111003/c9acdbae/attachment.html From stoklund at 2pi.dk Mon Oct 3 15:20:36 2011 From: stoklund at 2pi.dk (Jakob Stoklund Olesen) Date: Mon, 03 Oct 2011 13:20:36 -0700 Subject: [llvm-commits] patch: chrec * chrec = chrec. In-Reply-To: References: <4E88F8E3.3050506@mxc.ca> <7AD2AE23-DD82-4D4E-A75B-FCB290144F4D@2pi.dk> Message-ID: On Oct 3, 2011, at 1:03 PM, Nick Lewycky wrote: > On 3 October 2011 09:50, Jakob Stoklund Olesen wrote: > > + const SCEV *CoeffTerm = getConstant(Ty, Coeff1*Coeff2); > > Can this multiplication overflow? > > Oh good point. I spent all this time thinking about what if Ty is an i3 and Coeff1*Coeff2 doesn't fit there, but not the case where Ty is larger than unsigned. The most straight-forward thing to do is reuse umul_ov. Or just promote to 64-bit. ScalarEvolution::getConstant() already takes a uint64_t. > > Finally, your x,y,z loop is O(N^4) in the number of SCEV operands. I don't know if this is a problem in practice. > > The Choose() calls in that loop are computing the same intermediate results over and over. You could get an O(N^3) computation by reusing those binomials. > > Both true, but not yet observed to be problems in practice. One alternative approach would be to allocate a binomial-coefficient scratch space and then use the recursive algorithm. I was really hoping to avoid putting more complex implementation for Choose into this patch, there's enough gnarly math in there as it is. Fair enough. /jakob -------------- next part -------------- An HTML attachment was scrubbed... URL: http://lists.cs.uiuc.edu/pipermail/llvm-commits/attachments/20111003/47b5e01c/attachment.html From ahatanaka at mips.com Mon Oct 3 15:38:09 2011 From: ahatanaka at mips.com (Akira Hatanaka) Date: Mon, 03 Oct 2011 20:38:09 -0000 Subject: [llvm-commits] [llvm] r141019 - /llvm/trunk/lib/Target/Mips/MipsInstrInfo.cpp Message-ID: <20111003203809.4EF552A6C12C@llvm.org> Author: ahatanak Date: Mon Oct 3 15:38:08 2011 New Revision: 141019 URL: http://llvm.org/viewvc/llvm-project?rev=141019&view=rev Log: Clean up MipsInstrInfo::copyPhysReg and handle copies from and to 64-bit integer registers. Modified: llvm/trunk/lib/Target/Mips/MipsInstrInfo.cpp Modified: llvm/trunk/lib/Target/Mips/MipsInstrInfo.cpp URL: http://llvm.org/viewvc/llvm-project/llvm/trunk/lib/Target/Mips/MipsInstrInfo.cpp?rev=141019&r1=141018&r2=141019&view=diff ============================================================================== --- llvm/trunk/lib/Target/Mips/MipsInstrInfo.cpp (original) +++ llvm/trunk/lib/Target/Mips/MipsInstrInfo.cpp Mon Oct 3 15:38:08 2011 @@ -94,70 +94,63 @@ MachineBasicBlock::iterator I, DebugLoc DL, unsigned DestReg, unsigned SrcReg, bool KillSrc) const { - bool DestCPU = Mips::CPURegsRegClass.contains(DestReg); - bool SrcCPU = Mips::CPURegsRegClass.contains(SrcReg); + unsigned Opc = 0, ZeroReg = 0; - // CPU-CPU is the most common. - if (DestCPU && SrcCPU) { - BuildMI(MBB, I, DL, get(Mips::ADDu), DestReg).addReg(Mips::ZERO) - .addReg(SrcReg, getKillRegState(KillSrc)); - return; - } - - // Copy to CPU from other registers. - if (DestCPU) { - if (Mips::CCRRegClass.contains(SrcReg)) - BuildMI(MBB, I, DL, get(Mips::CFC1), DestReg) - .addReg(SrcReg, getKillRegState(KillSrc)); + if (Mips::CPURegsRegClass.contains(DestReg)) { // Copy to CPU Reg. + if (Mips::CPURegsRegClass.contains(SrcReg)) + Opc = Mips::ADDu, ZeroReg = Mips::ZERO; + else if (Mips::CCRRegClass.contains(SrcReg)) + Opc = Mips::CFC1; else if (Mips::FGR32RegClass.contains(SrcReg)) - BuildMI(MBB, I, DL, get(Mips::MFC1), DestReg) - .addReg(SrcReg, getKillRegState(KillSrc)); + Opc = Mips::MFC1; else if (SrcReg == Mips::HI) - BuildMI(MBB, I, DL, get(Mips::MFHI), DestReg); + Opc = Mips::MFHI, SrcReg = 0; else if (SrcReg == Mips::LO) - BuildMI(MBB, I, DL, get(Mips::MFLO), DestReg); - else - llvm_unreachable("Copy to CPU from invalid register"); - return; + Opc = Mips::MFLO, SrcReg = 0; } - - // Copy to other registers from CPU. - if (SrcCPU) { + else if (Mips::CPURegsRegClass.contains(SrcReg)) { // Copy from CPU Reg. if (Mips::CCRRegClass.contains(DestReg)) - BuildMI(MBB, I, DL, get(Mips::CTC1), DestReg) - .addReg(SrcReg, getKillRegState(KillSrc)); + Opc = Mips::CTC1; else if (Mips::FGR32RegClass.contains(DestReg)) - BuildMI(MBB, I, DL, get(Mips::MTC1), DestReg) - .addReg(SrcReg, getKillRegState(KillSrc)); + Opc = Mips::MTC1; else if (DestReg == Mips::HI) - BuildMI(MBB, I, DL, get(Mips::MTHI)) - .addReg(SrcReg, getKillRegState(KillSrc)); + Opc = Mips::MTHI, DestReg = 0; else if (DestReg == Mips::LO) - BuildMI(MBB, I, DL, get(Mips::MTLO)) - .addReg(SrcReg, getKillRegState(KillSrc)); - else - llvm_unreachable("Copy from CPU to invalid register"); - return; + Opc = Mips::MTLO, DestReg = 0; } - - if (Mips::FGR32RegClass.contains(DestReg, SrcReg)) { - BuildMI(MBB, I, DL, get(Mips::FMOV_S32), DestReg) - .addReg(SrcReg, getKillRegState(KillSrc)); - return; + else if (Mips::FGR32RegClass.contains(DestReg, SrcReg)) + Opc = Mips::FMOV_S32; + else if (Mips::AFGR64RegClass.contains(DestReg, SrcReg)) + Opc = Mips::FMOV_D32; + else if (Mips::CCRRegClass.contains(DestReg, SrcReg)) + Opc = Mips::MOVCCRToCCR; + else if (Mips::CPU64RegsRegClass.contains(DestReg)) { // Copy to CPU64 Reg. + if (Mips::CPU64RegsRegClass.contains(SrcReg)) + Opc = Mips::DADDu, ZeroReg = Mips::ZERO_64; + else if (SrcReg == Mips::HI64) + Opc = Mips::MFHI64, SrcReg = 0; + else if (SrcReg == Mips::LO64) + Opc = Mips::MFLO64, SrcReg = 0; + } + else if (Mips::CPU64RegsRegClass.contains(SrcReg)) { // Copy from CPU64 Reg. + if (DestReg == Mips::HI64) + Opc = Mips::MTHI64, DestReg = 0; + else if (DestReg == Mips::LO64) + Opc = Mips::MTLO64, DestReg = 0; } - if (Mips::AFGR64RegClass.contains(DestReg, SrcReg)) { - BuildMI(MBB, I, DL, get(Mips::FMOV_D32), DestReg) - .addReg(SrcReg, getKillRegState(KillSrc)); - return; - } + assert(Opc && "Cannot copy registers"); - if (Mips::CCRRegClass.contains(DestReg, SrcReg)) { - BuildMI(MBB, I, DL, get(Mips::MOVCCRToCCR), DestReg) - .addReg(SrcReg, getKillRegState(KillSrc)); - return; - } - llvm_unreachable("Cannot copy registers"); + MachineInstrBuilder MIB = BuildMI(MBB, I, DL, get(Opc)); + + if (DestReg) + MIB.addReg(DestReg, RegState::Define); + + if (ZeroReg) + MIB.addReg(ZeroReg); + + if (SrcReg) + MIB.addReg(SrcReg, getKillRegState(KillSrc)); } void MipsInstrInfo:: From joerg at britannica.bec.de Mon Oct 3 15:51:57 2011 From: joerg at britannica.bec.de (Joerg Sonnenberger) Date: Mon, 3 Oct 2011 22:51:57 +0200 Subject: [llvm-commits] patch: chrec * chrec = chrec. In-Reply-To: <4E88F8E3.3050506@mxc.ca> References: <4E88F8E3.3050506@mxc.ca> Message-ID: <20111003205157.GA10434@britannica.bec.de> On Sun, Oct 02, 2011 at 04:50:59PM -0700, Nick Lewycky wrote: > Index: lib/Analysis/ScalarEvolution.cpp > =================================================================== > --- lib/Analysis/ScalarEvolution.cpp (revision 140963) > +++ lib/Analysis/ScalarEvolution.cpp (working copy) > @@ -1812,6 +1812,29 @@ > return S; > } > > +static unsigned umul_ov(unsigned i, unsigned j, bool &Overflow) { > + unsigned k = i*j; > + if (j > 1 && k / j != i) Overflow = true; > + return k; > +} > + > +static unsigned Choose(unsigned n, unsigned k, bool &Overflow) { > + // This method can overflow internally even if the final result would fit. > + > + if (n == 0) return 1; > + if (k >= n) return 1; > + > + if (k > n/2) > + k = n-k; > + > + unsigned r = 1; > + for (unsigned i = 1; i <= k; ++i) { > + r = umul_ov(r, n-(i-1), Overflow); > + r /= i; > + } > + return r; > +} > + What exactly is the desired behavior in case of overflow? E.g. do you want to get C(n,k) % (UINTMAX + 1)? In that case, your formula doesn't compute correct results. Joerg From grosbach at apple.com Mon Oct 3 15:52:00 2011 From: grosbach at apple.com (Jim Grosbach) Date: Mon, 03 Oct 2011 20:52:00 -0000 Subject: [llvm-commits] [llvm] r141020 - /llvm/trunk/lib/Target/ARM/ARMInstrThumb2.td Message-ID: <20111003205200.751D02A6C12C@llvm.org> Author: grosbach Date: Mon Oct 3 15:51:59 2011 New Revision: 141020 URL: http://llvm.org/viewvc/llvm-project?rev=141020&view=rev Log: Thumb2 ADD/SUB can take SP as a destination register. It's documented as a separate instruction to line up with the Thumb1 encodings, for which it really is a distinct instruction encoding. Modified: llvm/trunk/lib/Target/ARM/ARMInstrThumb2.td Modified: llvm/trunk/lib/Target/ARM/ARMInstrThumb2.td URL: http://llvm.org/viewvc/llvm-project/llvm/trunk/lib/Target/ARM/ARMInstrThumb2.td?rev=141020&r1=141019&r2=141020&view=diff ============================================================================== --- llvm/trunk/lib/Target/ARM/ARMInstrThumb2.td (original) +++ llvm/trunk/lib/Target/ARM/ARMInstrThumb2.td Mon Oct 3 15:51:59 2011 @@ -639,9 +639,9 @@ // in particular for taking the address of a local. let isReMaterializable = 1 in { def ri : T2sTwoRegImm< - (outs rGPR:$Rd), (ins GPRnopc:$Rn, t2_so_imm:$imm), IIC_iALUi, - opc, ".w\t$Rd, $Rn, $imm", - [(set rGPR:$Rd, (opnode GPRnopc:$Rn, t2_so_imm:$imm))]> { + (outs GPRnopc:$Rd), (ins GPRnopc:$Rn, t2_so_imm:$imm), IIC_iALUi, + opc, ".w\t$Rd, $Rn, $imm", + [(set GPRnopc:$Rd, (opnode GPRnopc:$Rn, t2_so_imm:$imm))]> { let Inst{31-27} = 0b11110; let Inst{25} = 0; let Inst{24} = 1; @@ -651,9 +651,9 @@ } // 12-bit imm def ri12 : T2I< - (outs rGPR:$Rd), (ins GPR:$Rn, imm0_4095:$imm), IIC_iALUi, + (outs GPRnopc:$Rd), (ins GPR:$Rn, imm0_4095:$imm), IIC_iALUi, !strconcat(opc, "w"), "\t$Rd, $Rn, $imm", - [(set rGPR:$Rd, (opnode GPR:$Rn, imm0_4095:$imm))]> { + [(set GPRnopc:$Rd, (opnode GPR:$Rn, imm0_4095:$imm))]> { bits<4> Rd; bits<4> Rn; bits<12> imm; @@ -669,9 +669,9 @@ let Inst{7-0} = imm{7-0}; } // register - def rr : T2sThreeReg<(outs rGPR:$Rd), (ins GPRnopc:$Rn, rGPR:$Rm), IIC_iALUr, - opc, ".w\t$Rd, $Rn, $Rm", - [(set rGPR:$Rd, (opnode GPRnopc:$Rn, rGPR:$Rm))]> { + def rr : T2sThreeReg<(outs GPRnopc:$Rd), (ins GPRnopc:$Rn, rGPR:$Rm), + IIC_iALUr, opc, ".w\t$Rd, $Rn, $Rm", + [(set GPRnopc:$Rd, (opnode GPRnopc:$Rn, rGPR:$Rm))]> { let isCommutable = Commutable; let Inst{31-27} = 0b11101; let Inst{26-25} = 0b01; @@ -683,9 +683,9 @@ } // shifted register def rs : T2sTwoRegShiftedReg< - (outs rGPR:$Rd), (ins GPRnopc:$Rn, t2_so_reg:$ShiftedRm), + (outs GPRnopc:$Rd), (ins GPRnopc:$Rn, t2_so_reg:$ShiftedRm), IIC_iALUsi, opc, ".w\t$Rd, $Rn, $ShiftedRm", - [(set rGPR:$Rd, (opnode GPRnopc:$Rn, t2_so_reg:$ShiftedRm))]> { + [(set GPRnopc:$Rd, (opnode GPRnopc:$Rn, t2_so_reg:$ShiftedRm))]> { let Inst{31-27} = 0b11101; let Inst{26-25} = 0b01; let Inst{24} = 1; @@ -3848,24 +3848,24 @@ // Aliases for ADD without the ".w" optional width specifier. def : t2InstAlias<"add${s}${p} $Rd, $Rn, $imm", - (t2ADDri rGPR:$Rd, GPRnopc:$Rn, t2_so_imm:$imm, pred:$p, cc_out:$s)>; + (t2ADDri GPRnopc:$Rd, GPRnopc:$Rn, t2_so_imm:$imm, pred:$p, cc_out:$s)>; def : t2InstAlias<"add${p} $Rd, $Rn, $imm", - (t2ADDri12 rGPR:$Rd, GPR:$Rn, imm0_4095:$imm, pred:$p)>; + (t2ADDri12 GPRnopc:$Rd, GPR:$Rn, imm0_4095:$imm, pred:$p)>; def : t2InstAlias<"add${s}${p} $Rd, $Rn, $Rm", - (t2ADDrr rGPR:$Rd, GPRnopc:$Rn, rGPR:$Rm, pred:$p, cc_out:$s)>; + (t2ADDrr GPRnopc:$Rd, GPRnopc:$Rn, rGPR:$Rm, pred:$p, cc_out:$s)>; def : t2InstAlias<"add${s}${p} $Rd, $Rn, $ShiftedRm", - (t2ADDrs rGPR:$Rd, GPRnopc:$Rn, t2_so_reg:$ShiftedRm, + (t2ADDrs GPRnopc:$Rd, GPRnopc:$Rn, t2_so_reg:$ShiftedRm, pred:$p, cc_out:$s)>; // Aliases for SUB without the ".w" optional width specifier. def : t2InstAlias<"sub${s}${p} $Rd, $Rn, $imm", - (t2SUBri rGPR:$Rd, GPRnopc:$Rn, t2_so_imm:$imm, pred:$p, cc_out:$s)>; + (t2SUBri GPRnopc:$Rd, GPRnopc:$Rn, t2_so_imm:$imm, pred:$p, cc_out:$s)>; def : t2InstAlias<"sub${p} $Rd, $Rn, $imm", - (t2SUBri12 rGPR:$Rd, GPR:$Rn, imm0_4095:$imm, pred:$p)>; + (t2SUBri12 GPRnopc:$Rd, GPR:$Rn, imm0_4095:$imm, pred:$p)>; def : t2InstAlias<"sub${s}${p} $Rd, $Rn, $Rm", - (t2SUBrr rGPR:$Rd, GPRnopc:$Rn, rGPR:$Rm, pred:$p, cc_out:$s)>; + (t2SUBrr GPRnopc:$Rd, GPRnopc:$Rn, rGPR:$Rm, pred:$p, cc_out:$s)>; def : t2InstAlias<"sub${s}${p} $Rd, $Rn, $ShiftedRm", - (t2SUBrs rGPR:$Rd, GPRnopc:$Rn, t2_so_reg:$ShiftedRm, + (t2SUBrs GPRnopc:$Rd, GPRnopc:$Rn, t2_so_reg:$ShiftedRm, pred:$p, cc_out:$s)>; // Alias for compares without the ".w" optional width specifier. From grosbach at apple.com Mon Oct 3 15:58:08 2011 From: grosbach at apple.com (Jim Grosbach) Date: Mon, 03 Oct 2011 20:58:08 -0000 Subject: [llvm-commits] [llvm] r141022 - /llvm/trunk/test/MC/ARM/thumb-diagnostics.s Message-ID: <20111003205808.BE5722A6C12C@llvm.org> Author: grosbach Date: Mon Oct 3 15:58:08 2011 New Revision: 141022 URL: http://llvm.org/viewvc/llvm-project?rev=141022&view=rev Log: Update test for 141010. Modified: llvm/trunk/test/MC/ARM/thumb-diagnostics.s Modified: llvm/trunk/test/MC/ARM/thumb-diagnostics.s URL: http://llvm.org/viewvc/llvm-project/llvm/trunk/test/MC/ARM/thumb-diagnostics.s?rev=141022&r1=141021&r2=141022&view=diff ============================================================================== --- llvm/trunk/test/MC/ARM/thumb-diagnostics.s (original) +++ llvm/trunk/test/MC/ARM/thumb-diagnostics.s Mon Oct 3 15:58:08 2011 @@ -131,7 +131,7 @@ @ CHECK-ERRORS: error: invalid operand for instruction @ CHECK-ERRORS: add sp, #3 @ CHECK-ERRORS: ^ -@ CHECK-ERRORS: error: invalid operand for instruction +@ CHECK-ERRORS: error: instruction requires a CPU feature not currently enabled @ CHECK-ERRORS: add sp, sp, #512 @ CHECK-ERRORS: ^ @ CHECK-ERRORS: error: instruction requires a CPU feature not currently enabled From dpatel at apple.com Mon Oct 3 15:59:18 2011 From: dpatel at apple.com (Devang Patel) Date: Mon, 03 Oct 2011 20:59:18 -0000 Subject: [llvm-commits] [llvm] r141023 - in /llvm/trunk: include/llvm-c/Core.h lib/VMCore/Core.cpp Message-ID: <20111003205918.5DBAE2A6C12C@llvm.org> Author: dpatel Date: Mon Oct 3 15:59:18 2011 New Revision: 141023 URL: http://llvm.org/viewvc/llvm-project?rev=141023&view=rev Log: Add C api for Instruction->eraseFromParent(). Modified: llvm/trunk/include/llvm-c/Core.h llvm/trunk/lib/VMCore/Core.cpp Modified: llvm/trunk/include/llvm-c/Core.h URL: http://llvm.org/viewvc/llvm-project/llvm/trunk/include/llvm-c/Core.h?rev=141023&r1=141022&r2=141023&view=diff ============================================================================== --- llvm/trunk/include/llvm-c/Core.h (original) +++ llvm/trunk/include/llvm-c/Core.h Mon Oct 3 15:59:18 2011 @@ -776,6 +776,7 @@ LLVMBasicBlockRef LLVMGetInstructionParent(LLVMValueRef Inst); LLVMValueRef LLVMGetNextInstruction(LLVMValueRef Inst); LLVMValueRef LLVMGetPreviousInstruction(LLVMValueRef Inst); +void LLVMInstructionEraseFromParent(LLVMValueRef Inst); /* Operations on call sites */ void LLVMSetInstructionCallConv(LLVMValueRef Instr, unsigned CC); Modified: llvm/trunk/lib/VMCore/Core.cpp URL: http://llvm.org/viewvc/llvm-project/llvm/trunk/lib/VMCore/Core.cpp?rev=141023&r1=141022&r2=141023&view=diff ============================================================================== --- llvm/trunk/lib/VMCore/Core.cpp (original) +++ llvm/trunk/lib/VMCore/Core.cpp Mon Oct 3 15:59:18 2011 @@ -1508,6 +1508,10 @@ return wrap(--I); } +void LLVMInstructionEraseFromParent(LLVMValueRef Inst) { + unwrap(Inst)->eraseFromParent(); +} + /*--.. Call and invoke instructions ........................................--*/ unsigned LLVMGetInstructionCallConv(LLVMValueRef Instr) { From ahatanaka at mips.com Mon Oct 3 16:06:13 2011 From: ahatanaka at mips.com (Akira Hatanaka) Date: Mon, 03 Oct 2011 21:06:13 -0000 Subject: [llvm-commits] [llvm] r141024 - in /llvm/trunk: lib/Target/Mips/Mips64InstrInfo.td lib/Target/Mips/MipsISelLowering.cpp lib/Target/Mips/MipsInstrInfo.td test/CodeGen/Mips/mips64instrs.ll Message-ID: <20111003210613.966DD2A6C12C@llvm.org> Author: ahatanak Date: Mon Oct 3 16:06:13 2011 New Revision: 141024 URL: http://llvm.org/viewvc/llvm-project?rev=141024&view=rev Log: Add support for 64-bit divide instructions. Modified: llvm/trunk/lib/Target/Mips/Mips64InstrInfo.td llvm/trunk/lib/Target/Mips/MipsISelLowering.cpp llvm/trunk/lib/Target/Mips/MipsInstrInfo.td llvm/trunk/test/CodeGen/Mips/mips64instrs.ll Modified: llvm/trunk/lib/Target/Mips/Mips64InstrInfo.td URL: http://llvm.org/viewvc/llvm-project/llvm/trunk/lib/Target/Mips/Mips64InstrInfo.td?rev=141024&r1=141023&r2=141024&view=diff ============================================================================== --- llvm/trunk/lib/Target/Mips/Mips64InstrInfo.td (original) +++ llvm/trunk/lib/Target/Mips/Mips64InstrInfo.td Mon Oct 3 16:06:13 2011 @@ -96,6 +96,11 @@ class Mul64 func, string instr_asm, InstrItinClass itin>: FR<0x00, func, (outs), (ins CPU64Regs:$a, CPU64Regs:$b), !strconcat(instr_asm, "\t$a, $b"), [], itin>; + + class Div64 func, string instr_asm, InstrItinClass itin>: + FR<0x00, func, (outs), (ins CPU64Regs:$a, CPU64Regs:$b), + !strconcat(instr_asm, "\t$$zero, $a, $b"), + [(op CPU64Regs:$a, CPU64Regs:$b)], itin>; } // Move from Hi/Lo @@ -150,6 +155,8 @@ /// Multiply and Divide Instructions. def DMULT : Mul64<0x1c, "dmult", IIImul>; def DMULTu : Mul64<0x1d, "dmultu", IIImul>; +def DSDIV : Div64; +def DUDIV : Div64; let Defs = [HI64] in def MTHI64 : MoveToLOHI64<0x11, "mthi">; Modified: llvm/trunk/lib/Target/Mips/MipsISelLowering.cpp URL: http://llvm.org/viewvc/llvm-project/llvm/trunk/lib/Target/Mips/MipsISelLowering.cpp?rev=141024&r1=141023&r2=141024&view=diff ============================================================================== --- llvm/trunk/lib/Target/Mips/MipsISelLowering.cpp (original) +++ llvm/trunk/lib/Target/Mips/MipsISelLowering.cpp Mon Oct 3 16:06:13 2011 @@ -138,6 +138,10 @@ setOperationAction(ISD::SREM, MVT::i32, Expand); setOperationAction(ISD::UDIV, MVT::i32, Expand); setOperationAction(ISD::UREM, MVT::i32, Expand); + setOperationAction(ISD::SDIV, MVT::i64, Expand); + setOperationAction(ISD::SREM, MVT::i64, Expand); + setOperationAction(ISD::UDIV, MVT::i64, Expand); + setOperationAction(ISD::UREM, MVT::i64, Expand); // Operations not directly supported by Mips. setOperationAction(ISD::BR_JT, MVT::Other, Expand); @@ -413,6 +417,9 @@ if (DCI.isBeforeLegalizeOps()) return SDValue(); + EVT Ty = N->getValueType(0); + unsigned LO = (Ty == MVT::i32) ? Mips::LO : Mips::LO64; + unsigned HI = (Ty == MVT::i32) ? Mips::HI : Mips::HI64; unsigned opc = N->getOpcode() == ISD::SDIVREM ? MipsISD::DivRem : MipsISD::DivRemU; DebugLoc dl = N->getDebugLoc(); @@ -424,7 +431,7 @@ // insert MFLO if (N->hasAnyUseOfValue(0)) { - SDValue CopyFromLo = DAG.getCopyFromReg(InChain, dl, Mips::LO, MVT::i32, + SDValue CopyFromLo = DAG.getCopyFromReg(InChain, dl, LO, Ty, InGlue); DAG.ReplaceAllUsesOfValueWith(SDValue(N, 0), CopyFromLo); InChain = CopyFromLo.getValue(1); @@ -434,7 +441,7 @@ // insert MFHI if (N->hasAnyUseOfValue(1)) { SDValue CopyFromHi = DAG.getCopyFromReg(InChain, dl, - Mips::HI, MVT::i32, InGlue); + HI, Ty, InGlue); DAG.ReplaceAllUsesOfValueWith(SDValue(N, 1), CopyFromHi); } Modified: llvm/trunk/lib/Target/Mips/MipsInstrInfo.td URL: http://llvm.org/viewvc/llvm-project/llvm/trunk/lib/Target/Mips/MipsInstrInfo.td?rev=141024&r1=141023&r2=141024&view=diff ============================================================================== --- llvm/trunk/lib/Target/Mips/MipsInstrInfo.td (original) +++ llvm/trunk/lib/Target/Mips/MipsInstrInfo.td Mon Oct 3 16:06:13 2011 @@ -34,7 +34,7 @@ SDTCisSameAs<1, 2>, SDTCisSameAs<2, 3>]>; def SDT_MipsDivRem : SDTypeProfile<0, 2, - [SDTCisVT<0, i32>, + [SDTCisInt<0>, SDTCisSameAs<0, 1>]>; def SDT_MipsThreadPointer : SDTypeProfile<1, 0, [SDTCisPtrTy<0>]>; Modified: llvm/trunk/test/CodeGen/Mips/mips64instrs.ll URL: http://llvm.org/viewvc/llvm-project/llvm/trunk/test/CodeGen/Mips/mips64instrs.ll?rev=141024&r1=141023&r2=141024&view=diff ============================================================================== --- llvm/trunk/test/CodeGen/Mips/mips64instrs.ll (original) +++ llvm/trunk/test/CodeGen/Mips/mips64instrs.ll Mon Oct 3 16:06:13 2011 @@ -83,3 +83,36 @@ %mul = mul i64 %b, %a ret i64 %mul } + +define i64 @f14(i64 %a, i64 %b) nounwind readnone { +entry: +; CHECK: ddiv $zero +; CHECK: mflo + %div = sdiv i64 %a, %b + ret i64 %div +} + +define i64 @f15(i64 %a, i64 %b) nounwind readnone { +entry: +; CHECK: ddivu $zero +; CHECK: mflo + %div = udiv i64 %a, %b + ret i64 %div +} + +define i64 @f16(i64 %a, i64 %b) nounwind readnone { +entry: +; CHECK: ddiv $zero +; CHECK: mfhi + %rem = srem i64 %a, %b + ret i64 %rem +} + +define i64 @f17(i64 %a, i64 %b) nounwind readnone { +entry: +; CHECK: ddivu $zero +; CHECK: mfhi + %rem = urem i64 %a, %b + ret i64 %rem +} + From nlewycky at google.com Mon Oct 3 16:10:45 2011 From: nlewycky at google.com (Nick Lewycky) Date: Mon, 3 Oct 2011 14:10:45 -0700 Subject: [llvm-commits] patch: chrec * chrec = chrec. In-Reply-To: <20111003205157.GA10434@britannica.bec.de> References: <4E88F8E3.3050506@mxc.ca> <20111003205157.GA10434@britannica.bec.de> Message-ID: On 3 October 2011 13:51, Joerg Sonnenberger wrote: > On Sun, Oct 02, 2011 at 04:50:59PM -0700, Nick Lewycky wrote: > > Index: lib/Analysis/ScalarEvolution.cpp > > =================================================================== > > --- lib/Analysis/ScalarEvolution.cpp (revision 140963) > > +++ lib/Analysis/ScalarEvolution.cpp (working copy) > > @@ -1812,6 +1812,29 @@ > > return S; > > } > > > > +static unsigned umul_ov(unsigned i, unsigned j, bool &Overflow) { > > + unsigned k = i*j; > > + if (j > 1 && k / j != i) Overflow = true; > > + return k; > > +} > > + > > +static unsigned Choose(unsigned n, unsigned k, bool &Overflow) { > > + // This method can overflow internally even if the final result would > fit. > > + > > + if (n == 0) return 1; > > + if (k >= n) return 1; > > + > > + if (k > n/2) > > + k = n-k; > > + > > + unsigned r = 1; > > + for (unsigned i = 1; i <= k; ++i) { > > + r = umul_ov(r, n-(i-1), Overflow); > > + r /= i; > > + } > > + return r; > > +} > > + > > What exactly is the desired behavior in case of overflow? > E.g. do you want to get C(n,k) % (UINTMAX + 1)? In that case, your > formula doesn't compute correct results. > In overflow the return value is garbage and Overflow is set. This method deserves a comment. Nick -------------- next part -------------- An HTML attachment was scrubbed... URL: http://lists.cs.uiuc.edu/pipermail/llvm-commits/attachments/20111003/a9cf75e4/attachment.html From grosbach at apple.com Mon Oct 3 16:12:43 2011 From: grosbach at apple.com (Jim Grosbach) Date: Mon, 03 Oct 2011 21:12:43 -0000 Subject: [llvm-commits] [llvm] r141025 - in /llvm/trunk: lib/Target/ARM/ARMInstrFormats.td lib/Target/ARM/ARMInstrVFP.td lib/Target/ARM/AsmParser/ARMAsmParser.cpp test/MC/ARM/simple-fp-encoding.s Message-ID: <20111003211243.8AF782A6C12C@llvm.org> Author: grosbach Date: Mon Oct 3 16:12:43 2011 New Revision: 141025 URL: http://llvm.org/viewvc/llvm-project?rev=141025&view=rev Log: ARM assembly parsing and encoding for VMRS/FMSTAT. Modified: llvm/trunk/lib/Target/ARM/ARMInstrFormats.td llvm/trunk/lib/Target/ARM/ARMInstrVFP.td llvm/trunk/lib/Target/ARM/AsmParser/ARMAsmParser.cpp llvm/trunk/test/MC/ARM/simple-fp-encoding.s Modified: llvm/trunk/lib/Target/ARM/ARMInstrFormats.td URL: http://llvm.org/viewvc/llvm-project/llvm/trunk/lib/Target/ARM/ARMInstrFormats.td?rev=141025&r1=141024&r2=141025&view=diff ============================================================================== --- llvm/trunk/lib/Target/ARM/ARMInstrFormats.td (original) +++ llvm/trunk/lib/Target/ARM/ARMInstrFormats.td Mon Oct 3 16:12:43 2011 @@ -227,6 +227,10 @@ : InstAlias, Requires<[IsThumb]>; class t2InstAlias : InstAlias, Requires<[IsThumb2]>; +class VFP2InstAlias + : InstAlias, Requires<[HasVFP2]>; +class VFP3InstAlias + : InstAlias, Requires<[HasVFP3]>; //===----------------------------------------------------------------------===// // ARM Instruction templates. Modified: llvm/trunk/lib/Target/ARM/ARMInstrVFP.td URL: http://llvm.org/viewvc/llvm-project/llvm/trunk/lib/Target/ARM/ARMInstrVFP.td?rev=141025&r1=141024&r2=141025&view=diff ============================================================================== --- llvm/trunk/lib/Target/ARM/ARMInstrVFP.td (original) +++ llvm/trunk/lib/Target/ARM/ARMInstrVFP.td Mon Oct 3 16:12:43 2011 @@ -1148,3 +1148,10 @@ let Inst{3-0} = imm{3-0}; } } + +//===----------------------------------------------------------------------===// +// Assembler aliases. +// + +def : VFP2InstAlias<"fmstat${p}", (FMSTAT pred:$p)>; + Modified: llvm/trunk/lib/Target/ARM/AsmParser/ARMAsmParser.cpp URL: http://llvm.org/viewvc/llvm-project/llvm/trunk/lib/Target/ARM/AsmParser/ARMAsmParser.cpp?rev=141025&r1=141024&r2=141025&view=diff ============================================================================== --- llvm/trunk/lib/Target/ARM/AsmParser/ARMAsmParser.cpp (original) +++ llvm/trunk/lib/Target/ARM/AsmParser/ARMAsmParser.cpp Mon Oct 3 16:12:43 2011 @@ -3046,6 +3046,7 @@ Error(Parser.getTok().getLoc(), "unexpected token in operand"); return true; case AsmToken::Identifier: { + // If this is VMRS, check for the apsr_nzcv operand. if (!tryParseRegisterWithWriteBack(Operands)) return false; int Res = tryParseShiftRegister(Operands); @@ -3053,6 +3054,12 @@ return false; else if (Res == -1) // irrecoverable error return true; + if (Mnemonic == "vmrs" && Parser.getTok().getString() == "apsr_nzcv") { + S = Parser.getTok().getLoc(); + Parser.Lex(); + Operands.push_back(ARMOperand::CreateToken("apsr_nzcv", S)); + return false; + } // Fall though for the Identifier case that is not a register or a // special name. Modified: llvm/trunk/test/MC/ARM/simple-fp-encoding.s URL: http://llvm.org/viewvc/llvm-project/llvm/trunk/test/MC/ARM/simple-fp-encoding.s?rev=141025&r1=141024&r2=141025&view=diff ============================================================================== --- llvm/trunk/test/MC/ARM/simple-fp-encoding.s (original) +++ llvm/trunk/test/MC/ARM/simple-fp-encoding.s Mon Oct 3 16:12:43 2011 @@ -114,8 +114,10 @@ @ CHECK: vnmls.f32 s1, s2, s0 @ encoding: [0x00,0x0a,0x51,0xee] vnmls.f32 s1, s2, s0 -@ FIXME: vmrs apsr_nzcv, fpscr @ encoding: [0x10,0xfa,0xf1,0xee] -@ vmrs apsr_nzcv, fpscr +@ CHECK: vmrs apsr_nzcv, fpscr @ encoding: [0x10,0xfa,0xf1,0xee] +@ CHECK: vmrs apsr_nzcv, fpscr @ encoding: [0x10,0xfa,0xf1,0xee] + vmrs apsr_nzcv, fpscr + fmstat @ CHECK: vnegne.f64 d16, d16 @ encoding: [0x60,0x0b,0xf1,0x1e] vnegne.f64 d16, d16 From isanbard at gmail.com Mon Oct 3 16:15:28 2011 From: isanbard at gmail.com (Bill Wendling) Date: Mon, 03 Oct 2011 21:15:28 -0000 Subject: [llvm-commits] [llvm] r141026 - /llvm/trunk/lib/CodeGen/SjLjEHPrepare.cpp Message-ID: <20111003211528.C1E702A6C12C@llvm.org> Author: void Date: Mon Oct 3 16:15:28 2011 New Revision: 141026 URL: http://llvm.org/viewvc/llvm-project?rev=141026&view=rev Log: Move the grabbing of the jump buffer into the caller function, eliminating the need for returning a std::pair. Modified: llvm/trunk/lib/CodeGen/SjLjEHPrepare.cpp Modified: llvm/trunk/lib/CodeGen/SjLjEHPrepare.cpp URL: http://llvm.org/viewvc/llvm-project/llvm/trunk/lib/CodeGen/SjLjEHPrepare.cpp?rev=141026&r1=141025&r2=141026&view=diff ============================================================================== --- llvm/trunk/lib/CodeGen/SjLjEHPrepare.cpp (original) +++ llvm/trunk/lib/CodeGen/SjLjEHPrepare.cpp Mon Oct 3 16:15:28 2011 @@ -75,8 +75,7 @@ private: bool setupEntryBlockAndCallSites(Function &F); - std::pair - setupFunctionContext(Function &F, ArrayRef LPads); + Value *setupFunctionContext(Function &F, ArrayRef LPads); void insertCallSiteStore(Instruction *I, int Number, Value *CallSite); void markInvokeCallSite(InvokeInst *II, int InvokeNo, Value *CallSite, @@ -712,7 +711,7 @@ /// setupFunctionContext - Allocate the function context on the stack and fill /// it with all of the data that we know at this point. -std::pair SjLjEHPass:: +Value *SjLjEHPass:: setupFunctionContext(Function &F, ArrayRef LPads) { BasicBlock *EntryBB = F.begin(); @@ -788,24 +787,7 @@ EntryBB->getTerminator()); new StoreInst(LSDA, LSDAFieldPtr, true, EntryBB->getTerminator()); - // Get a reference to the jump buffer. - Idxs[1] = ConstantInt::get(Int32Ty, 5); - Value *JBufPtr = - GetElementPtrInst::Create(FuncCtx, Idxs, "jbuf_gep", - EntryBB->getTerminator()); - Idxs[1] = Zero; - Value *FramePtr = - GetElementPtrInst::Create(JBufPtr, Idxs, "jbuf_fp_gep", - EntryBB->getTerminator()); - - // Save the frame pointer. - Value *Val = CallInst::Create(FrameAddrFn, - ConstantInt::get(Int32Ty, 0), - "fp", - EntryBB->getTerminator()); - new StoreInst(Val, FramePtr, true, EntryBB->getTerminator()); - - return std::make_pair(FuncCtx, JBufPtr); + return FuncCtx; } /// setupEntryBlockAndCallSites - Setup the entry block by creating and filling @@ -827,24 +809,44 @@ if (Invokes.empty()) return false; - std::pair FuncCtx = setupFunctionContext(F, LPads); + Value *FuncCtx = setupFunctionContext(F, LPads); BasicBlock *EntryBB = F.begin(); - - // Save the stack pointer. Type *Int32Ty = Type::getInt32Ty(F.getContext()); + Value *Idxs[2] = { - ConstantInt::get(Int32Ty, 0), ConstantInt::get(Int32Ty, 2) + ConstantInt::get(Int32Ty, 0), 0 }; + + // Get a reference to the jump buffer. + Idxs[1] = ConstantInt::get(Int32Ty, 5); + Value *JBufPtr = + GetElementPtrInst::Create(FuncCtx, Idxs, "jbuf_gep", + EntryBB->getTerminator()); + + // Save the frame pointer. + Idxs[1] = ConstantInt::get(Int32Ty, 0); + Value *FramePtr = + GetElementPtrInst::Create(JBufPtr, Idxs, "jbuf_fp_gep", + EntryBB->getTerminator()); + + Value *Val = CallInst::Create(FrameAddrFn, + ConstantInt::get(Int32Ty, 0), + "fp", + EntryBB->getTerminator()); + new StoreInst(Val, FramePtr, true, EntryBB->getTerminator()); + + // Save the stack pointer. + Idxs[1] = ConstantInt::get(Int32Ty, 2); Value *StackPtr = - GetElementPtrInst::Create(FuncCtx.second, Idxs, "jbuf_sp_gep", + GetElementPtrInst::Create(JBufPtr, Idxs, "jbuf_sp_gep", EntryBB->getTerminator()); - Value *Val = CallInst::Create(StackAddrFn, "sp", EntryBB->getTerminator()); + Val = CallInst::Create(StackAddrFn, "sp", EntryBB->getTerminator()); new StoreInst(Val, StackPtr, true, EntryBB->getTerminator()); // Call the setjmp instrinsic. It fills in the rest of the jmpbuf. Value *SetjmpArg = - CastInst::Create(Instruction::BitCast, FuncCtx.second, + CastInst::Create(Instruction::BitCast, JBufPtr, Type::getInt8PtrTy(F.getContext()), "", EntryBB->getTerminator()); Value *DispatchVal = CallInst::Create(BuiltinSetjmpFn, SetjmpArg, @@ -858,7 +860,7 @@ // Store a pointer to the function context so that the back-end will know // where to look for it. Value *FuncCtxArg = - CastInst::Create(Instruction::BitCast, FuncCtx.first, + CastInst::Create(Instruction::BitCast, FuncCtx, Type::getInt8PtrTy(F.getContext()), "", EntryBB->getTerminator()); CallInst::Create(FuncCtxFn, FuncCtxArg, "", EntryBB->getTerminator()); @@ -892,14 +894,14 @@ } // Register the function context and make sure it's known to not throw - CallInst *Register = CallInst::Create(RegisterFn, FuncCtx.first, "", + CallInst *Register = CallInst::Create(RegisterFn, FuncCtx, "", EntryBB->getTerminator()); Register->setDoesNotThrow(); // Finally, for any returns from this function, if this function contains an // invoke, add a call to unregister the function context. for (unsigned I = 0, E = Returns.size(); I != E; ++I) - CallInst::Create(UnregisterFn, FuncCtx.first, "", Returns[I]); + CallInst::Create(UnregisterFn, FuncCtx, "", Returns[I]); return true; } From ahatanaka at mips.com Mon Oct 3 16:16:53 2011 From: ahatanaka at mips.com (Akira Hatanaka) Date: Mon, 03 Oct 2011 21:16:53 -0000 Subject: [llvm-commits] [llvm] r141028 - in /llvm/trunk: lib/Target/Mips/Mips64InstrInfo.td test/CodeGen/Mips/mips64instrs.ll Message-ID: <20111003211653.ED1F32A6C12C@llvm.org> Author: ahatanak Date: Mon Oct 3 16:16:50 2011 New Revision: 141028 URL: http://llvm.org/viewvc/llvm-project?rev=141028&view=rev Log: Add support for 64-bit count leading ones and zeros instructions. Modified: llvm/trunk/lib/Target/Mips/Mips64InstrInfo.td llvm/trunk/test/CodeGen/Mips/mips64instrs.ll Modified: llvm/trunk/lib/Target/Mips/Mips64InstrInfo.td URL: http://llvm.org/viewvc/llvm-project/llvm/trunk/lib/Target/Mips/Mips64InstrInfo.td?rev=141028&r1=141027&r2=141028&view=diff ============================================================================== --- llvm/trunk/lib/Target/Mips/Mips64InstrInfo.td (original) +++ llvm/trunk/lib/Target/Mips/Mips64InstrInfo.td Mon Oct 3 16:16:50 2011 @@ -116,6 +116,15 @@ !strconcat(instr_asm, "\t$src"), [], IIHiLo>; } +// Count Leading Ones/Zeros in Word +class CountLeading64 func, string instr_asm, list pattern>: + FR<0x1c, func, (outs CPU64Regs:$dst), (ins CPU64Regs:$src), + !strconcat(instr_asm, "\t$dst, $src"), pattern, IIAlu>, + Requires<[HasBitCount]> { + let shamt = 0; + let rt = rd; +} + //===----------------------------------------------------------------------===// // Instruction definition //===----------------------------------------------------------------------===// @@ -168,6 +177,12 @@ let Uses = [LO64] in def MFLO64 : MoveFromLOHI64<0x12, "mflo">; +/// Count Leading +def DCLZ : CountLeading64<0x24, "dclz", + [(set CPU64Regs:$dst, (ctlz CPU64Regs:$src))]>; +def DCLO : CountLeading64<0x25, "dclo", + [(set CPU64Regs:$dst, (ctlz (not CPU64Regs:$src)))]>; + //===----------------------------------------------------------------------===// // Arbitrary patterns that map to one or more instructions //===----------------------------------------------------------------------===// Modified: llvm/trunk/test/CodeGen/Mips/mips64instrs.ll URL: http://llvm.org/viewvc/llvm-project/llvm/trunk/test/CodeGen/Mips/mips64instrs.ll?rev=141028&r1=141027&r2=141028&view=diff ============================================================================== --- llvm/trunk/test/CodeGen/Mips/mips64instrs.ll (original) +++ llvm/trunk/test/CodeGen/Mips/mips64instrs.ll Mon Oct 3 16:16:50 2011 @@ -116,3 +116,20 @@ ret i64 %rem } +declare i64 @llvm.ctlz.i64(i64) nounwind readnone + +; CHECK: dclz $2, $4 +define i64 @f18(i64 %X) nounwind readnone { +entry: + %tmp1 = tail call i64 @llvm.ctlz.i64(i64 %X) + ret i64 %tmp1 +} + +; CHECK: dclo $2, $4 +define i64 @f19(i64 %X) nounwind readnone { +entry: + %neg = xor i64 %X, -1 + %tmp1 = tail call i64 @llvm.ctlz.i64(i64 %neg) + ret i64 %tmp1 +} + From ahatanaka at mips.com Mon Oct 3 16:23:18 2011 From: ahatanaka at mips.com (Akira Hatanaka) Date: Mon, 03 Oct 2011 21:23:18 -0000 Subject: [llvm-commits] [llvm] r141029 - in /llvm/trunk: lib/Target/Mips/Mips64InstrInfo.td test/CodeGen/Mips/mips64instrs.ll Message-ID: <20111003212319.188E62A6C12C@llvm.org> Author: ahatanak Date: Mon Oct 3 16:23:18 2011 New Revision: 141029 URL: http://llvm.org/viewvc/llvm-project?rev=141029&view=rev Log: Add support for 64-bit logical NOR. Modified: llvm/trunk/lib/Target/Mips/Mips64InstrInfo.td llvm/trunk/test/CodeGen/Mips/mips64instrs.ll Modified: llvm/trunk/lib/Target/Mips/Mips64InstrInfo.td URL: http://llvm.org/viewvc/llvm-project/llvm/trunk/lib/Target/Mips/Mips64InstrInfo.td?rev=141029&r1=141028&r2=141029&view=diff ============================================================================== --- llvm/trunk/lib/Target/Mips/Mips64InstrInfo.td (original) +++ llvm/trunk/lib/Target/Mips/Mips64InstrInfo.td Mon Oct 3 16:23:18 2011 @@ -72,6 +72,12 @@ !strconcat(instr_asm, "\t$dst, $b, $c"), [(set CPU64Regs:$dst, (OpNode CPU64Regs:$b, immZExt16:$c))], IIAlu>; +let isCommutable = 1 in +class LogicNOR64 op, bits<6> func, string instr_asm>: + FR; + // Shifts class LogicR_shift_rotate_imm64 func, bits<5> _rs, string instr_asm, SDNode OpNode, PatFrag PF>: @@ -141,6 +147,7 @@ def DAND : LogicR64<0x24, "and", and>; def DOR : LogicR64<0x25, "or", or>; def DXOR : LogicR64<0x26, "xor", xor>; +def DNOR : LogicNOR64<0x00, 0x27, "nor">; /// Shift Instructions def DSLL : LogicR_shift_rotate_imm64<0x38, 0x00, "dsll", shl, immZExt5>; Modified: llvm/trunk/test/CodeGen/Mips/mips64instrs.ll URL: http://llvm.org/viewvc/llvm-project/llvm/trunk/test/CodeGen/Mips/mips64instrs.ll?rev=141029&r1=141028&r2=141029&view=diff ============================================================================== --- llvm/trunk/test/CodeGen/Mips/mips64instrs.ll (original) +++ llvm/trunk/test/CodeGen/Mips/mips64instrs.ll Mon Oct 3 16:23:18 2011 @@ -133,3 +133,11 @@ ret i64 %tmp1 } +define i64 @f20(i64 %a, i64 %b) nounwind readnone { +entry: +; CHECK: nor + %or = or i64 %b, %a + %neg = xor i64 %or, -1 + ret i64 %neg +} + From ahatanaka at mips.com Mon Oct 3 16:24:30 2011 From: ahatanaka at mips.com (Akira Hatanaka) Date: Mon, 03 Oct 2011 21:24:30 -0000 Subject: [llvm-commits] [llvm] r141030 - /llvm/trunk/test/CodeGen/Mips/mips64instrs.ll Message-ID: <20111003212430.5DCEA2A6C12C@llvm.org> Author: ahatanak Date: Mon Oct 3 16:24:30 2011 New Revision: 141030 URL: http://llvm.org/viewvc/llvm-project?rev=141030&view=rev Log: Move CHECK after entry label. Modified: llvm/trunk/test/CodeGen/Mips/mips64instrs.ll Modified: llvm/trunk/test/CodeGen/Mips/mips64instrs.ll URL: http://llvm.org/viewvc/llvm-project/llvm/trunk/test/CodeGen/Mips/mips64instrs.ll?rev=141030&r1=141029&r2=141030&view=diff ============================================================================== --- llvm/trunk/test/CodeGen/Mips/mips64instrs.ll (original) +++ llvm/trunk/test/CodeGen/Mips/mips64instrs.ll Mon Oct 3 16:24:30 2011 @@ -118,16 +118,16 @@ declare i64 @llvm.ctlz.i64(i64) nounwind readnone -; CHECK: dclz $2, $4 define i64 @f18(i64 %X) nounwind readnone { entry: +; CHECK: dclz $2, $4 %tmp1 = tail call i64 @llvm.ctlz.i64(i64 %X) ret i64 %tmp1 } -; CHECK: dclo $2, $4 define i64 @f19(i64 %X) nounwind readnone { entry: +; CHECK: dclo $2, $4 %neg = xor i64 %X, -1 %tmp1 = tail call i64 @llvm.ctlz.i64(i64 %neg) ret i64 %tmp1 From isanbard at gmail.com Mon Oct 3 16:25:38 2011 From: isanbard at gmail.com (Bill Wendling) Date: Mon, 03 Oct 2011 21:25:38 -0000 Subject: [llvm-commits] [llvm] r141031 - in /llvm/trunk/lib/Target/ARM: ARMISelLowering.cpp ARMISelLowering.h Message-ID: <20111003212538.E1C222A6C12C@llvm.org> Author: void Date: Mon Oct 3 16:25:38 2011 New Revision: 141031 URL: http://llvm.org/viewvc/llvm-project?rev=141031&view=rev Log: Check-pointing the new SjLj EH lowering. This code will replace the version in ARMAsmPrinter.cpp. It creates a new machine basic block, which is the dispatch for the return from a longjmp call. It then shoves the address of that machine basic block into the correct place in the function context so that the EH runtime will jump to it directly instead of having to go through a compare-and-jump-to-the-dispatch bit. This should be more efficient in the common case. Modified: llvm/trunk/lib/Target/ARM/ARMISelLowering.cpp llvm/trunk/lib/Target/ARM/ARMISelLowering.h Modified: llvm/trunk/lib/Target/ARM/ARMISelLowering.cpp URL: http://llvm.org/viewvc/llvm-project/llvm/trunk/lib/Target/ARM/ARMISelLowering.cpp?rev=141031&r1=141030&r2=141031&view=diff ============================================================================== --- llvm/trunk/lib/Target/ARM/ARMISelLowering.cpp (original) +++ llvm/trunk/lib/Target/ARM/ARMISelLowering.cpp Mon Oct 3 16:25:38 2011 @@ -5482,6 +5482,80 @@ return BB; } +MachineBasicBlock *ARMTargetLowering:: +EmitSjLjDispatchBlock(MachineInstr *MI, MachineBasicBlock *MBB) const { + const TargetInstrInfo *TII = getTargetMachine().getInstrInfo(); + DebugLoc dl = MI->getDebugLoc(); + MachineFunction *MF = MBB->getParent(); + MachineRegisterInfo *MRI = &MF->getRegInfo(); + MachineConstantPool *MCP = MF->getConstantPool(); + ARMFunctionInfo *AFI = MF->getInfo(); + const Function *F = MF->getFunction(); + MachineFrameInfo *MFI = MF->getFrameInfo(); + MachineBasicBlock *DispatchBB = MF->CreateMachineBasicBlock(); + int FI = MFI->getFunctionContextIndex(); + MachineBasicBlock *Last = &MF->back(); + MF->insert(MF->end(), DispatchBB); + MF->RenumberBlocks(Last); + + // Shove the dispatch's address into the return slot in the function context. + DispatchBB->setIsLandingPad(); + MBB->addSuccessor(DispatchBB); + + BuildMI(DispatchBB, dl, TII->get(ARM::TRAP)); + + bool isThumb = Subtarget->isThumb(); + unsigned PCLabelId = AFI->createPICLabelUId(); + unsigned PCAdj = isThumb ? 4 : 8; + ARMConstantPoolValue *CPV = + ARMConstantPoolMBB::Create(F->getContext(), DispatchBB, PCLabelId, PCAdj); + unsigned CPI = MCP->getConstantPoolIndex(CPV, 4); + + const TargetRegisterClass *TRC = + isThumb ? ARM::tGPRRegisterClass : ARM::GPRRegisterClass; + + MachineMemOperand *CPMMO = + MF->getMachineMemOperand(MachinePointerInfo::getConstantPool(), + MachineMemOperand::MOLoad, 4, 4); + + MachineMemOperand *FIMMO = + MF->getMachineMemOperand(MachinePointerInfo::getFixedStack(FI), + MachineMemOperand::MOStore, 4, 4); + + // Load the address of the dispatch MBB into the jump buffer. + if (isThumb) { + unsigned NewVReg = MRI->createVirtualRegister(TRC); + BuildMI(*MBB, MI, dl, TII->get(ARM::tLDRpci_pic), NewVReg) + .addConstantPoolIndex(CPI) + .addImm(1) + .addMemOperand(CPMMO); + AddDefaultPred(BuildMI(*MBB, MI, dl, TII->get(ARM::tSTRspi)) + .addReg(NewVReg, RegState::Kill) + .addFrameIndex(FI) + .addImm(36) // &jbuf[1] :: pc + .addMemOperand(FIMMO)); + } else { + unsigned NewVReg1 = MRI->createVirtualRegister(TRC); + AddDefaultPred(BuildMI(*MBB, MI, dl, TII->get(ARM::LDRi12), NewVReg1) + .addConstantPoolIndex(CPI) + .addImm(0) + .addMemOperand(CPMMO)); + unsigned NewVReg2 = MRI->createVirtualRegister(TRC); + AddDefaultPred(BuildMI(*MBB, MI, dl, TII->get(ARM::PICADD), NewVReg2) + .addReg(NewVReg1, RegState::Kill) + .addImm(1)); + AddDefaultPred(BuildMI(*MBB, MI, dl, TII->get(ARM::STRi12)) + .addReg(NewVReg2, RegState::Kill) + .addFrameIndex(FI) + .addImm(36) // &jbuf[1] :: pc + .addMemOperand(FIMMO)); + } + + MI->eraseFromParent(); // The instruction is gone now. + + return MBB; +} + static MachineBasicBlock *OtherSucc(MachineBasicBlock *MBB, MachineBasicBlock *Succ) { for (MachineBasicBlock::succ_iterator I = MBB->succ_begin(), Modified: llvm/trunk/lib/Target/ARM/ARMISelLowering.h URL: http://llvm.org/viewvc/llvm-project/llvm/trunk/lib/Target/ARM/ARMISelLowering.h?rev=141031&r1=141030&r2=141031&view=diff ============================================================================== --- llvm/trunk/lib/Target/ARM/ARMISelLowering.h (original) +++ llvm/trunk/lib/Target/ARM/ARMISelLowering.h Mon Oct 3 16:25:38 2011 @@ -512,6 +512,9 @@ bool signExtend, ARMCC::CondCodes Cond) const; + MachineBasicBlock *EmitSjLjDispatchBlock(MachineInstr *MI, + MachineBasicBlock *MBB) const; + bool RemapAddSubWithFlags(MachineInstr *MI, MachineBasicBlock *BB) const; }; From nicholas at mxc.ca Mon Oct 3 16:30:08 2011 From: nicholas at mxc.ca (Nick Lewycky) Date: Mon, 03 Oct 2011 21:30:08 -0000 Subject: [llvm-commits] [llvm] r141032 - /llvm/trunk/lib/Support/APFloat.cpp Message-ID: <20111003213008.B23272A6C12C@llvm.org> Author: nicholas Date: Mon Oct 3 16:30:08 2011 New Revision: 141032 URL: http://llvm.org/viewvc/llvm-project?rev=141032&view=rev Log: Fix typo in comments. Modified: llvm/trunk/lib/Support/APFloat.cpp Modified: llvm/trunk/lib/Support/APFloat.cpp URL: http://llvm.org/viewvc/llvm-project/llvm/trunk/lib/Support/APFloat.cpp?rev=141032&r1=141031&r2=141032&view=diff ============================================================================== --- llvm/trunk/lib/Support/APFloat.cpp (original) +++ llvm/trunk/lib/Support/APFloat.cpp Mon Oct 3 16:30:08 2011 @@ -1192,7 +1192,7 @@ if (omsb) { /* OMSB is numbered from 1. We want to place it in the integer - bit numbered PRECISON if possible, with a compensating change in + bit numbered PRECISION if possible, with a compensating change in the exponent. */ exponentChange = omsb - semantics->precision; @@ -2125,7 +2125,7 @@ dstCount = partCount(); precision = semantics->precision; - /* We want the most significant PRECISON bits of SRC. There may not + /* We want the most significant PRECISION bits of SRC. There may not be that many; extract what we can. */ if (precision <= omsb) { exponent = omsb - 1; From evan.cheng at apple.com Mon Oct 3 17:19:05 2011 From: evan.cheng at apple.com (Evan Cheng) Date: Mon, 03 Oct 2011 15:19:05 -0700 Subject: [llvm-commits] [llvm] r140863 - in /llvm/trunk: lib/Target/ARM/MCTargetDesc/ARMMCTargetDesc.cpp test/CodeGen/ARM/fast-isel.ll test/CodeGen/ARM/hidden-vis-2.ll test/CodeGen/ARM/hidden-vis-3.ll test/CodeGen/ARM/tail-opts.ll test/CodeGen/Thumb2/machine-licm.ll In-Reply-To: <20110930174137.A91E42A6C12C@llvm.org> References: <20110930174137.A91E42A6C12C@llvm.org> Message-ID: Since you are making this change, can you fix x86_64 as well? Evan On Sep 30, 2011, at 10:41 AM, Jim Grosbach wrote: > Author: grosbach > Date: Fri Sep 30 12:41:35 2011 > New Revision: 140863 > > URL: http://llvm.org/viewvc/llvm-project?rev=140863&view=rev > Log: > ARM Darwin default relocation model is PIC. > > This matches clang, so default options in llc and friends are now closer to > clang's defaults. > > Modified: > llvm/trunk/lib/Target/ARM/MCTargetDesc/ARMMCTargetDesc.cpp > llvm/trunk/test/CodeGen/ARM/fast-isel.ll > llvm/trunk/test/CodeGen/ARM/hidden-vis-2.ll > llvm/trunk/test/CodeGen/ARM/hidden-vis-3.ll > llvm/trunk/test/CodeGen/ARM/tail-opts.ll > llvm/trunk/test/CodeGen/Thumb2/machine-licm.ll > > Modified: llvm/trunk/lib/Target/ARM/MCTargetDesc/ARMMCTargetDesc.cpp > URL: http://llvm.org/viewvc/llvm-project/llvm/trunk/lib/Target/ARM/MCTargetDesc/ARMMCTargetDesc.cpp?rev=140863&r1=140862&r2=140863&view=diff > ============================================================================== > --- llvm/trunk/lib/Target/ARM/MCTargetDesc/ARMMCTargetDesc.cpp (original) > +++ llvm/trunk/lib/Target/ARM/MCTargetDesc/ARMMCTargetDesc.cpp Fri Sep 30 12:41:35 2011 > @@ -139,8 +139,11 @@ > static MCCodeGenInfo *createARMMCCodeGenInfo(StringRef TT, Reloc::Model RM, > CodeModel::Model CM) { > MCCodeGenInfo *X = new MCCodeGenInfo(); > - if (RM == Reloc::Default) > - RM = Reloc::DynamicNoPIC; > + if (RM == Reloc::Default) { > + Triple TheTriple(TT); > + // Default relocation model on Darwin is PIC, not DynamicNoPIC. > + RM = TheTriple.isOSDarwin() ? Reloc::PIC_ : Reloc::DynamicNoPIC; > + } > X->InitMCCodeGenInfo(RM, CM); > return X; > } > > Modified: llvm/trunk/test/CodeGen/ARM/fast-isel.ll > URL: http://llvm.org/viewvc/llvm-project/llvm/trunk/test/CodeGen/ARM/fast-isel.ll?rev=140863&r1=140862&r2=140863&view=diff > ============================================================================== > --- llvm/trunk/test/CodeGen/ARM/fast-isel.ll (original) > +++ llvm/trunk/test/CodeGen/ARM/fast-isel.ll Fri Sep 30 12:41:35 2011 > @@ -1,5 +1,5 @@ > -; RUN: llc < %s -O0 -fast-isel-abort -mtriple=armv7-apple-darwin | FileCheck %s --check-prefix=ARM > -; RUN: llc < %s -O0 -fast-isel-abort -mtriple=thumbv7-apple-darwin | FileCheck %s --check-prefix=THUMB > +; RUN: llc < %s -O0 -fast-isel-abort -relocation-model=dynamic-no-pic -mtriple=armv7-apple-darwin | FileCheck %s --check-prefix=ARM > +; RUN: llc < %s -O0 -fast-isel-abort -relocation-model=dynamic-no-pic -mtriple=thumbv7-apple-darwin | FileCheck %s --check-prefix=THUMB > > ; Very basic fast-isel functionality. > define i32 @add(i32 %a, i32 %b) nounwind { > > Modified: llvm/trunk/test/CodeGen/ARM/hidden-vis-2.ll > URL: http://llvm.org/viewvc/llvm-project/llvm/trunk/test/CodeGen/ARM/hidden-vis-2.ll?rev=140863&r1=140862&r2=140863&view=diff > ============================================================================== > --- llvm/trunk/test/CodeGen/ARM/hidden-vis-2.ll (original) > +++ llvm/trunk/test/CodeGen/ARM/hidden-vis-2.ll Fri Sep 30 12:41:35 2011 > @@ -1,4 +1,4 @@ > -; RUN: llc < %s -mtriple=arm-apple-darwin | FileCheck %s > +; RUN: llc < %s -relocation-model=dynamic-no-pic -mtriple=arm-apple-darwin | FileCheck %s > > @x = weak hidden global i32 0 ; [#uses=1] > > > Modified: llvm/trunk/test/CodeGen/ARM/hidden-vis-3.ll > URL: http://llvm.org/viewvc/llvm-project/llvm/trunk/test/CodeGen/ARM/hidden-vis-3.ll?rev=140863&r1=140862&r2=140863&view=diff > ============================================================================== > --- llvm/trunk/test/CodeGen/ARM/hidden-vis-3.ll (original) > +++ llvm/trunk/test/CodeGen/ARM/hidden-vis-3.ll Fri Sep 30 12:41:35 2011 > @@ -1,4 +1,4 @@ > -; RUN: llc < %s -mtriple=arm-apple-darwin9 | FileCheck %s > +; RUN: llc < %s -relocation-model=dynamic-no-pic -mtriple=arm-apple-darwin9 | FileCheck %s > > @x = external hidden global i32 ; [#uses=1] > @y = extern_weak hidden global i32 ; [#uses=1] > > Modified: llvm/trunk/test/CodeGen/ARM/tail-opts.ll > URL: http://llvm.org/viewvc/llvm-project/llvm/trunk/test/CodeGen/ARM/tail-opts.ll?rev=140863&r1=140862&r2=140863&view=diff > ============================================================================== > --- llvm/trunk/test/CodeGen/ARM/tail-opts.ll (original) > +++ llvm/trunk/test/CodeGen/ARM/tail-opts.ll Fri Sep 30 12:41:35 2011 > @@ -1,4 +1,4 @@ > -; RUN: llc < %s -mtriple=arm-apple-darwin -mcpu=cortex-a8 -asm-verbose=false | FileCheck %s > +; RUN: llc < %s -mtriple=arm-apple-darwin -relocation-model=dynamic-no-pic -mcpu=cortex-a8 -asm-verbose=false | FileCheck %s > > declare void @bar(i32) > declare void @car(i32) > > Modified: llvm/trunk/test/CodeGen/Thumb2/machine-licm.ll > URL: http://llvm.org/viewvc/llvm-project/llvm/trunk/test/CodeGen/Thumb2/machine-licm.ll?rev=140863&r1=140862&r2=140863&view=diff > ============================================================================== > --- llvm/trunk/test/CodeGen/Thumb2/machine-licm.ll (original) > +++ llvm/trunk/test/CodeGen/Thumb2/machine-licm.ll Fri Sep 30 12:41:35 2011 > @@ -1,4 +1,4 @@ > -; RUN: llc < %s -mtriple=thumbv7-apple-darwin -mcpu=cortex-a8 -disable-fp-elim | FileCheck %s > +; RUN: llc < %s -mtriple=thumbv7-apple-darwin -mcpu=cortex-a8 -relocation-model=dynamic-no-pic -disable-fp-elim | FileCheck %s > ; RUN: llc < %s -mtriple=thumbv7-apple-darwin -mcpu=cortex-a8 -relocation-model=pic -disable-fp-elim | FileCheck %s --check-prefix=PIC > ; rdar://7353541 > ; rdar://7354376 > > > _______________________________________________ > llvm-commits mailing list > llvm-commits at cs.uiuc.edu > http://lists.cs.uiuc.edu/mailman/listinfo/llvm-commits From evan.cheng at apple.com Mon Oct 3 17:25:30 2011 From: evan.cheng at apple.com (Evan Cheng) Date: Mon, 03 Oct 2011 15:25:30 -0700 Subject: [llvm-commits] [patch] Add the returns_twice attribute In-Reply-To: <4E84F46A.9070206@gmail.com> References: <4E84F46A.9070206@gmail.com> Message-ID: <6638C20A-2346-49A1-B604-45C0FE854CC4@apple.com> See Function::callsFunctionThatReturnsTwice(). If you are adding this attribute, then should add the attribute to these special functions (e.g. setjmp)? Then callsFunctionThatReturnsTwice() can go away. Evan On Sep 29, 2011, at 3:42 PM, Rafael ?vila de Esp?ndola wrote: > The attached patch reuses the hotpatch attribute (which Charles Davis > says is unused) to create the returs_twice attribute. This will be used > to implement the C attribute with the same name. > > It is needed by valgrind, since it has its own setjmp like function. > > See PR11038 for more information. > > Is it OK? > > Cheers, > Rafael > _______________________________________________ > llvm-commits mailing list > llvm-commits at cs.uiuc.edu > http://lists.cs.uiuc.edu/mailman/listinfo/llvm-commits From grosbach at apple.com Mon Oct 3 17:30:25 2011 From: grosbach at apple.com (Jim Grosbach) Date: Mon, 03 Oct 2011 22:30:25 -0000 Subject: [llvm-commits] [llvm] r141038 - in /llvm/trunk: lib/Target/ARM/AsmParser/ARMAsmParser.cpp test/MC/ARM/simple-fp-encoding.s Message-ID: <20111003223025.91C582A6C12C@llvm.org> Author: grosbach Date: Mon Oct 3 17:30:24 2011 New Revision: 141038 URL: http://llvm.org/viewvc/llvm-project?rev=141038&view=rev Log: ARM parsing/encoding for VCMP/VCMPE. Modified: llvm/trunk/lib/Target/ARM/AsmParser/ARMAsmParser.cpp llvm/trunk/test/MC/ARM/simple-fp-encoding.s Modified: llvm/trunk/lib/Target/ARM/AsmParser/ARMAsmParser.cpp URL: http://llvm.org/viewvc/llvm-project/llvm/trunk/lib/Target/ARM/AsmParser/ARMAsmParser.cpp?rev=141038&r1=141037&r2=141038&view=diff ============================================================================== --- llvm/trunk/lib/Target/ARM/AsmParser/ARMAsmParser.cpp (original) +++ llvm/trunk/lib/Target/ARM/AsmParser/ARMAsmParser.cpp Mon Oct 3 17:30:24 2011 @@ -3582,6 +3582,17 @@ delete Op; } } + // VCMP{E} does the same thing, but with a different operand count. + if ((Mnemonic == "vcmp" || Mnemonic == "vcmpe") && Operands.size() == 5 && + static_cast(Operands[4])->isImm()) { + ARMOperand *Op = static_cast(Operands[4]); + const MCConstantExpr *CE = dyn_cast(Op->getImm()); + if (CE && CE->getValue() == 0) { + Operands.erase(Operands.begin() + 4); + Operands.push_back(ARMOperand::CreateToken("#0", Op->getStartLoc())); + delete Op; + } + } // Similarly, the Thumb1 "RSB" instruction has a literal "#0" on the // end. Convert it to a token here. if (Mnemonic == "rsb" && isThumb() && Operands.size() == 6 && Modified: llvm/trunk/test/MC/ARM/simple-fp-encoding.s URL: http://llvm.org/viewvc/llvm-project/llvm/trunk/test/MC/ARM/simple-fp-encoding.s?rev=141038&r1=141037&r2=141038&view=diff ============================================================================== --- llvm/trunk/test/MC/ARM/simple-fp-encoding.s (original) +++ llvm/trunk/test/MC/ARM/simple-fp-encoding.s Mon Oct 3 17:30:24 2011 @@ -36,11 +36,11 @@ @ CHECK: vcmpe.f32 s1, s0 @ encoding: [0xc0,0x0a,0xf4,0xee] vcmpe.f32 s1, s0 -@ FIXME: vcmpe.f64 d16, #0 @ encoding: [0xc0,0x0b,0xf5,0xee] -@ vcmpe.f64 d16, #0 +@ CHECK: vcmpe.f64 d16, #0 @ encoding: [0xc0,0x0b,0xf5,0xee] + vcmpe.f64 d16, #0 -@ FIXME: vcmpe.f32 s0, #0 @ encoding: [0xc0,0x0a,0xb5,0xee] -@ vcmpe.f32 s0, #0 +@ CHECK: vcmpe.f32 s0, #0 @ encoding: [0xc0,0x0a,0xb5,0xee] + vcmpe.f32 s0, #0 @ CHECK: vabs.f64 d16, d16 @ encoding: [0xe0,0x0b,0xf0,0xee] vabs.f64 d16, d16 From isanbard at gmail.com Mon Oct 3 17:42:40 2011 From: isanbard at gmail.com (Bill Wendling) Date: Mon, 03 Oct 2011 22:42:40 -0000 Subject: [llvm-commits] [llvm] r141040 - /llvm/trunk/lib/CodeGen/SjLjEHPrepare.cpp Message-ID: <20111003224240.B4E062A6C12C@llvm.org> Author: void Date: Mon Oct 3 17:42:40 2011 New Revision: 141040 URL: http://llvm.org/viewvc/llvm-project?rev=141040&view=rev Log: Don't carry over the dispatchsetup hack from the old system. Modified: llvm/trunk/lib/CodeGen/SjLjEHPrepare.cpp Modified: llvm/trunk/lib/CodeGen/SjLjEHPrepare.cpp URL: http://llvm.org/viewvc/llvm-project/llvm/trunk/lib/CodeGen/SjLjEHPrepare.cpp?rev=141040&r1=141039&r2=141040&view=diff ============================================================================== --- llvm/trunk/lib/CodeGen/SjLjEHPrepare.cpp (original) +++ llvm/trunk/lib/CodeGen/SjLjEHPrepare.cpp Mon Oct 3 17:42:40 2011 @@ -849,13 +849,7 @@ CastInst::Create(Instruction::BitCast, JBufPtr, Type::getInt8PtrTy(F.getContext()), "", EntryBB->getTerminator()); - Value *DispatchVal = CallInst::Create(BuiltinSetjmpFn, SetjmpArg, - "dispatch", - EntryBB->getTerminator()); - - // Add a call to dispatch_setup after the setjmp call. This is expanded to any - // target-specific setup that needs to be done. - CallInst::Create(DispatchSetupFn, DispatchVal, "", EntryBB->getTerminator()); + CallInst::Create(BuiltinSetjmpFn, SetjmpArg, "", EntryBB->getTerminator()); // Store a pointer to the function context so that the back-end will know // where to look for it. From isanbard at gmail.com Mon Oct 3 17:44:15 2011 From: isanbard at gmail.com (Bill Wendling) Date: Mon, 03 Oct 2011 22:44:15 -0000 Subject: [llvm-commits] [llvm] r141042 - /llvm/trunk/lib/Target/ARM/ARMISelLowering.cpp Message-ID: <20111003224415.AC7442A6C12C@llvm.org> Author: void Date: Mon Oct 3 17:44:15 2011 New Revision: 141042 URL: http://llvm.org/viewvc/llvm-project?rev=141042&view=rev Log: Use the PC label ID rather than '1'. Add support for thumb-2, because I heard that some people use it. Modified: llvm/trunk/lib/Target/ARM/ARMISelLowering.cpp Modified: llvm/trunk/lib/Target/ARM/ARMISelLowering.cpp URL: http://llvm.org/viewvc/llvm-project/llvm/trunk/lib/Target/ARM/ARMISelLowering.cpp?rev=141042&r1=141041&r2=141042&view=diff ============================================================================== --- llvm/trunk/lib/Target/ARM/ARMISelLowering.cpp (original) +++ llvm/trunk/lib/Target/ARM/ARMISelLowering.cpp Mon Oct 3 17:44:15 2011 @@ -5505,8 +5505,9 @@ BuildMI(DispatchBB, dl, TII->get(ARM::TRAP)); bool isThumb = Subtarget->isThumb(); + bool isThumb2 = Subtarget->isThumb2(); unsigned PCLabelId = AFI->createPICLabelUId(); - unsigned PCAdj = isThumb ? 4 : 8; + unsigned PCAdj = (isThumb || isThumb2) ? 4 : 8; ARMConstantPoolValue *CPV = ARMConstantPoolMBB::Create(F->getContext(), DispatchBB, PCLabelId, PCAdj); unsigned CPI = MCP->getConstantPoolIndex(CPV, 4); @@ -5523,18 +5524,48 @@ MachineMemOperand::MOStore, 4, 4); // Load the address of the dispatch MBB into the jump buffer. - if (isThumb) { - unsigned NewVReg = MRI->createVirtualRegister(TRC); - BuildMI(*MBB, MI, dl, TII->get(ARM::tLDRpci_pic), NewVReg) - .addConstantPoolIndex(CPI) - .addImm(1) - .addMemOperand(CPMMO); - AddDefaultPred(BuildMI(*MBB, MI, dl, TII->get(ARM::tSTRspi)) - .addReg(NewVReg, RegState::Kill) + if (isThumb2) { + unsigned NewVReg1 = MRI->createVirtualRegister(TRC); + AddDefaultPred(BuildMI(*MBB, MI, dl, TII->get(ARM::t2LDRpci), NewVReg1) + .addConstantPoolIndex(CPI) + .addMemOperand(CPMMO)); + unsigned NewVReg2 = MRI->createVirtualRegister(TRC); + BuildMI(*MBB, MI, dl, TII->get(ARM::tPICADD), NewVReg2) + .addReg(NewVReg1, RegState::Kill) + .addImm(PCLabelId); + AddDefaultPred(BuildMI(*MBB, MI, dl, TII->get(ARM::t2STRi12)) + .addReg(NewVReg2, RegState::Kill) .addFrameIndex(FI) .addImm(36) // &jbuf[1] :: pc .addMemOperand(FIMMO)); + } else if (isThumb) { + // Incoming value: jbuf + // ldr.n r1, LCPI1_4 + // add r1, pc + // add r2, sp, #48 ; &jbuf[1] + // str r1, [r2] + unsigned NewVReg1 = MRI->createVirtualRegister(TRC); + AddDefaultPred(BuildMI(*MBB, MI, dl, TII->get(ARM::tLDRpci), NewVReg1) + .addConstantPoolIndex(CPI) + .addMemOperand(CPMMO)); + unsigned NewVReg2 = MRI->createVirtualRegister(TRC); + BuildMI(*MBB, MI, dl, TII->get(ARM::tPICADD), NewVReg2) + .addReg(NewVReg1) + .addImm(PCLabelId); + unsigned NewVReg3 = MRI->createVirtualRegister(TRC); + AddDefaultPred(BuildMI(*MBB, MI, dl, TII->get(ARM::tADDrSPi), NewVReg3) + .addFrameIndex(FI) + .addImm(36)); // &jbuf[1] :: pc + AddDefaultPred(BuildMI(*MBB, MI, dl, TII->get(ARM::tSTRi)) + .addReg(NewVReg2, RegState::Kill) + .addReg(NewVReg3, RegState::Kill) + .addImm(0) + .addMemOperand(FIMMO)); } else { + // Incoming value: jbuf + // ldr r1, LCPI1_1 + // add r1, pc, r1 + // str r1, [$jbuf, #+4] ; &jbuf[1] unsigned NewVReg1 = MRI->createVirtualRegister(TRC); AddDefaultPred(BuildMI(*MBB, MI, dl, TII->get(ARM::LDRi12), NewVReg1) .addConstantPoolIndex(CPI) @@ -5543,7 +5574,7 @@ unsigned NewVReg2 = MRI->createVirtualRegister(TRC); AddDefaultPred(BuildMI(*MBB, MI, dl, TII->get(ARM::PICADD), NewVReg2) .addReg(NewVReg1, RegState::Kill) - .addImm(1)); + .addImm(PCLabelId)); AddDefaultPred(BuildMI(*MBB, MI, dl, TII->get(ARM::STRi12)) .addReg(NewVReg2, RegState::Kill) .addFrameIndex(FI) From grosbach at apple.com Mon Oct 3 17:48:13 2011 From: grosbach at apple.com (Jim Grosbach) Date: Mon, 03 Oct 2011 15:48:13 -0700 Subject: [llvm-commits] [llvm] r140863 - in /llvm/trunk: lib/Target/ARM/MCTargetDesc/ARMMCTargetDesc.cpp test/CodeGen/ARM/fast-isel.ll test/CodeGen/ARM/hidden-vis-2.ll test/CodeGen/ARM/hidden-vis-3.ll test/CodeGen/ARM/tail-opts.ll test/CodeGen/Thumb2/machine-licm.ll In-Reply-To: References: <20110930174137.A91E42A6C12C@llvm.org> Message-ID: <64B540EC-DBFF-4E2F-8798-F0329460766B@apple.com> It looks like x86_64 is already supposed to default to PIC. Are you seeing examples where that's not working? -Jim On Oct 3, 2011, at 3:19 PM, Evan Cheng wrote: > Since you are making this change, can you fix x86_64 as well? > > Evan > > On Sep 30, 2011, at 10:41 AM, Jim Grosbach wrote: > >> Author: grosbach >> Date: Fri Sep 30 12:41:35 2011 >> New Revision: 140863 >> >> URL: http://llvm.org/viewvc/llvm-project?rev=140863&view=rev >> Log: >> ARM Darwin default relocation model is PIC. >> >> This matches clang, so default options in llc and friends are now closer to >> clang's defaults. >> >> Modified: >> llvm/trunk/lib/Target/ARM/MCTargetDesc/ARMMCTargetDesc.cpp >> llvm/trunk/test/CodeGen/ARM/fast-isel.ll >> llvm/trunk/test/CodeGen/ARM/hidden-vis-2.ll >> llvm/trunk/test/CodeGen/ARM/hidden-vis-3.ll >> llvm/trunk/test/CodeGen/ARM/tail-opts.ll >> llvm/trunk/test/CodeGen/Thumb2/machine-licm.ll >> >> Modified: llvm/trunk/lib/Target/ARM/MCTargetDesc/ARMMCTargetDesc.cpp >> URL: http://llvm.org/viewvc/llvm-project/llvm/trunk/lib/Target/ARM/MCTargetDesc/ARMMCTargetDesc.cpp?rev=140863&r1=140862&r2=140863&view=diff >> ============================================================================== >> --- llvm/trunk/lib/Target/ARM/MCTargetDesc/ARMMCTargetDesc.cpp (original) >> +++ llvm/trunk/lib/Target/ARM/MCTargetDesc/ARMMCTargetDesc.cpp Fri Sep 30 12:41:35 2011 >> @@ -139,8 +139,11 @@ >> static MCCodeGenInfo *createARMMCCodeGenInfo(StringRef TT, Reloc::Model RM, >> CodeModel::Model CM) { >> MCCodeGenInfo *X = new MCCodeGenInfo(); >> - if (RM == Reloc::Default) >> - RM = Reloc::DynamicNoPIC; >> + if (RM == Reloc::Default) { >> + Triple TheTriple(TT); >> + // Default relocation model on Darwin is PIC, not DynamicNoPIC. >> + RM = TheTriple.isOSDarwin() ? Reloc::PIC_ : Reloc::DynamicNoPIC; >> + } >> X->InitMCCodeGenInfo(RM, CM); >> return X; >> } >> >> Modified: llvm/trunk/test/CodeGen/ARM/fast-isel.ll >> URL: http://llvm.org/viewvc/llvm-project/llvm/trunk/test/CodeGen/ARM/fast-isel.ll?rev=140863&r1=140862&r2=140863&view=diff >> ============================================================================== >> --- llvm/trunk/test/CodeGen/ARM/fast-isel.ll (original) >> +++ llvm/trunk/test/CodeGen/ARM/fast-isel.ll Fri Sep 30 12:41:35 2011 >> @@ -1,5 +1,5 @@ >> -; RUN: llc < %s -O0 -fast-isel-abort -mtriple=armv7-apple-darwin | FileCheck %s --check-prefix=ARM >> -; RUN: llc < %s -O0 -fast-isel-abort -mtriple=thumbv7-apple-darwin | FileCheck %s --check-prefix=THUMB >> +; RUN: llc < %s -O0 -fast-isel-abort -relocation-model=dynamic-no-pic -mtriple=armv7-apple-darwin | FileCheck %s --check-prefix=ARM >> +; RUN: llc < %s -O0 -fast-isel-abort -relocation-model=dynamic-no-pic -mtriple=thumbv7-apple-darwin | FileCheck %s --check-prefix=THUMB >> >> ; Very basic fast-isel functionality. >> define i32 @add(i32 %a, i32 %b) nounwind { >> >> Modified: llvm/trunk/test/CodeGen/ARM/hidden-vis-2.ll >> URL: http://llvm.org/viewvc/llvm-project/llvm/trunk/test/CodeGen/ARM/hidden-vis-2.ll?rev=140863&r1=140862&r2=140863&view=diff >> ============================================================================== >> --- llvm/trunk/test/CodeGen/ARM/hidden-vis-2.ll (original) >> +++ llvm/trunk/test/CodeGen/ARM/hidden-vis-2.ll Fri Sep 30 12:41:35 2011 >> @@ -1,4 +1,4 @@ >> -; RUN: llc < %s -mtriple=arm-apple-darwin | FileCheck %s >> +; RUN: llc < %s -relocation-model=dynamic-no-pic -mtriple=arm-apple-darwin | FileCheck %s >> >> @x = weak hidden global i32 0 ; [#uses=1] >> >> >> Modified: llvm/trunk/test/CodeGen/ARM/hidden-vis-3.ll >> URL: http://llvm.org/viewvc/llvm-project/llvm/trunk/test/CodeGen/ARM/hidden-vis-3.ll?rev=140863&r1=140862&r2=140863&view=diff >> ============================================================================== >> --- llvm/trunk/test/CodeGen/ARM/hidden-vis-3.ll (original) >> +++ llvm/trunk/test/CodeGen/ARM/hidden-vis-3.ll Fri Sep 30 12:41:35 2011 >> @@ -1,4 +1,4 @@ >> -; RUN: llc < %s -mtriple=arm-apple-darwin9 | FileCheck %s >> +; RUN: llc < %s -relocation-model=dynamic-no-pic -mtriple=arm-apple-darwin9 | FileCheck %s >> >> @x = external hidden global i32 ; [#uses=1] >> @y = extern_weak hidden global i32 ; [#uses=1] >> >> Modified: llvm/trunk/test/CodeGen/ARM/tail-opts.ll >> URL: http://llvm.org/viewvc/llvm-project/llvm/trunk/test/CodeGen/ARM/tail-opts.ll?rev=140863&r1=140862&r2=140863&view=diff >> ============================================================================== >> --- llvm/trunk/test/CodeGen/ARM/tail-opts.ll (original) >> +++ llvm/trunk/test/CodeGen/ARM/tail-opts.ll Fri Sep 30 12:41:35 2011 >> @@ -1,4 +1,4 @@ >> -; RUN: llc < %s -mtriple=arm-apple-darwin -mcpu=cortex-a8 -asm-verbose=false | FileCheck %s >> +; RUN: llc < %s -mtriple=arm-apple-darwin -relocation-model=dynamic-no-pic -mcpu=cortex-a8 -asm-verbose=false | FileCheck %s >> >> declare void @bar(i32) >> declare void @car(i32) >> >> Modified: llvm/trunk/test/CodeGen/Thumb2/machine-licm.ll >> URL: http://llvm.org/viewvc/llvm-project/llvm/trunk/test/CodeGen/Thumb2/machine-licm.ll?rev=140863&r1=140862&r2=140863&view=diff >> ============================================================================== >> --- llvm/trunk/test/CodeGen/Thumb2/machine-licm.ll (original) >> +++ llvm/trunk/test/CodeGen/Thumb2/machine-licm.ll Fri Sep 30 12:41:35 2011 >> @@ -1,4 +1,4 @@ >> -; RUN: llc < %s -mtriple=thumbv7-apple-darwin -mcpu=cortex-a8 -disable-fp-elim | FileCheck %s >> +; RUN: llc < %s -mtriple=thumbv7-apple-darwin -mcpu=cortex-a8 -relocation-model=dynamic-no-pic -disable-fp-elim | FileCheck %s >> ; RUN: llc < %s -mtriple=thumbv7-apple-darwin -mcpu=cortex-a8 -relocation-model=pic -disable-fp-elim | FileCheck %s --check-prefix=PIC >> ; rdar://7353541 >> ; rdar://7354376 >> >> >> _______________________________________________ >> llvm-commits mailing list >> llvm-commits at cs.uiuc.edu >> http://lists.cs.uiuc.edu/mailman/listinfo/llvm-commits > From atrick at apple.com Mon Oct 3 17:57:09 2011 From: atrick at apple.com (Andrew Trick) Date: Mon, 03 Oct 2011 15:57:09 -0700 Subject: [llvm-commits] patch: chrec * chrec = chrec. In-Reply-To: <4E88F8E3.3050506@mxc.ca> References: <4E88F8E3.3050506@mxc.ca> Message-ID: On Oct 2, 2011, at 4:50 PM, Nick Lewycky wrote: > This patch is a follow-up to r139133 which corrected SCEV's getMulExpr when given two chrec arguments. Here I extend it to correctly multiply chrecs of any length. > > The meat of this patch is a pure blob of illegible math. If you want to do a hard review, I would suggest: > - trying to derive the formula I used in the comment to calculate the terms of the new chrec > - proving to yourself a coefficient that doesn't fit can safely be truncated > > If you want to do an easier review, I would suggest running it over code. This will fire in 447.dealII for example. > > I know that other work is going on in the loop optimizer right now which I don't want to interfere with, so please let me know when wouldn't be a bad time to land this. > > Nick > Nick, I don't have a problem with you landing this whenever you can. As long as I don't have to vouch for correctness of the math. More comments would help in this regard. Not being a math major, it wasn't obvious to me that you're computing binomial coefficients here. The reference to a benchmark is quite helpful, and the unit tests give me a good feeling. I'm aware of the problem with verifying SCEV equivalence. I would love to an equivalence checker that can run in assert mode, but it's pretty low on my todo list now. -Andy From grosbach at apple.com Mon Oct 3 18:03:27 2011 From: grosbach at apple.com (Jim Grosbach) Date: Mon, 03 Oct 2011 23:03:27 -0000 Subject: [llvm-commits] [llvm] r141043 - /llvm/trunk/lib/Target/ARM/MCTargetDesc/ARMAddressingModes.h Message-ID: <20111003230328.1768A2A6C12C@llvm.org> Author: grosbach Date: Mon Oct 3 18:03:26 2011 New Revision: 141043 URL: http://llvm.org/viewvc/llvm-project?rev=141043&view=rev Log: Tidy up. 80 columns. Modified: llvm/trunk/lib/Target/ARM/MCTargetDesc/ARMAddressingModes.h Modified: llvm/trunk/lib/Target/ARM/MCTargetDesc/ARMAddressingModes.h URL: http://llvm.org/viewvc/llvm-project/llvm/trunk/lib/Target/ARM/MCTargetDesc/ARMAddressingModes.h?rev=141043&r1=141042&r2=141043&view=diff ============================================================================== --- llvm/trunk/lib/Target/ARM/MCTargetDesc/ARMAddressingModes.h (original) +++ llvm/trunk/lib/Target/ARM/MCTargetDesc/ARMAddressingModes.h Mon Oct 3 18:03:26 2011 @@ -637,7 +637,7 @@ /// floating-point value, then return -1. static inline int getFP64Imm(const APInt &Imm) { uint64_t Sign = Imm.lshr(63).getZExtValue() & 1; - int64_t Exp = (Imm.lshr(52).getSExtValue() & 0x7ff) - 1023; // -1022 to 1023 + int64_t Exp = (Imm.lshr(52).getSExtValue() & 0x7ff) - 1023; // -1022 to 1023 uint64_t Mantissa = Imm.getZExtValue() & 0xfffffffffffffULL; // We can handle 4 bits of mantissa. From joerg at britannica.bec.de Mon Oct 3 18:27:26 2011 From: joerg at britannica.bec.de (Joerg Sonnenberger) Date: Tue, 4 Oct 2011 01:27:26 +0200 Subject: [llvm-commits] patch: chrec * chrec = chrec. In-Reply-To: References: <4E88F8E3.3050506@mxc.ca> <20111003205157.GA10434@britannica.bec.de> Message-ID: <20111003232726.GA13292@britannica.bec.de> On Mon, Oct 03, 2011 at 02:10:45PM -0700, Nick Lewycky wrote: > On 3 October 2011 13:51, Joerg Sonnenberger wrote: > > What exactly is the desired behavior in case of overflow? > > E.g. do you want to get C(n,k) % (UINTMAX + 1)? In that case, your > > formula doesn't compute correct results. > > > > In overflow the return value is garbage and Overflow is set. This method > deserves a comment. >From IRC: since n is supposed to be small, it might be better to just check for n <= 34 and consider it as overflow otherwise. Essentially, that's the largest number for which C(2n,n) < 2**32. In theory, it would be possible to compute C(n,k) in the finite field by eliminating the factors 2 in the divisor and implementing the division using the multiplicative inverse at the end. That's quite a bit more work though. Joerg From grosbach at apple.com Mon Oct 3 18:38:41 2011 From: grosbach at apple.com (Jim Grosbach) Date: Mon, 03 Oct 2011 23:38:41 -0000 Subject: [llvm-commits] [llvm] r141046 - in /llvm/trunk: lib/Target/ARM/ARMInstrVFP.td lib/Target/ARM/AsmParser/ARMAsmParser.cpp test/MC/ARM/simple-fp-encoding.s Message-ID: <20111003233841.929B42A6C12C@llvm.org> Author: grosbach Date: Mon Oct 3 18:38:36 2011 New Revision: 141046 URL: http://llvm.org/viewvc/llvm-project?rev=141046&view=rev Log: ARM assembly parsing and encoding for VMOV immediate. Modified: llvm/trunk/lib/Target/ARM/ARMInstrVFP.td llvm/trunk/lib/Target/ARM/AsmParser/ARMAsmParser.cpp llvm/trunk/test/MC/ARM/simple-fp-encoding.s Modified: llvm/trunk/lib/Target/ARM/ARMInstrVFP.td URL: http://llvm.org/viewvc/llvm-project/llvm/trunk/lib/Target/ARM/ARMInstrVFP.td?rev=141046&r1=141045&r2=141046&view=diff ============================================================================== --- llvm/trunk/lib/Target/ARM/ARMInstrVFP.td (original) +++ llvm/trunk/lib/Target/ARM/ARMInstrVFP.td Mon Oct 3 18:38:36 2011 @@ -31,6 +31,12 @@ // Operand Definitions. // +// 8-bit floating-point immediate encodings. +def FPImmOperand : AsmOperandClass { + let Name = "FPImm"; + let ParserMethod = "parseFPImm"; +} + def vfp_f32imm : Operand, PatLeaf<(f32 fpimm), [{ return ARM_AM::getFP32Imm(N->getValueAPF()) != -1; @@ -40,6 +46,7 @@ return CurDAG->getTargetConstant(enc, MVT::i32); }]>> { let PrintMethod = "printFPImmOperand"; + let ParserMatchClass = FPImmOperand; } def vfp_f64imm : Operand, @@ -51,6 +58,7 @@ return CurDAG->getTargetConstant(enc, MVT::i32); }]>> { let PrintMethod = "printFPImmOperand"; + let ParserMatchClass = FPImmOperand; } Modified: llvm/trunk/lib/Target/ARM/AsmParser/ARMAsmParser.cpp URL: http://llvm.org/viewvc/llvm-project/llvm/trunk/lib/Target/ARM/AsmParser/ARMAsmParser.cpp?rev=141046&r1=141045&r2=141046&view=diff ============================================================================== --- llvm/trunk/lib/Target/ARM/AsmParser/ARMAsmParser.cpp (original) +++ llvm/trunk/lib/Target/ARM/AsmParser/ARMAsmParser.cpp Mon Oct 3 18:38:36 2011 @@ -158,6 +158,7 @@ OperandMatchResultTy parseBitfield(SmallVectorImpl&); OperandMatchResultTy parsePostIdxReg(SmallVectorImpl&); OperandMatchResultTy parseAM3Offset(SmallVectorImpl&); + OperandMatchResultTy parseFPImm(SmallVectorImpl&); // Asm Match Converter Methods bool cvtT2LdrdPre(MCInst &Inst, unsigned Opcode, @@ -247,6 +248,7 @@ CoprocNum, CoprocReg, Immediate, + FPImmediate, MemBarrierOpt, Memory, PostIndexRegister, @@ -305,6 +307,10 @@ const MCExpr *Val; } Imm; + struct { + unsigned Val; // encoded 8-bit representation + } FPImm; + /// Combined record for all forms of ARM address expressions. struct { unsigned BaseRegNum; @@ -380,6 +386,9 @@ case Immediate: Imm = o.Imm; break; + case FPImmediate: + FPImm = o.FPImm; + break; case MemBarrierOpt: MBOpt = o.MBOpt; break; @@ -449,6 +458,11 @@ return Imm.Val; } + unsigned getFPImm() const { + assert(Kind == FPImmediate && "Invalid access!"); + return FPImm.Val; + } + ARM_MB::MemBOpt getMemBarrierOpt() const { assert(Kind == MemBarrierOpt && "Invalid access!"); return MBOpt.Val; @@ -471,6 +485,7 @@ bool isITMask() const { return Kind == ITCondMask; } bool isITCondCode() const { return Kind == CondCode; } bool isImm() const { return Kind == Immediate; } + bool isFPImm() const { return Kind == FPImmediate; } bool isImm8s4() const { if (Kind != Immediate) return false; @@ -952,6 +967,11 @@ addExpr(Inst, getImm()); } + void addFPImmOperands(MCInst &Inst, unsigned N) const { + assert(N == 1 && "Invalid number of operands!"); + Inst.addOperand(MCOperand::CreateImm(getFPImm())); + } + void addImm8s4Operands(MCInst &Inst, unsigned N) const { assert(N == 1 && "Invalid number of operands!"); // FIXME: We really want to scale the value here, but the LDRD/STRD @@ -1467,6 +1487,14 @@ return Op; } + static ARMOperand *CreateFPImm(unsigned Val, SMLoc S, MCContext &Ctx) { + ARMOperand *Op = new ARMOperand(FPImmediate); + Op->FPImm.Val = Val; + Op->StartLoc = S; + Op->EndLoc = S; + return Op; + } + static ARMOperand *CreateMem(unsigned BaseRegNum, const MCConstantExpr *OffsetImm, unsigned OffsetRegNum, @@ -1529,6 +1557,10 @@ void ARMOperand::print(raw_ostream &OS) const { switch (Kind) { + case FPImmediate: + OS << ""; + break; case CondCode: OS << ""; break; @@ -3024,6 +3056,50 @@ return false; } +/// parseFPImm - A floating point immediate expression operand. +ARMAsmParser::OperandMatchResultTy ARMAsmParser:: +parseFPImm(SmallVectorImpl &Operands) { + SMLoc S = Parser.getTok().getLoc(); + + if (Parser.getTok().isNot(AsmToken::Hash)) + return MatchOperand_NoMatch; + Parser.Lex(); // Eat the '#'. + + // Handle negation, as that still comes through as a separate token. + bool isNegative = false; + if (Parser.getTok().is(AsmToken::Minus)) { + isNegative = true; + Parser.Lex(); + } + const AsmToken &Tok = Parser.getTok(); + if (Tok.is(AsmToken::Real)) { + APFloat RealVal(APFloat::IEEEdouble, Tok.getString()); + uint64_t IntVal = RealVal.bitcastToAPInt().getZExtValue(); + // If we had a '-' in front, toggle the sign bit. + IntVal ^= (uint64_t)isNegative << 63; + int Val = ARM_AM::getFP64Imm(APInt(64, IntVal)); + Parser.Lex(); // Eat the token. + if (Val == -1) { + TokError("floating point value out of range"); + return MatchOperand_ParseFail; + } + Operands.push_back(ARMOperand::CreateFPImm(Val, S, getContext())); + return MatchOperand_Success; + } + if (Tok.is(AsmToken::Integer)) { + int64_t Val = Tok.getIntVal(); + Parser.Lex(); // Eat the token. + if (Val > 255 || Val < 0) { + TokError("encoded floating point value out of range"); + return MatchOperand_ParseFail; + } + Operands.push_back(ARMOperand::CreateFPImm(Val, S, getContext())); + return MatchOperand_Success; + } + + TokError("invalid floating point immediate"); + return MatchOperand_ParseFail; +} /// Parse a arm instruction operand. For now this parses the operand regardless /// of the mnemonic. bool ARMAsmParser::parseOperand(SmallVectorImpl &Operands, Modified: llvm/trunk/test/MC/ARM/simple-fp-encoding.s URL: http://llvm.org/viewvc/llvm-project/llvm/trunk/test/MC/ARM/simple-fp-encoding.s?rev=141046&r1=141045&r2=141046&view=diff ============================================================================== --- llvm/trunk/test/MC/ARM/simple-fp-encoding.s (original) +++ llvm/trunk/test/MC/ARM/simple-fp-encoding.s Mon Oct 3 18:38:36 2011 @@ -141,11 +141,15 @@ @ CHECK: vmsr fpsid, r0 @ encoding: [0x10,0x0a,0xe0,0xee] vmsr fpsid, r0 -@ FIXME: vmov.f64 d16, #3.000000e+00 @ encoding: [0x08,0x0b,0xf0,0xee] -@ vmov.f64 d16, #3.000000e+00 - -@ FIXME: vmov.f32 s0, #3.000000e+00 @ encoding: [0x08,0x0a,0xb0,0xee] -@ vmov.f32 s0, #3.000000e+00 + vmov.f64 d16, #3.000000e+00 + vmov.f32 s0, #3.000000e+00 + vmov.f64 d16, #-3.000000e+00 + vmov.f32 s0, #-3.000000e+00 + +@ CHECK: vmov.f64 d16, #3.000000e+00 @ encoding: [0x08,0x0b,0xf0,0xee] +@ CHECK: vmov.f32 s0, #3.000000e+00 @ encoding: [0x08,0x0a,0xb0,0xee] +@ CHECK: vmov.f64 d16, #-3.000000e+00 @ encoding: [0x08,0x0b,0xf8,0xee] +@ CHECK: vmov.f32 s0, #-3.000000e+00 @ encoding: [0x08,0x0a,0xb8,0xee] @ CHECK: vmov s0, r0 @ encoding: [0x10,0x0a,0x00,0xee] @ CHECK: vmov s1, r1 @ encoding: [0x90,0x1a,0x00,0xee] From grosbach at apple.com Mon Oct 3 18:40:13 2011 From: grosbach at apple.com (Jim Grosbach) Date: Mon, 03 Oct 2011 23:40:13 -0000 Subject: [llvm-commits] [llvm] r141047 - /llvm/trunk/test/MC/ARM/simple-encoding.ll Message-ID: <20111003234013.7FD5D2A6C12C@llvm.org> Author: grosbach Date: Mon Oct 3 18:40:13 2011 New Revision: 141047 URL: http://llvm.org/viewvc/llvm-project?rev=141047&view=rev Log: Tidy up. These tests are covered in the .s file tests now. Removed: llvm/trunk/test/MC/ARM/simple-encoding.ll Removed: llvm/trunk/test/MC/ARM/simple-encoding.ll URL: http://llvm.org/viewvc/llvm-project/llvm/trunk/test/MC/ARM/simple-encoding.ll?rev=141046&view=auto ============================================================================== --- llvm/trunk/test/MC/ARM/simple-encoding.ll (original) +++ llvm/trunk/test/MC/ARM/simple-encoding.ll (removed) @@ -1,236 +0,0 @@ -;RUN: llc -mtriple=armv7-apple-darwin -show-mc-encoding -disable-cgp-branch-opts -join-physregs < %s | FileCheck %s - - -;FIXME: Once the ARM integrated assembler is up and going, these sorts of tests -; should run on .s source files rather than using llc to generate the -; assembly. There's also a large number of instruction encodings the -; compiler never generates, so we need the integrated assembler to be -; able to test those at all. - -declare void @llvm.trap() nounwind -declare i32 @llvm.ctlz.i32(i32) - -define i32 @foo(i32 %a, i32 %b) { -; CHECK: foo -; CHECK: trap @ encoding: [0xfe,0xde,0xff,0xe7] -; CHECK: bx lr @ encoding: [0x1e,0xff,0x2f,0xe1] - - tail call void @llvm.trap() - ret i32 undef -} - -define i32 @f2(i32 %a, i32 %b) { -; CHECK: f2 -; CHECK: add r0, r1, r0 @ encoding: [0x00,0x00,0x81,0xe0] -; CHECK: bx lr @ encoding: [0x1e,0xff,0x2f,0xe1] - %add = add nsw i32 %b, %a - ret i32 %add -} - - -define i32 @f3(i32 %a, i32 %b) { -; CHECK: f3 -; CHECK: add r0, r0, r1, lsl #3 @ encoding: [0x81,0x01,0x80,0xe0] -; CHECK: bx lr @ encoding: [0x1e,0xff,0x2f,0xe1] - %mul = shl i32 %b, 3 - %add = add nsw i32 %mul, %a - ret i32 %add -} - -define i32 @f4(i32 %a, i32 %b) { -; CHECK: f4 -; CHECK: add r0, r0, #4064 @ encoding: [0xfe,0x0e,0x80,0xe2] -; CHECK: bx lr @ encoding: [0x1e,0xff,0x2f,0xe1] - %add = add nsw i32 %a, 4064 - ret i32 %add -} - -define i32 @f5(i32 %a, i32 %b, i32 %c) { -; CHECK: f5 -; CHECK: cmp r0, r1 @ encoding: [0x01,0x00,0x50,0xe1] -; CHECK: mov r0, r2 @ encoding: [0x02,0x00,0xa0,0xe1] -; CHECK: movgt r0, r1 @ encoding: [0x01,0x00,0xa0,0xc1] - %cmp = icmp sgt i32 %a, %b - %retval.0 = select i1 %cmp, i32 %b, i32 %c - ret i32 %retval.0 -} - -define i64 @f6(i64 %a, i64 %b, i64 %c) { -; CHECK: f6 -; CHECK: adds r0, r2, r0 @ encoding: [0x00,0x00,0x92,0xe0] -; CHECK: adc r1, r3, r1 @ encoding: [0x01,0x10,0xa3,0xe0] - %add = add nsw i64 %b, %a - ret i64 %add -} - -define i32 @f7(i32 %a, i32 %b) { -; CHECK: f7 -; CHECK: uxtab r0, r0, r1 @ encoding: [0x71,0x00,0xe0,0xe6] - %and = and i32 %b, 255 - %add = add i32 %and, %a - ret i32 %add -} - -define i32 @f8(i32 %a) { -; CHECK: f8 -; CHECK: movt r0, #42405 @ encoding: [0xa5,0x05,0x4a,0xe3] - %and = and i32 %a, 65535 - %or = or i32 %and, -1515913216 - ret i32 %or -} - -define i32 @f9() { -; CHECK: f9 -; CHECK: movw r0, #42405 @ encoding: [0xa5,0x05,0x0a,0xe3] - ret i32 42405 -} - -define i64 @f10(i64 %a) { -; CHECK: f10 -; CHECK: asrs r1, r1, #1 @ encoding: [0xc1,0x10,0xb0,0xe1] -; CHECK: rrx r0, r0 @ encoding: [0x60,0x00,0xa0,0xe1] - %shr = ashr i64 %a, 1 - ret i64 %shr -} - -define i32 @f11([1 x i32] %A.coerce0, [1 x i32] %B.coerce0) { -; CHECK: f11 -; CHECK: ubfx r1, r1, #8, #5 @ encoding: [0x51,0x14,0xe4,0xe7] -; CHECK: sbfx r0, r0, #13, #7 @ encoding: [0xd0,0x06,0xa6,0xe7] - %tmp1 = extractvalue [1 x i32] %A.coerce0, 0 - %tmp2 = extractvalue [1 x i32] %B.coerce0, 0 - %tmp3 = shl i32 %tmp1, 12 - %bf.val.sext = ashr i32 %tmp3, 25 - %tmp4 = lshr i32 %tmp2, 8 - %bf.clear2 = and i32 %tmp4, 31 - %mul = mul nsw i32 %bf.val.sext, %bf.clear2 - ret i32 %mul -} - -define i32 @f12(i32 %a) { -; CHECK: f12: -; CHECK: bfc r0, #4, #20 @ encoding: [0x1f,0x02,0xd7,0xe7] - %tmp = and i32 %a, 4278190095 - ret i32 %tmp -} - -define i64 @f13() { -; CHECK: f13: -; CHECK: mvn r0, #0 @ encoding: [0x00,0x00,0xe0,0xe3] -; CHECK: mvn r1, #-2147483648 @ encoding: [0x02,0x11,0xe0,0xe3] - ret i64 9223372036854775807 -} - -define i32 @f14(i32 %x, i32 %y) { -; CHECK: f14: -; CHECK: smmul r0, r1, r0 @ encoding: [0x11,0xf0,0x50,0xe7] - %tmp = sext i32 %x to i64 - %tmp1 = sext i32 %y to i64 - %tmp2 = mul i64 %tmp1, %tmp - %tmp3 = lshr i64 %tmp2, 32 - %tmp3.upgrd.1 = trunc i64 %tmp3 to i32 - ret i32 %tmp3.upgrd.1 -} - -define i32 @f15(i32 %x, i32 %y) { -; CHECK: f15: -; CHECK: umull r1, r0, r1, r0 @ encoding: [0x91,0x10,0x80,0xe0] - %tmp = zext i32 %x to i64 - %tmp1 = zext i32 %y to i64 - %tmp2 = mul i64 %tmp1, %tmp - %tmp3 = lshr i64 %tmp2, 32 - %tmp3.upgrd.2 = trunc i64 %tmp3 to i32 - ret i32 %tmp3.upgrd.2 -} - -define i32 @f16(i16 %x, i32 %y) { -; CHECK: f16: -; CHECK: smulbt r0, r0, r1 @ encoding: [0xc0,0x01,0x60,0xe1] - %tmp1 = add i16 %x, 2 - %tmp2 = sext i16 %tmp1 to i32 - %tmp3 = ashr i32 %y, 16 - %tmp4 = mul i32 %tmp2, %tmp3 - ret i32 %tmp4 -} - -define i32 @f17(i32 %x, i32 %y) { -; CHECK: f17: -; CHECK: smultt r0, r1, r0 @ encoding: [0xe1,0x00,0x60,0xe1] - %tmp1 = ashr i32 %x, 16 - %tmp3 = ashr i32 %y, 16 - %tmp4 = mul i32 %tmp3, %tmp1 - ret i32 %tmp4 -} - -define i32 @f18(i32 %a, i16 %x, i32 %y) { -; CHECK: f18: -; CHECK: smlabt r0, r1, r2, r0 @ encoding: [0xc1,0x02,0x00,0xe1] - %tmp = sext i16 %x to i32 - %tmp2 = ashr i32 %y, 16 - %tmp3 = mul i32 %tmp2, %tmp - %tmp5 = add i32 %tmp3, %a - ret i32 %tmp5 -} - -define i32 @f19(i32 %x) { -; CHECK: f19 -; CHECK: clz r0, r0 @ encoding: [0x10,0x0f,0x6f,0xe1] - %tmp.1 = call i32 @llvm.ctlz.i32( i32 %x ) - ret i32 %tmp.1 -} - -define i32 @f20(i32 %X) { -; CHECK: f20 -; CHECK: rev16 r0, r0 @ encoding: [0xb0,0x0f,0xbf,0xe6] - %tmp1 = lshr i32 %X, 8 - %X15 = bitcast i32 %X to i32 - %tmp4 = shl i32 %X15, 8 - %tmp2 = and i32 %tmp1, 16711680 - %tmp5 = and i32 %tmp4, -16777216 - %tmp9 = and i32 %tmp1, 255 - %tmp13 = and i32 %tmp4, 65280 - %tmp6 = or i32 %tmp5, %tmp2 - %tmp10 = or i32 %tmp6, %tmp13 - %tmp14 = or i32 %tmp10, %tmp9 - ret i32 %tmp14 -} - -define i32 @f21(i32 %X) { -; CHECK: f21 -; CHECK: revsh r0, r0 @ encoding: [0xb0,0x0f,0xff,0xe6] - %tmp1 = lshr i32 %X, 8 - %tmp1.upgrd.1 = trunc i32 %tmp1 to i16 - %tmp3 = trunc i32 %X to i16 - %tmp2 = and i16 %tmp1.upgrd.1, 255 - %tmp4 = shl i16 %tmp3, 8 - %tmp5 = or i16 %tmp2, %tmp4 - %tmp5.upgrd.2 = sext i16 %tmp5 to i32 - ret i32 %tmp5.upgrd.2 -} - -define i32 @f22(i32 %X, i32 %Y) { -; CHECK: f22 -; CHECK: pkhtb r0, r0, r1, asr #22 @ encoding: [0x51,0x0b,0x80,0xe6] - %tmp1 = and i32 %X, -65536 - %tmp2 = lshr i32 %Y, 22 - %tmp3 = or i32 %tmp2, %tmp1 - ret i32 %tmp3 -} - -define i32 @f23(i32 %X, i32 %Y) { -; CHECK: f23 -; CHECK: pkhbt r0, r0, r1, lsl #18 @ encoding: [0x11,0x09,0x80,0xe6] - %tmp1 = and i32 %X, 65535 - %tmp2 = shl i32 %Y, 18 - %tmp3 = or i32 %tmp1, %tmp2 - ret i32 %tmp3 -} - -define void @f24(i32 %a) { -; CHECK: f24 -; CHECK: cmp r0, #65536 @ encoding: [0x01,0x08,0x50,0xe3] - %b = icmp ugt i32 %a, 65536 - br i1 %b, label %r, label %r -r: - ret void -} From peter at pcc.me.uk Mon Oct 3 18:48:49 2011 From: peter at pcc.me.uk (Peter Collingbourne) Date: Tue, 4 Oct 2011 00:48:49 +0100 Subject: [llvm-commits] [llvm] r140951 - in /llvm/trunk: ./ include/llvm/TableGen/ lib/ lib/TableGen/ utils/TableGen/ In-Reply-To: References: <20111001164115.E37E82A6C12C@llvm.org> Message-ID: <20111003234849.GA27357@pcc.me.uk> Hi Chris, > What direction are you going here? My intention is to move the Clang tblgen backends into the Clang source tree by building the tblgen parser out into a library that can be used to create tblgen-like tools, and creating LLVM and Clang utilities which contain their respective backends and which are clients of that library. I'm trying to achieve this incrementally, by first creating a TableGen library containing the parser and most of 'main'. Currently tblgen is the only client, but I hope to replace this with llvm-tblgen and clang-tblgen utilities. > Are you committed to fixing these problems as follow-ons? To address these issues: > 1. All of the 'main' code and the top-level cl::opt's should be in utils/tablegen, not in TableGen/Main.h Since llvm-tblgen and clang-tblgen would share most of the implementation of their 'main' functions, I think it makes sense to also put most of that code in the library. The TableGenAction class allows for tools to provide the relevant part of 'main' that calls out to their backends. I have noticed that this change is causing problems for shared library users [1], and I apologise for not anticipating this. I think that as a single-purpose library, TableGen does not belong in the shared library, so the most logical way to resolve this problem is to exclude it from the shared library. > 2. The tablegen headers (like the rest of it :) are a mess, they are not split properly between public and private headers. I think that to begin with, the TableGen public interface should provide the bare minimum to allow clients to write their own tblgen-like tools. To this end, the public interface consists of the backend base class, the TableGenAction base class, the Record data structure definitions and the 'TableGenMain' function. I believe that I've largely achieved this split with the current set of header files in include/llvm/TableGen. > 3. The tblgen code uses RTTI and EH, which none of the rest of the LLVM libraries do. > > So long as RTTI and EH don't invade tools other than the utils/TableGen executable, I'm ok with continuing to forget about #3, but #1 and #2 are pretty important. I'm not addressing this problem. The TableGen library and its clients will be built with RTTI and EH. Thanks, -- Peter [1] http://lists.cs.uiuc.edu/pipermail/llvmdev/2011-October/043687.html From bigcheesegs at gmail.com Mon Oct 3 19:02:38 2011 From: bigcheesegs at gmail.com (Michael Spencer) Date: Mon, 3 Oct 2011 17:02:38 -0700 Subject: [llvm-commits] [llvm] r139314 - in /llvm/trunk: include/llvm/Object/COFF.h include/llvm/Object/ObjectFile.h lib/Object/COFFObjectFile.cpp lib/Object/ELFObjectFile.cpp lib/Object/MachOObjectFile.cpp In-Reply-To: <20110908205217.935612A6C12C@llvm.org> References: <20110908205217.935612A6C12C@llvm.org> Message-ID: On Thu, Sep 8, 2011 at 1:52 PM, Benjamin Kramer wrote: > Author: d0k > Date: Thu Sep ?8 15:52:17 2011 > New Revision: 139314 > > URL: http://llvm.org/viewvc/llvm-project?rev=139314&view=rev > Log: > Add support for relocations to ObjectFile. > > Patch by Danil Malyshev! > > Modified: > ? ?llvm/trunk/include/llvm/Object/COFF.h > ? ?llvm/trunk/include/llvm/Object/ObjectFile.h > ? ?llvm/trunk/lib/Object/COFFObjectFile.cpp > ? ?llvm/trunk/lib/Object/ELFObjectFile.cpp > ? ?llvm/trunk/lib/Object/MachOObjectFile.cpp > > Modified: llvm/trunk/include/llvm/Object/COFF.h > URL: http://llvm.org/viewvc/llvm-project/llvm/trunk/include/llvm/Object/COFF.h?rev=139314&r1=139313&r2=139314&view=diff > ============================================================================== > --- llvm/trunk/include/llvm/Object/COFF.h (original) > +++ llvm/trunk/include/llvm/Object/COFF.h Thu Sep ?8 15:52:17 2011 > @@ -67,6 +67,12 @@ > ? support::ulittle32_t Characteristics; > ?}; > > +struct coff_relocation { > + ?support::ulittle32_t VirtualAddress; > + ?support::ulittle32_t SymbolTableIndex; > + ?support::ulittle16_t Type; > +}; > + > ?class COFFObjectFile : public ObjectFile { > ?private: > ? const coff_file_header *Header; > @@ -81,6 +87,7 @@ > > ? const coff_symbol ? ? ?*toSymb(DataRefImpl Symb) const; > ? const coff_section ? ? *toSec(DataRefImpl Sec) const; > + ?const coff_relocation ?*toRel(DataRefImpl Rel) const; > > ?protected: > ? virtual error_code getSymbolNext(DataRefImpl Symb, SymbolRef &Res) const; > @@ -99,12 +106,24 @@ > ? virtual error_code sectionContainsSymbol(DataRefImpl Sec, DataRefImpl Symb, > ? ? ? ? ? ? ? ? ? ? ? ? ? ? ? ? ? ? ? ? ? ?bool &Result) const; > > + ?virtual error_code getRelocationNext(DataRefImpl Rel, > + ? ? ? ? ? ? ? ? ? ? ? ? ? ? ? ? ? ? ? RelocationRef &Res) const; > + ?virtual error_code getRelocationAddress(DataRefImpl Rel, > + ? ? ? ? ? ? ? ? ? ? ? ? ? ? ? ? ? ? ? ? ?uint64_t &Res) const; > + ?virtual error_code getRelocationSymbol(DataRefImpl Rel, > + ? ? ? ? ? ? ? ? ? ? ? ? ? ? ? ? ? ? ? ? SymbolRef &Res) const; > + ?virtual error_code getRelocationType(DataRefImpl Rel, > + ? ? ? ? ? ? ? ? ? ? ? ? ? ? ? ? ? ? ? uint32_t &Res) const; > + ?virtual error_code getRelocationAdditionalInfo(DataRefImpl Rel, > + ? ? ? ? ? ? ? ? ? ? ? ? ? ? ? ? ? ? ? ? ? ? ? ? int64_t &Res) const; > ?public: > ? COFFObjectFile(MemoryBuffer *Object, error_code &ec); > ? virtual symbol_iterator begin_symbols() const; > ? virtual symbol_iterator end_symbols() const; > ? virtual section_iterator begin_sections() const; > ? virtual section_iterator end_sections() const; > + ?virtual relocation_iterator begin_relocations() const; > + ?virtual relocation_iterator end_relocations() const; > > ? virtual uint8_t getBytesInAddress() const; > ? virtual StringRef getFileFormatName() const; > > Modified: llvm/trunk/include/llvm/Object/ObjectFile.h > URL: http://llvm.org/viewvc/llvm-project/llvm/trunk/include/llvm/Object/ObjectFile.h?rev=139314&r1=139313&r2=139314&view=diff > ============================================================================== > --- llvm/trunk/include/llvm/Object/ObjectFile.h (original) > +++ llvm/trunk/include/llvm/Object/ObjectFile.h Thu Sep ?8 15:52:17 2011 > @@ -39,22 +39,6 @@ > ? return std::memcmp(&a, &b, sizeof(DataRefImpl)) == 0; > ?} > > -class RelocationRef { > - ?DataRefImpl RelocationPimpl; > - ?const ObjectFile *OwningObject; > - > -public: > - ?RelocationRef() : OwningObject(NULL) { > - ? ?std::memset(&RelocationPimpl, 0, sizeof(RelocationPimpl)); > - ?} > - > - ?RelocationRef(DataRefImpl RelocationP, const ObjectFile *Owner); > - > - ?bool operator==(const RelocationRef &Other) const; > - > - ?error_code getNext(RelocationRef &Result); > -}; > - > ?/// SymbolRef - This is a value type class that represents a single symbol in > ?/// the list of symbols in the object file. > ?class SymbolRef { > @@ -86,6 +70,29 @@ > ? error_code isInternal(bool &Result) const; > ?}; > > +/// RelocationRef - This is a value type class that represents a single > +/// relocation in the list of relocations in the object file. > +class RelocationRef { > + ?DataRefImpl RelocationPimpl; > + ?const ObjectFile *OwningObject; > + > +public: > + ?RelocationRef() : OwningObject(NULL) { > + ? ?std::memset(&RelocationPimpl, 0, sizeof(RelocationPimpl)); > + ?} > + > + ?RelocationRef(DataRefImpl RelocationP, const ObjectFile *Owner); > + > + ?bool operator==(const RelocationRef &Other) const; > + > + ?error_code getNext(RelocationRef &Result) const; > + > + ?error_code getAddress(uint64_t &Result) const; > + ?error_code getSymbol(SymbolRef &Result) const; > + ?error_code getType(uint32_t &Result) const; > + ?error_code getAdditionalInfo(int64_t &Result) const; > +}; > + > ?/// SectionRef - This is a value type class that represents a single section in > ?/// the list of sections in the object file. > ?class SectionRef { > @@ -160,6 +167,19 @@ > ? ? ? ? ? ? ? ? ? ? ? ? ? ? ? ? ? ? ? ? ? ?bool &Result) const = 0; > > > + ?// Same as above for RelocationRef. > + ?friend class RelocationRef; > + ?virtual error_code getRelocationNext(DataRefImpl Rel, > + ? ? ? ? ? ? ? ? ? ? ? ? ? ? ? ? ? ? ? RelocationRef &Res) const = 0; > + ?virtual error_code getRelocationAddress(DataRefImpl Rel, > + ? ? ? ? ? ? ? ? ? ? ? ? ? ? ? ? ? ? ? ? ?uint64_t &Res) const =0; > + ?virtual error_code getRelocationSymbol(DataRefImpl Rel, > + ? ? ? ? ? ? ? ? ? ? ? ? ? ? ? ? ? ? ? ? SymbolRef &Res) const = 0; > + ?virtual error_code getRelocationType(DataRefImpl Rel, > + ? ? ? ? ? ? ? ? ? ? ? ? ? ? ? ? ? ? ? uint32_t &Res) const = 0; > + ?virtual error_code getRelocationAdditionalInfo(DataRefImpl Rel, > + ? ? ? ? ? ? ? ? ? ? ? ? ? ? ? ? ? ? ? ? ? ? ? ? int64_t &Res) const = 0; > + > ?public: > ? template > ? class content_iterator { > @@ -196,6 +216,7 @@ > > ? typedef content_iterator symbol_iterator; > ? typedef content_iterator section_iterator; > + ?typedef content_iterator relocation_iterator; > > ? virtual symbol_iterator begin_symbols() const = 0; > ? virtual symbol_iterator end_symbols() const = 0; > @@ -203,6 +224,9 @@ > ? virtual section_iterator begin_sections() const = 0; > ? virtual section_iterator end_sections() const = 0; > > + ?virtual relocation_iterator begin_relocations() const = 0; > + ?virtual relocation_iterator end_relocations() const = 0; > + > ? /// @brief The number of bytes used to represent an address in this object > ? /// ? ? ? ?file format. > ? virtual uint8_t getBytesInAddress() const = 0; > @@ -302,6 +326,37 @@ > ? ? ? ? ? ? ? ? ? ? ? ? ? ? ? ? ? ? ? ? ? ? ?Result); > ?} > > + > +/// RelocationRef > +inline RelocationRef::RelocationRef(DataRefImpl RelocationP, > + ? ? ? ? ? ? ? ? ? ? ? ? ? ? ?const ObjectFile *Owner) > + ?: RelocationPimpl(RelocationP) > + ?, OwningObject(Owner) {} > + > +inline bool RelocationRef::operator==(const RelocationRef &Other) const { > + ?return RelocationPimpl == Other.RelocationPimpl; > +} > + > +inline error_code RelocationRef::getNext(RelocationRef &Result) const { > + ?return OwningObject->getRelocationNext(RelocationPimpl, Result); > +} > + > +inline error_code RelocationRef::getAddress(uint64_t &Result) const { > + ?return OwningObject->getRelocationAddress(RelocationPimpl, Result); > +} > + > +inline error_code RelocationRef::getSymbol(SymbolRef &Result) const { > + ?return OwningObject->getRelocationSymbol(RelocationPimpl, Result); > +} > + > +inline error_code RelocationRef::getType(uint32_t &Result) const { > + ?return OwningObject->getRelocationType(RelocationPimpl, Result); > +} > + > +inline error_code RelocationRef::getAdditionalInfo(int64_t &Result) const { > + ?return OwningObject->getRelocationAdditionalInfo(RelocationPimpl, Result); > +} > + > ?} // end namespace object > ?} // end namespace llvm > > > Modified: llvm/trunk/lib/Object/COFFObjectFile.cpp > URL: http://llvm.org/viewvc/llvm-project/llvm/trunk/lib/Object/COFFObjectFile.cpp?rev=139314&r1=139313&r2=139314&view=diff > ============================================================================== > --- llvm/trunk/lib/Object/COFFObjectFile.cpp (original) > +++ llvm/trunk/lib/Object/COFFObjectFile.cpp Thu Sep ?8 15:52:17 2011 > @@ -327,7 +327,7 @@ > ? Header = reinterpret_cast(base() + HeaderStart); > ? if (!checkAddr(Data, ec, uintptr_t(Header), sizeof(coff_file_header))) > ? ? return; > - > + > ? SectionTable = > ? ? reinterpret_cast( base() > ? ? ? ? ? ? ? ? ? ? ? ? ? ? ? ? ? ? ? ? ? + HeaderStart > @@ -360,7 +360,7 @@ > ? ? ec = object_error::parse_failed; > ? ? return; > ? } > - > + > ? ec = object_error::success; > ?} > > @@ -445,6 +445,77 @@ > ? return object_error::success; > ?} > > +const coff_relocation *COFFObjectFile::toRel(DataRefImpl Rel) const { > + ?assert(Rel.d.b < Header->NumberOfSections && "Section index out of range!"); > + ?const coff_section *Sect; > + ?getSection(Rel.d.b, Sect); > + ?assert(Rel.d.a < Sect->NumberOfRelocations && "Relocation index out of range!"); > + ?return > + ? ?reinterpret_cast(base() + > + ? ? ? ? ? ? ? ? ? ? ? ? ? ? ? ? ? ? ? ? ? ? Sect->PointerToRelocations) + > + ? ? ? ? ? ? ? ? ? ? ? ? ? ? ? ? ? ? ? ? ? ? Rel.d.a; > +} > +error_code COFFObjectFile::getRelocationNext(DataRefImpl Rel, > + ? ? ? ? ? ? ? ? ? ? ? ? ? ? ? ? ? ? ? ? ? ? RelocationRef &Res) const { > + ?const coff_section *Sect = NULL; > + ?if (error_code ec = getSection(Rel.d.b, Sect)) > + ? ?return ec; > + ?if (++Rel.d.a >= Sect->NumberOfRelocations) { > + ? ?Rel.d.a = 0; > + ? ?while (++Rel.d.b < Header->NumberOfSections) { > + ? ? ?const coff_section *Sect; > + ? ? ?getSection(Rel.d.b, Sect); > + ? ? ?if (Sect->NumberOfRelocations > 0) > + ? ? ? ?break; > + ? ?} > + ?} > + ?Res = RelocationRef(Rel, this); > + ?return object_error::success; > +} > +error_code COFFObjectFile::getRelocationAddress(DataRefImpl Rel, > + ? ? ? ? ? ? ? ? ? ? ? ? ? ? ? ? ? ? ? ? ? ? ? ?uint64_t &Res) const { > + ?const coff_section *Sect; > + ?if (error_code ec = getSection(Rel.d.b, Sect)) > + ? ?return ec; > + ?const coff_relocation* R = toRel(Rel); > + ?Res = reinterpret_cast(base() + > + ? ? ? ? ? ? ? ? ? ? ? ? ? ? ? ? ? ?Sect->PointerToRawData + > + ? ? ? ? ? ? ? ? ? ? ? ? ? ? ? ? ? ?R->VirtualAddress); > + ?return object_error::success; > +} > +error_code COFFObjectFile::getRelocationSymbol(DataRefImpl Rel, > + ? ? ? ? ? ? ? ? ? ? ? ? ? ? ? ? ? ? ? ? ? ? ? SymbolRef &Res) const { > + ?const coff_relocation* R = toRel(Rel); > + ?DataRefImpl Symb; > + ?Symb.p = reinterpret_cast(SymbolTable + R->SymbolTableIndex); > + ?Res = SymbolRef(Symb, this); > + ?return object_error::success; > +} > +error_code COFFObjectFile::getRelocationType(DataRefImpl Rel, > + ? ? ? ? ? ? ? ? ? ? ? ? ? ? ? ? ? ? ? ? ? ? uint32_t &Res) const { > + ?const coff_relocation* R = toRel(Rel); > + ?Res = R->Type; > + ?return object_error::success; > +} > +error_code COFFObjectFile::getRelocationAdditionalInfo(DataRefImpl Rel, > + ? ? ? ? ? ? ? ? ? ? ? ? ? ? ? ? ? ? ? ? ? ? ? ? ? ? ? int64_t &Res) const { > + ?Res = 0; > + ?return object_error::success; > +} > +ObjectFile::relocation_iterator COFFObjectFile::begin_relocations() const { > + ?DataRefImpl ret; > + ?ret.d.a = 0; > + ?ret.d.b = 1; > + ?return relocation_iterator(RelocationRef(ret, this)); > +} > +ObjectFile::relocation_iterator COFFObjectFile::end_relocations() const { > + ?DataRefImpl ret; > + ?ret.d.a = 0; > + ?ret.d.b = Header->NumberOfSections; > + ?return relocation_iterator(RelocationRef(ret, this)); > +} > + > + > ?namespace llvm { > > ? ObjectFile *ObjectFile::createCOFFObjectFile(MemoryBuffer *Object) { > > Modified: llvm/trunk/lib/Object/ELFObjectFile.cpp > URL: http://llvm.org/viewvc/llvm-project/llvm/trunk/lib/Object/ELFObjectFile.cpp?rev=139314&r1=139313&r2=139314&view=diff > ============================================================================== > --- llvm/trunk/lib/Object/ELFObjectFile.cpp (original) > +++ llvm/trunk/lib/Object/ELFObjectFile.cpp Thu Sep ?8 15:52:17 2011 > @@ -14,6 +14,7 @@ > ?#include "llvm/ADT/SmallVector.h" > ?#include "llvm/ADT/StringSwitch.h" > ?#include "llvm/ADT/Triple.h" > +#include "llvm/ADT/DenseMap.h" > ?#include "llvm/Object/ObjectFile.h" > ?#include "llvm/Support/ELF.h" > ?#include "llvm/Support/Endian.h" > @@ -176,12 +177,89 @@ > ?} > > ?namespace { > +template > +struct Elf_Rel_Base; > + > +template > +struct Elf_Rel_Base { > + ?LLVM_ELF_IMPORT_TYPES(target_endianness, false) > + ?Elf_Addr ? ? ?r_offset; // Location (file byte offset, or program virtual addr) > + ?Elf_Word ? ? ?r_info; ?// Symbol table index and type of relocation to apply > +}; > + > +template > +struct Elf_Rel_Base { > + ?LLVM_ELF_IMPORT_TYPES(target_endianness, true) > + ?Elf_Addr ? ? ?r_offset; // Location (file byte offset, or program virtual addr) > + ?Elf_Xword ? ? r_info; ? // Symbol table index and type of relocation to apply > +}; > + > +template > +struct Elf_Rel_Base { > + ?LLVM_ELF_IMPORT_TYPES(target_endianness, false) > + ?Elf_Addr ? ? ?r_offset; // Location (file byte offset, or program virtual addr) > + ?Elf_Word ? ? ?r_info; ? // Symbol table index and type of relocation to apply > + ?Elf_Sword ? ? r_addend; // Compute value for relocatable field by adding this > +}; > + > +template > +struct Elf_Rel_Base { > + ?LLVM_ELF_IMPORT_TYPES(target_endianness, true) > + ?Elf_Addr ? ? ?r_offset; // Location (file byte offset, or program virtual addr) > + ?Elf_Xword ? ? r_info; ? // Symbol table index and type of relocation to apply > + ?Elf_Sxword ? ?r_addend; // Compute value for relocatable field by adding this. > +}; > + > +template > +struct Elf_Rel_Impl; > + > +template > +struct Elf_Rel_Impl > + ? ? ? : Elf_Rel_Base { > + ?using Elf_Rel_Base::r_info; > + ?LLVM_ELF_IMPORT_TYPES(target_endianness, true) > + > + ?// These accessors and mutators correspond to the ELF64_R_SYM, ELF64_R_TYPE, > + ?// and ELF64_R_INFO macros defined in the ELF specification: > + ?uint64_t getSymbol() const { return (r_info >> 32); } > + ?unsigned char getType() const { > + ? ?return (unsigned char) (r_info & 0xffffffffL); > + ?} > + ?void setSymbol(uint64_t s) { setSymbolAndType(s, getType()); } > + ?void setType(unsigned char t) { setSymbolAndType(getSymbol(), t); } > + ?void setSymbolAndType(uint64_t s, unsigned char t) { > + ? ?r_info = (s << 32) + (t&0xffffffffL); > + ?} > +}; > + > +template > +struct Elf_Rel_Impl > + ? ? ? : Elf_Rel_Base { > + ?using Elf_Rel_Base::r_info; > + ?LLVM_ELF_IMPORT_TYPES(target_endianness, false) > + > + ?// These accessors and mutators correspond to the ELF32_R_SYM, ELF32_R_TYPE, > + ?// and ELF32_R_INFO macros defined in the ELF specification: > + ?uint32_t getSymbol() const { return (r_info >> 8); } > + ?unsigned char getType() const { return (unsigned char) (r_info & 0x0ff); } > + ?void setSymbol(uint32_t s) { setSymbolAndType(s, getType()); } > + ?void setType(unsigned char t) { setSymbolAndType(getSymbol(), t); } > + ?void setSymbolAndType(uint32_t s, unsigned char t) { > + ? ?r_info = (s << 8) + t; > + ?} > +}; > + > +} > + > +namespace { > ?template > ?class ELFObjectFile : public ObjectFile { > ? LLVM_ELF_IMPORT_TYPES(target_endianness, is64Bits) > > ? typedef Elf_Shdr_Impl Elf_Shdr; > ? typedef Elf_Sym_Impl Elf_Sym; > + ?typedef Elf_Rel_Impl Elf_Rel; > + ?typedef Elf_Rel_Impl Elf_Rela; > > ? struct Elf_Ehdr { > ? ? unsigned char e_ident[ELF::EI_NIDENT]; // ELF Identification bytes > @@ -206,18 +284,26 @@ > ? ? unsigned char getDataEncoding() const { return e_ident[ELF::EI_DATA]; } > ? }; > > - ?typedef SmallVector SymbolTableSections_t; > + ?typedef SmallVector Sections_t; > + ?typedef DenseMap IndexMap_t; > > ? const Elf_Ehdr *Header; > ? const Elf_Shdr *SectionHeaderTable; > ? const Elf_Shdr *dot_shstrtab_sec; // Section header string table. > ? const Elf_Shdr *dot_strtab_sec; ? // Symbol header string table. > - ?SymbolTableSections_t SymbolTableSections; > + ?Sections_t SymbolTableSections; > + ?IndexMap_t SymbolTableSectionsIndexMap; > + ?Sections_t RelocationTableSections; > > ? void ? ? ? ? ? ?validateSymbol(DataRefImpl Symb) const; > + ?bool ? ? ? ? ? ?isRelocationHasAddend(DataRefImpl Rel) const; > + ?template > + ?const T ? ? ? ?*getEntry(DataRefImpl Entry, Sections_t Sections) const; > ? const Elf_Sym ?*getSymbol(DataRefImpl Symb) const; > ? const Elf_Shdr *getSection(DataRefImpl index) const; > ? const Elf_Shdr *getSection(uint16_t index) const; > + ?const Elf_Rel ?*getRel(DataRefImpl Rel) const; > + ?const Elf_Rela *getRela(DataRefImpl Rela) const; > ? const char ? ? *getString(uint16_t section, uint32_t offset) const; > ? const char ? ? *getString(const Elf_Shdr *section, uint32_t offset) const; > > @@ -238,12 +324,25 @@ > ? virtual error_code sectionContainsSymbol(DataRefImpl Sec, DataRefImpl Symb, > ? ? ? ? ? ? ? ? ? ? ? ? ? ? ? ? ? ? ? ? ? ?bool &Result) const; > > + ?virtual error_code getRelocationNext(DataRefImpl Rel, > + ? ? ? ? ? ? ? ? ? ? ? ? ? ? ? ? ? ? ? RelocationRef &Res) const; > + ?virtual error_code getRelocationAddress(DataRefImpl Rel, > + ? ? ? ? ? ? ? ? ? ? ? ? ? ? ? ? ? ? ? ? ?uint64_t &Res) const; > + ?virtual error_code getRelocationSymbol(DataRefImpl Rel, > + ? ? ? ? ? ? ? ? ? ? ? ? ? ? ? ? ? ? ? ? SymbolRef &Res) const; > + ?virtual error_code getRelocationType(DataRefImpl Rel, > + ? ? ? ? ? ? ? ? ? ? ? ? ? ? ? ? ? ? ? uint32_t &Res) const; > + ?virtual error_code getRelocationAdditionalInfo(DataRefImpl Rel, > + ? ? ? ? ? ? ? ? ? ? ? ? ? ? ? ? ? ? ? ? ? ? ? ? int64_t &Res) const; > + > ?public: > ? ELFObjectFile(MemoryBuffer *Object, error_code &ec); > ? virtual symbol_iterator begin_symbols() const; > ? virtual symbol_iterator end_symbols() const; > ? virtual section_iterator begin_sections() const; > ? virtual section_iterator end_sections() const; > + ?virtual relocation_iterator begin_relocations() const; > + ?virtual relocation_iterator end_relocations() const; > > ? virtual uint8_t getBytesInAddress() const; > ? virtual StringRef getFileFormatName() const; > @@ -416,7 +515,8 @@ > ? ? ? return ec; > ? ? Result = StringSwitch(name) > ? ? ? .StartsWith(".debug", 'N') > - ? ? ?.StartsWith(".note", 'n'); > + ? ? ?.StartsWith(".note", 'n') > + ? ? ?.Default('?'); > ? ? return object_error::success; > ? } > > @@ -507,6 +607,121 @@ > ? return object_error::success; > ?} > > +// Relocations > +template > +error_code ELFObjectFile > + ? ? ? ? ? ? ? ? ? ? ? ?::getRelocationNext(DataRefImpl Rel, > + ? ? ? ? ? ? ? ? ? ? ? ? ? ? ? ? ? ? ? ? ? ?RelocationRef &Result) const { > + ?const Elf_Shdr *RelocationTableSection = RelocationTableSections[Rel.d.b]; > + > + ?// Check to see if we are at the end of this relocation table. > + ?if (++Rel.d.a >= RelocationTableSection->getEntityCount()) { > + ? ?// We are at the end. If there are other relocation tables, jump to them. > + ? ?Rel.d.a = 0; > + ? ?// Otherwise return the terminator. > + ? ?if (++Rel.d.b >= SymbolTableSections.size()) { > + ? ? ?Rel.d.a = std::numeric_limits::max(); > + ? ? ?Rel.d.b = std::numeric_limits::max(); > + ? ?} > + ?} > + > + ?Result = RelocationRef(Rel, this); > + ?return object_error::success; > +} > + > +template > +error_code ELFObjectFile > + ? ? ? ? ? ? ? ? ? ? ? ?::getRelocationSymbol(DataRefImpl Rel, > + ? ? ? ? ? ? ? ? ? ? ? ? ? ? ? ? ? ? ? ? ? ? ?SymbolRef &Result) const { > + ?uint32_t symbolIdx; > + ?const Elf_Shdr *sec = RelocationTableSections[Rel.d.b]; > + ?switch (sec->sh_type) { > + ? ?default : > + ? ? ?report_fatal_error("Invalid section type in Rel!"); > + ? ?case ELF::SHT_REL : { > + ? ? ?symbolIdx = getRel(Rel)->getSymbol(); > + ? ? ?break; > + ? ?} > + ? ?case ELF::SHT_RELA : { > + ? ? ?symbolIdx = getRela(Rel)->getSymbol(); > + ? ? ?break; > + ? ?} > + ?} > + ?DataRefImpl SymbolData; > + ?IndexMap_t::const_iterator it = SymbolTableSectionsIndexMap.find(sec->sh_link); > + ?if (it == SymbolTableSectionsIndexMap.end()) > + ? ?report_fatal_error("Relocation symbol table not found!"); > + ?SymbolData.d.a = symbolIdx; > + ?SymbolData.d.b = it->second; > + ?Result = SymbolRef(SymbolData, this); > + ?return object_error::success; > +} > + > +template > +error_code ELFObjectFile > + ? ? ? ? ? ? ? ? ? ? ? ?::getRelocationAddress(DataRefImpl Rel, > + ? ? ? ? ? ? ? ? ? ? ? ? ? ? ? ? ? ? ? ? ? ? ? uint64_t &Result) const { > + ?uint64_t offset; > + ?const Elf_Shdr *sec = RelocationTableSections[Rel.d.b]; > + ?switch (sec->sh_type) { > + ? ?default : > + ? ? ?report_fatal_error("Invalid section type in Rel!"); > + ? ?case ELF::SHT_REL : { > + ? ? ?offset = getRel(Rel)->r_offset; > + ? ? ?break; > + ? ?} > + ? ?case ELF::SHT_RELA : { > + ? ? ?offset = getRela(Rel)->r_offset; > + ? ? ?break; > + ? ?} > + ?} > + > + ?const Elf_Shdr *secAddr = getSection(sec->sh_info); > + ?Result = offset + reinterpret_cast(base() + secAddr->sh_offset); > + ?return object_error::success; > +} > + > +template > +error_code ELFObjectFile > + ? ? ? ? ? ? ? ? ? ? ? ?::getRelocationType(DataRefImpl Rel, > + ? ? ? ? ? ? ? ? ? ? ? ? ? ? ? ? ? ? ? ? ? ?uint32_t &Result) const { > + ?const Elf_Shdr *sec = RelocationTableSections[Rel.d.b]; > + ?switch (sec->sh_type) { > + ? ?default : > + ? ? ?report_fatal_error("Invalid section type in Rel!"); > + ? ?case ELF::SHT_REL : { > + ? ? ?Result = getRel(Rel)->getType(); > + ? ? ?break; > + ? ?} > + ? ?case ELF::SHT_RELA : { > + ? ? ?Result = getRela(Rel)->getType(); > + ? ? ?break; > + ? ?} > + ?} > + ?return object_error::success; > +} > + > +template > +error_code ELFObjectFile > + ? ? ? ? ? ? ? ? ? ? ? ?::getRelocationAdditionalInfo(DataRefImpl Rel, > + ? ? ? ? ? ? ? ? ? ? ? ? ? ? ? ? ? ? ? ? ? ? ? ? ? ? ?int64_t &Result) const { > + ?const Elf_Shdr *sec = RelocationTableSections[Rel.d.b]; > + ?switch (sec->sh_type) { > + ? ?default : > + ? ? ?report_fatal_error("Invalid section type in Rel!"); > + ? ?case ELF::SHT_REL : { > + ? ? ?Result = 0; > + ? ? ?return object_error::success; > + ? ?} > + ? ?case ELF::SHT_RELA : { > + ? ? ?Result = getRela(Rel)->r_addend; > + ? ? ?return object_error::success; > + ? ?} > + ?} > +} > + > + > + > ?template > ?ELFObjectFile::ELFObjectFile(MemoryBuffer *Object > ? ? ? ? ? ? ? ? ? ? ? ? ? ? ? ? ? ? ? ? ? ? ? ? ? ? ? ? ? , error_code &ec) > @@ -529,13 +744,17 @@ > > > ? // To find the symbol tables we walk the section table to find SHT_STMTAB. > - ?for (const char *i = reinterpret_cast(SectionHeaderTable), > - ? ? ? ? ? ? ? ? ?*e = i + Header->e_shnum * Header->e_shentsize; > - ? ? ? ? ? ? ? ? ? i != e; i += Header->e_shentsize) { > - ? ?const Elf_Shdr *sh = reinterpret_cast(i); > + ?const Elf_Shdr* sh = > + ? ? ? ? ? ? ? ? ? ?reinterpret_cast(SectionHeaderTable); > + ?for (unsigned i = 0; i < Header->e_shnum; ++i) { > ? ? if (sh->sh_type == ELF::SHT_SYMTAB) { > + ? ? ?SymbolTableSectionsIndexMap[i] = SymbolTableSections.size(); > ? ? ? SymbolTableSections.push_back(sh); > ? ? } > + ? ?if (sh->sh_type == ELF::SHT_REL || sh->sh_type == ELF::SHT_RELA) { > + ? ? ?RelocationTableSections.push_back(sh); > + ? ?} > + ? ?++sh; > ? } > > ? // Get string table sections. > @@ -615,6 +834,31 @@ > ?} > > ?template > +ObjectFile::relocation_iterator ELFObjectFile > + ? ? ? ? ? ? ? ? ? ? ? ? ? ? ? ? ? ? ? ? ::begin_relocations() const { > + ?DataRefImpl RelData; > + ?memset(&RelData, 0, sizeof(RelData)); > + ?if (RelocationTableSections.size() == 0) { > + ? ?RelData.d.a = std::numeric_limits::max(); > + ? ?RelData.d.b = std::numeric_limits::max(); > + ?} else { > + ? ?RelData.d.a = 0; > + ? ?RelData.d.b = 0; > + ?} > + ?return relocation_iterator(RelocationRef(RelData, this)); > +} > + > +template > +ObjectFile::relocation_iterator ELFObjectFile > + ? ? ? ? ? ? ? ? ? ? ? ? ? ? ? ? ? ? ? ? ::end_relocations() const { > + ?DataRefImpl RelData; > + ?memset(&RelData, 0, sizeof(RelData)); > + ?RelData.d.a = std::numeric_limits::max(); > + ?RelData.d.b = std::numeric_limits::max(); > + ?return relocation_iterator(RelocationRef(RelData, this)); > +} > + > +template > ?uint8_t ELFObjectFile::getBytesInAddress() const { > ? return is64Bits ? 8 : 4; > ?} > @@ -629,6 +873,8 @@ > ? ? ? return "ELF32-i386"; > ? ? case ELF::EM_X86_64: > ? ? ? return "ELF32-x86-64"; > + ? ?case ELF::EM_ARM: > + ? ? ?return "ELF32-arm"; > ? ? default: > ? ? ? return "ELF32-unknown"; > ? ? } > @@ -654,19 +900,41 @@ > ? ? return Triple::x86; > ? case ELF::EM_X86_64: > ? ? return Triple::x86_64; > + ?case ELF::EM_ARM: > + ? ?return Triple::arm; > ? default: > ? ? return Triple::UnknownArch; > ? } > ?} > > ?template > -const typename ELFObjectFile::Elf_Sym * > -ELFObjectFile::getSymbol(DataRefImpl Symb) const { > - ?const Elf_Shdr *sec = SymbolTableSections[Symb.d.b]; > - ?return reinterpret_cast( > +template > +inline const T * > +ELFObjectFile::getEntry(DataRefImpl Entry, > + ? ? ? ? ? ? ? ? ? ? ? ? ? ? ? ? ? ? ? ? ? ? ? ? ? ? Sections_t Sections) const { > + ?const Elf_Shdr *sec = Sections[Entry.d.b]; > + ?return reinterpret_cast( > ? ? ? ? ? ?base() > ? ? ? ? ? ?+ sec->sh_offset > - ? ? ? ? ? + (Symb.d.a * sec->sh_entsize)); > + ? ? ? ? ? + (Entry.d.a * sec->sh_entsize)); > +} > + > +template > +const typename ELFObjectFile::Elf_Sym * > +ELFObjectFile::getSymbol(DataRefImpl Symb) const { > + ?return getEntry(Symb, SymbolTableSections); > +} > + > +template > +const typename ELFObjectFile::Elf_Rel * > +ELFObjectFile::getRel(DataRefImpl Rel) const { > + ?return getEntry(Rel, RelocationTableSections); > +} > + > +template > +const typename ELFObjectFile::Elf_Rela * > +ELFObjectFile::getRela(DataRefImpl Rela) const { > + ?return getEntry(Rela, RelocationTableSections); > ?} > > ?template > > Modified: llvm/trunk/lib/Object/MachOObjectFile.cpp > URL: http://llvm.org/viewvc/llvm-project/llvm/trunk/lib/Object/MachOObjectFile.cpp?rev=139314&r1=139313&r2=139314&view=diff > ============================================================================== > --- llvm/trunk/lib/Object/MachOObjectFile.cpp (original) > +++ llvm/trunk/lib/Object/MachOObjectFile.cpp Thu Sep ?8 15:52:17 2011 > @@ -18,6 +18,7 @@ > ?#include "llvm/Object/ObjectFile.h" > ?#include "llvm/Support/MemoryBuffer.h" > ?#include "llvm/Support/MachO.h" > +#include "llvm/ADT/SmallVector.h" > > ?#include > ?#include > @@ -32,15 +33,14 @@ > > ?class MachOObjectFile : public ObjectFile { > ?public: > - ?MachOObjectFile(MemoryBuffer *Object, MachOObject *MOO, error_code &ec) > - ? ?: ObjectFile(Binary::isMachO, Object, ec), > - ? ? ?MachOObj(MOO), > - ? ? ?RegisteredStringTable(std::numeric_limits::max()) {} > + ?MachOObjectFile(MemoryBuffer *Object, MachOObject *MOO, error_code &ec); > > ? virtual symbol_iterator begin_symbols() const; > ? virtual symbol_iterator end_symbols() const; > ? virtual section_iterator begin_sections() const; > ? virtual section_iterator end_sections() const; > + ?virtual relocation_iterator begin_relocations() const; > + ?virtual relocation_iterator end_relocations() const; > > ? virtual uint8_t getBytesInAddress() const; > ? virtual StringRef getFileFormatName() const; > @@ -63,9 +63,22 @@ > ? virtual error_code sectionContainsSymbol(DataRefImpl DRI, DataRefImpl S, > ? ? ? ? ? ? ? ? ? ? ? ? ? ? ? ? ? ? ? ? ? ?bool &Result) const; > > + ?virtual error_code getRelocationNext(DataRefImpl Rel, > + ? ? ? ? ? ? ? ? ? ? ? ? ? ? ? ? ? ? ? RelocationRef &Res) const; > + ?virtual error_code getRelocationAddress(DataRefImpl Rel, > + ? ? ? ? ? ? ? ? ? ? ? ? ? ? ? ? ? ? ? ? ?uint64_t &Res) const; > + ?virtual error_code getRelocationSymbol(DataRefImpl Rel, > + ? ? ? ? ? ? ? ? ? ? ? ? ? ? ? ? ? ? ? ? SymbolRef &Res) const; > + ?virtual error_code getRelocationType(DataRefImpl Rel, > + ? ? ? ? ? ? ? ? ? ? ? ? ? ? ? ? ? ? ? uint32_t &Res) const; > + ?virtual error_code getRelocationAdditionalInfo(DataRefImpl Rel, > + ? ? ? ? ? ? ? ? ? ? ? ? ? ? ? ? ? ? ? ? ? ? ? ? int64_t &Res) const; > ?private: > ? MachOObject *MachOObj; > ? mutable uint32_t RegisteredStringTable; > + ?typedef SmallVector SectionList; > + ?SectionList Sections; > + > > ? void moveToNextSection(DataRefImpl &DRI) const; > ? void getSymbolTableEntry(DataRefImpl DRI, > @@ -76,8 +89,35 @@ > ? void getSection(DataRefImpl DRI, InMemoryStruct &Res) const; > ? void getSection64(DataRefImpl DRI, > ? ? ? ? ? ? ? ? ? ? InMemoryStruct &Res) const; > + ?void getRelocation(DataRefImpl Rel, > + ? ? ? ? ? ? ? ? ? ? InMemoryStruct &Res) const; > ?}; > > +MachOObjectFile::MachOObjectFile(MemoryBuffer *Object, MachOObject *MOO, > + ? ? ? ? ? ? ? ? ? ? ? ? ? ? ? ? error_code &ec) > + ? ?: ObjectFile(Binary::isMachO, Object, ec), > + ? ? ?MachOObj(MOO), > + ? ? ?RegisteredStringTable(std::numeric_limits::max()) { > + ?DataRefImpl DRI; > + ?DRI.d.a = DRI.d.b = 0; > + ?moveToNextSection(DRI); > + ?uint32_t LoadCommandCount = MachOObj->getHeader().NumLoadCommands; > + ?while (DRI.d.a < LoadCommandCount) { > + ? ?Sections.push_back(DRI); > + ? ?uint64_t Addr; > + ? ?uint64_t Size; > + ? ?StringRef Name; > + ? ?getSectionAddress(DRI, Addr); > + ? ?getSectionSize(DRI, Size); > + ? ?getSectionName(DRI, Name); > + ? ?InMemoryStruct Sect; > + ? ?getSection(DRI, Sect); > + ? ?DRI.d.b++; > + ? ?moveToNextSection(DRI); > + ?} > +} > + > + > ?ObjectFile *ObjectFile::createMachOObjectFile(MemoryBuffer *Buffer) { > ? error_code ec; > ? std::string Err; > @@ -414,6 +454,125 @@ > ? return section_iterator(SectionRef(DRI, this)); > ?} > > +/*===-- Relocations -------------------------------------------------------===*/ > + > +void MachOObjectFile:: > +getRelocation(DataRefImpl Rel, > + ? ? ? ? ? ? ?InMemoryStruct &Res) const { > + ?uint32_t relOffset; > + ?if (MachOObj->is64Bit()) { > + ? ?InMemoryStruct Sect; > + ? ?getSection64(Sections[Rel.d.b], Sect); > + ? ?relOffset = Sect->RelocationTableOffset; > + ?} else { > + ? ?InMemoryStruct Sect; > + ? ?getSection(Sections[Rel.d.b], Sect); > + ? ?relOffset = Sect->RelocationTableOffset; > + ?} > + ?MachOObj->ReadRelocationEntry(relOffset, Rel.d.a, Res); > +} > +error_code MachOObjectFile::getRelocationNext(DataRefImpl Rel, > + ? ? ? ? ? ? ? ? ? ? ? ? ? ? ? ? ? ? ? ? ? ? ?RelocationRef &Res) const { > + ?++Rel.d.a; > + ?while (Rel.d.b < Sections.size()) { > + ? ?unsigned relocationCount; > + ? ?if (MachOObj->is64Bit()) { > + ? ? ?InMemoryStruct Sect; > + ? ? ?getSection64(Sections[Rel.d.b], Sect); > + ? ? ?relocationCount = Sect->NumRelocationTableEntries; > + ? ?} else { > + ? ? ?InMemoryStruct Sect; > + ? ? ?getSection(Sections[Rel.d.b], Sect); > + ? ? ?relocationCount = Sect->NumRelocationTableEntries; > + ? ?} > + ? ?if (Rel.d.a < relocationCount) > + ? ? ?break; > + > + ? ?Rel.d.a = 0; > + ? ?++Rel.d.b; > + ?} > + ?Res = RelocationRef(Rel, this); > + ?return object_error::success; > +} > +error_code MachOObjectFile::getRelocationAddress(DataRefImpl Rel, > + ? ? ? ? ? ? ? ? ? ? ? ? ? ? ? ? ? ? ? ? ? ? ? ? uint64_t &Res) const { > + ?const uint8_t* sectAddress = base(); > + ?if (MachOObj->is64Bit()) { > + ? ?InMemoryStruct Sect; > + ? ?getSection64(Sections[Rel.d.b], Sect); > + ? ?sectAddress += Sect->Offset; > + ?} else { > + ? ?InMemoryStruct Sect; > + ? ?getSection(Sections[Rel.d.b], Sect); > + ? ?sectAddress += Sect->Offset; > + ?} > + ?InMemoryStruct RE; > + ?getRelocation(Rel, RE); > + ?Res = reinterpret_cast(sectAddress + RE->Word0); > + ?return object_error::success; > +} > +error_code MachOObjectFile::getRelocationSymbol(DataRefImpl Rel, > + ? ? ? ? ? ? ? ? ? ? ? ? ? ? ? ? ? ? ? ? ? ? ? ?SymbolRef &Res) const { > + ?InMemoryStruct RE; > + ?getRelocation(Rel, RE); > + ?uint32_t SymbolIdx = RE->Word1 & 0xffffff; > + ?bool isExtern = (RE->Word1 >> 27) & 1; > + > + ?DataRefImpl Sym; > + ?Sym.d.a = Sym.d.b = 0; > + ?moveToNextSymbol(Sym); > + ?uint32_t NumLoadCommands = MachOObj->getHeader().NumLoadCommands; > + ?if (isExtern) { > + ? ?for (unsigned i = 0; i < SymbolIdx; i++) { > + ? ? ?Sym.d.b++; > + ? ? ?moveToNextSymbol(Sym); > + ? ? ?assert(Sym.d.a < NumLoadCommands && > + ? ? ? ? ? ? "Relocation symbol index out of range!"); > + ? ?} > + ?} > + ?Res = SymbolRef(Sym, this); > + ?return object_error::success; > +} > +error_code MachOObjectFile::getRelocationType(DataRefImpl Rel, > + ? ? ? ? ? ? ? ? ? ? ? ? ? ? ? ? ? ? ? ? ? ? ?uint32_t &Res) const { > + ?InMemoryStruct RE; > + ?getRelocation(Rel, RE); > + ?Res = RE->Word1; > + ?return object_error::success; > +} > +error_code MachOObjectFile::getRelocationAdditionalInfo(DataRefImpl Rel, > + ? ? ? ? ? ? ? ? ? ? ? ? ? ? ? ? ? ? ? ? ? ? ? ? ? ? ? ?int64_t &Res) const { > + ?InMemoryStruct RE; > + ?getRelocation(Rel, RE); > + ?bool isExtern = (RE->Word1 >> 27) & 1; > + ?Res = 0; > + ?if (!isExtern) { > + ? ?const uint8_t* sectAddress = base(); > + ? ?if (MachOObj->is64Bit()) { > + ? ? ?InMemoryStruct Sect; > + ? ? ?getSection64(Sections[Rel.d.b], Sect); > + ? ? ?sectAddress += Sect->Offset; > + ? ?} else { > + ? ? ?InMemoryStruct Sect; > + ? ? ?getSection(Sections[Rel.d.b], Sect); > + ? ? ?sectAddress += Sect->Offset; > + ? ?} > + ? ?Res = reinterpret_cast(sectAddress); > + ?} > + ?return object_error::success; > +} > +ObjectFile::relocation_iterator MachOObjectFile::begin_relocations() const { > + ?DataRefImpl ret; > + ?ret.d.a = ret.d.b = 0; > + ?return relocation_iterator(RelocationRef(ret, this)); > +} > +ObjectFile::relocation_iterator MachOObjectFile::end_relocations() const { > + ?DataRefImpl ret; > + ?ret.d.a = 0; > + ?ret.d.b = Sections.size(); > + ?return relocation_iterator(RelocationRef(ret, this)); > +} > + > ?/*===-- Miscellaneous -----------------------------------------------------===*/ > > ?uint8_t MachOObjectFile::getBytesInAddress() const { Is it alright with you if I change the relocation API to provide relocations per section instead of per object file? All currently supported file formats do this internally, and most tools access relocations in this manner. Also, your implementation of getAddress returns the memory address the relocation targets on the system as a uintptr_t, which seems very odd to me. - Michael Spencer From atrick at apple.com Mon Oct 3 19:07:03 2011 From: atrick at apple.com (Andrew Trick) Date: Tue, 04 Oct 2011 00:07:03 -0000 Subject: [llvm-commits] [llvm] r141049 - /llvm/trunk/test/Transforms/LoopUnroll/2011-10-01-NoopTrunc.ll Message-ID: <20111004000703.F11752A6C12C@llvm.org> Author: atrick Date: Mon Oct 3 19:07:02 2011 New Revision: 141049 URL: http://llvm.org/viewvc/llvm-project?rev=141049&view=rev Log: Unit test for r140919, loop unroll heuristics. Added: llvm/trunk/test/Transforms/LoopUnroll/2011-10-01-NoopTrunc.ll Added: llvm/trunk/test/Transforms/LoopUnroll/2011-10-01-NoopTrunc.ll URL: http://llvm.org/viewvc/llvm-project/llvm/trunk/test/Transforms/LoopUnroll/2011-10-01-NoopTrunc.ll?rev=141049&view=auto ============================================================================== --- llvm/trunk/test/Transforms/LoopUnroll/2011-10-01-NoopTrunc.ll (added) +++ llvm/trunk/test/Transforms/LoopUnroll/2011-10-01-NoopTrunc.ll Mon Oct 3 19:07:02 2011 @@ -0,0 +1,36 @@ +; RUN: opt < %s -S -loop-unroll -unroll-threshold=150 | FileCheck %s +; +; Verify that trunc i64 to i32 is considered free by loop unrolling +; heuristics when i32 is a native type. +; This should result in full unrolling this loop with size=7, TC=19. +; If the trunc were not free we would have 8*19=152 > 150. + +target datalayout = "e-p:64:64:64-i1:8:8-i8:8:8-i16:16:16-i32:32:32-i64:64:64-f32:32:32-f64:64:64-v64:64:64-v128:128:128-a0:0:64-s0:64:64-f80:128:128-n8:16:32:64" + +; Check that for.body was unrolled 19 times. +; CHECK: @test +; CHECK: %0 = load +; CHECK: %conv = sext i8 %0 to i32 +; CHECK: %add.1 = add nsw i32 %conv.1, %conv +; CHECK: %add.18 = add nsw i32 %conv.18, %add.17 +; CHECK: ret i32 %add.18 +define i32 @test(i8* %arr) nounwind uwtable readnone { +entry: + br label %for.body + +for.body: ; preds = %for.body, %entry + %indvars.iv = phi i64 [ 0, %entry ], [ %indvars.iv.next, %for.body ] + %sum.02 = phi i32 [ 0, %entry ], [ %add, %for.body ] + %arrayidx = getelementptr inbounds i8* %arr, i64 %indvars.iv + %0 = load i8* %arrayidx, align 1 + %conv = sext i8 %0 to i32 + %add = add nsw i32 %conv, %sum.02 + %indvars.iv.next = add i64 %indvars.iv, 1 + %lftr.wideiv1 = trunc i64 %indvars.iv.next to i32 + %exitcond2 = icmp eq i32 %lftr.wideiv1, 19 + br i1 %exitcond2, label %for.end, label %for.body + +for.end: ; preds = %for.body + %add.lcssa = phi i32 [ %add, %for.body ] + ret i32 %add.lcssa +} From isanbard at gmail.com Mon Oct 3 19:16:48 2011 From: isanbard at gmail.com (Bill Wendling) Date: Tue, 04 Oct 2011 00:16:48 -0000 Subject: [llvm-commits] [llvm] r141050 - /llvm/trunk/lib/CodeGen/SjLjEHPrepare.cpp Message-ID: <20111004001648.CC1802A6C12C@llvm.org> Author: void Date: Mon Oct 3 19:16:40 2011 New Revision: 141050 URL: http://llvm.org/viewvc/llvm-project?rev=141050&view=rev Log: Generic cleanup. Modified: llvm/trunk/lib/CodeGen/SjLjEHPrepare.cpp Modified: llvm/trunk/lib/CodeGen/SjLjEHPrepare.cpp URL: http://llvm.org/viewvc/llvm-project/llvm/trunk/lib/CodeGen/SjLjEHPrepare.cpp?rev=141050&r1=141049&r2=141050&view=diff ============================================================================== --- llvm/trunk/lib/CodeGen/SjLjEHPrepare.cpp (original) +++ llvm/trunk/lib/CodeGen/SjLjEHPrepare.cpp Mon Oct 3 19:16:40 2011 @@ -638,7 +638,7 @@ Type::getInt8PtrTy(F.getContext()), "", EntryBB->getTerminator()); Value *DispatchVal = CallInst::Create(BuiltinSetjmpFn, SetjmpArg, - "dispatch", + "", EntryBB->getTerminator()); // Add a call to dispatch_setup after the setjmp call. This is expanded to any @@ -780,9 +780,8 @@ // LSDA address Idxs[1] = ConstantInt::get(Int32Ty, 4); - Value *LSDAFieldPtr = - GetElementPtrInst::Create(FuncCtx, Idxs, "lsda_gep", - EntryBB->getTerminator()); + Value *LSDAFieldPtr = GetElementPtrInst::Create(FuncCtx, Idxs, "lsda_gep", + EntryBB->getTerminator()); Value *LSDA = CallInst::Create(LSDAAddrFn, "lsda_addr", EntryBB->getTerminator()); new StoreInst(LSDA, LSDAFieldPtr, true, EntryBB->getTerminator()); @@ -819,15 +818,13 @@ // Get a reference to the jump buffer. Idxs[1] = ConstantInt::get(Int32Ty, 5); - Value *JBufPtr = - GetElementPtrInst::Create(FuncCtx, Idxs, "jbuf_gep", - EntryBB->getTerminator()); + Value *JBufPtr = GetElementPtrInst::Create(FuncCtx, Idxs, "jbuf_gep", + EntryBB->getTerminator()); // Save the frame pointer. Idxs[1] = ConstantInt::get(Int32Ty, 0); - Value *FramePtr = - GetElementPtrInst::Create(JBufPtr, Idxs, "jbuf_fp_gep", - EntryBB->getTerminator()); + Value *FramePtr = GetElementPtrInst::Create(JBufPtr, Idxs, "jbuf_fp_gep", + EntryBB->getTerminator()); Value *Val = CallInst::Create(FrameAddrFn, ConstantInt::get(Int32Ty, 0), @@ -837,26 +834,23 @@ // Save the stack pointer. Idxs[1] = ConstantInt::get(Int32Ty, 2); - Value *StackPtr = - GetElementPtrInst::Create(JBufPtr, Idxs, "jbuf_sp_gep", - EntryBB->getTerminator()); + Value *StackPtr = GetElementPtrInst::Create(JBufPtr, Idxs, "jbuf_sp_gep", + EntryBB->getTerminator()); Val = CallInst::Create(StackAddrFn, "sp", EntryBB->getTerminator()); new StoreInst(Val, StackPtr, true, EntryBB->getTerminator()); // Call the setjmp instrinsic. It fills in the rest of the jmpbuf. - Value *SetjmpArg = - CastInst::Create(Instruction::BitCast, JBufPtr, - Type::getInt8PtrTy(F.getContext()), "", - EntryBB->getTerminator()); + Value *SetjmpArg = CastInst::Create(Instruction::BitCast, JBufPtr, + Type::getInt8PtrTy(F.getContext()), "", + EntryBB->getTerminator()); CallInst::Create(BuiltinSetjmpFn, SetjmpArg, "", EntryBB->getTerminator()); // Store a pointer to the function context so that the back-end will know // where to look for it. - Value *FuncCtxArg = - CastInst::Create(Instruction::BitCast, FuncCtx, - Type::getInt8PtrTy(F.getContext()), "", - EntryBB->getTerminator()); + Value *FuncCtxArg = CastInst::Create(Instruction::BitCast, FuncCtx, + Type::getInt8PtrTy(F.getContext()), "", + EntryBB->getTerminator()); CallInst::Create(FuncCtxFn, FuncCtxArg, "", EntryBB->getTerminator()); // At this point, we are all set up, update the invoke instructions to mark @@ -877,7 +871,7 @@ // created for this function and any unexpected exceptions thrown will go // directly to the caller's context, which is what we want anyway, so no need // to do anything here. - for (Function::iterator BB = F.begin(), E = F.end(); ++BB != E;) { + for (Function::iterator BB = F.begin(), E = F.end(); ++BB != E;) for (BasicBlock::iterator I = BB->begin(), end = BB->end(); I != end; ++I) if (CallInst *CI = dyn_cast(I)) { if (!CI->doesNotThrow()) @@ -885,7 +879,6 @@ } else if (ResumeInst *RI = dyn_cast(I)) { insertCallSiteStore(RI, -1, CallSite); } - } // Register the function context and make sure it's known to not throw CallInst *Register = CallInst::Create(RegisterFn, FuncCtx, "", From peter at pcc.me.uk Mon Oct 3 19:30:35 2011 From: peter at pcc.me.uk (Peter Collingbourne) Date: Tue, 04 Oct 2011 00:30:35 -0000 Subject: [llvm-commits] [llvm] r141052 - /llvm/trunk/tools/llvm-shlib/Makefile Message-ID: <20111004003035.C393B2A6C12C@llvm.org> Author: pcc Date: Mon Oct 3 19:30:34 2011 New Revision: 141052 URL: http://llvm.org/viewvc/llvm-project?rev=141052&view=rev Log: Exclude libLLVMTableGen.a from the shared library Unbreaks tools for --enable-shared build. Modified: llvm/trunk/tools/llvm-shlib/Makefile Modified: llvm/trunk/tools/llvm-shlib/Makefile URL: http://llvm.org/viewvc/llvm-project/llvm/trunk/tools/llvm-shlib/Makefile?rev=141052&r1=141051&r2=141052&view=diff ============================================================================== --- llvm/trunk/tools/llvm-shlib/Makefile (original) +++ llvm/trunk/tools/llvm-shlib/Makefile Mon Oct 3 19:30:34 2011 @@ -30,10 +30,11 @@ include $(LEVEL)/Makefile.common # Include all archives in libLLVM.(so|dylib) except the ones that have -# their own dynamic libraries. +# their own dynamic libraries and TableGen. Archives := $(wildcard $(LibDir)/libLLVM*.a) SharedLibraries := $(wildcard $(LibDir)/libLLVM*$(SHLIBEXT)) -IncludeInLibLlvm := $(filter-out $(basename $(SharedLibraries)).a, $(Archives)) +ExcludeFromLibLlvm := $(basename $(SharedLibraries)).a %/libLLVMTableGen.a +IncludeInLibLlvm := $(filter-out $(ExcludeFromLibLlvm), $(Archives)) LLVMLibsOptions := $(IncludeInLibLlvm:$(LibDir)/lib%.a=-l%) LLVMLibsPaths := $(IncludeInLibLlvm) From rafael.espindola at gmail.com Mon Oct 3 21:51:02 2011 From: rafael.espindola at gmail.com (=?UTF-8?Q?Rafael_Esp=C3=ADndola?=) Date: Mon, 3 Oct 2011 22:51:02 -0400 Subject: [llvm-commits] [patch] Add the returns_twice attribute In-Reply-To: <6638C20A-2346-49A1-B604-45C0FE854CC4@apple.com> References: <4E84F46A.9070206@gmail.com> <6638C20A-2346-49A1-B604-45C0FE854CC4@apple.com> Message-ID: 2011/10/3 Evan Cheng : > See Function::callsFunctionThatReturnsTwice(). If you are adding this attribute, then should add the attribute to these special functions (e.g. setjmp)? Then callsFunctionThatReturnsTwice() can go away. Well, it will check if the function calls another function with this attribute. I hope the next patches done this week (see llvm.org/pr11038). > Evan > Cheers, Rafael From rafael.espindola at gmail.com Mon Oct 3 22:08:44 2011 From: rafael.espindola at gmail.com (Rafael Espindola) Date: Tue, 04 Oct 2011 03:08:44 -0000 Subject: [llvm-commits] [llvm] r141057 - in /llvm/trunk: docs/LangRef.html lib/AsmParser/LLLexer.cpp lib/AsmParser/LLToken.h utils/llvm.grm Message-ID: <20111004030846.644012A6C12C@llvm.org> Author: rafael Date: Mon Oct 3 22:08:43 2011 New Revision: 141057 URL: http://llvm.org/viewvc/llvm-project?rev=141057&view=rev Log: Remove last references to hotpatch. Modified: llvm/trunk/docs/LangRef.html llvm/trunk/lib/AsmParser/LLLexer.cpp llvm/trunk/lib/AsmParser/LLToken.h llvm/trunk/utils/llvm.grm Modified: llvm/trunk/docs/LangRef.html URL: http://llvm.org/viewvc/llvm-project/llvm/trunk/docs/LangRef.html?rev=141057&r1=141056&r2=141057&view=diff ============================================================================== --- llvm/trunk/docs/LangRef.html (original) +++ llvm/trunk/docs/LangRef.html Mon Oct 3 22:08:43 2011 @@ -1163,14 +1163,6 @@ function into callers whenever possible, ignoring any active inlining size threshold for this caller. -
hotpatch
-
This attribute indicates that the function should be 'hotpatchable', - meaning the function can be patched and/or hooked even while it is - loaded into memory. On x86, the function prologue will be preceded - by six bytes of padding and will begin with a two-byte instruction. - Most of the functions in the Windows system DLLs in Windows XP SP2 or - higher were compiled in this fashion.
-
nonlazybind
This attribute suppresses lazy symbol binding for the function. This may make calls to the function faster, at the cost of extra program Modified: llvm/trunk/lib/AsmParser/LLLexer.cpp URL: http://llvm.org/viewvc/llvm-project/llvm/trunk/lib/AsmParser/LLLexer.cpp?rev=141057&r1=141056&r2=141057&view=diff ============================================================================== --- llvm/trunk/lib/AsmParser/LLLexer.cpp (original) +++ llvm/trunk/lib/AsmParser/LLLexer.cpp Mon Oct 3 22:08:43 2011 @@ -569,7 +569,6 @@ KEYWORD(noredzone); KEYWORD(noimplicitfloat); KEYWORD(naked); - KEYWORD(hotpatch); KEYWORD(nonlazybind); KEYWORD(type); Modified: llvm/trunk/lib/AsmParser/LLToken.h URL: http://llvm.org/viewvc/llvm-project/llvm/trunk/lib/AsmParser/LLToken.h?rev=141057&r1=141056&r2=141057&view=diff ============================================================================== --- llvm/trunk/lib/AsmParser/LLToken.h (original) +++ llvm/trunk/lib/AsmParser/LLToken.h Mon Oct 3 22:08:43 2011 @@ -101,7 +101,6 @@ kw_noredzone, kw_noimplicitfloat, kw_naked, - kw_hotpatch, kw_nonlazybind, kw_type, Modified: llvm/trunk/utils/llvm.grm URL: http://llvm.org/viewvc/llvm-project/llvm/trunk/utils/llvm.grm?rev=141057&r1=141056&r2=141057&view=diff ============================================================================== --- llvm/trunk/utils/llvm.grm (original) +++ llvm/trunk/utils/llvm.grm Mon Oct 3 22:08:43 2011 @@ -172,7 +172,7 @@ | optsize | ssp | sspreq - | hotpatch + | returns_twice | nonlazybind ; From atrick at apple.com Mon Oct 3 22:34:50 2011 From: atrick at apple.com (Andrew Trick) Date: Tue, 04 Oct 2011 03:34:50 -0000 Subject: [llvm-commits] [llvm] r141058 - in /llvm/trunk: include/llvm/Transforms/Utils/BasicBlockUtils.h lib/Transforms/Utils/BreakCriticalEdges.cpp Message-ID: <20111004033452.D336F2A6C12C@llvm.org> Author: atrick Date: Mon Oct 3 22:34:49 2011 New Revision: 141058 URL: http://llvm.org/viewvc/llvm-project?rev=141058&view=rev Log: whitespace Modified: llvm/trunk/include/llvm/Transforms/Utils/BasicBlockUtils.h llvm/trunk/lib/Transforms/Utils/BreakCriticalEdges.cpp Modified: llvm/trunk/include/llvm/Transforms/Utils/BasicBlockUtils.h URL: http://llvm.org/viewvc/llvm-project/llvm/trunk/include/llvm/Transforms/Utils/BasicBlockUtils.h?rev=141058&r1=141057&r2=141058&view=diff ============================================================================== --- llvm/trunk/include/llvm/Transforms/Utils/BasicBlockUtils.h (original) +++ llvm/trunk/include/llvm/Transforms/Utils/BasicBlockUtils.h Mon Oct 3 22:34:49 2011 @@ -31,8 +31,8 @@ /// DeleteDeadBlock - Delete the specified block, which must have no /// predecessors. void DeleteDeadBlock(BasicBlock *BB); - - + + /// FoldSingleEntryPHINodes - We know that BB has one predecessor. If there are /// any single-entry PHI nodes in it, fold them away. This handles the case /// when all entries to the PHI nodes in a block are guaranteed equal, such as @@ -75,7 +75,7 @@ /// The output is added to Result, as pairs of edge info. void FindFunctionBackedges(const Function &F, SmallVectorImpl > &Result); - + /// GetSuccessorNumber - Search for the specified successor of basic block BB /// and return its position in the terminator instruction's list of @@ -97,10 +97,10 @@ /// was split, null otherwise. /// /// If MergeIdenticalEdges is true (not the default), *all* edges from TI to the -/// specified successor will be merged into the same critical edge block. -/// This is most commonly interesting with switch instructions, which may +/// specified successor will be merged into the same critical edge block. +/// This is most commonly interesting with switch instructions, which may /// have many edges to any one destination. This ensures that all edges to that -/// dest go to one block instead of each going to a different block, but isn't +/// dest go to one block instead of each going to a different block, but isn't /// the standard definition of a "critical edge". /// /// It is invalid to call this function on a critical edge that starts at an @@ -147,8 +147,8 @@ } } -/// SplitEdge - Split the edge connecting specified block. Pass P must -/// not be NULL. +/// SplitEdge - Split the edge connecting specified block. Pass P must +/// not be NULL. BasicBlock *SplitEdge(BasicBlock *From, BasicBlock *To, Pass *P); /// SplitBlock - Split the specified block at the specified instruction - every @@ -157,7 +157,7 @@ /// the loop info is updated. /// BasicBlock *SplitBlock(BasicBlock *Old, Instruction *SplitPt, Pass *P); - + /// SplitBlockPredecessors - This method transforms BB by introducing a new /// basic block into the function, and moving some of the predecessors of BB to /// be predecessors of the new block. The new predecessors are indicated by the @@ -180,13 +180,13 @@ /// block gets the remaining predecessors of OrigBB. The landingpad instruction /// OrigBB is clone into both of the new basic blocks. The new blocks are given /// the suffixes 'Suffix1' and 'Suffix2', and are returned in the NewBBs vector. -/// +/// /// This currently updates the LLVM IR, AliasAnalysis, DominatorTree, /// DominanceFrontier, LoopInfo, and LCCSA but no other analyses. In particular, /// it does not preserve LoopSimplify (because it's complicated to handle the /// case where one of the edges being split is an exit of a loop with other /// exits). -/// +/// void SplitLandingPadPredecessors(BasicBlock *OrigBB,ArrayRef Preds, const char *Suffix, const char *Suffix2, Pass *P, SmallVectorImpl &NewBBs); @@ -199,7 +199,7 @@ ReturnInst *FoldReturnIntoUncondBranch(ReturnInst *RI, BasicBlock *BB, BasicBlock *Pred); -/// GetFirstDebugLocInBasicBlock - Return first valid DebugLoc entry in a +/// GetFirstDebugLocInBasicBlock - Return first valid DebugLoc entry in a /// given basic block. DebugLoc GetFirstDebugLocInBasicBlock(const BasicBlock *BB); Modified: llvm/trunk/lib/Transforms/Utils/BreakCriticalEdges.cpp URL: http://llvm.org/viewvc/llvm-project/llvm/trunk/lib/Transforms/Utils/BreakCriticalEdges.cpp?rev=141058&r1=141057&r2=141058&view=diff ============================================================================== --- llvm/trunk/lib/Transforms/Utils/BreakCriticalEdges.cpp (original) +++ llvm/trunk/lib/Transforms/Utils/BreakCriticalEdges.cpp Mon Oct 3 22:34:49 2011 @@ -102,7 +102,7 @@ ++I; // Skip one edge due to the incoming arc from TI. if (!AllowIdenticalEdges) return I != E; - + // If AllowIdenticalEdges is true, then we allow this edge to be considered // non-critical iff all preds come from TI's block. while (I != E) { @@ -155,10 +155,10 @@ /// This returns the new block if the edge was split, null otherwise. /// /// If MergeIdenticalEdges is true (not the default), *all* edges from TI to the -/// specified successor will be merged into the same critical edge block. -/// This is most commonly interesting with switch instructions, which may +/// specified successor will be merged into the same critical edge block. +/// This is most commonly interesting with switch instructions, which may /// have many edges to any one destination. This ensures that all edges to that -/// dest go to one block instead of each going to a different block, but isn't +/// dest go to one block instead of each going to a different block, but isn't /// the standard definition of a "critical edge". /// /// It is invalid to call this function on a critical edge that starts at an @@ -169,10 +169,10 @@ BasicBlock *llvm::SplitCriticalEdge(TerminatorInst *TI, unsigned SuccNum, Pass *P, bool MergeIdenticalEdges) { if (!isCriticalEdge(TI, SuccNum, MergeIdenticalEdges)) return 0; - + assert(!isa(TI) && "Cannot split critical edge from IndirectBrInst"); - + BasicBlock *TIBB = TI->getParent(); BasicBlock *DestBB = TI->getSuccessor(SuccNum); @@ -194,7 +194,7 @@ Function &F = *TIBB->getParent(); Function::iterator FBBI = TIBB; F.getBasicBlockList().insert(++FBBI, NewBB); - + // If there are any PHI nodes in DestBB, we need to update them so that they // merge incoming values from NewBB instead of from TIBB. { @@ -211,35 +211,35 @@ // happens because the BB list of PHI nodes are usually in the same // order. if (PN->getIncomingBlock(BBIdx) != TIBB) - BBIdx = PN->getBasicBlockIndex(TIBB); + BBIdx = PN->getBasicBlockIndex(TIBB); PN->setIncomingBlock(BBIdx, NewBB); } } - + // If there are any other edges from TIBB to DestBB, update those to go // through the split block, making those edges non-critical as well (and // reducing the number of phi entries in the DestBB if relevant). if (MergeIdenticalEdges) { for (unsigned i = SuccNum+1, e = TI->getNumSuccessors(); i != e; ++i) { if (TI->getSuccessor(i) != DestBB) continue; - + // Remove an entry for TIBB from DestBB phi nodes. DestBB->removePredecessor(TIBB); - + // We found another edge to DestBB, go to NewBB instead. TI->setSuccessor(i, NewBB); } } - - + + // If we don't have a pass object, we can't update anything... if (P == 0) return NewBB; - + DominatorTree *DT = P->getAnalysisIfAvailable(); LoopInfo *LI = P->getAnalysisIfAvailable(); ProfileInfo *PI = P->getAnalysisIfAvailable(); - + // If we have nothing to update, just return. if (DT == 0 && LI == 0 && PI == 0) return NewBB; @@ -267,7 +267,7 @@ } bool NewBBDominatesDestBB = true; - + // Should we update DominatorTree information? if (DT) { DomTreeNode *TINode = DT->getNode(TIBB); @@ -278,7 +278,7 @@ if (TINode) { // Don't break unreachable code! DomTreeNode *NewBBNode = DT->addNewBlock(NewBB, TIBB); DomTreeNode *DestBBNode = 0; - + // If NewBBDominatesDestBB hasn't been computed yet, do so with DT. if (!OtherPreds.empty()) { DestBBNode = DT->getNode(DestBB); @@ -289,7 +289,7 @@ } OtherPreds.clear(); } - + // If NewBBDominatesDestBB, then NewBB dominates DestBB, otherwise it // doesn't dominate anything. if (NewBBDominatesDestBB) { From atrick at apple.com Mon Oct 3 22:50:45 2011 From: atrick at apple.com (Andrew Trick) Date: Tue, 04 Oct 2011 03:50:45 -0000 Subject: [llvm-commits] [llvm] r141059 - in /llvm/trunk: include/llvm/Transforms/Utils/BasicBlockUtils.h lib/Transforms/Scalar/LoopStrengthReduce.cpp lib/Transforms/Utils/BreakCriticalEdges.cpp test/Transforms/LoopStrengthReduce/2011-10-03-CritEdgeMerge.ll Message-ID: <20111004035045.F07DD2A6C12C@llvm.org> Author: atrick Date: Mon Oct 3 22:50:44 2011 New Revision: 141059 URL: http://llvm.org/viewvc/llvm-project?rev=141059&view=rev Log: LSR should avoid redundant edge splitting. This handles the case in which LSR rewrites an IV user that is a phi and splits critical edges originating from a switch. Fixes LSR is not splitting edges "nicely" Added: llvm/trunk/test/Transforms/LoopStrengthReduce/2011-10-03-CritEdgeMerge.ll Modified: llvm/trunk/include/llvm/Transforms/Utils/BasicBlockUtils.h llvm/trunk/lib/Transforms/Scalar/LoopStrengthReduce.cpp llvm/trunk/lib/Transforms/Utils/BreakCriticalEdges.cpp Modified: llvm/trunk/include/llvm/Transforms/Utils/BasicBlockUtils.h URL: http://llvm.org/viewvc/llvm-project/llvm/trunk/include/llvm/Transforms/Utils/BasicBlockUtils.h?rev=141059&r1=141058&r2=141059&view=diff ============================================================================== --- llvm/trunk/include/llvm/Transforms/Utils/BasicBlockUtils.h (original) +++ llvm/trunk/include/llvm/Transforms/Utils/BasicBlockUtils.h Mon Oct 3 22:50:44 2011 @@ -109,7 +109,8 @@ /// to. /// BasicBlock *SplitCriticalEdge(TerminatorInst *TI, unsigned SuccNum, - Pass *P = 0, bool MergeIdenticalEdges = false); + Pass *P = 0, bool MergeIdenticalEdges = false, + bool DontDeleteUselessPHIs = false); inline BasicBlock *SplitCriticalEdge(BasicBlock *BB, succ_iterator SI, Pass *P = 0) { @@ -136,13 +137,15 @@ /// described above. inline BasicBlock *SplitCriticalEdge(BasicBlock *Src, BasicBlock *Dst, Pass *P = 0, - bool MergeIdenticalEdges = false) { + bool MergeIdenticalEdges = false, + bool DontDeleteUselessPHIs = false) { TerminatorInst *TI = Src->getTerminator(); unsigned i = 0; while (1) { assert(i != TI->getNumSuccessors() && "Edge doesn't exist!"); if (TI->getSuccessor(i) == Dst) - return SplitCriticalEdge(TI, i, P, MergeIdenticalEdges); + return SplitCriticalEdge(TI, i, P, MergeIdenticalEdges, + DontDeleteUselessPHIs); ++i; } } Modified: llvm/trunk/lib/Transforms/Scalar/LoopStrengthReduce.cpp URL: http://llvm.org/viewvc/llvm-project/llvm/trunk/lib/Transforms/Scalar/LoopStrengthReduce.cpp?rev=141059&r1=141058&r2=141059&view=diff ============================================================================== --- llvm/trunk/lib/Transforms/Scalar/LoopStrengthReduce.cpp (original) +++ llvm/trunk/lib/Transforms/Scalar/LoopStrengthReduce.cpp Mon Oct 3 22:50:44 2011 @@ -3677,7 +3677,9 @@ // Split the critical edge. BasicBlock *NewBB = 0; if (!Parent->isLandingPad()) { - NewBB = SplitCriticalEdge(BB, Parent, P); + NewBB = SplitCriticalEdge(BB, Parent, P, + /*MergeIdenticalEdges=*/true, + /*DontDeleteUselessPhis=*/true); } else { SmallVector NewBBs; SplitLandingPadPredecessors(Parent, BB, "", "", P, NewBBs); Modified: llvm/trunk/lib/Transforms/Utils/BreakCriticalEdges.cpp URL: http://llvm.org/viewvc/llvm-project/llvm/trunk/lib/Transforms/Utils/BreakCriticalEdges.cpp?rev=141059&r1=141058&r2=141059&view=diff ============================================================================== --- llvm/trunk/lib/Transforms/Utils/BreakCriticalEdges.cpp (original) +++ llvm/trunk/lib/Transforms/Utils/BreakCriticalEdges.cpp Mon Oct 3 22:50:44 2011 @@ -167,7 +167,8 @@ /// to. /// BasicBlock *llvm::SplitCriticalEdge(TerminatorInst *TI, unsigned SuccNum, - Pass *P, bool MergeIdenticalEdges) { + Pass *P, bool MergeIdenticalEdges, + bool DontDeleteUselessPhis) { if (!isCriticalEdge(TI, SuccNum, MergeIdenticalEdges)) return 0; assert(!isa(TI) && @@ -224,7 +225,7 @@ if (TI->getSuccessor(i) != DestBB) continue; // Remove an entry for TIBB from DestBB phi nodes. - DestBB->removePredecessor(TIBB); + DestBB->removePredecessor(TIBB, DontDeleteUselessPhis); // We found another edge to DestBB, go to NewBB instead. TI->setSuccessor(i, NewBB); Added: llvm/trunk/test/Transforms/LoopStrengthReduce/2011-10-03-CritEdgeMerge.ll URL: http://llvm.org/viewvc/llvm-project/llvm/trunk/test/Transforms/LoopStrengthReduce/2011-10-03-CritEdgeMerge.ll?rev=141059&view=auto ============================================================================== --- llvm/trunk/test/Transforms/LoopStrengthReduce/2011-10-03-CritEdgeMerge.ll (added) +++ llvm/trunk/test/Transforms/LoopStrengthReduce/2011-10-03-CritEdgeMerge.ll Mon Oct 3 22:50:44 2011 @@ -0,0 +1,43 @@ +; RUN: opt -loop-reduce -S < %s | FileCheck %s +; +; Test LSR's use of SplitCriticalEdge during phi rewriting. +; Verify that identical edges are merged. rdar://problem/6453893 + +target triple = "x86-apple-darwin" + +; CHECK: @test +; CHECK: bb89: +; CHECK: phi i8* [ %lsr.iv.next1, %bbA.bb89_crit_edge ], [ %lsr.iv.next1, %bbB.bb89_crit_edge ]{{$}} + +define i8* @test() { +entry: + br label %loop + +loop: + %rec = phi i32 [ %next, %loop ], [ 0, %entry ] + %next = add i32 %rec, 1 + %tmp75 = getelementptr i8* null, i32 %next + br i1 false, label %loop, label %loopexit + +loopexit: + br i1 false, label %bbA, label %bbB + +bbA: + switch i32 0, label %bb89 [ + i32 47, label %bb89 + i32 58, label %bb89 + ] + +bbB: + switch i8 0, label %bb89 [ + i8 47, label %bb89 + i8 58, label %bb89 + ] + +bb89: + %tmp75phi = phi i8* [ %tmp75, %bbA ], [ %tmp75, %bbA ], [ %tmp75, %bbA ], [ %tmp75, %bbB ], [ %tmp75, %bbB ], [ %tmp75, %bbB ] + br label %exit + +exit: + ret i8* %tmp75phi +} From nicholas at mxc.ca Tue Oct 4 01:23:06 2011 From: nicholas at mxc.ca (Nick Lewycky) Date: Mon, 03 Oct 2011 23:23:06 -0700 Subject: [llvm-commits] patch: chrec * chrec = chrec. In-Reply-To: <20111003232726.GA13292@britannica.bec.de> References: <4E88F8E3.3050506@mxc.ca> <20111003205157.GA10434@britannica.bec.de> <20111003232726.GA13292@britannica.bec.de> Message-ID: <4E8AA64A.9040505@mxc.ca> Joerg Sonnenberger wrote: > On Mon, Oct 03, 2011 at 02:10:45PM -0700, Nick Lewycky wrote: >> On 3 October 2011 13:51, Joerg Sonnenberger wrote: >>> What exactly is the desired behavior in case of overflow? >>> E.g. do you want to get C(n,k) % (UINTMAX + 1)? In that case, your >>> formula doesn't compute correct results. >>> >> >> In overflow the return value is garbage and Overflow is set. This method >> deserves a comment. > >> From IRC: since n is supposed to be small, it might be better to just > check for n<= 34 and consider it as overflow otherwise. Essentially, > that's the largest number for which C(2n,n)< 2**32. In theory, it would > be possible to compute C(n,k) in the finite field by eliminating the > factors 2 in the divisor and implementing the division using the > multiplicative inverse at the end. That's quite a bit more work though. I tried the simple trick of pulling out 2's before the multiple/divide in Choose() and that only helped a little; in all the cases I could find, the actually loop optimization being performed was guaranteed to overflow on some other Choose(n, k) computation it would do later. It's not clear to me how using multiplicative inverses helps? Can I take each term in the denominator (the terms in k!) and take the inverse of each, and just turn them all into multiplies? For now I'm planning to go ahead with the implementation of Choose() as-is, then we can change it in subsequent patches. Nick From craig.topper at gmail.com Tue Oct 4 01:30:56 2011 From: craig.topper at gmail.com (Craig Topper) Date: Tue, 04 Oct 2011 06:30:56 -0000 Subject: [llvm-commits] [llvm] r141065 - in /llvm/trunk: lib/Target/X86/Disassembler/X86DisassemblerDecoder.c lib/Target/X86/Disassembler/X86DisassemblerDecoderCommon.h lib/Target/X86/MCTargetDesc/X86BaseInfo.h lib/Target/X86/X86InstrFormats.td lib/Target/X86/X86InstrSSE.td test/MC/Disassembler/X86/simple-tests.txt test/MC/Disassembler/X86/x86-32.txt utils/TableGen/X86DisassemblerTables.cpp utils/TableGen/X86DisassemblerTables.h utils/TableGen/X86RecognizableInstr.cpp utils/TableGen/X86RecognizableInstr.h Message-ID: <20111004063056.6B762312800A@llvm.org> Author: ctopper Date: Tue Oct 4 01:30:42 2011 New Revision: 141065 URL: http://llvm.org/viewvc/llvm-project?rev=141065&view=rev Log: Add support in the disassembler for ignoring the L-bit on certain VEX instructions. Mark instructions that have this behavior. Fixes PR10676. Modified: llvm/trunk/lib/Target/X86/Disassembler/X86DisassemblerDecoder.c llvm/trunk/lib/Target/X86/Disassembler/X86DisassemblerDecoderCommon.h llvm/trunk/lib/Target/X86/MCTargetDesc/X86BaseInfo.h llvm/trunk/lib/Target/X86/X86InstrFormats.td llvm/trunk/lib/Target/X86/X86InstrSSE.td llvm/trunk/test/MC/Disassembler/X86/simple-tests.txt llvm/trunk/test/MC/Disassembler/X86/x86-32.txt llvm/trunk/utils/TableGen/X86DisassemblerTables.cpp llvm/trunk/utils/TableGen/X86DisassemblerTables.h llvm/trunk/utils/TableGen/X86RecognizableInstr.cpp llvm/trunk/utils/TableGen/X86RecognizableInstr.h Modified: llvm/trunk/lib/Target/X86/Disassembler/X86DisassemblerDecoder.c URL: http://llvm.org/viewvc/llvm-project/llvm/trunk/lib/Target/X86/Disassembler/X86DisassemblerDecoder.c?rev=141065&r1=141064&r2=141065&view=diff ============================================================================== --- llvm/trunk/lib/Target/X86/Disassembler/X86DisassemblerDecoder.c (original) +++ llvm/trunk/lib/Target/X86/Disassembler/X86DisassemblerDecoder.c Tue Oct 4 01:30:42 2011 @@ -767,8 +767,6 @@ break; } - if (insn->mode == MODE_64BIT && wFromVEX3of3(insn->vexPrefix[2])) - attrMask |= ATTR_REXW; if (lFromVEX3of3(insn->vexPrefix[2])) attrMask |= ATTR_VEXL; } @@ -793,23 +791,55 @@ } } else { - if (insn->rexPrefix & 0x08) - attrMask |= ATTR_REXW; - if (isPrefixAtLocation(insn, 0x66, insn->necessaryPrefixLocation)) attrMask |= ATTR_OPSIZE; else if (isPrefixAtLocation(insn, 0xf3, insn->necessaryPrefixLocation)) attrMask |= ATTR_XS; else if (isPrefixAtLocation(insn, 0xf2, insn->necessaryPrefixLocation)) attrMask |= ATTR_XD; - } + if (insn->rexPrefix & 0x08) + attrMask |= ATTR_REXW; + if (getIDWithAttrMask(&instructionID, insn, attrMask)) return -1; /* The following clauses compensate for limitations of the tables. */ + if ((attrMask & ATTR_VEXL) && (attrMask & ATTR_REXW)) { + /* + * Some VEX instructions ignore the L-bit, but use the W-bit. Normally L-bit + * has precedence since there are no L-bit with W-bit entries in the tables. + * So if the L-bit isn't significant we should use the W-bit instead. + */ + + const struct InstructionSpecifier *spec; + uint16_t instructionIDWithWBit; + const struct InstructionSpecifier *specWithWBit; + + spec = specifierForUID(instructionID); + + if (getIDWithAttrMask(&instructionIDWithWBit, + insn, + (attrMask & (~ATTR_VEXL)) | ATTR_REXW)) { + insn->instructionID = instructionID; + insn->spec = spec; + return 0; + } + + specWithWBit = specifierForUID(instructionIDWithWBit); + + if (instructionID != instructionIDWithWBit) { + insn->instructionID = instructionIDWithWBit; + insn->spec = specWithWBit; + } else { + insn->instructionID = instructionID; + insn->spec = spec; + } + return 0; + } + if ((attrMask & ATTR_XD) && (attrMask & ATTR_REXW)) { /* * Although for SSE instructions it is usually necessary to treat REX.W+F2 Modified: llvm/trunk/lib/Target/X86/Disassembler/X86DisassemblerDecoderCommon.h URL: http://llvm.org/viewvc/llvm-project/llvm/trunk/lib/Target/X86/Disassembler/X86DisassemblerDecoderCommon.h?rev=141065&r1=141064&r2=141065&view=diff ============================================================================== --- llvm/trunk/lib/Target/X86/Disassembler/X86DisassemblerDecoderCommon.h (original) +++ llvm/trunk/lib/Target/X86/Disassembler/X86DisassemblerDecoderCommon.h Tue Oct 4 01:30:42 2011 @@ -107,7 +107,7 @@ ENUM_ENTRY(IC_VEX_W_OPSIZE, 4, "requires VEX, W, and OpSize") \ ENUM_ENTRY(IC_VEX_L, 3, "requires VEX and the L prefix") \ ENUM_ENTRY(IC_VEX_L_XS, 4, "requires VEX and the L and XS prefix")\ - ENUM_ENTRY(IC_VEX_L_XD, 4, "requires VEX and the L and XS prefix")\ + ENUM_ENTRY(IC_VEX_L_XD, 4, "requires VEX and the L and XD prefix")\ ENUM_ENTRY(IC_VEX_L_OPSIZE, 4, "requires VEX, L, and OpSize") Modified: llvm/trunk/lib/Target/X86/MCTargetDesc/X86BaseInfo.h URL: http://llvm.org/viewvc/llvm-project/llvm/trunk/lib/Target/X86/MCTargetDesc/X86BaseInfo.h?rev=141065&r1=141064&r2=141065&view=diff ============================================================================== --- llvm/trunk/lib/Target/X86/MCTargetDesc/X86BaseInfo.h (original) +++ llvm/trunk/lib/Target/X86/MCTargetDesc/X86BaseInfo.h Tue Oct 4 01:30:42 2011 @@ -398,13 +398,17 @@ /// field marked when using a f256 memory references. VEX_L = 1U << 4, + // VEX_LIG - Specifies that this instruction ignores the L-bit in the VEX + // prefix. Usually used for scalar instructions. Needed by disassembler. + VEX_LIG = 1U << 5, + /// Has3DNow0F0FOpcode - This flag indicates that the instruction uses the /// wacky 0x0F 0x0F prefix for 3DNow! instructions. The manual documents /// this as having a 0x0F prefix with a 0x0F opcode, and each instruction /// storing a classifier in the imm8 field. To simplify our implementation, /// we handle this by storeing the classifier in the opcode field and using /// this flag to indicate that the encoder should do the wacky 3DNow! thing. - Has3DNow0F0FOpcode = 1U << 5 + Has3DNow0F0FOpcode = 1U << 6 }; // getBaseOpcodeFor - This function returns the "base" X86 opcode for the Modified: llvm/trunk/lib/Target/X86/X86InstrFormats.td URL: http://llvm.org/viewvc/llvm-project/llvm/trunk/lib/Target/X86/X86InstrFormats.td?rev=141065&r1=141064&r2=141065&view=diff ============================================================================== --- llvm/trunk/lib/Target/X86/X86InstrFormats.td (original) +++ llvm/trunk/lib/Target/X86/X86InstrFormats.td Tue Oct 4 01:30:42 2011 @@ -113,6 +113,7 @@ class VEX_4V : VEX { bit hasVEX_4VPrefix = 1; } class VEX_I8IMM { bit hasVEX_i8ImmReg = 1; } class VEX_L { bit hasVEX_L = 1; } +class VEX_LIG { bit ignoresVEX_L = 1; } class Has3DNow0F0FOpcode { bit has3DNow0F0FOpcode = 1; } class X86Inst opcod, Format f, ImmType i, dag outs, dag ins, @@ -150,6 +151,7 @@ bit hasVEX_i8ImmReg = 0; // Does this inst require the last source register // to be encoded in a immediate field? bit hasVEX_L = 0; // Does this inst use large (256-bit) registers? + bit ignoresVEX_L = 0; // Does this instruction ignore the L-bit bit has3DNow0F0FOpcode =0;// Wacky 3dNow! encoding? // TSFlags layout should be kept in sync with X86InstrInfo.h. @@ -169,7 +171,8 @@ let TSFlags{35} = hasVEX_4VPrefix; let TSFlags{36} = hasVEX_i8ImmReg; let TSFlags{37} = hasVEX_L; - let TSFlags{38} = has3DNow0F0FOpcode; + let TSFlags{38} = ignoresVEX_L; + let TSFlags{39} = has3DNow0F0FOpcode; } class PseudoI pattern> Modified: llvm/trunk/lib/Target/X86/X86InstrSSE.td URL: http://llvm.org/viewvc/llvm-project/llvm/trunk/lib/Target/X86/X86InstrSSE.td?rev=141065&r1=141064&r2=141065&view=diff ============================================================================== --- llvm/trunk/lib/Target/X86/X86InstrSSE.td (original) +++ llvm/trunk/lib/Target/X86/X86InstrSSE.td Tue Oct 4 01:30:42 2011 @@ -342,34 +342,38 @@ // AVX def VMOVSSrr : sse12_move_rr, XS, VEX_4V; + "movss\t{$src2, $src1, $dst|$dst, $src1, $src2}">, XS, VEX_4V, + VEX_LIG; def VMOVSDrr : sse12_move_rr, XD, VEX_4V; + "movsd\t{$src2, $src1, $dst|$dst, $src1, $src2}">, XD, VEX_4V, + VEX_LIG; // For the disassembler let isCodeGenOnly = 1 in { def VMOVSSrr_REV : SI<0x11, MRMDestReg, (outs VR128:$dst), (ins VR128:$src1, FR32:$src2), "movss\t{$src2, $src1, $dst|$dst, $src1, $src2}", []>, - XS, VEX_4V; + XS, VEX_4V, VEX_LIG; def VMOVSDrr_REV : SI<0x11, MRMDestReg, (outs VR128:$dst), (ins VR128:$src1, FR64:$src2), "movsd\t{$src2, $src1, $dst|$dst, $src1, $src2}", []>, - XD, VEX_4V; + XD, VEX_4V, VEX_LIG; } let canFoldAsLoad = 1, isReMaterializable = 1 in { - def VMOVSSrm : sse12_move_rm, XS, VEX; + def VMOVSSrm : sse12_move_rm, XS, VEX, + VEX_LIG; let AddedComplexity = 20 in - def VMOVSDrm : sse12_move_rm, XD, VEX; + def VMOVSDrm : sse12_move_rm, XD, VEX, + VEX_LIG; } def VMOVSSmr : SI<0x11, MRMDestMem, (outs), (ins f32mem:$dst, FR32:$src), "movss\t{$src, $dst|$dst, $src}", - [(store FR32:$src, addr:$dst)]>, XS, VEX; + [(store FR32:$src, addr:$dst)]>, XS, VEX, VEX_LIG; def VMOVSDmr : SI<0x11, MRMDestMem, (outs), (ins f64mem:$dst, FR64:$src), "movsd\t{$src, $dst|$dst, $src}", - [(store FR64:$src, addr:$dst)]>, XD, VEX; + [(store FR64:$src, addr:$dst)]>, XD, VEX, VEX_LIG; // SSE1 & 2 let Constraints = "$src1 = $dst" in { @@ -1344,30 +1348,32 @@ } defm VCVTTSS2SI : sse12_cvt_s<0x2C, FR32, GR32, fp_to_sint, f32mem, loadf32, - "cvttss2si\t{$src, $dst|$dst, $src}">, XS, VEX; + "cvttss2si\t{$src, $dst|$dst, $src}">, XS, VEX, + VEX_LIG; defm VCVTTSS2SI64 : sse12_cvt_s<0x2C, FR32, GR64, fp_to_sint, f32mem, loadf32, "cvttss2si\t{$src, $dst|$dst, $src}">, XS, VEX, - VEX_W; + VEX_W, VEX_LIG; defm VCVTTSD2SI : sse12_cvt_s<0x2C, FR64, GR32, fp_to_sint, f64mem, loadf64, - "cvttsd2si\t{$src, $dst|$dst, $src}">, XD, VEX; + "cvttsd2si\t{$src, $dst|$dst, $src}">, XD, VEX, + VEX_LIG; defm VCVTTSD2SI64 : sse12_cvt_s<0x2C, FR64, GR64, fp_to_sint, f64mem, loadf64, "cvttsd2si\t{$src, $dst|$dst, $src}">, XD, - VEX, VEX_W; + VEX, VEX_W, VEX_LIG; // The assembler can recognize rr 64-bit instructions by seeing a rxx // register, but the same isn't true when only using memory operands, // provide other assembly "l" and "q" forms to address this explicitly // where appropriate to do so. defm VCVTSI2SS : sse12_vcvt_avx<0x2A, GR32, FR32, i32mem, "cvtsi2ss">, XS, - VEX_4V; + VEX_4V, VEX_LIG; defm VCVTSI2SS64 : sse12_vcvt_avx<0x2A, GR64, FR32, i64mem, "cvtsi2ss{q}">, XS, - VEX_4V, VEX_W; + VEX_4V, VEX_W, VEX_LIG; defm VCVTSI2SD : sse12_vcvt_avx<0x2A, GR32, FR64, i32mem, "cvtsi2sd">, XD, - VEX_4V; + VEX_4V, VEX_LIG; defm VCVTSI2SDL : sse12_vcvt_avx<0x2A, GR32, FR64, i32mem, "cvtsi2sd{l}">, XD, - VEX_4V; + VEX_4V, VEX_LIG; defm VCVTSI2SD64 : sse12_vcvt_avx<0x2A, GR64, FR64, i64mem, "cvtsi2sd{q}">, XD, - VEX_4V, VEX_W; + VEX_4V, VEX_W, VEX_LIG; let Predicates = [HasAVX] in { def : Pat<(f32 (sint_to_fp (loadi32 addr:$src))), @@ -1447,9 +1453,10 @@ // intructions that only match with the intrinsic form, why create duplicates // to let them be recognized by the assembler? defm VCVTSD2SI : sse12_cvt_s_np<0x2D, FR64, GR32, f64mem, - "cvtsd2si\t{$src, $dst|$dst, $src}">, XD, VEX; + "cvtsd2si\t{$src, $dst|$dst, $src}">, XD, VEX, VEX_LIG; defm VCVTSD2SI64 : sse12_cvt_s_np<0x2D, FR64, GR64, f64mem, - "cvtsd2si\t{$src, $dst|$dst, $src}">, XD, VEX, VEX_W; + "cvtsd2si\t{$src, $dst|$dst, $src}">, XD, VEX, VEX_W, + VEX_LIG; defm CVTSD2SI : sse12_cvt_sint<0x2D, VR128, GR32, int_x86_sse2_cvtsd2si, f128mem, load, "cvtsd2si{l}">, XD; @@ -1509,10 +1516,11 @@ let Pattern = [] in { defm VCVTSS2SI : sse12_cvt_s<0x2D, FR32, GR32, undef, f32mem, load, - "cvtss2si{l}\t{$src, $dst|$dst, $src}">, XS, VEX; + "cvtss2si{l}\t{$src, $dst|$dst, $src}">, XS, + VEX, VEX_LIG; defm VCVTSS2SI64 : sse12_cvt_s<0x2D, FR32, GR64, undef, f32mem, load, "cvtss2si\t{$src, $dst|$dst, $src}">, XS, VEX, - VEX_W; + VEX_W, VEX_LIG; defm VCVTDQ2PS : sse12_cvt_p<0x5B, VR128, VR128, undef, i128mem, load, "cvtdq2ps\t{$src, $dst|$dst, $src}", SSEPackedSingle>, TB, VEX; @@ -1559,12 +1567,12 @@ def VCVTSD2SSrr : VSDI<0x5A, MRMSrcReg, (outs FR32:$dst), (ins FR64:$src1, FR64:$src2), "cvtsd2ss\t{$src2, $src1, $dst|$dst, $src1, $src2}", []>, - VEX_4V; + VEX_4V, VEX_LIG; let mayLoad = 1 in def VCVTSD2SSrm : I<0x5A, MRMSrcMem, (outs FR32:$dst), (ins FR64:$src1, f64mem:$src2), "vcvtsd2ss\t{$src2, $src1, $dst|$dst, $src1, $src2}", - []>, XD, Requires<[HasAVX, OptForSize]>, VEX_4V; + []>, XD, Requires<[HasAVX, OptForSize]>, VEX_4V, VEX_LIG; def : Pat<(f32 (fround FR64:$src)), (VCVTSD2SSrr FR64:$src, FR64:$src)>, Requires<[HasAVX]>; @@ -1589,12 +1597,12 @@ def VCVTSS2SDrr : I<0x5A, MRMSrcReg, (outs FR64:$dst), (ins FR32:$src1, FR32:$src2), "vcvtss2sd\t{$src2, $src1, $dst|$dst, $src1, $src2}", - []>, XS, Requires<[HasAVX]>, VEX_4V; + []>, XS, Requires<[HasAVX]>, VEX_4V, VEX_LIG; let mayLoad = 1 in def VCVTSS2SDrm : I<0x5A, MRMSrcMem, (outs FR64:$dst), (ins FR32:$src1, f32mem:$src2), "vcvtss2sd\t{$src2, $src1, $dst|$dst, $src1, $src2}", - []>, XS, VEX_4V, Requires<[HasAVX, OptForSize]>; + []>, XS, VEX_4V, VEX_LIG, Requires<[HasAVX, OptForSize]>; let Predicates = [HasAVX] in { def : Pat<(f64 (fextend FR32:$src)), @@ -1986,11 +1994,11 @@ defm VCMPSS : sse12_cmp_scalar, - XS, VEX_4V; + XS, VEX_4V, VEX_LIG; defm VCMPSD : sse12_cmp_scalar, - XD, VEX_4V; + XD, VEX_4V, VEX_LIG; let Constraints = "$src1 = $dst" in { defm CMPSS : sse12_cmp_scalar, TB, VEX; + "ucomiss", SSEPackedSingle>, TB, VEX, VEX_LIG; defm VUCOMISD : sse12_ord_cmp<0x2E, FR64, X86cmp, f64, f64mem, loadf64, - "ucomisd", SSEPackedDouble>, TB, OpSize, VEX; + "ucomisd", SSEPackedDouble>, TB, OpSize, VEX, + VEX_LIG; let Pattern = [] in { defm VCOMISS : sse12_ord_cmp<0x2F, VR128, undef, v4f32, f128mem, load, - "comiss", SSEPackedSingle>, TB, VEX; + "comiss", SSEPackedSingle>, TB, VEX, + VEX_LIG; defm VCOMISD : sse12_ord_cmp<0x2F, VR128, undef, v2f64, f128mem, load, - "comisd", SSEPackedDouble>, TB, OpSize, VEX; + "comisd", SSEPackedDouble>, TB, OpSize, VEX, + VEX_LIG; } defm Int_VUCOMISS : sse12_ord_cmp<0x2E, VR128, X86ucomi, v4f32, f128mem, @@ -2744,32 +2755,32 @@ // Binary Arithmetic instructions defm VADD : basic_sse12_fp_binop_s<0x58, "add", fadd, 0>, - basic_sse12_fp_binop_s_int<0x58, "add", 0>, - basic_sse12_fp_binop_p<0x58, "add", fadd, 0>, + basic_sse12_fp_binop_s_int<0x58, "add", 0>, VEX_4V, VEX_LIG; +defm VADD : basic_sse12_fp_binop_p<0x58, "add", fadd, 0>, basic_sse12_fp_binop_p_y<0x58, "add", fadd>, VEX_4V; defm VMUL : basic_sse12_fp_binop_s<0x59, "mul", fmul, 0>, - basic_sse12_fp_binop_s_int<0x59, "mul", 0>, - basic_sse12_fp_binop_p<0x59, "mul", fmul, 0>, + basic_sse12_fp_binop_s_int<0x59, "mul", 0>, VEX_4V, VEX_LIG; +defm VMUL : basic_sse12_fp_binop_p<0x59, "mul", fmul, 0>, basic_sse12_fp_binop_p_y<0x59, "mul", fmul>, VEX_4V; let isCommutable = 0 in { defm VSUB : basic_sse12_fp_binop_s<0x5C, "sub", fsub, 0>, - basic_sse12_fp_binop_s_int<0x5C, "sub", 0>, - basic_sse12_fp_binop_p<0x5C, "sub", fsub, 0>, + basic_sse12_fp_binop_s_int<0x5C, "sub", 0>, VEX_4V, VEX_LIG; + defm VSUB : basic_sse12_fp_binop_p<0x5C, "sub", fsub, 0>, basic_sse12_fp_binop_p_y<0x5C, "sub", fsub>, VEX_4V; defm VDIV : basic_sse12_fp_binop_s<0x5E, "div", fdiv, 0>, - basic_sse12_fp_binop_s_int<0x5E, "div", 0>, - basic_sse12_fp_binop_p<0x5E, "div", fdiv, 0>, + basic_sse12_fp_binop_s_int<0x5E, "div", 0>, VEX_4V, VEX_LIG; + defm VDIV : basic_sse12_fp_binop_p<0x5E, "div", fdiv, 0>, basic_sse12_fp_binop_p_y<0x5E, "div", fdiv>, VEX_4V; defm VMAX : basic_sse12_fp_binop_s<0x5F, "max", X86fmax, 0>, - basic_sse12_fp_binop_s_int<0x5F, "max", 0>, - basic_sse12_fp_binop_p<0x5F, "max", X86fmax, 0>, + basic_sse12_fp_binop_s_int<0x5F, "max", 0>, VEX_4V, VEX_LIG; + defm VMAX : basic_sse12_fp_binop_p<0x5F, "max", X86fmax, 0>, basic_sse12_fp_binop_p_int<0x5F, "max", 0>, basic_sse12_fp_binop_p_y<0x5F, "max", X86fmax>, basic_sse12_fp_binop_p_y_int<0x5F, "max">, VEX_4V; defm VMIN : basic_sse12_fp_binop_s<0x5D, "min", X86fmin, 0>, - basic_sse12_fp_binop_s_int<0x5D, "min", 0>, - basic_sse12_fp_binop_p<0x5D, "min", X86fmin, 0>, + basic_sse12_fp_binop_s_int<0x5D, "min", 0>, VEX_4V, VEX_LIG; + defm VMIN : basic_sse12_fp_binop_p<0x5D, "min", X86fmin, 0>, basic_sse12_fp_binop_p_int<0x5D, "min", 0>, basic_sse12_fp_binop_p_y_int<0x5D, "min">, basic_sse12_fp_binop_p_y<0x5D, "min", X86fmin>, VEX_4V; @@ -2967,7 +2978,7 @@ let Predicates = [HasAVX] in { // Square root. defm VSQRT : sse1_fp_unop_s_avx<0x51, "vsqrt">, - sse2_fp_unop_s_avx<0x51, "vsqrt">, VEX_4V; + sse2_fp_unop_s_avx<0x51, "vsqrt">, VEX_4V, VEX_LIG; defm VSQRT : sse1_fp_unop_p<0x51, "vsqrt", fsqrt>, sse2_fp_unop_p<0x51, "vsqrt", fsqrt>, @@ -2981,13 +2992,13 @@ // Reciprocal approximations. Note that these typically require refinement // in order to obtain suitable precision. - defm VRSQRT : sse1_fp_unop_s_avx<0x52, "vrsqrt">, VEX_4V; + defm VRSQRT : sse1_fp_unop_s_avx<0x52, "vrsqrt">, VEX_4V, VEX_LIG; defm VRSQRT : sse1_fp_unop_p<0x52, "vrsqrt", X86frsqrt>, sse1_fp_unop_p_y<0x52, "vrsqrt", X86frsqrt>, sse1_fp_unop_p_y_int<0x52, "vrsqrt", int_x86_avx_rsqrt_ps_256>, sse1_fp_unop_p_int<0x52, "vrsqrt", int_x86_sse_rsqrt_ps>, VEX; - defm VRCP : sse1_fp_unop_s_avx<0x53, "vrcp">, VEX_4V; + defm VRCP : sse1_fp_unop_s_avx<0x53, "vrcp">, VEX_4V, VEX_LIG; defm VRCP : sse1_fp_unop_p<0x53, "vrcp", X86frcp>, sse1_fp_unop_p_y<0x53, "vrcp", X86frcp>, sse1_fp_unop_p_y_int<0x53, "vrcp", int_x86_avx_rcp_ps_256>, @@ -5612,14 +5623,14 @@ int_x86_avx_round_pd_256>, VEX; defm VROUND : sse41_fp_binop_rm<0x0A, 0x0B, "vround", int_x86_sse41_round_ss, - int_x86_sse41_round_sd, 0>, VEX_4V; + int_x86_sse41_round_sd, 0>, VEX_4V, VEX_LIG; // Instructions for the assembler defm VROUND : sse41_fp_unop_rm_avx_p<0x08, 0x09, VR128, f128mem, "vround">, VEX; defm VROUNDY : sse41_fp_unop_rm_avx_p<0x08, 0x09, VR256, f256mem, "vround">, VEX; - defm VROUND : sse41_fp_binop_rm_avx_s<0x0A, 0x0B, "vround">, VEX_4V; + defm VROUND : sse41_fp_binop_rm_avx_s<0x0A, 0x0B, "vround">, VEX_4V, VEX_LIG; } defm ROUND : sse41_fp_unop_rm<0x08, 0x09, "round", f128mem, VR128, Modified: llvm/trunk/test/MC/Disassembler/X86/simple-tests.txt URL: http://llvm.org/viewvc/llvm-project/llvm/trunk/test/MC/Disassembler/X86/simple-tests.txt?rev=141065&r1=141064&r2=141065&view=diff ============================================================================== --- llvm/trunk/test/MC/Disassembler/X86/simple-tests.txt (original) +++ llvm/trunk/test/MC/Disassembler/X86/simple-tests.txt Tue Oct 4 01:30:42 2011 @@ -395,3 +395,30 @@ # CHECK: rdrandq %rax 0x48 0x0f 0xc7 0xf0 + +# CHECK: vroundss $0, %xmm0, %xmm0, %xmm0 +0xc4 0xe3 0x7d 0x0a 0xc0 0x00 + +# CHECK: vroundsd $0, %xmm0, %xmm0, %xmm0 +0xc4 0xe3 0x7d 0x0b 0xc0 0x00 + +# CHECK: vcvtsd2si %xmm0, %eax +0xc4 0xe1 0x7f 0x2d 0xc0 + +# CHECK: vcvtsd2si %xmm0, %rax +0xc4 0xe1 0xff 0x2d 0xc0 + +# CHECK: vucomisd %xmm1, %xmm0 +0xc5 0xfd 0x2e 0xc1 + +# CHECK: vucomiss %xmm1, %xmm0 +0xc5 0xfc 0x2e 0xc1 + +# CHECK: vcomisd %xmm1, %xmm0 +0xc5 0xfd 0x2f 0xc1 + +# CHECK: vcomiss %xmm1, %xmm0 +0xc5 0xfc 0x2f 0xc1 + +# CHECK: vaddss %xmm1, %xmm0, %xmm0 +0xc5 0xfe 0x58 0xc1 Modified: llvm/trunk/test/MC/Disassembler/X86/x86-32.txt URL: http://llvm.org/viewvc/llvm-project/llvm/trunk/test/MC/Disassembler/X86/x86-32.txt?rev=141065&r1=141064&r2=141065&view=diff ============================================================================== --- llvm/trunk/test/MC/Disassembler/X86/x86-32.txt (original) +++ llvm/trunk/test/MC/Disassembler/X86/x86-32.txt Tue Oct 4 01:30:42 2011 @@ -405,3 +405,30 @@ # CHECK: rdrandl %eax 0x0f 0xc7 0xf0 + +# CHECK: vroundss $0, %xmm0, %xmm0, %xmm0 +0xc4 0xe3 0x7d 0x0a 0xc0 0x00 + +# CHECK: vroundsd $0, %xmm0, %xmm0, %xmm0 +0xc4 0xe3 0x7d 0x0b 0xc0 0x00 + +# CHECK: vcvtsd2si %xmm0, %eax +0xc4 0xe1 0x7f 0x2d 0xc0 + +# CHECK: vcvtsd2si %xmm0, %eax +0xc4 0xe1 0xff 0x2d 0xc0 + +# CHECK: vucomisd %xmm1, %xmm0 +0xc5 0xfd 0x2e 0xc1 + +# CHECK: vucomiss %xmm1, %xmm0 +0xc5 0xfc 0x2e 0xc1 + +# CHECK: vcomisd %xmm1, %xmm0 +0xc5 0xfd 0x2f 0xc1 + +# CHECK: vcomiss %xmm1, %xmm0 +0xc5 0xfc 0x2f 0xc1 + +# CHECK: vaddss %xmm1, %xmm0, %xmm0 +0xc5 0xfe 0x58 0xc1 Modified: llvm/trunk/utils/TableGen/X86DisassemblerTables.cpp URL: http://llvm.org/viewvc/llvm-project/llvm/trunk/utils/TableGen/X86DisassemblerTables.cpp?rev=141065&r1=141064&r2=141065&view=diff ============================================================================== --- llvm/trunk/utils/TableGen/X86DisassemblerTables.cpp (original) +++ llvm/trunk/utils/TableGen/X86DisassemblerTables.cpp Tue Oct 4 01:30:42 2011 @@ -32,7 +32,8 @@ /// @param parent - The class that may be the superset /// @return - True if child is a subset of parent, false otherwise. static inline bool inheritsFrom(InstructionContext child, - InstructionContext parent) { + InstructionContext parent, + bool VEX_LIG = false) { if (child == parent) return true; @@ -68,33 +69,29 @@ case IC_64BIT_XD_OPSIZE: return false; case IC_64BIT_REXW_XD: - return false; case IC_64BIT_REXW_XS: - return false; case IC_64BIT_REXW_OPSIZE: return false; case IC_VEX: - return inheritsFrom(child, IC_VEX_W); + return inheritsFrom(child, IC_VEX_W) || + (VEX_LIG && inheritsFrom(child, IC_VEX_L)); case IC_VEX_XS: - return inheritsFrom(child, IC_VEX_W_XS); + return inheritsFrom(child, IC_VEX_W_XS) || + (VEX_LIG && inheritsFrom(child, IC_VEX_L_XS)); case IC_VEX_XD: - return inheritsFrom(child, IC_VEX_W_XD); + return inheritsFrom(child, IC_VEX_W_XD) || + (VEX_LIG && inheritsFrom(child, IC_VEX_L_XD)); case IC_VEX_OPSIZE: - return inheritsFrom(child, IC_VEX_W_OPSIZE); + return inheritsFrom(child, IC_VEX_W_OPSIZE) || + (VEX_LIG && inheritsFrom(child, IC_VEX_L_OPSIZE)); case IC_VEX_W: - return false; case IC_VEX_W_XS: - return false; case IC_VEX_W_XD: - return false; case IC_VEX_W_OPSIZE: return false; case IC_VEX_L: - return false; case IC_VEX_L_XS: - return false; case IC_VEX_L_XD: - return false; case IC_VEX_L_OPSIZE: return false; default: @@ -651,7 +648,8 @@ uint8_t opcode, const ModRMFilter &filter, InstrUID uid, - bool is32bit) { + bool is32bit, + bool ignoresVEX_L) { unsigned index; ContextDecision &decision = *Tables[type]; @@ -661,7 +659,7 @@ continue; if (inheritsFrom((InstructionContext)index, - InstructionSpecifiers[uid].insnContext)) + InstructionSpecifiers[uid].insnContext, ignoresVEX_L)) setTableFields(decision.opcodeDecisions[index].modRMDecisions[opcode], filter, uid, Modified: llvm/trunk/utils/TableGen/X86DisassemblerTables.h URL: http://llvm.org/viewvc/llvm-project/llvm/trunk/utils/TableGen/X86DisassemblerTables.h?rev=141065&r1=141064&r2=141065&view=diff ============================================================================== --- llvm/trunk/utils/TableGen/X86DisassemblerTables.h (original) +++ llvm/trunk/utils/TableGen/X86DisassemblerTables.h Tue Oct 4 01:30:42 2011 @@ -261,12 +261,14 @@ /// correspond to the desired instruction. /// @param uid - The unique ID of the instruction. /// @param is32bit - Instructon is only 32-bit + /// @param ignoresVEX_L - Instruction ignores VEX.L void setTableFields(OpcodeType type, InstructionContext insnContext, uint8_t opcode, const ModRMFilter &filter, InstrUID uid, - bool is32bit); + bool is32bit, + bool ignoresVEX_L); /// specForUID - Returns the instruction specifier for a given unique /// instruction ID. Used when resolving collisions. Modified: llvm/trunk/utils/TableGen/X86RecognizableInstr.cpp URL: http://llvm.org/viewvc/llvm-project/llvm/trunk/utils/TableGen/X86RecognizableInstr.cpp?rev=141065&r1=141064&r2=141065&view=diff ============================================================================== --- llvm/trunk/utils/TableGen/X86RecognizableInstr.cpp (original) +++ llvm/trunk/utils/TableGen/X86RecognizableInstr.cpp Tue Oct 4 01:30:42 2011 @@ -217,6 +217,7 @@ HasVEXPrefix = Rec->getValueAsBit("hasVEXPrefix"); HasVEX_4VPrefix = Rec->getValueAsBit("hasVEX_4VPrefix"); HasVEX_WPrefix = Rec->getValueAsBit("hasVEX_WPrefix"); + IgnoresVEX_L = Rec->getValueAsBit("ignoresVEX_L"); HasLockPrefix = Rec->getValueAsBit("hasLockPrefix"); IsCodeGenOnly = Rec->getValueAsBit("isCodeGenOnly"); @@ -284,7 +285,9 @@ InstructionContext insnContext; if (HasVEX_4VPrefix || HasVEXPrefix) { - if (HasOpSizePrefix && HasVEX_LPrefix) + if (HasVEX_LPrefix && HasVEX_WPrefix) + llvm_unreachable("Don't support VEX.L and VEX.W together"); + else if (HasOpSizePrefix && HasVEX_LPrefix) insnContext = IC_VEX_L_OPSIZE; else if (HasOpSizePrefix && HasVEX_WPrefix) insnContext = IC_VEX_W_OPSIZE; @@ -957,7 +960,7 @@ insnContext(), currentOpcode, *filter, - UID, Is32Bit); + UID, Is32Bit, IgnoresVEX_L); Spec->modifierType = MODIFIER_OPCODE; Spec->modifierBase = opcodeToSet; @@ -967,14 +970,14 @@ insnContext(), opcodeToSet, *filter, - UID, Is32Bit); + UID, Is32Bit, IgnoresVEX_L); } } else { tables.setTableFields(opcodeType, insnContext(), opcodeToSet, *filter, - UID, Is32Bit); + UID, Is32Bit, IgnoresVEX_L); Spec->modifierType = MODIFIER_NONE; Spec->modifierBase = opcodeToSet; Modified: llvm/trunk/utils/TableGen/X86RecognizableInstr.h URL: http://llvm.org/viewvc/llvm-project/llvm/trunk/utils/TableGen/X86RecognizableInstr.h?rev=141065&r1=141064&r2=141065&view=diff ============================================================================== --- llvm/trunk/utils/TableGen/X86RecognizableInstr.h (original) +++ llvm/trunk/utils/TableGen/X86RecognizableInstr.h Tue Oct 4 01:30:42 2011 @@ -60,6 +60,8 @@ bool HasVEX_WPrefix; /// Inferred from the operands; indicates whether the L bit in the VEX prefix is set bool HasVEX_LPrefix; + // The ignoreVEX_L field from the record + bool IgnoresVEX_L; /// The hasLockPrefix field from the record bool HasLockPrefix; /// The isCodeGenOnly filed from the record From nicholas at mxc.ca Tue Oct 4 01:51:27 2011 From: nicholas at mxc.ca (Nick Lewycky) Date: Tue, 04 Oct 2011 06:51:27 -0000 Subject: [llvm-commits] [llvm] r141066 - in /llvm/trunk: include/llvm/Analysis/ScalarEvolution.h lib/Analysis/ScalarEvolution.cpp unittests/Analysis/ScalarEvolutionTest.cpp Message-ID: <20111004065128.2B4BB312800A@llvm.org> Author: nicholas Date: Tue Oct 4 01:51:26 2011 New Revision: 141066 URL: http://llvm.org/viewvc/llvm-project?rev=141066&view=rev Log: The product of two chrec's can always be represented as a chrec. Modified: llvm/trunk/include/llvm/Analysis/ScalarEvolution.h llvm/trunk/lib/Analysis/ScalarEvolution.cpp llvm/trunk/unittests/Analysis/ScalarEvolutionTest.cpp Modified: llvm/trunk/include/llvm/Analysis/ScalarEvolution.h URL: http://llvm.org/viewvc/llvm-project/llvm/trunk/include/llvm/Analysis/ScalarEvolution.h?rev=141066&r1=141065&r2=141066&view=diff ============================================================================== --- llvm/trunk/include/llvm/Analysis/ScalarEvolution.h (original) +++ llvm/trunk/include/llvm/Analysis/ScalarEvolution.h Tue Oct 4 01:51:26 2011 @@ -588,6 +588,14 @@ Ops.push_back(RHS); return getMulExpr(Ops, Flags); } + const SCEV *getMulExpr(const SCEV *Op0, const SCEV *Op1, const SCEV *Op2, + SCEV::NoWrapFlags Flags = SCEV::FlagAnyWrap) { + SmallVector Ops; + Ops.push_back(Op0); + Ops.push_back(Op1); + Ops.push_back(Op2); + return getMulExpr(Ops, Flags); + } const SCEV *getUDivExpr(const SCEV *LHS, const SCEV *RHS); const SCEV *getAddRecExpr(const SCEV *Start, const SCEV *Step, const Loop *L, SCEV::NoWrapFlags Flags); Modified: llvm/trunk/lib/Analysis/ScalarEvolution.cpp URL: http://llvm.org/viewvc/llvm-project/llvm/trunk/lib/Analysis/ScalarEvolution.cpp?rev=141066&r1=141065&r2=141066&view=diff ============================================================================== --- llvm/trunk/lib/Analysis/ScalarEvolution.cpp (original) +++ llvm/trunk/lib/Analysis/ScalarEvolution.cpp Tue Oct 4 01:51:26 2011 @@ -1812,6 +1812,38 @@ return S; } +static uint64_t umul_ov(uint64_t i, uint64_t j, bool &Overflow) { + uint64_t k = i*j; + if (j > 1 && k / j != i) Overflow = true; + return k; +} + +/// Compute the result of "n choose k", the binomial coefficient. If an +/// intermediate computation overflows, Overflow will be set and the return will +/// be garbage. Overflow is not cleared on absense of overflow. +static uint64_t Choose(uint64_t n, uint64_t k, bool &Overflow) { + // We use the multiplicative formula: + // n(n-1)(n-2)...(n-(k-1)) / k(k-1)(k-2)...1 . + // At each iteration, we take the n-th term of the numeral and divide by the + // (k-n)th term of the denominator. This division will always produce an + // integral result, and helps reduce the chance of overflow in the + // intermediate computations. However, we can still overflow even when the + // final result would fit. + + if (n == 0 || n == k) return 1; + if (k > n) return 0; + + if (k > n/2) + k = n-k; + + uint64_t r = 1; + for (uint64_t i = 1; i <= k; ++i) { + r = umul_ov(r, n-(i-1), Overflow); + r /= i; + } + return r; +} + /// getMulExpr - Get a canonical multiply expression, or something simpler if /// possible. const SCEV *ScalarEvolution::getMulExpr(SmallVectorImpl &Ops, @@ -1987,53 +2019,61 @@ for (unsigned OtherIdx = Idx+1; OtherIdx < Ops.size() && isa(Ops[OtherIdx]); ++OtherIdx) { - bool Retry = false; if (AddRecLoop == cast(Ops[OtherIdx])->getLoop()) { - // {A,+,B} * {C,+,D} --> {A*C,+,A*D + B*C + B*D,+,2*B*D} + // {A1,+,A2,+,...,+,An} * {B1,+,B2,+,...,+,Bn} + // = {x=1 in [ sum y=x..2x [ sum z=max(y-x, y-n)..min(x,n) [ + // choose(x, 2x)*choose(2x-y, x-z)*A_{y-z}*B_z + // ]]],+,...up to x=2n}. + // Note that the arguments to choose() are always integers with values + // known at compile time, never SCEV objects. // - // {A,+,B} * {C,+,D} = A+It*B * C+It*D = A*C + (A*D + B*C)*It + B*D*It^2 - // Given an equation of the form x + y*It + z*It^2 (above), we want to - // express it in terms of {X,+,Y,+,Z}. - // {X,+,Y,+,Z} = X + Y*It + Z*(It^2 - It)/2. - // Rearranging, X = x, Y = y+z, Z = 2z. - // - // x = A*C, y = (A*D + B*C), z = B*D. - // Therefore X = A*C, Y = A*D + B*C + B*D and Z = 2*B*D. + // The implementation avoids pointless extra computations when the two + // addrec's are of different length (mathematically, it's equivalent to + // an infinite stream of zeros on the right). + bool OpsModified = false; for (; OtherIdx != Ops.size() && isa(Ops[OtherIdx]); ++OtherIdx) if (const SCEVAddRecExpr *OtherAddRec = dyn_cast(Ops[OtherIdx])) if (OtherAddRec->getLoop() == AddRecLoop) { - const SCEV *A = AddRec->getStart(); - const SCEV *B = AddRec->getStepRecurrence(*this); - const SCEV *C = OtherAddRec->getStart(); - const SCEV *D = OtherAddRec->getStepRecurrence(*this); - const SCEV *NewStart = getMulExpr(A, C); - const SCEV *BD = getMulExpr(B, D); - const SCEV *NewStep = getAddExpr(getMulExpr(A, D), - getMulExpr(B, C), BD); - const SCEV *NewSecondOrderStep = - getMulExpr(BD, getConstant(BD->getType(), 2)); - - // This can happen when AddRec or OtherAddRec have >3 operands. - // TODO: support these add-recs. - if (isLoopInvariant(NewStart, AddRecLoop) && - isLoopInvariant(NewStep, AddRecLoop) && - isLoopInvariant(NewSecondOrderStep, AddRecLoop)) { - SmallVector AddRecOps; - AddRecOps.push_back(NewStart); - AddRecOps.push_back(NewStep); - AddRecOps.push_back(NewSecondOrderStep); + bool Overflow = false; + Type *Ty = AddRec->getType(); + bool LargerThan64Bits = getTypeSizeInBits(Ty) > 64; + SmallVector AddRecOps; + for (int x = 0, xe = AddRec->getNumOperands() + + OtherAddRec->getNumOperands() - 1; + x != xe && !Overflow; ++x) { + const SCEV *Term = getConstant(Ty, 0); + for (int y = x, ye = 2*x+1; y != ye && !Overflow; ++y) { + uint64_t Coeff1 = Choose(x, 2*x - y, Overflow); + for (int z = std::max(y-x, y-(int)AddRec->getNumOperands()+1), + ze = std::min(x+1, (int)OtherAddRec->getNumOperands()); + z < ze && !Overflow; ++z) { + uint64_t Coeff2 = Choose(2*x - y, x-z, Overflow); + uint64_t Coeff; + if (LargerThan64Bits) + Coeff = umul_ov(Coeff1, Coeff2, Overflow); + else + Coeff = Coeff1*Coeff2; + const SCEV *CoeffTerm = getConstant(Ty, Coeff); + const SCEV *Term1 = AddRec->getOperand(y-z); + const SCEV *Term2 = OtherAddRec->getOperand(z); + Term = getAddExpr(Term, getMulExpr(CoeffTerm, Term1,Term2)); + } + } + AddRecOps.push_back(Term); + } + if (!Overflow) { const SCEV *NewAddRec = getAddRecExpr(AddRecOps, AddRec->getLoop(), SCEV::FlagAnyWrap); if (Ops.size() == 2) return NewAddRec; Ops[Idx] = AddRec = cast(NewAddRec); Ops.erase(Ops.begin() + OtherIdx); --OtherIdx; - Retry = true; + OpsModified = true; } } - if (Retry) + if (OpsModified) return getMulExpr(Ops); } } Modified: llvm/trunk/unittests/Analysis/ScalarEvolutionTest.cpp URL: http://llvm.org/viewvc/llvm-project/llvm/trunk/unittests/Analysis/ScalarEvolutionTest.cpp?rev=141066&r1=141065&r2=141066&view=diff ============================================================================== --- llvm/trunk/unittests/Analysis/ScalarEvolutionTest.cpp (original) +++ llvm/trunk/unittests/Analysis/ScalarEvolutionTest.cpp Tue Oct 4 01:51:26 2011 @@ -8,20 +8,35 @@ //===----------------------------------------------------------------------===// #include +#include #include #include #include #include #include +#include #include "gtest/gtest.h" namespace llvm { namespace { -TEST(ScalarEvolutionsTest, SCEVUnknownRAUW) { +// We use this fixture to ensure that we clean up ScalarEvolution before +// deleting the PassManager. +class ScalarEvolutionsTest : public testing::Test { +protected: + ScalarEvolutionsTest() : M("", Context), SE(*new ScalarEvolution) {} + ~ScalarEvolutionsTest() { + // Manually clean up, since we allocated new SCEV objects after the + // pass was finished. + SE.releaseMemory(); + } LLVMContext Context; - Module M("world", Context); + Module M; + PassManager PM; + ScalarEvolution &SE; +}; +TEST_F(ScalarEvolutionsTest, SCEVUnknownRAUW) { FunctionType *FTy = FunctionType::get(Type::getVoidTy(Context), std::vector(), false); Function *F = cast(M.getOrInsertFunction("f", FTy)); @@ -35,8 +50,6 @@ Value *V2 = new GlobalVariable(M, Ty, false, GlobalValue::ExternalLinkage, Init, "V2"); // Create a ScalarEvolution and "run" it so that it gets initialized. - PassManager PM; - ScalarEvolution &SE = *new ScalarEvolution(); PM.add(&SE); PM.run(M); @@ -72,10 +85,149 @@ EXPECT_EQ(cast(M0->getOperand(1))->getValue(), V0); EXPECT_EQ(cast(M1->getOperand(1))->getValue(), V0); EXPECT_EQ(cast(M2->getOperand(1))->getValue(), V0); +} + +TEST_F(ScalarEvolutionsTest, SCEVMultiplyAddRecs) { + Type *Ty = Type::getInt32Ty(Context); + SmallVector Types; + Types.append(10, Ty); + FunctionType *FTy = FunctionType::get(Type::getVoidTy(Context), Types, false); + Function *F = cast(M.getOrInsertFunction("f", FTy)); + BasicBlock *BB = BasicBlock::Create(Context, "entry", F); + ReturnInst::Create(Context, 0, BB); + + // Create a ScalarEvolution and "run" it so that it gets initialized. + PM.add(&SE); + PM.run(M); + + // It's possible to produce an empty loop through the default constructor, + // but you can't add any blocks to it without a LoopInfo pass. + Loop L; + const_cast&>(L.getBlocks()).push_back(BB); + + Function::arg_iterator AI = F->arg_begin(); + SmallVector A; + A.push_back(SE.getSCEV(&*AI++)); + A.push_back(SE.getSCEV(&*AI++)); + A.push_back(SE.getSCEV(&*AI++)); + A.push_back(SE.getSCEV(&*AI++)); + A.push_back(SE.getSCEV(&*AI++)); + const SCEV *A_rec = SE.getAddRecExpr(A, &L, SCEV::FlagAnyWrap); + + SmallVector B; + B.push_back(SE.getSCEV(&*AI++)); + B.push_back(SE.getSCEV(&*AI++)); + B.push_back(SE.getSCEV(&*AI++)); + B.push_back(SE.getSCEV(&*AI++)); + B.push_back(SE.getSCEV(&*AI++)); + const SCEV *B_rec = SE.getAddRecExpr(B, &L, SCEV::FlagAnyWrap); + + /* Spot check that we perform this transformation: + {A0,+,A1,+,A2,+,A3,+,A4} * {B0,+,B1,+,B2,+,B3,+,B4} = + {A0*B0,+, + A1*B0 + A0*B1 + A1*B1,+, + A2*B0 + 2A1*B1 + A0*B2 + 2A2*B1 + 2A1*B2 + A2*B2,+, + A3*B0 + 3A2*B1 + 3A1*B2 + A0*B3 + 3A3*B1 + 6A2*B2 + 3A1*B3 + 3A3*B2 + + 3A2*B3 + A3*B3,+, + A4*B0 + 4A3*B1 + 6A2*B2 + 4A1*B3 + A0*B4 + 4A4*B1 + 12A3*B2 + 12A2*B3 + + 4A1*B4 + 6A4*B2 + 12A3*B3 + 6A2*B4 + 4A4*B3 + 4A3*B4 + A4*B4,+, + 5A4*B1 + 10A3*B2 + 10A2*B3 + 5A1*B4 + 20A4*B2 + 30A3*B3 + 20A2*B4 + + 30A4*B3 + 30A3*B4 + 20A4*B4,+, + 15A4*B2 + 20A3*B3 + 15A2*B4 + 60A4*B3 + 60A3*B4 + 90A4*B4,+, + 35A4*B3 + 35A3*B4 + 140A4*B4,+, + 70A4*B4} + */ + + const SCEVAddRecExpr *Product = + dyn_cast(SE.getMulExpr(A_rec, B_rec)); + ASSERT_TRUE(Product); + ASSERT_EQ(Product->getNumOperands(), 9u); + + SmallVector Sum; + Sum.push_back(SE.getMulExpr(A[0], B[0])); + EXPECT_EQ(Product->getOperand(0), SE.getAddExpr(Sum)); + Sum.clear(); + + // SCEV produces different an equal but different expression for these. + // Re-enable when PR11052 is fixed. +#if 0 + Sum.push_back(SE.getMulExpr(A[1], B[0])); + Sum.push_back(SE.getMulExpr(A[0], B[1])); + Sum.push_back(SE.getMulExpr(A[1], B[1])); + EXPECT_EQ(Product->getOperand(1), SE.getAddExpr(Sum)); + Sum.clear(); + + Sum.push_back(SE.getMulExpr(A[2], B[0])); + Sum.push_back(SE.getMulExpr(SE.getConstant(Ty, 2), A[1], B[1])); + Sum.push_back(SE.getMulExpr(A[0], B[2])); + Sum.push_back(SE.getMulExpr(SE.getConstant(Ty, 2), A[2], B[1])); + Sum.push_back(SE.getMulExpr(SE.getConstant(Ty, 2), A[1], B[2])); + Sum.push_back(SE.getMulExpr(A[2], B[2])); + EXPECT_EQ(Product->getOperand(2), SE.getAddExpr(Sum)); + Sum.clear(); + + Sum.push_back(SE.getMulExpr(A[3], B[0])); + Sum.push_back(SE.getMulExpr(SE.getConstant(Ty, 3), A[2], B[1])); + Sum.push_back(SE.getMulExpr(SE.getConstant(Ty, 3), A[1], B[2])); + Sum.push_back(SE.getMulExpr(A[0], B[3])); + Sum.push_back(SE.getMulExpr(SE.getConstant(Ty, 3), A[3], B[1])); + Sum.push_back(SE.getMulExpr(SE.getConstant(Ty, 6), A[2], B[2])); + Sum.push_back(SE.getMulExpr(SE.getConstant(Ty, 3), A[1], B[3])); + Sum.push_back(SE.getMulExpr(SE.getConstant(Ty, 3), A[3], B[2])); + Sum.push_back(SE.getMulExpr(SE.getConstant(Ty, 3), A[2], B[3])); + Sum.push_back(SE.getMulExpr(A[3], B[3])); + EXPECT_EQ(Product->getOperand(3), SE.getAddExpr(Sum)); + Sum.clear(); + + Sum.push_back(SE.getMulExpr(A[4], B[0])); + Sum.push_back(SE.getMulExpr(SE.getConstant(Ty, 4), A[3], B[1])); + Sum.push_back(SE.getMulExpr(SE.getConstant(Ty, 6), A[2], B[2])); + Sum.push_back(SE.getMulExpr(SE.getConstant(Ty, 4), A[1], B[3])); + Sum.push_back(SE.getMulExpr(A[0], B[4])); + Sum.push_back(SE.getMulExpr(SE.getConstant(Ty, 4), A[4], B[1])); + Sum.push_back(SE.getMulExpr(SE.getConstant(Ty, 12), A[3], B[2])); + Sum.push_back(SE.getMulExpr(SE.getConstant(Ty, 12), A[2], B[3])); + Sum.push_back(SE.getMulExpr(SE.getConstant(Ty, 4), A[1], B[4])); + Sum.push_back(SE.getMulExpr(SE.getConstant(Ty, 6), A[4], B[2])); + Sum.push_back(SE.getMulExpr(SE.getConstant(Ty, 12), A[3], B[3])); + Sum.push_back(SE.getMulExpr(SE.getConstant(Ty, 6), A[2], B[4])); + Sum.push_back(SE.getMulExpr(SE.getConstant(Ty, 4), A[4], B[3])); + Sum.push_back(SE.getMulExpr(SE.getConstant(Ty, 4), A[3], B[4])); + Sum.push_back(SE.getMulExpr(A[4], B[4])); + EXPECT_EQ(Product->getOperand(4), SE.getAddExpr(Sum)); + Sum.clear(); + + Sum.push_back(SE.getMulExpr(SE.getConstant(Ty, 5), A[4], B[1])); + Sum.push_back(SE.getMulExpr(SE.getConstant(Ty, 10), A[3], B[2])); + Sum.push_back(SE.getMulExpr(SE.getConstant(Ty, 10), A[2], B[3])); + Sum.push_back(SE.getMulExpr(SE.getConstant(Ty, 5), A[1], B[4])); + Sum.push_back(SE.getMulExpr(SE.getConstant(Ty, 20), A[4], B[2])); + Sum.push_back(SE.getMulExpr(SE.getConstant(Ty, 30), A[3], B[3])); + Sum.push_back(SE.getMulExpr(SE.getConstant(Ty, 20), A[2], B[4])); + Sum.push_back(SE.getMulExpr(SE.getConstant(Ty, 30), A[4], B[3])); + Sum.push_back(SE.getMulExpr(SE.getConstant(Ty, 30), A[3], B[4])); + Sum.push_back(SE.getMulExpr(SE.getConstant(Ty, 20), A[4], B[4])); + EXPECT_EQ(Product->getOperand(5), SE.getAddExpr(Sum)); + Sum.clear(); + + Sum.push_back(SE.getMulExpr(SE.getConstant(Ty, 15), A[4], B[2])); + Sum.push_back(SE.getMulExpr(SE.getConstant(Ty, 20), A[3], B[3])); + Sum.push_back(SE.getMulExpr(SE.getConstant(Ty, 15), A[2], B[4])); + Sum.push_back(SE.getMulExpr(SE.getConstant(Ty, 60), A[4], B[3])); + Sum.push_back(SE.getMulExpr(SE.getConstant(Ty, 60), A[3], B[4])); + Sum.push_back(SE.getMulExpr(SE.getConstant(Ty, 90), A[4], B[4])); + EXPECT_EQ(Product->getOperand(6), SE.getAddExpr(Sum)); + Sum.clear(); + + Sum.push_back(SE.getMulExpr(SE.getConstant(Ty, 35), A[4], B[3])); + Sum.push_back(SE.getMulExpr(SE.getConstant(Ty, 35), A[3], B[4])); + Sum.push_back(SE.getMulExpr(SE.getConstant(Ty, 140), A[4], B[4])); + EXPECT_EQ(Product->getOperand(7), SE.getAddExpr(Sum)); + Sum.clear(); +#endif - // Manually clean up, since we allocated new SCEV objects after the - // pass was finished. - SE.releaseMemory(); + Sum.push_back(SE.getMulExpr(SE.getConstant(Ty, 70), A[4], B[4])); + EXPECT_EQ(Product->getOperand(8), SE.getAddExpr(Sum)); } } // end anonymous namespace From grosser at fim.uni-passau.de Tue Oct 4 01:55:04 2011 From: grosser at fim.uni-passau.de (Tobias Grosser) Date: Tue, 04 Oct 2011 06:55:04 -0000 Subject: [llvm-commits] [polly] r141067 - in /polly/trunk: autoconf/configure.ac configure Message-ID: <20111004065504.10C892A6C12C@llvm.org> Author: grosser Date: Tue Oct 4 01:55:03 2011 New Revision: 141067 URL: http://llvm.org/viewvc/llvm-project?rev=141067&view=rev Log: configure: Add gmp_inc when checking for CLooG Otherwise configure fails if gmp is installed in a non default location. Modified: polly/trunk/autoconf/configure.ac polly/trunk/configure Modified: polly/trunk/autoconf/configure.ac URL: http://llvm.org/viewvc/llvm-project/polly/trunk/autoconf/configure.ac?rev=141067&r1=141066&r2=141067&view=diff ============================================================================== --- polly/trunk/autoconf/configure.ac (original) +++ polly/trunk/autoconf/configure.ac Tue Oct 4 01:55:03 2011 @@ -82,7 +82,7 @@ dnl Find cloog saved_CXXFLAGS=$CXXFLAGS -CXXFLAGS="$CXXFLAGS $isl_inc" +CXXFLAGS="$CXXFLAGS $gmp_inc $isl_inc" find_lib_and_headers([cloog], [cloog/isl/cloog.h], [cloog-isl], [required]) CXXFLAGS=$saved_CXXFLAGS Modified: polly/trunk/configure URL: http://llvm.org/viewvc/llvm-project/polly/trunk/configure?rev=141067&r1=141066&r2=141067&view=diff ============================================================================== --- polly/trunk/configure (original) +++ polly/trunk/configure Tue Oct 4 01:55:03 2011 @@ -2542,7 +2542,7 @@ saved_CXXFLAGS=$CXXFLAGS -CXXFLAGS="$CXXFLAGS $isl_inc" +CXXFLAGS="$CXXFLAGS $gmp_inc $isl_inc" ac_ext=cpp ac_cpp='$CXXCPP $CPPFLAGS' From grosser at fim.uni-passau.de Tue Oct 4 01:56:36 2011 From: grosser at fim.uni-passau.de (Tobias Grosser) Date: Tue, 04 Oct 2011 06:56:36 -0000 Subject: [llvm-commits] [polly] r141068 - /polly/trunk/README Message-ID: <20111004065636.E12E22A6C12D@llvm.org> Author: grosser Date: Tue Oct 4 01:56:36 2011 New Revision: 141068 URL: http://llvm.org/viewvc/llvm-project?rev=141068&view=rev Log: Remove some empty lines Modified: polly/trunk/README Modified: polly/trunk/README URL: http://llvm.org/viewvc/llvm-project/polly/trunk/README?rev=141068&r1=141067&r2=141068&view=diff ============================================================================== --- polly/trunk/README (original) +++ polly/trunk/README Tue Oct 4 01:56:36 2011 @@ -8,5 +8,3 @@ propagation through arrays, remove dead loop iterations, optimize loops for cache locality, optimize arrays, apply advanced automatic parallelization, drive vectorization, or they can be used to do software pipelining. - - From james.molloy at arm.com Tue Oct 4 02:16:39 2011 From: james.molloy at arm.com (James Molloy) Date: Tue, 4 Oct 2011 08:16:39 +0100 Subject: [llvm-commits] [llvm] r140951 - in /llvm/trunk: ./ include/llvm/TableGen/ lib/ lib/TableGen/ utils/TableGen/ In-Reply-To: <20111003234849.GA27357@pcc.me.uk> References: <20111001164115.E37E82A6C12C@llvm.org> <20111003234849.GA27357@pcc.me.uk> Message-ID: <000a01cc8265$8f6d8950$ae489bf0$@molloy@arm.com> Hi Peter, This is a good idea, and I've been meaning to do it for a while. I have multiple other projects based on LLVM, and while tblgen is extremely useful the barrier to entry to using it in spinoff projects is the cost of maintaining a backend under the main LLVM tree, and not being able to keep your code together. The way I was going to go was slightly different to yours, in that I was going to make a couple of the main tblgen headers public and have clients #include those, create shared objects and pass them to the main LLVM tblgen as a dynamically loaded backend, much how opt has the "-load" option. With your method, I still see the possibility of the content of the "main" tblgen file changing and breaking spinoff projects' code. The worst part about this though is that because their main function will be held out of tree in their own sourcebase, they won't get proper merge conflicts and fixing the changes may be manual and arduous. Have you thought about these kind of developers (hobbyist and academic) and how your changes will affect them, for better or worse? Cheers, James -----Original Message----- From: llvm-commits-bounces at cs.uiuc.edu [mailto:llvm-commits-bounces at cs.uiuc.edu] On Behalf Of Peter Collingbourne Sent: 04 October 2011 00:49 To: Chris Lattner Cc: llvm-commits at cs.uiuc.edu Subject: Re: [llvm-commits] [llvm] r140951 - in /llvm/trunk: ./ include/llvm/TableGen/ lib/ lib/TableGen/ utils/TableGen/ Hi Chris, > What direction are you going here? My intention is to move the Clang tblgen backends into the Clang source tree by building the tblgen parser out into a library that can be used to create tblgen-like tools, and creating LLVM and Clang utilities which contain their respective backends and which are clients of that library. I'm trying to achieve this incrementally, by first creating a TableGen library containing the parser and most of 'main'. Currently tblgen is the only client, but I hope to replace this with llvm-tblgen and clang-tblgen utilities. > Are you committed to fixing these problems as follow-ons? To address these issues: > 1. All of the 'main' code and the top-level cl::opt's should be in utils/tablegen, not in TableGen/Main.h Since llvm-tblgen and clang-tblgen would share most of the implementation of their 'main' functions, I think it makes sense to also put most of that code in the library. The TableGenAction class allows for tools to provide the relevant part of 'main' that calls out to their backends. I have noticed that this change is causing problems for shared library users [1], and I apologise for not anticipating this. I think that as a single-purpose library, TableGen does not belong in the shared library, so the most logical way to resolve this problem is to exclude it from the shared library. > 2. The tablegen headers (like the rest of it :) are a mess, they are not split properly between public and private headers. I think that to begin with, the TableGen public interface should provide the bare minimum to allow clients to write their own tblgen-like tools. To this end, the public interface consists of the backend base class, the TableGenAction base class, the Record data structure definitions and the 'TableGenMain' function. I believe that I've largely achieved this split with the current set of header files in include/llvm/TableGen. > 3. The tblgen code uses RTTI and EH, which none of the rest of the LLVM libraries do. > > So long as RTTI and EH don't invade tools other than the utils/TableGen executable, I'm ok with continuing to forget about #3, but #1 and #2 are pretty important. I'm not addressing this problem. The TableGen library and its clients will be built with RTTI and EH. Thanks, -- Peter [1] http://lists.cs.uiuc.edu/pipermail/llvmdev/2011-October/043687.html _______________________________________________ llvm-commits mailing list llvm-commits at cs.uiuc.edu http://lists.cs.uiuc.edu/mailman/listinfo/llvm-commits From james.molloy at arm.com Tue Oct 4 02:25:34 2011 From: james.molloy at arm.com (James Molloy) Date: Tue, 4 Oct 2011 08:25:34 +0100 Subject: [llvm-commits] [llvm] r140971 - in /llvm/trunk: lib/Target/X86/Disassembler/X86DisassemblerDecoder.c test/MC/Disassembler/X86/simple-tests.txt In-Reply-To: <20111002165610.EC2592A6C12C@llvm.org> References: <20111002165610.EC2592A6C12C@llvm.org> Message-ID: <000b01cc8266$cead22f0$6c0768d0$@molloy@arm.com> Hi Craig, This commit breaks our opensource build. X86DisassemblerDecoder.c:906:5: error: C++ style comments are not allowed in ISO C90 Could you please change the comments to C-style? Cheers, James -----Original Message----- From: llvm-commits-bounces at cs.uiuc.edu [mailto:llvm-commits-bounces at cs.uiuc.edu] On Behalf Of Craig Topper Sent: 02 October 2011 17:56 To: llvm-commits at cs.uiuc.edu Subject: [llvm-commits] [llvm] r140971 - in /llvm/trunk: lib/Target/X86/Disassembler/X86DisassemblerDecoder.c test/MC/Disassembler/X86/simple-tests.txt Author: ctopper Date: Sun Oct 2 11:56:09 2011 New Revision: 140971 URL: http://llvm.org/viewvc/llvm-project?rev=140971&view=rev Log: Special case disassembler handling of REX.B prefix on NOP instruction to decode as XCHG R8D, EAX instead. Fixes PR10344. Modified: llvm/trunk/lib/Target/X86/Disassembler/X86DisassemblerDecoder.c llvm/trunk/test/MC/Disassembler/X86/simple-tests.txt Modified: llvm/trunk/lib/Target/X86/Disassembler/X86DisassemblerDecoder.c URL: http://llvm.org/viewvc/llvm-project/llvm/trunk/lib/Target/X86/Disassembler/X 86DisassemblerDecoder.c?rev=140971&r1=140970&r2=140971&view=diff ============================================================================ == --- llvm/trunk/lib/Target/X86/Disassembler/X86DisassemblerDecoder.c (original) +++ llvm/trunk/lib/Target/X86/Disassembler/X86DisassemblerDecoder.c Sun Oct 2 11:56:09 2011 @@ -58,8 +58,8 @@ * @return - TRUE if the ModR/M byte is required, FALSE otherwise. */ static int modRMRequired(OpcodeType type, - InstructionContext insnContext, - uint8_t opcode) { + InstructionContext insnContext, + uint8_t opcode) { const struct ContextDecision* decision = 0; switch (type) { @@ -885,6 +885,43 @@ } return 0; } + + if (insn->opcodeType == ONEBYTE && insn->opcode == 0x90 && + insn->rexPrefix & 0x01) { + /* + * NOOP shouldn't decode as NOOP if REX.b is set. Instead + * it should decode as XCHG %r8, %eax. + */ + + const struct InstructionSpecifier *spec; + uint16_t instructionIDWithNewOpcode; + const struct InstructionSpecifier *specWithNewOpcode; + + spec = specifierForUID(instructionID); + + // Borrow opcode from one of the other XCHGar opcodes + insn->opcode = 0x91; + + if (getIDWithAttrMask(&instructionIDWithNewOpcode, + insn, + attrMask)) { + insn->opcode = 0x90; + + insn->instructionID = instructionID; + insn->spec = spec; + return 0; + } + + specWithNewOpcode = specifierForUID(instructionIDWithNewOpcode); + + // Change back + insn->opcode = 0x90; + + insn->instructionID = instructionIDWithNewOpcode; + insn->spec = specWithNewOpcode; + + return 0; + } insn->instructionID = instructionID; insn->spec = specifierForUID(insn->instructionID); Modified: llvm/trunk/test/MC/Disassembler/X86/simple-tests.txt URL: http://llvm.org/viewvc/llvm-project/llvm/trunk/test/MC/Disassembler/X86/simp le-tests.txt?rev=140971&r1=140970&r2=140971&view=diff ============================================================================ == --- llvm/trunk/test/MC/Disassembler/X86/simple-tests.txt (original) +++ llvm/trunk/test/MC/Disassembler/X86/simple-tests.txt Sun Oct 2 11:56:09 2011 @@ -308,3 +308,6 @@ # CHECK: invvpid (%rax), %rax 0x66 0x0f 0x38 0x81 0x00 + +# CHECK: xchgl %r8d, %eax +0x41 0x90 _______________________________________________ llvm-commits mailing list llvm-commits at cs.uiuc.edu http://lists.cs.uiuc.edu/mailman/listinfo/llvm-commits From grosser at fim.uni-passau.de Tue Oct 4 02:53:29 2011 From: grosser at fim.uni-passau.de (Tobias Grosser) Date: Tue, 04 Oct 2011 07:53:29 -0000 Subject: [llvm-commits] [polly] r141069 - in /polly/trunk/test/ScopInfo: phi_not_grouped_at_top.ll phi_with_invoke_edge.ll Message-ID: <20111004075330.86C52312800A@llvm.org> Author: grosser Date: Tue Oct 4 02:53:21 2011 New Revision: 141069 URL: http://llvm.org/viewvc/llvm-project?rev=141069&view=rev Log: Test: Convert to new exception handling Modified: polly/trunk/test/ScopInfo/phi_not_grouped_at_top.ll polly/trunk/test/ScopInfo/phi_with_invoke_edge.ll Modified: polly/trunk/test/ScopInfo/phi_not_grouped_at_top.ll URL: http://llvm.org/viewvc/llvm-project/polly/trunk/test/ScopInfo/phi_not_grouped_at_top.ll?rev=141069&r1=141068&r2=141069&view=diff ============================================================================== --- polly/trunk/test/ScopInfo/phi_not_grouped_at_top.ll (original) +++ polly/trunk/test/ScopInfo/phi_not_grouped_at_top.ll Tue Oct 4 02:53:21 2011 @@ -5,6 +5,8 @@ declare i32 @funa() align 2 +declare i32 @generic_personality_v0(i32, i64, i8*, i8*) + define void @funb() align 2 { entry: br label %bb117 @@ -14,6 +16,7 @@ to label %bb121 unwind label %invcont118 ; <%struct.btHullTriangle*> [#uses=1] invcont118: ; preds = %bb117 + %d = landingpad { i8*, i32 } personality i32 (i32, i64, i8*, i8*)* @generic_personality_v0 cleanup catch i32* null br label %bb121 bb121: ; preds = %bb120, %invcont118 Modified: polly/trunk/test/ScopInfo/phi_with_invoke_edge.ll URL: http://llvm.org/viewvc/llvm-project/polly/trunk/test/ScopInfo/phi_with_invoke_edge.ll?rev=141069&r1=141068&r2=141069&view=diff ============================================================================== --- polly/trunk/test/ScopInfo/phi_with_invoke_edge.ll (original) +++ polly/trunk/test/ScopInfo/phi_with_invoke_edge.ll Tue Oct 4 02:53:21 2011 @@ -1,8 +1,8 @@ ; RUN: opt %loadPolly %defaultOpts -polly-prepare -polly-detect -analyze %s -; ModuleID = '/tmp/invoke_edge_not_supported.ll' target datalayout = "e-p:64:64:64-i1:8:8-i8:8:8-i16:16:16-i32:32:32-i64:64:64-f32:32:32-f64:64:64-v64:64:64-v128:128:128-a0:0:64-s0:64:64-f80:128:128-n8:16:32:64" target triple = "x86_64-linux-gnu" +declare i32 @generic_personality_v0(i32, i64, i8*, i8*) define i16 @v() { entry: @@ -22,5 +22,6 @@ ret i16 0 lpad22: ; preds = %invcont12 + %d = landingpad { i8*, i32 } personality i32 (i32, i64, i8*, i8*)* @generic_personality_v0 cleanup catch i32* null unreachable } From grosser at fim.uni-passau.de Tue Oct 4 03:08:43 2011 From: grosser at fim.uni-passau.de (Tobias Grosser) Date: Tue, 04 Oct 2011 08:08:43 -0000 Subject: [llvm-commits] [polly] r141070 - /polly/trunk/www/menu.html.incl Message-ID: <20111004080844.5484F312800A@llvm.org> Author: grosser Date: Tue Oct 4 03:08:43 2011 New Revision: 141070 URL: http://llvm.org/viewvc/llvm-project?rev=141070&view=rev Log: Point to our own buildbot until the official one is up again. Modified: polly/trunk/www/menu.html.incl Modified: polly/trunk/www/menu.html.incl URL: http://llvm.org/viewvc/llvm-project/polly/trunk/www/menu.html.incl?rev=141070&r1=141069&r2=141070&view=diff ============================================================================== --- polly/trunk/www/menu.html.incl (original) +++ polly/trunk/www/menu.html.incl Tue Oct 4 03:08:43 2011 @@ -21,7 +21,7 @@ polly-dev Mailing List Bug Reports - Buildbot + Buildbot +

On some platforms, you will need to specify -rdynamic or -Wl,--export-dynamic +when linking. This ensures that symbols defined in the main executable are +exported to the dynamic linker and so are available for symbol resolution at +run time. This is not needed if you compile your support code into a shared +library, although doing that will cause problems on Windows.

+

Here is the code:

From dpatel at apple.com Tue Oct 4 14:38:17 2011 From: dpatel at apple.com (Devang Patel) Date: Tue, 04 Oct 2011 19:38:17 -0000 Subject: [llvm-commits] [llvm] r141104 - /llvm/trunk/tools/llvm-cov/CMakeLists.txt Message-ID: <20111004193828.CC2102A6C12C@llvm.org> Author: dpatel Date: Tue Oct 4 14:38:16 2011 New Revision: 141104 URL: http://llvm.org/viewvc/llvm-project?rev=141104&view=rev Log: Update cmake list. Modified: llvm/trunk/tools/llvm-cov/CMakeLists.txt Modified: llvm/trunk/tools/llvm-cov/CMakeLists.txt URL: http://llvm.org/viewvc/llvm-project/llvm/trunk/tools/llvm-cov/CMakeLists.txt?rev=141104&r1=141103&r2=141104&view=diff ============================================================================== --- llvm/trunk/tools/llvm-cov/CMakeLists.txt (original) +++ llvm/trunk/tools/llvm-cov/CMakeLists.txt Tue Oct 4 14:38:16 2011 @@ -1,6 +1,5 @@ set(LLVM_LINK_COMPONENTS instrumentation ) add_llvm_tool(llvm-cov - GCOVReader.cpp llvm-cov.cpp ) From stoklund at 2pi.dk Tue Oct 4 15:18:40 2011 From: stoklund at 2pi.dk (Jakob Stoklund Olesen) Date: Tue, 04 Oct 2011 20:18:40 -0000 Subject: [llvm-commits] [llvm] r141105 - /llvm/trunk/utils/TableGen/CodeGenRegisters.cpp Message-ID: <20111004201840.4A5B12A6C12C@llvm.org> Author: stoklund Date: Tue Oct 4 15:18:39 2011 New Revision: 141105 URL: http://llvm.org/viewvc/llvm-project?rev=141105&view=rev Log: Properly use const_iterator. This should unbreak the Windows build. Modified: llvm/trunk/utils/TableGen/CodeGenRegisters.cpp Modified: llvm/trunk/utils/TableGen/CodeGenRegisters.cpp URL: http://llvm.org/viewvc/llvm-project/llvm/trunk/utils/TableGen/CodeGenRegisters.cpp?rev=141105&r1=141104&r2=141105&view=diff ============================================================================== --- llvm/trunk/utils/TableGen/CodeGenRegisters.cpp (original) +++ llvm/trunk/utils/TableGen/CodeGenRegisters.cpp Tue Oct 4 15:18:39 2011 @@ -757,11 +757,11 @@ // Compute the set of registers supporting each SubRegIndex. SubReg2SetMap SRSets; - for (CodeGenRegister::Set::iterator RI = RC.getMembers().begin(), + for (CodeGenRegister::Set::const_iterator RI = RC.getMembers().begin(), RE = RC.getMembers().end(); RI != RE; ++RI) { - CodeGenRegister::SubRegMap SRM = (*RI)->getSubRegs(); - for (CodeGenRegister::SubRegMap::iterator I = SRM.begin(), E = SRM.end(); - I != E; ++I) + const CodeGenRegister::SubRegMap &SRM = (*RI)->getSubRegs(); + for (CodeGenRegister::SubRegMap::const_iterator I = SRM.begin(), + E = SRM.end(); I != E; ++I) SRSets[I->first].insert(*RI); } From isanbard at gmail.com Tue Oct 4 15:31:56 2011 From: isanbard at gmail.com (Bill Wendling) Date: Tue, 04 Oct 2011 20:31:56 -0000 Subject: [llvm-commits] [llvm] r141107 - /llvm/trunk/include/llvm/CodeGen/MachineModuleInfo.h Message-ID: <20111004203156.9B7AF2A6C12C@llvm.org> Author: void Date: Tue Oct 4 15:31:56 2011 New Revision: 141107 URL: http://llvm.org/viewvc/llvm-project?rev=141107&view=rev Log: Add method to determine if a begin label has a call site number associated with it. Modified: llvm/trunk/include/llvm/CodeGen/MachineModuleInfo.h Modified: llvm/trunk/include/llvm/CodeGen/MachineModuleInfo.h URL: http://llvm.org/viewvc/llvm-project/llvm/trunk/include/llvm/CodeGen/MachineModuleInfo.h?rev=141107&r1=141106&r2=141107&view=diff ============================================================================== --- llvm/trunk/include/llvm/CodeGen/MachineModuleInfo.h (original) +++ llvm/trunk/include/llvm/CodeGen/MachineModuleInfo.h Tue Oct 4 15:31:56 2011 @@ -329,18 +329,24 @@ return LandingPads; } - /// setCallSiteBeginLabel - Map the begin label for a call site + /// setCallSiteBeginLabel - Map the begin label for a call site. void setCallSiteBeginLabel(MCSymbol *BeginLabel, unsigned Site) { CallSiteMap[BeginLabel] = Site; } - /// getCallSiteBeginLabel - Get the call site number for a begin label + /// getCallSiteBeginLabel - Get the call site number for a begin label. unsigned getCallSiteBeginLabel(MCSymbol *BeginLabel) { - assert(CallSiteMap.count(BeginLabel) && + assert(hasCallSiteBeginLabel(BeginLabel) && "Missing call site number for EH_LABEL!"); return CallSiteMap[BeginLabel]; } + /// hasCallSiteBeginLabel - Return true if the begin label has a call site + /// number associated with it. + bool hasCallSiteBeginLabel(MCSymbol *BeginLabel) { + return CallSiteMap[BeginLabel] != 0; + } + /// setCurrentCallSite - Set the call site currently being processed. void setCurrentCallSite(unsigned Site) { CurCallSite = Site; } From grosbach at apple.com Tue Oct 4 15:34:11 2011 From: grosbach at apple.com (Jim Grosbach) Date: Tue, 04 Oct 2011 20:34:11 -0000 Subject: [llvm-commits] [llvm] r141108 - /llvm/trunk/test/MC/ARM/neon-dup-encoding.s Message-ID: <20111004203411.8EE8E2A6C12C@llvm.org> Author: grosbach Date: Tue Oct 4 15:34:11 2011 New Revision: 141108 URL: http://llvm.org/viewvc/llvm-project?rev=141108&view=rev Log: Un-XFAIL the file. Disable only the individual tests that aren't working yet. Modified: llvm/trunk/test/MC/ARM/neon-dup-encoding.s Modified: llvm/trunk/test/MC/ARM/neon-dup-encoding.s URL: http://llvm.org/viewvc/llvm-project/llvm/trunk/test/MC/ARM/neon-dup-encoding.s?rev=141108&r1=141107&r2=141108&view=diff ============================================================================== --- llvm/trunk/test/MC/ARM/neon-dup-encoding.s (original) +++ llvm/trunk/test/MC/ARM/neon-dup-encoding.s Tue Oct 4 15:34:11 2011 @@ -1,7 +1,5 @@ @ RUN: llvm-mc -mcpu=cortex-a8 -triple arm-unknown-unknown -show-encoding < %s | FileCheck %s -@ XFAIL: * - vdup.8 d16, r0 vdup.16 d16, r0 vdup.32 d16, r0 @@ -18,18 +16,18 @@ @ CHECK: vdup.16 q8, r0 @ encoding: [0xb0,0x0b,0xa0,0xee] @ CHECK: vdup.32 q8, r0 @ encoding: [0x90,0x0b,0xa0,0xee] - vdup.8 d16, d16[1] - vdup.16 d16, d16[1] - vdup.32 d16, d16[1] - -@ CHECK: vdup.8 d16, d16[1] @ encoding: [0x20,0x0c,0xf3,0xf3] -@ CHECK: vdup.16 d16, d16[1] @ encoding: [0x20,0x0c,0xf6,0xf3] -@ CHECK: vdup.32 d16, d16[1] @ encoding: [0x20,0x0c,0xfc,0xf3] - - vdup.8 q8, d16[1] - vdup.16 q8, d16[1] - vdup.32 q8, d16[1] - -@ CHECK: vdup.8 q8, d16[1] @ encoding: [0x60,0x0c,0xf3,0xf3] -@ CHECK: vdup.16 q8, d16[1] @ encoding: [0x60,0x0c,0xf6,0xf3] -@ CHECK: vdup.32 q8, d16[1] @ encoding: [0x60,0x0c,0xfc,0xf3] +@ vdup.8 d16, d16[1] +@ vdup.16 d16, d16[1] +@ vdup.32 d16, d16[1] + +@ FIXME: vdup.8 d16, d16[1] @ encoding: [0x20,0x0c,0xf3,0xf3] +@ FIXME: vdup.16 d16, d16[1] @ encoding: [0x20,0x0c,0xf6,0xf3] +@ FIXME: vdup.32 d16, d16[1] @ encoding: [0x20,0x0c,0xfc,0xf3] + +@ vdup.8 q8, d16[1] +@ vdup.16 q8, d16[1] +@ vdup.32 q8, d16[1] + +@ FIXME: vdup.8 q8, d16[1] @ encoding: [0x60,0x0c,0xf3,0xf3] +@ FIXME: vdup.16 q8, d16[1] @ encoding: [0x60,0x0c,0xf6,0xf3] +@ FIXME: vdup.32 q8, d16[1] @ encoding: [0x60,0x0c,0xfc,0xf3] From grosbach at apple.com Tue Oct 4 15:42:09 2011 From: grosbach at apple.com (Jim Grosbach) Date: Tue, 04 Oct 2011 20:42:09 -0000 Subject: [llvm-commits] [llvm] r141110 - /llvm/trunk/test/MC/ARM/neon-mul-accum-encoding.s Message-ID: <20111004204210.B383B2A6C12C@llvm.org> Author: grosbach Date: Tue Oct 4 15:42:09 2011 New Revision: 141110 URL: http://llvm.org/viewvc/llvm-project?rev=141110&view=rev Log: Un-XFAIL file. Fix incorrect CHECK line. Modified: llvm/trunk/test/MC/ARM/neon-mul-accum-encoding.s Modified: llvm/trunk/test/MC/ARM/neon-mul-accum-encoding.s URL: http://llvm.org/viewvc/llvm-project/llvm/trunk/test/MC/ARM/neon-mul-accum-encoding.s?rev=141110&r1=141109&r2=141110&view=diff ============================================================================== --- llvm/trunk/test/MC/ARM/neon-mul-accum-encoding.s (original) +++ llvm/trunk/test/MC/ARM/neon-mul-accum-encoding.s Tue Oct 4 15:42:09 2011 @@ -1,11 +1,10 @@ @ RUN: llvm-mc -mcpu=cortex-a8 -triple arm-unknown-unknown -show-encoding < %s | FileCheck %s -@ XFAIL: * @ CHECK: vmla.i8 d16, d18, d17 @ encoding: [0xa1,0x09,0x42,0xf2] vmla.i8 d16, d18, d17 @ CHECK: vmla.i16 d16, d18, d17 @ encoding: [0xa1,0x09,0x52,0xf2] vmla.i16 d16, d18, d17 -@ CHECK: vmla.i16 d16, d18, d17 @ encoding: [0xa1,0x09,0x52,0xf2] +@ CHECK: vmla.i32 d16, d18, d17 @ encoding: [0xa1,0x09,0x62,0xf2] vmla.i32 d16, d18, d17 @ CHECK: vmla.f32 d16, d18, d17 @ encoding: [0xb1,0x0d,0x42,0xf2] vmla.f32 d16, d18, d17 From grosbach at apple.com Tue Oct 4 15:42:36 2011 From: grosbach at apple.com (Jim Grosbach) Date: Tue, 04 Oct 2011 20:42:36 -0000 Subject: [llvm-commits] [llvm] r141111 - /llvm/trunk/test/MC/ARM/neon-mul-encoding.s Message-ID: <20111004204237.AC5602A6C12C@llvm.org> Author: grosbach Date: Tue Oct 4 15:42:35 2011 New Revision: 141111 URL: http://llvm.org/viewvc/llvm-project?rev=141111&view=rev Log: Tidy up formatting. Modified: llvm/trunk/test/MC/ARM/neon-mul-encoding.s Modified: llvm/trunk/test/MC/ARM/neon-mul-encoding.s URL: http://llvm.org/viewvc/llvm-project/llvm/trunk/test/MC/ARM/neon-mul-encoding.s?rev=141111&r1=141110&r2=141111&view=diff ============================================================================== --- llvm/trunk/test/MC/ARM/neon-mul-encoding.s (original) +++ llvm/trunk/test/MC/ARM/neon-mul-encoding.s Tue Oct 4 15:42:35 2011 @@ -1,56 +1,82 @@ @ RUN: llvm-mc -mcpu=cortex-a8 -triple arm-unknown-unknown -show-encoding < %s | FileCheck %s -@ CHECK: vmul.i8 d16, d16, d17 @ encoding: [0xb1,0x09,0x40,0xf2] - vmul.i8 d16, d16, d17 -@ CHECK: vmul.i16 d16, d16, d17 @ encoding: [0xb1,0x09,0x50,0xf2] - vmul.i16 d16, d16, d17 -@ CHECK: vmul.i32 d16, d16, d17 @ encoding: [0xb1,0x09,0x60,0xf2] - vmul.i32 d16, d16, d17 -@ CHECK: vmul.f32 d16, d16, d17 @ encoding: [0xb1,0x0d,0x40,0xf3] - vmul.f32 d16, d16, d17 -@ CHECK: vmul.i8 q8, q8, q9 @ encoding: [0xf2,0x09,0x40,0xf2] - vmul.i8 q8, q8, q9 -@ CHECK: vmul.i16 q8, q8, q9 @ encoding: [0xf2,0x09,0x50,0xf2] - vmul.i16 q8, q8, q9 -@ CHECK: vmul.i32 q8, q8, q9 @ encoding: [0xf2,0x09,0x60,0xf2] - vmul.i32 q8, q8, q9 -@ CHECK: vmul.f32 q8, q8, q9 @ encoding: [0xf2,0x0d,0x40,0xf3] - vmul.f32 q8, q8, q9 -@ CHECK: vmul.p8 d16, d16, d17 @ encoding: [0xb1,0x09,0x40,0xf3] - vmul.p8 d16, d16, d17 -@ CHECK: vmul.p8 q8, q8, q9 @ encoding: [0xf2,0x09,0x40,0xf3] - vmul.p8 q8, q8, q9 -@ CHECK: vqdmulh.s16 d16, d16, d17 @ encoding: [0xa1,0x0b,0x50,0xf2] - vqdmulh.s16 d16, d16, d17 -@ CHECK: vqdmulh.s32 d16, d16, d17 @ encoding: [0xa1,0x0b,0x60,0xf2] - vqdmulh.s32 d16, d16, d17 -@ CHECK: vqdmulh.s16 q8, q8, q9 @ encoding: [0xe2,0x0b,0x50,0xf2] - vqdmulh.s16 q8, q8, q9 -@ CHECK: vqdmulh.s32 q8, q8, q9 @ encoding: [0xe2,0x0b,0x60,0xf2] - vqdmulh.s32 q8, q8, q9 -@ CHECK: vqrdmulh.s16 d16, d16, d17 @ encoding: [0xa1,0x0b,0x50,0xf3] - vqrdmulh.s16 d16, d16, d17 -@ CHECK: vqrdmulh.s32 d16, d16, d17 @ encoding: [0xa1,0x0b,0x60,0xf3] - vqrdmulh.s32 d16, d16, d17 -@ CHECK: vqrdmulh.s16 q8, q8, q9 @ encoding: [0xe2,0x0b,0x50,0xf3] - vqrdmulh.s16 q8, q8, q9 -@ CHECK: vqrdmulh.s32 q8, q8, q9 @ encoding: [0xe2,0x0b,0x60,0xf3] - vqrdmulh.s32 q8, q8, q9 -@ CHECK: vmull.s8 q8, d16, d17 @ encoding: [0xa1,0x0c,0xc0,0xf2] - vmull.s8 q8, d16, d17 -@ CHECK: vmull.s16 q8, d16, d17 @ encoding: [0xa1,0x0c,0xd0,0xf2] - vmull.s16 q8, d16, d17 -@ CHECK: vmull.s32 q8, d16, d17 @ encoding: [0xa1,0x0c,0xe0,0xf2] - vmull.s32 q8, d16, d17 -@ CHECK: vmull.u8 q8, d16, d17 @ encoding: [0xa1,0x0c,0xc0,0xf3] - vmull.u8 q8, d16, d17 -@ CHECK: vmull.u16 q8, d16, d17 @ encoding: [0xa1,0x0c,0xd0,0xf3] - vmull.u16 q8, d16, d17 -@ CHECK: vmull.u32 q8, d16, d17 @ encoding: [0xa1,0x0c,0xe0,0xf3] - vmull.u32 q8, d16, d17 -@ CHECK: vmull.p8 q8, d16, d17 @ encoding: [0xa1,0x0e,0xc0,0xf2] - vmull.p8 q8, d16, d17 -@ CHECK: vqdmull.s16 q8, d16, d17 @ encoding: [0xa1,0x0d,0xd0,0xf2] - vqdmull.s16 q8, d16, d17 -@ CHECK: vqdmull.s32 q8, d16, d17 @ encoding: [0xa1,0x0d,0xe0,0xf2] - vqdmull.s32 q8, d16, d17 + vmla.i8 d16, d18, d17 + vmla.i16 d16, d18, d17 + vmla.i32 d16, d18, d17 + vmla.f32 d16, d18, d17 + vmla.i8 q9, q8, q10 + vmla.i16 q9, q8, q10 + vmla.i32 q9, q8, q10 + vmla.f32 q9, q8, q10 + +@ CHECK: vmla.i8 d16, d18, d17 @ encoding: [0xa1,0x09,0x42,0xf2] +@ CHECK: vmla.i16 d16, d18, d17 @ encoding: [0xa1,0x09,0x52,0xf2] +@ CHECK: vmla.i32 d16, d18, d17 @ encoding: [0xa1,0x09,0x62,0xf2] +@ CHECK: vmla.f32 d16, d18, d17 @ encoding: [0xb1,0x0d,0x42,0xf2] +@ CHECK: vmla.i8 q9, q8, q10 @ encoding: [0xe4,0x29,0x40,0xf2] +@ CHECK: vmla.i16 q9, q8, q10 @ encoding: [0xe4,0x29,0x50,0xf2] +@ CHECK: vmla.i32 q9, q8, q10 @ encoding: [0xe4,0x29,0x60,0xf2] +@ CHECK: vmla.f32 q9, q8, q10 @ encoding: [0xf4,0x2d,0x40,0xf2] + + + vmlal.s8 q8, d19, d18 + vmlal.s16 q8, d19, d18 + vmlal.s32 q8, d19, d18 + vmlal.u8 q8, d19, d18 + vmlal.u16 q8, d19, d18 + vmlal.u32 q8, d19, d18 + +@ CHECK: vmlal.s8 q8, d19, d18 @ encoding: [0xa2,0x08,0xc3,0xf2] +@ CHECK: vmlal.s16 q8, d19, d18 @ encoding: [0xa2,0x08,0xd3,0xf2] +@ CHECK: vmlal.s32 q8, d19, d18 @ encoding: [0xa2,0x08,0xe3,0xf2] +@ CHECK: vmlal.u8 q8, d19, d18 @ encoding: [0xa2,0x08,0xc3,0xf3] +@ CHECK: vmlal.u16 q8, d19, d18 @ encoding: [0xa2,0x08,0xd3,0xf3] +@ CHECK: vmlal.u32 q8, d19, d18 @ encoding: [0xa2,0x08,0xe3,0xf3] + + + vqdmlal.s16 q8, d19, d18 + vqdmlal.s32 q8, d19, d18 + +@ CHECK: vqdmlal.s16 q8, d19, d18 @ encoding: [0xa2,0x09,0xd3,0xf2] +@ CHECK: vqdmlal.s32 q8, d19, d18 @ encoding: [0xa2,0x09,0xe3,0xf2] + + + vmls.i8 d16, d18, d17 + vmls.i16 d16, d18, d17 + vmls.i32 d16, d18, d17 + vmls.f32 d16, d18, d17 + vmls.i8 q9, q8, q10 + vmls.i16 q9, q8, q10 + vmls.i32 q9, q8, q10 + vmls.f32 q9, q8, q10 + +@ CHECK: vmls.i8 d16, d18, d17 @ encoding: [0xa1,0x09,0x42,0xf3] +@ CHECK: vmls.i16 d16, d18, d17 @ encoding: [0xa1,0x09,0x52,0xf3] +@ CHECK: vmls.i32 d16, d18, d17 @ encoding: [0xa1,0x09,0x62,0xf3] +@ CHECK: vmls.f32 d16, d18, d17 @ encoding: [0xb1,0x0d,0x62,0xf2] +@ CHECK: vmls.i8 q9, q8, q10 @ encoding: [0xe4,0x29,0x40,0xf3] +@ CHECK: vmls.i16 q9, q8, q10 @ encoding: [0xe4,0x29,0x50,0xf3] +@ CHECK: vmls.i32 q9, q8, q10 @ encoding: [0xe4,0x29,0x60,0xf3] +@ CHECK: vmls.f32 q9, q8, q10 @ encoding: [0xf4,0x2d,0x60,0xf2] + + + vmlsl.s8 q8, d19, d18 + vmlsl.s16 q8, d19, d18 + vmlsl.s32 q8, d19, d18 + vmlsl.u8 q8, d19, d18 + vmlsl.u16 q8, d19, d18 + vmlsl.u32 q8, d19, d18 + +@ CHECK: vmlsl.s8 q8, d19, d18 @ encoding: [0xa2,0x0a,0xc3,0xf2] +@ CHECK: vmlsl.s16 q8, d19, d18 @ encoding: [0xa2,0x0a,0xd3,0xf2] +@ CHECK: vmlsl.s32 q8, d19, d18 @ encoding: [0xa2,0x0a,0xe3,0xf2] +@ CHECK: vmlsl.u8 q8, d19, d18 @ encoding: [0xa2,0x0a,0xc3,0xf3] +@ CHECK: vmlsl.u16 q8, d19, d18 @ encoding: [0xa2,0x0a,0xd3,0xf3] +@ CHECK: vmlsl.u32 q8, d19, d18 @ encoding: [0xa2,0x0a,0xe3,0xf3] + + + vqdmlsl.s16 q8, d19, d18 + vqdmlsl.s32 q8, d19, d18 + +@ CHECK: vqdmlsl.s16 q8, d19, d18 @ encoding: [0xa2,0x0b,0xd3,0xf2] +@ CHECK: vqdmlsl.s32 q8, d19, d18 @ encoding: [0xa2,0x0b,0xe3,0xf2] From grosbach at apple.com Tue Oct 4 15:46:52 2011 From: grosbach at apple.com (Jim Grosbach) Date: Tue, 04 Oct 2011 20:46:52 -0000 Subject: [llvm-commits] [llvm] r141113 - /llvm/trunk/test/MC/ARM/neont2-mul-accum-encoding.s Message-ID: <20111004204653.A76562A6C12C@llvm.org> Author: grosbach Date: Tue Oct 4 15:46:49 2011 New Revision: 141113 URL: http://llvm.org/viewvc/llvm-project?rev=141113&view=rev Log: Un-XFAIL file. Fix incorrect CHECK line. General format cleanup. Modified: llvm/trunk/test/MC/ARM/neont2-mul-accum-encoding.s Modified: llvm/trunk/test/MC/ARM/neont2-mul-accum-encoding.s URL: http://llvm.org/viewvc/llvm-project/llvm/trunk/test/MC/ARM/neont2-mul-accum-encoding.s?rev=141113&r1=141112&r2=141113&view=diff ============================================================================== --- llvm/trunk/test/MC/ARM/neont2-mul-accum-encoding.s (original) +++ llvm/trunk/test/MC/ARM/neont2-mul-accum-encoding.s Tue Oct 4 15:46:49 2011 @@ -1,69 +1,84 @@ @ RUN: llvm-mc -mcpu=cortex-a8 -triple thumb-unknown-unknown -show-encoding < %s | FileCheck %s -@ XFAIL: * .code 16 -@ CHECK: vmla.i8 d16, d18, d17 @ encoding: [0xa1,0x09,0x42,0xef] vmla.i8 d16, d18, d17 -@ CHECK: vmla.i16 d16, d18, d17 @ encoding: [0xa1,0x09,0x52,0xef] vmla.i16 d16, d18, d17 -@ CHECK: vmla.i16 d16, d18, d17 @ encoding: [0xa1,0x09,0x52,0xef] vmla.i32 d16, d18, d17 -@ CHECK: vmla.f32 d16, d18, d17 @ encoding: [0xb1,0x0d,0x42,0xef] vmla.f32 d16, d18, d17 -@ CHECK: vmla.i8 q9, q8, q10 @ encoding: [0xe4,0x29,0x40,0xef] vmla.i8 q9, q8, q10 -@ CHECK: vmla.i16 q9, q8, q10 @ encoding: [0xe4,0x29,0x50,0xef] vmla.i16 q9, q8, q10 -@ CHECK: vmla.i32 q9, q8, q10 @ encoding: [0xe4,0x29,0x60,0xef] vmla.i32 q9, q8, q10 -@ CHECK: vmla.f32 q9, q8, q10 @ encoding: [0xf4,0x2d,0x40,0xef] vmla.f32 q9, q8, q10 -@ CHECK: vmlal.s8 q8, d19, d18 @ encoding: [0xa2,0x08,0xc3,0xef] + +@ CHECK: vmla.i8 d16, d18, d17 @ encoding: [0x42,0xef,0xa1,0x09] +@ CHECK: vmla.i16 d16, d18, d17 @ encoding: [0x52,0xef,0xa1,0x09] +@ CHECK: vmla.i32 d16, d18, d17 @ encoding: [0x62,0xef,0xa1,0x09] +@ CHECK: vmla.f32 d16, d18, d17 @ encoding: [0x42,0xef,0xb1,0x0d] +@ CHECK: vmla.i8 q9, q8, q10 @ encoding: [0x40,0xef,0xe4,0x29] +@ CHECK: vmla.i16 q9, q8, q10 @ encoding: [0x50,0xef,0xe4,0x29] +@ CHECK: vmla.i32 q9, q8, q10 @ encoding: [0x60,0xef,0xe4,0x29] +@ CHECK: vmla.f32 q9, q8, q10 @ encoding: [0x40,0xef,0xf4,0x2d] + + vmlal.s8 q8, d19, d18 -@ CHECK: vmlal.s16 q8, d19, d18 @ encoding: [0xa2,0x08,0xd3,0xef] vmlal.s16 q8, d19, d18 -@ CHECK: vmlal.s32 q8, d19, d18 @ encoding: [0xa2,0x08,0xe3,0xef] vmlal.s32 q8, d19, d18 -@ CHECK: vmlal.u8 q8, d19, d18 @ encoding: [0xa2,0x08,0xc3,0xff] vmlal.u8 q8, d19, d18 -@ CHECK: vmlal.u16 q8, d19, d18 @ encoding: [0xa2,0x08,0xd3,0xff] vmlal.u16 q8, d19, d18 -@ CHECK: vmlal.u32 q8, d19, d18 @ encoding: [0xa2,0x08,0xe3,0xff] vmlal.u32 q8, d19, d18 -@ CHECK: vqdmlal.s16 q8, d19, d18 @ encoding: [0xa2,0x09,0xd3,0xef] + +@ CHECK: vmlal.s8 q8, d19, d18 @ encoding: [0xc3,0xef,0xa2,0x08] +@ CHECK: vmlal.s16 q8, d19, d18 @ encoding: [0xd3,0xef,0xa2,0x08] +@ CHECK: vmlal.s32 q8, d19, d18 @ encoding: [0xe3,0xef,0xa2,0x08] +@ CHECK: vmlal.u8 q8, d19, d18 @ encoding: [0xc3,0xff,0xa2,0x08] +@ CHECK: vmlal.u16 q8, d19, d18 @ encoding: [0xd3,0xff,0xa2,0x08] +@ CHECK: vmlal.u32 q8, d19, d18 @ encoding: [0xe3,0xff,0xa2,0x08] + + vqdmlal.s16 q8, d19, d18 -@ CHECK: vqdmlal.s32 q8, d19, d18 @ encoding: [0xa2,0x09,0xe3,0xef] vqdmlal.s32 q8, d19, d18 -@ CHECK: vmls.i8 d16, d18, d17 @ encoding: [0xa1,0x09,0x42,0xff] + +@ CHECK: vqdmlal.s16 q8, d19, d18 @ encoding: [0xd3,0xef,0xa2,0x09] +@ CHECK: vqdmlal.s32 q8, d19, d18 @ encoding: [0xe3,0xef,0xa2,0x09] + + vmls.i8 d16, d18, d17 -@ CHECK: vmls.i16 d16, d18, d17 @ encoding: [0xa1,0x09,0x52,0xff] vmls.i16 d16, d18, d17 -@ CHECK: vmls.i32 d16, d18, d17 @ encoding: [0xa1,0x09,0x62,0xff] vmls.i32 d16, d18, d17 -@ CHECK: vmls.f32 d16, d18, d17 @ encoding: [0xb1,0x0d,0x62,0xef] vmls.f32 d16, d18, d17 -@ CHECK: vmls.i8 q9, q8, q10 @ encoding: [0xe4,0x29,0x40,0xff] vmls.i8 q9, q8, q10 -@ CHECK: vmls.i16 q9, q8, q10 @ encoding: [0xe4,0x29,0x50,0xff] vmls.i16 q9, q8, q10 -@ CHECK: vmls.i32 q9, q8, q10 @ encoding: [0xe4,0x29,0x60,0xff] vmls.i32 q9, q8, q10 -@ CHECK: vmls.f32 q9, q8, q10 @ encoding: [0xf4,0x2d,0x60,0xef] vmls.f32 q9, q8, q10 -@ CHECK: vmlsl.s8 q8, d19, d18 @ encoding: [0xa2,0x0a,0xc3,0xef] + +@ CHECK: vmls.i8 d16, d18, d17 @ encoding: [0x42,0xff,0xa1,0x09] +@ CHECK: vmls.i16 d16, d18, d17 @ encoding: [0x52,0xff,0xa1,0x09] +@ CHECK: vmls.i32 d16, d18, d17 @ encoding: [0x62,0xff,0xa1,0x09] +@ CHECK: vmls.f32 d16, d18, d17 @ encoding: [0x62,0xef,0xb1,0x0d] +@ CHECK: vmls.i8 q9, q8, q10 @ encoding: [0x40,0xff,0xe4,0x29] +@ CHECK: vmls.i16 q9, q8, q10 @ encoding: [0x50,0xff,0xe4,0x29] +@ CHECK: vmls.i32 q9, q8, q10 @ encoding: [0x60,0xff,0xe4,0x29] +@ CHECK: vmls.f32 q9, q8, q10 @ encoding: [0x60,0xef,0xf4,0x2d] + + vmlsl.s8 q8, d19, d18 -@ CHECK: vmlsl.s16 q8, d19, d18 @ encoding: [0xa2,0x0a,0xd3,0xef] vmlsl.s16 q8, d19, d18 -@ CHECK: vmlsl.s32 q8, d19, d18 @ encoding: [0xa2,0x0a,0xe3,0xef] vmlsl.s32 q8, d19, d18 -@ CHECK: vmlsl.u8 q8, d19, d18 @ encoding: [0xa2,0x0a,0xc3,0xff] vmlsl.u8 q8, d19, d18 -@ CHECK: vmlsl.u16 q8, d19, d18 @ encoding: [0xa2,0x0a,0xd3,0xff] vmlsl.u16 q8, d19, d18 -@ CHECK: vmlsl.u32 q8, d19, d18 @ encoding: [0xa2,0x0a,0xe3,0xff] vmlsl.u32 q8, d19, d18 -@ CHECK: vqdmlsl.s16 q8, d19, d18 @ encoding: [0xa2,0x0b,0xd3,0xef] + +@ CHECK: vmlsl.s8 q8, d19, d18 @ encoding: [0xc3,0xef,0xa2,0x0a] +@ CHECK: vmlsl.s16 q8, d19, d18 @ encoding: [0xd3,0xef,0xa2,0x0a] +@ CHECK: vmlsl.s32 q8, d19, d18 @ encoding: [0xe3,0xef,0xa2,0x0a] +@ CHECK: vmlsl.u8 q8, d19, d18 @ encoding: [0xc3,0xff,0xa2,0x0a] +@ CHECK: vmlsl.u16 q8, d19, d18 @ encoding: [0xd3,0xff,0xa2,0x0a] +@ CHECK: vmlsl.u32 q8, d19, d18 @ encoding: [0xe3,0xff,0xa2,0x0a] + + vqdmlsl.s16 q8, d19, d18 -@ CHECK: vqdmlsl.s32 q8, d19, d18 @ encoding: [0xa2,0x0b,0xe3,0xef] vqdmlsl.s32 q8, d19, d18 + +@ CHECK: vqdmlsl.s16 q8, d19, d18 @ encoding: [0xd3,0xef,0xa2,0x0b] +@ CHECK: vqdmlsl.s32 q8, d19, d18 @ encoding: [0xe3,0xef,0xa2,0x0b] From grosbach at apple.com Tue Oct 4 15:50:06 2011 From: grosbach at apple.com (Jim Grosbach) Date: Tue, 04 Oct 2011 20:50:06 -0000 Subject: [llvm-commits] [llvm] r141114 - /llvm/trunk/test/MC/ARM/neont2-bitcount-encoding.s Message-ID: <20111004205007.67AA62A6C12C@llvm.org> Author: grosbach Date: Tue Oct 4 15:50:05 2011 New Revision: 141114 URL: http://llvm.org/viewvc/llvm-project?rev=141114&view=rev Log: Un-XFAIL file. Fix incorrect CHECK lines. General format cleanup. Modified: llvm/trunk/test/MC/ARM/neont2-bitcount-encoding.s Modified: llvm/trunk/test/MC/ARM/neont2-bitcount-encoding.s URL: http://llvm.org/viewvc/llvm-project/llvm/trunk/test/MC/ARM/neont2-bitcount-encoding.s?rev=141114&r1=141113&r2=141114&view=diff ============================================================================== --- llvm/trunk/test/MC/ARM/neont2-bitcount-encoding.s (original) +++ llvm/trunk/test/MC/ARM/neont2-bitcount-encoding.s Tue Oct 4 15:50:05 2011 @@ -1,34 +1,38 @@ @ RUN: llvm-mc -mcpu=cortex-a8 -triple thumb-unknown-unknown -show-encoding < %s | FileCheck %s -@ XFAIL: * .code 16 -@ CHECK: vcnt.8 d16, d16 @ encoding: [0x20,0x05,0xf0,0xff] vcnt.8 d16, d16 -@ CHECK: vcnt.8 q8, q8 @ encoding: [0x60,0x05,0xf0,0xff] vcnt.8 q8, q8 -@ CHECK: vclz.i8 d16, d16 @ encoding: [0xa0,0x04,0xf0,0xff] + +@ CHECK: vcnt.8 d16, d16 @ encoding: [0xf0,0xff,0x20,0x05] +@ CHECK: vcnt.8 q8, q8 @ encoding: [0xf0,0xff,0x60,0x05] + vclz.i8 d16, d16 -@ CHECK: vclz.i16 d16, d16 @ encoding: [0xa0,0x04,0xf4,0xff] vclz.i16 d16, d16 -@ CHECK: vclz.i32 d16, d16 @ encoding: [0xa0,0x04,0xf8,0xff] vclz.i32 d16, d16 -@ CHECK: vclz.i8 q8, q8 @ encoding: [0xe0,0x04,0xf0,0xff] vclz.i8 q8, q8 -@ CHECK: vclz.i16 q8, q8 @ encoding: [0xe0,0x04,0xf4,0xff] vclz.i16 q8, q8 -@ CHECK: vclz.i32 q8, q8 @ encoding: [0xe0,0x04,0xf8,0xff] vclz.i32 q8, q8 -@ CHECK: vcls.s8 d16, d16 @ encoding: [0x20,0x04,0xf0,0xff] + +@ CHECK: vclz.i8 d16, d16 @ encoding: [0xf0,0xff,0xa0,0x04] +@ CHECK: vclz.i16 d16, d16 @ encoding: [0xf4,0xff,0xa0,0x04] +@ CHECK: vclz.i32 d16, d16 @ encoding: [0xf8,0xff,0xa0,0x04] +@ CHECK: vclz.i8 q8, q8 @ encoding: [0xf0,0xff,0xe0,0x04] +@ CHECK: vclz.i16 q8, q8 @ encoding: [0xf4,0xff,0xe0,0x04] +@ CHECK: vclz.i32 q8, q8 @ encoding: [0xf8,0xff,0xe0,0x04] + vcls.s8 d16, d16 -@ CHECK: vcls.s16 d16, d16 @ encoding: [0x20,0x04,0xf4,0xff] vcls.s16 d16, d16 -@ CHECK: vcls.s32 d16, d16 @ encoding: [0x20,0x04,0xf8,0xff] vcls.s32 d16, d16 -@ CHECK: vcls.s8 q8, q8 @ encoding: [0x60,0x04,0xf0,0xff] vcls.s8 q8, q8 -@ CHECK: vcls.s16 q8, q8 @ encoding: [0x60,0x04,0xf4,0xff] vcls.s16 q8, q8 -@ CHECK: vcls.s32 q8, q8 @ encoding: [0x60,0x04,0xf8,0xff] vcls.s32 q8, q8 +@ CHECK: vcls.s8 d16, d16 @ encoding: [0xf0,0xff,0x20,0x04] +@ CHECK: vcls.s16 d16, d16 @ encoding: [0xf4,0xff,0x20,0x04] +@ CHECK: vcls.s32 d16, d16 @ encoding: [0xf8,0xff,0x20,0x04] +@ CHECK: vcls.s8 q8, q8 @ encoding: [0xf0,0xff,0x60,0x04] +@ CHECK: vcls.s16 q8, q8 @ encoding: [0xf4,0xff,0x60,0x04] +@ CHECK: vcls.s32 q8, q8 @ encoding: [0xf8,0xff,0x60,0x04] + From grosbach at apple.com Tue Oct 4 15:53:01 2011 From: grosbach at apple.com (Jim Grosbach) Date: Tue, 04 Oct 2011 20:53:01 -0000 Subject: [llvm-commits] [llvm] r141115 - /llvm/trunk/test/MC/ARM/neont2-bitwise-encoding.s Message-ID: <20111004205303.186F62A6C12C@llvm.org> Author: grosbach Date: Tue Oct 4 15:52:57 2011 New Revision: 141115 URL: http://llvm.org/viewvc/llvm-project?rev=141115&view=rev Log: Tidy up formatting. Modified: llvm/trunk/test/MC/ARM/neont2-bitwise-encoding.s Modified: llvm/trunk/test/MC/ARM/neont2-bitwise-encoding.s URL: http://llvm.org/viewvc/llvm-project/llvm/trunk/test/MC/ARM/neont2-bitwise-encoding.s?rev=141115&r1=141114&r2=141115&view=diff ============================================================================== --- llvm/trunk/test/MC/ARM/neont2-bitwise-encoding.s (original) +++ llvm/trunk/test/MC/ARM/neont2-bitwise-encoding.s Tue Oct 4 15:52:57 2011 @@ -3,47 +3,60 @@ .code 16 -@ CHECK: vand d16, d17, d16 @ encoding: [0xb0,0x01,0x41,0xef] vand d16, d17, d16 -@ CHECK: vand q8, q8, q9 @ encoding: [0xf2,0x01,0x40,0xef] vand q8, q8, q9 -@ CHECK: veor d16, d17, d16 @ encoding: [0xb0,0x01,0x41,0xff] +@ CHECK: vand d16, d17, d16 @ encoding: [0xb0,0x01,0x41,0xef] +@ CHECK: vand q8, q8, q9 @ encoding: [0xf2,0x01,0x40,0xef] + + veor d16, d17, d16 -@ CHECK: veor q8, q8, q9 @ encoding: [0xf2,0x01,0x40,0xff] veor q8, q8, q9 -@ CHECK: vorr d16, d17, d16 @ encoding: [0xb0,0x01,0x61,0xef] +@ CHECK: veor d16, d17, d16 @ encoding: [0xb0,0x01,0x41,0xff] +@ CHECK: veor q8, q8, q9 @ encoding: [0xf2,0x01,0x40,0xff] + + vorr d16, d17, d16 -@ CHECK: vorr q8, q8, q9 @ encoding: [0xf2,0x01,0x60,0xef] vorr q8, q8, q9 + vorr.i32 d16, #0x1000000 + vorr.i32 q8, #0x1000000 + vorr.i32 q8, #0x0 + +@ CHECK: vorr d16, d17, d16 @ encoding: [0xb0,0x01,0x61,0xef] +@ CHECK: vorr q8, q8, q9 @ encoding: [0xf2,0x01,0x60,0xef] @ CHECK: vorr.i32 d16, #0x1000000 @ encoding: [0x11,0x07,0xc0,0xef] - vorr.i32 d16, #0x1000000 @ CHECK: vorr.i32 q8, #0x1000000 @ encoding: [0x51,0x07,0xc0,0xef] - vorr.i32 q8, #0x1000000 @ CHECK: vorr.i32 q8, #0x0 @ encoding: [0x50,0x01,0xc0,0xef] - vorr.i32 q8, #0x0 -@ CHECK: vbic d16, d17, d16 @ encoding: [0xb0,0x01,0x51,0xef] + vbic d16, d17, d16 -@ CHECK: vbic q8, q8, q9 @ encoding: [0xf2,0x01,0x50,0xef] vbic q8, q8, q9 + vbic.i32 d16, #0xFF000000 + vbic.i32 q8, #0xFF000000 + +@ CHECK: vbic d16, d17, d16 @ encoding: [0xb0,0x01,0x51,0xef] +@ CHECK: vbic q8, q8, q9 @ encoding: [0xf2,0x01,0x50,0xef] @ CHECK: vbic.i32 d16, #0xFF000000 @ encoding: [0x3f,0x07,0xc7,0xff] - vbic.i32 d16, #0xFF000000 @ CHECK: vbic.i32 q8, #0xFF000000 @ encoding: [0x7f,0x07,0xc7,0xff] - vbic.i32 q8, #0xFF000000 -@ CHECK: vorn d16, d17, d16 @ encoding: [0xb0,0x01,0x71,0xef] + vorn d16, d17, d16 -@ CHECK: vorn q8, q8, q9 @ encoding: [0xf2,0x01,0x70,0xef] vorn q8, q8, q9 -@ CHECK: vmvn d16, d16 @ encoding: [0xa0,0x05,0xf0,0xff] +@ CHECK: vorn d16, d17, d16 @ encoding: [0xb0,0x01,0x71,0xef] +@ CHECK: vorn q8, q8, q9 @ encoding: [0xf2,0x01,0x70,0xef] + + vmvn d16, d16 -@ CHECK: vmvn q8, q8 @ encoding: [0xe0,0x05,0xf0,0xff] vmvn q8, q8 -@ CHECK: vbsl d18, d17, d16 @ encoding: [0xb0,0x21,0x51,0xff] +@ CHECK: vmvn d16, d16 @ encoding: [0xa0,0x05,0xf0,0xff] +@ CHECK: vmvn q8, q8 @ encoding: [0xe0,0x05,0xf0,0xff] + + vbsl d18, d17, d16 -@ CHECK: vbsl q8, q10, q9 @ encoding: [0xf2,0x01,0x54,0xff] vbsl q8, q10, q9 + +@ CHECK: vbsl d18, d17, d16 @ encoding: [0xb0,0x21,0x51,0xff] +@ CHECK: vbsl q8, q10, q9 @ encoding: [0xf2,0x01,0x54,0xff] From pichet2000 at gmail.com Tue Oct 4 16:09:00 2011 From: pichet2000 at gmail.com (Francois Pichet) Date: Tue, 04 Oct 2011 21:09:00 -0000 Subject: [llvm-commits] [llvm] r141116 - /llvm/trunk/lib/TableGen/TGPreprocessor.cpp Message-ID: <20111004210900.B78502A6C12C@llvm.org> Author: fpichet Date: Tue Oct 4 16:08:56 2011 New Revision: 141116 URL: http://llvm.org/viewvc/llvm-project?rev=141116&view=rev Log: Replace snprintf with raw_string_ostream. Modified: llvm/trunk/lib/TableGen/TGPreprocessor.cpp Modified: llvm/trunk/lib/TableGen/TGPreprocessor.cpp URL: http://llvm.org/viewvc/llvm-project/llvm/trunk/lib/TableGen/TGPreprocessor.cpp?rev=141116&r1=141115&r2=141116&view=diff ============================================================================== --- llvm/trunk/lib/TableGen/TGPreprocessor.cpp (original) +++ llvm/trunk/lib/TableGen/TGPreprocessor.cpp Tue Oct 4 16:08:56 2011 @@ -24,10 +24,6 @@ #include #include -#ifdef _MSC_VER -#define snprintf _snprintf -#endif - namespace llvm { typedef std::map TGPPEnvironment; @@ -170,9 +166,10 @@ if (Kind == tgpprange_list) return Vals.at(i); else { - char buf[32]; - snprintf(buf, sizeof(buf), "%ld", From + (long int)i); - return std::string(buf); + std::string Result; + raw_string_ostream Tmp(Result); + Tmp << (From + (long int)i); + return Tmp.str(); } } From pichet2000 at gmail.com Tue Oct 4 16:11:44 2011 From: pichet2000 at gmail.com (Francois Pichet) Date: Tue, 4 Oct 2011 17:11:44 -0400 Subject: [llvm-commits] [llvm] r141093 - /llvm/trunk/lib/TableGen/TGPreprocessor.cpp In-Reply-To: <85572F49-9DAF-42B7-8CC7-FDF840B76D7F@2pi.dk> References: <20111004162807.BB4E92A6C12C@llvm.org> <85572F49-9DAF-42B7-8CC7-FDF840B76D7F@2pi.dk> Message-ID: On Tue, Oct 4, 2011 at 1:03 PM, Jakob Stoklund Olesen wrote: > > On Oct 4, 2011, at 9:28 AM, Francois Pichet wrote: > >> Author: fpichet >> Date: Tue Oct ?4 11:28:07 2011 >> New Revision: 141093 >> >> URL: http://llvm.org/viewvc/llvm-project?rev=141093&view=rev >> Log: >> Unbreak MSVC build. >> >> Modified: >> ? ?llvm/trunk/lib/TableGen/TGPreprocessor.cpp >> >> Modified: llvm/trunk/lib/TableGen/TGPreprocessor.cpp >> URL: http://llvm.org/viewvc/llvm-project/llvm/trunk/lib/TableGen/TGPreprocessor.cpp?rev=141093&r1=141092&r2=141093&view=diff >> ============================================================================== >> --- llvm/trunk/lib/TableGen/TGPreprocessor.cpp (original) >> +++ llvm/trunk/lib/TableGen/TGPreprocessor.cpp Tue Oct ?4 11:28:07 2011 >> @@ -24,6 +24,10 @@ >> #include >> #include >> >> +#ifdef _MSC_VER >> +#define snprintf _snprintf >> +#endif > > Hi Francois, > > Unfortunately, Microsoft's _snprintf is not a safe replacement for the C99 snprintf function. It doesn't NUL-terminate the buffer on overflow. > > Please rewrite the code to use raw_string_ostream, or plain sprintf which seems safe in this case. > ok then, r141116. From stoklund at 2pi.dk Tue Oct 4 16:13:20 2011 From: stoklund at 2pi.dk (Jakob Stoklund Olesen) Date: Tue, 04 Oct 2011 14:13:20 -0700 Subject: [llvm-commits] [llvm] r141093 - /llvm/trunk/lib/TableGen/TGPreprocessor.cpp In-Reply-To: References: <20111004162807.BB4E92A6C12C@llvm.org> <85572F49-9DAF-42B7-8CC7-FDF840B76D7F@2pi.dk> Message-ID: <0080B26F-E95A-4D65-91CB-AB12F7911334@2pi.dk> On Oct 4, 2011, at 2:11 PM, Francois Pichet wrote: > On Tue, Oct 4, 2011 at 1:03 PM, Jakob Stoklund Olesen wrote: >> >> On Oct 4, 2011, at 9:28 AM, Francois Pichet wrote: >> >>> Author: fpichet >>> Date: Tue Oct 4 11:28:07 2011 >>> New Revision: 141093 >>> >>> URL: http://llvm.org/viewvc/llvm-project?rev=141093&view=rev >>> Log: >>> Unbreak MSVC build. >>> >>> Modified: >>> llvm/trunk/lib/TableGen/TGPreprocessor.cpp >>> >>> Modified: llvm/trunk/lib/TableGen/TGPreprocessor.cpp >>> URL: http://llvm.org/viewvc/llvm-project/llvm/trunk/lib/TableGen/TGPreprocessor.cpp?rev=141093&r1=141092&r2=141093&view=diff >>> ============================================================================== >>> --- llvm/trunk/lib/TableGen/TGPreprocessor.cpp (original) >>> +++ llvm/trunk/lib/TableGen/TGPreprocessor.cpp Tue Oct 4 11:28:07 2011 >>> @@ -24,6 +24,10 @@ >>> #include >>> #include >>> >>> +#ifdef _MSC_VER >>> +#define snprintf _snprintf >>> +#endif >> >> Hi Francois, >> >> Unfortunately, Microsoft's _snprintf is not a safe replacement for the C99 snprintf function. It doesn't NUL-terminate the buffer on overflow. >> >> Please rewrite the code to use raw_string_ostream, or plain sprintf which seems safe in this case. >> > > ok then, r141116. Thanks! /jakob From grosbach at apple.com Tue Oct 4 16:16:50 2011 From: grosbach at apple.com (Jim Grosbach) Date: Tue, 04 Oct 2011 21:16:50 -0000 Subject: [llvm-commits] [llvm] r141117 - /llvm/trunk/test/MC/ARM/neont2-bitwise-encoding.s Message-ID: <20111004211650.543C22A6C12C@llvm.org> Author: grosbach Date: Tue Oct 4 16:16:42 2011 New Revision: 141117 URL: http://llvm.org/viewvc/llvm-project?rev=141117&view=rev Log: Un-XFAIL file. Comment out individual failing instructions. Modified: llvm/trunk/test/MC/ARM/neont2-bitwise-encoding.s Modified: llvm/trunk/test/MC/ARM/neont2-bitwise-encoding.s URL: http://llvm.org/viewvc/llvm-project/llvm/trunk/test/MC/ARM/neont2-bitwise-encoding.s?rev=141117&r1=141116&r2=141117&view=diff ============================================================================== --- llvm/trunk/test/MC/ARM/neont2-bitwise-encoding.s (original) +++ llvm/trunk/test/MC/ARM/neont2-bitwise-encoding.s Tue Oct 4 16:16:42 2011 @@ -1,62 +1,55 @@ @ RUN: llvm-mc -mcpu=cortex-a8 -triple thumb-unknown-unknown -show-encoding < %s | FileCheck %s -@ XFAIL: * .code 16 vand d16, d17, d16 vand q8, q8, q9 -@ CHECK: vand d16, d17, d16 @ encoding: [0xb0,0x01,0x41,0xef] -@ CHECK: vand q8, q8, q9 @ encoding: [0xf2,0x01,0x40,0xef] - +@ CHECK: vand d16, d17, d16 @ encoding: [0x41,0xef,0xb0,0x01] +@ CHECK: vand q8, q8, q9 @ encoding: [0x40,0xef,0xf2,0x01] veor d16, d17, d16 veor q8, q8, q9 -@ CHECK: veor d16, d17, d16 @ encoding: [0xb0,0x01,0x41,0xff] -@ CHECK: veor q8, q8, q9 @ encoding: [0xf2,0x01,0x40,0xff] +@ CHECK: veor d16, d17, d16 @ encoding: [0x41,0xff,0xb0,0x01] +@ CHECK: veor q8, q8, q9 @ encoding: [0x40,0xff,0xf2,0x01] vorr d16, d17, d16 vorr q8, q8, q9 - vorr.i32 d16, #0x1000000 - vorr.i32 q8, #0x1000000 - vorr.i32 q8, #0x0 - -@ CHECK: vorr d16, d17, d16 @ encoding: [0xb0,0x01,0x61,0xef] -@ CHECK: vorr q8, q8, q9 @ encoding: [0xf2,0x01,0x60,0xef] -@ CHECK: vorr.i32 d16, #0x1000000 @ encoding: [0x11,0x07,0xc0,0xef] -@ CHECK: vorr.i32 q8, #0x1000000 @ encoding: [0x51,0x07,0xc0,0xef] -@ CHECK: vorr.i32 q8, #0x0 @ encoding: [0x50,0x01,0xc0,0xef] +@ vorr.i32 d16, #0x1000000 +@ vorr.i32 q8, #0x1000000 +@ vorr.i32 q8, #0x0 + +@ CHECK: vorr d16, d17, d16 @ encoding: [0x61,0xef,0xb0,0x01] +@ CHECK: vorr q8, q8, q9 @ encoding: [0x60,0xef,0xf2,0x01] vbic d16, d17, d16 vbic q8, q8, q9 - vbic.i32 d16, #0xFF000000 - vbic.i32 q8, #0xFF000000 +@ vbic.i32 d16, #0xFF000000 +@ vbic.i32 q8, #0xFF000000 -@ CHECK: vbic d16, d17, d16 @ encoding: [0xb0,0x01,0x51,0xef] -@ CHECK: vbic q8, q8, q9 @ encoding: [0xf2,0x01,0x50,0xef] -@ CHECK: vbic.i32 d16, #0xFF000000 @ encoding: [0x3f,0x07,0xc7,0xff] -@ CHECK: vbic.i32 q8, #0xFF000000 @ encoding: [0x7f,0x07,0xc7,0xff] +@ CHECK: vbic d16, d17, d16 @ encoding: [0x51,0xef,0xb0,0x01] +@ CHECK: vbic q8, q8, q9 @ encoding: [0x50,0xef,0xf2,0x01] vorn d16, d17, d16 vorn q8, q8, q9 -@ CHECK: vorn d16, d17, d16 @ encoding: [0xb0,0x01,0x71,0xef] -@ CHECK: vorn q8, q8, q9 @ encoding: [0xf2,0x01,0x70,0xef] +@ CHECK: vorn d16, d17, d16 @ encoding: [0x71,0xef,0xb0,0x01] +@ CHECK: vorn q8, q8, q9 @ encoding: [0x70,0xef,0xf2,0x01] vmvn d16, d16 vmvn q8, q8 -@ CHECK: vmvn d16, d16 @ encoding: [0xa0,0x05,0xf0,0xff] -@ CHECK: vmvn q8, q8 @ encoding: [0xe0,0x05,0xf0,0xff] +@ CHECK: vmvn d16, d16 @ encoding: [0xf0,0xff,0xa0,0x05] +@ CHECK: vmvn q8, q8 @ encoding: [0xf0,0xff,0xe0,0x05] vbsl d18, d17, d16 vbsl q8, q10, q9 -@ CHECK: vbsl d18, d17, d16 @ encoding: [0xb0,0x21,0x51,0xff] -@ CHECK: vbsl q8, q10, q9 @ encoding: [0xf2,0x01,0x54,0xff] +@ CHECK: vbsl d18, d17, d16 @ encoding: [0x51,0xff,0xb0,0x21] +@ CHECK: vbsl q8, q10, q9 @ encoding: [0x54,0xff,0xf2,0x01] From daniel at zuster.org Tue Oct 4 16:17:19 2011 From: daniel at zuster.org (Daniel Dunbar) Date: Tue, 04 Oct 2011 21:17:19 -0000 Subject: [llvm-commits] [llvm] r141118 - /llvm/trunk/website/index.html Message-ID: <20111004211719.4B1582A6C12C@llvm.org> Author: ddunbar Date: Tue Oct 4 16:17:19 2011 New Revision: 141118 URL: http://llvm.org/viewvc/llvm-project?rev=141118&view=rev Log: Remove unused web page. Removed: llvm/trunk/website/index.html Removed: llvm/trunk/website/index.html URL: http://llvm.org/viewvc/llvm-project/llvm/trunk/website/index.html?rev=141117&view=auto ============================================================================== --- llvm/trunk/website/index.html (original) +++ llvm/trunk/website/index.html (removed) @@ -1,26 +0,0 @@ - - - - LLVM Core Website - - - - -
LLVM Core Web Site
-

This is just a place holder for now.

-
- - - -
-
- Valid CSS! - Valid HTML 4.01! - - LLVM Compiler Infrastructure
- Last modified: $Date: 2007-07-09 01:04:31 -0700 (Mon, 09 Jul 2007) $ -
- From isanbard at gmail.com Tue Oct 4 16:25:01 2011 From: isanbard at gmail.com (Bill Wendling) Date: Tue, 04 Oct 2011 21:25:01 -0000 Subject: [llvm-commits] [llvm] r141122 - /llvm/trunk/include/llvm/CodeGen/MachineModuleInfo.h Message-ID: <20111004212502.745AE2A6C12C@llvm.org> Author: void Date: Tue Oct 4 16:25:01 2011 New Revision: 141122 URL: http://llvm.org/viewvc/llvm-project?rev=141122&view=rev Log: Doxygen-ize comments. No functionality change. Modified: llvm/trunk/include/llvm/CodeGen/MachineModuleInfo.h Modified: llvm/trunk/include/llvm/CodeGen/MachineModuleInfo.h URL: http://llvm.org/viewvc/llvm-project/llvm/trunk/include/llvm/CodeGen/MachineModuleInfo.h?rev=141122&r1=141121&r2=141122&view=diff ============================================================================== --- llvm/trunk/include/llvm/CodeGen/MachineModuleInfo.h (original) +++ llvm/trunk/include/llvm/CodeGen/MachineModuleInfo.h Tue Oct 4 16:25:01 2011 @@ -107,40 +107,38 @@ /// want. MachineModuleInfoImpl *ObjFileMMI; - // FrameMoves - List of moves done by a function's prolog. Used to construct - // frame maps by debug and exception handling consumers. + /// FrameMoves - List of moves done by a function's prolog. Used to construct + /// frame maps by debug and exception handling consumers. std::vector FrameMoves; - // CompactUnwindEncoding - If the target supports it, this is the compact - // unwind encoding. It replaces a function's CIE and FDE. + /// CompactUnwindEncoding - If the target supports it, this is the compact + /// unwind encoding. It replaces a function's CIE and FDE. uint32_t CompactUnwindEncoding; - // LandingPads - List of LandingPadInfo describing the landing pad information - // in the current function. + /// LandingPads - List of LandingPadInfo describing the landing pad + /// information in the current function. std::vector LandingPads; - // Map of invoke call site index values to associated begin EH_LABEL for - // the current function. + /// CallSiteMap - Map of invoke call site index values to associated begin + /// EH_LABEL for the current function. DenseMap CallSiteMap; - // The current call site index being processed, if any. 0 if none. + /// CurCallSite - The current call site index being processed, if any. 0 if + /// none. unsigned CurCallSite; - // TypeInfos - List of C++ TypeInfo used in the current function. - // + /// TypeInfos - List of C++ TypeInfo used in the current function. std::vector TypeInfos; - // FilterIds - List of typeids encoding filters used in the current function. - // + /// FilterIds - List of typeids encoding filters used in the current function. std::vector FilterIds; - // FilterEnds - List of the indices in FilterIds corresponding to filter - // terminators. - // + /// FilterEnds - List of the indices in FilterIds corresponding to filter + /// terminators. std::vector FilterEnds; - // Personalities - Vector of all personality functions ever seen. Used to emit - // common EH frames. + /// Personalities - Vector of all personality functions ever seen. Used to + /// emit common EH frames. std::vector Personalities; /// UsedFunctions - The functions in the @llvm.used list in a more easily @@ -148,7 +146,6 @@ /// llvm.compiler.used. SmallPtrSet UsedFunctions; - /// AddrLabelSymbols - This map keeps track of which symbol is being used for /// the specified basic block's address of label. MMIAddrLabelMap *AddrLabelSymbols; @@ -160,8 +157,9 @@ /// in this module. bool DbgInfoAvailable; - /// True if this module calls VarArg function with floating point arguments. - /// This is used to emit an undefined reference to fltused on Windows targets. + /// CallsExternalVAFunctionWithFloatingPointArguments - True if this module + /// calls VarArg function with floating point arguments. This is used to emit + /// an undefined reference to fltused on Windows targets. bool CallsExternalVAFunctionWithFloatingPointArguments; public: From grosbach at apple.com Tue Oct 4 16:43:52 2011 From: grosbach at apple.com (Jim Grosbach) Date: Tue, 04 Oct 2011 21:43:52 -0000 Subject: [llvm-commits] [llvm] r141123 - /llvm/trunk/test/MC/ARM/neon-vld-encoding.s Message-ID: <20111004214353.75820312800A@llvm.org> Author: grosbach Date: Tue Oct 4 16:43:51 2011 New Revision: 141123 URL: http://llvm.org/viewvc/llvm-project?rev=141123&view=rev Log: Tidy up formatting. Modified: llvm/trunk/test/MC/ARM/neon-vld-encoding.s Modified: llvm/trunk/test/MC/ARM/neon-vld-encoding.s URL: http://llvm.org/viewvc/llvm-project/llvm/trunk/test/MC/ARM/neon-vld-encoding.s?rev=141123&r1=141122&r2=141123&view=diff ============================================================================== --- llvm/trunk/test/MC/ARM/neon-vld-encoding.s (original) +++ llvm/trunk/test/MC/ARM/neon-vld-encoding.s Tue Oct 4 16:43:51 2011 @@ -1,110 +1,125 @@ @ RUN: llvm-mc -mcpu=cortex-a8 -triple armv7-apple-darwin -show-encoding < %s | FileCheck %s @ XFAIL: * -@ CHECK: vld1.8 {d16}, [r0, :64] @ encoding: [0x1f,0x07,0x60,0xf4] vld1.8 {d16}, [r0, :64] -@ CHECK: vld1.16 {d16}, [r0] @ encoding: [0x4f,0x07,0x60,0xf4] - vld1.16 {d16}, [r0] -@ CHECK: vld1.32 {d16}, [r0] @ encoding: [0x8f,0x07,0x60,0xf4] - vld1.32 {d16}, [r0] -@ CHECK: vld1.64 {d16}, [r0] @ encoding: [0xcf,0x07,0x60,0xf4] - vld1.64 {d16}, [r0] + vld1.16 {d16}, [r0] + vld1.32 {d16}, [r0] + vld1.64 {d16}, [r0] + vld1.8 {d16, d17}, [r0, :64] + vld1.16 {d16, d17}, [r0, :128] + vld1.32 {d16, d17}, [r0] + vld1.64 {d16, d17}, [r0] + +@ CHECK: vld1.8 {d16}, [r0, :64] @ encoding: [0x1f,0x07,0x60,0xf4] +@ CHECK: vld1.16 {d16}, [r0] @ encoding: [0x4f,0x07,0x60,0xf4] +@ CHECK: vld1.32 {d16}, [r0] @ encoding: [0x8f,0x07,0x60,0xf4] +@ CHECK: vld1.64 {d16}, [r0] @ encoding: [0xcf,0x07,0x60,0xf4] @ CHECK: vld1.8 {d16, d17}, [r0, :64] @ encoding: [0x1f,0x0a,0x60,0xf4] - vld1.8 {d16, d17}, [r0, :64] -@ CHECK: vld1.16 {d16, d17}, [r0, :128] @ encoding: [0x6f,0x0a,0x60,0xf4] - vld1.16 {d16, d17}, [r0, :128] -@ CHECK: vld1.32 {d16, d17}, [r0] @ encoding: [0x8f,0x0a,0x60,0xf4] - vld1.32 {d16, d17}, [r0] -@ CHECK: vld1.64 {d16, d17}, [r0] @ encoding: [0xcf,0x0a,0x60,0xf4] - vld1.64 {d16, d17}, [r0] +@ CHECK: vld1.16 {d16, d17}, [r0, :128] @ encoding: [0x6f,0x0a,0x60,0xf4] +@ CHECK: vld1.32 {d16, d17}, [r0]@ encoding: [0x8f,0x0a,0x60,0xf4] +@ CHECK: vld1.64 {d16, d17}, [r0]@ encoding: [0xcf,0x0a,0x60,0xf4] + + + vld2.8 {d16, d17}, [r0, :64] + vld2.16 {d16, d17}, [r0, :128] + vld2.32 {d16, d17}, [r0] + vld2.8 {d16, d17, d18, d19}, [r0, :64] + vld2.16 {d16, d17, d18, d19}, [r0, :128] + vld2.32 {d16, d17, d18, d19}, [r0, :256] @ CHECK: vld2.8 {d16, d17}, [r0, :64] @ encoding: [0x1f,0x08,0x60,0xf4] - vld2.8 {d16, d17}, [r0, :64] -@ CHECK: vld2.16 {d16, d17}, [r0, :128] @ encoding: [0x6f,0x08,0x60,0xf4] - vld2.16 {d16, d17}, [r0, :128] -@ CHECK: vld2.32 {d16, d17}, [r0] @ encoding: [0x8f,0x08,0x60,0xf4] - vld2.32 {d16, d17}, [r0] -@ CHECK: vld2.8 {d16, d17, d18, d19}, [r0, :64] @ encoding: [0x1f,0x03,0x60,0xf4] - vld2.8 {d16, d17, d18, d19}, [r0, :64] -@ CHECK: vld2.16 {d16, d17, d18, d19}, [r0, :128] @ encoding: [0x6f,0x03,0x60,0xf4] - vld2.16 {d16, d17, d18, d19}, [r0, :128] -@ CHECK: vld2.32 {d16, d17, d18, d19}, [r0, :256] @ encoding: [0xbf,0x03,0x60,0xf4] - vld2.32 {d16, d17, d18, d19}, [r0, :256] +@ CHECK: vld2.16 {d16, d17}, [r0, :128] @ encoding: [0x6f,0x08,0x60,0xf4] +@ CHECK: vld2.32 {d16, d17}, [r0]@ encoding: [0x8f,0x08,0x60,0xf4] +@ CHECK: vld2.8 {d16, d17, d18, d19}, [r0, :64]@ encoding: [0x1f,0x03,0x60,0xf4] +@ CHECK: vld2.16 {d16, d17, d18, d19}, [r0, :128] @ encoding: [0x6f,0x03,0x60,0xf4] +@ CHECK: vld2.32 {d16, d17, d18, d19}, [r0, :256] @ encoding: [0xbf,0x03,0x60,0xf4] + + + vld3.8 {d16, d17, d18}, [r0, :64] + vld3.16 {d16, d17, d18}, [r0] + vld3.32 {d16, d17, d18}, [r0] + vld3.8 {d16, d18, d20}, [r0, :64]! + vld3.8 {d17, d19, d21}, [r0, :64]! + vld3.16 {d16, d18, d20}, [r0]! + vld3.16 {d17, d19, d21}, [r0]! + vld3.32 {d16, d18, d20}, [r0]! + vld3.32 {d17, d19, d21}, [r0]! @ CHECK: vld3.8 {d16, d17, d18}, [r0, :64] @ encoding: [0x1f,0x04,0x60,0xf4] - vld3.8 {d16, d17, d18}, [r0, :64] -@ CHECK: vld3.16 {d16, d17, d18}, [r0] @ encoding: [0x4f,0x04,0x60,0xf4] - vld3.16 {d16, d17, d18}, [r0] -@ CHECK: vld3.32 {d16, d17, d18}, [r0] @ encoding: [0x8f,0x04,0x60,0xf4] - vld3.32 {d16, d17, d18}, [r0] +@ CHECK: vld3.16 {d16, d17, d18}, [r0] @ encoding: [0x4f,0x04,0x60,0xf4] +@ CHECK: vld3.32 {d16, d17, d18}, [r0] @ encoding: [0x8f,0x04,0x60,0xf4] @ CHECK: vld3.8 {d16, d18, d20}, [r0, :64]! @ encoding: [0x1d,0x05,0x60,0xf4] - vld3.8 {d16, d18, d20}, [r0, :64]! @ CHECK: vld3.8 {d17, d19, d21}, [r0, :64]! @ encoding: [0x1d,0x15,0x60,0xf4] - vld3.8 {d17, d19, d21}, [r0, :64]! -@ CHECK: vld3.16 {d16, d18, d20}, [r0]! @ encoding: [0x4d,0x05,0x60,0xf4] - vld3.16 {d16, d18, d20}, [r0]! -@ CHECK: vld3.16 {d17, d19, d21}, [r0]! @ encoding: [0x4d,0x15,0x60,0xf4] - vld3.16 {d17, d19, d21}, [r0]! -@ CHECK: vld3.32 {d16, d18, d20}, [r0]! @ encoding: [0x8d,0x05,0x60,0xf4] - vld3.32 {d16, d18, d20}, [r0]! -@ CHECK: vld3.32 {d17, d19, d21}, [r0]! @ encoding: [0x8d,0x15,0x60,0xf4] - vld3.32 {d17, d19, d21}, [r0]! - -@ CHECK: vld4.8 {d16, d17, d18, d19}, [r0, :64] @ encoding: [0x1f,0x00,0x60,0xf4] - vld4.8 {d16, d17, d18, d19}, [r0, :64] -@ CHECK: vld4.16 {d16, d17, d18, d19}, [r0, :128] @ encoding: [0x6f,0x00,0x60,0xf4] - vld4.16 {d16, d17, d18, d19}, [r0, :128] -@ CHECK: vld4.32 {d16, d17, d18, d19}, [r0, :256] @ encoding: [0xbf,0x00,0x60,0xf4] - vld4.32 {d16, d17, d18, d19}, [r0, :256] -@ CHECK: vld4.8 {d16, d18, d20, d22}, [r0, :256]! @ encoding: [0x3d,0x01,0x60,0xf4] - vld4.8 {d16, d18, d20, d22}, [r0, :256]! -@ CHECK: vld4.8 {d17, d19, d21, d23}, [r0, :256]! @ encoding: [0x3d,0x11,0x60,0xf4] - vld4.8 {d17, d19, d21, d23}, [r0, :256]! -@ CHECK: vld4.16 {d16, d18, d20, d22}, [r0]! @ encoding: [0x4d,0x01,0x60,0xf4] - vld4.16 {d16, d18, d20, d22}, [r0]! -@ CHECK: vld4.16 {d17, d19, d21, d23}, [r0]! @ encoding: [0x4d,0x11,0x60,0xf4] - vld4.16 {d17, d19, d21, d23}, [r0]! -@ CHECK: vld4.32 {d16, d18, d20, d22}, [r0]! @ encoding: [0x8d,0x01,0x60,0xf4] - vld4.32 {d16, d18, d20, d22}, [r0]! -@ CHECK: vld4.32 {d17, d19, d21, d23}, [r0]! @ encoding: [0x8d,0x11,0x60,0xf4] - vld4.32 {d17, d19, d21, d23}, [r0]! +@ CHECK: vld3.16 {d16, d18, d20}, [r0]! @ encoding: [0x4d,0x05,0x60,0xf4] +@ CHECK: vld3.16 {d17, d19, d21}, [r0]! @ encoding: [0x4d,0x15,0x60,0xf4] +@ CHECK: vld3.32 {d16, d18, d20}, [r0]! @ encoding: [0x8d,0x05,0x60,0xf4] +@ CHECK: vld3.32 {d17, d19, d21}, [r0]! @ encoding: [0x8d,0x15,0x60,0xf4] + + + vld4.8 {d16, d17, d18, d19}, [r0, :64] + vld4.16 {d16, d17, d18, d19}, [r0, :128] + vld4.32 {d16, d17, d18, d19}, [r0, :256] + vld4.8 {d16, d18, d20, d22}, [r0, :256]! + vld4.8 {d17, d19, d21, d23}, [r0, :256]! + vld4.16 {d16, d18, d20, d22}, [r0]! + vld4.16 {d17, d19, d21, d23}, [r0]! + vld4.32 {d16, d18, d20, d22}, [r0]! + vld4.32 {d17, d19, d21, d23}, [r0]! + +@ CHECK: vld4.8 {d16, d17, d18, d19}, [r0, :64]@ encoding: [0x1f,0x00,0x60,0xf4] +@ CHECK: vld4.16 {d16, d17, d18, d19}, [r0,:128]@ encoding:[0x6f,0x00,0x60,0xf4] +@ CHECK: vld4.32 {d16, d17, d18, d19}, [r0,:256]@ encoding:[0xbf,0x00,0x60,0xf4] +@ CHECK: vld4.8 {d16, d18, d20, d22}, [r0,:256]!@ encoding:[0x3d,0x01,0x60,0xf4] +@ CHECK: vld4.8 {d17, d19, d21, d23}, [r0,:256]!@ encoding:[0x3d,0x11,0x60,0xf4] +@ CHECK: vld4.16 {d16, d18, d20, d22}, [r0]! @ encoding: [0x4d,0x01,0x60,0xf4] +@ CHECK: vld4.16 {d17, d19, d21, d23}, [r0]! @ encoding: [0x4d,0x11,0x60,0xf4] +@ CHECK: vld4.32 {d16, d18, d20, d22}, [r0]! @ encoding: [0x8d,0x01,0x60,0xf4] +@ CHECK: vld4.32 {d17, d19, d21, d23}, [r0]! @ encoding: [0x8d,0x11,0x60,0xf4] + + + vld1.8 {d16[3]}, [r0] + vld1.16 {d16[2]}, [r0, :16] + vld1.32 {d16[1]}, [r0, :32] @ CHECK: vld1.8 {d16[3]}, [r0] @ encoding: [0x6f,0x00,0xe0,0xf4] - vld1.8 {d16[3]}, [r0] -@ CHECK: vld1.16 {d16[2]}, [r0, :16] @ encoding: [0x9f,0x04,0xe0,0xf4] - vld1.16 {d16[2]}, [r0, :16] -@ CHECK: vld1.32 {d16[1]}, [r0, :32] @ encoding: [0xbf,0x08,0xe0,0xf4] - vld1.32 {d16[1]}, [r0, :32] +@ CHECK: vld1.16 {d16[2]}, [r0, :16] @ encoding: [0x9f,0x04,0xe0,0xf4] +@ CHECK: vld1.32 {d16[1]}, [r0, :32] @ encoding: [0xbf,0x08,0xe0,0xf4] + + + vld2.8 {d16[1], d17[1]}, [r0, :16] + vld2.16 {d16[1], d17[1]}, [r0, :32] + vld2.32 {d16[1], d17[1]}, [r0] + vld2.16 {d17[1], d19[1]}, [r0] + vld2.32 {d17[0], d19[0]}, [r0, :64] @ CHECK: vld2.8 {d16[1], d17[1]}, [r0, :16] @ encoding: [0x3f,0x01,0xe0,0xf4] - vld2.8 {d16[1], d17[1]}, [r0, :16] -@ CHECK: vld2.16 {d16[1], d17[1]}, [r0, :32] @ encoding: [0x5f,0x05,0xe0,0xf4] - vld2.16 {d16[1], d17[1]}, [r0, :32] -@ CHECK: vld2.32 {d16[1], d17[1]}, [r0] @ encoding: [0x8f,0x09,0xe0,0xf4] - vld2.32 {d16[1], d17[1]}, [r0] -@ CHECK: vld2.16 {d17[1], d19[1]}, [r0] @ encoding: [0x6f,0x15,0xe0,0xf4] - vld2.16 {d17[1], d19[1]}, [r0] -@ CHECK: vld2.32 {d17[0], d19[0]}, [r0, :64] @ encoding: [0x5f,0x19,0xe0,0xf4] - vld2.32 {d17[0], d19[0]}, [r0, :64] +@ CHECK: vld2.16 {d16[1], d17[1]}, [r0, :32] @ encoding: [0x5f,0x05,0xe0,0xf4] +@ CHECK: vld2.32 {d16[1], d17[1]}, [r0] @ encoding: [0x8f,0x09,0xe0,0xf4] +@ CHECK: vld2.16 {d17[1], d19[1]}, [r0] @ encoding: [0x6f,0x15,0xe0,0xf4] +@ CHECK: vld2.32 {d17[0], d19[0]}, [r0, :64] @ encoding: [0x5f,0x19,0xe0,0xf4] + + + vld3.8 {d16[1], d17[1], d18[1]}, [r0] + vld3.16 {d16[1], d17[1], d18[1]}, [r0] + vld3.32 {d16[1], d17[1], d18[1]}, [r0] + vld3.16 {d16[1], d18[1], d20[1]}, [r0] + vld3.32 {d17[1], d19[1], d21[1]}, [r0] @ CHECK: vld3.8 {d16[1], d17[1], d18[1]}, [r0] @ encoding: [0x2f,0x02,0xe0,0xf4] - vld3.8 {d16[1], d17[1], d18[1]}, [r0] -@ CHECK: vld3.16 {d16[1], d17[1], d18[1]}, [r0] @ encoding: [0x4f,0x06,0xe0,0xf4] - vld3.16 {d16[1], d17[1], d18[1]}, [r0] -@ CHECK: vld3.32 {d16[1], d17[1], d18[1]}, [r0] @ encoding: [0x8f,0x0a,0xe0,0xf4] - vld3.32 {d16[1], d17[1], d18[1]}, [r0] -@ CHECK: vld3.16 {d16[1], d18[1], d20[1]}, [r0] @ encoding: [0x6f,0x06,0xe0,0xf4] - vld3.16 {d16[1], d18[1], d20[1]}, [r0] -@ CHECK: vld3.32 {d17[1], d19[1], d21[1]}, [r0] @ encoding: [0xcf,0x1a,0xe0,0xf4] - vld3.32 {d17[1], d19[1], d21[1]}, [r0] +@ CHECK: vld3.16 {d16[1], d17[1], d18[1]}, [r0]@ encoding: [0x4f,0x06,0xe0,0xf4] +@ CHECK: vld3.32 {d16[1], d17[1], d18[1]}, [r0]@ encoding: [0x8f,0x0a,0xe0,0xf4] +@ CHECK: vld3.16 {d16[1], d18[1], d20[1]}, [r0]@ encoding: [0x6f,0x06,0xe0,0xf4] +@ CHECK: vld3.32 {d17[1], d19[1], d21[1]}, [r0]@ encoding: [0xcf,0x1a,0xe0,0xf4] + + + vld4.8 {d16[1], d17[1], d18[1], d19[1]}, [r0, :32] + vld4.16 {d16[1], d17[1], d18[1], d19[1]}, [r0] + vld4.32 {d16[1], d17[1], d18[1], d19[1]}, [r0, :128] + vld4.16 {d16[1], d18[1], d20[1], d22[1]}, [r0, :64] + vld4.32 {d17[0], d19[0], d21[0], d23[0]}, [r0] @ CHECK: vld4.8 {d16[1], d17[1], d18[1], d19[1]}, [r0, :32] @ encoding: [0x3f,0x03,0xe0,0xf4] - vld4.8 {d16[1], d17[1], d18[1], d19[1]}, [r0, :32] -@ CHECK: vld4.16 {d16[1], d17[1], d18[1], d19[1]}, [r0] @ encoding: [0x4f,0x07,0xe0,0xf4] - vld4.16 {d16[1], d17[1], d18[1], d19[1]}, [r0] -@ CHECK: vld4.32 {d16[1], d17[1], d18[1], d19[1]}, [r0, :128] @ encoding: [0xaf,0x0b,0xe0,0xf4] - vld4.32 {d16[1], d17[1], d18[1], d19[1]}, [r0, :128] -@ CHECK: vld4.16 {d16[1], d18[1], d20[1], d22[1]}, [r0, :64] @ encoding: [0x7f,0x07,0xe0,0xf4] - vld4.16 {d16[1], d18[1], d20[1], d22[1]}, [r0, :64] -@ CHECK: vld4.32 {d17[0], d19[0], d21[0], d23[0]}, [r0] @ encoding: [0x4f,0x1b,0xe0,0xf4] - vld4.32 {d17[0], d19[0], d21[0], d23[0]}, [r0] +@ CHECK: vld4.16 {d16[1], d17[1], d18[1], d19[1]}, [r0] @ encoding: [0x4f,0x07,0xe0,0xf4] +@ CHECK: vld4.32 {d16[1], d17[1], d18[1], d19[1]}, [r0, :128] @ encoding: [0xaf,0x0b,0xe0,0xf4] +@ CHECK: vld4.16 {d16[1], d18[1], d20[1], d22[1]}, [r0, :64] @ encoding: [0x7f,0x07,0xe0,0xf4] +@ CHECK: vld4.32 {d17[0], d19[0], d21[0], d23[0]}, [r0] @ encoding: [0x4f,0x1b,0xe0,0xf4] From stoklund at 2pi.dk Tue Oct 4 16:49:34 2011 From: stoklund at 2pi.dk (Jakob Stoklund Olesen) Date: Tue, 04 Oct 2011 21:49:34 -0000 Subject: [llvm-commits] [llvm] r141124 - in /llvm/trunk: include/llvm/CodeGen/MachineOperand.h lib/CodeGen/LiveIntervalAnalysis.cpp Message-ID: <20111004214934.ABB332A6C12C@llvm.org> Author: stoklund Date: Tue Oct 4 16:49:33 2011 New Revision: 141124 URL: http://llvm.org/viewvc/llvm-project?rev=141124&view=rev Log: Allow flags on def operands as well as uses. The flag says that a MachineOperand doesn't read its register, or doesn't depend on the previous value of its register. A full register def never depends on the previous register value. A partial register def may depend on the previous value if it is intended to update part of a register. For example: %vreg10:dsub_0 = COPY %vreg1 %vreg10:dsub_1 = COPY %vreg2 The first copy instruction defines the full %vreg10 register with the bits not covered by dsub_0 defined as . It is not considered a read of %vreg10. The second copy modifies part of %vreg10 while preserving the rest. It has an implicit read of %vreg10. This patch adds a MachineOperand::readsReg() method to determine if an operand reads its register. Previously, this was modelled by adding a full-register operand to the instruction. This approach makes it possible to determine directly from a MachineOperand if it reads its register. No scanning of MI operands is required. Modified: llvm/trunk/include/llvm/CodeGen/MachineOperand.h llvm/trunk/lib/CodeGen/LiveIntervalAnalysis.cpp Modified: llvm/trunk/include/llvm/CodeGen/MachineOperand.h URL: http://llvm.org/viewvc/llvm-project/llvm/trunk/include/llvm/CodeGen/MachineOperand.h?rev=141124&r1=141123&r2=141124&view=diff ============================================================================== --- llvm/trunk/include/llvm/CodeGen/MachineOperand.h (original) +++ llvm/trunk/include/llvm/CodeGen/MachineOperand.h Tue Oct 4 16:49:33 2011 @@ -83,8 +83,23 @@ /// This is only valid on definitions of registers. bool IsDead : 1; - /// IsUndef - True if this is a register def / use of "undef", i.e. register - /// defined by an IMPLICIT_DEF. This is only valid on registers. + /// IsUndef - True if this register operand reads an "undef" value, i.e. the + /// read value doesn't matter. This flag can be set on both use and def + /// operands. On a sub-register def operand, it refers to the part of the + /// register that isn't written. On a full-register def operand, it is a + /// noop. See readsReg(). + /// + /// This is only valid on registers. + /// + /// Note that an instruction may have multiple operands referring to + /// the same register. In that case, the instruction may depend on those + /// operands reading the same dont-care value. For example: + /// + /// %vreg1 = XOR %vreg2, %vreg2 + /// + /// Any register can be used for %vreg2, and its value doesn't matter, but + /// the two operands must be the same register. + /// bool IsUndef : 1; /// IsEarlyClobber - True if this MO_Register 'def' operand is written to @@ -253,6 +268,15 @@ return IsDebug; } + /// readsReg - Returns true if this operand reads the previous value of its + /// register. A use operand with the flag set doesn't read its + /// register. A sub-register def implicitly reads the other parts of the + /// register being redefined unless the flag is set. + bool readsReg() const { + assert(isReg() && "Wrong MachineOperand accessor"); + return !isUndef() && (isUse() || getSubReg()); + } + /// getNextOperandForReg - Return the next MachineOperand in the function that /// uses or defines this register. MachineOperand *getNextOperandForReg() const { Modified: llvm/trunk/lib/CodeGen/LiveIntervalAnalysis.cpp URL: http://llvm.org/viewvc/llvm-project/llvm/trunk/lib/CodeGen/LiveIntervalAnalysis.cpp?rev=141124&r1=141123&r2=141124&view=diff ============================================================================== --- llvm/trunk/lib/CodeGen/LiveIntervalAnalysis.cpp (original) +++ llvm/trunk/lib/CodeGen/LiveIntervalAnalysis.cpp Tue Oct 4 16:49:33 2011 @@ -304,8 +304,15 @@ // Make sure the first definition is not a partial redefinition. Add an // of the full register. - if (MO.getSubReg()) + if (MO.getSubReg()) { mi->addRegisterDefined(interval.reg); + // Mark all defs of interval.reg on this instruction as reading . + for (unsigned i = MOIdx, e = mi->getNumOperands(); i != e; ++i) { + MachineOperand &MO2 = mi->getOperand(i); + if (MO2.isReg() && MO2.getReg() == interval.reg && MO2.getSubReg()) + MO2.setIsUndef(); + } + } MachineInstr *CopyMI = NULL; if (mi->isCopyLike()) { From isanbard at gmail.com Tue Oct 4 17:00:36 2011 From: isanbard at gmail.com (Bill Wendling) Date: Tue, 04 Oct 2011 22:00:36 -0000 Subject: [llvm-commits] [llvm] r141125 - in /llvm/trunk/lib/CodeGen/SelectionDAG: SelectionDAGBuilder.cpp SelectionDAGBuilder.h Message-ID: <20111004220036.77EFE2A6C12C@llvm.org> Author: void Date: Tue Oct 4 17:00:35 2011 New Revision: 141125 URL: http://llvm.org/viewvc/llvm-project?rev=141125&view=rev Log: Create a mapping between the landing pad basic block and the call site index for later use. Modified: llvm/trunk/lib/CodeGen/SelectionDAG/SelectionDAGBuilder.cpp llvm/trunk/lib/CodeGen/SelectionDAG/SelectionDAGBuilder.h Modified: llvm/trunk/lib/CodeGen/SelectionDAG/SelectionDAGBuilder.cpp URL: http://llvm.org/viewvc/llvm-project/llvm/trunk/lib/CodeGen/SelectionDAG/SelectionDAGBuilder.cpp?rev=141125&r1=141124&r2=141125&view=diff ============================================================================== --- llvm/trunk/lib/CodeGen/SelectionDAG/SelectionDAGBuilder.cpp (original) +++ llvm/trunk/lib/CodeGen/SelectionDAG/SelectionDAGBuilder.cpp Tue Oct 4 17:00:35 2011 @@ -5250,6 +5250,8 @@ unsigned CallSiteIndex = MMI.getCurrentCallSite(); if (CallSiteIndex) { MMI.setCallSiteBeginLabel(BeginLabel, CallSiteIndex); + LPadToCallSiteMap[LandingPad] = CallSiteIndex; + // Now that the call site is handled, stop tracking it. MMI.setCurrentCallSite(0); } Modified: llvm/trunk/lib/CodeGen/SelectionDAG/SelectionDAGBuilder.h URL: http://llvm.org/viewvc/llvm-project/llvm/trunk/lib/CodeGen/SelectionDAG/SelectionDAGBuilder.h?rev=141125&r1=141124&r2=141125&view=diff ============================================================================== --- llvm/trunk/lib/CodeGen/SelectionDAG/SelectionDAGBuilder.h (original) +++ llvm/trunk/lib/CodeGen/SelectionDAG/SelectionDAGBuilder.h Tue Oct 4 17:00:35 2011 @@ -320,6 +320,9 @@ /// GFI - Garbage collection metadata for the function. GCFunctionInfo *GFI; + /// LPadToBeginLabelMap - Map a landing pad to the begin label. + DenseMap LPadToCallSiteMap; + /// HasTailCall - This is set to true if a call in the current /// block has been translated as a tail call. In this case, /// no subsequent DAG nodes should be created. From enderby at apple.com Tue Oct 4 17:44:49 2011 From: enderby at apple.com (Kevin Enderby) Date: Tue, 04 Oct 2011 22:44:49 -0000 Subject: [llvm-commits] [llvm] r141129 - in /llvm/trunk: include/llvm-c/Disassembler.h include/llvm/MC/MCDisassembler.h lib/MC/MCDisassembler/Disassembler.cpp lib/MC/MCInstPrinter.cpp lib/Target/ARM/ARMInstrInfo.td lib/Target/ARM/ARMInstrThumb2.td lib/Target/ARM/Disassembler/ARMDisassembler.cpp lib/Target/ARM/InstPrinter/ARMInstPrinter.cpp Message-ID: <20111004224449.67C18312800A@llvm.org> Author: enderby Date: Tue Oct 4 17:44:48 2011 New Revision: 141129 URL: http://llvm.org/viewvc/llvm-project?rev=141129&view=rev Log: Adding back support for printing operands symbolically to ARM's new disassembler using llvm's public 'C' disassembler API now including annotations. Hooked this up to Darwin's otool(1) so it can again print things like branch targets for example this: blx _puts instead of this: blx #-36 and includes support for annotations for branches to symbol stubs like: bl 0x40 @ symbol stub for: _puts and annotations for pc relative loads like this: ldr r3, #8 @ literal pool for: Hello, world! Also again can print the expression encoded in the Mach-O relocation entries for things like this: movt r0, :upper16:((_foo-_bar)+1234) Modified: llvm/trunk/include/llvm-c/Disassembler.h llvm/trunk/include/llvm/MC/MCDisassembler.h llvm/trunk/lib/MC/MCDisassembler/Disassembler.cpp llvm/trunk/lib/MC/MCInstPrinter.cpp llvm/trunk/lib/Target/ARM/ARMInstrInfo.td llvm/trunk/lib/Target/ARM/ARMInstrThumb2.td llvm/trunk/lib/Target/ARM/Disassembler/ARMDisassembler.cpp llvm/trunk/lib/Target/ARM/InstPrinter/ARMInstPrinter.cpp Modified: llvm/trunk/include/llvm-c/Disassembler.h URL: http://llvm.org/viewvc/llvm-project/llvm/trunk/include/llvm-c/Disassembler.h?rev=141129&r1=141128&r2=141129&view=diff ============================================================================== --- llvm/trunk/include/llvm-c/Disassembler.h (original) +++ llvm/trunk/include/llvm-c/Disassembler.h Tue Oct 4 17:44:48 2011 @@ -66,7 +66,7 @@ */ struct LLVMOpInfoSymbol1 { uint64_t Present; /* 1 if this symbol is present */ - char *Name; /* symbol name if not NULL */ + const char *Name; /* symbol name if not NULL */ uint64_t Value; /* symbol value if name is NULL */ }; @@ -93,11 +93,35 @@ * disassembler for things like adding a comment for a PC plus a constant * offset load instruction to use a symbol name instead of a load address value. * It is passed the block information is saved when the disassembler context is - * created and a value of a symbol to look up. If no symbol is found NULL is - * returned. + * created and the ReferenceValue to look up as a symbol. If no symbol is found + * for the ReferenceValue NULL is returned. The ReferenceType of the + * instruction is passed indirectly as is the PC of the instruction in + * ReferencePC. If the output reference can be determined its type is returned + * indirectly in ReferenceType along with ReferenceName if any, or that is set + * to NULL. */ typedef const char *(*LLVMSymbolLookupCallback)(void *DisInfo, - uint64_t SymbolValue); + uint64_t ReferenceValue, + uint64_t *ReferenceType, + uint64_t ReferencePC, + const char **ReferenceName); +/** + * The reference types on input and output. + */ +/* No input reference type or no output reference type. */ +#define LLVMDisassembler_ReferenceType_InOut_None 0 + +/* The input reference is from a branch instruction. */ +#define LLVMDisassembler_ReferenceType_In_Branch 1 +/* The input reference is from a PC relative load instruction. */ +#define LLVMDisassembler_ReferenceType_In_PCrel_Load 2 + +/* The output reference is to as symbol stub. */ +#define LLVMDisassembler_ReferenceType_Out_SymbolStub 1 +/* The output reference is to a symbol address in a literal pool. */ +#define LLVMDisassembler_ReferenceType_Out_LitPool_SymAddr 2 +/* The output reference is to a cstring address in a literal pool. */ +#define LLVMDisassembler_ReferenceType_Out_LitPool_CstrAddr 3 #ifdef __cplusplus extern "C" { Modified: llvm/trunk/include/llvm/MC/MCDisassembler.h URL: http://llvm.org/viewvc/llvm-project/llvm/trunk/include/llvm/MC/MCDisassembler.h?rev=141129&r1=141128&r2=141129&view=diff ============================================================================== --- llvm/trunk/include/llvm/MC/MCDisassembler.h (original) +++ llvm/trunk/include/llvm/MC/MCDisassembler.h Tue Oct 4 17:44:48 2011 @@ -55,7 +55,9 @@ }; /// Constructor - Performs initial setup for the disassembler. - MCDisassembler(const MCSubtargetInfo &STI) : GetOpInfo(0), DisInfo(0), Ctx(0), STI(STI) {} + MCDisassembler(const MCSubtargetInfo &STI) : GetOpInfo(0), SymbolLookUp(0), + DisInfo(0), Ctx(0), + STI(STI), CommentStream(0) {} virtual ~MCDisassembler(); @@ -96,6 +98,8 @@ // // The function to get the symbolic information for operands. LLVMOpInfoCallback GetOpInfo; + // The function to lookup a symbol name. + LLVMSymbolLookupCallback SymbolLookUp; // The pointer to the block of symbolic information for above call back. void *DisInfo; // The assembly context for creating symbols and MCExprs in place of @@ -107,15 +111,24 @@ public: void setupForSymbolicDisassembly(LLVMOpInfoCallback getOpInfo, + LLVMSymbolLookupCallback symbolLookUp, void *disInfo, MCContext *ctx) { GetOpInfo = getOpInfo; + SymbolLookUp = symbolLookUp; DisInfo = disInfo; Ctx = ctx; } LLVMOpInfoCallback getLLVMOpInfoCallback() const { return GetOpInfo; } + LLVMSymbolLookupCallback getLLVMSymbolLookupCallback() const { + return SymbolLookUp; + } void *getDisInfoBlock() const { return DisInfo; } MCContext *getMCContext() const { return Ctx; } + + // Marked mutable because we cache it inside the disassembler, rather than + // having to pass it around as an argument through all the autogenerated code. + mutable raw_ostream *CommentStream; }; } // namespace llvm Modified: llvm/trunk/lib/MC/MCDisassembler/Disassembler.cpp URL: http://llvm.org/viewvc/llvm-project/llvm/trunk/lib/MC/MCDisassembler/Disassembler.cpp?rev=141129&r1=141128&r2=141129&view=diff ============================================================================== --- llvm/trunk/lib/MC/MCDisassembler/Disassembler.cpp (original) +++ llvm/trunk/lib/MC/MCDisassembler/Disassembler.cpp Tue Oct 4 17:44:48 2011 @@ -68,7 +68,7 @@ // Set up disassembler. MCDisassembler *DisAsm = TheTarget->createMCDisassembler(*STI); assert(DisAsm && "Unable to create disassembler!"); - DisAsm->setupForSymbolicDisassembly(GetOpInfo, DisInfo, Ctx); + DisAsm->setupForSymbolicDisassembly(GetOpInfo, SymbolLookUp, DisInfo, Ctx); // Set up the instruction printer. int AsmPrinterVariant = MAI->getAssemblerDialect(); Modified: llvm/trunk/lib/MC/MCInstPrinter.cpp URL: http://llvm.org/viewvc/llvm-project/llvm/trunk/lib/MC/MCInstPrinter.cpp?rev=141129&r1=141128&r2=141129&view=diff ============================================================================== --- llvm/trunk/lib/MC/MCInstPrinter.cpp (original) +++ llvm/trunk/lib/MC/MCInstPrinter.cpp Tue Oct 4 17:44:48 2011 @@ -29,8 +29,8 @@ void MCInstPrinter::printAnnotation(raw_ostream &OS, StringRef Annot) { if (!Annot.empty()) { if (CommentStream) - (*CommentStream) << Annot << "\n"; + (*CommentStream) << Annot; else - OS << " " << MAI.getCommentString() << " " << Annot << "\n"; + OS << " " << MAI.getCommentString() << " " << Annot; } } Modified: llvm/trunk/lib/Target/ARM/ARMInstrInfo.td URL: http://llvm.org/viewvc/llvm-project/llvm/trunk/lib/Target/ARM/ARMInstrInfo.td?rev=141129&r1=141128&r2=141129&view=diff ============================================================================== --- llvm/trunk/lib/Target/ARM/ARMInstrInfo.td (original) +++ llvm/trunk/lib/Target/ARM/ARMInstrInfo.td Tue Oct 4 17:44:48 2011 @@ -2915,6 +2915,7 @@ let Inst{19-16} = imm{15-12}; let Inst{20} = 0; let Inst{25} = 1; + let DecoderMethod = "DecodeArmMOVTWInstruction"; } def : InstAlias<"mov${p} $Rd, $imm", @@ -2940,6 +2941,7 @@ let Inst{19-16} = imm{15-12}; let Inst{20} = 0; let Inst{25} = 1; + let DecoderMethod = "DecodeArmMOVTWInstruction"; } def MOVTi16_ga_pcrel : PseudoInst<(outs GPR:$Rd), Modified: llvm/trunk/lib/Target/ARM/ARMInstrThumb2.td URL: http://llvm.org/viewvc/llvm-project/llvm/trunk/lib/Target/ARM/ARMInstrThumb2.td?rev=141129&r1=141128&r2=141129&view=diff ============================================================================== --- llvm/trunk/lib/Target/ARM/ARMInstrThumb2.td (original) +++ llvm/trunk/lib/Target/ARM/ARMInstrThumb2.td Tue Oct 4 17:44:48 2011 @@ -1741,6 +1741,7 @@ let Inst{26} = imm{11}; let Inst{14-12} = imm{10-8}; let Inst{7-0} = imm{7-0}; + let DecoderMethod = "DecodeT2MOVTWInstruction"; } def t2MOVi16_ga_pcrel : PseudoInst<(outs rGPR:$Rd), @@ -1766,6 +1767,7 @@ let Inst{26} = imm{11}; let Inst{14-12} = imm{10-8}; let Inst{7-0} = imm{7-0}; + let DecoderMethod = "DecodeT2MOVTWInstruction"; } def t2MOVTi16_ga_pcrel : PseudoInst<(outs rGPR:$Rd), Modified: llvm/trunk/lib/Target/ARM/Disassembler/ARMDisassembler.cpp URL: http://llvm.org/viewvc/llvm-project/llvm/trunk/lib/Target/ARM/Disassembler/ARMDisassembler.cpp?rev=141129&r1=141128&r2=141129&view=diff ============================================================================== --- llvm/trunk/lib/Target/ARM/Disassembler/ARMDisassembler.cpp (original) +++ llvm/trunk/lib/Target/ARM/Disassembler/ARMDisassembler.cpp Tue Oct 4 17:44:48 2011 @@ -13,6 +13,7 @@ #include "ARMRegisterInfo.h" #include "ARMSubtarget.h" #include "MCTargetDesc/ARMAddressingModes.h" +#include "MCTargetDesc/ARMMCExpr.h" #include "MCTargetDesc/ARMBaseInfo.h" #include "llvm/MC/EDInstInfo.h" #include "llvm/MC/MCInst.h" @@ -160,6 +161,10 @@ unsigned Insn, uint64_t Adddress, const void *Decoder); +static DecodeStatus DecodeT2MOVTWInstruction(llvm::MCInst &Inst, unsigned Insn, + uint64_t Address, const void *Decoder); +static DecodeStatus DecodeArmMOVTWInstruction(llvm::MCInst &Inst, unsigned Insn, + uint64_t Address, const void *Decoder); static DecodeStatus DecodeSMLAInstruction(llvm::MCInst &Inst, unsigned Insn, uint64_t Address, const void *Decoder); static DecodeStatus DecodeCPSInstruction(llvm::MCInst &Inst, unsigned Insn, @@ -335,6 +340,8 @@ uint64_t Address, raw_ostream &os, raw_ostream &cs) const { + CommentStream = &cs; + uint8_t bytes[4]; assert(!(STI.getFeatureBits() & ARM::ModeThumb) && @@ -411,6 +418,146 @@ extern MCInstrDesc ARMInsts[]; } +/// tryAddingSymbolicOperand - trys to add a symbolic operand in place of the +/// immediate Value in the MCInst. The immediate Value has had any PC +/// adjustment made by the caller. If the instruction is a branch instruction +/// then isBranch is true, else false. If the getOpInfo() function was set as +/// part of the setupForSymbolicDisassembly() call then that function is called +/// to get any symbolic information at the Address for this instruction. If +/// that returns non-zero then the symbolic information it returns is used to +/// create an MCExpr and that is added as an operand to the MCInst. If +/// getOpInfo() returns zero and isBranch is true then a symbol look up for +/// Value is done and if a symbol is found an MCExpr is created with that, else +/// an MCExpr with Value is created. This function returns true if it adds an +/// operand to the MCInst and false otherwise. +static bool tryAddingSymbolicOperand(uint64_t Address, int32_t Value, + bool isBranch, uint64_t InstSize, + MCInst &MI, const void *Decoder) { + const MCDisassembler *Dis = static_cast(Decoder); + LLVMOpInfoCallback getOpInfo = Dis->getLLVMOpInfoCallback(); + if (!getOpInfo) + return false; + + struct LLVMOpInfo1 SymbolicOp; + SymbolicOp.Value = Value; + void *DisInfo = Dis->getDisInfoBlock(); + if (!getOpInfo(DisInfo, Address, 0 /* Offset */, InstSize, 1, &SymbolicOp)) { + if (isBranch) { + LLVMSymbolLookupCallback SymbolLookUp = + Dis->getLLVMSymbolLookupCallback(); + if (SymbolLookUp) { + uint64_t ReferenceType; + ReferenceType = LLVMDisassembler_ReferenceType_In_Branch; + const char *ReferenceName; + const char *Name = SymbolLookUp(DisInfo, Value, &ReferenceType, Address, + &ReferenceName); + if (Name) { + SymbolicOp.AddSymbol.Name = Name; + SymbolicOp.AddSymbol.Present = true; + SymbolicOp.Value = 0; + } + else { + SymbolicOp.Value = Value; + } + if(ReferenceType == LLVMDisassembler_ReferenceType_Out_SymbolStub) + (*Dis->CommentStream) << "symbol stub for: " << ReferenceName; + } + else { + return false; + } + } + else { + return false; + } + } + + MCContext *Ctx = Dis->getMCContext(); + const MCExpr *Add = NULL; + if (SymbolicOp.AddSymbol.Present) { + if (SymbolicOp.AddSymbol.Name) { + StringRef Name(SymbolicOp.AddSymbol.Name); + MCSymbol *Sym = Ctx->GetOrCreateSymbol(Name); + Add = MCSymbolRefExpr::Create(Sym, *Ctx); + } else { + Add = MCConstantExpr::Create(SymbolicOp.AddSymbol.Value, *Ctx); + } + } + + const MCExpr *Sub = NULL; + if (SymbolicOp.SubtractSymbol.Present) { + if (SymbolicOp.SubtractSymbol.Name) { + StringRef Name(SymbolicOp.SubtractSymbol.Name); + MCSymbol *Sym = Ctx->GetOrCreateSymbol(Name); + Sub = MCSymbolRefExpr::Create(Sym, *Ctx); + } else { + Sub = MCConstantExpr::Create(SymbolicOp.SubtractSymbol.Value, *Ctx); + } + } + + const MCExpr *Off = NULL; + if (SymbolicOp.Value != 0) + Off = MCConstantExpr::Create(SymbolicOp.Value, *Ctx); + + const MCExpr *Expr; + if (Sub) { + const MCExpr *LHS; + if (Add) + LHS = MCBinaryExpr::CreateSub(Add, Sub, *Ctx); + else + LHS = MCUnaryExpr::CreateMinus(Sub, *Ctx); + if (Off != 0) + Expr = MCBinaryExpr::CreateAdd(LHS, Off, *Ctx); + else + Expr = LHS; + } else if (Add) { + if (Off != 0) + Expr = MCBinaryExpr::CreateAdd(Add, Off, *Ctx); + else + Expr = Add; + } else { + if (Off != 0) + Expr = Off; + else + Expr = MCConstantExpr::Create(0, *Ctx); + } + + if (SymbolicOp.VariantKind == LLVMDisassembler_VariantKind_ARM_HI16) + MI.addOperand(MCOperand::CreateExpr(ARMMCExpr::CreateUpper16(Expr, *Ctx))); + else if (SymbolicOp.VariantKind == LLVMDisassembler_VariantKind_ARM_LO16) + MI.addOperand(MCOperand::CreateExpr(ARMMCExpr::CreateLower16(Expr, *Ctx))); + else if (SymbolicOp.VariantKind == LLVMDisassembler_VariantKind_None) + MI.addOperand(MCOperand::CreateExpr(Expr)); + else + assert("bad SymbolicOp.VariantKind"); + + return true; +} + +/// tryAddingPcLoadReferenceComment - trys to add a comment as to what is being +/// referenced by a load instruction with the base register that is the Pc. +/// These can often be values in a literal pool near the Address of the +/// instruction. The Address of the instruction and its immediate Value are +/// used as a possible literal pool entry. The SymbolLookUp call back will +/// return the name of a symbol referenced by the the literal pool's entry if +/// the referenced address is that of a symbol. Or it will return a pointer to +/// a literal 'C' string if the referenced address of the literal pool's entry +/// is an address into a section with 'C' string literals. +static void tryAddingPcLoadReferenceComment(uint64_t Address, int Value, + const void *Decoder) { + const MCDisassembler *Dis = static_cast(Decoder); + LLVMSymbolLookupCallback SymbolLookUp = Dis->getLLVMSymbolLookupCallback(); + if (SymbolLookUp) { + void *DisInfo = Dis->getDisInfoBlock(); + uint64_t ReferenceType; + ReferenceType = LLVMDisassembler_ReferenceType_In_PCrel_Load; + const char *ReferenceName; + (void)SymbolLookUp(DisInfo, Value, &ReferenceType, Address, &ReferenceName); + if(ReferenceType == LLVMDisassembler_ReferenceType_Out_LitPool_SymAddr || + ReferenceType == LLVMDisassembler_ReferenceType_Out_LitPool_CstrAddr) + (*Dis->CommentStream) << "literal pool for: " << ReferenceName; + } +} + // Thumb1 instructions don't have explicit S bits. Rather, they // implicitly set CPSR. Since it's not represented in the encoding, the // auto-generated decoder won't inject the CPSR operand. We need to fix @@ -542,6 +689,8 @@ uint64_t Address, raw_ostream &os, raw_ostream &cs) const { + CommentStream = &cs; + uint8_t bytes[4]; assert((STI.getFeatureBits() & ARM::ModeThumb) && @@ -1624,6 +1773,55 @@ return S; } +static DecodeStatus DecodeT2MOVTWInstruction(llvm::MCInst &Inst, unsigned Insn, + uint64_t Address, const void *Decoder) { + DecodeStatus S = MCDisassembler::Success; + + unsigned Rd = fieldFromInstruction32(Insn, 8, 4); + unsigned imm = 0; + + imm |= (fieldFromInstruction32(Insn, 0, 8) << 0); + imm |= (fieldFromInstruction32(Insn, 12, 3) << 8); + imm |= (fieldFromInstruction32(Insn, 16, 4) << 12); + imm |= (fieldFromInstruction32(Insn, 26, 1) << 11); + + if (Inst.getOpcode() == ARM::t2MOVTi16) + if (!Check(S, DecoderGPRRegisterClass(Inst, Rd, Address, Decoder))) + return MCDisassembler::Fail; + if (!Check(S, DecoderGPRRegisterClass(Inst, Rd, Address, Decoder))) + return MCDisassembler::Fail; + + if (!tryAddingSymbolicOperand(Address, imm, false, 4, Inst, Decoder)) + Inst.addOperand(MCOperand::CreateImm(imm)); + + return S; +} + +static DecodeStatus DecodeArmMOVTWInstruction(llvm::MCInst &Inst, unsigned Insn, + uint64_t Address, const void *Decoder) { + DecodeStatus S = MCDisassembler::Success; + + unsigned Rd = fieldFromInstruction32(Insn, 12, 4); + unsigned pred = fieldFromInstruction32(Insn, 28, 4); + unsigned imm = 0; + + imm |= (fieldFromInstruction32(Insn, 0, 12) << 0); + imm |= (fieldFromInstruction32(Insn, 16, 4) << 12); + + if (Inst.getOpcode() == ARM::MOVTi16) + if (!Check(S, DecoderGPRRegisterClass(Inst, Rd, Address, Decoder))) + return MCDisassembler::Fail; + if (!Check(S, DecoderGPRRegisterClass(Inst, Rd, Address, Decoder))) + return MCDisassembler::Fail; + + if (!tryAddingSymbolicOperand(Address, imm, false, 4, Inst, Decoder)) + Inst.addOperand(MCOperand::CreateImm(imm)); + + if (!Check(S, DecodePredicateOperand(Inst, pred, Address, Decoder))) + return MCDisassembler::Fail; + + return S; +} static DecodeStatus DecodeSMLAInstruction(llvm::MCInst &Inst, unsigned Insn, uint64_t Address, const void *Decoder) { @@ -1667,6 +1865,8 @@ if (!add) imm *= -1; if (imm == 0 && !add) imm = INT32_MIN; Inst.addOperand(MCOperand::CreateImm(imm)); + if (Rn == 15) + tryAddingPcLoadReferenceComment(Address, Address + imm + 8, Decoder); return S; } @@ -1710,7 +1910,9 @@ return S; } - Inst.addOperand(MCOperand::CreateImm(SignExtend32<26>(imm))); + if (!tryAddingSymbolicOperand(Address, Address + SignExtend32<26>(imm) + 8, true, + 4, Inst, Decoder)) + Inst.addOperand(MCOperand::CreateImm(SignExtend32<26>(imm))); if (!Check(S, DecodePredicateOperand(Inst, pred, Address, Decoder))) return MCDisassembler::Fail; @@ -2595,7 +2797,10 @@ static DecodeStatus DecodeThumbAddrModePC(llvm::MCInst &Inst, unsigned Val, uint64_t Address, const void *Decoder) { - Inst.addOperand(MCOperand::CreateImm(Val << 2)); + unsigned imm = Val << 2; + + Inst.addOperand(MCOperand::CreateImm(imm)); + tryAddingPcLoadReferenceComment(Address, (Address & ~2u) + imm + 4, Decoder); return MCDisassembler::Success; } @@ -2870,7 +3075,10 @@ static DecodeStatus DecodeThumbBLXOffset(llvm::MCInst &Inst, unsigned Val, uint64_t Address, const void *Decoder) { - Inst.addOperand(MCOperand::CreateImm(SignExtend32<22>(Val << 1))); + if (!tryAddingSymbolicOperand(Address, + (Address & ~2u) + SignExtend32<22>(Val << 1) + 4, + true, 4, Inst, Decoder)) + Inst.addOperand(MCOperand::CreateImm(SignExtend32<22>(Val << 1))); return MCDisassembler::Success; } Modified: llvm/trunk/lib/Target/ARM/InstPrinter/ARMInstPrinter.cpp URL: http://llvm.org/viewvc/llvm-project/llvm/trunk/lib/Target/ARM/InstPrinter/ARMInstPrinter.cpp?rev=141129&r1=141128&r2=141129&view=diff ============================================================================== --- llvm/trunk/lib/Target/ARM/InstPrinter/ARMInstPrinter.cpp (original) +++ llvm/trunk/lib/Target/ARM/InstPrinter/ARMInstPrinter.cpp Tue Oct 4 17:44:48 2011 @@ -207,7 +207,18 @@ O << '#' << Op.getImm(); } else { assert(Op.isExpr() && "unknown operand kind in printOperand"); - O << *Op.getExpr(); + // If a symbolic branch target was added as a constant expression then print + // that address in hex. + const MCConstantExpr *BranchTarget = dyn_cast(Op.getExpr()); + int64_t Address; + if (BranchTarget && BranchTarget->EvaluateAsAbsolute(Address)) { + O << "0x"; + O.write_hex(Address); + } + else { + // Otherwise, just print the expression. + O << *Op.getExpr(); + } } } From evan.cheng at apple.com Tue Oct 4 18:25:30 2011 From: evan.cheng at apple.com (Evan Cheng) Date: Tue, 04 Oct 2011 16:25:30 -0700 Subject: [llvm-commits] [llvm] r140863 - in /llvm/trunk: lib/Target/ARM/MCTargetDesc/ARMMCTargetDesc.cpp test/CodeGen/ARM/fast-isel.ll test/CodeGen/ARM/hidden-vis-2.ll test/CodeGen/ARM/hidden-vis-3.ll test/CodeGen/ARM/tail-opts.ll test/CodeGen/Thumb2/machine-licm.ll In-Reply-To: <64B540EC-DBFF-4E2F-8798-F0329460766B@apple.com> References: <20110930174137.A91E42A6C12C@llvm.org> <64B540EC-DBFF-4E2F-8798-F0329460766B@apple.com> Message-ID: <3F474F6D-AA3D-4493-8E7C-ABC37EB0174B@apple.com> I forgot it was already fixed. NM. Evan On Oct 3, 2011, at 3:48 PM, Jim Grosbach wrote: > It looks like x86_64 is already supposed to default to PIC. Are you seeing examples where that's not working? > > -Jim > > > On Oct 3, 2011, at 3:19 PM, Evan Cheng wrote: > >> Since you are making this change, can you fix x86_64 as well? >> >> Evan >> >> On Sep 30, 2011, at 10:41 AM, Jim Grosbach wrote: >> >>> Author: grosbach >>> Date: Fri Sep 30 12:41:35 2011 >>> New Revision: 140863 >>> >>> URL: http://llvm.org/viewvc/llvm-project?rev=140863&view=rev >>> Log: >>> ARM Darwin default relocation model is PIC. >>> >>> This matches clang, so default options in llc and friends are now closer to >>> clang's defaults. >>> >>> Modified: >>> llvm/trunk/lib/Target/ARM/MCTargetDesc/ARMMCTargetDesc.cpp >>> llvm/trunk/test/CodeGen/ARM/fast-isel.ll >>> llvm/trunk/test/CodeGen/ARM/hidden-vis-2.ll >>> llvm/trunk/test/CodeGen/ARM/hidden-vis-3.ll >>> llvm/trunk/test/CodeGen/ARM/tail-opts.ll >>> llvm/trunk/test/CodeGen/Thumb2/machine-licm.ll >>> >>> Modified: llvm/trunk/lib/Target/ARM/MCTargetDesc/ARMMCTargetDesc.cpp >>> URL: http://llvm.org/viewvc/llvm-project/llvm/trunk/lib/Target/ARM/MCTargetDesc/ARMMCTargetDesc.cpp?rev=140863&r1=140862&r2=140863&view=diff >>> ============================================================================== >>> --- llvm/trunk/lib/Target/ARM/MCTargetDesc/ARMMCTargetDesc.cpp (original) >>> +++ llvm/trunk/lib/Target/ARM/MCTargetDesc/ARMMCTargetDesc.cpp Fri Sep 30 12:41:35 2011 >>> @@ -139,8 +139,11 @@ >>> static MCCodeGenInfo *createARMMCCodeGenInfo(StringRef TT, Reloc::Model RM, >>> CodeModel::Model CM) { >>> MCCodeGenInfo *X = new MCCodeGenInfo(); >>> - if (RM == Reloc::Default) >>> - RM = Reloc::DynamicNoPIC; >>> + if (RM == Reloc::Default) { >>> + Triple TheTriple(TT); >>> + // Default relocation model on Darwin is PIC, not DynamicNoPIC. >>> + RM = TheTriple.isOSDarwin() ? Reloc::PIC_ : Reloc::DynamicNoPIC; >>> + } >>> X->InitMCCodeGenInfo(RM, CM); >>> return X; >>> } >>> >>> Modified: llvm/trunk/test/CodeGen/ARM/fast-isel.ll >>> URL: http://llvm.org/viewvc/llvm-project/llvm/trunk/test/CodeGen/ARM/fast-isel.ll?rev=140863&r1=140862&r2=140863&view=diff >>> ============================================================================== >>> --- llvm/trunk/test/CodeGen/ARM/fast-isel.ll (original) >>> +++ llvm/trunk/test/CodeGen/ARM/fast-isel.ll Fri Sep 30 12:41:35 2011 >>> @@ -1,5 +1,5 @@ >>> -; RUN: llc < %s -O0 -fast-isel-abort -mtriple=armv7-apple-darwin | FileCheck %s --check-prefix=ARM >>> -; RUN: llc < %s -O0 -fast-isel-abort -mtriple=thumbv7-apple-darwin | FileCheck %s --check-prefix=THUMB >>> +; RUN: llc < %s -O0 -fast-isel-abort -relocation-model=dynamic-no-pic -mtriple=armv7-apple-darwin | FileCheck %s --check-prefix=ARM >>> +; RUN: llc < %s -O0 -fast-isel-abort -relocation-model=dynamic-no-pic -mtriple=thumbv7-apple-darwin | FileCheck %s --check-prefix=THUMB >>> >>> ; Very basic fast-isel functionality. >>> define i32 @add(i32 %a, i32 %b) nounwind { >>> >>> Modified: llvm/trunk/test/CodeGen/ARM/hidden-vis-2.ll >>> URL: http://llvm.org/viewvc/llvm-project/llvm/trunk/test/CodeGen/ARM/hidden-vis-2.ll?rev=140863&r1=140862&r2=140863&view=diff >>> ============================================================================== >>> --- llvm/trunk/test/CodeGen/ARM/hidden-vis-2.ll (original) >>> +++ llvm/trunk/test/CodeGen/ARM/hidden-vis-2.ll Fri Sep 30 12:41:35 2011 >>> @@ -1,4 +1,4 @@ >>> -; RUN: llc < %s -mtriple=arm-apple-darwin | FileCheck %s >>> +; RUN: llc < %s -relocation-model=dynamic-no-pic -mtriple=arm-apple-darwin | FileCheck %s >>> >>> @x = weak hidden global i32 0 ; [#uses=1] >>> >>> >>> Modified: llvm/trunk/test/CodeGen/ARM/hidden-vis-3.ll >>> URL: http://llvm.org/viewvc/llvm-project/llvm/trunk/test/CodeGen/ARM/hidden-vis-3.ll?rev=140863&r1=140862&r2=140863&view=diff >>> ============================================================================== >>> --- llvm/trunk/test/CodeGen/ARM/hidden-vis-3.ll (original) >>> +++ llvm/trunk/test/CodeGen/ARM/hidden-vis-3.ll Fri Sep 30 12:41:35 2011 >>> @@ -1,4 +1,4 @@ >>> -; RUN: llc < %s -mtriple=arm-apple-darwin9 | FileCheck %s >>> +; RUN: llc < %s -relocation-model=dynamic-no-pic -mtriple=arm-apple-darwin9 | FileCheck %s >>> >>> @x = external hidden global i32 ; [#uses=1] >>> @y = extern_weak hidden global i32 ; [#uses=1] >>> >>> Modified: llvm/trunk/test/CodeGen/ARM/tail-opts.ll >>> URL: http://llvm.org/viewvc/llvm-project/llvm/trunk/test/CodeGen/ARM/tail-opts.ll?rev=140863&r1=140862&r2=140863&view=diff >>> ============================================================================== >>> --- llvm/trunk/test/CodeGen/ARM/tail-opts.ll (original) >>> +++ llvm/trunk/test/CodeGen/ARM/tail-opts.ll Fri Sep 30 12:41:35 2011 >>> @@ -1,4 +1,4 @@ >>> -; RUN: llc < %s -mtriple=arm-apple-darwin -mcpu=cortex-a8 -asm-verbose=false | FileCheck %s >>> +; RUN: llc < %s -mtriple=arm-apple-darwin -relocation-model=dynamic-no-pic -mcpu=cortex-a8 -asm-verbose=false | FileCheck %s >>> >>> declare void @bar(i32) >>> declare void @car(i32) >>> >>> Modified: llvm/trunk/test/CodeGen/Thumb2/machine-licm.ll >>> URL: http://llvm.org/viewvc/llvm-project/llvm/trunk/test/CodeGen/Thumb2/machine-licm.ll?rev=140863&r1=140862&r2=140863&view=diff >>> ============================================================================== >>> --- llvm/trunk/test/CodeGen/Thumb2/machine-licm.ll (original) >>> +++ llvm/trunk/test/CodeGen/Thumb2/machine-licm.ll Fri Sep 30 12:41:35 2011 >>> @@ -1,4 +1,4 @@ >>> -; RUN: llc < %s -mtriple=thumbv7-apple-darwin -mcpu=cortex-a8 -disable-fp-elim | FileCheck %s >>> +; RUN: llc < %s -mtriple=thumbv7-apple-darwin -mcpu=cortex-a8 -relocation-model=dynamic-no-pic -disable-fp-elim | FileCheck %s >>> ; RUN: llc < %s -mtriple=thumbv7-apple-darwin -mcpu=cortex-a8 -relocation-model=pic -disable-fp-elim | FileCheck %s --check-prefix=PIC >>> ; rdar://7353541 >>> ; rdar://7354376 >>> >>> >>> _______________________________________________ >>> llvm-commits mailing list >>> llvm-commits at cs.uiuc.edu >>> http://lists.cs.uiuc.edu/mailman/listinfo/llvm-commits >> > From resistor at mac.com Tue Oct 4 18:26:20 2011 From: resistor at mac.com (Owen Anderson) Date: Tue, 04 Oct 2011 23:26:20 -0000 Subject: [llvm-commits] [llvm] r141135 - in /llvm/trunk: include/llvm/MC/MCAsmInfo.h include/llvm/MC/MCStreamer.h lib/CodeGen/AsmPrinter/AsmPrinter.cpp lib/MC/MCAsmInfo.cpp lib/MC/MCAsmInfoCOFF.cpp lib/MC/MCAsmInfoDarwin.cpp lib/MC/MCStreamer.cpp lib/Target/ARM/ARMAsmPrinter.cpp lib/Target/X86/X86MCInstLower.cpp test/MC/ARM/elf-reloc-01.ll Message-ID: <20111004232620.77DEE312800A@llvm.org> Author: resistor Date: Tue Oct 4 18:26:17 2011 New Revision: 141135 URL: http://llvm.org/viewvc/llvm-project?rev=141135&view=rev Log: Teach the MC to output code/data region marker labels in MachO and ELF modes. These are used by disassemblers to provide better disassembly, particularly on targets like ARM Thumb that like to intermingle data in the TEXT segment. Modified: llvm/trunk/include/llvm/MC/MCAsmInfo.h llvm/trunk/include/llvm/MC/MCStreamer.h llvm/trunk/lib/CodeGen/AsmPrinter/AsmPrinter.cpp llvm/trunk/lib/MC/MCAsmInfo.cpp llvm/trunk/lib/MC/MCAsmInfoCOFF.cpp llvm/trunk/lib/MC/MCAsmInfoDarwin.cpp llvm/trunk/lib/MC/MCStreamer.cpp llvm/trunk/lib/Target/ARM/ARMAsmPrinter.cpp llvm/trunk/lib/Target/X86/X86MCInstLower.cpp llvm/trunk/test/MC/ARM/elf-reloc-01.ll Modified: llvm/trunk/include/llvm/MC/MCAsmInfo.h URL: http://llvm.org/viewvc/llvm-project/llvm/trunk/include/llvm/MC/MCAsmInfo.h?rev=141135&r1=141134&r2=141135&view=diff ============================================================================== --- llvm/trunk/include/llvm/MC/MCAsmInfo.h (original) +++ llvm/trunk/include/llvm/MC/MCAsmInfo.h Tue Oct 4 18:26:17 2011 @@ -177,6 +177,18 @@ const char *Data32bitsDirective; // Defaults to "\t.long\t" const char *Data64bitsDirective; // Defaults to "\t.quad\t" + /// [Data|Code]Begin - These magic labels are used to marked a region as + /// data or code, and are used to provide additional information for + /// correct disassembly on targets that like to mix data and code within + /// a segment. These labels will be implicitly suffixed by the streamer + /// to give them unique names. + const char *DataBegin; // Defaults to "$d." + const char *CodeBegin; // Defaults to "$a." + const char *JT8Begin; // Defaults to "$a." + const char *JT16Begin; // Defaults to "$a." + const char *JT32Begin; // Defaults to "$a." + bool SupportsDataRegions; + /// GPRel32Directive - if non-null, a directive that is used to emit a word /// which should be relocated as a 32-bit GP-relative offset, e.g. .gpword /// on Mips or .gprel32 on Alpha. @@ -371,6 +383,14 @@ } const char *getGPRel32Directive() const { return GPRel32Directive; } + /// [Code|Data]Begin label name accessors. + const char *getCodeBeginLabelName() const { return CodeBegin; } + const char *getDataBeginLabelName() const { return DataBegin; } + const char *getJumpTable8BeginLabelName() const { return JT8Begin; } + const char *getJumpTable16BeginLabelName() const { return JT16Begin; } + const char *getJumpTable32BeginLabelName() const { return JT32Begin; } + bool getSupportsDataRegions() const { return SupportsDataRegions; } + /// getNonexecutableStackSection - Targets can implement this method to /// specify a section to switch to if the translation unit doesn't have any /// trampolines that require an executable stack. Modified: llvm/trunk/include/llvm/MC/MCStreamer.h URL: http://llvm.org/viewvc/llvm-project/llvm/trunk/include/llvm/MC/MCStreamer.h?rev=141135&r1=141134&r2=141135&view=diff ============================================================================== --- llvm/trunk/include/llvm/MC/MCStreamer.h (original) +++ llvm/trunk/include/llvm/MC/MCStreamer.h Tue Oct 4 18:26:17 2011 @@ -71,7 +71,22 @@ SmallVector, 4> SectionStack; + unsigned UniqueCodeBeginSuffix; + unsigned UniqueDataBeginSuffix; + protected: + /// Indicator of whether the previous data-or-code indicator was for + /// code or not. Used to determine when we need to emit a new indicator. + enum DataType { + Data, + Code, + JumpTable8, + JumpTable16, + JumpTable32 + }; + DataType RegionIndicator; + + MCStreamer(MCContext &Ctx); const MCExpr *BuildSymbolDiff(MCContext &Context, const MCSymbol *A, @@ -224,6 +239,41 @@ /// used in an assignment. virtual void EmitLabel(MCSymbol *Symbol); + /// EmitDataRegion - Emit a label that marks the beginning of a data + /// region. + /// On ELF targets, this corresponds to an assembler statement such as: + /// $d.1: + virtual void EmitDataRegion(); + + /// EmitJumpTable8Region - Emit a label that marks the beginning of a + /// jump table composed of 8-bit offsets. + /// On ELF targets, this corresponds to an assembler statement such as: + /// $d.1: + virtual void EmitJumpTable8Region(); + + /// EmitJumpTable16Region - Emit a label that marks the beginning of a + /// jump table composed of 16-bit offsets. + /// On ELF targets, this corresponds to an assembler statement such as: + /// $d.1: + virtual void EmitJumpTable16Region(); + + /// EmitJumpTable32Region - Emit a label that marks the beginning of a + /// jump table composed of 32-bit offsets. + /// On ELF targets, this corresponds to an assembler statement such as: + /// $d.1: + virtual void EmitJumpTable32Region(); + + /// EmitCodeRegion - Emit a label that marks the beginning of a code + /// region. + /// On ELF targets, this corresponds to an assembler statement such as: + /// $a.1: + virtual void EmitCodeRegion(); + + /// ForceCodeRegion - Forcibly sets the current region mode to code. Used + /// at function entry points. + void ForceCodeRegion() { RegionIndicator = Code; } + + virtual void EmitEHSymAttributes(const MCSymbol *Symbol, MCSymbol *EHSymbol); Modified: llvm/trunk/lib/CodeGen/AsmPrinter/AsmPrinter.cpp URL: http://llvm.org/viewvc/llvm-project/llvm/trunk/lib/CodeGen/AsmPrinter/AsmPrinter.cpp?rev=141135&r1=141134&r2=141135&view=diff ============================================================================== --- llvm/trunk/lib/CodeGen/AsmPrinter/AsmPrinter.cpp (original) +++ llvm/trunk/lib/CodeGen/AsmPrinter/AsmPrinter.cpp Tue Oct 4 18:26:17 2011 @@ -474,8 +474,10 @@ void AsmPrinter::EmitFunctionEntryLabel() { // The function label could have already been emitted if two symbols end up // conflicting due to asm renaming. Detect this and emit an error. - if (CurrentFnSym->isUndefined()) + if (CurrentFnSym->isUndefined()) { + OutStreamer.ForceCodeRegion(); return OutStreamer.EmitLabel(CurrentFnSym); + } report_fatal_error("'" + Twine(CurrentFnSym->getName()) + "' label emitted multiple times to assembly file"); @@ -1058,6 +1060,15 @@ EmitAlignment(Log2_32(MJTI->getEntryAlignment(*TM.getTargetData()))); + // If we know the form of the jump table, go ahead and tag it as such. + if (!JTInDiffSection) { + if (MJTI->getEntryKind() == MachineJumpTableInfo::EK_LabelDifference32) { + OutStreamer.EmitJumpTable32Region(); + } else { + OutStreamer.EmitDataRegion(); + } + } + for (unsigned JTI = 0, e = JT.size(); JTI != e; ++JTI) { const std::vector &JTBBs = JT[JTI].MBBs; Modified: llvm/trunk/lib/MC/MCAsmInfo.cpp URL: http://llvm.org/viewvc/llvm-project/llvm/trunk/lib/MC/MCAsmInfo.cpp?rev=141135&r1=141134&r2=141135&view=diff ============================================================================== --- llvm/trunk/lib/MC/MCAsmInfo.cpp (original) +++ llvm/trunk/lib/MC/MCAsmInfo.cpp Tue Oct 4 18:26:17 2011 @@ -57,6 +57,12 @@ Data16bitsDirective = "\t.short\t"; Data32bitsDirective = "\t.long\t"; Data64bitsDirective = "\t.quad\t"; + DataBegin = "$d."; + CodeBegin = "$a."; + JT8Begin = "$d."; + JT16Begin = "$d."; + JT32Begin = "$d."; + SupportsDataRegions = true; SunStyleELFSectionSwitchSyntax = false; UsesELFSectionDirectiveForBSS = false; AlignDirective = "\t.align\t"; Modified: llvm/trunk/lib/MC/MCAsmInfoCOFF.cpp URL: http://llvm.org/viewvc/llvm-project/llvm/trunk/lib/MC/MCAsmInfoCOFF.cpp?rev=141135&r1=141134&r2=141135&view=diff ============================================================================== --- llvm/trunk/lib/MC/MCAsmInfoCOFF.cpp (original) +++ llvm/trunk/lib/MC/MCAsmInfoCOFF.cpp Tue Oct 4 18:26:17 2011 @@ -35,4 +35,6 @@ SupportsDebugInformation = true; DwarfSectionOffsetDirective = "\t.secrel32\t"; HasMicrosoftFastStdCallMangling = true; + + SupportsDataRegions = false; } Modified: llvm/trunk/lib/MC/MCAsmInfoDarwin.cpp URL: http://llvm.org/viewvc/llvm-project/llvm/trunk/lib/MC/MCAsmInfoDarwin.cpp?rev=141135&r1=141134&r2=141135&view=diff ============================================================================== --- llvm/trunk/lib/MC/MCAsmInfoDarwin.cpp (original) +++ llvm/trunk/lib/MC/MCAsmInfoDarwin.cpp Tue Oct 4 18:26:17 2011 @@ -42,6 +42,13 @@ StructorOutputOrder = Structors::PriorityOrder; HasStaticCtorDtorReferenceInStaticMode = true; + CodeBegin = "L$start$code$"; + DataBegin = "L$start$data$"; + JT8Begin = "L$start$jt8$"; + JT16Begin = "L$start$jt16$"; + JT32Begin = "L$start$jt32$"; + SupportsDataRegions = true; + // FIXME: Darwin 10 and newer don't need this. LinkerRequiresNonEmptyDwarfLines = true; Modified: llvm/trunk/lib/MC/MCStreamer.cpp URL: http://llvm.org/viewvc/llvm-project/llvm/trunk/lib/MC/MCStreamer.cpp?rev=141135&r1=141134&r2=141135&view=diff ============================================================================== --- llvm/trunk/lib/MC/MCStreamer.cpp (original) +++ llvm/trunk/lib/MC/MCStreamer.cpp Tue Oct 4 18:26:17 2011 @@ -16,6 +16,7 @@ #include "llvm/Support/ErrorHandling.h" #include "llvm/Support/raw_ostream.h" #include "llvm/ADT/SmallString.h" +#include "llvm/ADT/StringExtras.h" #include "llvm/ADT/Twine.h" #include using namespace llvm; @@ -23,7 +24,9 @@ MCStreamer::MCStreamer(MCContext &Ctx) : Context(Ctx), EmitEHFrame(true), EmitDebugFrame(false), CurrentW64UnwindInfo(0), - LastSymbol(0) { + LastSymbol(0), + UniqueCodeBeginSuffix(0), + UniqueDataBeginSuffix(0) { const MCSection *section = NULL; SectionStack.push_back(std::make_pair(section, section)); } @@ -175,6 +178,87 @@ LastSymbol = Symbol; } +void MCStreamer::EmitDataRegion() { + if (RegionIndicator == Data) return; + + MCContext &Context = getContext(); + const MCAsmInfo &MAI = Context.getAsmInfo(); + if (!MAI.getSupportsDataRegions()) return; + + // Generate a unique symbol name. + MCSymbol *NewSym = Context.GetOrCreateSymbol( + Twine(MAI.getDataBeginLabelName()) + + utostr(UniqueDataBeginSuffix++)); + EmitLabel(NewSym); + + RegionIndicator = Data; +} + +void MCStreamer::EmitCodeRegion() { + if (RegionIndicator == Code) return; + + MCContext &Context = getContext(); + const MCAsmInfo &MAI = Context.getAsmInfo(); + if (!MAI.getSupportsDataRegions()) return; + + // Generate a unique symbol name. + MCSymbol *NewSym = Context.GetOrCreateSymbol( + Twine(MAI.getCodeBeginLabelName()) + + utostr(UniqueCodeBeginSuffix++)); + EmitLabel(NewSym); + + RegionIndicator = Code; +} + +void MCStreamer::EmitJumpTable8Region() { + if (RegionIndicator == JumpTable8) return; + + MCContext &Context = getContext(); + const MCAsmInfo &MAI = Context.getAsmInfo(); + if (!MAI.getSupportsDataRegions()) return; + + // Generate a unique symbol name. + MCSymbol *NewSym = Context.GetOrCreateSymbol( + Twine(MAI.getJumpTable8BeginLabelName()) + + utostr(UniqueDataBeginSuffix++)); + EmitLabel(NewSym); + + RegionIndicator = JumpTable8; +} + +void MCStreamer::EmitJumpTable16Region() { + if (RegionIndicator == JumpTable16) return; + + MCContext &Context = getContext(); + const MCAsmInfo &MAI = Context.getAsmInfo(); + if (!MAI.getSupportsDataRegions()) return; + + // Generate a unique symbol name. + MCSymbol *NewSym = Context.GetOrCreateSymbol( + Twine(MAI.getJumpTable16BeginLabelName()) + + utostr(UniqueDataBeginSuffix++)); + EmitLabel(NewSym); + + RegionIndicator = JumpTable16; +} + + +void MCStreamer::EmitJumpTable32Region() { + if (RegionIndicator == JumpTable32) return; + + MCContext &Context = getContext(); + const MCAsmInfo &MAI = Context.getAsmInfo(); + if (!MAI.getSupportsDataRegions()) return; + + // Generate a unique symbol name. + MCSymbol *NewSym = Context.GetOrCreateSymbol( + Twine(MAI.getJumpTable32BeginLabelName()) + + utostr(UniqueDataBeginSuffix++)); + EmitLabel(NewSym); + + RegionIndicator = JumpTable32; +} + void MCStreamer::EmitCompactUnwindEncoding(uint32_t CompactUnwindEncoding) { EnsureValidFrame(); MCDwarfFrameInfo *CurFrame = getCurrentFrameInfo(); @@ -206,6 +290,7 @@ } FrameInfos.push_back(Frame); + RegionIndicator = Code; } void MCStreamer::EmitCFIEndProc() { Modified: llvm/trunk/lib/Target/ARM/ARMAsmPrinter.cpp URL: http://llvm.org/viewvc/llvm-project/llvm/trunk/lib/Target/ARM/ARMAsmPrinter.cpp?rev=141135&r1=141134&r2=141135&view=diff ============================================================================== --- llvm/trunk/lib/Target/ARM/ARMAsmPrinter.cpp (original) +++ llvm/trunk/lib/Target/ARM/ARMAsmPrinter.cpp Tue Oct 4 18:26:17 2011 @@ -290,6 +290,8 @@ } void ARMAsmPrinter::EmitFunctionEntryLabel() { + OutStreamer.ForceCodeRegion(); + if (AFI->isThumbFunction()) { OutStreamer.EmitAssemblerFlag(MCAF_Code16); OutStreamer.EmitThumbFunc(CurrentFnSym); @@ -905,6 +907,9 @@ const MachineOperand &MO2 = MI->getOperand(OpNum+1); // Unique Id unsigned JTI = MO1.getIndex(); + // Tag the jump table appropriately for precise disassembly. + OutStreamer.EmitJumpTable32Region(); + // Emit a label for the jump table. MCSymbol *JTISymbol = GetARMJTIPICJumpTableLabel2(JTI, MO2.getImm()); OutStreamer.EmitLabel(JTISymbol); @@ -947,6 +952,14 @@ unsigned JTI = MO1.getIndex(); // Emit a label for the jump table. + if (MI->getOpcode() == ARM::t2TBB_JT) { + OutStreamer.EmitJumpTable8Region(); + } else if (MI->getOpcode() == ARM::t2TBH_JT) { + OutStreamer.EmitJumpTable16Region(); + } else { + OutStreamer.EmitJumpTable32Region(); + } + MCSymbol *JTISymbol = GetARMJTIPICJumpTableLabel2(JTI, MO2.getImm()); OutStreamer.EmitLabel(JTISymbol); @@ -1165,6 +1178,9 @@ #include "ARMGenMCPseudoLowering.inc" void ARMAsmPrinter::EmitInstruction(const MachineInstr *MI) { + if (MI->getOpcode() != ARM::CONSTPOOL_ENTRY) + OutStreamer.EmitCodeRegion(); + // Emit unwinding stuff for frame-related instructions if (EnableARMEHABI && MI->getFlag(MachineInstr::FrameSetup)) EmitUnwindingInstruction(MI); @@ -1470,6 +1486,10 @@ unsigned CPIdx = (unsigned)MI->getOperand(1).getIndex(); EmitAlignment(2); + + // Mark the constant pool entry as data if we're not already in a data + // region. + OutStreamer.EmitDataRegion(); OutStreamer.EmitLabel(GetCPISymbol(LabelId)); const MachineConstantPoolEntry &MCPE = MCP->getConstants()[CPIdx]; @@ -1477,7 +1497,6 @@ EmitMachineConstantPoolValue(MCPE.Val.MachineCPVal); else EmitGlobalConstant(MCPE.Val.ConstVal); - return; } case ARM::t2BR_JT: { Modified: llvm/trunk/lib/Target/X86/X86MCInstLower.cpp URL: http://llvm.org/viewvc/llvm-project/llvm/trunk/lib/Target/X86/X86MCInstLower.cpp?rev=141135&r1=141134&r2=141135&view=diff ============================================================================== --- llvm/trunk/lib/Target/X86/X86MCInstLower.cpp (original) +++ llvm/trunk/lib/Target/X86/X86MCInstLower.cpp Tue Oct 4 18:26:17 2011 @@ -592,6 +592,8 @@ } void X86AsmPrinter::EmitInstruction(const MachineInstr *MI) { + OutStreamer.EmitCodeRegion(); + X86MCInstLower MCInstLowering(Mang, *MF, *this); switch (MI->getOpcode()) { case TargetOpcode::DBG_VALUE: @@ -608,7 +610,7 @@ if (OutStreamer.hasRawTextSupport()) OutStreamer.EmitRawText(StringRef("\t#MEMBARRIER")); return; - + case X86::EH_RETURN: case X86::EH_RETURN64: { Modified: llvm/trunk/test/MC/ARM/elf-reloc-01.ll URL: http://llvm.org/viewvc/llvm-project/llvm/trunk/test/MC/ARM/elf-reloc-01.ll?rev=141135&r1=141134&r2=141135&view=diff ============================================================================== --- llvm/trunk/test/MC/ARM/elf-reloc-01.ll (original) +++ llvm/trunk/test/MC/ARM/elf-reloc-01.ll Tue Oct 4 18:26:17 2011 @@ -62,9 +62,9 @@ ;; OBJ: Relocation 1 ;; OBJ-NEXT: 'r_offset', -;; OBJ-NEXT: 'r_sym', 0x000002 +;; OBJ-NEXT: 'r_sym', 0x000003 ;; OBJ-NEXT: 'r_type', 0x2b -;; OBJ: Symbol 2 +;; OBJ: Symbol 3 ;; OBJ-NEXT: '_MergedGlobals' ;; OBJ-NEXT: 'st_value', 0x00000010 From stoklund at 2pi.dk Tue Oct 4 19:01:46 2011 From: stoklund at 2pi.dk (Jakob Stoklund Olesen) Date: Wed, 05 Oct 2011 00:01:46 -0000 Subject: [llvm-commits] [llvm] r141138 - /llvm/trunk/lib/CodeGen/RegisterCoalescer.cpp Message-ID: <20111005000146.5E0752A6C12C@llvm.org> Author: stoklund Date: Tue Oct 4 19:01:46 2011 New Revision: 141138 URL: http://llvm.org/viewvc/llvm-project?rev=141138&view=rev Log: Also add flags when coalescing sub-registers. RegisterCoalescer can create sub-register defs when it is joining a register with a sub-register. Add flags to these new sub-register defs where appropriate. Modified: llvm/trunk/lib/CodeGen/RegisterCoalescer.cpp Modified: llvm/trunk/lib/CodeGen/RegisterCoalescer.cpp URL: http://llvm.org/viewvc/llvm-project/llvm/trunk/lib/CodeGen/RegisterCoalescer.cpp?rev=141138&r1=141137&r2=141138&view=diff ============================================================================== --- llvm/trunk/lib/CodeGen/RegisterCoalescer.cpp (original) +++ llvm/trunk/lib/CodeGen/RegisterCoalescer.cpp Tue Oct 4 19:01:46 2011 @@ -967,6 +967,14 @@ Kills |= MO.isKill(); Deads |= MO.isDead(); + // Make sure we don't create read-modify-write defs accidentally. We + // assume here that a SrcReg def cannot be joined into a live DstReg. If + // RegisterCoalescer starts tracking partially live registers, we will + // need to check the actual LiveInterval to determine if DstReg is live + // here. + if (SubIdx && !Reads) + MO.setIsUndef(); + if (DstIsPhys) MO.substPhysReg(DstReg, *TRI); else From stoklund at 2pi.dk Tue Oct 4 19:01:49 2011 From: stoklund at 2pi.dk (Jakob Stoklund Olesen) Date: Wed, 05 Oct 2011 00:01:49 -0000 Subject: [llvm-commits] [llvm] r141139 - /llvm/trunk/lib/CodeGen/VirtRegMap.cpp Message-ID: <20111005000149.2A2312A6C12C@llvm.org> Author: stoklund Date: Tue Oct 4 19:01:48 2011 New Revision: 141139 URL: http://llvm.org/viewvc/llvm-project?rev=141139&view=rev Log: Also add flags for redefined super-registers. For example: %vreg10:dsub_0 = COPY %vreg1 %vreg10:dsub_1 = COPY %vreg2 is rewritten as: %D2 = COPY %D0, %Q1 %D3 = COPY %D1, %Q1, %Q1 The first COPY doesn't care about the previous value of %Q1, so it doesn't read that register. The second COPY is a partial redefinition of %Q1, so it implicitly kills and redefines that register. This makes it possible to recognize instructions that can harmlessly clobber the full super-register. The write and don't read the super-register. Modified: llvm/trunk/lib/CodeGen/VirtRegMap.cpp Modified: llvm/trunk/lib/CodeGen/VirtRegMap.cpp URL: http://llvm.org/viewvc/llvm-project/llvm/trunk/lib/CodeGen/VirtRegMap.cpp?rev=141139&r1=141138&r2=141139&view=diff ============================================================================== --- llvm/trunk/lib/CodeGen/VirtRegMap.cpp (original) +++ llvm/trunk/lib/CodeGen/VirtRegMap.cpp Tue Oct 4 19:01:48 2011 @@ -285,14 +285,24 @@ // Preserve semantics of sub-register operands. if (MO.getSubReg()) { // A virtual register kill refers to the whole register, so we may - // have to add operands for the super-register. - if (MO.isUse()) { - if (MO.isKill() && !MO.isUndef()) - SuperKills.push_back(PhysReg); - } else if (MO.isDead()) - SuperDeads.push_back(PhysReg); - else - SuperDefs.push_back(PhysReg); + // have to add operands for the super-register. A + // partial redef always kills and redefines the super-register. + if (MO.readsReg() && (MO.isDef() || MO.isKill())) + SuperKills.push_back(PhysReg); + + if (MO.isDef()) { + // The flag only makes sense for sub-register defs, and + // we are substituting a full physreg. An operand + // from the SuperKills list will represent the partial read of the + // super-register. + MO.setIsUndef(false); + + // Also add implicit defs for the super-register. + if (MO.isDead()) + SuperDeads.push_back(PhysReg); + else + SuperDefs.push_back(PhysReg); + } // PhysReg operands cannot have subregister indexes. PhysReg = TRI->getSubReg(PhysReg, MO.getSubReg()); From isanbard at gmail.com Tue Oct 4 19:02:33 2011 From: isanbard at gmail.com (Bill Wendling) Date: Wed, 05 Oct 2011 00:02:33 -0000 Subject: [llvm-commits] [llvm] r141140 - /llvm/trunk/lib/Target/ARM/ARMISelLowering.cpp Message-ID: <20111005000233.C8D042A6C12C@llvm.org> Author: void Date: Tue Oct 4 19:02:33 2011 New Revision: 141140 URL: http://llvm.org/viewvc/llvm-project?rev=141140&view=rev Log: Checkpoint for SJLJ EH code. This is a first pass at generating the jump table for the sjlj dispatch. It currently generates something plausible, but hasn't been tested thoroughly. Modified: llvm/trunk/lib/Target/ARM/ARMISelLowering.cpp Modified: llvm/trunk/lib/Target/ARM/ARMISelLowering.cpp URL: http://llvm.org/viewvc/llvm-project/llvm/trunk/lib/Target/ARM/ARMISelLowering.cpp?rev=141140&r1=141139&r2=141140&view=diff ============================================================================== --- llvm/trunk/lib/Target/ARM/ARMISelLowering.cpp (original) +++ llvm/trunk/lib/Target/ARM/ARMISelLowering.cpp Tue Oct 4 19:02:33 2011 @@ -38,6 +38,7 @@ #include "llvm/CodeGen/MachineFrameInfo.h" #include "llvm/CodeGen/MachineFunction.h" #include "llvm/CodeGen/MachineInstrBuilder.h" +#include "llvm/CodeGen/MachineModuleInfo.h" #include "llvm/CodeGen/MachineRegisterInfo.h" #include "llvm/CodeGen/PseudoSourceValue.h" #include "llvm/CodeGen/SelectionDAG.h" @@ -5502,8 +5503,6 @@ DispatchBB->setIsLandingPad(); MBB->addSuccessor(DispatchBB); - BuildMI(DispatchBB, dl, TII->get(ARM::TRAP)); - bool isThumb = Subtarget->isThumb(); bool isThumb2 = Subtarget->isThumb2(); unsigned PCLabelId = AFI->createPICLabelUId(); @@ -5525,6 +5524,10 @@ // Load the address of the dispatch MBB into the jump buffer. if (isThumb2) { + // Incoming value: jbuf + // ldr.n r1, LCPI1_4 + // add r1, pc + // str r5, [$jbuf, #+4] ; &jbuf[1] unsigned NewVReg1 = MRI->createVirtualRegister(TRC); AddDefaultPred(BuildMI(*MBB, MI, dl, TII->get(ARM::t2LDRpci), NewVReg1) .addConstantPoolIndex(CPI) @@ -5542,7 +5545,7 @@ // Incoming value: jbuf // ldr.n r1, LCPI1_4 // add r1, pc - // add r2, sp, #48 ; &jbuf[1] + // add r2, $jbuf, #+4 ; &jbuf[1] // str r1, [r2] unsigned NewVReg1 = MRI->createVirtualRegister(TRC); AddDefaultPred(BuildMI(*MBB, MI, dl, TII->get(ARM::tLDRpci), NewVReg1) @@ -5584,6 +5587,75 @@ MI->eraseFromParent(); // The instruction is gone now. + // Now get a mapping of the call site numbers to all of the landing pads + // they're associated with. + DenseMap > CallSiteNumToLPad; + unsigned MaxCSNum = 0; + MachineModuleInfo &MMI = MF->getMMI(); + for (MachineFunction::iterator BB = MF->begin(), E = MF->end(); BB != E; ++BB) { + if (!BB->isLandingPad()) continue; + + // FIXME: We should assert that the EH_LABEL is the first MI in the landing + // pad. + for (MachineBasicBlock::iterator + II = BB->begin(), IE = BB->end(); II != IE; ++II) { + if (!II->isEHLabel()) continue; + + MCSymbol *Sym = II->getOperand(0).getMCSymbol(); + if (!MMI.hasCallSiteBeginLabel(Sym)) continue; + + unsigned CallSiteNum = MMI.getCallSiteBeginLabel(Sym); + CallSiteNumToLPad[CallSiteNum].push_back(BB); + MaxCSNum = std::max(MaxCSNum, CallSiteNum); + break; + } + } + + // Get an ordered list of the machine basic blocks for the jump table. + std::vector LPadList; + LPadList.reserve(CallSiteNumToLPad.size()); + for (unsigned I = 1; I <= MaxCSNum; ++I) { + SmallVectorImpl &MBBList = CallSiteNumToLPad[I]; + for (SmallVectorImpl::iterator + II = MBBList.begin(), IE = MBBList.end(); II != IE; ++II) { + LPadList.push_back(*II); + DispatchBB->addSuccessor(*II); + } + } + + MachineJumpTableInfo *JTI = + MF->getOrCreateJumpTableInfo(MachineJumpTableInfo::EK_Inline); + unsigned MJTI = JTI->createJumpTableIndex(LPadList); + unsigned UId = AFI->createJumpTableUId(); + + FIMMO = MF->getMachineMemOperand(MachinePointerInfo::getFixedStack(FI), + MachineMemOperand::MOLoad, 4, 4); + + unsigned NewVReg1 = MRI->createVirtualRegister(TRC); + AddDefaultPred(BuildMI(DispatchBB, dl, TII->get(ARM::t2LDRi12), NewVReg1) + .addFrameIndex(FI) + .addImm(4) + .addMemOperand(FIMMO)); + + unsigned NewVReg2 = MRI->createVirtualRegister(TRC); + AddDefaultPred(BuildMI(DispatchBB, dl, TII->get(ARM::t2LEApcrelJT), NewVReg2) + .addJumpTableIndex(MJTI) + .addImm(UId)); + + unsigned NewVReg3 = MRI->createVirtualRegister(TRC); + AddDefaultCC( + AddDefaultPred( + BuildMI(DispatchBB, dl, TII->get(ARM::t2ADDrs), NewVReg3) + .addReg(NewVReg2, RegState::Kill) + .addReg(NewVReg1) + .addImm(18))); + + BuildMI(DispatchBB, dl, TII->get(ARM::t2BR_JT)) + .addReg(NewVReg3, RegState::Kill) + .addReg(NewVReg1) + .addJumpTableIndex(MJTI) + .addImm(UId); + return MBB; } From stoklund at 2pi.dk Tue Oct 4 19:35:50 2011 From: stoklund at 2pi.dk (Jakob Stoklund Olesen) Date: Wed, 05 Oct 2011 00:35:50 -0000 Subject: [llvm-commits] [llvm] r141142 - in /llvm/trunk: include/llvm/Target/TargetRegisterInfo.h utils/TableGen/CodeGenRegisters.cpp utils/TableGen/CodeGenRegisters.h utils/TableGen/RegisterInfoEmitter.cpp Message-ID: <20111005003551.704422A6C12C@llvm.org> Author: stoklund Date: Tue Oct 4 19:35:49 2011 New Revision: 141142 URL: http://llvm.org/viewvc/llvm-project?rev=141142&view=rev Log: Add TRI::getSubClassWithSubReg(RC, Idx) function. This function is used to constrain a register class to a sub-class that supports the given sub-register index. For example, getSubClassWithSubReg(GR32, sub_8bit) -> GR32_ABCD. The function will be used to compute register classes when emitting INSERT_SUBREG and EXTRACT_SUBREG nodes and for register class inflation of sub-register operations. The version provided by TableGen is usually adequate, but targets can override. Modified: llvm/trunk/include/llvm/Target/TargetRegisterInfo.h llvm/trunk/utils/TableGen/CodeGenRegisters.cpp llvm/trunk/utils/TableGen/CodeGenRegisters.h llvm/trunk/utils/TableGen/RegisterInfoEmitter.cpp Modified: llvm/trunk/include/llvm/Target/TargetRegisterInfo.h URL: http://llvm.org/viewvc/llvm-project/llvm/trunk/include/llvm/Target/TargetRegisterInfo.h?rev=141142&r1=141141&r2=141142&view=diff ============================================================================== --- llvm/trunk/include/llvm/Target/TargetRegisterInfo.h (original) +++ llvm/trunk/include/llvm/Target/TargetRegisterInfo.h Tue Oct 4 19:35:49 2011 @@ -429,6 +429,20 @@ return 0; } + /// getSubClassWithSubReg - Returns the largest legal sub-class of RC that + /// supports the sub-register index Idx. + /// If no such sub-class exists, return NULL. + /// If all registers in RC already have an Idx sub-register, return RC. + /// + /// TableGen generates a version of this function that is good enough in most + /// cases. Targets can override if they have constraints that TableGen + /// doesn't understand. For example, the x86 sub_8bit sub-register index is + /// supported by the full GR32 register class in 64-bit mode, but only by the + /// GR32_ABCD regiister class in 32-bit mode. + /// + virtual const TargetRegisterClass * + getSubClassWithSubReg(const TargetRegisterClass *RC, unsigned Idx) const =0; + /// composeSubRegIndices - Return the subregister index you get from composing /// two subregister indices. /// Modified: llvm/trunk/utils/TableGen/CodeGenRegisters.cpp URL: http://llvm.org/viewvc/llvm-project/llvm/trunk/utils/TableGen/CodeGenRegisters.cpp?rev=141142&r1=141141&r2=141142&view=diff ============================================================================== --- llvm/trunk/utils/TableGen/CodeGenRegisters.cpp (original) +++ llvm/trunk/utils/TableGen/CodeGenRegisters.cpp Tue Oct 4 19:35:49 2011 @@ -768,23 +768,31 @@ // Find matching classes for all SRSets entries. Iterate in SubRegIndex // numerical order to visit synthetic indices last. for (unsigned sri = 0, sre = SubRegIndices.size(); sri != sre; ++sri) { - SubReg2SetMap::const_iterator I = SRSets.find(SubRegIndices[sri]); + Record *SubIdx = SubRegIndices[sri]; + SubReg2SetMap::const_iterator I = SRSets.find(SubIdx); // Unsupported SubRegIndex. Skip it. if (I == SRSets.end()) continue; - // In most cases, all RC registers support the SubRegIndex. Skip those. - if (I->second.size() == RC.getMembers().size()) + // In most cases, all RC registers support the SubRegIndex. + if (I->second.size() == RC.getMembers().size()) { + RC.setSubClassWithSubReg(SubIdx, &RC); continue; + } // This is a real subset. See if we have a matching class. CodeGenRegisterClass::Key K(&I->second, RC.SpillSize, RC.SpillAlignment); RCKeyMap::const_iterator FoundI = Key2RC.find(K); - if (FoundI != Key2RC.end()) + if (FoundI != Key2RC.end()) { + RC.setSubClassWithSubReg(SubIdx, FoundI->second); continue; + } // Class doesn't exist. - addToMaps(new CodeGenRegisterClass(RC.getName() + "_with_" + - I->first->getName(), K)); + CodeGenRegisterClass *NewRC = + new CodeGenRegisterClass(RC.getName() + "_with_" + + I->first->getName(), K); + addToMaps(NewRC); + RC.setSubClassWithSubReg(SubIdx, NewRC); } } } Modified: llvm/trunk/utils/TableGen/CodeGenRegisters.h URL: http://llvm.org/viewvc/llvm-project/llvm/trunk/utils/TableGen/CodeGenRegisters.h?rev=141142&r1=141141&r2=141142&view=diff ============================================================================== --- llvm/trunk/utils/TableGen/CodeGenRegisters.h (original) +++ llvm/trunk/utils/TableGen/CodeGenRegisters.h Tue Oct 4 19:35:49 2011 @@ -101,6 +101,9 @@ // super-class. void inheritProperties(CodeGenRegBank&); + // Map SubRegIndex -> sub-class + DenseMap SubClassWithSubReg; + public: unsigned EnumValue; std::string Namespace; @@ -145,6 +148,16 @@ return SubClasses.test(RC->EnumValue); } + // getSubClassWithSubReg - Returns the largest sub-class where all + // registers have a SubIdx sub-register. + CodeGenRegisterClass *getSubClassWithSubReg(Record *SubIdx) const { + return SubClassWithSubReg.lookup(SubIdx); + } + + void setSubClassWithSubReg(Record *SubIdx, CodeGenRegisterClass *SubRC) { + SubClassWithSubReg[SubIdx] = SubRC; + } + // getSubClasses - Returns a constant BitVector of subclasses indexed by // EnumValue. // The SubClasses vector includs an entry for this class. Modified: llvm/trunk/utils/TableGen/RegisterInfoEmitter.cpp URL: http://llvm.org/viewvc/llvm-project/llvm/trunk/utils/TableGen/RegisterInfoEmitter.cpp?rev=141142&r1=141141&r2=141142&view=diff ============================================================================== --- llvm/trunk/utils/TableGen/RegisterInfoEmitter.cpp (original) +++ llvm/trunk/utils/TableGen/RegisterInfoEmitter.cpp Tue Oct 4 19:35:49 2011 @@ -426,6 +426,8 @@ << " unsigned getSubReg(unsigned RegNo, unsigned Index) const;\n" << " unsigned getSubRegIndex(unsigned RegNo, unsigned SubRegNo) const;\n" << " unsigned composeSubRegIndices(unsigned, unsigned) const;\n" + << " const TargetRegisterClass *" + "getSubClassWithSubReg(const TargetRegisterClass*, unsigned) const;\n" << "};\n\n"; const std::vector &SubRegIndices = RegBank.getSubRegIndices(); @@ -802,6 +804,44 @@ } OS << " }\n}\n\n"; + // Emit getSubClassWithSubReg. + OS << "const TargetRegisterClass *" << ClassName + << "::getSubClassWithSubReg(const TargetRegisterClass *RC, unsigned Idx)" + " const {\n"; + if (SubRegIndices.empty()) { + OS << " assert(Idx == 0 && \"Target has no sub-registers\");\n" + << " return RC;\n"; + } else { + // Use the smallest type that can hold a regclass ID with room for a + // sentinel. + if (RegisterClasses.size() < UINT8_MAX) + OS << " static const uint8_t Table["; + else if (RegisterClasses.size() < UINT16_MAX) + OS << " static const uint16_t Table["; + else + throw "Too many register classes."; + OS << RegisterClasses.size() << "][" << SubRegIndices.size() << "] = {\n"; + for (unsigned rci = 0, rce = RegisterClasses.size(); rci != rce; ++rci) { + const CodeGenRegisterClass &RC = *RegisterClasses[rci]; + OS << " {\t// " << RC.getName() << "\n"; + for (unsigned sri = 0, sre = SubRegIndices.size(); sri != sre; ++sri) { + Record *Idx = SubRegIndices[sri]; + if (CodeGenRegisterClass *SRC = RC.getSubClassWithSubReg(Idx)) + OS << " " << SRC->EnumValue + 1 << ",\t// " << Idx->getName() + << " -> " << SRC->getName() << "\n"; + else + OS << " 0,\t// " << Idx->getName() << "\n"; + } + OS << " },\n"; + } + OS << " };\n assert(RC && \"Missing regclass\");\n" + << " if (!Idx) return RC;\n --Idx;\n" + << " assert(Idx < " << SubRegIndices.size() << " && \"Bad subreg\");\n" + << " unsigned TV = Table[RC->getID()][Idx];\n" + << " return TV ? getRegClass(TV - 1) : 0;\n"; + } + OS << "}\n\n"; + // Emit the constructor of the class... OS << "extern MCRegisterDesc " << TargetName << "RegDesc[];\n"; From isanbard at gmail.com Tue Oct 4 19:39:33 2011 From: isanbard at gmail.com (Bill Wendling) Date: Wed, 05 Oct 2011 00:39:33 -0000 Subject: [llvm-commits] [llvm] r141143 - /llvm/trunk/lib/Target/ARM/ARMISelLowering.cpp Message-ID: <20111005003934.2A9CD2A6C12C@llvm.org> Author: void Date: Tue Oct 4 19:39:32 2011 New Revision: 141143 URL: http://llvm.org/viewvc/llvm-project?rev=141143&view=rev Log: Look at the number of entries in the jump table and jump to a 'trap' block if the value exceeds that number. Modified: llvm/trunk/lib/Target/ARM/ARMISelLowering.cpp Modified: llvm/trunk/lib/Target/ARM/ARMISelLowering.cpp URL: http://llvm.org/viewvc/llvm-project/llvm/trunk/lib/Target/ARM/ARMISelLowering.cpp?rev=141143&r1=141142&r2=141143&view=diff ============================================================================== --- llvm/trunk/lib/Target/ARM/ARMISelLowering.cpp (original) +++ llvm/trunk/lib/Target/ARM/ARMISelLowering.cpp Tue Oct 4 19:39:32 2011 @@ -5493,11 +5493,9 @@ ARMFunctionInfo *AFI = MF->getInfo(); const Function *F = MF->getFunction(); MachineFrameInfo *MFI = MF->getFrameInfo(); - MachineBasicBlock *DispatchBB = MF->CreateMachineBasicBlock(); int FI = MFI->getFunctionContextIndex(); - MachineBasicBlock *Last = &MF->back(); - MF->insert(MF->end(), DispatchBB); - MF->RenumberBlocks(Last); + + MachineBasicBlock *DispatchBB = MF->CreateMachineBasicBlock(); // Shove the dispatch's address into the return slot in the function context. DispatchBB->setIsLandingPad(); @@ -5585,8 +5583,6 @@ .addMemOperand(FIMMO)); } - MI->eraseFromParent(); // The instruction is gone now. - // Now get a mapping of the call site numbers to all of the landing pads // they're associated with. DenseMap > CallSiteNumToLPad; @@ -5617,10 +5613,8 @@ for (unsigned I = 1; I <= MaxCSNum; ++I) { SmallVectorImpl &MBBList = CallSiteNumToLPad[I]; for (SmallVectorImpl::iterator - II = MBBList.begin(), IE = MBBList.end(); II != IE; ++II) { + II = MBBList.begin(), IE = MBBList.end(); II != IE; ++II) LPadList.push_back(*II); - DispatchBB->addSuccessor(*II); - } } MachineJumpTableInfo *JTI = @@ -5628,34 +5622,76 @@ unsigned MJTI = JTI->createJumpTableIndex(LPadList); unsigned UId = AFI->createJumpTableUId(); - FIMMO = MF->getMachineMemOperand(MachinePointerInfo::getFixedStack(FI), - MachineMemOperand::MOLoad, 4, 4); + MachineBasicBlock *TrapBB = MF->CreateMachineBasicBlock(); + BuildMI(TrapBB, dl, TII->get(ARM::TRAP)); + DispatchBB->addSuccessor(TrapBB); + + MachineBasicBlock *DispContBB = MF->CreateMachineBasicBlock(); + DispatchBB->addSuccessor(DispContBB); unsigned NewVReg1 = MRI->createVirtualRegister(TRC); AddDefaultPred(BuildMI(DispatchBB, dl, TII->get(ARM::t2LDRi12), NewVReg1) .addFrameIndex(FI) .addImm(4) .addMemOperand(FIMMO)); + AddDefaultPred(BuildMI(DispatchBB, dl, TII->get(ARM::t2CMPri)) + .addReg(NewVReg1) + .addImm(LPadList.size())); + BuildMI(DispatchBB, dl, TII->get(ARM::t2Bcc)) + .addMBB(TrapBB) + .addImm(ARMCC::HI) + .addReg(ARM::CPSR); + +/* + %vreg11 = t2LDRi12 , 4, pred:14, pred:%noreg; mem:Volatile LD4[%sunkaddr131] rGPR:%vreg11 + t2CMPri %vreg11, 6, pred:14, pred:%noreg, %CPSR; rGPR:%vreg11 + t2Bcc , pred:8, pred:%CPSR +*/ + +/* + %vreg11 = t2LDRi12 , 4, pred:14, pred:%noreg; mem:Volatile LD4[%sunkaddr131] rGPR:%vreg11 + %vreg12 = t2LEApcrelJT , 0, pred:14, pred:%noreg; rGPR:%vreg12 + %vreg13 = t2ADDrs %vreg12, %vreg11, 18, pred:14, pred:%noreg, opt:%noreg; GPRnopc:%vreg13 rGPR:%vreg12,%vreg11 + t2BR_JT %vreg13, %vreg11, , 0; GPRnopc:%vreg13 rGPR:%vreg11 +*/ + + FIMMO = MF->getMachineMemOperand(MachinePointerInfo::getFixedStack(FI), + MachineMemOperand::MOLoad, 4, 4); unsigned NewVReg2 = MRI->createVirtualRegister(TRC); - AddDefaultPred(BuildMI(DispatchBB, dl, TII->get(ARM::t2LEApcrelJT), NewVReg2) + AddDefaultPred(BuildMI(DispContBB, dl, TII->get(ARM::t2LEApcrelJT), NewVReg2) .addJumpTableIndex(MJTI) .addImm(UId)); unsigned NewVReg3 = MRI->createVirtualRegister(TRC); AddDefaultCC( AddDefaultPred( - BuildMI(DispatchBB, dl, TII->get(ARM::t2ADDrs), NewVReg3) + BuildMI(DispContBB, dl, TII->get(ARM::t2ADDrs), NewVReg3) .addReg(NewVReg2, RegState::Kill) .addReg(NewVReg1) .addImm(18))); - BuildMI(DispatchBB, dl, TII->get(ARM::t2BR_JT)) + BuildMI(DispContBB, dl, TII->get(ARM::t2BR_JT)) .addReg(NewVReg3, RegState::Kill) .addReg(NewVReg1) .addJumpTableIndex(MJTI) .addImm(UId); + // Add the jump table entries as successors to the MBB. + for (std::vector::iterator + I = LPadList.begin(), E = LPadList.end(); I != E; ++I) + DispContBB->addSuccessor(*I); + + // Insert and renumber MBBs. + MachineBasicBlock *Last = &MF->back(); + MF->insert(MF->end(), DispatchBB); + MF->insert(MF->end(), DispContBB); + MF->insert(MF->end(), TrapBB); + MF->RenumberBlocks(Last); + + // The instruction is gone now. + MI->eraseFromParent(); + return MBB; } From ahatanaka at mips.com Tue Oct 4 20:06:58 2011 From: ahatanaka at mips.com (Akira Hatanaka) Date: Wed, 05 Oct 2011 01:06:58 -0000 Subject: [llvm-commits] [llvm] r141146 - /llvm/trunk/lib/Target/Mips/MipsDelaySlotFiller.cpp Message-ID: <20111005010659.168EF2A6C12C@llvm.org> Author: ahatanak Date: Tue Oct 4 20:06:57 2011 New Revision: 141146 URL: http://llvm.org/viewvc/llvm-project?rev=141146&view=rev Log: Correct description string of enable-mips-delay-filler. Modified: llvm/trunk/lib/Target/Mips/MipsDelaySlotFiller.cpp Modified: llvm/trunk/lib/Target/Mips/MipsDelaySlotFiller.cpp URL: http://llvm.org/viewvc/llvm-project/llvm/trunk/lib/Target/Mips/MipsDelaySlotFiller.cpp?rev=141146&r1=141145&r2=141146&view=diff ============================================================================== --- llvm/trunk/lib/Target/Mips/MipsDelaySlotFiller.cpp (original) +++ llvm/trunk/lib/Target/Mips/MipsDelaySlotFiller.cpp Tue Oct 4 20:06:57 2011 @@ -31,7 +31,7 @@ static cl::opt EnableDelaySlotFiller( "enable-mips-delay-filler", cl::init(false), - cl::desc("Fill the Mips delay slots with noop."), + cl::desc("Fill the Mips delay slots useful instructions."), cl::Hidden); namespace { From ahatanaka at mips.com Tue Oct 4 20:09:37 2011 From: ahatanaka at mips.com (Akira Hatanaka) Date: Wed, 05 Oct 2011 01:09:37 -0000 Subject: [llvm-commits] [llvm] r141147 - /llvm/trunk/lib/Target/Mips/MipsDelaySlotFiller.cpp Message-ID: <20111005010937.E4CCD2A6C12C@llvm.org> Author: ahatanak Date: Tue Oct 4 20:09:37 2011 New Revision: 141147 URL: http://llvm.org/viewvc/llvm-project?rev=141147&view=rev Log: Add comments and move assignment statement. If sawStore is true, sawLoad does not have to be set. Modified: llvm/trunk/lib/Target/Mips/MipsDelaySlotFiller.cpp Modified: llvm/trunk/lib/Target/Mips/MipsDelaySlotFiller.cpp URL: http://llvm.org/viewvc/llvm-project/llvm/trunk/lib/Target/Mips/MipsDelaySlotFiller.cpp?rev=141147&r1=141146&r2=141147&view=diff ============================================================================== --- llvm/trunk/lib/Target/Mips/MipsDelaySlotFiller.cpp (original) +++ llvm/trunk/lib/Target/Mips/MipsDelaySlotFiller.cpp Tue Oct 4 20:09:37 2011 @@ -174,10 +174,12 @@ if (candidate->isImplicitDef() || candidate->isKill()) return true; + // Loads or stores cannot be moved past a store to the delay slot + // and stores cannot be moved past a load. if (candidate->getDesc().mayLoad()) { - sawLoad = true; if (sawStore) return true; + sawLoad = true; } if (candidate->getDesc().mayStore()) { From ahatanaka at mips.com Tue Oct 4 20:15:31 2011 From: ahatanaka at mips.com (Akira Hatanaka) Date: Wed, 05 Oct 2011 01:15:31 -0000 Subject: [llvm-commits] [llvm] r141148 - /llvm/trunk/lib/Target/Mips/MipsDelaySlotFiller.cpp Message-ID: <20111005011531.AFAA82A6C12C@llvm.org> Author: ahatanak Date: Tue Oct 4 20:15:31 2011 New Revision: 141148 URL: http://llvm.org/viewvc/llvm-project?rev=141148&view=rev Log: Remove unnecessary check. isDelayFiller(MBB, I) will evaluate to true before I->getDesc().hasDelaySlot() does. Modified: llvm/trunk/lib/Target/Mips/MipsDelaySlotFiller.cpp Modified: llvm/trunk/lib/Target/Mips/MipsDelaySlotFiller.cpp URL: http://llvm.org/viewvc/llvm-project/llvm/trunk/lib/Target/Mips/MipsDelaySlotFiller.cpp?rev=141148&r1=141147&r2=141148&view=diff ============================================================================== --- llvm/trunk/lib/Target/Mips/MipsDelaySlotFiller.cpp (original) +++ llvm/trunk/lib/Target/Mips/MipsDelaySlotFiller.cpp Tue Oct 4 20:15:31 2011 @@ -146,7 +146,6 @@ if (I->hasUnmodeledSideEffects() || I->isInlineAsm() || I->isLabel() - || I->getDesc().hasDelaySlot() || isDelayFiller(MBB, I) || I->getDesc().isPseudo() // From ahatanaka at mips.com Tue Oct 4 20:19:15 2011 From: ahatanaka at mips.com (Akira Hatanaka) Date: Wed, 05 Oct 2011 01:19:15 -0000 Subject: [llvm-commits] [llvm] r141149 - /llvm/trunk/lib/Target/Mips/MipsDelaySlotFiller.cpp Message-ID: <20111005011915.C42FE2A6C12C@llvm.org> Author: ahatanak Date: Tue Oct 4 20:19:13 2011 New Revision: 141149 URL: http://llvm.org/viewvc/llvm-project?rev=141149&view=rev Log: Define a statistic for the number of slots that were filled with useful instructions (instructions that are not NOP). Modified: llvm/trunk/lib/Target/Mips/MipsDelaySlotFiller.cpp Modified: llvm/trunk/lib/Target/Mips/MipsDelaySlotFiller.cpp URL: http://llvm.org/viewvc/llvm-project/llvm/trunk/lib/Target/Mips/MipsDelaySlotFiller.cpp?rev=141149&r1=141148&r2=141149&view=diff ============================================================================== --- llvm/trunk/lib/Target/Mips/MipsDelaySlotFiller.cpp (original) +++ llvm/trunk/lib/Target/Mips/MipsDelaySlotFiller.cpp Tue Oct 4 20:19:13 2011 @@ -27,6 +27,8 @@ using namespace llvm; STATISTIC(FilledSlots, "Number of delay slots filled"); +STATISTIC(UsefulSlots, "Number of delay slots filled with instructions that" + "are not NOP."); static cl::opt EnableDelaySlotFiller( "enable-mips-delay-filler", From ahatanaka at mips.com Tue Oct 4 20:23:40 2011 From: ahatanaka at mips.com (Akira Hatanaka) Date: Wed, 05 Oct 2011 01:23:40 -0000 Subject: [llvm-commits] [llvm] r141150 - /llvm/trunk/lib/Target/Mips/MipsDelaySlotFiller.cpp Message-ID: <20111005012340.30C272A6C12C@llvm.org> Author: ahatanak Date: Tue Oct 4 20:23:39 2011 New Revision: 141150 URL: http://llvm.org/viewvc/llvm-project?rev=141150&view=rev Log: Clean up Filler::runOnMachineBasicBlock. Change interface of Filler::findDelayInstr. Modified: llvm/trunk/lib/Target/Mips/MipsDelaySlotFiller.cpp Modified: llvm/trunk/lib/Target/Mips/MipsDelaySlotFiller.cpp URL: http://llvm.org/viewvc/llvm-project/llvm/trunk/lib/Target/Mips/MipsDelaySlotFiller.cpp?rev=141150&r1=141149&r2=141150&view=diff ============================================================================== --- llvm/trunk/lib/Target/Mips/MipsDelaySlotFiller.cpp (original) +++ llvm/trunk/lib/Target/Mips/MipsDelaySlotFiller.cpp Tue Oct 4 20:23:39 2011 @@ -78,8 +78,9 @@ SmallSet &RegDefs, SmallSet &RegUses); - MachineBasicBlock::iterator - findDelayInstr(MachineBasicBlock &MBB, MachineBasicBlock::iterator slot); + bool + findDelayInstr(MachineBasicBlock &MBB, MachineBasicBlock::iterator slot, + MachineBasicBlock::iterator &Filler); }; @@ -93,19 +94,19 @@ bool Changed = false; for (MachineBasicBlock::iterator I = MBB.begin(); I != MBB.end(); ++I) if (I->getDesc().hasDelaySlot()) { - MachineBasicBlock::iterator D = MBB.end(); - MachineBasicBlock::iterator J = I; - - if (EnableDelaySlotFiller) - D = findDelayInstr(MBB, I); - ++FilledSlots; Changed = true; - if (D == MBB.end()) - BuildMI(MBB, ++J, I->getDebugLoc(), TII->get(Mips::NOP)); - else - MBB.splice(++J, &MBB, D); + MachineBasicBlock::iterator D; + + if (EnableDelaySlotFiller && findDelayInstr(MBB, I, D)) { + MBB.splice(llvm::next(I), &MBB, D); + ++UsefulSlots; + } + else + BuildMI(MBB, llvm::next(I), I->getDebugLoc(), TII->get(Mips::NOP)); + + ++I; // Skip instruction that has just been moved to delay slot. } return Changed; @@ -117,9 +118,9 @@ return new Filler(tm); } -MachineBasicBlock::iterator -Filler::findDelayInstr(MachineBasicBlock &MBB, - MachineBasicBlock::iterator slot) { +bool Filler::findDelayInstr(MachineBasicBlock &MBB, + MachineBasicBlock::iterator slot, + MachineBasicBlock::iterator &Filler) { SmallSet RegDefs; SmallSet RegUses; bool sawLoad = false; @@ -162,9 +163,11 @@ continue; } - return I; + Filler = I; + return true; } - return MBB.end(); + + return false; } bool Filler::delayHasHazard(MachineBasicBlock::iterator candidate, From ahatanaka at mips.com Tue Oct 4 20:30:09 2011 From: ahatanaka at mips.com (Akira Hatanaka) Date: Wed, 05 Oct 2011 01:30:09 -0000 Subject: [llvm-commits] [llvm] r141151 - /llvm/trunk/lib/Target/Mips/MipsDelaySlotFiller.cpp Message-ID: <20111005013010.B3E492A6C12C@llvm.org> Author: ahatanak Date: Tue Oct 4 20:30:09 2011 New Revision: 141151 URL: http://llvm.org/viewvc/llvm-project?rev=141151&view=rev Log: Remove function Filler::isDelayFiller. Check if I is the same instruction that filled the last delay slot visited. Modified: llvm/trunk/lib/Target/Mips/MipsDelaySlotFiller.cpp Modified: llvm/trunk/lib/Target/Mips/MipsDelaySlotFiller.cpp URL: http://llvm.org/viewvc/llvm-project/llvm/trunk/lib/Target/Mips/MipsDelaySlotFiller.cpp?rev=141151&r1=141150&r2=141151&view=diff ============================================================================== --- llvm/trunk/lib/Target/Mips/MipsDelaySlotFiller.cpp (original) +++ llvm/trunk/lib/Target/Mips/MipsDelaySlotFiller.cpp Tue Oct 4 20:30:09 2011 @@ -41,6 +41,7 @@ TargetMachine &TM; const TargetInstrInfo *TII; + MachineBasicBlock::iterator LastFiller; static char ID; Filler(TargetMachine &tm) @@ -92,6 +93,8 @@ bool Filler:: runOnMachineBasicBlock(MachineBasicBlock &MBB) { bool Changed = false; + LastFiller = MBB.end(); + for (MachineBasicBlock::iterator I = MBB.begin(); I != MBB.end(); ++I) if (I->getDesc().hasDelaySlot()) { ++FilledSlots; @@ -106,7 +109,9 @@ else BuildMI(MBB, llvm::next(I), I->getDebugLoc(), TII->get(Mips::NOP)); - ++I; // Skip instruction that has just been moved to delay slot. + // Record the filler instruction that filled the delay slot. + // The instruction after it will be visited in the next iteration. + LastFiller = ++I; } return Changed; @@ -149,7 +154,7 @@ if (I->hasUnmodeledSideEffects() || I->isInlineAsm() || I->isLabel() - || isDelayFiller(MBB, I) + || I == LastFiller || I->getDesc().isPseudo() // // Should not allow: @@ -264,12 +269,3 @@ return false; } - -// return true if the candidate is a delay filler. -bool Filler::isDelayFiller(MachineBasicBlock &MBB, - MachineBasicBlock::iterator candidate) { - if (candidate == MBB.begin()) - return false; - const MCInstrDesc &prevdesc = (--candidate)->getDesc(); - return prevdesc.hasDelaySlot(); -} From aaron at aaronballman.com Tue Oct 4 20:34:32 2011 From: aaron at aaronballman.com (Aaron Ballman) Date: Tue, 4 Oct 2011 20:34:32 -0500 Subject: [llvm-commits] [PATCH] Removed FIXME from Memory.inc on Windows In-Reply-To: References: Message-ID: Ping? On Mon, Sep 19, 2011 at 5:30 PM, Aaron Ballman wrote: > On Mon, Sep 19, 2011 at 4:31 AM, Anton Korobeynikov > wrote: >> Hi Aaron, >> >>> This patch addresses a FIXME in the Memory class on Windows. ?It now >>> supports allocating blocks of memory around the "NearBlock" parameter. >>> ?Additionally, it adds support for changing the protection for blocks >>> of virtual memory. >> Stuff looks generally ok for me, but I'd ask Takumi as well. >> Also, please split the patch into 2 parts, it definitely contains 2 >> unrelated blocks >> >> Thanks for working on this! > > My pleasure! ?I've split the changes into two separate diffs, and > attached them both. > > VProt.diff is the patch for supporting setting memory to be writable > or executable. > > NearBlock.diff is the patch which removes the FIXME for NearBlock support. > > Thanks! > > ~Aaron > -------------- next part -------------- A non-text attachment was scrubbed... Name: VProt.diff Type: application/octet-stream Size: 1960 bytes Desc: not available Url : http://lists.cs.uiuc.edu/pipermail/llvm-commits/attachments/20111004/188e6fbd/attachment.obj -------------- next part -------------- A non-text attachment was scrubbed... Name: NearBlock.diff Type: application/octet-stream Size: 949 bytes Desc: not available Url : http://lists.cs.uiuc.edu/pipermail/llvm-commits/attachments/20111004/188e6fbd/attachment-0001.obj From ahatanaka at mips.com Tue Oct 4 20:57:49 2011 From: ahatanaka at mips.com (Akira Hatanaka) Date: Wed, 05 Oct 2011 01:57:49 -0000 Subject: [llvm-commits] [llvm] r141152 - /llvm/trunk/lib/Target/Mips/MipsDelaySlotFiller.cpp Message-ID: <20111005015749.C74EE2A6C12C@llvm.org> Author: ahatanak Date: Tue Oct 4 20:57:46 2011 New Revision: 141152 URL: http://llvm.org/viewvc/llvm-project?rev=141152&view=rev Log: Clean up Filler::findDelayInstr. Modified: llvm/trunk/lib/Target/Mips/MipsDelaySlotFiller.cpp Modified: llvm/trunk/lib/Target/Mips/MipsDelaySlotFiller.cpp URL: http://llvm.org/viewvc/llvm-project/llvm/trunk/lib/Target/Mips/MipsDelaySlotFiller.cpp?rev=141152&r1=141151&r2=141152&view=diff ============================================================================== --- llvm/trunk/lib/Target/Mips/MipsDelaySlotFiller.cpp (original) +++ llvm/trunk/lib/Target/Mips/MipsDelaySlotFiller.cpp Tue Oct 4 20:57:46 2011 @@ -128,10 +128,6 @@ MachineBasicBlock::iterator &Filler) { SmallSet RegDefs; SmallSet RegUses; - bool sawLoad = false; - bool sawStore = false; - - MachineBasicBlock::iterator I = slot; // Call's delay filler can def some of call's uses. if (slot->getDesc().isCall()) @@ -139,22 +135,21 @@ else insertDefsUses(slot, RegDefs, RegUses); - bool done = false; - - while (!done) { - done = (I == MBB.begin()); - - if (!done) - --I; + bool sawLoad = false; + bool sawStore = false; + for (MachineBasicBlock::reverse_iterator I(slot); I != MBB.rend(); ++I) { // skip debug value if (I->isDebugValue()) continue; + // Convert to forward iterator. + MachineBasicBlock::iterator FI(next(I).base()); + if (I->hasUnmodeledSideEffects() || I->isInlineAsm() || I->isLabel() - || I == LastFiller + || FI == LastFiller || I->getDesc().isPseudo() // // Should not allow: @@ -163,12 +158,12 @@ ) break; - if (delayHasHazard(I, sawLoad, sawStore, RegDefs, RegUses)) { - insertDefsUses(I, RegDefs, RegUses); + if (delayHasHazard(FI, sawLoad, sawStore, RegDefs, RegUses)) { + insertDefsUses(FI, RegDefs, RegUses); continue; } - Filler = I; + Filler = FI; return true; } From ahatanaka at mips.com Tue Oct 4 21:04:17 2011 From: ahatanaka at mips.com (Akira Hatanaka) Date: Wed, 05 Oct 2011 02:04:17 -0000 Subject: [llvm-commits] [llvm] r141154 - /llvm/trunk/lib/Target/Mips/MipsDelaySlotFiller.cpp Message-ID: <20111005020418.3D8322A6C12C@llvm.org> Author: ahatanak Date: Tue Oct 4 21:04:17 2011 New Revision: 141154 URL: http://llvm.org/viewvc/llvm-project?rev=141154&view=rev Log: Remove function Filler::insertCallUses. Record the registers used and defined by a call in Filler::insertDefsUses. Modified: llvm/trunk/lib/Target/Mips/MipsDelaySlotFiller.cpp Modified: llvm/trunk/lib/Target/Mips/MipsDelaySlotFiller.cpp URL: http://llvm.org/viewvc/llvm-project/llvm/trunk/lib/Target/Mips/MipsDelaySlotFiller.cpp?rev=141154&r1=141153&r2=141154&view=diff ============================================================================== --- llvm/trunk/lib/Target/Mips/MipsDelaySlotFiller.cpp (original) +++ llvm/trunk/lib/Target/Mips/MipsDelaySlotFiller.cpp Tue Oct 4 21:04:17 2011 @@ -129,11 +129,7 @@ SmallSet RegDefs; SmallSet RegUses; - // Call's delay filler can def some of call's uses. - if (slot->getDesc().isCall()) - insertCallUses(slot, RegDefs, RegUses); - else - insertDefsUses(slot, RegDefs, RegUses); + insertDefsUses(slot, RegDefs, RegUses); bool sawLoad = false; bool sawStore = false; @@ -215,39 +211,28 @@ return false; } -void Filler::insertCallUses(MachineBasicBlock::iterator MI, - SmallSet& RegDefs, - SmallSet& RegUses) { - switch(MI->getOpcode()) { - default: llvm_unreachable("Unknown opcode."); - case Mips::JAL: - RegDefs.insert(31); - break; - case Mips::JALR: - assert(MI->getNumOperands() >= 1); - const MachineOperand &Reg = MI->getOperand(0); - assert(Reg.isReg() && "JALR first operand is not a register."); - RegUses.insert(Reg.getReg()); - RegDefs.insert(31); - break; - } -} - // Insert Defs and Uses of MI into the sets RegDefs and RegUses. void Filler::insertDefsUses(MachineBasicBlock::iterator MI, SmallSet& RegDefs, SmallSet& RegUses) { - for (unsigned i = 0, e = MI->getNumOperands(); i != e; ++i) { + // If MI is a call, just examine the explicit non-variadic operands. + // NOTE: $ra is not added to RegDefs, since currently $ra is reserved and + // no instruction that can possibly be put in a delay slot can read or + // write it. + + unsigned e = MI->getDesc().isCall() ? MI->getDesc().getNumOperands() : + MI->getNumOperands(); + + for (unsigned i = 0; i != e; ++i) { const MachineOperand &MO = MI->getOperand(i); - if (!MO.isReg()) - continue; + unsigned Reg; - unsigned Reg = MO.getReg(); - if (Reg == 0) + if (!MO.isReg() || !(Reg = MO.getReg())) continue; + if (MO.isDef()) RegDefs.insert(Reg); - if (MO.isUse()) + else if (MO.isUse()) RegUses.insert(Reg); } } From ahatanaka at mips.com Tue Oct 4 21:19:01 2011 From: ahatanaka at mips.com (Akira Hatanaka) Date: Wed, 05 Oct 2011 02:19:01 -0000 Subject: [llvm-commits] [llvm] r141156 - /llvm/trunk/lib/Target/Mips/MipsDelaySlotFiller.cpp Message-ID: <20111005021901.9AD5E2A6C12C@llvm.org> Author: ahatanak Date: Tue Oct 4 21:18:58 2011 New Revision: 141156 URL: http://llvm.org/viewvc/llvm-project?rev=141156&view=rev Log: Clean up function Filler::delayHasHazard. Modified: llvm/trunk/lib/Target/Mips/MipsDelaySlotFiller.cpp Modified: llvm/trunk/lib/Target/Mips/MipsDelaySlotFiller.cpp URL: http://llvm.org/viewvc/llvm-project/llvm/trunk/lib/Target/Mips/MipsDelaySlotFiller.cpp?rev=141156&r1=141155&r2=141156&view=diff ============================================================================== --- llvm/trunk/lib/Target/Mips/MipsDelaySlotFiller.cpp (original) +++ llvm/trunk/lib/Target/Mips/MipsDelaySlotFiller.cpp Tue Oct 4 21:18:58 2011 @@ -190,12 +190,14 @@ return true; } + assert(!candidate->getDesc().isCall() && "Cannot put calls in delay slot."); + for (unsigned i = 0, e = candidate->getNumOperands(); i!= e; ++i) { const MachineOperand &MO = candidate->getOperand(i); - if (!MO.isReg()) - continue; // skip + unsigned Reg; - unsigned Reg = MO.getReg(); + if (!MO.isReg() || !(Reg = MO.getReg())) + continue; // skip if (MO.isDef()) { // check whether Reg is defined or used before delay slot. @@ -215,7 +217,7 @@ void Filler::insertDefsUses(MachineBasicBlock::iterator MI, SmallSet& RegDefs, SmallSet& RegUses) { - // If MI is a call, just examine the explicit non-variadic operands. + // If MI is a call or return, just examine the explicit non-variadic operands. // NOTE: $ra is not added to RegDefs, since currently $ra is reserved and // no instruction that can possibly be put in a delay slot can read or // write it. From ahatanaka at mips.com Tue Oct 4 21:21:58 2011 From: ahatanaka at mips.com (Akira Hatanaka) Date: Wed, 05 Oct 2011 02:21:58 -0000 Subject: [llvm-commits] [llvm] r141157 - /llvm/trunk/lib/Target/Mips/MipsDelaySlotFiller.cpp Message-ID: <20111005022158.379B32A6C12C@llvm.org> Author: ahatanak Date: Tue Oct 4 21:21:58 2011 New Revision: 141157 URL: http://llvm.org/viewvc/llvm-project?rev=141157&view=rev Log: Do not examine variadic or implicit operands if instruction is a return (jr). Modified: llvm/trunk/lib/Target/Mips/MipsDelaySlotFiller.cpp Modified: llvm/trunk/lib/Target/Mips/MipsDelaySlotFiller.cpp URL: http://llvm.org/viewvc/llvm-project/llvm/trunk/lib/Target/Mips/MipsDelaySlotFiller.cpp?rev=141157&r1=141156&r2=141157&view=diff ============================================================================== --- llvm/trunk/lib/Target/Mips/MipsDelaySlotFiller.cpp (original) +++ llvm/trunk/lib/Target/Mips/MipsDelaySlotFiller.cpp Tue Oct 4 21:21:58 2011 @@ -222,8 +222,9 @@ // no instruction that can possibly be put in a delay slot can read or // write it. - unsigned e = MI->getDesc().isCall() ? MI->getDesc().getNumOperands() : - MI->getNumOperands(); + MCInstrDesc MCID = MI->getDesc(); + unsigned e = MCID.isCall() || MCID.isReturn() ? MCID.getNumOperands() : + MI->getNumOperands(); for (unsigned i = 0; i != e; ++i) { const MachineOperand &MO = MI->getOperand(i); From ahatanaka at mips.com Tue Oct 4 21:22:54 2011 From: ahatanaka at mips.com (Akira Hatanaka) Date: Wed, 05 Oct 2011 02:22:54 -0000 Subject: [llvm-commits] [llvm] r141158 - /llvm/trunk/lib/Target/Mips/MipsDelaySlotFiller.cpp Message-ID: <20111005022257.69E992A6C12C@llvm.org> Author: ahatanak Date: Tue Oct 4 21:22:49 2011 New Revision: 141158 URL: http://llvm.org/viewvc/llvm-project?rev=141158&view=rev Log: Insert space. Modified: llvm/trunk/lib/Target/Mips/MipsDelaySlotFiller.cpp Modified: llvm/trunk/lib/Target/Mips/MipsDelaySlotFiller.cpp URL: http://llvm.org/viewvc/llvm-project/llvm/trunk/lib/Target/Mips/MipsDelaySlotFiller.cpp?rev=141158&r1=141157&r2=141158&view=diff ============================================================================== --- llvm/trunk/lib/Target/Mips/MipsDelaySlotFiller.cpp (original) +++ llvm/trunk/lib/Target/Mips/MipsDelaySlotFiller.cpp Tue Oct 4 21:22:49 2011 @@ -28,7 +28,7 @@ STATISTIC(FilledSlots, "Number of delay slots filled"); STATISTIC(UsefulSlots, "Number of delay slots filled with instructions that" - "are not NOP."); + " are not NOP."); static cl::opt EnableDelaySlotFiller( "enable-mips-delay-filler", From clchiou at gmail.com Tue Oct 4 21:43:44 2011 From: clchiou at gmail.com (Che-Liang Chiou) Date: Wed, 5 Oct 2011 10:43:44 +0800 Subject: [llvm-commits] [llvm] r141093 - /llvm/trunk/lib/TableGen/TGPreprocessor.cpp In-Reply-To: <20111004162807.BB4E92A6C12C@llvm.org> References: <20111004162807.BB4E92A6C12C@llvm.org> Message-ID: Thanks for fixing this! On Wed, Oct 5, 2011 at 12:28 AM, Francois Pichet wrote: > Author: fpichet > Date: Tue Oct ?4 11:28:07 2011 > New Revision: 141093 > > URL: http://llvm.org/viewvc/llvm-project?rev=141093&view=rev > Log: > Unbreak MSVC build. > > Modified: > ? ?llvm/trunk/lib/TableGen/TGPreprocessor.cpp > > Modified: llvm/trunk/lib/TableGen/TGPreprocessor.cpp > URL: http://llvm.org/viewvc/llvm-project/llvm/trunk/lib/TableGen/TGPreprocessor.cpp?rev=141093&r1=141092&r2=141093&view=diff > ============================================================================== > --- llvm/trunk/lib/TableGen/TGPreprocessor.cpp (original) > +++ llvm/trunk/lib/TableGen/TGPreprocessor.cpp Tue Oct ?4 11:28:07 2011 > @@ -24,6 +24,10 @@ > ?#include > ?#include > > +#ifdef _MSC_VER > +#define snprintf _snprintf > +#endif > + > ?namespace llvm { > ?typedef std::map TGPPEnvironment; > > > > _______________________________________________ > llvm-commits mailing list > llvm-commits at cs.uiuc.edu > http://lists.cs.uiuc.edu/mailman/listinfo/llvm-commits > From atrick at apple.com Tue Oct 4 22:25:32 2011 From: atrick at apple.com (Andrew Trick) Date: Wed, 05 Oct 2011 03:25:32 -0000 Subject: [llvm-commits] [llvm] r141161 - /llvm/trunk/lib/Analysis/ScalarEvolution.cpp Message-ID: <20111005032535.290952A6C12C@llvm.org> Author: atrick Date: Tue Oct 4 22:25:31 2011 New Revision: 141161 URL: http://llvm.org/viewvc/llvm-project?rev=141161&view=rev Log: Avoid exponential recursion in SCEV getConstantEvolvingPHI and EvaluateExpression. Note to compiler writers: never recurse on multiple instruction operands without memoization. Fixes rdar://10187945. Was taking 45s, now taking 5ms. Modified: llvm/trunk/lib/Analysis/ScalarEvolution.cpp Modified: llvm/trunk/lib/Analysis/ScalarEvolution.cpp URL: http://llvm.org/viewvc/llvm-project/llvm/trunk/lib/Analysis/ScalarEvolution.cpp?rev=141161&r1=141160&r2=141161&view=diff ============================================================================== --- llvm/trunk/lib/Analysis/ScalarEvolution.cpp (original) +++ llvm/trunk/lib/Analysis/ScalarEvolution.cpp Tue Oct 4 22:25:31 2011 @@ -4667,61 +4667,100 @@ return false; } -/// getConstantEvolvingPHI - Given an LLVM value and a loop, return a PHI node -/// in the loop that V is derived from. We allow arbitrary operations along the -/// way, but the operands of an operation must either be constants or a value -/// derived from a constant PHI. If this expression does not fit with these -/// constraints, return null. -static PHINode *getConstantEvolvingPHI(Value *V, const Loop *L) { - // If this is not an instruction, or if this is an instruction outside of the - // loop, it can't be derived from a loop PHI. - Instruction *I = dyn_cast(V); - if (I == 0 || !L->contains(I)) return 0; +/// Determine whether this instruction can constant evolve within this loop +/// assuming its operands can all constant evolve. +static bool canConstantEvolve(Instruction *I, const Loop *L) { + // An instruction outside of the loop can't be derived from a loop PHI. + if (!L->contains(I)) return false; - if (PHINode *PN = dyn_cast(I)) { + if (isa(I)) { if (L->getHeader() == I->getParent()) - return PN; + return true; else // We don't currently keep track of the control flow needed to evaluate // PHIs, so we cannot handle PHIs inside of loops. - return 0; + return false; } // If we won't be able to constant fold this expression even if the operands - // are constants, return early. - if (!CanConstantFold(I)) return 0; + // are constants, bail early. + return CanConstantFold(I); +} + +/// getConstantEvolvingPHIOperands - Implement getConstantEvolvingPHI by +/// recursing through each instruction operand until reaching a loop header phi. +static PHINode * +getConstantEvolvingPHIOperands(Instruction *UseInst, const Loop *L, + SmallPtrSet &Visited) { // Otherwise, we can evaluate this instruction if all of its operands are // constant or derived from a PHI node themselves. PHINode *PHI = 0; - for (unsigned Op = 0, e = I->getNumOperands(); Op != e; ++Op) - if (!isa(I->getOperand(Op))) { - PHINode *P = getConstantEvolvingPHI(I->getOperand(Op), L); - if (P == 0) return 0; // Not evolving from PHI - if (PHI == 0) - PHI = P; - else if (PHI != P) - return 0; // Evolving from multiple different PHIs. - } + for (Instruction::op_iterator OpI = UseInst->op_begin(), + OpE = UseInst->op_end(); OpI != OpE; ++OpI) { + if (isa(*OpI)) continue; + + Instruction *OpInst = dyn_cast(*OpI); + if (!OpInst || !canConstantEvolve(OpInst, L)) return 0; + + PHINode *P = dyn_cast(OpInst); + if (!P) { + // If this operand is already visited, ignore it. It's evolving phi has + // already been shown to be consistent on the first path that reached it. + if (!Visited.insert(OpInst)) continue; + + P = getConstantEvolvingPHIOperands(OpInst, L, Visited); + } + if (P == 0) return 0; // Not evolving from PHI + if (PHI == 0) + PHI = P; + else if (PHI != P) + return 0; // Evolving from multiple different PHIs. + } // This is a expression evolving from a constant PHI! return PHI; } +/// getConstantEvolvingPHI - Given an LLVM value and a loop, return a PHI node +/// in the loop that V is derived from. We allow arbitrary operations along the +/// way, but the operands of an operation must either be constants or a value +/// derived from a constant PHI. If this expression does not fit with these +/// constraints, return null. +static PHINode *getConstantEvolvingPHI(Value *V, const Loop *L) { + Instruction *I = dyn_cast(V); + if (I == 0 || !canConstantEvolve(I, L)) return 0; + + if (PHINode *PN = dyn_cast(I)) { + return PN; + } + + // Record non-constant instructions contained by the loop. + SmallPtrSet Visited; + Visited.insert(I); + return getConstantEvolvingPHIOperands(I, L, Visited); +} + /// EvaluateExpression - Given an expression that passes the /// getConstantEvolvingPHI predicate, evaluate its value assuming the PHI node /// in the loop has the value PHIVal. If we can't fold this expression for some /// reason, return null. -static Constant *EvaluateExpression(Value *V, Constant *PHIVal, +static Constant *EvaluateExpression(Value *V, const Loop *L, + DenseMap &Vals, const TargetData *TD) { - if (isa(V)) return PHIVal; if (Constant *C = dyn_cast(V)) return C; + Instruction *I = cast(V); + if (Constant *C = Vals.lookup(I)) return C; + + assert(!isa(I) && "loop header phis should be mapped to constant"); + assert(canConstantEvolve(I, L) && "cannot evaluate expression in this loop"); + (void)L; std::vector Operands(I->getNumOperands()); for (unsigned i = 0, e = I->getNumOperands(); i != e; ++i) { - Operands[i] = EvaluateExpression(I->getOperand(i), PHIVal, TD); + Operands[i] = EvaluateExpression(I->getOperand(i), L, Vals, TD); if (Operands[i] == 0) return 0; } @@ -4749,6 +4788,9 @@ Constant *&RetVal = ConstantEvolutionLoopExitValue[PN]; + // FIXME: Nick's fix for PR11034 will seed constants for multiple header phis. + DenseMap CurrentIterVals; + // Since the loop is canonicalized, the PHI node must have two entries. One // entry must be a constant (coming in from outside of the loop), and the // second must be derived from the same PHI. @@ -4757,6 +4799,7 @@ dyn_cast(PN->getIncomingValue(!SecondIsBackedge)); if (StartCST == 0) return RetVal = 0; // Must be a constant. + CurrentIterVals[PN] = StartCST; Value *BEValue = PN->getIncomingValue(SecondIsBackedge); if (getConstantEvolvingPHI(BEValue, L) != PN && @@ -4769,17 +4812,20 @@ unsigned NumIterations = BEs.getZExtValue(); // must be in range unsigned IterationNum = 0; - for (Constant *PHIVal = StartCST; ; ++IterationNum) { + for (; ; ++IterationNum) { if (IterationNum == NumIterations) - return RetVal = PHIVal; // Got exit value! + return RetVal = CurrentIterVals[PN]; // Got exit value! // Compute the value of the PHI node for the next iteration. - Constant *NextPHI = EvaluateExpression(BEValue, PHIVal, TD); - if (NextPHI == PHIVal) + // EvaluateExpression adds non-phi values to the CurrentIterVals map. + Constant *NextPHI = EvaluateExpression(BEValue, L, CurrentIterVals, TD); + if (NextPHI == CurrentIterVals[PN]) return RetVal = NextPHI; // Stopped evolving! if (NextPHI == 0) return 0; // Couldn't evaluate! - PHIVal = NextPHI; + DenseMap NextIterVals; + NextIterVals[PN] = NextPHI; + CurrentIterVals.swap(NextIterVals); } } @@ -4815,10 +4861,12 @@ // "ExitWhen". unsigned IterationNum = 0; unsigned MaxIterations = MaxBruteForceIterations; // Limit analysis. + DenseMap PHIValMap; for (Constant *PHIVal = StartCST; IterationNum != MaxIterations; ++IterationNum) { + PHIValMap[PN] = PHIVal; ConstantInt *CondVal = - dyn_cast_or_null(EvaluateExpression(Cond, PHIVal, TD)); + dyn_cast_or_null(EvaluateExpression(Cond, L, PHIValMap, TD)); // Couldn't symbolically evaluate. if (!CondVal) return getCouldNotCompute(); @@ -4829,7 +4877,7 @@ } // Compute the value of the PHI node for the next iteration. - Constant *NextPHI = EvaluateExpression(BEValue, PHIVal, TD); + Constant *NextPHI = EvaluateExpression(BEValue, L, PHIValMap, TD); if (NextPHI == 0 || NextPHI == PHIVal) return getCouldNotCompute();// Couldn't evaluate or not making progress... PHIVal = NextPHI; From craig.topper at gmail.com Tue Oct 4 22:29:33 2011 From: craig.topper at gmail.com (Craig Topper) Date: Wed, 05 Oct 2011 03:29:33 -0000 Subject: [llvm-commits] [llvm] r141162 - /llvm/trunk/lib/Target/X86/Disassembler/X86DisassemblerDecoder.c Message-ID: <20111005032933.625592A6C12C@llvm.org> Author: ctopper Date: Tue Oct 4 22:29:32 2011 New Revision: 141162 URL: http://llvm.org/viewvc/llvm-project?rev=141162&view=rev Log: Change C++ style comments to C style comments in X86 disassembler. Patch from Joe Abbey. Modified: llvm/trunk/lib/Target/X86/Disassembler/X86DisassemblerDecoder.c Modified: llvm/trunk/lib/Target/X86/Disassembler/X86DisassemblerDecoder.c URL: http://llvm.org/viewvc/llvm-project/llvm/trunk/lib/Target/X86/Disassembler/X86DisassemblerDecoder.c?rev=141162&r1=141161&r2=141162&view=diff ============================================================================== --- llvm/trunk/lib/Target/X86/Disassembler/X86DisassemblerDecoder.c (original) +++ llvm/trunk/lib/Target/X86/Disassembler/X86DisassemblerDecoder.c Tue Oct 4 22:29:32 2011 @@ -933,7 +933,7 @@ spec = specifierForUID(instructionID); - // Borrow opcode from one of the other XCHGar opcodes + /* Borrow opcode from one of the other XCHGar opcodes */ insn->opcode = 0x91; if (getIDWithAttrMask(&instructionIDWithNewOpcode, @@ -948,7 +948,7 @@ specWithNewOpcode = specifierForUID(instructionIDWithNewOpcode); - // Change back + /* Change back */ insn->opcode = 0x90; insn->instructionID = instructionIDWithNewOpcode; From craig.topper at gmail.com Tue Oct 4 22:32:06 2011 From: craig.topper at gmail.com (Craig Topper) Date: Tue, 4 Oct 2011 20:32:06 -0700 Subject: [llvm-commits] [llvm] r140971 - in /llvm/trunk: lib/Target/X86/Disassembler/X86DisassemblerDecoder.c test/MC/Disassembler/X86/simple-tests.txt In-Reply-To: References: <20111002165610.EC2592A6C12C@llvm.org> <4e8ab4f6.413cd80a.124a.1308SMTPIN_ADDED@mx.google.com> Message-ID: Committed in r141162. On Tue, Oct 4, 2011 at 10:48 AM, Joe Abbey wrote: > See the attached patch :) > > Joe > > On Tue, Oct 4, 2011 at 1:27 PM, Craig Topper > wrote: > > I'll fix it tonight unless someone beats me to it. > > > > On Tue, Oct 4, 2011 at 12:25 AM, James Molloy > wrote: > >> > >> Hi Craig, > >> > >> This commit breaks our opensource build. > >> > >> X86DisassemblerDecoder.c:906:5: error: C++ style comments are not > allowed > >> in > >> ISO C90 > >> > >> Could you please change the comments to C-style? > >> > >> Cheers, > >> > >> James > >> > >> -----Original Message----- > >> From: llvm-commits-bounces at cs.uiuc.edu > >> [mailto:llvm-commits-bounces at cs.uiuc.edu] On Behalf Of Craig Topper > >> Sent: 02 October 2011 17:56 > >> To: llvm-commits at cs.uiuc.edu > >> Subject: [llvm-commits] [llvm] r140971 - in /llvm/trunk: > >> lib/Target/X86/Disassembler/X86DisassemblerDecoder.c > >> test/MC/Disassembler/X86/simple-tests.txt > >> > >> Author: ctopper > >> Date: Sun Oct 2 11:56:09 2011 > >> New Revision: 140971 > >> > >> URL: http://llvm.org/viewvc/llvm-project?rev=140971&view=rev > >> Log: > >> Special case disassembler handling of REX.B prefix on NOP instruction to > >> decode as XCHG R8D, EAX instead. Fixes PR10344. > >> > >> Modified: > >> llvm/trunk/lib/Target/X86/Disassembler/X86DisassemblerDecoder.c > >> llvm/trunk/test/MC/Disassembler/X86/simple-tests.txt > >> > >> Modified: > llvm/trunk/lib/Target/X86/Disassembler/X86DisassemblerDecoder.c > >> URL: > >> > >> > http://llvm.org/viewvc/llvm-project/llvm/trunk/lib/Target/X86/Disassembler/X > >> 86DisassemblerDecoder.c?rev=140971&r1=140970&r2=140971&view=diff > >> > >> > ============================================================================ > >> == > >> --- llvm/trunk/lib/Target/X86/Disassembler/X86DisassemblerDecoder.c > >> (original) > >> +++ llvm/trunk/lib/Target/X86/Disassembler/X86DisassemblerDecoder.c Sun > >> Oct > >> 2 11:56:09 2011 > >> @@ -58,8 +58,8 @@ > >> * @return - TRUE if the ModR/M byte is required, FALSE > >> otherwise. > >> */ > >> static int modRMRequired(OpcodeType type, > >> - InstructionContext insnContext, > >> - uint8_t opcode) { > >> + InstructionContext insnContext, > >> + uint8_t opcode) { > >> const struct ContextDecision* decision = 0; > >> > >> switch (type) { > >> @@ -885,6 +885,43 @@ > >> } > >> return 0; > >> } > >> + > >> + if (insn->opcodeType == ONEBYTE && insn->opcode == 0x90 && > >> + insn->rexPrefix & 0x01) { > >> + /* > >> + * NOOP shouldn't decode as NOOP if REX.b is set. Instead > >> + * it should decode as XCHG %r8, %eax. > >> + */ > >> + > >> + const struct InstructionSpecifier *spec; > >> + uint16_t instructionIDWithNewOpcode; > >> + const struct InstructionSpecifier *specWithNewOpcode; > >> + > >> + spec = specifierForUID(instructionID); > >> + > >> + // Borrow opcode from one of the other XCHGar opcodes > >> + insn->opcode = 0x91; > >> + > >> + if (getIDWithAttrMask(&instructionIDWithNewOpcode, > >> + insn, > >> + attrMask)) { > >> + insn->opcode = 0x90; > >> + > >> + insn->instructionID = instructionID; > >> + insn->spec = spec; > >> + return 0; > >> + } > >> + > >> + specWithNewOpcode = specifierForUID(instructionIDWithNewOpcode); > >> + > >> + // Change back > >> + insn->opcode = 0x90; > >> + > >> + insn->instructionID = instructionIDWithNewOpcode; > >> + insn->spec = specWithNewOpcode; > >> + > >> + return 0; > >> + } > >> > >> insn->instructionID = instructionID; > >> insn->spec = specifierForUID(insn->instructionID); > >> > >> Modified: llvm/trunk/test/MC/Disassembler/X86/simple-tests.txt > >> URL: > >> > >> > http://llvm.org/viewvc/llvm-project/llvm/trunk/test/MC/Disassembler/X86/simp > >> le-tests.txt?rev=140971&r1=140970&r2=140971&view=diff > >> > >> > ============================================================================ > >> == > >> --- llvm/trunk/test/MC/Disassembler/X86/simple-tests.txt (original) > >> +++ llvm/trunk/test/MC/Disassembler/X86/simple-tests.txt Sun Oct 2 > >> 11:56:09 > >> 2011 > >> @@ -308,3 +308,6 @@ > >> > >> # CHECK: invvpid (%rax), %rax > >> 0x66 0x0f 0x38 0x81 0x00 > >> + > >> +# CHECK: xchgl %r8d, %eax > >> +0x41 0x90 > >> > >> > >> _______________________________________________ > >> llvm-commits mailing list > >> llvm-commits at cs.uiuc.edu > >> http://lists.cs.uiuc.edu/mailman/listinfo/llvm-commits > >> > >> > >> > >> > > > > > > > > -- > > ~Craig > > > > _______________________________________________ > > llvm-commits mailing list > > llvm-commits at cs.uiuc.edu > > http://lists.cs.uiuc.edu/mailman/listinfo/llvm-commits > > > > > -- ~Craig -------------- next part -------------- An HTML attachment was scrubbed... URL: http://lists.cs.uiuc.edu/pipermail/llvm-commits/attachments/20111004/acebddf5/attachment.html From echristo at apple.com Tue Oct 4 22:56:19 2011 From: echristo at apple.com (Eric Christopher) Date: Tue, 04 Oct 2011 20:56:19 -0700 Subject: [llvm-commits] [llvm] r141161 - /llvm/trunk/lib/Analysis/ScalarEvolution.cpp In-Reply-To: <20111005032535.290952A6C12C@llvm.org> References: <20111005032535.290952A6C12C@llvm.org> Message-ID: On Oct 4, 2011, at 8:25 PM, Andrew Trick wrote: > Fixes rdar://10187945. Was taking 45s, now taking 5ms. Excellent! -eric -------------- next part -------------- An HTML attachment was scrubbed... URL: http://lists.cs.uiuc.edu/pipermail/llvm-commits/attachments/20111004/d02dbbae/attachment.html From echristo at apple.com Wed Oct 5 00:00:27 2011 From: echristo at apple.com (Eric Christopher) Date: Wed, 05 Oct 2011 05:00:27 -0000 Subject: [llvm-commits] [llvm] r141163 - /llvm/trunk/lib/Support/PrettyStackTrace.cpp Message-ID: <20111005050027.BDF5B2A6C12C@llvm.org> Author: echristo Date: Wed Oct 5 00:00:26 2011 New Revision: 141163 URL: http://llvm.org/viewvc/llvm-project?rev=141163&view=rev Log: Add more initializers to quiet a clang warning. Modified: llvm/trunk/lib/Support/PrettyStackTrace.cpp Modified: llvm/trunk/lib/Support/PrettyStackTrace.cpp URL: http://llvm.org/viewvc/llvm-project/llvm/trunk/lib/Support/PrettyStackTrace.cpp?rev=141163&r1=141162&r2=141163&view=diff ============================================================================== --- llvm/trunk/lib/Support/PrettyStackTrace.cpp (original) +++ llvm/trunk/lib/Support/PrettyStackTrace.cpp Wed Oct 5 00:00:26 2011 @@ -62,7 +62,7 @@ CRASH_REPORTER_CLIENT_HIDDEN struct crashreporter_annotations_t gCRAnnotations __attribute__((section("__DATA," CRASHREPORTER_ANNOTATIONS_SECTION))) - = { CRASHREPORTER_ANNOTATIONS_VERSION, 0, 0, 0, 0 }; + = { CRASHREPORTER_ANNOTATIONS_VERSION, 0, 0, 0, 0, 0, 0 }; } #elif defined (__APPLE__) && HAVE_CRASHREPORTER_INFO static const char *__crashreporter_info__ = 0; From atrick at apple.com Wed Oct 5 00:58:50 2011 From: atrick at apple.com (Andrew Trick) Date: Wed, 05 Oct 2011 05:58:50 -0000 Subject: [llvm-commits] [llvm] r141164 - /llvm/trunk/lib/Analysis/ScalarEvolution.cpp Message-ID: <20111005055851.46ACE2A6C12C@llvm.org> Author: atrick Date: Wed Oct 5 00:58:49 2011 New Revision: 141164 URL: http://llvm.org/viewvc/llvm-project?rev=141164&view=rev Log: Fix disabled SCEV analysis caused r141161 and add unit test. I noticed during self-review that my previous checkin disabled some analysis. Even with the reenabled analysis the test case runs in about 5ms. Without the fix, it will take several minutes at least. Modified: llvm/trunk/lib/Analysis/ScalarEvolution.cpp Modified: llvm/trunk/lib/Analysis/ScalarEvolution.cpp URL: http://llvm.org/viewvc/llvm-project/llvm/trunk/lib/Analysis/ScalarEvolution.cpp?rev=141164&r1=141163&r2=141164&view=diff ============================================================================== --- llvm/trunk/lib/Analysis/ScalarEvolution.cpp (original) +++ llvm/trunk/lib/Analysis/ScalarEvolution.cpp Wed Oct 5 00:58:49 2011 @@ -4691,7 +4691,7 @@ /// recursing through each instruction operand until reaching a loop header phi. static PHINode * getConstantEvolvingPHIOperands(Instruction *UseInst, const Loop *L, - SmallPtrSet &Visited) { + DenseMap &PHIMap) { // Otherwise, we can evaluate this instruction if all of its operands are // constant or derived from a PHI node themselves. @@ -4705,18 +4705,26 @@ if (!OpInst || !canConstantEvolve(OpInst, L)) return 0; PHINode *P = dyn_cast(OpInst); - if (!P) { - // If this operand is already visited, ignore it. It's evolving phi has - // already been shown to be consistent on the first path that reached it. - if (!Visited.insert(OpInst)) continue; - - P = getConstantEvolvingPHIOperands(OpInst, L, Visited); + if (P) { + if (PHI && PHI != P) return 0; // Evolving from multiple different PHIs. + PHI = P; + continue; } - if (P == 0) return 0; // Not evolving from PHI - if (PHI == 0) + + // If this operand is already visited, reuse the prior result. + P = PHIMap.lookup(OpInst); + if (P) { + assert(!PHI || P == PHI && "inconsitent data flow"); PHI = P; - else if (PHI != P) - return 0; // Evolving from multiple different PHIs. + continue; + } + // Recurse and memoize the results, whether a phi is found or not. + // This recursive call invalidates pointers into PHIMap. + P = getConstantEvolvingPHIOperands(OpInst, L, PHIMap); + PHIMap[OpInst] = P; + if (P == 0) return 0; // Not evolving from PHI + if (PHI && PHI != P) return 0; // Evolving from multiple different PHIs. + PHI = P; } // This is a expression evolving from a constant PHI! return PHI; @@ -4736,9 +4744,8 @@ } // Record non-constant instructions contained by the loop. - SmallPtrSet Visited; - Visited.insert(I); - return getConstantEvolvingPHIOperands(I, L, Visited); + DenseMap PHIMap; + return getConstantEvolvingPHIOperands(I, L, PHIMap); } /// EvaluateExpression - Given an expression that passes the @@ -4748,6 +4755,7 @@ static Constant *EvaluateExpression(Value *V, const Loop *L, DenseMap &Vals, const TargetData *TD) { + // Convenient constant check, but redundant for recursive calls. if (Constant *C = dyn_cast(V)) return C; Instruction *I = cast(V); @@ -4760,8 +4768,15 @@ std::vector Operands(I->getNumOperands()); for (unsigned i = 0, e = I->getNumOperands(); i != e; ++i) { - Operands[i] = EvaluateExpression(I->getOperand(i), L, Vals, TD); - if (Operands[i] == 0) return 0; + Instruction *Operand = dyn_cast(I->getOperand(i)); + if (!Operand) { + Operands[i] = cast(I->getOperand(i)); + continue; + } + Constant *C = EvaluateExpression(Operand, L, Vals, TD); + Vals[Operand] = C; + if (!C) return 0; + Operands[i] = C; } if (const CmpInst *CI = dyn_cast(I)) @@ -4861,9 +4876,9 @@ // "ExitWhen". unsigned IterationNum = 0; unsigned MaxIterations = MaxBruteForceIterations; // Limit analysis. - DenseMap PHIValMap; for (Constant *PHIVal = StartCST; IterationNum != MaxIterations; ++IterationNum) { + DenseMap PHIValMap; PHIValMap[PN] = PHIVal; ConstantInt *CondVal = dyn_cast_or_null(EvaluateExpression(Cond, L, PHIValMap, TD)); From nicholas at mxc.ca Wed Oct 5 01:10:07 2011 From: nicholas at mxc.ca (Nick Lewycky) Date: Tue, 04 Oct 2011 23:10:07 -0700 Subject: [llvm-commits] [llvm] r141161 - /llvm/trunk/lib/Analysis/ScalarEvolution.cpp In-Reply-To: <20111005032535.290952A6C12C@llvm.org> References: <20111005032535.290952A6C12C@llvm.org> Message-ID: <4E8BF4BF.7060502@mxc.ca> On 10/04/2011 08:25 PM, Andrew Trick wrote: > Author: atrick > Date: Tue Oct 4 22:25:31 2011 > New Revision: 141161 > > URL: http://llvm.org/viewvc/llvm-project?rev=141161&view=rev > Log: > Avoid exponential recursion in SCEV getConstantEvolvingPHI and EvaluateExpression. > > Note to compiler writers: never recurse on multiple instruction > operands without memoization. > Fixes rdar://10187945. Was taking 45s, now taking 5ms. Ugh. Sorry for adding this, I really didn't think this would be a problem in practice. Thanks for handling the fallout! Feel free to ask me to clean up my own performance problems too, if you like :) Nick From atrick at apple.com Wed Oct 5 01:18:07 2011 From: atrick at apple.com (Andrew Trick) Date: Tue, 04 Oct 2011 23:18:07 -0700 Subject: [llvm-commits] [llvm] r141161 - /llvm/trunk/lib/Analysis/ScalarEvolution.cpp In-Reply-To: <4E8BF4BF.7060502@mxc.ca> References: <20111005032535.290952A6C12C@llvm.org> <4E8BF4BF.7060502@mxc.ca> Message-ID: <4E81504D-4D44-4133-83CA-50279F9A8BF5@apple.com> On Oct 4, 2011, at 11:10 PM, Nick Lewycky wrote: > On 10/04/2011 08:25 PM, Andrew Trick wrote: >> Author: atrick >> Date: Tue Oct 4 22:25:31 2011 >> New Revision: 141161 >> >> URL: http://llvm.org/viewvc/llvm-project?rev=141161&view=rev >> Log: >> Avoid exponential recursion in SCEV getConstantEvolvingPHI and EvaluateExpression. >> >> Note to compiler writers: never recurse on multiple instruction >> operands without memoization. >> Fixes rdar://10187945. Was taking 45s, now taking 5ms. > > Ugh. Sorry for adding this, I really didn't think this would be a problem in practice. Thanks for handling the fallout! Feel free to ask me to clean up my own performance problems too, if you like :) Now I know who it was... I think a fair penalty would be to find any other places where we make recursive calls on operands or use lists without a visited set. After all, they're fun to fix. Incidentally, you'll see my fix is nicely compatible with your proposed patch to the same code. -Andy From atrick at apple.com Wed Oct 5 01:23:34 2011 From: atrick at apple.com (Andrew Trick) Date: Wed, 05 Oct 2011 06:23:34 -0000 Subject: [llvm-commits] [llvm] r141166 - /llvm/trunk/test/Analysis/ScalarEvolution/2011-10-04-ConstEvolve.ll Message-ID: <20111005062335.B712D2A6C12C@llvm.org> Author: atrick Date: Wed Oct 5 01:23:32 2011 New Revision: 141166 URL: http://llvm.org/viewvc/llvm-project?rev=141166&view=rev Log: Missing test case for r141164. Added: llvm/trunk/test/Analysis/ScalarEvolution/2011-10-04-ConstEvolve.ll Added: llvm/trunk/test/Analysis/ScalarEvolution/2011-10-04-ConstEvolve.ll URL: http://llvm.org/viewvc/llvm-project/llvm/trunk/test/Analysis/ScalarEvolution/2011-10-04-ConstEvolve.ll?rev=141166&view=auto ============================================================================== --- llvm/trunk/test/Analysis/ScalarEvolution/2011-10-04-ConstEvolve.ll (added) +++ llvm/trunk/test/Analysis/ScalarEvolution/2011-10-04-ConstEvolve.ll Wed Oct 5 01:23:32 2011 @@ -0,0 +1,50 @@ +; RUN: opt < %s -analyze -scalar-evolution | FileCheck %s + +; Exercise getConstantEvolvingPHIOperands on an interesting loop. +; This should complete in milliseconds, not minutes. + +; Just check that it actually ran trip count analysis. +; CHECK: Determining loop execution counts for: @test +define void @test() nounwind { +entry: + br label %loop + +loop: + %iv = phi i32 [ %30, %loop ], [ 0, %entry ] + %0 = add i32 %iv, 1 + %1 = add i32 %0, 2 + %2 = add i32 %1, %0 + %3 = add i32 %2, %1 + %4 = add i32 %3, %2 + %5 = add i32 %4, %3 + %6 = add i32 %5, %4 + %7 = add i32 %6, %5 + %8 = add i32 %7, %6 + %9 = add i32 %8, %7 + %10 = add i32 %9, %8 + %11 = add i32 %10, %9 + %12 = add i32 %11, %10 + %13 = add i32 %12, %11 + %14 = add i32 %13, %12 + %15 = add i32 %14, %13 + %16 = add i32 %15, %14 + %17 = add i32 %16, %15 + %18 = add i32 %17, %16 + %19 = add i32 %18, %17 + %20 = add i32 %19, %18 + %21 = add i32 %20, %19 + %22 = add i32 %21, %20 + %23 = add i32 %22, %21 + %24 = add i32 %23, %22 + %25 = add i32 %24, %23 + %26 = add i32 %25, %24 + %27 = add i32 %26, %25 + %28 = add i32 %27, %26 + %29 = add i32 %28, %27 + %30 = add i32 %29, %28 + %cmp = icmp eq i32 %30, -108 + br i1 %cmp, label %exit, label %loop + +exit: + unreachable +} From nicholas at mxc.ca Wed Oct 5 01:25:34 2011 From: nicholas at mxc.ca (Nick Lewycky) Date: Tue, 04 Oct 2011 23:25:34 -0700 Subject: [llvm-commits] [llvm] r141161 - /llvm/trunk/lib/Analysis/ScalarEvolution.cpp In-Reply-To: <4E81504D-4D44-4133-83CA-50279F9A8BF5@apple.com> References: <20111005032535.290952A6C12C@llvm.org> <4E8BF4BF.7060502@mxc.ca> <4E81504D-4D44-4133-83CA-50279F9A8BF5@apple.com> Message-ID: <4E8BF85E.5070600@mxc.ca> On 10/04/2011 11:18 PM, Andrew Trick wrote: > On Oct 4, 2011, at 11:10 PM, Nick Lewycky wrote: > >> On 10/04/2011 08:25 PM, Andrew Trick wrote: >>> Author: atrick >>> Date: Tue Oct 4 22:25:31 2011 >>> New Revision: 141161 >>> >>> URL: http://llvm.org/viewvc/llvm-project?rev=141161&view=rev >>> Log: >>> Avoid exponential recursion in SCEV getConstantEvolvingPHI and EvaluateExpression. >>> >>> Note to compiler writers: never recurse on multiple instruction >>> operands without memoization. >>> Fixes rdar://10187945. Was taking 45s, now taking 5ms. >> >> Ugh. Sorry for adding this, I really didn't think this would be a problem in practice. Thanks for handling the fallout! Feel free to ask me to clean up my own performance problems too, if you like :) > > > Now I know who it was... I think a fair penalty would be to find any other places where we make recursive calls on operands or use lists without a visited set. After all, they're fun to fix. > > Incidentally, you'll see my fix is nicely compatible with your proposed patch to the same code. Wait, proposed patch? Doh! This is the code I *haven't* committed the patch for yet! Never mind, forget I said anything :) And yes, this dovetails nicely with my proposed patch, so I suppose I should get on merging. :) Nick From spop at codeaurora.org Tue Oct 4 18:12:48 2011 From: spop at codeaurora.org (Sebastian Pop) Date: Tue, 4 Oct 2011 18:12:48 -0500 Subject: [llvm-commits] [polly] r141067 - in /polly/trunk: autoconf/configure.ac configure In-Reply-To: <20111004065504.10C892A6C12C@llvm.org> References: <20111004065504.10C892A6C12C@llvm.org> Message-ID: On Tue, Oct 4, 2011 at 1:55 AM, Tobias Grosser wrote: > > Author: grosser > Date: Tue Oct ?4 01:55:03 2011 > New Revision: 141067 > > URL: http://llvm.org/viewvc/llvm-project?rev=141067&view=rev > Log: > configure: Add gmp_inc when checking for CLooG > > Otherwise configure fails if gmp is installed in a non default location. Your patch looks good. Thanks Tobi for fixing this. I also got bitten by this one a few weeks ago ;-) Sebastian Pop -- Qualcomm Innovation Center, Inc is a member of Code Aurora Forum From chandlerc at gmail.com Wed Oct 5 02:02:24 2011 From: chandlerc at gmail.com (Chandler Carruth) Date: Wed, 05 Oct 2011 07:02:24 -0000 Subject: [llvm-commits] [llvm] r141168 - /llvm/trunk/lib/Analysis/ScalarEvolution.cpp Message-ID: <20111005070224.7C9262A6C12C@llvm.org> Author: chandlerc Date: Wed Oct 5 02:02:23 2011 New Revision: 141168 URL: http://llvm.org/viewvc/llvm-project?rev=141168&view=rev Log: Fix a broken assert found by -Wparentheses. Modified: llvm/trunk/lib/Analysis/ScalarEvolution.cpp Modified: llvm/trunk/lib/Analysis/ScalarEvolution.cpp URL: http://llvm.org/viewvc/llvm-project/llvm/trunk/lib/Analysis/ScalarEvolution.cpp?rev=141168&r1=141167&r2=141168&view=diff ============================================================================== --- llvm/trunk/lib/Analysis/ScalarEvolution.cpp (original) +++ llvm/trunk/lib/Analysis/ScalarEvolution.cpp Wed Oct 5 02:02:23 2011 @@ -4714,7 +4714,7 @@ // If this operand is already visited, reuse the prior result. P = PHIMap.lookup(OpInst); if (P) { - assert(!PHI || P == PHI && "inconsitent data flow"); + assert((!PHI || P == PHI) && "inconsitent data flow"); PHI = P; continue; } From isanbard at gmail.com Wed Oct 5 02:04:14 2011 From: isanbard at gmail.com (Bill Wendling) Date: Wed, 05 Oct 2011 07:04:14 -0000 Subject: [llvm-commits] [llvm] r141169 - /llvm/trunk/lib/Bitcode/Reader/BitcodeReader.cpp Message-ID: <20111005070414.D9F252A6C12C@llvm.org> Author: void Date: Wed Oct 5 02:04:14 2011 New Revision: 141169 URL: http://llvm.org/viewvc/llvm-project?rev=141169&view=rev Log: Also update the EH with bitcode. I missed this earlier. Thanks to Duncan for pointing it out. Modified: llvm/trunk/lib/Bitcode/Reader/BitcodeReader.cpp Modified: llvm/trunk/lib/Bitcode/Reader/BitcodeReader.cpp URL: http://llvm.org/viewvc/llvm-project/llvm/trunk/lib/Bitcode/Reader/BitcodeReader.cpp?rev=141169&r1=141168&r2=141169&view=diff ============================================================================== --- llvm/trunk/lib/Bitcode/Reader/BitcodeReader.cpp (original) +++ llvm/trunk/lib/Bitcode/Reader/BitcodeReader.cpp Wed Oct 5 02:04:14 2011 @@ -2939,6 +2939,9 @@ } std::vector >().swap(UpgradedIntrinsics); + // Upgrade to new EH scheme. N.B. This will go away in 3.1. + UpgradeExceptionHandling(M); + // Check debug info intrinsics. CheckDebugInfoIntrinsics(TheModule); From baldrick at free.fr Wed Oct 5 02:59:00 2011 From: baldrick at free.fr (Duncan Sands) Date: Wed, 05 Oct 2011 09:59:00 +0200 Subject: [llvm-commits] [llvm] r141125 - in /llvm/trunk/lib/CodeGen/SelectionDAG: SelectionDAGBuilder.cpp SelectionDAGBuilder.h In-Reply-To: <20111004220036.77EFE2A6C12C@llvm.org> References: <20111004220036.77EFE2A6C12C@llvm.org> Message-ID: <4E8C0E44.4080907@free.fr> Hi Bill, > Create a mapping between the landing pad basic block and the call site index for later use. can't multiple call sites (i.e. invokes) have the same landing pad? So mapping from landingpad to call site doesn't make any sense to me... Ciao, Duncan. > > Modified: > llvm/trunk/lib/CodeGen/SelectionDAG/SelectionDAGBuilder.cpp > llvm/trunk/lib/CodeGen/SelectionDAG/SelectionDAGBuilder.h > > Modified: llvm/trunk/lib/CodeGen/SelectionDAG/SelectionDAGBuilder.cpp > URL: http://llvm.org/viewvc/llvm-project/llvm/trunk/lib/CodeGen/SelectionDAG/SelectionDAGBuilder.cpp?rev=141125&r1=141124&r2=141125&view=diff > ============================================================================== > --- llvm/trunk/lib/CodeGen/SelectionDAG/SelectionDAGBuilder.cpp (original) > +++ llvm/trunk/lib/CodeGen/SelectionDAG/SelectionDAGBuilder.cpp Tue Oct 4 17:00:35 2011 > @@ -5250,6 +5250,8 @@ > unsigned CallSiteIndex = MMI.getCurrentCallSite(); > if (CallSiteIndex) { > MMI.setCallSiteBeginLabel(BeginLabel, CallSiteIndex); > + LPadToCallSiteMap[LandingPad] = CallSiteIndex; > + > // Now that the call site is handled, stop tracking it. > MMI.setCurrentCallSite(0); > } > > Modified: llvm/trunk/lib/CodeGen/SelectionDAG/SelectionDAGBuilder.h > URL: http://llvm.org/viewvc/llvm-project/llvm/trunk/lib/CodeGen/SelectionDAG/SelectionDAGBuilder.h?rev=141125&r1=141124&r2=141125&view=diff > ============================================================================== > --- llvm/trunk/lib/CodeGen/SelectionDAG/SelectionDAGBuilder.h (original) > +++ llvm/trunk/lib/CodeGen/SelectionDAG/SelectionDAGBuilder.h Tue Oct 4 17:00:35 2011 > @@ -320,6 +320,9 @@ > /// GFI - Garbage collection metadata for the function. > GCFunctionInfo *GFI; > > + /// LPadToBeginLabelMap - Map a landing pad to the begin label. > + DenseMap LPadToCallSiteMap; > + > /// HasTailCall - This is set to true if a call in the current > /// block has been translated as a tail call. In this case, > /// no subsequent DAG nodes should be created. > > > _______________________________________________ > llvm-commits mailing list > llvm-commits at cs.uiuc.edu > http://lists.cs.uiuc.edu/mailman/listinfo/llvm-commits From atrick at apple.com Wed Oct 5 03:10:10 2011 From: atrick at apple.com (Andrew Trick) Date: Wed, 05 Oct 2011 01:10:10 -0700 Subject: [llvm-commits] [llvm] r141168 - /llvm/trunk/lib/Analysis/ScalarEvolution.cpp In-Reply-To: <20111005070224.7C9262A6C12C@llvm.org> References: <20111005070224.7C9262A6C12C@llvm.org> Message-ID: <3347318B-3753-4C2D-A579-A48AF4102E4E@apple.com> Thanks for cleaning up. But broken? No, I just can't train myself to insert redundant parens in this idiom. GCC users will have to keep cleaning it up, or file a bug against gcc to silence a useless warning, or introduce proper assert macros in LLVM. Andy On Oct 5, 2011, at 12:02 AM, Chandler Carruth wrote: > Author: chandlerc > Date: Wed Oct 5 02:02:23 2011 > New Revision: 141168 > > URL: http://llvm.org/viewvc/llvm-project?rev=141168&view=rev > Log: > Fix a broken assert found by -Wparentheses. > > Modified: > llvm/trunk/lib/Analysis/ScalarEvolution.cpp > > Modified: llvm/trunk/lib/Analysis/ScalarEvolution.cpp > URL: http://llvm.org/viewvc/llvm-project/llvm/trunk/lib/Analysis/ScalarEvolution.cpp?rev=141168&r1=141167&r2=141168&view=diff > ============================================================================== > --- llvm/trunk/lib/Analysis/ScalarEvolution.cpp (original) > +++ llvm/trunk/lib/Analysis/ScalarEvolution.cpp Wed Oct 5 02:02:23 2011 > @@ -4714,7 +4714,7 @@ > // If this operand is already visited, reuse the prior result. > P = PHIMap.lookup(OpInst); > if (P) { > - assert(!PHI || P == PHI && "inconsitent data flow"); > + assert((!PHI || P == PHI) && "inconsitent data flow"); > PHI = P; > continue; > } > > > _______________________________________________ > llvm-commits mailing list > llvm-commits at cs.uiuc.edu > http://lists.cs.uiuc.edu/mailman/listinfo/llvm-commits From chandlerc at gmail.com Wed Oct 5 03:20:08 2011 From: chandlerc at gmail.com (Chandler Carruth) Date: Wed, 5 Oct 2011 01:20:08 -0700 Subject: [llvm-commits] [llvm] r141168 - /llvm/trunk/lib/Analysis/ScalarEvolution.cpp In-Reply-To: <3347318B-3753-4C2D-A579-A48AF4102E4E@apple.com> References: <20111005070224.7C9262A6C12C@llvm.org> <3347318B-3753-4C2D-A579-A48AF4102E4E@apple.com> Message-ID: On Wed, Oct 5, 2011 at 1:10 AM, Andrew Trick wrote: > Thanks for cleaning up. But broken? No, I just can't train myself to insert > redundant parens in this idiom. Heh, and on the other side it took me thinking about this more than I like admitting to convince myself that indeed, ((X || Y) && "...") is equivalent to (X || (Y && "..."))... Oh well, probably means that's enough coding for one evening. ;] -------------- next part -------------- An HTML attachment was scrubbed... URL: http://lists.cs.uiuc.edu/pipermail/llvm-commits/attachments/20111005/b92e3938/attachment.html From zwarich at apple.com Wed Oct 5 03:59:11 2011 From: zwarich at apple.com (Cameron Zwarich) Date: Wed, 05 Oct 2011 08:59:11 -0000 Subject: [llvm-commits] [llvm] r141173 - /llvm/trunk/lib/Target/ARM/ARMISelDAGToDAG.cpp Message-ID: <20111005085911.344A72A6C12E@llvm.org> Author: zwarich Date: Wed Oct 5 03:59:10 2011 New Revision: 141173 URL: http://llvm.org/viewvc/llvm-project?rev=141173&view=rev Log: Add braces around something that throws me for a loop. Modified: llvm/trunk/lib/Target/ARM/ARMISelDAGToDAG.cpp Modified: llvm/trunk/lib/Target/ARM/ARMISelDAGToDAG.cpp URL: http://llvm.org/viewvc/llvm-project/llvm/trunk/lib/Target/ARM/ARMISelDAGToDAG.cpp?rev=141173&r1=141172&r2=141173&view=diff ============================================================================== --- llvm/trunk/lib/Target/ARM/ARMISelDAGToDAG.cpp (original) +++ llvm/trunk/lib/Target/ARM/ARMISelDAGToDAG.cpp Wed Oct 5 03:59:10 2011 @@ -519,9 +519,10 @@ return false; } - if (Subtarget->isCortexA9() && !N.hasOneUse()) + if (Subtarget->isCortexA9() && !N.hasOneUse()) { // Compute R +/- (R << N) and reuse it. return false; + } // Otherwise this is R +/- [possibly shifted] R. ARM_AM::AddrOpc AddSub = N.getOpcode() == ISD::SUB ? ARM_AM::sub:ARM_AM::add; From zwarich at apple.com Wed Oct 5 03:59:06 2011 From: zwarich at apple.com (Cameron Zwarich) Date: Wed, 05 Oct 2011 08:59:06 -0000 Subject: [llvm-commits] [llvm] r141172 - /llvm/trunk/lib/Target/ARM/ARMISelDAGToDAG.cpp Message-ID: <20111005085907.623482A6C12D@llvm.org> Author: zwarich Date: Wed Oct 5 03:59:05 2011 New Revision: 141172 URL: http://llvm.org/viewvc/llvm-project?rev=141172&view=rev Log: There is no point in setting out-parameters for a ComplexPattern function when it returns false, at least as far as I could tell by reading the code. Modified: llvm/trunk/lib/Target/ARM/ARMISelDAGToDAG.cpp Modified: llvm/trunk/lib/Target/ARM/ARMISelDAGToDAG.cpp URL: http://llvm.org/viewvc/llvm-project/llvm/trunk/lib/Target/ARM/ARMISelDAGToDAG.cpp?rev=141172&r1=141171&r2=141172&view=diff ============================================================================== --- llvm/trunk/lib/Target/ARM/ARMISelDAGToDAG.cpp (original) +++ llvm/trunk/lib/Target/ARM/ARMISelDAGToDAG.cpp Wed Oct 5 03:59:05 2011 @@ -1287,7 +1287,6 @@ if (Subtarget->isCortexA9() && !N.hasOneUse()) { // Compute R + (R << [1,2,3]) and reuse it. - Base = N; return false; } From geek4civic at gmail.com Wed Oct 5 05:11:03 2011 From: geek4civic at gmail.com (NAKAMURA Takumi) Date: Wed, 05 Oct 2011 10:11:03 -0000 Subject: [llvm-commits] [llvm] r141174 - /llvm/trunk/lib/Target/Mips/MipsDelaySlotFiller.cpp Message-ID: <20111005101103.881942A6C12C@llvm.org> Author: chapuni Date: Wed Oct 5 05:11:02 2011 New Revision: 141174 URL: http://llvm.org/viewvc/llvm-project?rev=141174&view=rev Log: MipsDelaySlotFiller.cpp: Appease msvc to specify llvm::next() explicitly. Modified: llvm/trunk/lib/Target/Mips/MipsDelaySlotFiller.cpp Modified: llvm/trunk/lib/Target/Mips/MipsDelaySlotFiller.cpp URL: http://llvm.org/viewvc/llvm-project/llvm/trunk/lib/Target/Mips/MipsDelaySlotFiller.cpp?rev=141174&r1=141173&r2=141174&view=diff ============================================================================== --- llvm/trunk/lib/Target/Mips/MipsDelaySlotFiller.cpp (original) +++ llvm/trunk/lib/Target/Mips/MipsDelaySlotFiller.cpp Wed Oct 5 05:11:02 2011 @@ -140,7 +140,7 @@ continue; // Convert to forward iterator. - MachineBasicBlock::iterator FI(next(I).base()); + MachineBasicBlock::iterator FI(llvm::next(I).base()); if (I->hasUnmodeledSideEffects() || I->isInlineAsm() From baldrick at free.fr Wed Oct 5 08:10:02 2011 From: baldrick at free.fr (Duncan Sands) Date: Wed, 05 Oct 2011 13:10:02 -0000 Subject: [llvm-commits] [test-suite] r141175 - /test-suite/trunk/MultiSource/Benchmarks/tramp3d-v4/tramp3d-v4.cpp Message-ID: <20111005131003.1D6842A6C12C@llvm.org> Author: baldrick Date: Wed Oct 5 08:10:01 2011 New Revision: 141175 URL: http://llvm.org/viewvc/llvm-project?rev=141175&view=rev Log: Get this compiling with gcc-4.6, which did some more header trimming. Modified: test-suite/trunk/MultiSource/Benchmarks/tramp3d-v4/tramp3d-v4.cpp Modified: test-suite/trunk/MultiSource/Benchmarks/tramp3d-v4/tramp3d-v4.cpp URL: http://llvm.org/viewvc/llvm-project/test-suite/trunk/MultiSource/Benchmarks/tramp3d-v4/tramp3d-v4.cpp?rev=141175&r1=141174&r2=141175&view=diff ============================================================================== --- test-suite/trunk/MultiSource/Benchmarks/tramp3d-v4/tramp3d-v4.cpp (original) +++ test-suite/trunk/MultiSource/Benchmarks/tramp3d-v4/tramp3d-v4.cpp Wed Oct 5 08:10:01 2011 @@ -1,4 +1,5 @@ #include +#include #include #include #include From edwintorok at gmail.com Wed Oct 5 08:12:20 2011 From: edwintorok at gmail.com (=?ISO-8859-1?Q?T=F6r=F6k_Edwin?=) Date: Wed, 05 Oct 2011 16:12:20 +0300 Subject: [llvm-commits] [PATCH] OCaml/C bindings updates Message-ID: <4E8C57B4.8060705@gmail.com> Hi, Attached is a series of patches to bring the OCaml bindings in sync with the C bindings, they are mostly trivial changes. Even with these patches there are some C bindings that are not yet exposed in the OCaml bindings for various reasons, I will try to add more bindings as I find them. Some patches also add C bindings: LLVMTypeIsSized, LLVMGetStructName, LLVMGetInstructionOpcode, LLVMGetICmpPredicate, LLVMGetMDString, LLVMGetMDNumOperands, LLVMGetMDNodeOperand, LLVMGetNamedMetadataNumOperands, LLVMGetNamedMetadataOperands. These allow the OCaml bindings to be usable for analyzing LLVM IR, not just emitting LLVM IR. These are the trivial patches, I intend to commit them (after compile-testing each) unless there are objections: 0001-add-tests.patch 0002-Don-t-require-C-bindings-opcode-numbers-to-be-kept-i.patch 0005-ocaml-bindings-add-llvm_ipo-based-on-IPO.h.patch 0007-C-OCaml-API-to-retrieve-struct-name.patch 0009-ocaml-C-bindings-getmdstring-add-num_op-get_op-shoul.patch 0010-add-binding-to-read-icmp-predicate.patch 0011-ocaml-C-bindings-type-isSized.patch 0013-Add-uwtable-returnstwice-and-nonlazybind-to-the-C-bi.patch These patches are somewhat larger, but mostly mechanical. Wouldn't hurt if someone else double-checkes them though: 0003-ocaml-bindings-add-getopcode-for-constant-and-instru.patch 0014-OCaml-bindings-add-some-missing-functions-and-testca.patch And finally these are the patches which would need review: 0004-ocaml-bindings-introduce-classify_value.patch 0006-ocaml-bindings-add-findlib-META-support.patch 0008-fix-infinite-recursion-on-string_of_lltype.patch 0012-OCaml-bindings-fix-attributes-to-use-all-32-bits.patch Best regards, --Edwin -------------- next part -------------- A non-text attachment was scrubbed... Name: 0001-add-tests.patch Type: text/x-patch Size: 11031 bytes Desc: not available Url : http://lists.cs.uiuc.edu/pipermail/llvm-commits/attachments/20111005/fa746572/attachment-0014.bin -------------- next part -------------- A non-text attachment was scrubbed... Name: 0002-Don-t-require-C-bindings-opcode-numbers-to-be-kept-i.patch Type: text/x-patch Size: 3493 bytes Desc: not available Url : http://lists.cs.uiuc.edu/pipermail/llvm-commits/attachments/20111005/fa746572/attachment-0015.bin -------------- next part -------------- A non-text attachment was scrubbed... Name: 0003-ocaml-bindings-add-getopcode-for-constant-and-instru.patch Type: text/x-patch Size: 9087 bytes Desc: not available Url : http://lists.cs.uiuc.edu/pipermail/llvm-commits/attachments/20111005/fa746572/attachment-0016.bin -------------- next part -------------- A non-text attachment was scrubbed... Name: 0004-ocaml-bindings-introduce-classify_value.patch Type: text/x-patch Size: 8057 bytes Desc: not available Url : http://lists.cs.uiuc.edu/pipermail/llvm-commits/attachments/20111005/fa746572/attachment-0017.bin -------------- next part -------------- A non-text attachment was scrubbed... Name: 0005-ocaml-bindings-add-llvm_ipo-based-on-IPO.h.patch Type: text/x-patch Size: 13711 bytes Desc: not available Url : http://lists.cs.uiuc.edu/pipermail/llvm-commits/attachments/20111005/fa746572/attachment-0018.bin -------------- next part -------------- A non-text attachment was scrubbed... Name: 0006-ocaml-bindings-add-findlib-META-support.patch Type: text/x-patch Size: 4459 bytes Desc: not available Url : http://lists.cs.uiuc.edu/pipermail/llvm-commits/attachments/20111005/fa746572/attachment-0019.bin -------------- next part -------------- A non-text attachment was scrubbed... Name: 0007-C-OCaml-API-to-retrieve-struct-name.patch Type: text/x-patch Size: 4030 bytes Desc: not available Url : http://lists.cs.uiuc.edu/pipermail/llvm-commits/attachments/20111005/fa746572/attachment-0020.bin -------------- next part -------------- A non-text attachment was scrubbed... Name: 0008-fix-infinite-recursion-on-string_of_lltype.patch Type: text/x-patch Size: 2043 bytes Desc: not available Url : http://lists.cs.uiuc.edu/pipermail/llvm-commits/attachments/20111005/fa746572/attachment-0021.bin -------------- next part -------------- A non-text attachment was scrubbed... Name: 0009-ocaml-C-bindings-getmdstring-add-num_op-get_op-shoul.patch Type: text/x-patch Size: 6663 bytes Desc: not available Url : http://lists.cs.uiuc.edu/pipermail/llvm-commits/attachments/20111005/fa746572/attachment-0022.bin -------------- next part -------------- A non-text attachment was scrubbed... Name: 0010-add-binding-to-read-icmp-predicate.patch Type: text/x-patch Size: 3523 bytes Desc: not available Url : http://lists.cs.uiuc.edu/pipermail/llvm-commits/attachments/20111005/fa746572/attachment-0023.bin -------------- next part -------------- A non-text attachment was scrubbed... Name: 0011-ocaml-C-bindings-type-isSized.patch Type: text/x-patch Size: 3280 bytes Desc: not available Url : http://lists.cs.uiuc.edu/pipermail/llvm-commits/attachments/20111005/fa746572/attachment-0024.bin -------------- next part -------------- A non-text attachment was scrubbed... Name: 0012-OCaml-bindings-fix-attributes-to-use-all-32-bits.patch Type: text/x-patch Size: 12315 bytes Desc: not available Url : http://lists.cs.uiuc.edu/pipermail/llvm-commits/attachments/20111005/fa746572/attachment-0025.bin -------------- next part -------------- A non-text attachment was scrubbed... Name: 0013-Add-uwtable-returnstwice-and-nonlazybind-to-the-C-bi.patch Type: text/x-patch Size: 862 bytes Desc: not available Url : http://lists.cs.uiuc.edu/pipermail/llvm-commits/attachments/20111005/fa746572/attachment-0026.bin -------------- next part -------------- A non-text attachment was scrubbed... Name: 0014-OCaml-bindings-add-some-missing-functions-and-testca.patch Type: text/x-patch Size: 32243 bytes Desc: not available Url : http://lists.cs.uiuc.edu/pipermail/llvm-commits/attachments/20111005/fa746572/attachment-0027.bin From baldrick at free.fr Wed Oct 5 09:17:05 2011 From: baldrick at free.fr (Duncan Sands) Date: Wed, 05 Oct 2011 14:17:05 -0000 Subject: [llvm-commits] [llvm] r141176 - in /llvm/trunk: lib/Transforms/Scalar/GVN.cpp test/Transforms/GVN/condprop.ll Message-ID: <20111005141705.E05C32A6C12C@llvm.org> Author: baldrick Date: Wed Oct 5 09:17:01 2011 New Revision: 141176 URL: http://llvm.org/viewvc/llvm-project?rev=141176&view=rev Log: Generalize GVN's conditional propagation logic slightly: it's OK for the false/true destination to have multiple predecessors as long as the extra ones are dominated by the branch destination. Modified: llvm/trunk/lib/Transforms/Scalar/GVN.cpp llvm/trunk/test/Transforms/GVN/condprop.ll Modified: llvm/trunk/lib/Transforms/Scalar/GVN.cpp URL: http://llvm.org/viewvc/llvm-project/llvm/trunk/lib/Transforms/Scalar/GVN.cpp?rev=141176&r1=141175&r2=141176&view=diff ============================================================================== --- llvm/trunk/lib/Transforms/Scalar/GVN.cpp (original) +++ llvm/trunk/lib/Transforms/Scalar/GVN.cpp Wed Oct 5 09:17:01 2011 @@ -1921,14 +1921,39 @@ BasicBlock *TrueSucc = BI->getSuccessor(0); BasicBlock *FalseSucc = BI->getSuccessor(1); - - if (TrueSucc->getSinglePredecessor()) + BasicBlock *Parent = BI->getParent(); + + // If the true and false branches are to the same basic block then the + // branch gives no information about the condition. Eliminating this + // here simplifies the rest of the logic. + if (TrueSucc == FalseSucc) + return false; + + // If the true block can be reached without executing the true edge then we + // can't say anything about the value of the condition there. + for (pred_iterator PI = pred_begin(TrueSucc), PE = pred_end(TrueSucc); + PI != PE; ++PI) + if (*PI != Parent && !DT->dominates(TrueSucc, *PI)) { + TrueSucc = 0; + break; + } + + // If the false block can be reached without executing the false edge then + // we can't say anything about the value of the condition there. + for (pred_iterator PI = pred_begin(FalseSucc), PE = pred_end(FalseSucc); + PI != PE; ++PI) + if (*PI != Parent && !DT->dominates(FalseSucc, *PI)) { + FalseSucc = 0; + break; + } + + if (TrueSucc) addToLeaderTable(CondVN, ConstantInt::getTrue(TrueSucc->getContext()), TrueSucc); - if (FalseSucc->getSinglePredecessor()) + if (FalseSucc) addToLeaderTable(CondVN, - ConstantInt::getFalse(TrueSucc->getContext()), + ConstantInt::getFalse(FalseSucc->getContext()), FalseSucc); return false; Modified: llvm/trunk/test/Transforms/GVN/condprop.ll URL: http://llvm.org/viewvc/llvm-project/llvm/trunk/test/Transforms/GVN/condprop.ll?rev=141176&r1=141175&r2=141176&view=diff ============================================================================== --- llvm/trunk/test/Transforms/GVN/condprop.ll (original) +++ llvm/trunk/test/Transforms/GVN/condprop.ll Wed Oct 5 09:17:01 2011 @@ -52,4 +52,24 @@ return: ; preds = %bb8 ret i32 %.0 -} \ No newline at end of file +} + +declare void @ext(i1) + +; CHECK: @bar +define void @bar(i1 %x, i1 %y) { + %z = or i1 %x, %y + br i1 %z, label %true, label %false +true: +; CHECK: true: + %z2 = or i1 %x, %y + call void @ext(i1 %z2) +; CHECK: call void @ext(i1 true) + br label %true +false: +; CHECK: false: + %z3 = or i1 %x, %y + call void @ext(i1 %z3) +; CHECK: call void @ext(i1 false) + br label %false +} From baldrick at free.fr Wed Oct 5 09:28:50 2011 From: baldrick at free.fr (Duncan Sands) Date: Wed, 05 Oct 2011 14:28:50 -0000 Subject: [llvm-commits] [llvm] r141177 - in /llvm/trunk: lib/Transforms/Scalar/GVN.cpp test/Transforms/GVN/condprop.ll test/Transforms/GVN/phi-translate.ll Message-ID: <20111005142851.C3F3A2A6C12C@llvm.org> Author: baldrick Date: Wed Oct 5 09:28:49 2011 New Revision: 141177 URL: http://llvm.org/viewvc/llvm-project?rev=141177&view=rev Log: GVN does simple propagation of conditions: when it sees a conditional branch "br i1 %x, label %if_true, label %if_false" then it replaces "%x" with "true" in places only reachable via the %if_true arm, and with "false" in places only reachable via the %if_false arm. Except that actually it doesn't: if value numbering shows that %y is equal to %x then, yes, %y will be turned into true/false in this way, but any occurrences of %x itself are not transformed. Fix this. What's more, it's often the case that %x is an equality comparison such as "%x = icmp eq %A, 0", in which case every occurrence of %A that is only reachable via the %if_true arm can be replaced with 0. Implement this and a few other variations on this theme. This reduces the number of lines of LLVM IR in "GCC as one big file" by 0.2%. It has a bigger impact on Ada code, typically reducing the number of lines of bitcode by around 0.4% by removing repeated compiler generated checks. Passes the LLVM nightly testsuite and the Ada ACATS testsuite. Modified: llvm/trunk/lib/Transforms/Scalar/GVN.cpp llvm/trunk/test/Transforms/GVN/condprop.ll llvm/trunk/test/Transforms/GVN/phi-translate.ll Modified: llvm/trunk/lib/Transforms/Scalar/GVN.cpp URL: http://llvm.org/viewvc/llvm-project/llvm/trunk/lib/Transforms/Scalar/GVN.cpp?rev=141177&r1=141176&r2=141177&view=diff ============================================================================== --- llvm/trunk/lib/Transforms/Scalar/GVN.cpp (original) +++ llvm/trunk/lib/Transforms/Scalar/GVN.cpp Wed Oct 5 09:28:49 2011 @@ -41,12 +41,16 @@ #include "llvm/Support/CommandLine.h" #include "llvm/Support/Debug.h" #include "llvm/Support/IRBuilder.h" +#include "llvm/Support/PatternMatch.h" using namespace llvm; +using namespace PatternMatch; STATISTIC(NumGVNInstr, "Number of instructions deleted"); STATISTIC(NumGVNLoad, "Number of loads deleted"); STATISTIC(NumGVNPRE, "Number of instructions PRE'd"); STATISTIC(NumGVNBlocks, "Number of blocks merged"); +STATISTIC(NumGVNSimpl, "Number of instructions simplified"); +STATISTIC(NumGVNEqProp, "Number of equalities propagated"); STATISTIC(NumPRELoad, "Number of loads PRE'd"); static cl::opt EnablePRE("enable-pre", @@ -548,6 +552,9 @@ void cleanupGlobalSets(); void verifyRemoved(const Instruction *I) const; bool splitCriticalEdges(); + unsigned replaceAllDominatedUsesWith(Value *From, Value *To, + BasicBlock *Root); + bool propagateEquality(Value *LHS, Value *RHS, BasicBlock *Root); }; char GVN::ID = 0; @@ -1881,6 +1888,97 @@ return Val; } +/// replaceAllDominatedUsesWith - Replace all uses of 'From' with 'To' if the +/// use is dominated by the given basic block. Returns the number of uses that +/// were replaced. +unsigned GVN::replaceAllDominatedUsesWith(Value *From, Value *To, + BasicBlock *Root) { + unsigned Count = 0; + for (Value::use_iterator UI = From->use_begin(), UE = From->use_end(); + UI != UE; ) { + Instruction *User = cast(*UI); + unsigned OpNum = UI.getOperandNo(); + ++UI; + + if (DT->dominates(Root, User->getParent())) { + User->setOperand(OpNum, To); + ++Count; + } + } + return Count; +} + +/// propagateEquality - The given values are known to be equal in every block +/// dominated by 'Root'. Exploit this, for example by replacing 'LHS' with +/// 'RHS' everywhere in the scope. Returns whether a change was made. +bool GVN::propagateEquality(Value *LHS, Value *RHS, BasicBlock *Root) { + if (LHS == RHS) return false; + assert(LHS->getType() == RHS->getType() && "Equal but types differ!"); + + // Don't try to propagate equalities between constants. + if (isa(LHS) && isa(RHS)) + return false; + + // Make sure that any constants are on the right-hand side. In general the + // best results are obtained by placing the longest lived value on the RHS. + if (isa(LHS)) + std::swap(LHS, RHS); + + // If neither term is constant then bail out. This is not for correctness, + // it's just that the non-constant case is much less useful: it occurs just + // as often as the constant case but handling it hardly ever results in an + // improvement. + if (!isa(RHS)) + return false; + + // If value numbering later deduces that an instruction in the scope is equal + // to 'LHS' then ensure it will be turned into 'RHS'. + addToLeaderTable(VN.lookup_or_add(LHS), RHS, Root); + + // Replace all occurrences of 'LHS' with 'RHS' everywhere in the scope. + unsigned NumReplacements = replaceAllDominatedUsesWith(LHS, RHS, Root); + bool Changed = NumReplacements > 0; + NumGVNEqProp += NumReplacements; + + // Now try to deduce additional equalities from this one. For example, if the + // known equality was "(A != B)" == "false" then it follows that A and B are + // equal in the scope. Only boolean equalities with an explicit true or false + // RHS are currently supported. + if (!RHS->getType()->isIntegerTy(1)) + // Not a boolean equality - bail out. + return Changed; + ConstantInt *CI = dyn_cast(RHS); + if (!CI) + // RHS neither 'true' nor 'false' - bail out. + return Changed; + // Whether RHS equals 'true'. Otherwise it equals 'false'. + bool isKnownTrue = CI->isAllOnesValue(); + bool isKnownFalse = !isKnownTrue; + + // If "A && B" is known true then both A and B are known true. If "A || B" + // is known false then both A and B are known false. + Value *A, *B; + if ((isKnownTrue && match(LHS, m_And(m_Value(A), m_Value(B)))) || + (isKnownFalse && match(LHS, m_Or(m_Value(A), m_Value(B))))) { + Changed |= propagateEquality(A, RHS, Root); + Changed |= propagateEquality(B, RHS, Root); + return Changed; + } + + // If we are propagating an equality like "(A == B)" == "true" then also + // propagate the equality A == B. + if (ICmpInst *Cmp = dyn_cast(LHS)) { + // Only equality comparisons are supported. + if ((isKnownTrue && Cmp->getPredicate() == CmpInst::ICMP_EQ) || + (isKnownFalse && Cmp->getPredicate() == CmpInst::ICMP_NE)) { + Value *Op0 = Cmp->getOperand(0), *Op1 = Cmp->getOperand(1); + Changed |= propagateEquality(Op0, Op1, Root); + } + return Changed; + } + + return Changed; +} /// processInstruction - When calculating availability, handle an instruction /// by inserting it into the appropriate sets @@ -1898,6 +1996,7 @@ if (MD && V->getType()->isPointerTy()) MD->invalidateCachedPointerInfo(V); markInstructionForDeletion(I); + ++NumGVNSimpl; return true; } @@ -1910,15 +2009,15 @@ return false; } - // For conditions branches, we can perform simple conditional propagation on + // For conditional branches, we can perform simple conditional propagation on // the condition value itself. + // TODO: Add conditional propagation of switch cases. if (BranchInst *BI = dyn_cast(I)) { if (!BI->isConditional() || isa(BI->getCondition())) return false; - + Value *BranchCond = BI->getCondition(); - uint32_t CondVN = VN.lookup_or_add(BranchCond); - + BasicBlock *TrueSucc = BI->getSuccessor(0); BasicBlock *FalseSucc = BI->getSuccessor(1); BasicBlock *Parent = BI->getParent(); @@ -1947,16 +2046,14 @@ break; } - if (TrueSucc) - addToLeaderTable(CondVN, - ConstantInt::getTrue(TrueSucc->getContext()), - TrueSucc); - if (FalseSucc) - addToLeaderTable(CondVN, - ConstantInt::getFalse(FalseSucc->getContext()), - FalseSucc); - - return false; + // Replace the condition with true/false in basic blocks that can only be + // reached via the true/false arm of the branch. + return (TrueSucc && propagateEquality(BranchCond, + ConstantInt::getTrue(TrueSucc->getContext()), + TrueSucc)) + || (FalseSucc && propagateEquality(BranchCond, + ConstantInt::getFalse(FalseSucc->getContext()), + FalseSucc)); } // Instructions with void type don't return a value, so there's Modified: llvm/trunk/test/Transforms/GVN/condprop.ll URL: http://llvm.org/viewvc/llvm-project/llvm/trunk/test/Transforms/GVN/condprop.ll?rev=141177&r1=141176&r2=141177&view=diff ============================================================================== --- llvm/trunk/test/Transforms/GVN/condprop.ll (original) +++ llvm/trunk/test/Transforms/GVN/condprop.ll Wed Oct 5 09:28:49 2011 @@ -2,8 +2,8 @@ @a = external global i32 ; [#uses=7] -; CHECK: @foo -define i32 @foo() nounwind { +; CHECK: @test1 +define i32 @test1() nounwind { entry: %0 = load i32* @a, align 4 %1 = icmp eq i32 %0, 4 @@ -54,22 +54,46 @@ ret i32 %.0 } -declare void @ext(i1) +declare void @foo(i1) -; CHECK: @bar -define void @bar(i1 %x, i1 %y) { +; CHECK: @test2 +define void @test2(i1 %x, i1 %y) { %z = or i1 %x, %y br i1 %z, label %true, label %false true: ; CHECK: true: %z2 = or i1 %x, %y - call void @ext(i1 %z2) -; CHECK: call void @ext(i1 true) + call void @foo(i1 %z2) +; CHECK: call void @foo(i1 true) br label %true false: ; CHECK: false: %z3 = or i1 %x, %y - call void @ext(i1 %z3) -; CHECK: call void @ext(i1 false) + call void @foo(i1 %z3) +; CHECK: call void @foo(i1 false) br label %false } + +declare void @bar(i32) + +; CHECK: @test3 +define void @test3(i32 %x, i32 %y) { + %xz = icmp eq i32 %x, 0 + %yz = icmp eq i32 %y, 0 + %z = and i1 %xz, %yz + br i1 %z, label %both_zero, label %nope +both_zero: + call void @foo(i1 %xz) +; CHECK: call void @foo(i1 true) + call void @foo(i1 %yz) +; CHECK: call void @foo(i1 true) + call void @bar(i32 %x) +; CHECK: call void @bar(i32 0) + call void @bar(i32 %y) +; CHECK: call void @bar(i32 0) + ret void +nope: + call void @foo(i1 %z) +; CHECK: call void @foo(i1 false) + ret void +} Modified: llvm/trunk/test/Transforms/GVN/phi-translate.ll URL: http://llvm.org/viewvc/llvm-project/llvm/trunk/test/Transforms/GVN/phi-translate.ll?rev=141177&r1=141176&r2=141177&view=diff ============================================================================== --- llvm/trunk/test/Transforms/GVN/phi-translate.ll (original) +++ llvm/trunk/test/Transforms/GVN/phi-translate.ll Wed Oct 5 09:28:49 2011 @@ -14,7 +14,7 @@ @G = external global [100 x i32] define i32 @foo(i32 %x, i32 %z) { entry: - %tobool = icmp eq i32 %x, 0 + %tobool = icmp eq i32 %z, 0 br i1 %tobool, label %end, label %then then: From baldrick at free.fr Wed Oct 5 09:36:13 2011 From: baldrick at free.fr (Duncan Sands) Date: Wed, 05 Oct 2011 14:36:13 -0000 Subject: [llvm-commits] [llvm] r141178 - /llvm/trunk/lib/TableGen/TGPreprocessor.h Message-ID: <20111005143613.3DBAA2A6C12C@llvm.org> Author: baldrick Date: Wed Oct 5 09:36:12 2011 New Revision: 141178 URL: http://llvm.org/viewvc/llvm-project?rev=141178&view=rev Log: Fix compilation when using gcc-4.6. Patch by wanders. Modified: llvm/trunk/lib/TableGen/TGPreprocessor.h Modified: llvm/trunk/lib/TableGen/TGPreprocessor.h URL: http://llvm.org/viewvc/llvm-project/llvm/trunk/lib/TableGen/TGPreprocessor.h?rev=141178&r1=141177&r2=141178&view=diff ============================================================================== --- llvm/trunk/lib/TableGen/TGPreprocessor.h (original) +++ llvm/trunk/lib/TableGen/TGPreprocessor.h Wed Oct 5 09:36:12 2011 @@ -40,7 +40,7 @@ public: TGPreprocessor(SourceMgr &SM, tool_output_file &O) - : SrcMgr(SM), Out(O), Lexer(NULL), CurRecords(NULL) { + : SrcMgr(SM), Out(O), Lexer(0), CurRecords(0) { } /// PreprocessFile - Main entrypoint for preprocess a tblgen file. These From greened at obbligato.org Wed Oct 5 09:45:16 2011 From: greened at obbligato.org (David A. Greene) Date: Wed, 05 Oct 2011 09:45:16 -0500 Subject: [llvm-commits] [llvm] r141101 - /llvm/trunk/lib/TableGen/Record.cpp In-Reply-To: <276B7AFD-E55F-4906-9DBC-C195AA0DD46A@apple.com> (Chris Lattner's message of "Tue, 04 Oct 2011 12:06:12 -0700") References: <20111004185538.0D8222A6C12C@llvm.org> <276B7AFD-E55F-4906-9DBC-C195AA0DD46A@apple.com> Message-ID: Chris Lattner writes: >> Before, it was not possible to do this: >> class D { ... } >> class C A> : D; >> class B b> : C; > > Hi David, > > Please make sure to document all new features in the tblgen document. Ok. Is this really a new feature, though? All it does is make passing a list slice as an argument possible. I was actually surprised this didn't work before. -Dave From baldrick at free.fr Wed Oct 5 10:11:20 2011 From: baldrick at free.fr (Duncan Sands) Date: Wed, 05 Oct 2011 15:11:20 -0000 Subject: [llvm-commits] [llvm] r141182 - /llvm/trunk/lib/Target/PTX/PTXISelLowering.cpp Message-ID: <20111005151121.1FC242A6C12C@llvm.org> Author: baldrick Date: Wed Oct 5 10:11:08 2011 New Revision: 141182 URL: http://llvm.org/viewvc/llvm-project?rev=141182&view=rev Log: Remove a bunch of unused variables in the PTX backend (warned about by gcc-4.6). Modified: llvm/trunk/lib/Target/PTX/PTXISelLowering.cpp Modified: llvm/trunk/lib/Target/PTX/PTXISelLowering.cpp URL: http://llvm.org/viewvc/llvm-project/llvm/trunk/lib/Target/PTX/PTXISelLowering.cpp?rev=141182&r1=141181&r2=141182&view=diff ============================================================================== --- llvm/trunk/lib/Target/PTX/PTXISelLowering.cpp (original) +++ llvm/trunk/lib/Target/PTX/PTXISelLowering.cpp Wed Oct 5 10:11:08 2011 @@ -237,36 +237,22 @@ for (unsigned i = 0, e = Ins.size(); i != e; ++i) { EVT RegVT = Ins[i].VT; TargetRegisterClass* TRC = 0; - int OpCode; // Determine which register class we need - if (RegVT == MVT::i1) { + if (RegVT == MVT::i1) TRC = PTX::RegPredRegisterClass; - OpCode = PTX::READPARAMPRED; - } - else if (RegVT == MVT::i16) { + else if (RegVT == MVT::i16) TRC = PTX::RegI16RegisterClass; - OpCode = PTX::READPARAMI16; - } - else if (RegVT == MVT::i32) { + else if (RegVT == MVT::i32) TRC = PTX::RegI32RegisterClass; - OpCode = PTX::READPARAMI32; - } - else if (RegVT == MVT::i64) { + else if (RegVT == MVT::i64) TRC = PTX::RegI64RegisterClass; - OpCode = PTX::READPARAMI64; - } - else if (RegVT == MVT::f32) { + else if (RegVT == MVT::f32) TRC = PTX::RegF32RegisterClass; - OpCode = PTX::READPARAMF32; - } - else if (RegVT == MVT::f64) { + else if (RegVT == MVT::f64) TRC = PTX::RegF64RegisterClass; - OpCode = PTX::READPARAMF64; - } - else { + else llvm_unreachable("Unknown parameter type"); - } // Use a unique index in the instruction to prevent instruction folding. // Yes, this is a hack. @@ -275,10 +261,6 @@ SDValue ArgValue = DAG.getNode(PTXISD::READ_PARAM, dl, RegVT, Chain, Index); - SDValue Flag = ArgValue.getValue(1); - - SDValue Copy = DAG.getCopyFromReg(Chain, dl, Reg, RegVT); - SDValue RegValue = DAG.getRegister(Reg, RegVT); InVals.push_back(ArgValue); MFI->addArgReg(Reg); From baldrick at free.fr Wed Oct 5 10:12:44 2011 From: baldrick at free.fr (Duncan Sands) Date: Wed, 05 Oct 2011 15:12:44 -0000 Subject: [llvm-commits] [llvm] r141183 - /llvm/trunk/lib/Target/PTX/PTXRegisterInfo.cpp Message-ID: <20111005151244.E20E42A6C12C@llvm.org> Author: baldrick Date: Wed Oct 5 10:12:44 2011 New Revision: 141183 URL: http://llvm.org/viewvc/llvm-project?rev=141183&view=rev Log: Comment out a variable that is only used in commented out code. Modified: llvm/trunk/lib/Target/PTX/PTXRegisterInfo.cpp Modified: llvm/trunk/lib/Target/PTX/PTXRegisterInfo.cpp URL: http://llvm.org/viewvc/llvm-project/llvm/trunk/lib/Target/PTX/PTXRegisterInfo.cpp?rev=141183&r1=141182&r2=141183&view=diff ============================================================================== --- llvm/trunk/lib/Target/PTX/PTXRegisterInfo.cpp (original) +++ llvm/trunk/lib/Target/PTX/PTXRegisterInfo.cpp Wed Oct 5 10:12:44 2011 @@ -37,7 +37,7 @@ unsigned Index; MachineInstr &MI = *II; //MachineBasicBlock &MBB = *MI.getParent(); - DebugLoc dl = MI.getDebugLoc(); + //DebugLoc dl = MI.getDebugLoc(); //MachineRegisterInfo &MRI = MI.getParent()->getParent()->getRegInfo(); //unsigned Reg = MRI.createVirtualRegister(PTX::RegF32RegisterClass); From baldrick at free.fr Wed Oct 5 10:13:13 2011 From: baldrick at free.fr (Duncan Sands) Date: Wed, 05 Oct 2011 15:13:13 -0000 Subject: [llvm-commits] [llvm] r141184 - /llvm/trunk/lib/Target/PTX/PTXISelDAGToDAG.cpp Message-ID: <20111005151314.036D12A6C12C@llvm.org> Author: baldrick Date: Wed Oct 5 10:13:13 2011 New Revision: 141184 URL: http://llvm.org/viewvc/llvm-project?rev=141184&view=rev Log: Ensure OpCode is not used uninitialized. Modified: llvm/trunk/lib/Target/PTX/PTXISelDAGToDAG.cpp Modified: llvm/trunk/lib/Target/PTX/PTXISelDAGToDAG.cpp URL: http://llvm.org/viewvc/llvm-project/llvm/trunk/lib/Target/PTX/PTXISelDAGToDAG.cpp?rev=141184&r1=141183&r2=141184&view=diff ============================================================================== --- llvm/trunk/lib/Target/PTX/PTXISelDAGToDAG.cpp (original) +++ llvm/trunk/lib/Target/PTX/PTXISelDAGToDAG.cpp Wed Oct 5 10:13:13 2011 @@ -125,8 +125,10 @@ OpCode = PTX::READPARAMI64; else if (Type == MVT::f32) OpCode = PTX::READPARAMF32; - else if (Type == MVT::f64) + else { + assert(Type == MVT::f64 && "Unexpected type!"); OpCode = PTX::READPARAMF64; + } SDValue Pred = CurDAG->getRegister(PTX::NoRegister, MVT::i1); SDValue PredOp = CurDAG->getTargetConstant(PTXPredicate::None, MVT::i32); From bob.wilson at apple.com Wed Oct 5 11:32:29 2011 From: bob.wilson at apple.com (Bob Wilson) Date: Wed, 05 Oct 2011 09:32:29 -0700 Subject: [llvm-commits] [llvm] r141168 - /llvm/trunk/lib/Analysis/ScalarEvolution.cpp In-Reply-To: <20111005070224.7C9262A6C12C@llvm.org> References: <20111005070224.7C9262A6C12C@llvm.org> Message-ID: How about fixing the typo ("inconsitent") in the assert message, too? On Oct 5, 2011, at 12:02 AM, Chandler Carruth wrote: > Author: chandlerc > Date: Wed Oct 5 02:02:23 2011 > New Revision: 141168 > > URL: http://llvm.org/viewvc/llvm-project?rev=141168&view=rev > Log: > Fix a broken assert found by -Wparentheses. > > Modified: > llvm/trunk/lib/Analysis/ScalarEvolution.cpp > > Modified: llvm/trunk/lib/Analysis/ScalarEvolution.cpp > URL: http://llvm.org/viewvc/llvm-project/llvm/trunk/lib/Analysis/ScalarEvolution.cpp?rev=141168&r1=141167&r2=141168&view=diff > ============================================================================== > --- llvm/trunk/lib/Analysis/ScalarEvolution.cpp (original) > +++ llvm/trunk/lib/Analysis/ScalarEvolution.cpp Wed Oct 5 02:02:23 2011 > @@ -4714,7 +4714,7 @@ > // If this operand is already visited, reuse the prior result. > P = PHIMap.lookup(OpInst); > if (P) { > - assert(!PHI || P == PHI && "inconsitent data flow"); > + assert((!PHI || P == PHI) && "inconsitent data flow"); > PHI = P; > continue; > } > > > _______________________________________________ > llvm-commits mailing list > llvm-commits at cs.uiuc.edu > http://lists.cs.uiuc.edu/mailman/listinfo/llvm-commits From dblaikie at gmail.com Wed Oct 5 11:33:39 2011 From: dblaikie at gmail.com (David Blaikie) Date: Wed, 5 Oct 2011 09:33:39 -0700 Subject: [llvm-commits] [llvm] r141177 - in /llvm/trunk: lib/Transforms/Scalar/GVN.cpp test/Transforms/GVN/condprop.ll test/Transforms/GVN/phi-translate.ll Message-ID: <-1333772858463062519@unknownmsgid> Interesting. Might this help the proposed workaround/fix for http://llvm.org/bugs/show_bug.cgi?id=3100 work? From: Duncan Sands Sent: 10/5/2011 7:34 AM To: llvm-commits at cs.uiuc.edu Subject: [llvm-commits] [llvm] r141177 - in /llvm/trunk: lib/Transforms/Scalar/GVN.cpp test/Transforms/GVN/condprop.ll test/Transforms/GVN/phi-translate.ll Author: baldrick Date: Wed Oct 5 09:28:49 2011 New Revision: 141177 URL: http://llvm.org/viewvc/llvm-project?rev=141177&view=rev Log: GVN does simple propagation of conditions: when it sees a conditional branch "br i1 %x, label %if_true, label %if_false" then it replaces "%x" with "true" in places only reachable via the %if_true arm, and with "false" in places only reachable via the %if_false arm. Except that actually it doesn't: if value numbering shows that %y is equal to %x then, yes, %y will be turned into true/false in this way, but any occurrences of %x itself are not transformed. Fix this. What's more, it's often the case that %x is an equality comparison such as "%x = icmp eq %A, 0", in which case every occurrence of %A that is only reachable via the %if_true arm can be replaced with 0. Implement this and a few other variations on this theme. This reduces the number of lines of LLVM IR in "GCC as one big file" by 0.2%. It has a bigger impact on Ada code, typically reducing the number of lines of bitcode by around 0.4% by removing repeated compiler generated checks. Passes the LLVM nightly testsuite and the Ada ACATS testsuite. Modified: llvm/trunk/lib/Transforms/Scalar/GVN.cpp llvm/trunk/test/Transforms/GVN/condprop.ll llvm/trunk/test/Transforms/GVN/phi-translate.ll Modified: llvm/trunk/lib/Transforms/Scalar/GVN.cpp URL: http://llvm.org/viewvc/llvm-project/llvm/trunk/lib/Transforms/Scalar/GVN.cpp?rev=141177&r1=141176&r2=141177&view=diff ============================================================================== --- llvm/trunk/lib/Transforms/Scalar/GVN.cpp (original) +++ llvm/trunk/lib/Transforms/Scalar/GVN.cpp Wed Oct 5 09:28:49 2011 @@ -41,12 +41,16 @@ #include "llvm/Support/CommandLine.h" #include "llvm/Support/Debug.h" #include "llvm/Support/IRBuilder.h" +#include "llvm/Support/PatternMatch.h" using namespace llvm; +using namespace PatternMatch; STATISTIC(NumGVNInstr, "Number of instructions deleted"); STATISTIC(NumGVNLoad, "Number of loads deleted"); STATISTIC(NumGVNPRE, "Number of instructions PRE'd"); STATISTIC(NumGVNBlocks, "Number of blocks merged"); +STATISTIC(NumGVNSimpl, "Number of instructions simplified"); +STATISTIC(NumGVNEqProp, "Number of equalities propagated"); STATISTIC(NumPRELoad, "Number of loads PRE'd"); static cl::opt EnablePRE("enable-pre", @@ -548,6 +552,9 @@ void cleanupGlobalSets(); void verifyRemoved(const Instruction *I) const; bool splitCriticalEdges(); + unsigned replaceAllDominatedUsesWith(Value *From, Value *To, + BasicBlock *Root); + bool propagateEquality(Value *LHS, Value *RHS, BasicBlock *Root); }; char GVN::ID = 0; @@ -1881,6 +1888,97 @@ return Val; } +/// replaceAllDominatedUsesWith - Replace all uses of 'From' with 'To' if the +/// use is dominated by the given basic block. Returns the number of uses that +/// were replaced. +unsigned GVN::replaceAllDominatedUsesWith(Value *From, Value *To, + BasicBlock *Root) { + unsigned Count = 0; + for (Value::use_iterator UI = From->use_begin(), UE = From->use_end(); + UI != UE; ) { + Instruction *User = cast(*UI); + unsigned OpNum = UI.getOperandNo(); + ++UI; + + if (DT->dominates(Root, User->getParent())) { + User->setOperand(OpNum, To); + ++Count; + } + } + return Count; +} + +/// propagateEquality - The given values are known to be equal in every block +/// dominated by 'Root'. Exploit this, for example by replacing 'LHS' with +/// 'RHS' everywhere in the scope. Returns whether a change was made. +bool GVN::propagateEquality(Value *LHS, Value *RHS, BasicBlock *Root) { + if (LHS == RHS) return false; + assert(LHS->getType() == RHS->getType() && "Equal but types differ!"); + + // Don't try to propagate equalities between constants. + if (isa(LHS) && isa(RHS)) + return false; + + // Make sure that any constants are on the right-hand side. In general the + // best results are obtained by placing the longest lived value on the RHS. + if (isa(LHS)) + std::swap(LHS, RHS); + + // If neither term is constant then bail out. This is not for correctness, + // it's just that the non-constant case is much less useful: it occurs just + // as often as the constant case but handling it hardly ever results in an + // improvement. + if (!isa(RHS)) + return false; + + // If value numbering later deduces that an instruction in the scope is equal + // to 'LHS' then ensure it will be turned into 'RHS'. + addToLeaderTable(VN.lookup_or_add(LHS), RHS, Root); + + // Replace all occurrences of 'LHS' with 'RHS' everywhere in the scope. + unsigned NumReplacements = replaceAllDominatedUsesWith(LHS, RHS, Root); + bool Changed = NumReplacements > 0; + NumGVNEqProp += NumReplacements; + + // Now try to deduce additional equalities from this one. For example, if the + // known equality was "(A != B)" == "false" then it follows that A and B are + // equal in the scope. Only boolean equalities with an explicit true or false + // RHS are currently supported. + if (!RHS->getType()->isIntegerTy(1)) + // Not a boolean equality - bail out. + return Changed; + ConstantInt *CI = dyn_cast(RHS); + if (!CI) + // RHS neither 'true' nor 'false' - bail out. + return Changed; + // Whether RHS equals 'true'. Otherwise it equals 'false'. + bool isKnownTrue = CI->isAllOnesValue(); + bool isKnownFalse = !isKnownTrue; + + // If "A && B" is known true then both A and B are known true. If "A || B" + // is known false then both A and B are known false. + Value *A, *B; + if ((isKnownTrue && match(LHS, m_And(m_Value(A), m_Value(B)))) || + (isKnownFalse && match(LHS, m_Or(m_Value(A), m_Value(B))))) { + Changed |= propagateEquality(A, RHS, Root); + Changed |= propagateEquality(B, RHS, Root); + return Changed; + } + + // If we are propagating an equality like "(A == B)" == "true" then also + // propagate the equality A == B. + if (ICmpInst *Cmp = dyn_cast(LHS)) { + // Only equality comparisons are supported. + if ((isKnownTrue && Cmp->getPredicate() == CmpInst::ICMP_EQ) || + (isKnownFalse && Cmp->getPredicate() == CmpInst::ICMP_NE)) { + Value *Op0 = Cmp->getOperand(0), *Op1 = Cmp->getOperand(1); + Changed |= propagateEquality(Op0, Op1, Root); + } + return Changed; + } + + return Changed; +} /// processInstruction - When calculating availability, handle an instruction /// by inserting it into the appropriate sets @@ -1898,6 +1996,7 @@ if (MD && V->getType()->isPointerTy()) MD->invalidateCachedPointerInfo(V); markInstructionForDeletion(I); + ++NumGVNSimpl; return true; } @@ -1910,15 +2009,15 @@ return false; } - // For conditions branches, we can perform simple conditional propagation on + // For conditional branches, we can perform simple conditional propagation on // the condition value itself. + // TODO: Add conditional propagation of switch cases. if (BranchInst *BI = dyn_cast(I)) { if (!BI->isConditional() || isa(BI->getCondition())) return false; - + Value *BranchCond = BI->getCondition(); - uint32_t CondVN = VN.lookup_or_add(BranchCond); - + BasicBlock *TrueSucc = BI->getSuccessor(0); BasicBlock *FalseSucc = BI->getSuccessor(1); BasicBlock *Parent = BI->getParent(); @@ -1947,16 +2046,14 @@ break; } - if (TrueSucc) - addToLeaderTable(CondVN, - ConstantInt::getTrue(TrueSucc->getContext()), - TrueSucc); - if (FalseSucc) - addToLeaderTable(CondVN, - ConstantInt::getFalse(FalseSucc->getContext()), - FalseSucc); - - return false; + // Replace the condition with true/false in basic blocks that can only be + // reached via the true/false arm of the branch. + return (TrueSucc && propagateEquality(BranchCond, + ConstantInt::getTrue(TrueSucc->getContext()), + TrueSucc)) + || (FalseSucc && propagateEquality(BranchCond, + ConstantInt::getFalse(FalseSucc->getContext()), + FalseSucc)); } // Instructions with void type don't return a value, so there's Modified: llvm/trunk/test/Transforms/GVN/condprop.ll URL: http://llvm.org/viewvc/llvm-project/llvm/trunk/test/Transforms/GVN/condprop.ll?rev=141177&r1=141176&r2=141177&view=diff ============================================================================== --- llvm/trunk/test/Transforms/GVN/condprop.ll (original) +++ llvm/trunk/test/Transforms/GVN/condprop.ll Wed Oct 5 09:28:49 2011 @@ -2,8 +2,8 @@ @a = external global i32 ; [#uses=7] -; CHECK: @foo -define i32 @foo() nounwind { +; CHECK: @test1 +define i32 @test1() nounwind { entry: %0 = load i32* @a, align 4 %1 = icmp eq i32 %0, 4 @@ -54,22 +54,46 @@ ret i32 %.0 } -declare void @ext(i1) +declare void @foo(i1) -; CHECK: @bar -define void @bar(i1 %x, i1 %y) { +; CHECK: @test2 +define void @test2(i1 %x, i1 %y) { %z = or i1 %x, %y br i1 %z, label %true, label %false true: ; CHECK: true: %z2 = or i1 %x, %y - call void @ext(i1 %z2) -; CHECK: call void @ext(i1 true) + call void @foo(i1 %z2) +; CHECK: call void @foo(i1 true) br label %true false: ; CHECK: false: %z3 = or i1 %x, %y - call void @ext(i1 %z3) -; CHECK: call void @ext(i1 false) + call void @foo(i1 %z3) +; CHECK: call void @foo(i1 false) br label %false } + +declare void @bar(i32) + +; CHECK: @test3 +define void @test3(i32 %x, i32 %y) { + %xz = icmp eq i32 %x, 0 + %yz = icmp eq i32 %y, 0 + %z = and i1 %xz, %yz + br i1 %z, label %both_zero, label %nope +both_zero: + call void @foo(i1 %xz) +; CHECK: call void @foo(i1 true) + call void @foo(i1 %yz) +; CHECK: call void @foo(i1 true) + call void @bar(i32 %x) +; CHECK: call void @bar(i32 0) + call void @bar(i32 %y) +; CHECK: call void @bar(i32 0) + ret void +nope: + call void @foo(i1 %z) +; CHECK: call void @foo(i1 false) + ret void +} Modified: llvm/trunk/test/Transforms/GVN/phi-translate.ll URL: http://llvm.org/viewvc/llvm-project/llvm/trunk/test/Transforms/GVN/phi-translate.ll?rev=141177&r1=141176&r2=141177&view=diff ============================================================================== --- llvm/trunk/test/Transforms/GVN/phi-translate.ll (original) +++ llvm/trunk/test/Transforms/GVN/phi-translate.ll Wed Oct 5 09:28:49 2011 @@ -14,7 +14,7 @@ @G = external global [100 x i32] define i32 @foo(i32 %x, i32 %z) { entry: - %tobool = icmp eq i32 %x, 0 + %tobool = icmp eq i32 %z, 0 br i1 %tobool, label %end, label %then then: _______________________________________________ llvm-commits mailing list llvm-commits at cs.uiuc.edu http://lists.cs.uiuc.edu/mailman/listinfo/llvm-commits From atrick at apple.com Wed Oct 5 11:51:24 2011 From: atrick at apple.com (Andrew Trick) Date: Wed, 05 Oct 2011 09:51:24 -0700 Subject: [llvm-commits] [llvm] r141168 - /llvm/trunk/lib/Analysis/ScalarEvolution.cpp In-Reply-To: References: <20111005070224.7C9262A6C12C@llvm.org> <3347318B-3753-4C2D-A579-A48AF4102E4E@apple.com> Message-ID: On Oct 5, 2011, at 1:20 AM, Chandler Carruth wrote: > On Wed, Oct 5, 2011 at 1:10 AM, Andrew Trick wrote: > Thanks for cleaning up. But broken? No, I just can't train myself to insert redundant parens in this idiom. > > Heh, and on the other side it took me thinking about this more than I like admitting to convince myself that indeed, ((X || Y) && "...") is equivalent to (X || (Y && "..."))... Oh well, probably means that's enough coding for one evening. ;] I don't want anyone to have to think about binary operator precedence to read my code--I'm not picking on you. My point was that the compiler should know this idiom is ok if it's going to warn people in the general case. I only brought it up on the list because I make this mistake *all the time* using LLVM's assert idiom, so your cleanup won't be the last of its kind. After many years using asserts heavily in C++ (with good macros, not the silly keyword), the mechanical process of shuffling expressions around between if statements and asserts and adding comments to asserts is completely subconscious. I never visually parse the string as part of the expression then go out of my way to add parens in the rare case that they're needed. clang doesn't warn about this, which is good, but there is some value in emulating gcc's bad behavior. -Andy -------------- next part -------------- An HTML attachment was scrubbed... URL: http://lists.cs.uiuc.edu/pipermail/llvm-commits/attachments/20111005/cd153a22/attachment.html From stoklund at 2pi.dk Wed Oct 5 11:51:21 2011 From: stoklund at 2pi.dk (Jakob Stoklund Olesen) Date: Wed, 05 Oct 2011 16:51:21 -0000 Subject: [llvm-commits] [llvm] r141187 - /llvm/trunk/lib/CodeGen/LiveIntervalAnalysis.cpp Message-ID: <20111005165122.09A0C2A6C12C@llvm.org> Author: stoklund Date: Wed Oct 5 11:51:21 2011 New Revision: 141187 URL: http://llvm.org/viewvc/llvm-project?rev=141187&view=rev Log: Add a FIXME. TwoAddressInstructionPass should annotate instructions with flags when it lower REG_SEQUENCE instructions. LiveIntervals should not be in the business of modifying code (except for kill flags, perhaps). Modified: llvm/trunk/lib/CodeGen/LiveIntervalAnalysis.cpp Modified: llvm/trunk/lib/CodeGen/LiveIntervalAnalysis.cpp URL: http://llvm.org/viewvc/llvm-project/llvm/trunk/lib/CodeGen/LiveIntervalAnalysis.cpp?rev=141187&r1=141186&r2=141187&view=diff ============================================================================== --- llvm/trunk/lib/CodeGen/LiveIntervalAnalysis.cpp (original) +++ llvm/trunk/lib/CodeGen/LiveIntervalAnalysis.cpp Wed Oct 5 11:51:21 2011 @@ -304,6 +304,10 @@ // Make sure the first definition is not a partial redefinition. Add an // of the full register. + // FIXME: LiveIntervals shouldn't modify the code like this. Whoever + // created the machine instruction should annotate it with flags + // as needed. Then we can simply assert here. The REG_SEQUENCE lowering + // is the main suspect. if (MO.getSubReg()) { mi->addRegisterDefined(interval.reg); // Mark all defs of interval.reg on this instruction as reading . From atrick at apple.com Wed Oct 5 11:52:28 2011 From: atrick at apple.com (Andrew Trick) Date: Wed, 05 Oct 2011 16:52:28 -0000 Subject: [llvm-commits] [llvm] r141188 - /llvm/trunk/lib/Analysis/ScalarEvolution.cpp Message-ID: <20111005165228.8FE392A6C12C@llvm.org> Author: atrick Date: Wed Oct 5 11:52:28 2011 New Revision: 141188 URL: http://llvm.org/viewvc/llvm-project?rev=141188&view=rev Log: Typo. Thanks Bob. Modified: llvm/trunk/lib/Analysis/ScalarEvolution.cpp Modified: llvm/trunk/lib/Analysis/ScalarEvolution.cpp URL: http://llvm.org/viewvc/llvm-project/llvm/trunk/lib/Analysis/ScalarEvolution.cpp?rev=141188&r1=141187&r2=141188&view=diff ============================================================================== --- llvm/trunk/lib/Analysis/ScalarEvolution.cpp (original) +++ llvm/trunk/lib/Analysis/ScalarEvolution.cpp Wed Oct 5 11:52:28 2011 @@ -4714,7 +4714,7 @@ // If this operand is already visited, reuse the prior result. P = PHIMap.lookup(OpInst); if (P) { - assert((!PHI || P == PHI) && "inconsitent data flow"); + assert((!PHI || P == PHI) && "inconsistent data flow"); PHI = P; continue; } From baldrick at free.fr Wed Oct 5 12:00:40 2011 From: baldrick at free.fr (Duncan Sands) Date: Wed, 05 Oct 2011 17:00:40 -0000 Subject: [llvm-commits] [dragonegg] r141189 - in /dragonegg/trunk: include/dragonegg/Internals.h src/Convert.cpp Message-ID: <20111005170040.A1040312800A@llvm.org> Author: baldrick Date: Wed Oct 5 12:00:39 2011 New Revision: 141189 URL: http://llvm.org/viewvc/llvm-project?rev=141189&view=rev Log: Port commit 139562 (efriedma) from llvm-gcc. Original commit message: Convert llvm-gcc to use the new atomic instructions. I would appreciate if someone would do the same conversion for dragonegg. Modified: dragonegg/trunk/include/dragonegg/Internals.h dragonegg/trunk/src/Convert.cpp Modified: dragonegg/trunk/include/dragonegg/Internals.h URL: http://llvm.org/viewvc/llvm-project/dragonegg/trunk/include/dragonegg/Internals.h?rev=141189&r1=141188&r2=141189&view=diff ============================================================================== --- dragonegg/trunk/include/dragonegg/Internals.h (original) +++ dragonegg/trunk/include/dragonegg/Internals.h Wed Oct 5 12:00:39 2011 @@ -601,13 +601,13 @@ void EmitModifyOfRegisterVariable(tree_node *vardecl, Value *RHS); // Helpers for Builtin Function Expansion. - void EmitMemoryBarrier(bool ll, bool ls, bool sl, bool ss, bool device); Value *BuildVector(const std::vector &Elts); Value *BuildVector(Value *Elt, ...); Value *BuildVectorShuffle(Value *InVec1, Value *InVec2, ...); - Value *BuildBinaryAtomicBuiltin(gimple_statement_d *stmt, Intrinsic::ID id); - Value *BuildCmpAndSwapAtomicBuiltin(gimple_statement_d *stmt, unsigned Bits, - bool isBool); + Value *BuildBinaryAtomic(gimple_statement_d *stmt, AtomicRMWInst::BinOp Kind, + unsigned PostOp = 0); + Value *BuildCmpAndSwapAtomic(gimple_statement_d *stmt, unsigned Bits, + bool isBool); // Builtin Function Expansion. bool EmitBuiltinCall(gimple_statement_d *stmt, tree_node *fndecl, Modified: dragonegg/trunk/src/Convert.cpp URL: http://llvm.org/viewvc/llvm-project/dragonegg/trunk/src/Convert.cpp?rev=141189&r1=141188&r2=141189&view=diff ============================================================================== --- dragonegg/trunk/src/Convert.cpp (original) +++ dragonegg/trunk/src/Convert.cpp Wed Oct 5 12:00:39 2011 @@ -3561,22 +3561,8 @@ /// builtin number. static std::vector TargetBuiltinCache; -void TreeToLLVM::EmitMemoryBarrier(bool ll, bool ls, bool sl, bool ss, - bool device) { - Value* C[5]; - C[0] = Builder.getInt1(ll); - C[1] = Builder.getInt1(ls); - C[2] = Builder.getInt1(sl); - C[3] = Builder.getInt1(ss); - C[4] = Builder.getInt1(device); - - Builder.CreateCall(Intrinsic::getDeclaration(TheModule, - Intrinsic::memory_barrier), - C); -} - -Value * -TreeToLLVM::BuildBinaryAtomicBuiltin(gimple stmt, Intrinsic::ID id) { +Value *TreeToLLVM::BuildBinaryAtomic(gimple stmt, AtomicRMWInst::BinOp Kind, + unsigned PostOp) { tree return_type = gimple_call_return_type(stmt); Type *ResultTy = ConvertType(return_type); Value* C[2] = { @@ -3590,32 +3576,17 @@ C[1] = Builder.CreateIntCast(C[1], Ty[0], /*isSigned*/!TYPE_UNSIGNED(return_type), "cast"); - // The gcc builtins are also full memory barriers. - // FIXME: __sync_lock_test_and_set and __sync_lock_release require less. -#if defined(TARGET_ARM) && defined(CONFIG_DARWIN_H) - EmitMemoryBarrier(true, true, true, true, false); -#else - EmitMemoryBarrier(true, true, true, true, true); -#endif - - Value *Result = - Builder.CreateCall(Intrinsic::getDeclaration(TheModule, id, Ty), C); - - // The gcc builtins are also full memory barriers. - // FIXME: __sync_lock_test_and_set and __sync_lock_release require less. -#if defined(TARGET_ARM) && defined(CONFIG_DARWIN_H) - EmitMemoryBarrier(true, true, true, true, false); -#else - EmitMemoryBarrier(true, true, true, true, true); -#endif + Value *Result = Builder.CreateAtomicRMW(Kind, C[0], C[1], + SequentiallyConsistent); + if (PostOp) + Result = Builder.CreateBinOp(Instruction::BinaryOps(PostOp), Result, C[1]); Result = Builder.CreateIntToPtr(Result, ResultTy); return Result; } Value * -TreeToLLVM::BuildCmpAndSwapAtomicBuiltin(gimple stmt, unsigned Bits, - bool isBool) { +TreeToLLVM::BuildCmpAndSwapAtomic(gimple stmt, unsigned Bits, bool isBool) { tree ptr = gimple_call_arg(stmt, 0); tree old_val = gimple_call_arg(stmt, 1); tree new_val = gimple_call_arg(stmt, 2); @@ -3632,28 +3603,9 @@ !TYPE_UNSIGNED(TREE_TYPE(new_val)), MemTy, !TYPE_UNSIGNED(TREE_TYPE(new_val))); - // The gcc builtins are also full memory barriers. - // FIXME: __sync_lock_test_and_set and __sync_lock_release require less. -#if defined(TARGET_ARM) && defined(CONFIG_DARWIN_H) - EmitMemoryBarrier(true, true, true, true, false); -#else - EmitMemoryBarrier(true, true, true, true, true); -#endif - - Value *Ops[3] = { Ptr, Old_Val, New_Val }; - Type* Ty[2] = { MemTy, MemPtrTy }; - Value *Result = - Builder.CreateCall(Intrinsic::getDeclaration(TheModule, - Intrinsic::atomic_cmp_swap, - Ty), Ops); - - // The gcc builtins are also full memory barriers. - // FIXME: __sync_lock_test_and_set and __sync_lock_release require less. -#if defined(TARGET_ARM) && defined(CONFIG_DARWIN_H) - EmitMemoryBarrier(true, true, true, true, false); -#else - EmitMemoryBarrier(true, true, true, true, true); -#endif + Value *C[3] = { Ptr, Old_Val, New_Val }; + Value *Result = Builder.CreateAtomicCmpXchg(C[0], C[1], C[2], + SequentiallyConsistent); if (isBool) Result = Builder.CreateICmpEQ(Result, Old_Val); @@ -4044,17 +3996,10 @@ //TODO return true; //TODO } - case BUILT_IN_SYNCHRONIZE: { + case BUILT_IN_SYNCHRONIZE: // We assume like gcc appears to, that this only applies to cached memory. - Value* C[5]; - C[0] = C[1] = C[2] = C[3] = Builder.getTrue(); - C[4] = Builder.getFalse(); - - Builder.CreateCall(Intrinsic::getDeclaration(TheModule, - Intrinsic::memory_barrier), - C); + Builder.CreateFence(llvm::SequentiallyConsistent); return true; - } #if defined(TARGET_ALPHA) || defined(TARGET_386) || defined(TARGET_POWERPC) \ || defined(TARGET_ARM) // gcc uses many names for the sync intrinsics @@ -4067,38 +4012,38 @@ // Note that Intrinsic::getDeclaration expects the type list in reversed // order, while CreateCall expects the parameter list in normal order. case BUILT_IN_BOOL_COMPARE_AND_SWAP_1: - Result = BuildCmpAndSwapAtomicBuiltin(stmt, BITS_PER_UNIT, true); + Result = BuildCmpAndSwapAtomic(stmt, BITS_PER_UNIT, true); return true; case BUILT_IN_BOOL_COMPARE_AND_SWAP_2: - Result = BuildCmpAndSwapAtomicBuiltin(stmt, 2*BITS_PER_UNIT, true); + Result = BuildCmpAndSwapAtomic(stmt, 2*BITS_PER_UNIT, true); return true; case BUILT_IN_BOOL_COMPARE_AND_SWAP_4: - Result = BuildCmpAndSwapAtomicBuiltin(stmt, 4*BITS_PER_UNIT, true); + Result = BuildCmpAndSwapAtomic(stmt, 4*BITS_PER_UNIT, true); return true; case BUILT_IN_BOOL_COMPARE_AND_SWAP_8: #if defined(TARGET_POWERPC) if (!TARGET_64BIT) return false; #endif - Result = BuildCmpAndSwapAtomicBuiltin(stmt, 8*BITS_PER_UNIT, true); + Result = BuildCmpAndSwapAtomic(stmt, 8*BITS_PER_UNIT, true); return true; // Fall through. case BUILT_IN_VAL_COMPARE_AND_SWAP_1: - Result = BuildCmpAndSwapAtomicBuiltin(stmt, BITS_PER_UNIT, false); + Result = BuildCmpAndSwapAtomic(stmt, BITS_PER_UNIT, false); return true; case BUILT_IN_VAL_COMPARE_AND_SWAP_2: - Result = BuildCmpAndSwapAtomicBuiltin(stmt, 2*BITS_PER_UNIT, false); + Result = BuildCmpAndSwapAtomic(stmt, 2*BITS_PER_UNIT, false); return true; case BUILT_IN_VAL_COMPARE_AND_SWAP_4: - Result = BuildCmpAndSwapAtomicBuiltin(stmt, 4*BITS_PER_UNIT, false); + Result = BuildCmpAndSwapAtomic(stmt, 4*BITS_PER_UNIT, false); return true; case BUILT_IN_VAL_COMPARE_AND_SWAP_8: #if defined(TARGET_POWERPC) if (!TARGET_64BIT) return false; #endif - Result = BuildCmpAndSwapAtomicBuiltin(stmt, 8*BITS_PER_UNIT, false); + Result = BuildCmpAndSwapAtomic(stmt, 8*BITS_PER_UNIT, false); return true; case BUILT_IN_FETCH_AND_ADD_8: @@ -4109,7 +4054,7 @@ case BUILT_IN_FETCH_AND_ADD_1: case BUILT_IN_FETCH_AND_ADD_2: case BUILT_IN_FETCH_AND_ADD_4: { - Result = BuildBinaryAtomicBuiltin(stmt, Intrinsic::atomic_load_add); + Result = BuildBinaryAtomic(stmt, AtomicRMWInst::Add); return true; } case BUILT_IN_FETCH_AND_SUB_8: @@ -4120,7 +4065,7 @@ case BUILT_IN_FETCH_AND_SUB_1: case BUILT_IN_FETCH_AND_SUB_2: case BUILT_IN_FETCH_AND_SUB_4: { - Result = BuildBinaryAtomicBuiltin(stmt, Intrinsic::atomic_load_sub); + Result = BuildBinaryAtomic(stmt, AtomicRMWInst::Sub); return true; } case BUILT_IN_FETCH_AND_OR_8: @@ -4131,7 +4076,7 @@ case BUILT_IN_FETCH_AND_OR_1: case BUILT_IN_FETCH_AND_OR_2: case BUILT_IN_FETCH_AND_OR_4: { - Result = BuildBinaryAtomicBuiltin(stmt, Intrinsic::atomic_load_or); + Result = BuildBinaryAtomic(stmt, AtomicRMWInst::Or); return true; } case BUILT_IN_FETCH_AND_AND_8: @@ -4142,7 +4087,7 @@ case BUILT_IN_FETCH_AND_AND_1: case BUILT_IN_FETCH_AND_AND_2: case BUILT_IN_FETCH_AND_AND_4: { - Result = BuildBinaryAtomicBuiltin(stmt, Intrinsic::atomic_load_and); + Result = BuildBinaryAtomic(stmt, AtomicRMWInst::And); return true; } case BUILT_IN_FETCH_AND_XOR_8: @@ -4153,7 +4098,7 @@ case BUILT_IN_FETCH_AND_XOR_1: case BUILT_IN_FETCH_AND_XOR_2: case BUILT_IN_FETCH_AND_XOR_4: { - Result = BuildBinaryAtomicBuiltin(stmt, Intrinsic::atomic_load_xor); + Result = BuildBinaryAtomic(stmt, AtomicRMWInst::Xor); return true; } case BUILT_IN_FETCH_AND_NAND_8: @@ -4164,7 +4109,7 @@ case BUILT_IN_FETCH_AND_NAND_1: case BUILT_IN_FETCH_AND_NAND_2: case BUILT_IN_FETCH_AND_NAND_4: { - Result = BuildBinaryAtomicBuiltin(stmt, Intrinsic::atomic_load_nand); + Result = BuildBinaryAtomic(stmt, AtomicRMWInst::Nand); return true; } case BUILT_IN_LOCK_TEST_AND_SET_8: @@ -4175,7 +4120,7 @@ case BUILT_IN_LOCK_TEST_AND_SET_1: case BUILT_IN_LOCK_TEST_AND_SET_2: case BUILT_IN_LOCK_TEST_AND_SET_4: { - Result = BuildBinaryAtomicBuiltin(stmt, Intrinsic::atomic_swap); + Result = BuildBinaryAtomic(stmt, AtomicRMWInst::Xchg); return true; } @@ -4186,47 +4131,9 @@ #endif case BUILT_IN_ADD_AND_FETCH_1: case BUILT_IN_ADD_AND_FETCH_2: - case BUILT_IN_ADD_AND_FETCH_4: { - tree return_type = gimple_call_return_type(stmt); - Type *ResultTy = ConvertType(return_type); - Value* C[2] = { - EmitMemory(gimple_call_arg(stmt, 0)), - EmitMemory(gimple_call_arg(stmt, 1)) - }; - Type* Ty[2]; - Ty[0] = ResultTy; - Ty[1] = ResultTy->getPointerTo(); - C[0] = Builder.CreateBitCast(C[0], Ty[1]); - C[1] = Builder.CreateIntCast(C[1], Ty[0], - /*isSigned*/!TYPE_UNSIGNED(return_type), - "cast"); - - // The gcc builtins are also full memory barriers. - // FIXME: __sync_lock_test_and_set and __sync_lock_release require less. -#if defined(TARGET_ARM) && defined(CONFIG_DARWIN_H) - EmitMemoryBarrier(true, true, true, true, false); -#else - EmitMemoryBarrier(true, true, true, true, true); -#endif - - Result = - Builder.CreateCall(Intrinsic::getDeclaration(TheModule, - Intrinsic::atomic_load_add, - Ty), - C); - - // The gcc builtins are also full memory barriers. - // FIXME: __sync_lock_test_and_set and __sync_lock_release require less. -#if defined(TARGET_ARM) && defined(CONFIG_DARWIN_H) - EmitMemoryBarrier(true, true, true, true, false); -#else - EmitMemoryBarrier(true, true, true, true, true); -#endif - - Result = Builder.CreateAdd(Result, C[1]); - Result = Builder.CreateIntToPtr(Result, ResultTy); + case BUILT_IN_ADD_AND_FETCH_4: + Result = BuildBinaryAtomic(stmt, AtomicRMWInst::Add, Instruction::Add); return true; - } case BUILT_IN_SUB_AND_FETCH_8: #if defined(TARGET_POWERPC) if (!TARGET_64BIT) @@ -4234,47 +4141,9 @@ #endif case BUILT_IN_SUB_AND_FETCH_1: case BUILT_IN_SUB_AND_FETCH_2: - case BUILT_IN_SUB_AND_FETCH_4: { - tree return_type = gimple_call_return_type(stmt); - Type *ResultTy = ConvertType(return_type); - Value* C[2] = { - EmitMemory(gimple_call_arg(stmt, 0)), - EmitMemory(gimple_call_arg(stmt, 1)) - }; - Type* Ty[2]; - Ty[0] = ResultTy; - Ty[1] = ResultTy->getPointerTo(); - C[0] = Builder.CreateBitCast(C[0], Ty[1]); - C[1] = Builder.CreateIntCast(C[1], Ty[0], - /*isSigned*/!TYPE_UNSIGNED(return_type), - "cast"); - - // The gcc builtins are also full memory barriers. - // FIXME: __sync_lock_test_and_set and __sync_lock_release require less. -#if defined(TARGET_ARM) && defined(CONFIG_DARWIN_H) - EmitMemoryBarrier(true, true, true, true, false); -#else - EmitMemoryBarrier(true, true, true, true, true); -#endif - - Result = - Builder.CreateCall(Intrinsic::getDeclaration(TheModule, - Intrinsic::atomic_load_sub, - Ty), - C); - - // The gcc builtins are also full memory barriers. - // FIXME: __sync_lock_test_and_set and __sync_lock_release require less. -#if defined(TARGET_ARM) && defined(CONFIG_DARWIN_H) - EmitMemoryBarrier(true, true, true, true, false); -#else - EmitMemoryBarrier(true, true, true, true, true); -#endif - - Result = Builder.CreateSub(Result, C[1]); - Result = Builder.CreateIntToPtr(Result, ResultTy); + case BUILT_IN_SUB_AND_FETCH_4: + Result = BuildBinaryAtomic(stmt, AtomicRMWInst::Sub, Instruction::Sub); return true; - } case BUILT_IN_OR_AND_FETCH_8: #if defined(TARGET_POWERPC) if (!TARGET_64BIT) @@ -4282,47 +4151,9 @@ #endif case BUILT_IN_OR_AND_FETCH_1: case BUILT_IN_OR_AND_FETCH_2: - case BUILT_IN_OR_AND_FETCH_4: { - tree return_type = gimple_call_return_type(stmt); - Type *ResultTy = ConvertType(return_type); - Value* C[2] = { - EmitMemory(gimple_call_arg(stmt, 0)), - EmitMemory(gimple_call_arg(stmt, 1)) - }; - Type* Ty[2]; - Ty[0] = ResultTy; - Ty[1] = ResultTy->getPointerTo(); - C[0] = Builder.CreateBitCast(C[0], Ty[1]); - C[1] = Builder.CreateIntCast(C[1], Ty[0], - /*isSigned*/!TYPE_UNSIGNED(return_type), - "cast"); - - // The gcc builtins are also full memory barriers. - // FIXME: __sync_lock_test_and_set and __sync_lock_release require less. -#if defined(TARGET_ARM) && defined(CONFIG_DARWIN_H) - EmitMemoryBarrier(true, true, true, true, false); -#else - EmitMemoryBarrier(true, true, true, true, true); -#endif - - Result = - Builder.CreateCall(Intrinsic::getDeclaration(TheModule, - Intrinsic::atomic_load_or, - Ty), - C); - - // The gcc builtins are also full memory barriers. - // FIXME: __sync_lock_test_and_set and __sync_lock_release require less. -#if defined(TARGET_ARM) && defined(CONFIG_DARWIN_H) - EmitMemoryBarrier(true, true, true, true, false); -#else - EmitMemoryBarrier(true, true, true, true, true); -#endif - - Result = Builder.CreateOr(Result, C[1]); - Result = Builder.CreateIntToPtr(Result, ResultTy); + case BUILT_IN_OR_AND_FETCH_4: + Result = BuildBinaryAtomic(stmt, AtomicRMWInst::Or, Instruction::Or); return true; - } case BUILT_IN_AND_AND_FETCH_8: #if defined(TARGET_POWERPC) if (!TARGET_64BIT) @@ -4330,47 +4161,9 @@ #endif case BUILT_IN_AND_AND_FETCH_1: case BUILT_IN_AND_AND_FETCH_2: - case BUILT_IN_AND_AND_FETCH_4: { - tree return_type = gimple_call_return_type(stmt); - Type *ResultTy = ConvertType(return_type); - Value* C[2] = { - EmitMemory(gimple_call_arg(stmt, 0)), - EmitMemory(gimple_call_arg(stmt, 1)) - }; - Type* Ty[2]; - Ty[0] = ResultTy; - Ty[1] = ResultTy->getPointerTo(); - C[0] = Builder.CreateBitCast(C[0], Ty[1]); - C[1] = Builder.CreateIntCast(C[1], Ty[0], - /*isSigned*/!TYPE_UNSIGNED(return_type), - "cast"); - - // The gcc builtins are also full memory barriers. - // FIXME: __sync_lock_test_and_set and __sync_lock_release require less. -#if defined(TARGET_ARM) && defined(CONFIG_DARWIN_H) - EmitMemoryBarrier(true, true, true, true, false); -#else - EmitMemoryBarrier(true, true, true, true, true); -#endif - - Result = - Builder.CreateCall(Intrinsic::getDeclaration(TheModule, - Intrinsic::atomic_load_and, - Ty), - C); - - // The gcc builtins are also full memory barriers. - // FIXME: __sync_lock_test_and_set and __sync_lock_release require less. -#if defined(TARGET_ARM) && defined(CONFIG_DARWIN_H) - EmitMemoryBarrier(true, true, true, true, false); -#else - EmitMemoryBarrier(true, true, true, true, true); -#endif - - Result = Builder.CreateAnd(Result, C[1]); - Result = Builder.CreateIntToPtr(Result, ResultTy); + case BUILT_IN_AND_AND_FETCH_4: + Result = BuildBinaryAtomic(stmt, AtomicRMWInst::And, Instruction::And); return true; - } case BUILT_IN_XOR_AND_FETCH_8: #if defined(TARGET_POWERPC) if (!TARGET_64BIT) @@ -4378,47 +4171,9 @@ #endif case BUILT_IN_XOR_AND_FETCH_1: case BUILT_IN_XOR_AND_FETCH_2: - case BUILT_IN_XOR_AND_FETCH_4: { - tree return_type = gimple_call_return_type(stmt); - Type *ResultTy = ConvertType(return_type); - Value* C[2] = { - EmitMemory(gimple_call_arg(stmt, 0)), - EmitMemory(gimple_call_arg(stmt, 1)) - }; - Type* Ty[2]; - Ty[0] = ResultTy; - Ty[1] = ResultTy->getPointerTo(); - C[0] = Builder.CreateBitCast(C[0], Ty[1]); - C[1] = Builder.CreateIntCast(C[1], Ty[0], - /*isSigned*/!TYPE_UNSIGNED(return_type), - "cast"); - - // The gcc builtins are also full memory barriers. - // FIXME: __sync_lock_test_and_set and __sync_lock_release require less. -#if defined(TARGET_ARM) && defined(CONFIG_DARWIN_H) - EmitMemoryBarrier(true, true, true, true, false); -#else - EmitMemoryBarrier(true, true, true, true, true); -#endif - - Result = - Builder.CreateCall(Intrinsic::getDeclaration(TheModule, - Intrinsic::atomic_load_xor, - Ty), - C); - - // The gcc builtins are also full memory barriers. - // FIXME: __sync_lock_test_and_set and __sync_lock_release require less. -#if defined(TARGET_ARM) && defined(CONFIG_DARWIN_H) - EmitMemoryBarrier(true, true, true, true, false); -#else - EmitMemoryBarrier(true, true, true, true, true); -#endif - - Result = Builder.CreateXor(Result, C[1]); - Result = Builder.CreateIntToPtr(Result, ResultTy); + case BUILT_IN_XOR_AND_FETCH_4: + Result = BuildBinaryAtomic(stmt, AtomicRMWInst::Xor, Instruction::Xor); return true; - } case BUILT_IN_NAND_AND_FETCH_8: #if defined(TARGET_POWERPC) if (!TARGET_64BIT) @@ -4440,28 +4195,8 @@ C[1] = Builder.CreateIntCast(C[1], Ty[0], /*isSigned*/!TYPE_UNSIGNED(return_type), "cast"); - - // The gcc builtins are also full memory barriers. - // FIXME: __sync_lock_test_and_set and __sync_lock_release require less. -#if defined(TARGET_ARM) && defined(CONFIG_DARWIN_H) - EmitMemoryBarrier(true, true, true, true, false); -#else - EmitMemoryBarrier(true, true, true, true, true); -#endif - - Result = - Builder.CreateCall(Intrinsic::getDeclaration(TheModule, - Intrinsic::atomic_load_nand, - Ty), - C); - - // The gcc builtins are also full memory barriers. - // FIXME: __sync_lock_test_and_set and __sync_lock_release require less. -#if defined(TARGET_ARM) && defined(CONFIG_DARWIN_H) - EmitMemoryBarrier(true, true, true, true, false); -#else - EmitMemoryBarrier(true, true, true, true, true); -#endif + Value *Result = Builder.CreateAtomicRMW(AtomicRMWInst::Nand, C[0], C[1], + SequentiallyConsistent); Result = Builder.CreateAnd(Builder.CreateNot(Result), C[1]); Result = Builder.CreateIntToPtr(Result, ResultTy); @@ -4477,6 +4212,9 @@ // The argument has typically been coerced to "volatile void*"; the // only way to find the size of the operation is from the builtin // opcode. + // FIXME: This is wrong; it works to some extent on x86 if the optimizer + // doesn't get too clever, and is horribly broken anywhere else. It needs + // to use "store atomic [...] release". Type *Ty; switch(DECL_FUNCTION_CODE(fndecl)) { case BUILT_IN_LOCK_RELEASE_16: // not handled; should use SSE on x86 From stoklund at 2pi.dk Wed Oct 5 12:09:30 2011 From: stoklund at 2pi.dk (Jakob Stoklund Olesen) Date: Wed, 05 Oct 2011 10:09:30 -0700 Subject: [llvm-commits] [llvm] r141182 - /llvm/trunk/lib/Target/PTX/PTXISelLowering.cpp In-Reply-To: <20111005151121.1FC242A6C12C@llvm.org> References: <20111005151121.1FC242A6C12C@llvm.org> Message-ID: <459FBFE8-5B7D-41B9-80DC-6C030C0E78C9@2pi.dk> On Oct 5, 2011, at 8:11 AM, Duncan Sands wrote: > Modified: llvm/trunk/lib/Target/PTX/PTXISelLowering.cpp > URL: http://llvm.org/viewvc/llvm-project/llvm/trunk/lib/Target/PTX/PTXISelLowering.cpp?rev=141182&r1=141181&r2=141182&view=diff > ============================================================================== > --- llvm/trunk/lib/Target/PTX/PTXISelLowering.cpp (original) > +++ llvm/trunk/lib/Target/PTX/PTXISelLowering.cpp Wed Oct 5 10:11:08 2011 > @@ -237,36 +237,22 @@ > for (unsigned i = 0, e = Ins.size(); i != e; ++i) { > EVT RegVT = Ins[i].VT; > TargetRegisterClass* TRC = 0; > - int OpCode; > > // Determine which register class we need > - if (RegVT == MVT::i1) { > + if (RegVT == MVT::i1) > TRC = PTX::RegPredRegisterClass; > - OpCode = PTX::READPARAMPRED; > - } > - else if (RegVT == MVT::i16) { > + else if (RegVT == MVT::i16) > TRC = PTX::RegI16RegisterClass; > - OpCode = PTX::READPARAMI16; > - } > - else if (RegVT == MVT::i32) { > + else if (RegVT == MVT::i32) > TRC = PTX::RegI32RegisterClass; > - OpCode = PTX::READPARAMI32; > - } > - else if (RegVT == MVT::i64) { > + else if (RegVT == MVT::i64) > TRC = PTX::RegI64RegisterClass; > - OpCode = PTX::READPARAMI64; > - } > - else if (RegVT == MVT::f32) { > + else if (RegVT == MVT::f32) > TRC = PTX::RegF32RegisterClass; > - OpCode = PTX::READPARAMF32; > - } > - else if (RegVT == MVT::f64) { > + else if (RegVT == MVT::f64) > TRC = PTX::RegF64RegisterClass; > - OpCode = PTX::READPARAMF64; > - } > - else { > + else > llvm_unreachable("Unknown parameter type"); > - } At this point, you could simply use TRC = getRegClassFor(RegVT), right? /jakob From baldrick at free.fr Wed Oct 5 12:10:28 2011 From: baldrick at free.fr (Duncan Sands) Date: Wed, 05 Oct 2011 19:10:28 +0200 Subject: [llvm-commits] [llvm] r141177 - in /llvm/trunk: lib/Transforms/Scalar/GVN.cpp test/Transforms/GVN/condprop.ll test/Transforms/GVN/phi-translate.ll In-Reply-To: <-1333772858463062519@unknownmsgid> References: <-1333772858463062519@unknownmsgid> Message-ID: <4E8C8F84.10000@free.fr> On 10/05/11 18:33, David Blaikie wrote: > Interesting. Might this help the proposed workaround/fix for > http://llvm.org/bugs/show_bug.cgi?id=3100 work? Probably. Because the testcase is incomplete I was unable to check for real. Ciao, Duncan. From baldrick at free.fr Wed Oct 5 12:11:30 2011 From: baldrick at free.fr (Duncan Sands) Date: Wed, 05 Oct 2011 19:11:30 +0200 Subject: [llvm-commits] [llvm] r141182 - /llvm/trunk/lib/Target/PTX/PTXISelLowering.cpp In-Reply-To: <459FBFE8-5B7D-41B9-80DC-6C030C0E78C9@2pi.dk> References: <20111005151121.1FC242A6C12C@llvm.org> <459FBFE8-5B7D-41B9-80DC-6C030C0E78C9@2pi.dk> Message-ID: <4E8C8FC2.1090500@free.fr> Hi Jakob, > At this point, you could simply use TRC = getRegClassFor(RegVT), right? probably, but since I'm just fixing compiler warnings I'd rather leave that to the PTX people. Ciao, Duncan. From resistor at mac.com Wed Oct 5 12:16:41 2011 From: resistor at mac.com (Owen Anderson) Date: Wed, 05 Oct 2011 17:16:41 -0000 Subject: [llvm-commits] [llvm] r141190 - in /llvm/trunk: lib/Target/ARM/AsmParser/ARMAsmParser.cpp lib/Target/ARM/InstPrinter/ARMInstPrinter.cpp test/MC/ARM/arm_instructions.s Message-ID: <20111005171641.D98492A6C12C@llvm.org> Author: resistor Date: Wed Oct 5 12:16:40 2011 New Revision: 141190 URL: http://llvm.org/viewvc/llvm-project?rev=141190&view=rev Log: Support a valid, but not very useful, encoding of CPSIE where none of the AIF bits are set. Modified: llvm/trunk/lib/Target/ARM/AsmParser/ARMAsmParser.cpp llvm/trunk/lib/Target/ARM/InstPrinter/ARMInstPrinter.cpp llvm/trunk/test/MC/ARM/arm_instructions.s Modified: llvm/trunk/lib/Target/ARM/AsmParser/ARMAsmParser.cpp URL: http://llvm.org/viewvc/llvm-project/llvm/trunk/lib/Target/ARM/AsmParser/ARMAsmParser.cpp?rev=141190&r1=141189&r2=141190&view=diff ============================================================================== --- llvm/trunk/lib/Target/ARM/AsmParser/ARMAsmParser.cpp (original) +++ llvm/trunk/lib/Target/ARM/AsmParser/ARMAsmParser.cpp Wed Oct 5 12:16:40 2011 @@ -2085,20 +2085,24 @@ assert(Tok.is(AsmToken::Identifier) && "Token is not an Identifier"); StringRef IFlagsStr = Tok.getString(); + // An iflags string of "none" is interpreted to mean that none of the AIF + // bits are set. Not a terribly useful instruction, but a valid encoding. unsigned IFlags = 0; - for (int i = 0, e = IFlagsStr.size(); i != e; ++i) { - unsigned Flag = StringSwitch(IFlagsStr.substr(i, 1)) - .Case("a", ARM_PROC::A) - .Case("i", ARM_PROC::I) - .Case("f", ARM_PROC::F) - .Default(~0U); + if (IFlagsStr != "none") { + for (int i = 0, e = IFlagsStr.size(); i != e; ++i) { + unsigned Flag = StringSwitch(IFlagsStr.substr(i, 1)) + .Case("a", ARM_PROC::A) + .Case("i", ARM_PROC::I) + .Case("f", ARM_PROC::F) + .Default(~0U); - // If some specific iflag is already set, it means that some letter is - // present more than once, this is not acceptable. - if (Flag == ~0U || (IFlags & Flag)) - return MatchOperand_NoMatch; + // If some specific iflag is already set, it means that some letter is + // present more than once, this is not acceptable. + if (Flag == ~0U || (IFlags & Flag)) + return MatchOperand_NoMatch; - IFlags |= Flag; + IFlags |= Flag; + } } Parser.Lex(); // Eat identifier token. Modified: llvm/trunk/lib/Target/ARM/InstPrinter/ARMInstPrinter.cpp URL: http://llvm.org/viewvc/llvm-project/llvm/trunk/lib/Target/ARM/InstPrinter/ARMInstPrinter.cpp?rev=141190&r1=141189&r2=141190&view=diff ============================================================================== --- llvm/trunk/lib/Target/ARM/InstPrinter/ARMInstPrinter.cpp (original) +++ llvm/trunk/lib/Target/ARM/InstPrinter/ARMInstPrinter.cpp Wed Oct 5 12:16:40 2011 @@ -624,6 +624,9 @@ for (int i=2; i >= 0; --i) if (IFlags & (1 << i)) O << ARM_PROC::IFlagsToString(1 << i); + + if (IFlags == 0) + O << "none"; } void ARMInstPrinter::printMSRMaskOperand(const MCInst *MI, unsigned OpNum, Modified: llvm/trunk/test/MC/ARM/arm_instructions.s URL: http://llvm.org/viewvc/llvm-project/llvm/trunk/test/MC/ARM/arm_instructions.s?rev=141190&r1=141189&r2=141190&view=diff ============================================================================== --- llvm/trunk/test/MC/ARM/arm_instructions.s (original) +++ llvm/trunk/test/MC/ARM/arm_instructions.s Wed Oct 5 12:16:40 2011 @@ -71,3 +71,6 @@ @ CHECK: ssat16 r0, #7, r0 @ encoding: [0x30,0x0f,0xa6,0xe6] ssat16 r0, #7, r0 +@ CHECK: cpsie none, #0 @ encoding: [0x00,0x00,0x0a,0xf1] + cpsie none, #0 + From stoklund at 2pi.dk Wed Oct 5 12:17:42 2011 From: stoklund at 2pi.dk (Jakob Stoklund Olesen) Date: Wed, 05 Oct 2011 10:17:42 -0700 Subject: [llvm-commits] [llvm] r141182 - /llvm/trunk/lib/Target/PTX/PTXISelLowering.cpp In-Reply-To: <4E8C8FC2.1090500@free.fr> References: <20111005151121.1FC242A6C12C@llvm.org> <459FBFE8-5B7D-41B9-80DC-6C030C0E78C9@2pi.dk> <4E8C8FC2.1090500@free.fr> Message-ID: On Oct 5, 2011, at 10:11 AM, Duncan Sands wrote: >> At this point, you could simply use TRC = getRegClassFor(RegVT), right? > > probably, but since I'm just fixing compiler warnings I'd rather leave that > to the PTX people. Sure. Justin, please check if you can use getRegClassFor() here. /jakob From ed at extraordinarymachine.nl Wed Oct 5 09:27:45 2011 From: ed at extraordinarymachine.nl (Edward Meewis) Date: Wed, 05 Oct 2011 16:27:45 +0200 Subject: [llvm-commits] [PATCH] lib/Target/*/TargetInfo/Makefile Message-ID: <4E8C6961.1040009@extraordinarymachine.nl> Hi, This patch adds -I's to CPPFLAGS instead of replacing them. This broke my cygwin build. BTW: the X86 target uses CPP.Flags. Don't know if thats intended to be different; I didn't touch it. Hope it's useful, --Ed. -------------- next part -------------- A non-text attachment was scrubbed... Name: llvm.r141173.patch Type: text/x-patch Size: 7014 bytes Desc: not available Url : http://lists.cs.uiuc.edu/pipermail/llvm-commits/attachments/20111005/7fb18f25/attachment.bin From ed at extraordinarymachine.nl Wed Oct 5 09:40:17 2011 From: ed at extraordinarymachine.nl (Edward Meewis) Date: Wed, 05 Oct 2011 16:40:17 +0200 Subject: [llvm-commits] updated [PATCH] lib/Target/*/TargetInfo/Makefile In-Reply-To: <4E8C6961.1040009@extraordinarymachine.nl> References: <4E8C6961.1040009@extraordinarymachine.nl> Message-ID: <4E8C6C51.3030807@extraordinarymachine.nl> Missed similar thing in lib/Target/ARM/Disassembler/Makefile -- Ed. On 05-10-11 16:27, Edward Meewis wrote: > Hi, > > This patch adds -I's to CPPFLAGS instead of replacing them. This broke > my cygwin build. > > BTW: the X86 target uses CPP.Flags. Don't know if thats intended to be > different; I didn't touch it. > > Hope it's useful, > > --Ed. -------------- next part -------------- A non-text attachment was scrubbed... Name: llvm.r141173.patch Type: text/x-patch Size: 7521 bytes Desc: not available Url : http://lists.cs.uiuc.edu/pipermail/llvm-commits/attachments/20111005/bd12f4fc/attachment.bin From ahatanaka at mips.com Wed Oct 5 13:11:45 2011 From: ahatanaka at mips.com (Akira Hatanaka) Date: Wed, 05 Oct 2011 18:11:45 -0000 Subject: [llvm-commits] [llvm] r141194 - /llvm/trunk/lib/Target/Mips/MipsDelaySlotFiller.cpp Message-ID: <20111005181145.81D5B2A6C12C@llvm.org> Author: ahatanak Date: Wed Oct 5 13:11:44 2011 New Revision: 141194 URL: http://llvm.org/viewvc/llvm-project?rev=141194&view=rev Log: Add RA to the set of registers that are defined if instruction is a call. Modified: llvm/trunk/lib/Target/Mips/MipsDelaySlotFiller.cpp Modified: llvm/trunk/lib/Target/Mips/MipsDelaySlotFiller.cpp URL: http://llvm.org/viewvc/llvm-project/llvm/trunk/lib/Target/Mips/MipsDelaySlotFiller.cpp?rev=141194&r1=141193&r2=141194&view=diff ============================================================================== --- llvm/trunk/lib/Target/Mips/MipsDelaySlotFiller.cpp (original) +++ llvm/trunk/lib/Target/Mips/MipsDelaySlotFiller.cpp Wed Oct 5 13:11:44 2011 @@ -218,13 +218,13 @@ SmallSet& RegDefs, SmallSet& RegUses) { // If MI is a call or return, just examine the explicit non-variadic operands. - // NOTE: $ra is not added to RegDefs, since currently $ra is reserved and - // no instruction that can possibly be put in a delay slot can read or - // write it. - MCInstrDesc MCID = MI->getDesc(); unsigned e = MCID.isCall() || MCID.isReturn() ? MCID.getNumOperands() : MI->getNumOperands(); + + // Add RA to RegDefs to prevent users of RA from going into delay slot. + if (MCID.isCall()) + RegDefs.insert(Mips::RA); for (unsigned i = 0; i != e; ++i) { const MachineOperand &MO = MI->getOperand(i); From gohman at apple.com Wed Oct 5 13:13:08 2011 From: gohman at apple.com (Dan Gohman) Date: Wed, 05 Oct 2011 18:13:08 -0000 Subject: [llvm-commits] [llvm] r141195 - /llvm/trunk/test/CodeGen/ARM/va_arg.ll Message-ID: <20111005181308.81B7F2A6C12C@llvm.org> Author: djg Date: Wed Oct 5 13:13:08 2011 New Revision: 141195 URL: http://llvm.org/viewvc/llvm-project?rev=141195&view=rev Log: Make this test less sensitive to codegen optimizations. Modified: llvm/trunk/test/CodeGen/ARM/va_arg.ll Modified: llvm/trunk/test/CodeGen/ARM/va_arg.ll URL: http://llvm.org/viewvc/llvm-project/llvm/trunk/test/CodeGen/ARM/va_arg.ll?rev=141195&r1=141194&r2=141195&view=diff ============================================================================== --- llvm/trunk/test/CodeGen/ARM/va_arg.ll (original) +++ llvm/trunk/test/CodeGen/ARM/va_arg.ll Wed Oct 5 13:13:08 2011 @@ -30,6 +30,7 @@ %ap1 = bitcast i8** %ap to i8* ; [#uses=2] call void @llvm.va_start(i8* %ap1) %0 = va_arg i8** %ap, i32 ; [#uses=0] + store i32 %0, i32* undef %1 = va_arg i8** %ap, double ; [#uses=1] call void @llvm.va_end(i8* %ap1) ret double %1 From ahatanaka at mips.com Wed Oct 5 13:16:10 2011 From: ahatanaka at mips.com (Akira Hatanaka) Date: Wed, 05 Oct 2011 18:16:10 -0000 Subject: [llvm-commits] [llvm] r141196 - /llvm/trunk/lib/Target/Mips/MipsDelaySlotFiller.cpp Message-ID: <20111005181610.2B4652A6C12C@llvm.org> Author: ahatanak Date: Wed Oct 5 13:16:09 2011 New Revision: 141196 URL: http://llvm.org/viewvc/llvm-project?rev=141196&view=rev Log: Make sure candidate for delay slot filler is not a return instruction. Modified: llvm/trunk/lib/Target/Mips/MipsDelaySlotFiller.cpp Modified: llvm/trunk/lib/Target/Mips/MipsDelaySlotFiller.cpp URL: http://llvm.org/viewvc/llvm-project/llvm/trunk/lib/Target/Mips/MipsDelaySlotFiller.cpp?rev=141196&r1=141195&r2=141196&view=diff ============================================================================== --- llvm/trunk/lib/Target/Mips/MipsDelaySlotFiller.cpp (original) +++ llvm/trunk/lib/Target/Mips/MipsDelaySlotFiller.cpp Wed Oct 5 13:16:09 2011 @@ -174,15 +174,16 @@ if (candidate->isImplicitDef() || candidate->isKill()) return true; + MCInstrDesc MCID = candidate->getDesc(); // Loads or stores cannot be moved past a store to the delay slot // and stores cannot be moved past a load. - if (candidate->getDesc().mayLoad()) { + if (MCID.mayLoad()) { if (sawStore) return true; sawLoad = true; } - if (candidate->getDesc().mayStore()) { + if (MCID.mayStore()) { if (sawStore) return true; sawStore = true; @@ -190,7 +191,8 @@ return true; } - assert(!candidate->getDesc().isCall() && "Cannot put calls in delay slot."); + assert((!MCID.isCall() && !MCID.isReturn()) && + "Cannot put calls in delay slot."); for (unsigned i = 0, e = candidate->getNumOperands(); i!= e; ++i) { const MachineOperand &MO = candidate->getOperand(i); From ahatanaka at mips.com Wed Oct 5 13:17:49 2011 From: ahatanaka at mips.com (Akira Hatanaka) Date: Wed, 05 Oct 2011 18:17:49 -0000 Subject: [llvm-commits] [llvm] r141197 - /llvm/trunk/lib/Target/Mips/MipsDelaySlotFiller.cpp Message-ID: <20111005181749.C5F722A6C12C@llvm.org> Author: ahatanak Date: Wed Oct 5 13:17:49 2011 New Revision: 141197 URL: http://llvm.org/viewvc/llvm-project?rev=141197&view=rev Log: Fix assertion string. Modified: llvm/trunk/lib/Target/Mips/MipsDelaySlotFiller.cpp Modified: llvm/trunk/lib/Target/Mips/MipsDelaySlotFiller.cpp URL: http://llvm.org/viewvc/llvm-project/llvm/trunk/lib/Target/Mips/MipsDelaySlotFiller.cpp?rev=141197&r1=141196&r2=141197&view=diff ============================================================================== --- llvm/trunk/lib/Target/Mips/MipsDelaySlotFiller.cpp (original) +++ llvm/trunk/lib/Target/Mips/MipsDelaySlotFiller.cpp Wed Oct 5 13:17:49 2011 @@ -192,7 +192,7 @@ } assert((!MCID.isCall() && !MCID.isReturn()) && - "Cannot put calls in delay slot."); + "Cannot put calls or returns in delay slot."); for (unsigned i = 0, e = candidate->getNumOperands(); i!= e; ++i) { const MachineOperand &MO = candidate->getOperand(i); From stoklund at 2pi.dk Wed Oct 5 13:31:01 2011 From: stoklund at 2pi.dk (Jakob Stoklund Olesen) Date: Wed, 05 Oct 2011 18:31:01 -0000 Subject: [llvm-commits] [llvm] r141198 - /llvm/trunk/lib/CodeGen/SelectionDAG/InstrEmitter.cpp Message-ID: <20111005183101.D6B362A6C12C@llvm.org> Author: stoklund Date: Wed Oct 5 13:31:00 2011 New Revision: 141198 URL: http://llvm.org/viewvc/llvm-project?rev=141198&view=rev Log: Simplify INSERT_SUBREG emission. The register class created by INSERT_SUBREG and SUBREG_TO_REG must be legal and support the SubIdx sub-registers. The new getSubClassWithSubReg() hook can compute that. This may create INSERT_SUBREG instructions defining a larger register class than the sub-register being inserted. That is OK, RegisterCoalescer will constrain the register class as needed when it eliminates the INSERT_SUBREG instructions. Modified: llvm/trunk/lib/CodeGen/SelectionDAG/InstrEmitter.cpp Modified: llvm/trunk/lib/CodeGen/SelectionDAG/InstrEmitter.cpp URL: http://llvm.org/viewvc/llvm-project/llvm/trunk/lib/CodeGen/SelectionDAG/InstrEmitter.cpp?rev=141198&r1=141197&r2=141198&view=diff ============================================================================== --- llvm/trunk/lib/CodeGen/SelectionDAG/InstrEmitter.cpp (original) +++ llvm/trunk/lib/CodeGen/SelectionDAG/InstrEmitter.cpp Wed Oct 5 13:31:00 2011 @@ -392,21 +392,6 @@ } } -/// getSuperRegisterRegClass - Returns the register class of a superreg A whose -/// "SubIdx"'th sub-register class is the specified register class and whose -/// type matches the specified type. -static const TargetRegisterClass* -getSuperRegisterRegClass(const TargetRegisterClass *TRC, - unsigned SubIdx, EVT VT) { - // Pick the register class of the superegister for this type - for (TargetRegisterInfo::regclass_iterator I = TRC->superregclasses_begin(), - E = TRC->superregclasses_end(); I != E; ++I) - if ((*I)->hasType(VT) && (*I)->getSubRegisterRegClass(SubIdx) == TRC) - return *I; - assert(false && "Couldn't find the register class"); - return 0; -} - /// EmitSubregNode - Generate machine code for subreg nodes. /// void InstrEmitter::EmitSubregNode(SDNode *Node, @@ -482,21 +467,28 @@ SDValue N0 = Node->getOperand(0); SDValue N1 = Node->getOperand(1); SDValue N2 = Node->getOperand(2); - unsigned SubReg = getVR(N1, VRBaseMap); unsigned SubIdx = cast(N2)->getZExtValue(); - const TargetRegisterClass *TRC = MRI->getRegClass(SubReg); - const TargetRegisterClass *SRC = - getSuperRegisterRegClass(TRC, SubIdx, Node->getValueType(0)); - // Figure out the register class to create for the destreg. - // Note that if we're going to directly use an existing register, - // it must be precisely the required class, and not a subclass - // thereof. - if (VRBase == 0 || SRC != MRI->getRegClass(VRBase)) { - // Create the reg - assert(SRC && "Couldn't find source register class"); + // Figure out the register class to create for the destreg. It should be + // the largest legal register class supporting SubIdx sub-registers. + // RegisterCoalescer will constrain it further if it decides to eliminate + // the INSERT_SUBREG instruction. + // + // %dst = INSERT_SUBREG %src, %sub, SubIdx + // + // is lowered by TwoAddressInstructionPass to: + // + // %dst = COPY %src + // %dst:SubIdx = COPY %sub + // + // There is no constraint on the %src register class. + // + const TargetRegisterClass *SRC = TLI->getRegClassFor(Node->getValueType(0)); + SRC = TRI->getSubClassWithSubReg(SRC, SubIdx); + assert(SRC && "No register class supports VT and SubIdx for INSERT_SUBREG"); + + if (VRBase == 0 || !SRC->hasSubClassEq(MRI->getRegClass(VRBase))) VRBase = MRI->createVirtualRegister(SRC); - } // Create the insert_subreg or subreg_to_reg machine instruction. MachineInstr *MI = BuildMI(*MF, Node->getDebugLoc(), TII->get(Opc)); From justin.holewinski at gmail.com Wed Oct 5 13:32:25 2011 From: justin.holewinski at gmail.com (Justin Holewinski) Date: Wed, 05 Oct 2011 18:32:25 -0000 Subject: [llvm-commits] [llvm] r141199 - /llvm/trunk/lib/Target/PTX/PTXISelLowering.cpp Message-ID: <20111005183225.61AAB2A6C12C@llvm.org> Author: jholewinski Date: Wed Oct 5 13:32:25 2011 New Revision: 141199 URL: http://llvm.org/viewvc/llvm-project?rev=141199&view=rev Log: PTX: Fixup a case where getRegClassFor() should be used instead of custom code. Modified: llvm/trunk/lib/Target/PTX/PTXISelLowering.cpp Modified: llvm/trunk/lib/Target/PTX/PTXISelLowering.cpp URL: http://llvm.org/viewvc/llvm-project/llvm/trunk/lib/Target/PTX/PTXISelLowering.cpp?rev=141199&r1=141198&r2=141199&view=diff ============================================================================== --- llvm/trunk/lib/Target/PTX/PTXISelLowering.cpp (original) +++ llvm/trunk/lib/Target/PTX/PTXISelLowering.cpp Wed Oct 5 13:32:25 2011 @@ -236,23 +236,7 @@ else { for (unsigned i = 0, e = Ins.size(); i != e; ++i) { EVT RegVT = Ins[i].VT; - TargetRegisterClass* TRC = 0; - - // Determine which register class we need - if (RegVT == MVT::i1) - TRC = PTX::RegPredRegisterClass; - else if (RegVT == MVT::i16) - TRC = PTX::RegI16RegisterClass; - else if (RegVT == MVT::i32) - TRC = PTX::RegI32RegisterClass; - else if (RegVT == MVT::i64) - TRC = PTX::RegI64RegisterClass; - else if (RegVT == MVT::f32) - TRC = PTX::RegF32RegisterClass; - else if (RegVT == MVT::f64) - TRC = PTX::RegF64RegisterClass; - else - llvm_unreachable("Unknown parameter type"); + TargetRegisterClass* TRC = getRegClassFor(RegVT); // Use a unique index in the instruction to prevent instruction folding. // Yes, this is a hack. From justin.holewinski at gmail.com Wed Oct 5 13:34:46 2011 From: justin.holewinski at gmail.com (Justin Holewinski) Date: Wed, 5 Oct 2011 14:34:46 -0400 Subject: [llvm-commits] [llvm] r141182 - /llvm/trunk/lib/Target/PTX/PTXISelLowering.cpp In-Reply-To: References: <20111005151121.1FC242A6C12C@llvm.org> <459FBFE8-5B7D-41B9-80DC-6C030C0E78C9@2pi.dk> <4E8C8FC2.1090500@free.fr> Message-ID: On Wed, Oct 5, 2011 at 1:17 PM, Jakob Stoklund Olesen wrote: > > On Oct 5, 2011, at 10:11 AM, Duncan Sands wrote: > > >> At this point, you could simply use TRC = getRegClassFor(RegVT), right? > > > > probably, but since I'm just fixing compiler warnings I'd rather leave > that > > to the PTX people. > > Sure. > > Justin, please check if you can use getRegClassFor() here. > Sure, committed in r141199. Thanks for the catch! > > /jakob > > -- Thanks, Justin Holewinski -------------- next part -------------- An HTML attachment was scrubbed... URL: http://lists.cs.uiuc.edu/pipermail/llvm-commits/attachments/20111005/95e0adb2/attachment.html From grosbach at apple.com Wed Oct 5 15:05:00 2011 From: grosbach at apple.com (Jim Grosbach) Date: Wed, 05 Oct 2011 20:05:00 -0000 Subject: [llvm-commits] [llvm] r141203 - in /llvm/trunk: lib/Transforms/InstCombine/InstructionCombining.cpp test/Transforms/InstCombine/2010-11-01-lshr-mask.ll Message-ID: <20111005200501.2E6882A6C12C@llvm.org> Author: grosbach Date: Wed Oct 5 15:05:00 2011 New Revision: 141203 URL: http://llvm.org/viewvc/llvm-project?rev=141203&view=rev Log: Update InstCombine worklist after instruction transform is complete. When updating the worklist for InstCombine, the Add/AddUsersToWorklist functions may access the instruction(s) being added, for debug output for example. If the instructions aren't yet added to the basic block, this can result in a crash. Finish the instruction transformation before adjusting the worklist instead. rdar://10238555 Modified: llvm/trunk/lib/Transforms/InstCombine/InstructionCombining.cpp llvm/trunk/test/Transforms/InstCombine/2010-11-01-lshr-mask.ll Modified: llvm/trunk/lib/Transforms/InstCombine/InstructionCombining.cpp URL: http://llvm.org/viewvc/llvm-project/llvm/trunk/lib/Transforms/InstCombine/InstructionCombining.cpp?rev=141203&r1=141202&r2=141203&view=diff ============================================================================== --- llvm/trunk/lib/Transforms/InstCombine/InstructionCombining.cpp (original) +++ llvm/trunk/lib/Transforms/InstCombine/InstructionCombining.cpp Wed Oct 5 15:05:00 2011 @@ -2009,21 +2009,18 @@ ++NumCombined; // Should we replace the old instruction with a new one? if (Result != I) { - DEBUG(errs() << "IC: Old = " << *I << '\n' - << " New = " << *Result << '\n'); - if (!I->getDebugLoc().isUnknown()) Result->setDebugLoc(I->getDebugLoc()); // Everything uses the new instruction now. I->replaceAllUsesWith(Result); - // Push the new instruction and any users onto the worklist. - Worklist.Add(Result); - Worklist.AddUsersToWorkList(*Result); - - // Move the name to the new instruction first. + // Move the name to the new instruction. Result->takeName(I); + DEBUG(errs() << "IC: Old = " << *I << '\n' + << " New = " << *Result << '\n'); + + // Insert the new instruction into the basic block... BasicBlock *InstParent = I->getParent(); BasicBlock::iterator InsertPos = I; @@ -2035,6 +2032,10 @@ InstParent->getInstList().insert(InsertPos, Result); EraseInstFromFunction(*I); + + // Push the new instruction and any users onto the worklist. + Worklist.Add(Result); + Worklist.AddUsersToWorkList(*Result); } else { #ifndef NDEBUG DEBUG(errs() << "IC: Mod = " << OrigI << '\n' Modified: llvm/trunk/test/Transforms/InstCombine/2010-11-01-lshr-mask.ll URL: http://llvm.org/viewvc/llvm-project/llvm/trunk/test/Transforms/InstCombine/2010-11-01-lshr-mask.ll?rev=141203&r1=141202&r2=141203&view=diff ============================================================================== --- llvm/trunk/test/Transforms/InstCombine/2010-11-01-lshr-mask.ll (original) +++ llvm/trunk/test/Transforms/InstCombine/2010-11-01-lshr-mask.ll Wed Oct 5 15:05:00 2011 @@ -5,8 +5,8 @@ define i32 @main(i32 %argc) nounwind ssp { entry: %tmp3151 = trunc i32 %argc to i8 -; CHECK: %tmp3162 = shl i8 %tmp3151, 5 -; CHECK: and i8 %tmp3162, 64 +; CHECK: %0 = shl i8 %tmp3151, 5 +; CHECK: and i8 %0, 64 ; CHECK-NOT: shl ; CHECK-NOT: shr %tmp3161 = or i8 %tmp3151, -17 From rafael.espindola at gmail.com Wed Oct 5 15:05:14 2011 From: rafael.espindola at gmail.com (Rafael Espindola) Date: Wed, 05 Oct 2011 20:05:14 -0000 Subject: [llvm-commits] [llvm] r141204 - in /llvm/trunk: include/llvm/Instructions.h lib/VMCore/Function.cpp test/Transforms/TailCallElim/setjmp.ll Message-ID: <20111005200514.196E22A6C12C@llvm.org> Author: rafael Date: Wed Oct 5 15:05:13 2011 New Revision: 141204 URL: http://llvm.org/viewvc/llvm-project?rev=141204&view=rev Log: Check for the returns_twice attribute in callsFunctionThatReturnsTwice. This fixes PR11038, but there are still some cleanups to be done. Modified: llvm/trunk/include/llvm/Instructions.h llvm/trunk/lib/VMCore/Function.cpp llvm/trunk/test/Transforms/TailCallElim/setjmp.ll Modified: llvm/trunk/include/llvm/Instructions.h URL: http://llvm.org/viewvc/llvm-project/llvm/trunk/include/llvm/Instructions.h?rev=141204&r1=141203&r2=141204&view=diff ============================================================================== --- llvm/trunk/include/llvm/Instructions.h (original) +++ llvm/trunk/include/llvm/Instructions.h Wed Oct 5 15:05:13 2011 @@ -1267,6 +1267,15 @@ else removeAttribute(~0, Attribute::NoInline); } + /// @brief Return true if the call can return twice + bool canReturnTwice() const { + return paramHasAttr(~0, Attribute::ReturnsTwice); + } + void setCanReturnTwice(bool Value = true) { + if (Value) addAttribute(~0, Attribute::ReturnsTwice); + else removeAttribute(~0, Attribute::ReturnsTwice); + } + /// @brief Determine if the call does not access memory. bool doesNotAccessMemory() const { return paramHasAttr(~0, Attribute::ReadNone); Modified: llvm/trunk/lib/VMCore/Function.cpp URL: http://llvm.org/viewvc/llvm-project/llvm/trunk/lib/VMCore/Function.cpp?rev=141204&r1=141203&r2=141204&view=diff ============================================================================== --- llvm/trunk/lib/VMCore/Function.cpp (original) +++ llvm/trunk/lib/VMCore/Function.cpp Wed Oct 5 15:05:13 2011 @@ -17,6 +17,7 @@ #include "llvm/LLVMContext.h" #include "llvm/CodeGen/ValueTypes.h" #include "llvm/Support/CallSite.h" +#include "llvm/Support/InstIterator.h" #include "llvm/Support/LeakDetector.h" #include "llvm/Support/ManagedStatic.h" #include "llvm/Support/StringPool.h" @@ -416,7 +417,6 @@ /// FIXME: Remove after is fixed. /// FIXME: Is the above FIXME valid? bool Function::callsFunctionThatReturnsTwice() const { - const Module *M = this->getParent(); static const char *ReturnsTwiceFns[] = { "_setjmp", "setjmp", @@ -428,16 +428,25 @@ "getcontext" }; - for (unsigned I = 0; I < array_lengthof(ReturnsTwiceFns); ++I) - if (const Function *Callee = M->getFunction(ReturnsTwiceFns[I])) { - if (!Callee->use_empty()) - for (Value::const_use_iterator - I = Callee->use_begin(), E = Callee->use_end(); - I != E; ++I) - if (const CallInst *CI = dyn_cast(*I)) - if (CI->getParent()->getParent() == this) - return true; + for (const_inst_iterator I = inst_begin(this), E = inst_end(this); I != E; + ++I) { + const CallInst* callInst = dyn_cast(&*I); + if (!callInst) + continue; + if (callInst->canReturnTwice()) + return true; + + // check for known function names. + // FIXME: move this to clang. + Function *F = callInst->getCalledFunction(); + if (!F) + continue; + StringRef Name = F->getName(); + for (unsigned J = 0; J < array_lengthof(ReturnsTwiceFns); ++J) { + if (Name == ReturnsTwiceFns[J]) + return true; } + } return false; } Modified: llvm/trunk/test/Transforms/TailCallElim/setjmp.ll URL: http://llvm.org/viewvc/llvm-project/llvm/trunk/test/Transforms/TailCallElim/setjmp.ll?rev=141204&r1=141203&r2=141204&view=diff ============================================================================== --- llvm/trunk/test/Transforms/TailCallElim/setjmp.ll (original) +++ llvm/trunk/test/Transforms/TailCallElim/setjmp.ll Wed Oct 5 15:05:13 2011 @@ -1,16 +1,29 @@ ; RUN: opt < %s -tailcallelim -S | FileCheck %s -; Test that we don't tail call in a functions that calls setjmp. +; Test that we don't tail call in a functions that calls returns_twice +; functions. +declare void @bar() + +; CHECK: foo1 ; CHECK-NOT: tail call void @bar() -define void @foo(i32* %x) { +define void @foo1(i32* %x) { bb: %tmp75 = tail call i32 @setjmp(i32* %x) call void @bar() ret void } -declare i32 @setjmp(i32*) returns_twice +declare i32 @setjmp(i32*) -declare void @bar() +; CHECK: foo2 +; CHECK-NOT: tail call void @bar() + +define void @foo2(i32* %x) { +bb: + %tmp75 = tail call i32 @zed2(i32* %x) + call void @bar() + ret void +} +declare i32 @zed2(i32*) returns_twice From stoklund at 2pi.dk Wed Oct 5 15:26:35 2011 From: stoklund at 2pi.dk (Jakob Stoklund Olesen) Date: Wed, 05 Oct 2011 20:26:35 -0000 Subject: [llvm-commits] [llvm] r141206 - in /llvm/trunk/lib/Target/X86: X86RegisterInfo.cpp X86RegisterInfo.h Message-ID: <20111005202635.CB72F2A6C12C@llvm.org> Author: stoklund Date: Wed Oct 5 15:26:33 2011 New Revision: 141206 URL: http://llvm.org/viewvc/llvm-project?rev=141206&view=rev Log: Override TRI::getSubClassWithSubReg for X86. There are fewer registers with sub_8bit sub-registers in 32-bit mode than in 64-bit mode. In 32-bit mode, sub_8bit behaves the same as sub_8bit_hi. Modified: llvm/trunk/lib/Target/X86/X86RegisterInfo.cpp llvm/trunk/lib/Target/X86/X86RegisterInfo.h Modified: llvm/trunk/lib/Target/X86/X86RegisterInfo.cpp URL: http://llvm.org/viewvc/llvm-project/llvm/trunk/lib/Target/X86/X86RegisterInfo.cpp?rev=141206&r1=141205&r2=141206&view=diff ============================================================================== --- llvm/trunk/lib/Target/X86/X86RegisterInfo.cpp (original) +++ llvm/trunk/lib/Target/X86/X86RegisterInfo.cpp Wed Oct 5 15:26:33 2011 @@ -112,6 +112,18 @@ } const TargetRegisterClass * +X86RegisterInfo::getSubClassWithSubReg(const TargetRegisterClass *RC, + unsigned Idx) const { + // The sub_8bit sub-register index is more constrained in 32-bit mode. + // It behaves just like the sub_8bit_hi index. + if (!Is64Bit && Idx == X86::sub_8bit) + Idx = X86::sub_8bit_hi; + + // Forward to TableGen's default version. + return X86GenRegisterInfo::getSubClassWithSubReg(RC, Idx); +} + +const TargetRegisterClass * X86RegisterInfo::getMatchingSuperRegClass(const TargetRegisterClass *A, const TargetRegisterClass *B, unsigned SubIdx) const { Modified: llvm/trunk/lib/Target/X86/X86RegisterInfo.h URL: http://llvm.org/viewvc/llvm-project/llvm/trunk/lib/Target/X86/X86RegisterInfo.h?rev=141206&r1=141205&r2=141206&view=diff ============================================================================== --- llvm/trunk/lib/Target/X86/X86RegisterInfo.h (original) +++ llvm/trunk/lib/Target/X86/X86RegisterInfo.h Wed Oct 5 15:26:33 2011 @@ -74,6 +74,9 @@ getMatchingSuperRegClass(const TargetRegisterClass *A, const TargetRegisterClass *B, unsigned Idx) const; + virtual const TargetRegisterClass * + getSubClassWithSubReg(const TargetRegisterClass *RC, unsigned Idx) const; + const TargetRegisterClass* getLargestLegalSuperClass(const TargetRegisterClass *RC) const; From stoklund at 2pi.dk Wed Oct 5 15:26:40 2011 From: stoklund at 2pi.dk (Jakob Stoklund Olesen) Date: Wed, 05 Oct 2011 20:26:40 -0000 Subject: [llvm-commits] [llvm] r141207 - in /llvm/trunk/lib/CodeGen/SelectionDAG: InstrEmitter.cpp InstrEmitter.h Message-ID: <20111005202640.D09E32A6C12C@llvm.org> Author: stoklund Date: Wed Oct 5 15:26:40 2011 New Revision: 141207 URL: http://llvm.org/viewvc/llvm-project?rev=141207&view=rev Log: Simplify EXTRACT_SUBREG emission. EXTRACT_SUBREG is emitted as %dst = COPY %src:sub, so there is no need to constrain the %dst register class. RegisterCoalescer will apply the necessary constraints if it decides to eliminate the COPY. The %src register class does need to be constrained to something with the right sub-registers, though. This is currently done manually with COPY_TO_REGCLASS nodes. They can possibly be removed after this patch. Modified: llvm/trunk/lib/CodeGen/SelectionDAG/InstrEmitter.cpp llvm/trunk/lib/CodeGen/SelectionDAG/InstrEmitter.h Modified: llvm/trunk/lib/CodeGen/SelectionDAG/InstrEmitter.cpp URL: http://llvm.org/viewvc/llvm-project/llvm/trunk/lib/CodeGen/SelectionDAG/InstrEmitter.cpp?rev=141207&r1=141206&r2=141207&view=diff ============================================================================== --- llvm/trunk/lib/CodeGen/SelectionDAG/InstrEmitter.cpp (original) +++ llvm/trunk/lib/CodeGen/SelectionDAG/InstrEmitter.cpp Wed Oct 5 15:26:40 2011 @@ -30,6 +30,12 @@ #include "llvm/Support/MathExtras.h" using namespace llvm; +/// MinRCSize - Smallest register class we allow when constraining virtual +/// registers. If satisfying all register class constraints would require +/// using a smaller register class, emit a COPY to a new virtual register +/// instead. +const unsigned MinRCSize = 4; + /// CountResults - The results of target nodes have register or immediate /// operands first, then an optional chain, and optional glue operands (which do /// not go into the resulting MachineInstr). @@ -284,7 +290,6 @@ // a new virtual register and copy the value into it, but first attempt to // shrink VReg's register class within reason. For example, if VReg == GR32 // and II requires a GR32_NOSP, just constrain VReg to GR32_NOSP. - const unsigned MinRCSize = 4; if (II) { const TargetRegisterClass *DstRC = 0; if (IIOpNum < II->getNumOperands()) @@ -392,6 +397,30 @@ } } +unsigned InstrEmitter::ConstrainForSubReg(unsigned VReg, unsigned SubIdx, + EVT VT, DebugLoc DL) { + const TargetRegisterClass *VRC = MRI->getRegClass(VReg); + const TargetRegisterClass *RC = TRI->getSubClassWithSubReg(VRC, SubIdx); + + // RC is a sub-class of VRC that supports SubIdx. Try to constrain VReg + // within reason. + if (RC && RC != VRC) + RC = MRI->constrainRegClass(VReg, RC, MinRCSize); + + // VReg has been adjusted. It can be used with SubIdx operands now. + if (RC) + return VReg; + + // VReg couldn't be reasonably constrained. Emit a COPY to a new virtual + // register instead. + RC = TRI->getSubClassWithSubReg(TLI->getRegClassFor(VT), SubIdx); + assert(RC && "No legal register class for VT supports that SubIdx"); + unsigned NewReg = MRI->createVirtualRegister(RC); + BuildMI(*MBB, InsertPos, DL, TII->get(TargetOpcode::COPY), NewReg) + .addReg(VReg); + return NewReg; +} + /// EmitSubregNode - Generate machine code for subreg nodes. /// void InstrEmitter::EmitSubregNode(SDNode *Node, @@ -416,10 +445,12 @@ } if (Opc == TargetOpcode::EXTRACT_SUBREG) { - // EXTRACT_SUBREG is lowered as %dst = COPY %src:sub + // EXTRACT_SUBREG is lowered as %dst = COPY %src:sub. There are no + // constraints on the %dst register, COPY can target all legal register + // classes. unsigned SubIdx = cast(Node->getOperand(1))->getZExtValue(); + const TargetRegisterClass *TRC = TLI->getRegClassFor(Node->getValueType(0)); - // Figure out the register class to create for the destreg. unsigned VReg = getVR(Node->getOperand(0), VRBaseMap); MachineInstr *DefMI = MRI->getVRegDef(VReg); unsigned SrcReg, DstReg, DefSubIdx; @@ -431,36 +462,24 @@ // r1026 = extract_subreg r1025, 4 // to a copy // r1026 = copy r1024 - const TargetRegisterClass *TRC = MRI->getRegClass(SrcReg); VRBase = MRI->createVirtualRegister(TRC); BuildMI(*MBB, InsertPos, Node->getDebugLoc(), TII->get(TargetOpcode::COPY), VRBase).addReg(SrcReg); } else { - const TargetRegisterClass *TRC = MRI->getRegClass(VReg); - const TargetRegisterClass *SRC = TRC->getSubRegisterRegClass(SubIdx); - assert(SRC && "Invalid subregister index in EXTRACT_SUBREG"); - - // Figure out the register class to create for the destreg. - // Note that if we're going to directly use an existing register, - // it must be precisely the required class, and not a subclass - // thereof. - if (VRBase == 0 || SRC != MRI->getRegClass(VRBase)) { - // Create the reg - assert(SRC && "Couldn't find source register class"); - VRBase = MRI->createVirtualRegister(SRC); - } + // VReg may not support a SubIdx sub-register, and we may need to + // constrain its register class or issue a COPY to a compatible register + // class. + VReg = ConstrainForSubReg(VReg, SubIdx, + Node->getOperand(0).getValueType(), + Node->getDebugLoc()); + + // Create the destreg if it is missing. + if (VRBase == 0) + VRBase = MRI->createVirtualRegister(TRC); // Create the extract_subreg machine instruction. - MachineInstr *MI = BuildMI(*MF, Node->getDebugLoc(), - TII->get(TargetOpcode::COPY), VRBase); - - // Add source, and subreg index - AddOperand(MI, Node->getOperand(0), 0, 0, VRBaseMap, /*IsDebug=*/false, - IsClone, IsCloned); - assert(TargetRegisterInfo::isVirtualRegister(MI->getOperand(1).getReg())&& - "Cannot yet extract from physregs"); - MI->getOperand(1).setSubReg(SubIdx); - MBB->insert(InsertPos, MI); + BuildMI(*MBB, InsertPos, Node->getDebugLoc(), + TII->get(TargetOpcode::COPY), VRBase).addReg(VReg, 0, SubIdx); } } else if (Opc == TargetOpcode::INSERT_SUBREG || Opc == TargetOpcode::SUBREG_TO_REG) { Modified: llvm/trunk/lib/CodeGen/SelectionDAG/InstrEmitter.h URL: http://llvm.org/viewvc/llvm-project/llvm/trunk/lib/CodeGen/SelectionDAG/InstrEmitter.h?rev=141207&r1=141206&r2=141207&view=diff ============================================================================== --- llvm/trunk/lib/CodeGen/SelectionDAG/InstrEmitter.h (original) +++ llvm/trunk/lib/CodeGen/SelectionDAG/InstrEmitter.h Wed Oct 5 15:26:40 2011 @@ -77,6 +77,12 @@ DenseMap &VRBaseMap, bool IsDebug, bool IsClone, bool IsCloned); + /// ConstrainForSubReg - Try to constrain VReg to a register class that + /// supports SubIdx sub-registers. Emit a copy if that isn't possible. + /// Return the virtual register to use. + unsigned ConstrainForSubReg(unsigned VReg, unsigned SubIdx, + EVT VT, DebugLoc DL); + /// EmitSubregNode - Generate machine code for subreg nodes. /// void EmitSubregNode(SDNode *Node, DenseMap &VRBaseMap, From stoklund at 2pi.dk Wed Oct 5 15:36:06 2011 From: stoklund at 2pi.dk (Jakob Stoklund Olesen) Date: Wed, 05 Oct 2011 13:36:06 -0700 Subject: [llvm-commits] [llvm] r141203 - in /llvm/trunk: lib/Transforms/InstCombine/InstructionCombining.cpp test/Transforms/InstCombine/2010-11-01-lshr-mask.ll In-Reply-To: <20111005200501.2E6882A6C12C@llvm.org> References: <20111005200501.2E6882A6C12C@llvm.org> Message-ID: On Oct 5, 2011, at 1:05 PM, Jim Grosbach wrote: > Author: grosbach > Date: Wed Oct 5 15:05:00 2011 > New Revision: 141203 > > URL: http://llvm.org/viewvc/llvm-project?rev=141203&view=rev > Log: > Update InstCombine worklist after instruction transform is complete. > > When updating the worklist for InstCombine, the Add/AddUsersToWorklist > functions may access the instruction(s) being added, for debug output for > example. If the instructions aren't yet added to the basic block, this > can result in a crash. Finish the instruction transformation before > adjusting the worklist instead. Jim, After this commit, this test seems to be looping: $ opt < test/Transforms/InstCombine/or.ll -instcombine -S It is spending most of its time in SimplifyDemandedUseBits(). /jakob From grosbach at apple.com Wed Oct 5 15:37:35 2011 From: grosbach at apple.com (Jim Grosbach) Date: Wed, 05 Oct 2011 13:37:35 -0700 Subject: [llvm-commits] [llvm] r141203 - in /llvm/trunk: lib/Transforms/InstCombine/InstructionCombining.cpp test/Transforms/InstCombine/2010-11-01-lshr-mask.ll In-Reply-To: References: <20111005200501.2E6882A6C12C@llvm.org> Message-ID: <7A79F595-0CBB-4CE8-BC56-95ECA683DB6B@apple.com> On Oct 5, 2011, at 1:36 PM, Jakob Stoklund Olesen wrote: > > On Oct 5, 2011, at 1:05 PM, Jim Grosbach wrote: > >> Author: grosbach >> Date: Wed Oct 5 15:05:00 2011 >> New Revision: 141203 >> >> URL: http://llvm.org/viewvc/llvm-project?rev=141203&view=rev >> Log: >> Update InstCombine worklist after instruction transform is complete. >> >> When updating the worklist for InstCombine, the Add/AddUsersToWorklist >> functions may access the instruction(s) being added, for debug output for >> example. If the instructions aren't yet added to the basic block, this >> can result in a crash. Finish the instruction transformation before >> adjusting the worklist instead. > > Jim, > > After this commit, this test seems to be looping: > > $ opt < test/Transforms/InstCombine/or.ll -instcombine -S > > It is spending most of its time in SimplifyDemandedUseBits(). Huh. That's odd. It's passing for me OK. Lemme fiddle and try to reproduce. From eli.friedman at gmail.com Wed Oct 5 15:38:22 2011 From: eli.friedman at gmail.com (Eli Friedman) Date: Wed, 5 Oct 2011 13:38:22 -0700 Subject: [llvm-commits] [llvm] r141079 - in /llvm/trunk/lib/TableGen: CMakeLists.txt Main.cpp TGPreprocessor.cpp TGPreprocessor.h In-Reply-To: <20111004151452.DE8AB2A6C12C@llvm.org> References: <20111004151452.DE8AB2A6C12C@llvm.org> Message-ID: On Tue, Oct 4, 2011 at 8:14 AM, Che-Liang Chiou wrote: > Author: clchiou > Date: Tue Oct ?4 10:14:51 2011 > New Revision: 141079 > > URL: http://llvm.org/viewvc/llvm-project?rev=141079&view=rev > Log: > tblgen: add preprocessor as a separate mode > > This patch adds a preprocessor that can expand nested for-loops for > saving some copy-n-paste in *.td files. > > The preprocessor is not yet integrated with TGParser, and so it has > no direct effect on *.td inputs. ?However, you may preprocess an td > input (and only preprocess it). > > To test the proprecessor, type: > ?tblgen -E -o $@ $< Has anyone reviewed this feature? At first glance, this patch doesn't seem like the direction we want to go with TableGen. -Eli From stoklund at 2pi.dk Wed Oct 5 15:41:21 2011 From: stoklund at 2pi.dk (Jakob Stoklund Olesen) Date: Wed, 05 Oct 2011 13:41:21 -0700 Subject: [llvm-commits] [llvm] r141203 - in /llvm/trunk: lib/Transforms/InstCombine/InstructionCombining.cpp test/Transforms/InstCombine/2010-11-01-lshr-mask.ll In-Reply-To: <7A79F595-0CBB-4CE8-BC56-95ECA683DB6B@apple.com> References: <20111005200501.2E6882A6C12C@llvm.org> <7A79F595-0CBB-4CE8-BC56-95ECA683DB6B@apple.com> Message-ID: On Oct 5, 2011, at 1:37 PM, Jim Grosbach wrote: > > On Oct 5, 2011, at 1:36 PM, Jakob Stoklund Olesen wrote: > >> >> On Oct 5, 2011, at 1:05 PM, Jim Grosbach wrote: >> >>> Author: grosbach >>> Date: Wed Oct 5 15:05:00 2011 >>> New Revision: 141203 >>> >>> URL: http://llvm.org/viewvc/llvm-project?rev=141203&view=rev >>> Log: >>> Update InstCombine worklist after instruction transform is complete. >>> >>> When updating the worklist for InstCombine, the Add/AddUsersToWorklist >>> functions may access the instruction(s) being added, for debug output for >>> example. If the instructions aren't yet added to the basic block, this >>> can result in a crash. Finish the instruction transformation before >>> adjusting the worklist instead. >> >> Jim, >> >> After this commit, this test seems to be looping: >> >> $ opt < test/Transforms/InstCombine/or.ll -instcombine -S >> >> It is spending most of its time in SimplifyDemandedUseBits(). > > > Huh. That's odd. It's passing for me OK. Lemme fiddle and try to reproduce. I just double-checked that reverting this patch made it terminate properly. It's a Release+Asserts build. /jakob From grosbach at apple.com Wed Oct 5 15:44:30 2011 From: grosbach at apple.com (Jim Grosbach) Date: Wed, 05 Oct 2011 20:44:30 -0000 Subject: [llvm-commits] [llvm] r141209 - in /llvm/trunk: lib/Transforms/InstCombine/InstructionCombining.cpp test/Transforms/InstCombine/2010-11-01-lshr-mask.ll Message-ID: <20111005204430.C72CE2A6C12C@llvm.org> Author: grosbach Date: Wed Oct 5 15:44:29 2011 New Revision: 141209 URL: http://llvm.org/viewvc/llvm-project?rev=141209&view=rev Log: Revert 141203. InstCombine is looping on unit tests. Modified: llvm/trunk/lib/Transforms/InstCombine/InstructionCombining.cpp llvm/trunk/test/Transforms/InstCombine/2010-11-01-lshr-mask.ll Modified: llvm/trunk/lib/Transforms/InstCombine/InstructionCombining.cpp URL: http://llvm.org/viewvc/llvm-project/llvm/trunk/lib/Transforms/InstCombine/InstructionCombining.cpp?rev=141209&r1=141208&r2=141209&view=diff ============================================================================== --- llvm/trunk/lib/Transforms/InstCombine/InstructionCombining.cpp (original) +++ llvm/trunk/lib/Transforms/InstCombine/InstructionCombining.cpp Wed Oct 5 15:44:29 2011 @@ -2009,17 +2009,20 @@ ++NumCombined; // Should we replace the old instruction with a new one? if (Result != I) { + DEBUG(errs() << "IC: Old = " << *I << '\n' + << " New = " << *Result << '\n'); + if (!I->getDebugLoc().isUnknown()) Result->setDebugLoc(I->getDebugLoc()); // Everything uses the new instruction now. I->replaceAllUsesWith(Result); - // Move the name to the new instruction. - Result->takeName(I); - - DEBUG(errs() << "IC: Old = " << *I << '\n' - << " New = " << *Result << '\n'); + // Push the new instruction and any users onto the worklist. + Worklist.Add(Result); + Worklist.AddUsersToWorkList(*Result); + // Move the name to the new instruction first. + Result->takeName(I); // Insert the new instruction into the basic block... BasicBlock *InstParent = I->getParent(); @@ -2032,10 +2035,6 @@ InstParent->getInstList().insert(InsertPos, Result); EraseInstFromFunction(*I); - - // Push the new instruction and any users onto the worklist. - Worklist.Add(Result); - Worklist.AddUsersToWorkList(*Result); } else { #ifndef NDEBUG DEBUG(errs() << "IC: Mod = " << OrigI << '\n' Modified: llvm/trunk/test/Transforms/InstCombine/2010-11-01-lshr-mask.ll URL: http://llvm.org/viewvc/llvm-project/llvm/trunk/test/Transforms/InstCombine/2010-11-01-lshr-mask.ll?rev=141209&r1=141208&r2=141209&view=diff ============================================================================== --- llvm/trunk/test/Transforms/InstCombine/2010-11-01-lshr-mask.ll (original) +++ llvm/trunk/test/Transforms/InstCombine/2010-11-01-lshr-mask.ll Wed Oct 5 15:44:29 2011 @@ -5,8 +5,8 @@ define i32 @main(i32 %argc) nounwind ssp { entry: %tmp3151 = trunc i32 %argc to i8 -; CHECK: %0 = shl i8 %tmp3151, 5 -; CHECK: and i8 %0, 64 +; CHECK: %tmp3162 = shl i8 %tmp3151, 5 +; CHECK: and i8 %tmp3162, 64 ; CHECK-NOT: shl ; CHECK-NOT: shr %tmp3161 = or i8 %tmp3151, -17 From grosbach at apple.com Wed Oct 5 15:47:09 2011 From: grosbach at apple.com (Jim Grosbach) Date: Wed, 05 Oct 2011 13:47:09 -0700 Subject: [llvm-commits] [llvm] r141203 - in /llvm/trunk: lib/Transforms/InstCombine/InstructionCombining.cpp test/Transforms/InstCombine/2010-11-01-lshr-mask.ll In-Reply-To: References: <20111005200501.2E6882A6C12C@llvm.org> <7A79F595-0CBB-4CE8-BC56-95ECA683DB6B@apple.com> Message-ID: On Oct 5, 2011, at 1:41 PM, Jakob Stoklund Olesen wrote: > > On Oct 5, 2011, at 1:37 PM, Jim Grosbach wrote: > >> >> On Oct 5, 2011, at 1:36 PM, Jakob Stoklund Olesen wrote: >> >>> >>> On Oct 5, 2011, at 1:05 PM, Jim Grosbach wrote: >>> >>>> Author: grosbach >>>> Date: Wed Oct 5 15:05:00 2011 >>>> New Revision: 141203 >>>> >>>> URL: http://llvm.org/viewvc/llvm-project?rev=141203&view=rev >>>> Log: >>>> Update InstCombine worklist after instruction transform is complete. >>>> >>>> When updating the worklist for InstCombine, the Add/AddUsersToWorklist >>>> functions may access the instruction(s) being added, for debug output for >>>> example. If the instructions aren't yet added to the basic block, this >>>> can result in a crash. Finish the instruction transformation before >>>> adjusting the worklist instead. >>> >>> Jim, >>> >>> After this commit, this test seems to be looping: >>> >>> $ opt < test/Transforms/InstCombine/or.ll -instcombine -S >>> >>> It is spending most of its time in SimplifyDemandedUseBits(). >> >> >> Huh. That's odd. It's passing for me OK. Lemme fiddle and try to reproduce. > > I just double-checked that reverting this patch made it terminate properly. > > It's a Release+Asserts build. Thanks. Something odd going on there. Reverted in 141209. I should be able to fix the --debug crash a bit more conservatively. From stoklund at 2pi.dk Wed Oct 5 15:51:12 2011 From: stoklund at 2pi.dk (Jakob Stoklund Olesen) Date: Wed, 05 Oct 2011 13:51:12 -0700 Subject: [llvm-commits] [llvm] r141203 - in /llvm/trunk: lib/Transforms/InstCombine/InstructionCombining.cpp test/Transforms/InstCombine/2010-11-01-lshr-mask.ll In-Reply-To: References: <20111005200501.2E6882A6C12C@llvm.org> <7A79F595-0CBB-4CE8-BC56-95ECA683DB6B@apple.com> Message-ID: <7C77FB5A-22A0-4614-99E6-5468950FFAEE@2pi.dk> On Oct 5, 2011, at 1:47 PM, Jim Grosbach wrote: > > On Oct 5, 2011, at 1:41 PM, Jakob Stoklund Olesen wrote: > >>>> After this commit, this test seems to be looping: >>>> >>>> $ opt < test/Transforms/InstCombine/or.ll -instcombine -S >>>> >>>> It is spending most of its time in SimplifyDemandedUseBits(). >>> >>> >>> Huh. That's odd. It's passing for me OK. Lemme fiddle and try to reproduce. >> >> I just double-checked that reverting this patch made it terminate properly. >> >> It's a Release+Asserts build. > > Thanks. Something odd going on there. Reverted in 141209. I should be able to fix the --debug crash a bit more conservatively. Thanks. I was building with a clang from, say, a week ago. I'll try self hosting with r141207 to see if it was a miscompilation. /jakob From grosbach at apple.com Wed Oct 5 15:53:45 2011 From: grosbach at apple.com (Jim Grosbach) Date: Wed, 05 Oct 2011 20:53:45 -0000 Subject: [llvm-commits] [llvm] r141210 - /llvm/trunk/lib/Transforms/InstCombine/InstructionCombining.cpp Message-ID: <20111005205345.E8B852A6C12C@llvm.org> Author: grosbach Date: Wed Oct 5 15:53:43 2011 New Revision: 141210 URL: http://llvm.org/viewvc/llvm-project?rev=141210&view=rev Log: Re-commit 141203, but much more conservative. Just pull the instruction name, but don't change the order of anything else. That keeps --debug happy and non-crashing, but doesn't change how the worklist gets built. Modified: llvm/trunk/lib/Transforms/InstCombine/InstructionCombining.cpp Modified: llvm/trunk/lib/Transforms/InstCombine/InstructionCombining.cpp URL: http://llvm.org/viewvc/llvm-project/llvm/trunk/lib/Transforms/InstCombine/InstructionCombining.cpp?rev=141210&r1=141209&r2=141210&view=diff ============================================================================== --- llvm/trunk/lib/Transforms/InstCombine/InstructionCombining.cpp (original) +++ llvm/trunk/lib/Transforms/InstCombine/InstructionCombining.cpp Wed Oct 5 15:53:43 2011 @@ -2017,13 +2017,13 @@ // Everything uses the new instruction now. I->replaceAllUsesWith(Result); + // Move the name to the new instruction first. + Result->takeName(I); + // Push the new instruction and any users onto the worklist. Worklist.Add(Result); Worklist.AddUsersToWorkList(*Result); - // Move the name to the new instruction first. - Result->takeName(I); - // Insert the new instruction into the basic block... BasicBlock *InstParent = I->getParent(); BasicBlock::iterator InsertPos = I; From grosser at fim.uni-passau.de Wed Oct 5 16:10:10 2011 From: grosser at fim.uni-passau.de (Tobias Grosser) Date: Wed, 05 Oct 2011 21:10:10 -0000 Subject: [llvm-commits] [polly] r141212 - in /polly/trunk: utils/checkout_cloog.sh utils/get_cloog.sh www/get_started.html www/menu.html.incl Message-ID: <20111005211010.A9C8E312800A@llvm.org> Author: grosser Date: Wed Oct 5 16:10:10 2011 New Revision: 141212 URL: http://llvm.org/viewvc/llvm-project?rev=141212&view=rev Log: Add a tool to checkout cloog/isl automatically with the correct versions. The tool is called checkout_cloog.sh. We also update the get_started documentation to include this tool. An older unfinished tool called 'get_cloog.sh' is removed to avoid confusion. Added: polly/trunk/utils/checkout_cloog.sh (with props) Removed: polly/trunk/utils/get_cloog.sh Modified: polly/trunk/www/get_started.html polly/trunk/www/menu.html.incl Added: polly/trunk/utils/checkout_cloog.sh URL: http://llvm.org/viewvc/llvm-project/polly/trunk/utils/checkout_cloog.sh?rev=141212&view=auto ============================================================================== --- polly/trunk/utils/checkout_cloog.sh (added) +++ polly/trunk/utils/checkout_cloog.sh Wed Oct 5 16:10:10 2011 @@ -0,0 +1,86 @@ +#!/bin/sh + +CLOOG_HASH="cloog-0.16.3" +ISL_HASH="cd1939ed06617d00159e8e51b72a804b467e98b4" + +check_command_line() { + if [ "${1}x" = "x" ] || [ "${2}x" != "x" ] + then + echo "Usage: " ${0} '' + else + CLOOG_DIR="${1}" + fi +} + +check_cloog_directory() { + if not [ -e ${CLOOG_DIR} ] + then + echo :: Directory "'${CLOOG_DIR}'" does not exists. Trying to create it. + if not mkdir -p "${CLOOG_DIR}" + then exit 1 + fi + fi + + if not [ -d ${CLOOG_DIR} ] + then + echo "'${CLOOG_DIR}'" is not a directory + exit 1 + fi + + if not [ -e "${CLOOG_DIR}/.git" ] + then + IS_GIT=0 + echo ":: No git checkout found" + if [ `ls -A ${CLOOG_DIR}` ] + then + echo but directory "'${CLOOG_DIR}'" contains files + exit 1 + fi + else + echo ":: Existing git repo found" + IS_GIT=1 + fi +} + +complain() { + echo "$@" + exit 1 +} + +run() { + $cmdPre $* + if [ $? != 0 ] + then + complain $* failed + fi +} + +check_command_line $@ +check_cloog_directory + +cd ${CLOOG_DIR} + + + + +if [ ${IS_GIT} -eq 0 ] +then + echo :: Performing initial checkout + run git clone git://repo.or.cz/cloog.git . + run git submodule init + run git submodule update +fi + +echo :: Fetch versions required by Polly +run git remote update +run git reset --hard "${CLOOG_HASH}" +run cd isl +run git remote update +run git reset --hard "${ISL_HASH}" + +echo :: Generating configure +run ./autogen.sh + +echo :: If you install cloog/isl the first time run "'./configure'" followed by +echo :: "'make'" and "'make install'", otherwise, just call "'make'" and +echo :: "'make'" install. Propchange: polly/trunk/utils/checkout_cloog.sh ------------------------------------------------------------------------------ svn:executable = * Removed: polly/trunk/utils/get_cloog.sh URL: http://llvm.org/viewvc/llvm-project/polly/trunk/utils/get_cloog.sh?rev=141211&view=auto ============================================================================== --- polly/trunk/utils/get_cloog.sh (original) +++ polly/trunk/utils/get_cloog.sh (removed) @@ -1,160 +0,0 @@ -#!/bin/bash -# -# get_cloog.sh - retrieve cloog from git repo to current directory, configure, build -# and install into , which defaults to cwd. -# -# Basic process is: -# 1. git clone git://repo.or.cz/cloog.git -# 2. cd cloog -# 3. ./get_submodules.sh -# 4. ./autogen.sh -# 5. ./configure --prefix= -# - -this=$0 -verb=false -destDir=none -libGMPDir=/usr -forceClone=false -cmdPre="" - -usage() { - echo usage: $this '[--verbose --dry-run --force --gmp= ]' - echo 'where: must exist, defaults to cwd' - echo ' : path to GMP library, defaults to /usr' - exit $1 -} - -vsay() { - if [[ $verb = true ]] ; then - echo "$@" - fi -} - -complain() { - echo "$@" - exit 1 -} - -# Function to make a directory including its ancestors. -makedir() { - if [[ $1 == "" ]] ; then - : - elif [[ -d $1 ]] ; then - : - else - makedirtmp=`dirname "$1"` - makedir "$makedirtmp" - vsay "$this: Making directory $1" - if mkdir "$1" ; then - : - else - complain "$this: mkdir $1 failed" - fi - fi -} - -# echo/run command line, complain if it fails. -runCmd() { - $cmdPre $* - if [[ $? != 0 ]] ; then - complain $* failed - fi -} - -ACTUAL_PWD=`pwd` -ROOT=${PWD:-$ACTUAL_PWD} -vsay $this: Polylibs root is $ROOT. - -while [[ $# != 0 ]] ; do - tmp=`echo $1 | sed -e 's;^[-]*;;g'` - if [[ $tmp == $1 ]] ; then - if [[ $destDir == none ]] ; then - destDir=$tmp - fi - else - switchArg=`echo $tmp | cut -s -d= -f2` - if [[ $switchArg != "" ]] ; then - tmp=`echo $tmp | cut -d= -f1` - fi - case $tmp in - dry-run) - cmdPre=echo - ;; - force) - forceClone=true - ;; - gmp) - if [[ $switchArg == "" ]] ; then - echo "$this: --gmp requires a pathname argument" - usage 1 - fi - libGMPDir=$switchArg - ;; - help) - usage 0 - ;; - verbose) - verb=true - ;; - *) - usage 1 - ;; - esac - fi - shift -done - -if [[ $destDir == none ]] ; then - destDir=$ACTUAL_PWD -else - # Create specified install directory if it doesn't exist. - makedir $destDir -fi - -destDir=`(cd $destDir ; echo $PWD)` - -if [[ ! -d $libGMPDir ]] ; then - complain GMP dir $libGMPDIR not found. -fi -if [[ ! -f $libGMPDir/include/gmp.h ]] ; then - complain $libGMPDir does not appear to contain a GMP library. -fi - -# Check for libtoolize, required by cloog/autogen.sh -tmp=`which libtoolize` -if [[ $tmp == "" ]] ; then - complain libtoolize '(needed by cloog/autogen.sh)' not found -fi - -# 1. Get cloog, remove existing cloog tree if forcing. -if [[ $forceClone == true ]] ; then - vsay removing existing cloog tree - rm -rf ./cloog -fi - -# Allow reuse of existing cloog tree. -if [[ ! -d cloog ]] ; then - vsay cloning git repo into $ROOT/cloog - runCmd git clone git://repo.or.cz/cloog.git -else - vsay using existing cloog tree: $ROOT/cloog -fi - -runCmd cd cloog - -# 2. Get bundled isl library -runCmd ./get_submodules.sh - -# 3. Generate configure scripts for cloog and isl -runCmd ./autogen.sh - -configArgs="--without-polylib --with-isl=bundled" -configArgs="$configArgs --with-gmp-prefix=$libGMPDir --prefix=$destDir" - -# 4. Configure cloog and isl -runCmd ./configure $configArgs - -exit 0 - - Modified: polly/trunk/www/get_started.html URL: http://llvm.org/viewvc/llvm-project/polly/trunk/www/get_started.html?rev=141212&r1=141211&r2=141212&view=diff ============================================================================== --- polly/trunk/www/get_started.html (original) +++ polly/trunk/www/get_started.html Wed Oct 5 16:10:10 2011 @@ -15,47 +15,69 @@

Getting Started: Building and Installing Polly

+

Get the code

+ +The Polly source code is available in the LLVM SVN repository as well as in an +official a git mirror. It is added to the tools +directory of the llvm sources. +Polly and LLVM need to be checked out at the time. Checkouts + from different dates may not work! +

Set the directory layout:

+
+export BASE=`pwd`
+export LLVM_SRC=${BASE}/llvm
+export POLLY_SRC=${LLVM_SRC}/tools/polly
+
+

SVN

+
+svn checkout http://llvm.org/svn/llvm-project/llvm/trunk ${LLVM_SRC}
+svn checkout http://llvm.org/svn/llvm-project/polly/trunk ${POLLY_SRC}
+
+

GIT

+
+git clone http://llvm.org/git/llvm.git ${LLVM_SRC}
+git clone http://llvm.org/git/polly.git ${POLLY_SRC}
+

Prerequisites

+
    +
  • libgmp
  • +
  • CLooG/isl
  • +
  • PoCC (optional)
  • +
-The following prerequisites can be installed through the package management +

libgmp

+Install libgmp (library + developer package) through the package management system of your operating system. -
    -
  • libgmp (library + developer package)
  • -
+

CLooG/isl

-

Install ISL / CLooG libraries

+Polly is tested and works with CLooG as of +commit 225c2ed62fe37a4db22bf4b95c3731dab1a50dde +and isl as of +commit cd1939ed06617d00159e8e51b72a804b467e98b4. To get and install the +relevant cloog version use the following commands: -Polly requires the latest versions of CLooG -and isl checked out at -commit cd1939ed06617d00159e8e51b72a804b467e98b4. +

Set the directory layout:

+
+export CLOOG_SRC=${BASE}/cloog_src
+export CLOOG_INSTALL=${LLVM_SRC}/cloog_install
+

First installation

-git clone git://repo.or.cz/cloog.git
-cd cloog
-git checkout cloog-0.16.3
-./get_submodules.sh
-cd isl
-git remote update
-git checkout cd1939ed06617d00159e8e51b72a804b467e98b4
-cd ..
-./autogen.sh
-./configure --with-gmp-prefix=/path/to/gmp/installation --prefix=/path/to/cloog/installation
+${POLLY_SRC}/utils/checkout_cloog.sh ${CLOOG_SRC}
+${POLLY_SRC}/configure --prefix=${CLOOG_INSTALL}
 make
 make install
 
-

Update an earlier installation

+

Update the installation

+ +Updating CLooG may become necessary, if Polly uses a feature +only available in a recent version of CLooG.
-cd cloog
-git remote update
-git checkout cloog-0.16.3
-cd isl
-git remote update
-git checkout cd1939ed06617d00159e8e51b72a804b467e98b4
-cd ..
+${POLLY_SRC}/utils/checkout_cloog.sh ${CLOOG_SRC}
 make
 make install
 
@@ -94,59 +116,30 @@ make && make install -

Get the code

- -

-The Polly source code is available in the LLVM SVN repository. For convenience -we also provide a git mirror. To build Polly we extract its source code into the -tools directory of the llvm sources.

-A recent LLVM checkout is needed. Older versions may not work! - -

SVN

-
-export LLVM_SRC=`pwd`/llvm
-svn checkout http://llvm.org/svn/llvm-project/llvm/trunk ${LLVM_SRC}
-cd ${LLVM_SRC}/tools
-svn checkout http://llvm.org/svn/llvm-project/polly/trunk polly
-
-

GIT

-
-export LLVM_SRC=`pwd`/llvm
-git clone http://llvm.org/git/llvm.git ${LLVM_SRC}
-cd ${LLVM_SRC}/tools
-git clone http://llvm.org/git/polly.git
-
- - -

Build Polly

To build Polly you can either use the autoconf or the cmake build system. At the moment only the autoconf build system allows to run the llvm test-suite and only the cmake build system allows to run 'make polly-test'. -

CMake

- +

Set the directory layout:

-mkdir build
-cd build
-cmake ${LLVM_SRC}
-
-# If CMAKE cannot find CLooG and ISL
-cmake -DCMAKE_PREFIX_PATH=/cloog/installation .
+export LLVM_BUILD=${BASE}/llvm_build
+mkdir ${LLVM_BUILD}
+cd ${LLVM_BUILD}
+
-# To point CMAKE to the scoplib source -cmake -DCMAKE_PREFIX_PATH=/scoplib/installation . +

CMake

+
+cmake -DCMAKE_PREFIX_PATH=${CLOOG_INSTALL} ${LLVM_SRC}
 make
 
-

Autoconf

+

Autoconf

-mkdir build
-cd build
-${LLVM_SRC}/configure --with-cloog=/cloog/installation --with-isl=/cloog/installation --with-scoplib=/scoplib/installation
+${LLVM_SRC}/configure --with-cloog=${CLOOG_INSTALL} --with-isl=${CLOOG_INSTALL}
 make
 
Modified: polly/trunk/www/menu.html.incl URL: http://llvm.org/viewvc/llvm-project/polly/trunk/www/menu.html.incl?rev=141212&r1=141211&r2=141212&view=diff ============================================================================== --- polly/trunk/www/menu.html.incl (original) +++ polly/trunk/www/menu.html.incl Wed Oct 5 16:10:10 2011 @@ -26,9 +26,7 @@ From greened at obbligato.org Wed Oct 5 17:42:48 2011 From: greened at obbligato.org (David Greene) Date: Wed, 05 Oct 2011 22:42:48 -0000 Subject: [llvm-commits] [llvm] r141235 - /llvm/trunk/test/TableGen/MultiPat.td Message-ID: <20111005224248.8FCF02A6C12C@llvm.org> Author: greened Date: Wed Oct 5 17:42:48 2011 New Revision: 141235 URL: http://llvm.org/viewvc/llvm-project?rev=141235&view=rev Log: Update Test for Multidefs Update the MultiPat.td test to create some defs via multidefs. Modified: llvm/trunk/test/TableGen/MultiPat.td Modified: llvm/trunk/test/TableGen/MultiPat.td URL: http://llvm.org/viewvc/llvm-project/llvm/trunk/test/TableGen/MultiPat.td?rev=141235&r1=141234&r2=141235&view=diff ============================================================================== --- llvm/trunk/test/TableGen/MultiPat.td (original) +++ llvm/trunk/test/TableGen/MultiPat.td Wed Oct 5 17:42:48 2011 @@ -85,8 +85,16 @@ def int_x86_sse2_add_pd : Intrinsic<"addpd">; def INTRINSIC : Intrinsic<"Dummy">; def bitconvert; +def add; -class MakePat patterns> : Pat; +class MakePatImpl patterns> : Pat; +class MakePat patterns, + string suffix, + string intr> : MakePatImpl(!subst("SUFFIX", suffix, intr)), + !subst(REGCLASS, VR128, + !subst(MNEMONIC, set, Decls.operand)))))>; class Base opcode, dag opnds, dag iopnds, string asmstr, Intrinsic intr, list> patterns> @@ -95,12 +103,7 @@ !foreach(Decls.operand, Decls.pattern, !subst(INTRINSIC, intr, !subst(REGCLASS, VR128, - !subst(MNEMONIC, set, Decls.operand)))))>, - MakePat; + !subst(MNEMONIC, set, Decls.operand)))))>; multiclass arith opcode, string asmstr, string intr, list> patterns> { def PS : Base(!subst("SUFFIX", "_pd", intr)), patterns>; + + multidef pats, 1> : MakePat; + multidef pats, 1> : MakePat; } defm ADD : arith<0x58, "add", "int_x86_sse2_addSUFFIX", // rr Patterns [[(set REGCLASS:$dst, (INTRINSIC REGCLASS:$src1, REGCLASS:$src2))], [(set REGCLASS:$dst, (bitconvert (INTRINSIC REGCLASS:$src1, REGCLASS:$src2))), - (MNEMONIC REGCLASS:$dst, REGCLASS:$src)]]>; + (MNEMONIC REGCLASS:$dst, REGCLASS:$src)], + [(set REGCLASS:$dst, (add (INTRINSIC REGCLASS:$src1, REGCLASS:$src2))), + (MNEMONIC (add REGCLASS:$dst, REGCLASS:$src))]]>; // CHECK: [(set VR128:$dst, (int_x86_sse2_add_pd VR128:$src1, VR128:$src2))] // CHECK: [(set VR128:$dst, (int_x86_sse2_add_ps VR128:$src1, VR128:$src2))] From greened at obbligato.org Wed Oct 5 17:42:51 2011 From: greened at obbligato.org (David Greene) Date: Wed, 05 Oct 2011 22:42:51 -0000 Subject: [llvm-commits] [llvm] r141237 - /llvm/trunk/utils/emacs/tablegen-mode.el Message-ID: <20111005224251.6F2D32A6C12C@llvm.org> Author: greened Date: Wed Oct 5 17:42:51 2011 New Revision: 141237 URL: http://llvm.org/viewvc/llvm-project?rev=141237&view=rev Log: Emacs Support for Multidefs Add Emacs font-lock keyword support for multidefs. Modified: llvm/trunk/utils/emacs/tablegen-mode.el Modified: llvm/trunk/utils/emacs/tablegen-mode.el URL: http://llvm.org/viewvc/llvm-project/llvm/trunk/utils/emacs/tablegen-mode.el?rev=141237&r1=141236&r2=141237&view=diff ============================================================================== --- llvm/trunk/utils/emacs/tablegen-mode.el (original) +++ llvm/trunk/utils/emacs/tablegen-mode.el Wed Oct 5 17:42:51 2011 @@ -13,7 +13,7 @@ (defvar tablegen-font-lock-keywords (let ((kw (regexp-opt '("class" "defm" "def" "field" "include" "in" - "let" "multiclass") + "let" "multiclass" "multidef") 'words)) (type-kw (regexp-opt '("bit" "bits" "code" "dag" "int" "list" "string") 'words)) From greened at obbligato.org Wed Oct 5 17:42:52 2011 From: greened at obbligato.org (David Greene) Date: Wed, 05 Oct 2011 22:42:52 -0000 Subject: [llvm-commits] [llvm] r141238 - /llvm/trunk/utils/vim/tablegen.vim Message-ID: <20111005224252.CBB1F2A6C12C@llvm.org> Author: greened Date: Wed Oct 5 17:42:52 2011 New Revision: 141238 URL: http://llvm.org/viewvc/llvm-project?rev=141238&view=rev Log: Vim Support for Multidefs Add vim highlighting support for multidefs. Modified: llvm/trunk/utils/vim/tablegen.vim Modified: llvm/trunk/utils/vim/tablegen.vim URL: http://llvm.org/viewvc/llvm-project/llvm/trunk/utils/vim/tablegen.vim?rev=141238&r1=141237&r2=141238&view=diff ============================================================================== --- llvm/trunk/utils/vim/tablegen.vim (original) +++ llvm/trunk/utils/vim/tablegen.vim Wed Oct 5 17:42:52 2011 @@ -14,7 +14,7 @@ syn case match -syn keyword tgKeyword def let in code dag field include defm +syn keyword tgKeyword def let in code dag field include defm multidef syn keyword tgType class int string list bit bits multiclass syn match tgNumber /\<\d\+\>/ From greened at obbligato.org Wed Oct 5 17:42:54 2011 From: greened at obbligato.org (David Greene) Date: Wed, 05 Oct 2011 22:42:54 -0000 Subject: [llvm-commits] [llvm] r141239 - /llvm/trunk/lib/TableGen/TGParser.cpp Message-ID: <20111005224254.3934F2A6C12C@llvm.org> Author: greened Date: Wed Oct 5 17:42:54 2011 New Revision: 141239 URL: http://llvm.org/viewvc/llvm-project?rev=141239&view=rev Log: Prefix Template Arg Names with Multiclass Name For consistency, prefix multiclass template arg names with the multiclass name followed by "::" to avoid name clashes among multiclass arguments and other entities in the multiclass. Modified: llvm/trunk/lib/TableGen/TGParser.cpp Modified: llvm/trunk/lib/TableGen/TGParser.cpp URL: http://llvm.org/viewvc/llvm-project/llvm/trunk/lib/TableGen/TGParser.cpp?rev=141239&r1=141238&r2=141239&view=diff ============================================================================== --- llvm/trunk/lib/TableGen/TGParser.cpp (original) +++ llvm/trunk/lib/TableGen/TGParser.cpp Wed Oct 5 17:42:54 2011 @@ -650,6 +650,9 @@ return VarInit::get(Name, RV->getType()); std::string TemplateArgName = CurRec->getName()+":"+Name; + if (CurMultiClass) + TemplateArgName = CurMultiClass->Rec.getName()+"::"+TemplateArgName; + if (CurRec->isTemplateArg(TemplateArgName)) { const RecordVal *RV = CurRec->getValue(TemplateArgName); assert(RV && "Template arg doesn't exist??"); From grosser at fim.uni-passau.de Wed Oct 5 18:11:18 2011 From: grosser at fim.uni-passau.de (Tobias Grosser) Date: Wed, 05 Oct 2011 23:11:18 -0000 Subject: [llvm-commits] [polly] r141242 - /polly/trunk/utils/checkout_cloog.sh Message-ID: <20111005231118.3C4CD2A6C12C@llvm.org> Author: grosser Date: Wed Oct 5 18:11:17 2011 New Revision: 141242 URL: http://llvm.org/viewvc/llvm-project?rev=141242&view=rev Log: checkout_cloog: Fix this script to run on our buildbot. Modified: polly/trunk/utils/checkout_cloog.sh Modified: polly/trunk/utils/checkout_cloog.sh URL: http://llvm.org/viewvc/llvm-project/polly/trunk/utils/checkout_cloog.sh?rev=141242&r1=141241&r2=141242&view=diff ============================================================================== --- polly/trunk/utils/checkout_cloog.sh (original) +++ polly/trunk/utils/checkout_cloog.sh Wed Oct 5 18:11:17 2011 @@ -13,21 +13,21 @@ } check_cloog_directory() { - if not [ -e ${CLOOG_DIR} ] + if ! [ -e ${CLOOG_DIR} ] then echo :: Directory "'${CLOOG_DIR}'" does not exists. Trying to create it. - if not mkdir -p "${CLOOG_DIR}" + if ! mkdir -p "${CLOOG_DIR}" then exit 1 fi fi - if not [ -d ${CLOOG_DIR} ] + if ! [ -d ${CLOOG_DIR} ] then echo "'${CLOOG_DIR}'" is not a directory exit 1 fi - if not [ -e "${CLOOG_DIR}/.git" ] + if ! [ -e "${CLOOG_DIR}/.git" ] then IS_GIT=0 echo ":: No git checkout found" @@ -66,9 +66,8 @@ if [ ${IS_GIT} -eq 0 ] then echo :: Performing initial checkout - run git clone git://repo.or.cz/cloog.git . - run git submodule init - run git submodule update + run git clone http://repo.or.cz/r/cloog.git . + run git clone http://repo.or.cz/r/isl.git isl fi echo :: Fetch versions required by Polly @@ -77,6 +76,7 @@ run cd isl run git remote update run git reset --hard "${ISL_HASH}" +run cd .. echo :: Generating configure run ./autogen.sh From greened at obbligato.org Wed Oct 5 18:16:45 2011 From: greened at obbligato.org (David Greene) Date: Wed, 05 Oct 2011 23:16:45 -0000 Subject: [llvm-commits] [llvm] r141243 - /llvm/trunk/docs/TableGenFundamentals.html Message-ID: <20111005231645.37FE32A6C12C@llvm.org> Author: greened Date: Wed Oct 5 18:16:44 2011 New Revision: 141243 URL: http://llvm.org/viewvc/llvm-project?rev=141243&view=rev Log: Fix a typo. Fix the argument passed in the multidef example. Modified: llvm/trunk/docs/TableGenFundamentals.html Modified: llvm/trunk/docs/TableGenFundamentals.html URL: http://llvm.org/viewvc/llvm-project/llvm/trunk/docs/TableGenFundamentals.html?rev=141243&r1=141242&r2=141243&view=diff ============================================================================== --- llvm/trunk/docs/TableGenFundamentals.html (original) +++ llvm/trunk/docs/TableGenFundamentals.html Wed Oct 5 18:16:44 2011 @@ -784,7 +784,7 @@ def ONE : Base<values[0]>; def TWO : Base<values[1]>; - multidef COUNT<values, int v, 2> : Base<:v>; + multidef COUNT<values, int v, 2> : Base<v>; } defm List : Multi<[1, 2, 3, 4, 5, 6]<; From isanbard at gmail.com Wed Oct 5 18:26:11 2011 From: isanbard at gmail.com (Bill Wendling) Date: Wed, 05 Oct 2011 23:26:11 -0000 Subject: [llvm-commits] [llvm] r141244 - /llvm/trunk/include/llvm/CodeGen/MachineModuleInfo.h Message-ID: <20111005232612.004432A6C12C@llvm.org> Author: void Date: Wed Oct 5 18:26:10 2011 New Revision: 141244 URL: http://llvm.org/viewvc/llvm-project?rev=141244&view=rev Log: Add accessor method to check if the landing pad symbol has call site information. Modified: llvm/trunk/include/llvm/CodeGen/MachineModuleInfo.h Modified: llvm/trunk/include/llvm/CodeGen/MachineModuleInfo.h URL: http://llvm.org/viewvc/llvm-project/llvm/trunk/include/llvm/CodeGen/MachineModuleInfo.h?rev=141244&r1=141243&r2=141244&view=diff ============================================================================== --- llvm/trunk/include/llvm/CodeGen/MachineModuleInfo.h (original) +++ llvm/trunk/include/llvm/CodeGen/MachineModuleInfo.h Wed Oct 5 18:26:10 2011 @@ -338,9 +338,17 @@ /// getCallSiteLandingPad - Get the call site indexes for a landing pad EH /// symbol. SmallVectorImpl &getCallSiteLandingPad(MCSymbol *Sym) { + assert(hasCallSiteLandingPad(Sym) && + "missing call site number for landing pad!"); return LPadToCallSiteMap[Sym]; } + /// hasCallSiteLandingPad - Return true if the landing pad Eh symbol has an + /// associated call site. + bool hasCallSiteLandingPad(MCSymbol *Sym) { + return !LPadToCallSiteMap[Sym].empty(); + } + /// setCallSiteBeginLabel - Map the begin label for a call site. void setCallSiteBeginLabel(MCSymbol *BeginLabel, unsigned Site) { CallSiteMap[BeginLabel] = Site; From isanbard at gmail.com Wed Oct 5 18:28:57 2011 From: isanbard at gmail.com (Bill Wendling) Date: Wed, 05 Oct 2011 23:28:57 -0000 Subject: [llvm-commits] [llvm] r141245 - /llvm/trunk/lib/Target/ARM/ARMISelLowering.cpp Message-ID: <20111005232857.A378B2A6C12C@llvm.org> Author: void Date: Wed Oct 5 18:28:57 2011 New Revision: 141245 URL: http://llvm.org/viewvc/llvm-project?rev=141245&view=rev Log: Get the proper call site numbers for the landing pads. Also remove a magic number (18) for the proper addressing mode. Modified: llvm/trunk/lib/Target/ARM/ARMISelLowering.cpp Modified: llvm/trunk/lib/Target/ARM/ARMISelLowering.cpp URL: http://llvm.org/viewvc/llvm-project/llvm/trunk/lib/Target/ARM/ARMISelLowering.cpp?rev=141245&r1=141244&r2=141245&view=diff ============================================================================== --- llvm/trunk/lib/Target/ARM/ARMISelLowering.cpp (original) +++ llvm/trunk/lib/Target/ARM/ARMISelLowering.cpp Wed Oct 5 18:28:57 2011 @@ -5598,11 +5598,15 @@ if (!II->isEHLabel()) continue; MCSymbol *Sym = II->getOperand(0).getMCSymbol(); - if (!MMI.hasCallSiteBeginLabel(Sym)) continue; + if (!MMI.hasCallSiteLandingPad(Sym)) continue; - unsigned CallSiteNum = MMI.getCallSiteBeginLabel(Sym); - CallSiteNumToLPad[CallSiteNum].push_back(BB); - MaxCSNum = std::max(MaxCSNum, CallSiteNum); + SmallVectorImpl &CallSiteIdxs = MMI.getCallSiteLandingPad(Sym); + for (SmallVectorImpl::iterator + CSI = CallSiteIdxs.begin(), CSE = CallSiteIdxs.end(); + CSI != CSE; ++CSI) { + CallSiteNumToLPad[*CSI].push_back(BB); + MaxCSNum = std::max(MaxCSNum, *CSI); + } break; } } @@ -5617,6 +5621,9 @@ LPadList.push_back(*II); } + assert(!LPadList.empty() && + "No landing pad destinations for the dispatch jump table!"); + MachineJumpTableInfo *JTI = MF->getOrCreateJumpTableInfo(MachineJumpTableInfo::EK_Inline); unsigned MJTI = JTI->createJumpTableIndex(LPadList); @@ -5643,16 +5650,21 @@ .addReg(ARM::CPSR); /* - %vreg11 = t2LDRi12 , 4, pred:14, pred:%noreg; mem:Volatile LD4[%sunkaddr131] rGPR:%vreg11 - t2CMPri %vreg11, 6, pred:14, pred:%noreg, %CPSR; rGPR:%vreg11 - t2Bcc , pred:8, pred:%CPSR -*/ -/* - %vreg11 = t2LDRi12 , 4, pred:14, pred:%noreg; mem:Volatile LD4[%sunkaddr131] rGPR:%vreg11 - %vreg12 = t2LEApcrelJT , 0, pred:14, pred:%noreg; rGPR:%vreg12 - %vreg13 = t2ADDrs %vreg12, %vreg11, 18, pred:14, pred:%noreg, opt:%noreg; GPRnopc:%vreg13 rGPR:%vreg12,%vreg11 - t2BR_JT %vreg13, %vreg11, , 0; GPRnopc:%vreg13 rGPR:%vreg11 +BB#32: derived from LLVM BB %eh.sjlj.setjmp.catch + Predecessors according to CFG: BB#0 + %vreg11 = t2LDRi12 , 4, pred:14, pred:%noreg; mem:Volatile LD4[%sunkaddr131] rGPR:%vreg11 + t2CMPri %vreg11, 6, pred:14, pred:%noreg, %CPSR; rGPR:%vreg11 + t2Bcc , pred:8, pred:%CPSR + Successors according to CFG: BB#33 BB#35 + +BB#35: derived from LLVM BB %eh.sjlj.setjmp.catch + Predecessors according to CFG: BB#32 + %vreg12 = t2LEApcrelJT , 0, pred:14, pred:%noreg; rGPR:%vreg12 + %vreg13 = t2ADDrs %vreg12, %vreg11, 18, pred:14, pred:%noreg, opt:%noreg; GPRnopc:%vreg13 rGPR:%vreg12,%vreg11 + t2BR_JT %vreg13, %vreg11, , 0; GPRnopc:%vreg13 rGPR:%vreg11 + Successors according to CFG: BB#3 BB#28 BB#26 BB#24 BB#22 BB#20 BB#31 + */ FIMMO = MF->getMachineMemOperand(MachinePointerInfo::getFixedStack(FI), @@ -5669,7 +5681,7 @@ BuildMI(DispContBB, dl, TII->get(ARM::t2ADDrs), NewVReg3) .addReg(NewVReg2, RegState::Kill) .addReg(NewVReg1) - .addImm(18))); + .addImm(ARM_AM::getSORegOpc(ARM_AM::lsl, 2)))); BuildMI(DispContBB, dl, TII->get(ARM::t2BR_JT)) .addReg(NewVReg3, RegState::Kill) From zwarich at apple.com Wed Oct 5 18:38:50 2011 From: zwarich at apple.com (Cameron Zwarich) Date: Wed, 05 Oct 2011 23:38:50 -0000 Subject: [llvm-commits] [llvm] r141247 - in /llvm/trunk: lib/Target/ARM/ARMISelDAGToDAG.cpp test/CodeGen/ARM/shifter_operand.ll Message-ID: <20111005233850.B75AF2A6C12D@llvm.org> Author: zwarich Date: Wed Oct 5 18:38:50 2011 New Revision: 141247 URL: http://llvm.org/viewvc/llvm-project?rev=141247&view=rev Log: Remove a check from ARM shifted operand isel helper methods, which were blocking merging an lsl #2 that has multiple uses on A9. This shift is free, so there is no problem merging it in multiple places. Other unprofitable shifts will not be merged. Modified: llvm/trunk/lib/Target/ARM/ARMISelDAGToDAG.cpp llvm/trunk/test/CodeGen/ARM/shifter_operand.ll Modified: llvm/trunk/lib/Target/ARM/ARMISelDAGToDAG.cpp URL: http://llvm.org/viewvc/llvm-project/llvm/trunk/lib/Target/ARM/ARMISelDAGToDAG.cpp?rev=141247&r1=141246&r2=141247&view=diff ============================================================================== --- llvm/trunk/lib/Target/ARM/ARMISelDAGToDAG.cpp (original) +++ llvm/trunk/lib/Target/ARM/ARMISelDAGToDAG.cpp Wed Oct 5 18:38:50 2011 @@ -519,11 +519,6 @@ return false; } - if (Subtarget->isCortexA9() && !N.hasOneUse()) { - // Compute R +/- (R << N) and reuse it. - return false; - } - // Otherwise this is R +/- [possibly shifted] R. ARM_AM::AddrOpc AddSub = N.getOpcode() == ISD::SUB ? ARM_AM::sub:ARM_AM::add; ARM_AM::ShiftOpc ShOpcVal = @@ -1286,11 +1281,6 @@ return false; } - if (Subtarget->isCortexA9() && !N.hasOneUse()) { - // Compute R + (R << [1,2,3]) and reuse it. - return false; - } - // Look for (R + R) or (R + (R << [1,2,3])). unsigned ShAmt = 0; Base = N.getOperand(0); Modified: llvm/trunk/test/CodeGen/ARM/shifter_operand.ll URL: http://llvm.org/viewvc/llvm-project/llvm/trunk/test/CodeGen/ARM/shifter_operand.ll?rev=141247&r1=141246&r2=141247&view=diff ============================================================================== --- llvm/trunk/test/CodeGen/ARM/shifter_operand.ll (original) +++ llvm/trunk/test/CodeGen/ARM/shifter_operand.ll Wed Oct 5 18:38:50 2011 @@ -54,13 +54,12 @@ define fastcc void @test4(i16 %addr) nounwind { entry: ; A8: test4: -; A8: ldr r2, [r0, r1, lsl #2] -; A8: str r2, [r0, r1, lsl #2] +; A8: ldr [[REG:r[0-9]+]], [r0, r1, lsl #2] +; A8: str [[REG]], [r0, r1, lsl #2] ; A9: test4: -; A9: add r0, r0, r{{[0-9]+}}, lsl #2 -; A9: ldr r1, [r0] -; A9: str r1, [r0] +; A9: ldr [[REG:r[0-9]+]], [r0, r1, lsl #2] +; A9: str [[REG]], [r0, r1, lsl #2] %0 = tail call i8* (...)* @malloc(i32 undef) nounwind %1 = bitcast i8* %0 to i32* %2 = sext i16 %addr to i32 From zwarich at apple.com Wed Oct 5 18:39:02 2011 From: zwarich at apple.com (Cameron Zwarich) Date: Wed, 05 Oct 2011 23:39:02 -0000 Subject: [llvm-commits] [llvm] r141248 - /llvm/trunk/lib/Target/ARM/ARMISelDAGToDAG.cpp Message-ID: <20111005233902.9210F2A6C12D@llvm.org> Author: zwarich Date: Wed Oct 5 18:39:02 2011 New Revision: 141248 URL: http://llvm.org/viewvc/llvm-project?rev=141248&view=rev Log: Always merge profitable shifts on A9, not just when they have a single use. Modified: llvm/trunk/lib/Target/ARM/ARMISelDAGToDAG.cpp Modified: llvm/trunk/lib/Target/ARM/ARMISelDAGToDAG.cpp URL: http://llvm.org/viewvc/llvm-project/llvm/trunk/lib/Target/ARM/ARMISelDAGToDAG.cpp?rev=141248&r1=141247&r2=141248&view=diff ============================================================================== --- llvm/trunk/lib/Target/ARM/ARMISelDAGToDAG.cpp (original) +++ llvm/trunk/lib/Target/ARM/ARMISelDAGToDAG.cpp Wed Oct 5 18:39:02 2011 @@ -555,9 +555,7 @@ if (ConstantSDNode *Sh = dyn_cast(N.getOperand(0).getOperand(1))) { ShAmt = Sh->getZExtValue(); - if (!Subtarget->isCortexA9() || - (N.hasOneUse() && - isShifterOpProfitable(N.getOperand(0), ShOpcVal, ShAmt))) { + if (isShifterOpProfitable(N.getOperand(0), ShOpcVal, ShAmt)) { Offset = N.getOperand(0).getOperand(0); Base = N.getOperand(1); } else { @@ -697,9 +695,7 @@ if (ConstantSDNode *Sh = dyn_cast(N.getOperand(0).getOperand(1))) { ShAmt = Sh->getZExtValue(); - if (!Subtarget->isCortexA9() || - (N.hasOneUse() && - isShifterOpProfitable(N.getOperand(0), ShOpcVal, ShAmt))) { + if (isShifterOpProfitable(N.getOperand(0), ShOpcVal, ShAmt)) { Offset = N.getOperand(0).getOperand(0); Base = N.getOperand(1); } else { From stoklund at 2pi.dk Wed Oct 5 18:47:03 2011 From: stoklund at 2pi.dk (Jakob Stoklund Olesen) Date: Wed, 05 Oct 2011 16:47:03 -0700 Subject: [llvm-commits] [llvm] r141079 - in /llvm/trunk/lib/TableGen: CMakeLists.txt Main.cpp TGPreprocessor.cpp TGPreprocessor.h In-Reply-To: References: <20111004151452.DE8AB2A6C12C@llvm.org> Message-ID: <73740610-9873-41C1-A673-F20BF0108421@2pi.dk> On Oct 5, 2011, at 1:38 PM, Eli Friedman wrote: > On Tue, Oct 4, 2011 at 8:14 AM, Che-Liang Chiou wrote: >> Author: clchiou >> Date: Tue Oct 4 10:14:51 2011 >> New Revision: 141079 >> >> URL: http://llvm.org/viewvc/llvm-project?rev=141079&view=rev >> Log: >> tblgen: add preprocessor as a separate mode >> >> This patch adds a preprocessor that can expand nested for-loops for >> saving some copy-n-paste in *.td files. >> >> The preprocessor is not yet integrated with TGParser, and so it has >> no direct effect on *.td inputs. However, you may preprocess an td >> input (and only preprocess it). >> >> To test the proprecessor, type: >> tblgen -E -o $@ $< > > Has anyone reviewed this feature? At first glance, this patch doesn't > seem like the direction we want to go with TableGen. We definitely shouldn't add both this and David's Greenspunning. /jakob From grosser at fim.uni-passau.de Wed Oct 5 19:03:36 2011 From: grosser at fim.uni-passau.de (Tobias Grosser) Date: Thu, 06 Oct 2011 00:03:36 -0000 Subject: [llvm-commits] [polly] r141251 - in /polly/trunk: include/polly/ScopInfo.h lib/Analysis/Dependences.cpp lib/Analysis/ScopInfo.cpp lib/CodeGeneration.cpp lib/Exchange/JSONExporter.cpp lib/Exchange/OpenScopExporter.cpp lib/Exchange/OpenScopImporter.cpp lib/Exchange/ScopLib.cpp lib/Pocc.cpp lib/ScheduleOptimizer.cpp utils/checkout_cloog.sh www/get_started.html Message-ID: <20111006000337.092B22A6C12C@llvm.org> Author: grosser Date: Wed Oct 5 19:03:35 2011 New Revision: 141251 URL: http://llvm.org/viewvc/llvm-project?rev=141251&view=rev Log: Adapt to introduction of isl_space Polly should now be compiled with CLooG 0c252c88946b27b7b61a1a8d8fd7f94d2461dbfd and isl 56b7d238929980e62218525b4b3be121af386edf. The most convenient way to update is utils/checkout_cloog.sh. Modified: polly/trunk/include/polly/ScopInfo.h polly/trunk/lib/Analysis/Dependences.cpp polly/trunk/lib/Analysis/ScopInfo.cpp polly/trunk/lib/CodeGeneration.cpp polly/trunk/lib/Exchange/JSONExporter.cpp polly/trunk/lib/Exchange/OpenScopExporter.cpp polly/trunk/lib/Exchange/OpenScopImporter.cpp polly/trunk/lib/Exchange/ScopLib.cpp polly/trunk/lib/Pocc.cpp polly/trunk/lib/ScheduleOptimizer.cpp polly/trunk/utils/checkout_cloog.sh polly/trunk/www/get_started.html Modified: polly/trunk/include/polly/ScopInfo.h URL: http://llvm.org/viewvc/llvm-project/polly/trunk/include/polly/ScopInfo.h?rev=141251&r1=141250&r2=141251&view=diff ============================================================================== --- polly/trunk/include/polly/ScopInfo.h (original) +++ polly/trunk/include/polly/ScopInfo.h Wed Oct 5 19:03:35 2011 @@ -38,7 +38,7 @@ struct isl_basic_map; struct isl_set; struct isl_ctx; -struct isl_dim; +struct isl_space; struct isl_constraint; namespace polly { @@ -255,9 +255,9 @@ /// Build the statment. //@{ - isl_set *toUpperLoopBound(const SCEVAffFunc &UpperBound, isl_dim *dim, + isl_set *toUpperLoopBound(const SCEVAffFunc &UpperBound, isl_space *space, unsigned BoundedDimension) const; - isl_set *toConditionSet(const Comparison &Cmp, isl_dim *dim) const; + isl_set *toConditionSet(const Comparison &Cmp, isl_space *space) const; void addConditionsToDomain(TempScop &tempScop, const Region &CurRegion); void buildIterationDomainFromLoops(TempScop &tempScop); void buildIterationDomain(TempScop &tempScop, const Region &CurRegion); Modified: polly/trunk/lib/Analysis/Dependences.cpp URL: http://llvm.org/viewvc/llvm-project/polly/trunk/lib/Analysis/Dependences.cpp?rev=141251&r1=141250&r2=141251&view=diff ============================================================================== --- polly/trunk/lib/Analysis/Dependences.cpp (original) +++ polly/trunk/lib/Analysis/Dependences.cpp Wed Oct 5 19:03:35 2011 @@ -52,9 +52,9 @@ } bool Dependences::runOnScop(Scop &S) { - isl_dim *dim = isl_dim_alloc(S.getCtx(), 0, 0, 0); - isl_dim *Model = isl_set_get_dim(S.getContext()); - dim = isl_dim_align_params(dim, Model); + isl_space *Space = isl_space_alloc(S.getCtx(), 0, 0, 0); + isl_space *Model = isl_set_get_dim(S.getContext()); + Space = isl_space_align_params(Space, Model); if (sink) isl_union_map_free(sink); @@ -65,10 +65,10 @@ if (may_source) isl_union_map_free(may_source); - sink = isl_union_map_empty(isl_dim_copy(dim)); - must_source = isl_union_map_empty(isl_dim_copy(dim)); - may_source = isl_union_map_empty(isl_dim_copy(dim)); - isl_union_map *schedule = isl_union_map_empty(dim); + sink = isl_union_map_empty(isl_space_copy(Space)); + must_source = isl_union_map_empty(isl_space_copy(Space)); + may_source = isl_union_map_empty(isl_space_copy(Space)); + isl_union_map *schedule = isl_union_map_empty(Space); if (must_dep) isl_union_map_free(must_dep); @@ -155,11 +155,11 @@ if (LegalityCheckDisabled) return true; - isl_dim *dim = isl_dim_alloc(S.getCtx(), 0, 0, 0); + isl_space *Space = isl_space_alloc(S.getCtx(), 0, 0, 0); - isl_union_map *schedule = isl_union_map_empty(dim); + isl_union_map *schedule = isl_union_map_empty(Space); - isl_dim *Model = isl_set_get_dim(S.getContext()); + isl_space *Model = isl_set_get_space(S.getContext()); schedule = isl_union_map_align_params(schedule, Model); for (Scop::iterator SI = S.begin(), SE = S.end(); SI != SE; ++SI) { @@ -241,11 +241,11 @@ return isValid; } -isl_union_map* getCombinedScheduleForDim(Scop *scop, unsigned dimLevel) { - isl_dim *dim = isl_dim_alloc(scop->getCtx(), 0, 0, 0); +isl_union_map* getCombinedScheduleForSpace(Scop *scop, unsigned dimLevel) { + isl_space *Space = isl_space_alloc(scop->getCtx(), 0, 0, 0); - isl_union_map *schedule = isl_union_map_empty(dim); - isl_dim *Model = isl_set_get_dim(scop->getContext()); + isl_union_map *schedule = isl_union_map_empty(Space); + isl_space *Model = isl_set_get_space(scop->getContext()); schedule = isl_union_map_align_params(schedule, Model); for (Scop::iterator SI = scop->begin(), SE = scop->end(); SI != SE; ++SI) { @@ -263,8 +263,8 @@ bool Dependences::isParallelDimension(isl_set *loopDomain, unsigned parallelDimension) { Scop *S = &getCurScop(); - isl_union_map *schedule = getCombinedScheduleForDim(S, parallelDimension); - isl_dim *dimModel = isl_union_map_get_dim(schedule); + isl_union_map *schedule = getCombinedScheduleForSpace(S, parallelDimension); + isl_space *SpaceModel = isl_union_map_get_space(schedule); // Calculate distance vector. isl_union_set *scheduleSubset; @@ -311,14 +311,16 @@ isl_union_set *distance_waw = isl_union_map_deltas(restrictedDeps_waw); - isl_dim *dim = isl_dim_set_alloc(S->getCtx(), 0, parallelDimension); + isl_space *Space = isl_space_set_alloc(S->getCtx(), 0, parallelDimension); // [0, 0, 0, 0] - All zero - isl_basic_set *allZeroBS = isl_basic_set_universe(isl_dim_copy(dim)); - unsigned dimensions = isl_dim_size(dim, isl_dim_set); + isl_basic_set *allZeroBS = isl_basic_set_universe(isl_space_copy(Space)); + unsigned dimensions = isl_space_dim(Space, isl_dim_set); + isl_local_space *LocalSpace; + LocalSpace = isl_local_space_from_space(isl_space_copy(Space)); for (unsigned i = 0; i < dimensions; i++) { - isl_constraint *c = isl_equality_alloc(isl_dim_copy(dim)); + isl_constraint *c = isl_equality_alloc(isl_local_space_copy(LocalSpace)); isl_int v; isl_int_init(v); isl_int_set_si(v, -1); @@ -328,15 +330,15 @@ } isl_set *allZero = isl_set_from_basic_set(allZeroBS); - allZero = isl_set_align_params(allZero, isl_dim_copy(dimModel)); + allZero = isl_set_align_params(allZero, isl_space_copy(SpaceModel)); // All zero, last unknown. // [0, 0, 0, ?] - isl_basic_set *lastUnknownBS = isl_basic_set_universe(isl_dim_copy(dim)); - dimensions = isl_dim_size(dim, isl_dim_set); + isl_basic_set *lastUnknownBS = isl_basic_set_universe(isl_space_copy(Space)); + dimensions = isl_space_dim(Space, isl_dim_set); for (unsigned i = 0; i < dimensions - 1; i++) { - isl_constraint *c = isl_equality_alloc(isl_dim_copy(dim)); + isl_constraint *c = isl_equality_alloc(isl_local_space_copy(LocalSpace)); isl_int v; isl_int_init(v); isl_int_set_si(v, -1); @@ -345,8 +347,10 @@ isl_int_clear(v); } + isl_local_space_free(LocalSpace); + isl_set *lastUnknown = isl_set_from_basic_set(lastUnknownBS); - lastUnknown = isl_set_align_params(lastUnknown, dimModel); +lastUnknown = isl_set_align_params(lastUnknown, SpaceModel); // Valid distance vectors isl_set *validDistances = isl_set_subtract(lastUnknown, allZero); @@ -365,7 +369,7 @@ && isl_union_set_is_empty(nonValid_war) && isl_union_set_is_empty(nonValid_waw); - isl_dim_free(dim); + isl_space_free(Space); isl_union_set_free(nonValid); isl_union_set_free(nonValid_war); isl_union_set_free(nonValid_waw); @@ -430,8 +434,8 @@ } isl_union_map *Dependences::getDependences(int type) { - isl_dim *dim = isl_union_map_get_dim(must_dep); - isl_union_map *dependences = isl_union_map_empty(dim); + isl_space *Space = isl_union_map_get_space(must_dep); + isl_union_map *dependences = isl_union_map_empty(Space); if (type & TYPE_RAW) dependences = isl_union_map_union(dependences, Modified: polly/trunk/lib/Analysis/ScopInfo.cpp URL: http://llvm.org/viewvc/llvm-project/polly/trunk/lib/Analysis/ScopInfo.cpp?rev=141251&r1=141250&r2=141251&view=diff ============================================================================== --- polly/trunk/lib/Analysis/ScopInfo.cpp (original) +++ polly/trunk/lib/Analysis/ScopInfo.cpp Wed Oct 5 19:03:35 2011 @@ -40,6 +40,7 @@ #include "isl/map.h" #include "isl/aff.h" #include "isl/printer.h" +#include "isl/local_space.h" #include #include #include @@ -71,7 +72,7 @@ struct SCEVAffinator : public SCEVVisitor { private: isl_ctx *ctx; - int NbLoopDims; + int NbLoopSpaces; const Scop *scop; /// baseAdress is set if we analyze a memory access. It holds the base address @@ -97,11 +98,12 @@ if (*PI == scev) { isl_id *ID = isl_id_alloc(ctx, ("p" + convertInt(i)).c_str(), (void *) scev); - isl_dim *Dim = isl_dim_set_alloc(ctx, 1, NbLoopDims); - Dim = isl_dim_set_dim_id(Dim, isl_dim_param, 0, ID); + isl_space *Space = isl_space_set_alloc(ctx, 1, NbLoopSpaces); + Space = isl_space_set_dim_id(Space, isl_dim_param, 0, ID); - isl_set *Domain = isl_set_universe(isl_dim_copy(Dim)); - isl_aff *Affine = isl_aff_zero(isl_local_space_from_dim(Dim)); + isl_set *Domain = isl_set_universe(isl_space_copy(Space)); + isl_aff *Affine = isl_aff_zero_on_domain( + isl_local_space_from_space(Space)); Affine = isl_aff_add_coefficient_si(Affine, isl_dim_param, 0, 1); return isl_pw_aff_alloc(Domain, Affine); @@ -114,7 +116,7 @@ SCEVAffinator(const ScopStmt *stmt, const Value *baseAddress) : ctx(stmt->getParent()->getCtx()), - NbLoopDims(stmt->getNumIterators()), + NbLoopSpaces(stmt->getNumIterators()), scop(stmt->getParent()), baseAddress(baseAddress) {}; @@ -135,10 +137,10 @@ // this constant correctly. MPZ_from_APInt(v, Value->getValue(), /* isSigned */ true); - isl_dim *dim = isl_dim_set_alloc(ctx, 0, NbLoopDims); - isl_local_space *ls = isl_local_space_from_dim(isl_dim_copy(dim)); - isl_aff *Affine = isl_aff_zero(ls); - isl_set *Domain = isl_set_universe(dim); + isl_space *Space = isl_space_set_alloc(ctx, 0, NbLoopSpaces); + isl_local_space *ls = isl_local_space_from_space(isl_space_copy(Space)); + isl_aff *Affine = isl_aff_zero_on_domain(ls); + isl_set *Domain = isl_set_universe(Space); Affine = isl_aff_add_constant(Affine, v); isl_int_clear(v); @@ -207,13 +209,13 @@ isl_pw_aff *Start = visit(Expr->getStart()); isl_pw_aff *Step = visit(Expr->getOperand(1)); - isl_dim *Dim = isl_dim_set_alloc (ctx, 0, NbLoopDims); - isl_local_space *LocalSpace = isl_local_space_from_dim (Dim); + isl_space *Space = isl_space_set_alloc(ctx, 0, NbLoopSpaces); + isl_local_space *LocalSpace = isl_local_space_from_space(Space); int loopDimension = getLoopDepth(Expr->getLoop()); - isl_aff *LAff = isl_aff_set_coefficient_si (isl_aff_zero (LocalSpace), - isl_dim_set, loopDimension, 1); + isl_aff *LAff = isl_aff_set_coefficient_si( + isl_aff_zero_on_domain (LocalSpace), isl_dim_in, loopDimension, 1); isl_pw_aff *LPwAff = isl_pw_aff_from_aff(LAff); // TODO: Do we need to check for NSW and NUW? @@ -238,21 +240,21 @@ __isl_give isl_pw_aff *visitUnknown(const SCEVUnknown* Expr) { Value *Value = Expr->getValue(); - isl_dim *Dim; + isl_space *Space; /// If baseAddress is set, we ignore its Value object in the scev and do not /// add it to the isl_pw_aff. This is because it is regarded as defining the /// name of an array, in contrast to its array subscript. if (baseAddress != Value) { isl_id *ID = isl_id_alloc(ctx, Value->getNameStr().c_str(), Value); - Dim = isl_dim_set_alloc(ctx, 1, NbLoopDims); - Dim = isl_dim_set_dim_id(Dim, isl_dim_param, 0, ID); + Space = isl_space_set_alloc(ctx, 1, NbLoopSpaces); + Space = isl_space_set_dim_id(Space, isl_dim_param, 0, ID); } else { - Dim = isl_dim_set_alloc(ctx, 0, NbLoopDims); + Space = isl_space_set_alloc(ctx, 0, NbLoopSpaces); } - isl_set *Domain = isl_set_universe(isl_dim_copy(Dim)); - isl_aff *Affine = isl_aff_zero(isl_local_space_from_dim(Dim)); + isl_set *Domain = isl_set_universe(isl_space_copy(Space)); + isl_aff *Affine = isl_aff_zero_on_domain(isl_local_space_from_space(Space)); if (baseAddress != Value) Affine = isl_aff_add_coefficient_si(Affine, isl_dim_param, 0, 1); @@ -298,14 +300,14 @@ } isl_basic_map *MemoryAccess::createBasicAccessMap(ScopStmt *Statement) { - isl_dim *dim = isl_dim_alloc(Statement->getIslContext(), 0, - Statement->getNumIterators(), 1); + isl_space *Space = isl_space_alloc(Statement->getIslContext(), 0, + Statement->getNumIterators(), 1); setBaseName(); - dim = isl_dim_set_tuple_name(dim, isl_dim_out, getBaseName().c_str()); - dim = isl_dim_set_tuple_name(dim, isl_dim_in, Statement->getBaseName()); + Space = isl_space_set_tuple_name(Space, isl_dim_out, getBaseName().c_str()); + Space = isl_space_set_tuple_name(Space, isl_dim_in, Statement->getBaseName()); - return isl_basic_map_universe(dim); + return isl_basic_map_universe(Space); } MemoryAccess::MemoryAccess(const SCEVAffFunc &AffFunc, ScopStmt *Statement) { @@ -338,7 +340,7 @@ AccessRelation = isl_map_set_tuple_name(AccessRelation, isl_dim_out, getBaseName().c_str()); - isl_dim *Model = isl_set_get_dim(Statement->getParent()->getContext()); + isl_space *Model = isl_set_get_space(Statement->getParent()->getContext()); AccessRelation = isl_map_align_params(AccessRelation, Model); } @@ -350,7 +352,7 @@ isl_basic_map *BasicAccessMap = createBasicAccessMap(Statement); AccessRelation = isl_map_from_basic_map(BasicAccessMap); - isl_dim *Model = isl_set_get_dim(Statement->getParent()->getContext()); + isl_space *Model = isl_set_get_space(Statement->getParent()->getContext()); AccessRelation = isl_map_align_params(AccessRelation, Model); } @@ -375,9 +377,10 @@ // set[i0, i1, ..., iX] -> set[o0, o1, ..., oX] // : i0 = o0, i1 = o1, ..., i(X-1) = o(X-1), iX < oX // -static isl_map *getEqualAndLarger(isl_dim *setDomain) { - isl_dim *mapDomain = isl_dim_map_from_set(setDomain); +static isl_map *getEqualAndLarger(isl_space *setDomain) { + isl_space *mapDomain = isl_space_map_from_set(setDomain); isl_basic_map *bmap = isl_basic_map_universe(mapDomain); + isl_local_space *MapLocalSpace = isl_local_space_from_space(mapDomain); // Set all but the last dimension to be equal for the input and output // @@ -386,7 +389,7 @@ for (unsigned i = 0; i < isl_basic_map_n_in(bmap) - 1; ++i) { isl_int v; isl_int_init(v); - isl_constraint *c = isl_equality_alloc(isl_basic_map_get_dim(bmap)); + isl_constraint *c = isl_equality_alloc(isl_local_space_copy(MapLocalSpace)); isl_int_set_si(v, 1); isl_constraint_set_coefficient(c, isl_dim_in, i, v); @@ -406,7 +409,7 @@ unsigned lastDimension = isl_basic_map_n_in(bmap) - 1; isl_int v; isl_int_init(v); - isl_constraint *c = isl_inequality_alloc(isl_basic_map_get_dim(bmap)); + isl_constraint *c = isl_inequality_alloc(isl_local_space_copy(MapLocalSpace)); isl_int_set_si(v, -1); isl_constraint_set_coefficient(c, isl_dim_in, lastDimension, v); isl_int_set_si(v, 1); @@ -436,7 +439,7 @@ scattering = isl_map_set_tuple_name(scattering, isl_dim_in, ""); scatteringDomain = isl_set_set_tuple_name(scatteringDomain, ""); - isl_map *nextScatt = getEqualAndLarger(isl_set_get_dim(scatteringDomain)); + isl_map *nextScatt = getEqualAndLarger(isl_set_get_space(scatteringDomain)); nextScatt = isl_map_lexmin(nextScatt); scattering = isl_map_intersect_domain(scattering, scatteringDomain); @@ -451,7 +454,9 @@ bool MemoryAccess::isStrideZero(const isl_set *domainSubset) const { isl_set *stride = getStride(domainSubset); - isl_constraint *c = isl_equality_alloc(isl_set_get_dim(stride)); + isl_space *StrideSpace = isl_set_get_space(stride); + isl_local_space *StrideLS = isl_local_space_from_space(StrideSpace); + isl_constraint *c = isl_equality_alloc(StrideLS); isl_int v; isl_int_init(v); @@ -461,7 +466,7 @@ isl_constraint_set_constant(c, v); isl_int_clear(v); - isl_basic_set *bset = isl_basic_set_universe(isl_set_get_dim(stride)); + isl_basic_set *bset = isl_basic_set_universe(isl_set_get_space(stride)); bset = isl_basic_set_add_constraint(bset, c); isl_set *strideZero = isl_set_from_basic_set(bset); @@ -476,7 +481,9 @@ bool MemoryAccess::isStrideOne(const isl_set *domainSubset) const { isl_set *stride = getStride(domainSubset); - isl_constraint *c = isl_equality_alloc(isl_set_get_dim(stride)); + isl_space *StrideSpace = isl_set_get_space(stride); + isl_local_space *StrideLSpace = isl_local_space_from_space(StrideSpace); + isl_constraint *c = isl_equality_alloc(StrideLSpace); isl_int v; isl_int_init(v); @@ -486,7 +493,7 @@ isl_constraint_set_constant(c, v); isl_int_clear(v); - isl_basic_set *bset = isl_basic_set_universe(isl_set_get_dim(stride)); + isl_basic_set *bset = isl_basic_set_universe(isl_set_get_space(stride)); bset = isl_basic_set_add_constraint(bset, c); isl_set *strideOne = isl_set_from_basic_set(bset); @@ -512,17 +519,19 @@ void ScopStmt::buildScattering(SmallVectorImpl &Scatter) { unsigned NumberOfIterators = getNumIterators(); - unsigned ScatDim = Parent.getMaxLoopDepth() * 2 + 1; - isl_dim *dim = isl_dim_alloc(Parent.getCtx(), 0, NumberOfIterators, ScatDim); - dim = isl_dim_set_tuple_name(dim, isl_dim_out, "scattering"); - dim = isl_dim_set_tuple_name(dim, isl_dim_in, getBaseName()); - isl_basic_map *bmap = isl_basic_map_universe(isl_dim_copy(dim)); + unsigned ScatSpace = Parent.getMaxLoopDepth() * 2 + 1; + isl_space *Space = isl_space_alloc(Parent.getCtx(), 0, NumberOfIterators, + ScatSpace); + Space = isl_space_set_tuple_name(Space, isl_dim_out, "scattering"); + Space = isl_space_set_tuple_name(Space, isl_dim_in, getBaseName()); + isl_local_space *LSpace = isl_local_space_from_space(isl_space_copy(Space)); + isl_basic_map *bmap = isl_basic_map_universe(Space); isl_int v; isl_int_init(v); // Loop dimensions. for (unsigned i = 0; i < NumberOfIterators; ++i) { - isl_constraint *c = isl_equality_alloc(isl_dim_copy(dim)); + isl_constraint *c = isl_equality_alloc(isl_local_space_copy(LSpace)); isl_int_set_si(v, 1); isl_constraint_set_coefficient(c, isl_dim_out, 2 * i + 1, v); isl_int_set_si(v, -1); @@ -533,7 +542,7 @@ // Constant dimensions for (unsigned i = 0; i < NumberOfIterators + 1; ++i) { - isl_constraint *c = isl_equality_alloc(isl_dim_copy(dim)); + isl_constraint *c = isl_equality_alloc(isl_local_space_copy(LSpace)); isl_int_set_si(v, -1); isl_constraint_set_coefficient(c, isl_dim_out, 2 * i, v); isl_int_set_si(v, Scatter[i]); @@ -543,8 +552,8 @@ } // Fill scattering dimensions. - for (unsigned i = 2 * NumberOfIterators + 1; i < ScatDim ; ++i) { - isl_constraint *c = isl_equality_alloc(isl_dim_copy(dim)); + for (unsigned i = 2 * NumberOfIterators + 1; i < ScatSpace ; ++i) { + isl_constraint *c = isl_equality_alloc(isl_local_space_copy(LSpace)); isl_int_set_si(v, 1); isl_constraint_set_coefficient(c, isl_dim_out, i, v); isl_int_set_si(v, 0); @@ -554,9 +563,8 @@ } isl_int_clear(v); - isl_dim_free(dim); Scattering = isl_map_from_basic_map(bmap); - isl_dim *Model = isl_set_get_dim(getParent()->getContext()); + isl_space *Model = isl_set_get_space(getParent()->getContext()); Scattering = isl_map_align_params(Scattering, Model); } @@ -570,7 +578,8 @@ } } -isl_set *ScopStmt::toConditionSet(const Comparison &Comp, isl_dim *dim) const { +isl_set *ScopStmt::toConditionSet(const Comparison &Comp, + isl_space *space) const { isl_pw_aff *LHS = SCEVAffinator::getPwAff(this, Comp.getLHS()->OriginalSCEV, 0); isl_pw_aff *RHS = SCEVAffinator::getPwAff(this, Comp.getRHS()->OriginalSCEV, @@ -606,41 +615,45 @@ llvm_unreachable("Non integer predicate not supported"); } - set = isl_set_set_tuple_name(set, isl_dim_get_tuple_name(dim, isl_dim_set)); + set = isl_set_set_tuple_name(set, isl_space_get_tuple_name(space, isl_dim_set)); return set; } -isl_set *ScopStmt::toUpperLoopBound(const SCEVAffFunc &UpperBound, isl_dim *Dim, +isl_set *ScopStmt::toUpperLoopBound(const SCEVAffFunc &UpperBound, + isl_space *Space, unsigned BoundedDimension) const { // FIXME: We should choose a consistent scheme of when to name the dimensions. - isl_dim *UnnamedDim = isl_dim_copy(Dim); - UnnamedDim = isl_dim_set_tuple_name(UnnamedDim, isl_dim_set, 0); - isl_local_space *LocalSpace = isl_local_space_from_dim (UnnamedDim); - isl_aff *LAff = isl_aff_set_coefficient_si (isl_aff_zero (LocalSpace), - isl_dim_set, BoundedDimension, 1); - isl_pw_aff *BoundedDim = isl_pw_aff_from_aff(LAff); + isl_space *UnnamedSpace = isl_space_copy(Space); + UnnamedSpace = isl_space_set_tuple_name(UnnamedSpace, isl_dim_set, 0); + isl_local_space *LocalSpace = isl_local_space_from_space(UnnamedSpace); + isl_aff *LAff = isl_aff_set_coefficient_si(isl_aff_zero_on_domain(LocalSpace), + isl_dim_in, BoundedDimension, 1); + isl_pw_aff *BoundedSpace = isl_pw_aff_from_aff(LAff); isl_pw_aff *Bound = SCEVAffinator::getPwAff(this, UpperBound.OriginalSCEV, 0); - isl_set *set = isl_pw_aff_le_set(BoundedDim, Bound); - set = isl_set_set_tuple_name(set, isl_dim_get_tuple_name(Dim, isl_dim_set)); - isl_dim_free(Dim); + isl_set *set = isl_pw_aff_le_set(BoundedSpace, Bound); + set = isl_set_set_tuple_name(set, isl_space_get_tuple_name(Space, isl_dim_set)); + isl_space_free(Space); return set; } void ScopStmt::buildIterationDomainFromLoops(TempScop &tempScop) { - isl_dim *dim = isl_dim_set_alloc(getIslContext(), 0, getNumIterators()); - dim = isl_dim_set_tuple_name(dim, isl_dim_set, getBaseName()); + isl_space *Space = isl_space_set_alloc(getIslContext(), 0, getNumIterators()); + Space = isl_space_set_tuple_name(Space, isl_dim_set, getBaseName()); - Domain = isl_set_universe(isl_dim_copy(dim)); - Domain = isl_set_align_params(Domain, isl_set_get_dim(Parent.getContext())); + Domain = isl_set_universe(isl_space_copy(Space)); + Domain = isl_set_align_params(Domain, isl_set_get_space(Parent.getContext())); isl_int v; isl_int_init(v); + isl_local_space *LocalSpace; + LocalSpace = isl_local_space_from_space(isl_space_copy(Space)); + for (int i = 0, e = getNumIterators(); i != e; ++i) { // Lower bound: IV >= 0. - isl_basic_set *bset = isl_basic_set_universe(isl_dim_copy(dim)); - isl_constraint *c = isl_inequality_alloc(isl_dim_copy(dim)); + isl_basic_set *bset = isl_basic_set_universe(isl_space_copy(Space)); + isl_constraint *c = isl_inequality_alloc(isl_local_space_copy(LocalSpace)); isl_int_set_si(v, 1); isl_constraint_set_coefficient(c, isl_dim_set, i, v); bset = isl_basic_set_add_constraint(bset, c); @@ -649,17 +662,19 @@ // Upper bound: IV <= NumberOfIterations. const Loop *L = getLoopForDimension(i); const SCEVAffFunc &UpperBound = tempScop.getLoopBound(L); - isl_set *UpperBoundSet = toUpperLoopBound(UpperBound, isl_dim_copy(dim), i); + isl_set *UpperBoundSet = toUpperLoopBound(UpperBound, isl_space_copy(Space), + i); Domain = isl_set_intersect(Domain, UpperBoundSet); } - isl_dim_free(dim); + isl_local_space_free(LocalSpace); + isl_space_free(Space); isl_int_clear(v); } void ScopStmt::addConditionsToDomain(TempScop &tempScop, const Region &CurRegion) { - isl_dim *dim = isl_set_get_dim(Domain); + isl_space *Space = isl_set_get_space(Domain); const Region *TopR = tempScop.getMaxRegion().getParent(), *CurR = &CurRegion; const BasicBlock *CurEntry = BB; @@ -672,7 +687,7 @@ if (const BBCond *Cnd = tempScop.getBBCond(CurEntry)) for (BBCond::const_iterator I = Cnd->begin(), E = Cnd->end(); I != E; ++I) { - isl_set *c = toConditionSet(*I, dim); + isl_set *c = toConditionSet(*I, Space); Domain = isl_set_intersect(Domain, c); } } @@ -680,7 +695,7 @@ CurR = CurR->getParent(); } while (TopR != CurR); - isl_dim_free(dim); + isl_space_free(Space); } void ScopStmt::buildIterationDomain(TempScop &tempScop, const Region &CurRegion) @@ -720,22 +735,22 @@ // Build iteration domain. std::string IterationDomainString = "{[i0] : i0 = 0}"; - Domain = isl_set_read_from_str(Parent.getCtx(), IterationDomainString.c_str(), - -1); + Domain = isl_set_read_from_str(Parent.getCtx(), + IterationDomainString.c_str()); Domain = isl_set_set_tuple_name(Domain, getBaseName()); - isl_dim *Model = isl_set_get_dim(getParent()->getContext()); - Domain = isl_set_align_params(Domain, isl_dim_copy(Model)); + isl_space *Model = isl_set_get_space(getParent()->getContext()); + Domain = isl_set_align_params(Domain, isl_space_copy(Model)); // Build scattering. - unsigned ScatDim = Parent.getMaxLoopDepth() * 2 + 1; - isl_dim *dim = isl_dim_alloc(Parent.getCtx(), 0, 1, ScatDim); - dim = isl_dim_set_tuple_name(dim, isl_dim_out, "scattering"); - dim = isl_dim_set_tuple_name(dim, isl_dim_in, getBaseName()); - isl_basic_map *bmap = isl_basic_map_universe(isl_dim_copy(dim)); + unsigned ScatSpace = Parent.getMaxLoopDepth() * 2 + 1; + isl_space *Space = isl_space_alloc(Parent.getCtx(), 0, 1, ScatSpace); + Space = isl_space_set_tuple_name(Space, isl_dim_out, "scattering"); + Space = isl_space_set_tuple_name(Space, isl_dim_in, getBaseName()); + isl_basic_map *bmap = isl_basic_map_universe(isl_space_copy(Space)); isl_int v; isl_int_init(v); - isl_constraint *c = isl_equality_alloc(dim); + isl_constraint *c = isl_equality_alloc(isl_local_space_from_space(Space)); isl_int_set_si(v, -1); isl_constraint_set_coefficient(c, isl_dim_out, 0, v); @@ -863,7 +878,7 @@ ParamSetType &Params = tempScop.getParamSet(); Parameters.insert(Parameters.begin(), Params.begin(), Params.end()); - isl_dim *dim = isl_dim_set_alloc(ctx, getNumParams(), 0); + isl_space *Space = isl_space_set_alloc(ctx, getNumParams(), 0); int i = 0; for (ParamSetType::iterator PI = Params.begin(), PE = Params.end(); @@ -872,13 +887,13 @@ isl_id *id = isl_id_alloc(ctx, ("p" + convertInt(i)).c_str(), (void *) scev); - dim = isl_dim_set_dim_id(dim, isl_dim_param, i, id); + Space = isl_space_set_dim_id(Space, isl_dim_param, i, id); i++; } // TODO: Insert relations between parameters. // TODO: Insert constraints on parameters. - Context = isl_set_universe (dim); + Context = isl_set_universe (Space); SmallVector NestLoops; SmallVector Scatter; Modified: polly/trunk/lib/CodeGeneration.cpp URL: http://llvm.org/viewvc/llvm-project/polly/trunk/lib/CodeGeneration.cpp?rev=141251&r1=141250&r2=141251&view=diff ============================================================================== --- polly/trunk/lib/CodeGeneration.cpp (original) +++ polly/trunk/lib/CodeGeneration.cpp Wed Oct 5 19:03:35 2011 @@ -362,8 +362,8 @@ isl_map *currentAccessRelation = access.getAccessFunction(); isl_map *newAccessRelation = access.getNewAccessFunction(); - assert(isl_map_has_equal_dim(currentAccessRelation, newAccessRelation) - && "Current and new access function dimensions differ"); + assert(isl_map_has_equal_space(currentAccessRelation, newAccessRelation) + && "Current and new access function use different spaces"); if (!newAccessRelation) { Value *newPointer = getOperand(pointer, BBMap); @@ -1147,10 +1147,11 @@ // Calculate a map similar to the identity map, but with the last input // and output dimension not related. // [i0, i1, i2, i3] -> [i0, i1, i2, o0] - isl_dim *dim = isl_set_get_dim(loopDomain); - dim = isl_dim_drop_outputs(dim, isl_set_n_dim(loopDomain) - 2, 1); - dim = isl_dim_map_from_set(dim); - isl_map *identity = isl_map_identity(dim); + isl_space *Space = isl_set_get_space(loopDomain); + Space = isl_space_drop_outputs(Space, + isl_set_dim(loopDomain, isl_dim_set) - 2, 1); + Space = isl_space_map_from_set(Space); + isl_map *identity = isl_map_identity(Space); identity = isl_map_add_dims(identity, isl_dim_in, 1); identity = isl_map_add_dims(identity, isl_dim_out, 1); Modified: polly/trunk/lib/Exchange/JSONExporter.cpp URL: http://llvm.org/viewvc/llvm-project/polly/trunk/lib/Exchange/JSONExporter.cpp?rev=141251&r1=141250&r2=141251&view=diff ============================================================================== --- polly/trunk/lib/Exchange/JSONExporter.cpp (original) +++ polly/trunk/lib/Exchange/JSONExporter.cpp Wed Oct 5 19:03:35 2011 @@ -236,7 +236,7 @@ continue; Json::Value schedule = jscop["statements"][index]["schedule"]; - isl_map *m = isl_map_read_from_str(S->getCtx(), schedule.asCString(), -1); + isl_map *m = isl_map_read_from_str(S->getCtx(), schedule.asCString()); NewScattering[*SI] = m; index++; } @@ -267,9 +267,9 @@ Json::Value accesses = jscop["statements"][statementIdx] ["accesses"][memoryAccessIdx]["relation"]; isl_map *newAccessMap = isl_map_read_from_str(S->getCtx(), - accesses.asCString(), -1); + accesses.asCString()); isl_map *currentAccessMap = (*MI)->getAccessFunction(); - if (!isl_map_has_equal_dim(currentAccessMap, newAccessMap)) { + if (!isl_map_has_equal_space(currentAccessMap, newAccessMap)) { errs() << "JScop file contains access function with incompatible " << "dimensions\n"; isl_map_free(newAccessMap); Modified: polly/trunk/lib/Exchange/OpenScopExporter.cpp URL: http://llvm.org/viewvc/llvm-project/polly/trunk/lib/Exchange/OpenScopExporter.cpp?rev=141251&r1=141250&r2=141251&view=diff ============================================================================== --- polly/trunk/lib/Exchange/OpenScopExporter.cpp (original) +++ polly/trunk/lib/Exchange/OpenScopExporter.cpp Wed Oct 5 19:03:35 2011 @@ -223,9 +223,9 @@ int OpenScop::domainToMatrix_constraint(isl_constraint *c, void *user) { openscop_matrix_p m = (openscop_matrix_p) user; - int nb_params = isl_constraint_dim(c, isl_dim_param); - int nb_vars = isl_constraint_dim(c, isl_dim_set); - int nb_div = isl_constraint_dim(c, isl_dim_div); + int nb_params = isl_constraint_dim(c, isl_space_param); + int nb_vars = isl_constraint_dim(c, isl_space_set); + int nb_div = isl_constraint_dim(c, isl_space_div); assert(!nb_div && "Existentially quantified variables not yet supported"); @@ -242,13 +242,13 @@ // Assign variables for (int i = 0; i < nb_vars; ++i) { - isl_constraint_get_coefficient(c, isl_dim_set, i, &v); + isl_constraint_get_coefficient(c, isl_space_set, i, &v); isl_int_set(vec->p[i + 1], v); } // Assign parameters for (int i = 0; i < nb_params; ++i) { - isl_constraint_get_coefficient(c, isl_dim_param, i, &v); + isl_constraint_get_coefficient(c, isl_space_param, i, &v); isl_int_set(vec->p[nb_vars + i + 1], v); } @@ -309,10 +309,10 @@ int OpenScop::scatteringToMatrix_constraint(isl_constraint *c, void *user) { openscop_matrix_p m = (openscop_matrix_p) user; - int nb_params = isl_constraint_dim(c, isl_dim_param); - int nb_in = isl_constraint_dim(c, isl_dim_in); - int nb_out = isl_constraint_dim(c, isl_dim_out); - int nb_div = isl_constraint_dim(c, isl_dim_div); + int nb_params = isl_constraint_dim(c, isl_space_param); + int nb_in = isl_constraint_dim(c, isl_space_in); + int nb_out = isl_constraint_dim(c, isl_space_out); + int nb_div = isl_constraint_dim(c, isl_space_div); assert(!nb_div && "Existentially quantified variables not yet supported"); @@ -330,19 +330,19 @@ // Assign scattering for (int i = 0; i < nb_out; ++i) { - isl_constraint_get_coefficient(c, isl_dim_out, i, &v); + isl_constraint_get_coefficient(c, isl_space_out, i, &v); isl_int_set(vec->p[i + 1], v); } // Assign variables for (int i = 0; i < nb_in; ++i) { - isl_constraint_get_coefficient(c, isl_dim_in, i, &v); + isl_constraint_get_coefficient(c, isl_space_in, i, &v); isl_int_set(vec->p[nb_out + i + 1], v); } // Assign parameters for (int i = 0; i < nb_params; ++i) { - isl_constraint_get_coefficient(c, isl_dim_param, i, &v); + isl_constraint_get_coefficient(c, isl_space_param, i, &v); isl_int_set(vec->p[nb_out + nb_in + i + 1], v); } @@ -404,9 +404,9 @@ int OpenScop::accessToMatrix_constraint(isl_constraint *c, void *user) { openscop_matrix_p m = (openscop_matrix_p) user; - int nb_params = isl_constraint_dim(c, isl_dim_param); - int nb_in = isl_constraint_dim(c, isl_dim_in); - int nb_div = isl_constraint_dim(c, isl_dim_div); + int nb_params = isl_constraint_dim(c, isl_space_param); + int nb_in = isl_constraint_dim(c, isl_space_in); + int nb_div = isl_constraint_dim(c, isl_space_div); assert(!nb_div && "Existentially quantified variables not yet supported"); @@ -417,13 +417,13 @@ isl_int_init(v); // The access dimension has to be one. - isl_constraint_get_coefficient(c, isl_dim_out, 0, &v); + isl_constraint_get_coefficient(c, isl_space_out, 0, &v); assert(isl_int_is_one(v)); bool inverse = true ; // Assign variables for (int i = 0; i < nb_in; ++i) { - isl_constraint_get_coefficient(c, isl_dim_in, i, &v); + isl_constraint_get_coefficient(c, isl_space_in, i, &v); if (inverse) isl_int_neg(v,v); @@ -432,7 +432,7 @@ // Assign parameters for (int i = 0; i < nb_params; ++i) { - isl_constraint_get_coefficient(c, isl_dim_param, i, &v); + isl_constraint_get_coefficient(c, isl_space_param, i, &v); if (inverse) isl_int_neg(v,v); Modified: polly/trunk/lib/Exchange/OpenScopImporter.cpp URL: http://llvm.org/viewvc/llvm-project/polly/trunk/lib/Exchange/OpenScopImporter.cpp?rev=141251&r1=141250&r2=141251&view=diff ============================================================================== --- polly/trunk/lib/Exchange/OpenScopImporter.cpp (original) +++ polly/trunk/lib/Exchange/OpenScopImporter.cpp Wed Oct 5 19:03:35 2011 @@ -64,31 +64,31 @@ /// @brief Create an isl constraint from a row of OpenScop integers. /// /// @param row An array of isl/OpenScop integers. -/// @param dim An isl dim object, describing how to spilt the dimensions. +/// @param Space An isl space object, describing how to spilt the dimensions. /// /// @return An isl constraint representing this integer array. -isl_constraint *constraintFromMatrixRow(isl_int *row, isl_dim *dim) { +isl_constraint *constraintFromMatrixRow(isl_int *row, isl_space *Space) { isl_constraint *c; - unsigned NbOut = isl_dim_size(dim, isl_dim_out); - unsigned NbIn = isl_dim_size(dim, isl_dim_in); - unsigned NbParam = isl_dim_size(dim, isl_dim_param); + unsigned NbOut = isl_space_size(Space, isl_dim_out); + unsigned NbIn = isl_space_size(Space, isl_dim_in); + unsigned NbParam = isl_space_size(Space, isl_dim_param); if (isl_int_is_zero(row[0])) - c = isl_equality_alloc(isl_dim_copy(dim)); + c = isl_equality_alloc(isl_space_copy(Space)); else - c = isl_inequality_alloc(isl_dim_copy(dim)); + c = isl_inequality_alloc(isl_space_copy(Space)); unsigned current_column = 1; for (unsigned j = 0; j < NbOut; ++j) - isl_constraint_set_coefficient(c, isl_dim_out, j, row[current_column++]); + isl_constraint_set_coefficient(c, isl_space_out, j, row[current_column++]); for (unsigned j = 0; j < NbIn; ++j) - isl_constraint_set_coefficient(c, isl_dim_in, j, row[current_column++]); + isl_constraint_set_coefficient(c, isl_space_in, j, row[current_column++]); for (unsigned j = 0; j < NbParam; ++j) - isl_constraint_set_coefficient(c, isl_dim_param, j, row[current_column++]); + isl_constraint_set_coefficient(c, isl_space_param, j, row[current_column++]); isl_constraint_set_constant(c, row[current_column]); @@ -98,16 +98,16 @@ /// @brief Create an isl map from a OpenScop matrix. /// /// @param m The OpenScop matrix to translate. -/// @param dim The dimensions that are contained in the OpenScop matrix. +/// @param Space The dimensions that are contained in the OpenScop matrix. /// /// @return An isl map representing m. -isl_map *mapFromMatrix(openscop_matrix_p m, isl_dim *dim) { - isl_basic_map *bmap = isl_basic_map_universe(isl_dim_copy(dim)); +isl_map *mapFromMatrix(openscop_matrix_p m, isl_space *Space) { + isl_basic_map *bmap = isl_basic_map_universe(isl_space_copy(Space)); for (unsigned i = 0; i < m->NbRows; ++i) { isl_constraint *c; - c = constraintFromMatrixRow(m->p[i], dim); + c = constraintFromMatrixRow(m->p[i], Space); bmap = isl_basic_map_add_constraint(bmap, c); } @@ -127,11 +127,11 @@ unsigned NbScattering = m->NbColumns - 2 - NbParam - NbIterators; isl_ctx *ctx = PollyStmt->getParent()->getCtx(); - isl_dim *dim = isl_dim_alloc(ctx, NbParam, NbIterators, NbScattering); - dim = isl_dim_set_tuple_name(dim, isl_dim_out, "scattering"); - dim = isl_dim_set_tuple_name(dim, isl_dim_in, PollyStmt->getBaseName()); - isl_map *map = mapFromMatrix(m, dim); - isl_dim_free(dim); + isl_space *Space = isl_dim_alloc(ctx, NbParam, NbIterators, NbScattering); + Space = isl_space_set_tuple_name(Space, isl_dim_out, "scattering"); + Space = isl_space_set_tuple_name(Space, isl_dim_in, PollyStmt->getBaseName()); + isl_map *map = mapFromMatrix(m, Space); + isl_space_free(Space); return map; } Modified: polly/trunk/lib/Exchange/ScopLib.cpp URL: http://llvm.org/viewvc/llvm-project/polly/trunk/lib/Exchange/ScopLib.cpp?rev=141251&r1=141250&r2=141251&view=diff ============================================================================== --- polly/trunk/lib/Exchange/ScopLib.cpp (original) +++ polly/trunk/lib/Exchange/ScopLib.cpp Wed Oct 5 19:03:35 2011 @@ -173,9 +173,9 @@ int ScopLib::domainToMatrix_constraint(isl_constraint *c, void *user) { scoplib_matrix_p m = (scoplib_matrix_p) user; - int nb_params = isl_constraint_dim(c, isl_dim_param); - int nb_vars = isl_constraint_dim(c, isl_dim_set); - int nb_div = isl_constraint_dim(c, isl_dim_div); + int nb_params = isl_constraint_dim(c, isl_space_param); + int nb_vars = isl_constraint_dim(c, isl_space_set); + int nb_div = isl_constraint_dim(c, isl_space_div); assert(!nb_div && "Existentially quantified variables not yet supported"); @@ -192,13 +192,13 @@ // Assign variables for (int i = 0; i < nb_vars; ++i) { - isl_constraint_get_coefficient(c, isl_dim_set, i, &v); + isl_constraint_get_coefficient(c, isl_space_set, i, &v); isl_int_set(vec->p[i + 1], v); } // Assign parameters for (int i = 0; i < nb_params; ++i) { - isl_constraint_get_coefficient(c, isl_dim_param, i, &v); + isl_constraint_get_coefficient(c, isl_space_param, i, &v); isl_int_set(vec->p[nb_vars + i + 1], v); } @@ -259,9 +259,9 @@ int ScopLib::scatteringToMatrix_constraint(isl_constraint *c, void *user) { scoplib_matrix_p m = (scoplib_matrix_p) user; - int nb_params = isl_constraint_dim(c, isl_dim_param); - int nb_in = isl_constraint_dim(c, isl_dim_in); - int nb_div = isl_constraint_dim(c, isl_dim_div); + int nb_params = isl_constraint_dim(c, isl_space_param); + int nb_in = isl_constraint_dim(c, isl_space_in); + int nb_div = isl_constraint_dim(c, isl_space_div); assert(!nb_div && "Existentially quantified variables not yet supported"); @@ -279,13 +279,13 @@ // Assign variables for (int i = 0; i < nb_in; ++i) { - isl_constraint_get_coefficient(c, isl_dim_in, i, &v); + isl_constraint_get_coefficient(c, isl_space_in, i, &v); isl_int_set(vec->p[i + 1], v); } // Assign parameters for (int i = 0; i < nb_params; ++i) { - isl_constraint_get_coefficient(c, isl_dim_param, i, &v); + isl_constraint_get_coefficient(c, isl_space_param, i, &v); isl_int_set(vec->p[nb_in + i + 1], v); } @@ -355,9 +355,9 @@ int ScopLib::accessToMatrix_constraint(isl_constraint *c, void *user) { scoplib_matrix_p m = (scoplib_matrix_p) user; - int nb_params = isl_constraint_dim(c, isl_dim_param); - int nb_in = isl_constraint_dim(c, isl_dim_in); - int nb_div = isl_constraint_dim(c, isl_dim_div); + int nb_params = isl_constraint_dim(c, isl_space_param); + int nb_in = isl_constraint_dim(c, isl_space_in); + int nb_div = isl_constraint_dim(c, isl_space_div); assert(!nb_div && "Existentially quantified variables not yet supported"); @@ -368,13 +368,13 @@ isl_int_init(v); // The access dimension has to be one. - isl_constraint_get_coefficient(c, isl_dim_out, 0, &v); + isl_constraint_get_coefficient(c, isl_space_out, 0, &v); assert(isl_int_is_one(v)); bool inverse = true ; // Assign variables for (int i = 0; i < nb_in; ++i) { - isl_constraint_get_coefficient(c, isl_dim_in, i, &v); + isl_constraint_get_coefficient(c, isl_space_in, i, &v); if (inverse) isl_int_neg(v,v); @@ -383,7 +383,7 @@ // Assign parameters for (int i = 0; i < nb_params; ++i) { - isl_constraint_get_coefficient(c, isl_dim_param, i, &v); + isl_constraint_get_coefficient(c, isl_space_param, i, &v); if (inverse) isl_int_neg(v,v); @@ -482,27 +482,27 @@ /// @brief Create an isl constraint from a row of OpenScop integers. /// /// @param row An array of isl/OpenScop integers. -/// @param dim An isl dim object, describing how to spilt the dimensions. +/// @param Space An isl space object, describing how to spilt the dimensions. /// /// @return An isl constraint representing this integer array. -isl_constraint *constraintFromMatrixRow(isl_int *row, isl_dim *dim) { +isl_constraint *constraintFromMatrixRow(isl_int *row, isl_space *Space) { isl_constraint *c; - unsigned NbIn = isl_dim_size(dim, isl_dim_in); - unsigned NbParam = isl_dim_size(dim, isl_dim_param); + unsigned NbIn = isl_space_size(Space, isl_dim_in); + unsigned NbParam = isl_space_size(Space, isl_dim_param); if (isl_int_is_zero(row[0])) - c = isl_equality_alloc(isl_dim_copy(dim)); + c = isl_equality_alloc(isl_space_copy(Space)); else - c = isl_inequality_alloc(isl_dim_copy(dim)); + c = isl_inequality_alloc(isl_space_copy(Space)); unsigned current_column = 1; for (unsigned j = 0; j < NbIn; ++j) - isl_constraint_set_coefficient(c, isl_dim_in, j, row[current_column++]); + isl_constraint_set_coefficient(c, isl_space_in, j, row[current_column++]); for (unsigned j = 0; j < NbParam; ++j) - isl_constraint_set_coefficient(c, isl_dim_param, j, row[current_column++]); + isl_constraint_set_coefficient(c, isl_space_param, j, row[current_column++]); isl_constraint_set_constant(c, row[current_column]); @@ -512,22 +512,22 @@ /// @brief Create an isl map from a OpenScop matrix. /// /// @param m The OpenScop matrix to translate. -/// @param dim The dimensions that are contained in the OpenScop matrix. +/// @param Space The dimensions that are contained in the OpenScop matrix. /// /// @return An isl map representing m. -isl_map *mapFromMatrix(scoplib_matrix_p m, isl_dim *dim, +isl_map *mapFromMatrix(scoplib_matrix_p m, isl_space *Space, unsigned scatteringDims) { - isl_basic_map *bmap = isl_basic_map_universe(isl_dim_copy(dim)); + isl_basic_map *bmap = isl_basic_map_universe(isl_space_copy(Space)); for (unsigned i = 0; i < m->NbRows; ++i) { isl_constraint *c; - c = constraintFromMatrixRow(m->p[i], dim); + c = constraintFromMatrixRow(m->p[i], Space); mpz_t minusOne; mpz_init(minusOne); mpz_set_si(minusOne, -1); - isl_constraint_set_coefficient(c, isl_dim_out, i, minusOne); + isl_constraint_set_coefficient(c, isl_space_out, i, minusOne); bmap = isl_basic_map_add_constraint(bmap, c); } @@ -535,12 +535,12 @@ for (unsigned i = m->NbRows; i < scatteringDims; i++) { isl_constraint *c; - c = isl_equality_alloc(isl_dim_copy(dim)); + c = isl_equality_alloc(isl_space_copy(Space)); mpz_t One; mpz_init(One); mpz_set_si(One, 1); - isl_constraint_set_coefficient(c, isl_dim_out, i, One); + isl_constraint_set_coefficient(c, isl_space_out, i, One); bmap = isl_basic_map_add_constraint(bmap, c); } @@ -550,31 +550,31 @@ /// @brief Create an isl constraint from a row of OpenScop integers. /// /// @param row An array of isl/OpenScop integers. -/// @param dim An isl dim object, describing how to spilt the dimensions. +/// @param Space An isl space object, describing how to spilt the dimensions. /// /// @return An isl constraint representing this integer array. -isl_constraint *constraintFromMatrixRowFull(isl_int *row, isl_dim *dim) { +isl_constraint *constraintFromMatrixRowFull(isl_int *row, isl_space *Space) { isl_constraint *c; - unsigned NbOut = isl_dim_size(dim, isl_dim_out); - unsigned NbIn = isl_dim_size(dim, isl_dim_in); - unsigned NbParam = isl_dim_size(dim, isl_dim_param); + unsigned NbOut = isl_space_size(Space, isl_dim_out); + unsigned NbIn = isl_space_size(Space, isl_dim_in); + unsigned NbParam = isl_space_size(Space, isl_dim_param); if (isl_int_is_zero(row[0])) - c = isl_equality_alloc(isl_dim_copy(dim)); + c = isl_equality_alloc(isl_space_copy(Space)); else - c = isl_inequality_alloc(isl_dim_copy(dim)); + c = isl_inequality_alloc(isl_space_copy(Space)); unsigned current_column = 1; for (unsigned j = 0; j < NbOut; ++j) - isl_constraint_set_coefficient(c, isl_dim_out, j, row[current_column++]); + isl_constraint_set_coefficient(c, isl_space_out, j, row[current_column++]); for (unsigned j = 0; j < NbIn; ++j) - isl_constraint_set_coefficient(c, isl_dim_in, j, row[current_column++]); + isl_constraint_set_coefficient(c, isl_space_in, j, row[current_column++]); for (unsigned j = 0; j < NbParam; ++j) - isl_constraint_set_coefficient(c, isl_dim_param, j, row[current_column++]); + isl_constraint_set_coefficient(c, isl_space_param, j, row[current_column++]); isl_constraint_set_constant(c, row[current_column]); @@ -584,16 +584,16 @@ /// @brief Create an isl map from a OpenScop matrix. /// /// @param m The OpenScop matrix to translate. -/// @param dim The dimensions that are contained in the OpenScop matrix. +/// @param Space The dimensions that are contained in the OpenScop matrix. /// /// @return An isl map representing m. -isl_map *mapFromMatrix(scoplib_matrix_p m, isl_dim *dim) { - isl_basic_map *bmap = isl_basic_map_universe(isl_dim_copy(dim)); +isl_map *mapFromMatrix(scoplib_matrix_p m, isl_space *Space) { + isl_basic_map *bmap = isl_basic_map_universe(isl_space_copy(Space)); for (unsigned i = 0; i < m->NbRows; ++i) { isl_constraint *c; - c = constraintFromMatrixRowFull(m->p[i], dim); + c = constraintFromMatrixRowFull(m->p[i], Space); bmap = isl_basic_map_add_constraint(bmap, c); } @@ -619,18 +619,18 @@ NbScattering = scatteringDims; isl_ctx *ctx = PollyStmt->getParent()->getCtx(); - isl_dim *dim = isl_dim_alloc(ctx, NbParam, NbIterators, NbScattering); - dim = isl_dim_set_tuple_name(dim, isl_dim_out, "scattering"); - dim = isl_dim_set_tuple_name(dim, isl_dim_in, PollyStmt->getBaseName()); + isl_space *Space = isl_dim_alloc(ctx, NbParam, NbIterators, NbScattering); + Space = isl_space_set_tuple_name(Space, isl_dim_out, "scattering"); + Space = isl_space_set_tuple_name(Space, isl_dim_in, PollyStmt->getBaseName()); isl_map *map; if (scatteringDims == -1) - map = mapFromMatrix(m, dim); + map = mapFromMatrix(m, Space); else - map = mapFromMatrix(m, dim, scatteringDims); + map = mapFromMatrix(m, Space, scatteringDims); - isl_dim_free(dim); + isl_space_free(Space); return map; } Modified: polly/trunk/lib/Pocc.cpp URL: http://llvm.org/viewvc/llvm-project/polly/trunk/lib/Pocc.cpp?rev=141251&r1=141250&r2=141251&view=diff ============================================================================== --- polly/trunk/lib/Pocc.cpp (original) +++ polly/trunk/lib/Pocc.cpp Wed Oct 5 19:03:35 2011 @@ -32,7 +32,7 @@ #include "polly/ScopLib.h" -#include "isl/dim.h" +#include "isl/space.h" #include "isl/map.h" #include "isl/constraint.h" @@ -202,12 +202,12 @@ isl_map *scat = (*SI)->getScattering(); int scatDims = isl_map_n_out(scat); - isl_dim *dim = isl_dim_alloc(S.getCtx(), S.getNumParams(), scatDims, - scatDims + 1); - isl_basic_map *map = isl_basic_map_universe(isl_dim_copy(dim)); + isl_space *Space= isl_space_alloc(S.getCtx(), S.getNumParams(), scatDims, + scatDims + 1); + isl_basic_map *map = isl_basic_map_universe(isl_space_copy(Space)); for (int i = 0; i <= lastLoop - 1; i++) { - isl_constraint *c = isl_equality_alloc(isl_dim_copy(dim)); + isl_constraint *c = isl_equality_alloc(isl_space_copy(Space)); isl_constraint_set_coefficient_si(c, isl_dim_in, i, 1); isl_constraint_set_coefficient_si(c, isl_dim_out, i, -1); @@ -216,7 +216,7 @@ } for (int i = lastLoop; i < scatDims; i++) { - isl_constraint *c = isl_equality_alloc(isl_dim_copy(dim)); + isl_constraint *c = isl_equality_alloc(isl_space_copy(Space)); isl_constraint_set_coefficient_si(c, isl_dim_in, i, 1); isl_constraint_set_coefficient_si(c, isl_dim_out, i + 1, -1); @@ -227,12 +227,12 @@ isl_constraint *c; int vectorWidth = 4; - c = isl_inequality_alloc(isl_dim_copy(dim)); + c = isl_inequality_alloc(isl_space_copy(Space)); isl_constraint_set_coefficient_si(c, isl_dim_out, lastLoop, -vectorWidth); isl_constraint_set_coefficient_si(c, isl_dim_out, lastLoop + 1, 1); map = isl_basic_map_add_constraint(map, c); - c = isl_inequality_alloc(isl_dim_copy(dim)); + c = isl_inequality_alloc(isl_space_copy(Space)); isl_constraint_set_coefficient_si(c, isl_dim_out, lastLoop, vectorWidth); isl_constraint_set_coefficient_si(c, isl_dim_out, lastLoop + 1, -1); isl_constraint_set_constant_si(c, vectorWidth - 1); Modified: polly/trunk/lib/ScheduleOptimizer.cpp URL: http://llvm.org/viewvc/llvm-project/polly/trunk/lib/ScheduleOptimizer.cpp?rev=141251&r1=141250&r2=141251&view=diff ============================================================================== --- polly/trunk/lib/ScheduleOptimizer.cpp (original) +++ polly/trunk/lib/ScheduleOptimizer.cpp Wed Oct 5 19:03:35 2011 @@ -24,7 +24,7 @@ #include "polly/Dependences.h" #include "polly/ScopInfo.h" -#include "isl/dim.h" +#include "isl/space.h" #include "isl/map.h" #include "isl/constraint.h" #include "isl/schedule.h" @@ -75,30 +75,31 @@ continue; isl_map *scattering = stmt->getScattering(); - isl_dim *dim = isl_dim_alloc(isl_map_get_ctx(scattering), - 0, isl_map_n_out(scattering), - scatDimensions); - isl_basic_map *changeScattering = isl_basic_map_universe(isl_dim_copy(dim)); + isl_space *Space = isl_space_alloc(isl_map_get_ctx(scattering), 0, + isl_map_n_out(scattering), scatDimensions); + isl_basic_map *changeScattering = isl_basic_map_universe( + isl_space_copy(Space)); + isl_local_space *LocalSpace = isl_local_space_from_space(Space); for (unsigned i = 0; i < isl_map_n_out(scattering); i++) { - isl_constraint *c = isl_equality_alloc(isl_dim_copy(dim)); + isl_constraint *c = isl_equality_alloc(isl_local_space_copy(LocalSpace)); isl_constraint_set_coefficient_si(c, isl_dim_in, i, 1); isl_constraint_set_coefficient_si(c, isl_dim_out, i, -1); changeScattering = isl_basic_map_add_constraint(changeScattering, c); } for (unsigned i = isl_map_n_out(scattering); i < scatDimensions; i++) { - isl_constraint *c = isl_equality_alloc(isl_dim_copy(dim)); + isl_constraint *c = isl_equality_alloc(isl_local_space_copy(LocalSpace)); isl_constraint_set_coefficient_si(c, isl_dim_out, i, 1); changeScattering = isl_basic_map_add_constraint(changeScattering, c); } isl_map *changeScatteringMap = isl_map_from_basic_map(changeScattering); - isl_dim *dimModel = isl_map_get_dim(scattering); - changeScatteringMap = isl_map_align_params(changeScatteringMap, dimModel); + isl_space *SpaceModel = isl_map_get_space(scattering); + changeScatteringMap = isl_map_align_params(changeScatteringMap, SpaceModel); stmt->setScattering(isl_map_apply_range(scattering, changeScatteringMap)); - isl_dim_free(dim); + isl_local_space_free(LocalSpace); } } @@ -129,7 +130,7 @@ // S(i,j) // static isl_basic_map *getTileMap(isl_ctx *ctx, int scheduleDimensions, - isl_dim *dimModel, int tileSize = 32) { + isl_space *SpaceModel, int tileSize = 32) { // We construct // // tileMap := [p0] -> {[s0, s1] -> [t0, t1, p0, p1, a0, a1]: @@ -137,9 +138,11 @@ // s1 = a1 * 32 and s1 = p1 and t1 <= p1 < t1 + 32} // // and project out the auxilary dimensions a0 and a1. - isl_dim *dim = isl_dim_alloc(ctx, 0, scheduleDimensions, - scheduleDimensions * 3); - isl_basic_map *tileMap = isl_basic_map_universe(isl_dim_copy(dim)); + isl_space *Space = isl_space_alloc(ctx, 0, scheduleDimensions, + scheduleDimensions * 3); + isl_basic_map *tileMap = isl_basic_map_universe(isl_space_copy(Space)); + + isl_local_space *LocalSpace = isl_local_space_from_space(Space); for (int x = 0; x < scheduleDimensions; x++) { int sX = x; @@ -150,25 +153,25 @@ isl_constraint *c; // sX = aX * tileSize; - c = isl_equality_alloc(isl_dim_copy(dim)); + c = isl_equality_alloc(isl_local_space_copy(LocalSpace)); isl_constraint_set_coefficient_si(c, isl_dim_out, sX, 1); isl_constraint_set_coefficient_si(c, isl_dim_out, aX, -tileSize); tileMap = isl_basic_map_add_constraint(tileMap, c); // pX = sX; - c = isl_equality_alloc(isl_dim_copy(dim)); + c = isl_equality_alloc(isl_local_space_copy(LocalSpace)); isl_constraint_set_coefficient_si(c, isl_dim_out, pX, 1); isl_constraint_set_coefficient_si(c, isl_dim_in, sX, -1); tileMap = isl_basic_map_add_constraint(tileMap, c); // tX <= pX - c = isl_inequality_alloc(isl_dim_copy(dim)); + c = isl_inequality_alloc(isl_local_space_copy(LocalSpace)); isl_constraint_set_coefficient_si(c, isl_dim_out, pX, 1); isl_constraint_set_coefficient_si(c, isl_dim_out, tX, -1); tileMap = isl_basic_map_add_constraint(tileMap, c); // pX <= tX + (tileSize - 1) - c = isl_inequality_alloc(isl_dim_copy(dim)); + c = isl_inequality_alloc(isl_local_space_copy(LocalSpace)); isl_constraint_set_coefficient_si(c, isl_dim_out, tX, 1); isl_constraint_set_coefficient_si(c, isl_dim_out, pX, -1); isl_constraint_set_constant_si(c, tileSize - 1); @@ -183,7 +186,7 @@ tileMap = isl_basic_map_project_out(tileMap, isl_dim_out, 2 * scheduleDimensions, scheduleDimensions); - isl_dim_free(dim); + isl_local_space_free(LocalSpace); return tileMap; } @@ -191,18 +194,18 @@ isl_union_map *partialSchedule; int scheduleDimensions; isl_ctx *ctx; - isl_dim *dim; + isl_space *Space; isl_basic_map *tileMap; isl_union_map *tileUnionMap; partialSchedule = isl_band_get_partial_schedule(band); ctx = isl_union_map_get_ctx(partialSchedule); - dim = isl_union_map_get_dim(partialSchedule); + Space= isl_union_map_get_space(partialSchedule); scheduleDimensions = isl_band_n_member(band); - tileMap = getTileMap(ctx, scheduleDimensions, dim); + tileMap = getTileMap(ctx, scheduleDimensions, Space); tileUnionMap = isl_union_map_from_map(isl_map_from_basic_map(tileMap)); - tileUnionMap = isl_union_map_align_params(tileUnionMap, dim); + tileUnionMap = isl_union_map_align_params(tileUnionMap, Space); partialSchedule = isl_union_map_apply_range(partialSchedule, tileUnionMap); return partialSchedule; @@ -214,21 +217,23 @@ int vectorWidth = 4) { assert (0 <= vectorDimension && vectorDimension < scheduleDimensions); - isl_dim *dim = isl_dim_alloc(ctx, parameterDimensions, scheduleDimensions, - scheduleDimensions + 2); - isl_basic_map *tilingMap = isl_basic_map_universe(isl_dim_copy(dim)); + isl_space *Space = isl_space_alloc(ctx, parameterDimensions, + scheduleDimensions, scheduleDimensions + 2); + isl_basic_map *tilingMap = isl_basic_map_universe(isl_space_copy(Space)); isl_constraint *c; + isl_local_space *LocalSpace = isl_local_space_from_space(Space); + for (int i = 0; i < vectorDimension; i++) { - c = isl_equality_alloc(isl_dim_copy(dim)); + c = isl_equality_alloc(isl_local_space_copy(LocalSpace)); isl_constraint_set_coefficient_si(c, isl_dim_in, i, -1); isl_constraint_set_coefficient_si(c, isl_dim_out, i, 1); tilingMap = isl_basic_map_add_constraint(tilingMap, c); } for (int i = vectorDimension + 1; i < scheduleDimensions; i++) { - c = isl_equality_alloc(isl_dim_copy(dim)); + c = isl_equality_alloc(isl_local_space_copy(LocalSpace)); isl_constraint_set_coefficient_si(c, isl_dim_in, i, -1); isl_constraint_set_coefficient_si(c, isl_dim_out, i, 1); tilingMap = isl_basic_map_add_constraint(tilingMap, c); @@ -237,23 +242,23 @@ int stepDimension = scheduleDimensions; int auxilaryDimension = scheduleDimensions + 1; - c = isl_equality_alloc(isl_dim_copy(dim)); + c = isl_equality_alloc(isl_local_space_copy(LocalSpace)); isl_constraint_set_coefficient_si(c, isl_dim_out, vectorDimension, 1); isl_constraint_set_coefficient_si(c, isl_dim_out, auxilaryDimension, -vectorWidth); tilingMap = isl_basic_map_add_constraint(tilingMap, c); - c = isl_equality_alloc(isl_dim_copy(dim)); + c = isl_equality_alloc(isl_local_space_copy(LocalSpace)); isl_constraint_set_coefficient_si(c, isl_dim_in, vectorDimension, -1); isl_constraint_set_coefficient_si(c, isl_dim_out, stepDimension, 1); tilingMap = isl_basic_map_add_constraint(tilingMap, c); - c = isl_inequality_alloc(isl_dim_copy(dim)); + c = isl_inequality_alloc(isl_local_space_copy(LocalSpace)); isl_constraint_set_coefficient_si(c, isl_dim_out, vectorDimension, -1); isl_constraint_set_coefficient_si(c, isl_dim_out, stepDimension, 1); tilingMap = isl_basic_map_add_constraint(tilingMap, c); - c = isl_inequality_alloc(dim); + c = isl_inequality_alloc(LocalSpace); isl_constraint_set_coefficient_si(c, isl_dim_out, vectorDimension, 1); isl_constraint_set_coefficient_si(c, isl_dim_out, stepDimension, -1); isl_constraint_set_constant_si(c, vectorWidth- 1); @@ -285,7 +290,7 @@ band = isl_band_list_get_band(blist, i); partialSchedule = getTiledPartialSchedule(band); int scheduleDimensions = isl_band_n_member(band); - isl_dim *dim = isl_union_map_get_dim(partialSchedule); + isl_space *Space = isl_union_map_get_space(partialSchedule); if (isl_band_has_children(band)) { @@ -306,7 +311,7 @@ scheduleDimensions * 2, 0); tileUnionMap = isl_union_map_from_map(tileMap); tileUnionMap = isl_union_map_align_params(tileUnionMap, - isl_dim_copy(dim)); + isl_space_copy(Space)); partialSchedule = isl_union_map_apply_range(partialSchedule, tileUnionMap); break; @@ -320,7 +325,7 @@ finalSchedule = partialSchedule; isl_band_free(band); - isl_dim_free(dim); + isl_space_free(Space); } return finalSchedule; Modified: polly/trunk/utils/checkout_cloog.sh URL: http://llvm.org/viewvc/llvm-project/polly/trunk/utils/checkout_cloog.sh?rev=141251&r1=141250&r2=141251&view=diff ============================================================================== --- polly/trunk/utils/checkout_cloog.sh (original) +++ polly/trunk/utils/checkout_cloog.sh Wed Oct 5 19:03:35 2011 @@ -1,7 +1,7 @@ #!/bin/sh -CLOOG_HASH="cloog-0.16.3" -ISL_HASH="cd1939ed06617d00159e8e51b72a804b467e98b4" +cloog_hash="0c252c88946b27b7b61a1a8d8fd7f94d2461dbfd" +isl_hash="56b7d238929980e62218525b4b3be121af386edf" check_command_line() { if [ "${1}x" = "x" ] || [ "${2}x" != "x" ] Modified: polly/trunk/www/get_started.html URL: http://llvm.org/viewvc/llvm-project/polly/trunk/www/get_started.html?rev=141251&r1=141250&r2=141251&view=diff ============================================================================== --- polly/trunk/www/get_started.html (original) +++ polly/trunk/www/get_started.html Wed Oct 5 19:03:35 2011 @@ -53,9 +53,9 @@

CLooG/isl

Polly is tested and works with CLooG as of -commit 225c2ed62fe37a4db22bf4b95c3731dab1a50dde +commit 0c252c88946b27b7b61a1a8d8fd7f94d2461dbfd and isl as of -commit cd1939ed06617d00159e8e51b72a804b467e98b4. To get and install the +commit 56b7d238929980e62218525b4b3be121af386edf. To get and install the relevant cloog version use the following commands:

Set the directory layout:

From grosser at fim.uni-passau.de Wed Oct 5 19:03:42 2011 From: grosser at fim.uni-passau.de (Tobias Grosser) Date: Thu, 06 Oct 2011 00:03:42 -0000 Subject: [llvm-commits] [polly] r141252 - in /polly/trunk: include/polly/ScopInfo.h lib/Analysis/Dependences.cpp lib/Analysis/ScopInfo.cpp Message-ID: <20111006000342.868332A6C12C@llvm.org> Author: grosser Date: Wed Oct 5 19:03:42 2011 New Revision: 141252 URL: http://llvm.org/viewvc/llvm-project?rev=141252&view=rev Log: Export the parameter space directly from the SCoP. Use this to simplify some code. Modified: polly/trunk/include/polly/ScopInfo.h polly/trunk/lib/Analysis/Dependences.cpp polly/trunk/lib/Analysis/ScopInfo.cpp Modified: polly/trunk/include/polly/ScopInfo.h URL: http://llvm.org/viewvc/llvm-project/polly/trunk/include/polly/ScopInfo.h?rev=141252&r1=141251&r2=141252&view=diff ============================================================================== --- polly/trunk/include/polly/ScopInfo.h (original) +++ polly/trunk/include/polly/ScopInfo.h Wed Oct 5 19:03:42 2011 @@ -22,6 +22,8 @@ #include "llvm/Analysis/RegionPass.h" +#include "isl/ctx.h" + using namespace llvm; namespace llvm { @@ -490,6 +492,7 @@ /// /// @return The constraint on parameter of this Scop. inline isl_set *getContext() const { return Context; } + __isl_give isl_space *getParamSpace() const; /// @brief Get an isl string representing the context. std::string getContextStr() const; Modified: polly/trunk/lib/Analysis/Dependences.cpp URL: http://llvm.org/viewvc/llvm-project/polly/trunk/lib/Analysis/Dependences.cpp?rev=141252&r1=141251&r2=141252&view=diff ============================================================================== --- polly/trunk/lib/Analysis/Dependences.cpp (original) +++ polly/trunk/lib/Analysis/Dependences.cpp Wed Oct 5 19:03:42 2011 @@ -52,9 +52,7 @@ } bool Dependences::runOnScop(Scop &S) { - isl_space *Space = isl_space_alloc(S.getCtx(), 0, 0, 0); - isl_space *Model = isl_set_get_dim(S.getContext()); - Space = isl_space_align_params(Space, Model); + isl_space *Space = S.getParamSpace(); if (sink) isl_union_map_free(sink); @@ -155,13 +153,10 @@ if (LegalityCheckDisabled) return true; - isl_space *Space = isl_space_alloc(S.getCtx(), 0, 0, 0); + isl_space *Space = S.getParamSpace(); isl_union_map *schedule = isl_union_map_empty(Space); - isl_space *Model = isl_set_get_space(S.getContext()); - schedule = isl_union_map_align_params(schedule, Model); - for (Scop::iterator SI = S.begin(), SE = S.end(); SI != SE; ++SI) { ScopStmt *Stmt = *SI; @@ -242,11 +237,8 @@ } isl_union_map* getCombinedScheduleForSpace(Scop *scop, unsigned dimLevel) { - isl_space *Space = isl_space_alloc(scop->getCtx(), 0, 0, 0); - + isl_space *Space = scop->getParamSpace(); isl_union_map *schedule = isl_union_map_empty(Space); - isl_space *Model = isl_set_get_space(scop->getContext()); - schedule = isl_union_map_align_params(schedule, Model); for (Scop::iterator SI = scop->begin(), SE = scop->end(); SI != SE; ++SI) { ScopStmt *Stmt = *SI; @@ -264,7 +256,6 @@ unsigned parallelDimension) { Scop *S = &getCurScop(); isl_union_map *schedule = getCombinedScheduleForSpace(S, parallelDimension); - isl_space *SpaceModel = isl_union_map_get_space(schedule); // Calculate distance vector. isl_union_set *scheduleSubset; @@ -330,7 +321,7 @@ } isl_set *allZero = isl_set_from_basic_set(allZeroBS); - allZero = isl_set_align_params(allZero, isl_space_copy(SpaceModel)); + allZero = isl_set_align_params(allZero, S->getParamSpace()); // All zero, last unknown. // [0, 0, 0, ?] @@ -350,7 +341,7 @@ isl_local_space_free(LocalSpace); isl_set *lastUnknown = isl_set_from_basic_set(lastUnknownBS); -lastUnknown = isl_set_align_params(lastUnknown, SpaceModel); + lastUnknown = isl_set_align_params(lastUnknown, S->getParamSpace()); // Valid distance vectors isl_set *validDistances = isl_set_subtract(lastUnknown, allZero); Modified: polly/trunk/lib/Analysis/ScopInfo.cpp URL: http://llvm.org/viewvc/llvm-project/polly/trunk/lib/Analysis/ScopInfo.cpp?rev=141252&r1=141251&r2=141252&view=diff ============================================================================== --- polly/trunk/lib/Analysis/ScopInfo.cpp (original) +++ polly/trunk/lib/Analysis/ScopInfo.cpp Wed Oct 5 19:03:42 2011 @@ -340,8 +340,8 @@ AccessRelation = isl_map_set_tuple_name(AccessRelation, isl_dim_out, getBaseName().c_str()); - isl_space *Model = isl_set_get_space(Statement->getParent()->getContext()); - AccessRelation = isl_map_align_params(AccessRelation, Model); + isl_space *ParamSpace = Statement->getParent()->getParamSpace(); + AccessRelation = isl_map_align_params(AccessRelation, ParamSpace); } MemoryAccess::MemoryAccess(const Value *BaseAddress, ScopStmt *Statement) { @@ -352,8 +352,8 @@ isl_basic_map *BasicAccessMap = createBasicAccessMap(Statement); AccessRelation = isl_map_from_basic_map(BasicAccessMap); - isl_space *Model = isl_set_get_space(Statement->getParent()->getContext()); - AccessRelation = isl_map_align_params(AccessRelation, Model); + isl_space *ParamSpace = Statement->getParent()->getParamSpace(); + AccessRelation = isl_map_align_params(AccessRelation, ParamSpace); } void MemoryAccess::print(raw_ostream &OS) const { @@ -564,8 +564,7 @@ isl_int_clear(v); Scattering = isl_map_from_basic_map(bmap); - isl_space *Model = isl_set_get_space(getParent()->getContext()); - Scattering = isl_map_align_params(Scattering, Model); + Scattering = isl_map_align_params(Scattering, Parent.getParamSpace()); } void ScopStmt::buildAccesses(TempScop &tempScop, const Region &CurRegion) { @@ -642,7 +641,7 @@ Space = isl_space_set_tuple_name(Space, isl_dim_set, getBaseName()); Domain = isl_set_universe(isl_space_copy(Space)); - Domain = isl_set_align_params(Domain, isl_set_get_space(Parent.getContext())); + Domain = isl_set_align_params(Domain, Parent.getParamSpace()); isl_int v; isl_int_init(v); @@ -738,8 +737,7 @@ Domain = isl_set_read_from_str(Parent.getCtx(), IterationDomainString.c_str()); Domain = isl_set_set_tuple_name(Domain, getBaseName()); - isl_space *Model = isl_set_get_space(getParent()->getContext()); - Domain = isl_set_align_params(Domain, isl_space_copy(Model)); + Domain = isl_set_align_params(Domain, parent.getParamSpace()); // Build scattering. unsigned ScatSpace = Parent.getMaxLoopDepth() * 2 + 1; @@ -762,7 +760,7 @@ bmap = isl_basic_map_add_constraint(bmap, c); isl_int_clear(v); Scattering = isl_map_from_basic_map(bmap); - Scattering = isl_map_align_params(Scattering, Model); + Scattering = isl_map_align_params(Scattering, parent.getParamSpace()); // Build memory accesses, use SetVector to keep the order of memory accesses // and prevent the same memory access inserted more than once. @@ -937,6 +935,10 @@ return EntryName + "---" + ExitName; } +__isl_give isl_space *Scop::getParamSpace() const { + return isl_set_get_space(this->Context); +} + void Scop::printContext(raw_ostream &OS) const { OS << "Context:\n"; From grosser at fim.uni-passau.de Wed Oct 5 19:03:48 2011 From: grosser at fim.uni-passau.de (Tobias Grosser) Date: Thu, 06 Oct 2011 00:03:48 -0000 Subject: [llvm-commits] [polly] r141253 - in /polly/trunk: include/polly/ScopInfo.h lib/Analysis/ScopInfo.cpp test/ScopInfo/loop_carry.ll Message-ID: <20111006000348.60F922A6C12C@llvm.org> Author: grosser Date: Wed Oct 5 19:03:48 2011 New Revision: 141253 URL: http://llvm.org/viewvc/llvm-project?rev=141253&view=rev Log: ScopInfo: Use separate function to build context Modified: polly/trunk/include/polly/ScopInfo.h polly/trunk/lib/Analysis/ScopInfo.cpp polly/trunk/test/ScopInfo/loop_carry.ll Modified: polly/trunk/include/polly/ScopInfo.h URL: http://llvm.org/viewvc/llvm-project/polly/trunk/include/polly/ScopInfo.h?rev=141253&r1=141252&r2=141253&view=diff ============================================================================== --- polly/trunk/include/polly/ScopInfo.h (original) +++ polly/trunk/include/polly/ScopInfo.h Wed Oct 5 19:03:48 2011 @@ -20,6 +20,8 @@ #ifndef POLLY_SCOP_INFO_H #define POLLY_SCOP_INFO_H +#include "polly/ScopDetection.h" + #include "llvm/Analysis/RegionPass.h" #include "isl/ctx.h" @@ -39,7 +41,6 @@ struct isl_map; struct isl_basic_map; struct isl_set; -struct isl_ctx; struct isl_space; struct isl_constraint; @@ -418,6 +419,12 @@ /// @return True if the basic block is trivial, otherwise false. static bool isTrivialBB(BasicBlock *BB, TempScop &tempScop); + /// @brief Build the Context of the Scop. + /// + /// @param IslCtx The isl context to use. + /// @param ParamSet The list of all parameters in the SCoP. + void buildContext(isl_ctx *IslCtx, ParamSetType *ParamSet); + /// Build the Scop and Statement with precalculate scop information. void buildScop(TempScop &TempScop, const Region &CurRegion, // Loops in Scop containing CurRegion Modified: polly/trunk/lib/Analysis/ScopInfo.cpp URL: http://llvm.org/viewvc/llvm-project/polly/trunk/lib/Analysis/ScopInfo.cpp?rev=141253&r1=141252&r2=141253&view=diff ============================================================================== --- polly/trunk/lib/Analysis/ScopInfo.cpp (original) +++ polly/trunk/lib/Analysis/ScopInfo.cpp Wed Oct 5 19:03:48 2011 @@ -869,22 +869,18 @@ //===----------------------------------------------------------------------===// /// Scop class implement -Scop::Scop(TempScop &tempScop, LoopInfo &LI, ScalarEvolution &ScalarEvolution, - isl_ctx *ctx) - : SE(&ScalarEvolution), R(tempScop.getMaxRegion()), - MaxLoopDepth(tempScop.getMaxLoopDepth()) { - ParamSetType &Params = tempScop.getParamSet(); - Parameters.insert(Parameters.begin(), Params.begin(), Params.end()); - isl_space *Space = isl_space_set_alloc(ctx, getNumParams(), 0); +void Scop::buildContext(isl_ctx *IslCtx, ParamSetType *ParamSet) { + isl_space *Space = isl_space_params_alloc(IslCtx, ParamSet->size()); int i = 0; - for (ParamSetType::iterator PI = Params.begin(), PE = Params.end(); + for (ParamSetType::iterator PI = ParamSet->begin(), PE = ParamSet->end(); PI != PE; ++PI) { - const SCEV *scev = *PI; - isl_id *id = isl_id_alloc(ctx, - ("p" + convertInt(i)).c_str(), - (void *) scev); + const SCEV *Parameter = *PI; + Parameters.push_back(Parameter); + std::string ParameterName = "p" + convertInt(i); + isl_id *id = isl_id_alloc(IslCtx, ParameterName.c_str(), + (void *) Parameter); Space = isl_space_set_dim_id(Space, isl_dim_param, i, id); i++; } @@ -892,6 +888,13 @@ // TODO: Insert relations between parameters. // TODO: Insert constraints on parameters. Context = isl_set_universe (Space); +} + +Scop::Scop(TempScop &tempScop, LoopInfo &LI, ScalarEvolution &ScalarEvolution, + isl_ctx *Context) + : SE(&ScalarEvolution), R(tempScop.getMaxRegion()), + MaxLoopDepth(tempScop.getMaxLoopDepth()) { + buildContext(Context, &tempScop.getParamSet()); SmallVector NestLoops; SmallVector Scatter; Modified: polly/trunk/test/ScopInfo/loop_carry.ll URL: http://llvm.org/viewvc/llvm-project/polly/trunk/test/ScopInfo/loop_carry.ll?rev=141253&r1=141252&r2=141253&view=diff ============================================================================== --- polly/trunk/test/ScopInfo/loop_carry.ll (original) +++ polly/trunk/test/ScopInfo/loop_carry.ll Wed Oct 5 19:03:48 2011 @@ -47,7 +47,7 @@ } ; CHECK: Context: -; CHECK: [p0] -> { [] } +; CHECK: [p0] -> { : } ; CHECK: Statements { ; CHECK: Stmt_bb_nph ; CHECK: Domain := From grosser at fim.uni-passau.de Wed Oct 5 19:03:54 2011 From: grosser at fim.uni-passau.de (Tobias Grosser) Date: Thu, 06 Oct 2011 00:03:54 -0000 Subject: [llvm-commits] [polly] r141254 - in /polly/trunk: include/polly/ScopInfo.h lib/Analysis/Dependences.cpp lib/Analysis/ScopInfo.cpp lib/Analysis/ScopPass.cpp lib/Cloog.cpp lib/Exchange/JSONExporter.cpp Message-ID: <20111006000354.63BC72A6C12C@llvm.org> Author: grosser Date: Wed Oct 5 19:03:54 2011 New Revision: 141254 URL: http://llvm.org/viewvc/llvm-project?rev=141254&view=rev Log: ScopInfo: Get the isl_ctx always with getIslCtx() Modified: polly/trunk/include/polly/ScopInfo.h polly/trunk/lib/Analysis/Dependences.cpp polly/trunk/lib/Analysis/ScopInfo.cpp polly/trunk/lib/Analysis/ScopPass.cpp polly/trunk/lib/Cloog.cpp polly/trunk/lib/Exchange/JSONExporter.cpp Modified: polly/trunk/include/polly/ScopInfo.h URL: http://llvm.org/viewvc/llvm-project/polly/trunk/include/polly/ScopInfo.h?rev=141254&r1=141253&r2=141254&view=diff ============================================================================== --- polly/trunk/include/polly/ScopInfo.h (original) +++ polly/trunk/include/polly/ScopInfo.h Wed Oct 5 19:03:54 2011 @@ -282,7 +282,7 @@ ~ScopStmt(); /// @brief Get an isl_ctx pointer. - isl_ctx *getIslContext(); + isl_ctx *getIslCtx() const; /// @brief Get the iteration domain of this ScopStmt. /// @@ -536,7 +536,7 @@ /// @brief Get the isl context of this static control part. /// /// @return The isl context of this static control part. - isl_ctx *getCtx() const; + isl_ctx *getIslCtx() const; }; /// @brief Print Scop scop to raw_ostream O. Modified: polly/trunk/lib/Analysis/Dependences.cpp URL: http://llvm.org/viewvc/llvm-project/polly/trunk/lib/Analysis/Dependences.cpp?rev=141254&r1=141253&r2=141254&view=diff ============================================================================== --- polly/trunk/lib/Analysis/Dependences.cpp (original) +++ polly/trunk/lib/Analysis/Dependences.cpp Wed Oct 5 19:03:54 2011 @@ -302,7 +302,7 @@ isl_union_set *distance_waw = isl_union_map_deltas(restrictedDeps_waw); - isl_space *Space = isl_space_set_alloc(S->getCtx(), 0, parallelDimension); + isl_space *Space = isl_space_set_alloc(S->getIslCtx(), 0, parallelDimension); // [0, 0, 0, 0] - All zero isl_basic_set *allZeroBS = isl_basic_set_universe(isl_space_copy(Space)); Modified: polly/trunk/lib/Analysis/ScopInfo.cpp URL: http://llvm.org/viewvc/llvm-project/polly/trunk/lib/Analysis/ScopInfo.cpp?rev=141254&r1=141253&r2=141254&view=diff ============================================================================== --- polly/trunk/lib/Analysis/ScopInfo.cpp (original) +++ polly/trunk/lib/Analysis/ScopInfo.cpp Wed Oct 5 19:03:54 2011 @@ -115,7 +115,7 @@ } SCEVAffinator(const ScopStmt *stmt, const Value *baseAddress) : - ctx(stmt->getParent()->getCtx()), + ctx(stmt->getIslCtx()), NbLoopSpaces(stmt->getNumIterators()), scop(stmt->getParent()), baseAddress(baseAddress) {}; @@ -300,7 +300,7 @@ } isl_basic_map *MemoryAccess::createBasicAccessMap(ScopStmt *Statement) { - isl_space *Space = isl_space_alloc(Statement->getIslContext(), 0, + isl_space *Space = isl_space_alloc(Statement->getIslCtx(), 0, Statement->getNumIterators(), 1); setBaseName(); @@ -520,7 +520,7 @@ void ScopStmt::buildScattering(SmallVectorImpl &Scatter) { unsigned NumberOfIterators = getNumIterators(); unsigned ScatSpace = Parent.getMaxLoopDepth() * 2 + 1; - isl_space *Space = isl_space_alloc(Parent.getCtx(), 0, NumberOfIterators, + isl_space *Space = isl_space_alloc(getIslCtx(), 0, NumberOfIterators, ScatSpace); Space = isl_space_set_tuple_name(Space, isl_dim_out, "scattering"); Space = isl_space_set_tuple_name(Space, isl_dim_in, getBaseName()); @@ -637,7 +637,7 @@ } void ScopStmt::buildIterationDomainFromLoops(TempScop &tempScop) { - isl_space *Space = isl_space_set_alloc(getIslContext(), 0, getNumIterators()); + isl_space *Space = isl_space_set_alloc(getIslCtx(), 0, getNumIterators()); Space = isl_space_set_tuple_name(Space, isl_dim_set, getBaseName()); Domain = isl_set_universe(isl_space_copy(Space)); @@ -734,14 +734,13 @@ // Build iteration domain. std::string IterationDomainString = "{[i0] : i0 = 0}"; - Domain = isl_set_read_from_str(Parent.getCtx(), - IterationDomainString.c_str()); + Domain = isl_set_read_from_str(getIslCtx(), IterationDomainString.c_str()); Domain = isl_set_set_tuple_name(Domain, getBaseName()); Domain = isl_set_align_params(Domain, parent.getParamSpace()); // Build scattering. unsigned ScatSpace = Parent.getMaxLoopDepth() * 2 + 1; - isl_space *Space = isl_space_alloc(Parent.getCtx(), 0, 1, ScatSpace); + isl_space *Space = isl_space_alloc(getIslCtx(), 0, 1, ScatSpace); Space = isl_space_set_tuple_name(Space, isl_dim_out, "scattering"); Space = isl_space_set_tuple_name(Space, isl_dim_in, getBaseName()); isl_basic_map *bmap = isl_basic_map_universe(isl_space_copy(Space)); @@ -825,8 +824,8 @@ return cast(getParent()->getSE()->getSCEV(PN)); } -isl_ctx *ScopStmt::getIslContext() { - return Parent.getCtx(); +isl_ctx *ScopStmt::getIslCtx() const { + return Parent.getIslCtx(); } isl_set *ScopStmt::getDomain() const { @@ -970,7 +969,7 @@ void Scop::dump() const { print(dbgs()); } -isl_ctx *Scop::getCtx() const { return isl_set_get_ctx(Context); } +isl_ctx *Scop::getIslCtx() const { return isl_set_get_ctx(Context); } ScalarEvolution *Scop::getSE() const { return SE; } Modified: polly/trunk/lib/Analysis/ScopPass.cpp URL: http://llvm.org/viewvc/llvm-project/polly/trunk/lib/Analysis/ScopPass.cpp?rev=141254&r1=141253&r2=141254&view=diff ============================================================================== --- polly/trunk/lib/Analysis/ScopPass.cpp (original) +++ polly/trunk/lib/Analysis/ScopPass.cpp Wed Oct 5 19:03:54 2011 @@ -28,7 +28,7 @@ isl_ctx *ScopPass::getIslContext() { assert(S && "Not in on a Scop!"); - return S->getCtx(); + return S->getIslCtx(); } void ScopPass::print(raw_ostream &OS, const Module *M) const { Modified: polly/trunk/lib/Cloog.cpp URL: http://llvm.org/viewvc/llvm-project/polly/trunk/lib/Cloog.cpp?rev=141254&r1=141253&r2=141254&view=diff ============================================================================== --- polly/trunk/lib/Cloog.cpp (original) +++ polly/trunk/lib/Cloog.cpp Wed Oct 5 19:03:54 2011 @@ -62,7 +62,7 @@ }; Cloog::Cloog(Scop *Scop) : S(Scop) { - State = cloog_isl_state_malloc(Scop->getCtx()); + State = cloog_isl_state_malloc(Scop->getIslCtx()); buildCloogOptions(); ClastRoot = cloog_clast_create_from_input(buildCloogInput(), Options); } Modified: polly/trunk/lib/Exchange/JSONExporter.cpp URL: http://llvm.org/viewvc/llvm-project/polly/trunk/lib/Exchange/JSONExporter.cpp?rev=141254&r1=141253&r2=141254&view=diff ============================================================================== --- polly/trunk/lib/Exchange/JSONExporter.cpp (original) +++ polly/trunk/lib/Exchange/JSONExporter.cpp Wed Oct 5 19:03:54 2011 @@ -236,7 +236,7 @@ continue; Json::Value schedule = jscop["statements"][index]["schedule"]; - isl_map *m = isl_map_read_from_str(S->getCtx(), schedule.asCString()); + isl_map *m = isl_map_read_from_str(S->getIslCtx(), schedule.asCString()); NewScattering[*SI] = m; index++; } @@ -266,7 +266,7 @@ ME = Stmt->memacc_end(); MI != ME; ++MI) { Json::Value accesses = jscop["statements"][statementIdx] ["accesses"][memoryAccessIdx]["relation"]; - isl_map *newAccessMap = isl_map_read_from_str(S->getCtx(), + isl_map *newAccessMap = isl_map_read_from_str(S->getIslCtx(), accesses.asCString()); isl_map *currentAccessMap = (*MI)->getAccessFunction(); if (!isl_map_has_equal_space(currentAccessMap, newAccessMap)) { From grosser at fim.uni-passau.de Wed Oct 5 19:03:59 2011 From: grosser at fim.uni-passau.de (Tobias Grosser) Date: Thu, 06 Oct 2011 00:03:59 -0000 Subject: [llvm-commits] [polly] r141255 - in /polly/trunk: include/polly/ScopInfo.h lib/Analysis/ScopInfo.cpp lib/Cloog.cpp Message-ID: <20111006000359.716482A6C12C@llvm.org> Author: grosser Date: Wed Oct 5 19:03:59 2011 New Revision: 141255 URL: http://llvm.org/viewvc/llvm-project?rev=141255&view=rev Log: ScopInfo: Only give away a copy of the Context Modified: polly/trunk/include/polly/ScopInfo.h polly/trunk/lib/Analysis/ScopInfo.cpp polly/trunk/lib/Cloog.cpp Modified: polly/trunk/include/polly/ScopInfo.h URL: http://llvm.org/viewvc/llvm-project/polly/trunk/include/polly/ScopInfo.h?rev=141255&r1=141254&r2=141255&view=diff ============================================================================== --- polly/trunk/include/polly/ScopInfo.h (original) +++ polly/trunk/include/polly/ScopInfo.h Wed Oct 5 19:03:59 2011 @@ -498,7 +498,7 @@ /// @brief Get the constraint on parameter of this Scop. /// /// @return The constraint on parameter of this Scop. - inline isl_set *getContext() const { return Context; } + __isl_give isl_set *getContext() const; __isl_give isl_space *getParamSpace() const; /// @brief Get an isl string representing the context. Modified: polly/trunk/lib/Analysis/ScopInfo.cpp URL: http://llvm.org/viewvc/llvm-project/polly/trunk/lib/Analysis/ScopInfo.cpp?rev=141255&r1=141254&r2=141255&view=diff ============================================================================== --- polly/trunk/lib/Analysis/ScopInfo.cpp (original) +++ polly/trunk/lib/Analysis/ScopInfo.cpp Wed Oct 5 19:03:59 2011 @@ -780,10 +780,7 @@ } std::string ScopStmt::getDomainStr() const { - isl_set *domain = getDomain(); - std::string string = stringFromIslObj(domain); - isl_set_free(domain); - return string; + return stringFromIslObj(Domain); } std::string ScopStmt::getScatteringStr() const { @@ -917,7 +914,7 @@ } std::string Scop::getContextStr() const { - return stringFromIslObj(getContext()); + return stringFromIslObj(Context); } std::string Scop::getNameStr() const { @@ -937,6 +934,9 @@ return EntryName + "---" + ExitName; } +__isl_give isl_set *Scop::getContext() const { + return isl_set_copy(Context); +} __isl_give isl_space *Scop::getParamSpace() const { return isl_set_get_space(this->Context); } Modified: polly/trunk/lib/Cloog.cpp URL: http://llvm.org/viewvc/llvm-project/polly/trunk/lib/Cloog.cpp?rev=141255&r1=141254&r2=141255&view=diff ============================================================================== --- polly/trunk/lib/Cloog.cpp (original) +++ polly/trunk/lib/Cloog.cpp Wed Oct 5 19:03:59 2011 @@ -174,10 +174,9 @@ } CloogInput *Cloog::buildCloogInput() { - CloogDomain *Context = - cloog_domain_from_isl_set(isl_set_copy(S->getContext())); + CloogDomain *Context = cloog_domain_from_isl_set(S->getContext()); CloogUnionDomain *Statements = buildCloogUnionDomain(); - CloogInput *Input = cloog_input_alloc (Context, Statements); + CloogInput *Input = cloog_input_alloc(Context, Statements); return Input; } } // End namespace polly. From grosser at fim.uni-passau.de Wed Oct 5 19:04:05 2011 From: grosser at fim.uni-passau.de (Tobias Grosser) Date: Thu, 06 Oct 2011 00:04:05 -0000 Subject: [llvm-commits] [polly] r141256 - in /polly/trunk: include/polly/ScopInfo.h lib/Analysis/Dependences.cpp lib/Analysis/ScopInfo.cpp lib/Cloog.cpp lib/Exchange/OpenScopExporter.cpp lib/Exchange/ScopLib.cpp lib/Pocc.cpp lib/ScheduleOptimizer.cpp Message-ID: <20111006000406.09AD6312800A@llvm.org> Author: grosser Date: Wed Oct 5 19:04:05 2011 New Revision: 141256 URL: http://llvm.org/viewvc/llvm-project?rev=141256&view=rev Log: ScopInfo: Only give away a copy of the schedule. Modified: polly/trunk/include/polly/ScopInfo.h polly/trunk/lib/Analysis/Dependences.cpp polly/trunk/lib/Analysis/ScopInfo.cpp polly/trunk/lib/Cloog.cpp polly/trunk/lib/Exchange/OpenScopExporter.cpp polly/trunk/lib/Exchange/ScopLib.cpp polly/trunk/lib/Pocc.cpp polly/trunk/lib/ScheduleOptimizer.cpp Modified: polly/trunk/include/polly/ScopInfo.h URL: http://llvm.org/viewvc/llvm-project/polly/trunk/include/polly/ScopInfo.h?rev=141256&r1=141255&r2=141256&view=diff ============================================================================== --- polly/trunk/include/polly/ScopInfo.h (original) +++ polly/trunk/include/polly/ScopInfo.h Wed Oct 5 19:04:05 2011 @@ -295,7 +295,7 @@ /// @brief Get the scattering function of this ScopStmt. /// /// @return The scattering function of this ScopStmt. - isl_map *getScattering() const { return Scattering; } + isl_map *getScattering() const; void setScattering(isl_map *scattering); /// @brief Get an isl string representing this scattering. Modified: polly/trunk/lib/Analysis/Dependences.cpp URL: http://llvm.org/viewvc/llvm-project/polly/trunk/lib/Analysis/Dependences.cpp?rev=141256&r1=141255&r2=141256&view=diff ============================================================================== --- polly/trunk/lib/Analysis/Dependences.cpp (original) +++ polly/trunk/lib/Analysis/Dependences.cpp Wed Oct 5 19:04:05 2011 @@ -106,8 +106,7 @@ else must_source = isl_union_map_add_map(must_source, accdom); } - isl_map *scattering = isl_map_copy(Stmt->getScattering()); - schedule = isl_union_map_add_map(schedule, scattering); + schedule = isl_union_map_add_map(schedule, Stmt->getScattering()); } DEBUG( @@ -163,7 +162,7 @@ isl_map *scattering; if (NewScattering->find(*SI) == NewScattering->end()) - scattering = isl_map_copy(Stmt->getScattering()); + scattering = Stmt->getScattering(); else scattering = isl_map_copy((*NewScattering)[Stmt]); @@ -242,11 +241,11 @@ for (Scop::iterator SI = scop->begin(), SE = scop->end(); SI != SE; ++SI) { ScopStmt *Stmt = *SI; - isl_map *scattering = isl_map_copy(Stmt->getScattering()); - unsigned remainingDimensions = isl_map_n_out(scattering) - dimLevel; - scattering = isl_map_project_out(scattering, isl_dim_out, dimLevel, - remainingDimensions); - schedule = isl_union_map_add_map(schedule, scattering); + unsigned remainingDimensions = Stmt->getNumScattering() - dimLevel; + isl_map *Scattering = isl_map_project_out(Stmt->getScattering(), + isl_dim_out, dimLevel, + remainingDimensions); + schedule = isl_union_map_add_map(schedule, Scattering); } return schedule; Modified: polly/trunk/lib/Analysis/ScopInfo.cpp URL: http://llvm.org/viewvc/llvm-project/polly/trunk/lib/Analysis/ScopInfo.cpp?rev=141256&r1=141255&r2=141256&view=diff ============================================================================== --- polly/trunk/lib/Analysis/ScopInfo.cpp (original) +++ polly/trunk/lib/Analysis/ScopInfo.cpp Wed Oct 5 19:04:05 2011 @@ -426,7 +426,7 @@ isl_set *MemoryAccess::getStride(const isl_set *domainSubset) const { isl_map *accessRelation = isl_map_copy(getAccessFunction()); isl_set *scatteringDomain = isl_set_copy(const_cast(domainSubset)); - isl_map *scattering = isl_map_copy(getStatement()->getScattering()); + isl_map *scattering = getStatement()->getScattering(); scattering = isl_map_reverse(scattering); int difference = isl_map_n_in(scattering) - isl_set_n_dim(scatteringDomain); @@ -512,9 +512,14 @@ } //===----------------------------------------------------------------------===// -void ScopStmt::setScattering(isl_map *scattering) { + +isl_map *ScopStmt::getScattering() const { + return isl_map_copy(Scattering); +} + +void ScopStmt::setScattering(isl_map *NewScattering) { isl_map_free(Scattering); - Scattering = scattering; + Scattering = NewScattering; } void ScopStmt::buildScattering(SmallVectorImpl &Scatter) { @@ -784,7 +789,7 @@ } std::string ScopStmt::getScatteringStr() const { - return stringFromIslObj(getScattering()); + return stringFromIslObj(Scattering); } unsigned ScopStmt::getNumParams() const { Modified: polly/trunk/lib/Cloog.cpp URL: http://llvm.org/viewvc/llvm-project/polly/trunk/lib/Cloog.cpp?rev=141256&r1=141255&r2=141256&view=diff ============================================================================== --- polly/trunk/lib/Cloog.cpp (original) +++ polly/trunk/lib/Cloog.cpp Wed Oct 5 19:04:05 2011 @@ -159,10 +159,11 @@ if (Stmt->isFinalRead()) continue; - CloogScattering *Scattering= - cloog_scattering_from_isl_map(isl_map_copy(Stmt->getScattering())); - CloogDomain *Domain = - cloog_domain_from_isl_set(Stmt->getDomain()); + CloogScattering *Scattering; + CloogDomain *Domain; + + Scattering = cloog_scattering_from_isl_map(Stmt->getScattering()); + Domain = cloog_domain_from_isl_set(Stmt->getDomain()); std::string entryName = Stmt->getBaseName(); Modified: polly/trunk/lib/Exchange/OpenScopExporter.cpp URL: http://llvm.org/viewvc/llvm-project/polly/trunk/lib/Exchange/OpenScopExporter.cpp?rev=141256&r1=141255&r2=141256&view=diff ============================================================================== --- polly/trunk/lib/Exchange/OpenScopExporter.cpp (original) +++ polly/trunk/lib/Exchange/OpenScopExporter.cpp Wed Oct 5 19:04:05 2011 @@ -146,8 +146,11 @@ // Domain & Schedule isl_set *domain = stmt->getDomain(); Stmt->domain = domainToMatrix(domain); - Stmt->schedule = scatteringToMatrix(stmt->getScattering()); + isl_map *Scattering = stmt->getScattering(); + Stmt->schedule = scatteringToMatrix(Scattering); isl_set_free(domain); + isl_map_free(Scattering); + // Statement name const char* entryName = stmt->getBaseName(); Modified: polly/trunk/lib/Exchange/ScopLib.cpp URL: http://llvm.org/viewvc/llvm-project/polly/trunk/lib/Exchange/ScopLib.cpp?rev=141256&r1=141255&r2=141256&view=diff ============================================================================== --- polly/trunk/lib/Exchange/ScopLib.cpp (original) +++ polly/trunk/lib/Exchange/ScopLib.cpp Wed Oct 5 19:04:05 2011 @@ -93,7 +93,9 @@ Stmt->domain = scoplib_matrix_list_malloc(); Stmt->domain->elt = domainToMatrix(domain); Stmt->domain->next = NULL; - Stmt->schedule = scatteringToMatrix(stmt->getScattering()); + isl_map *Scattering = stmt->getScattering; + Stmt->schedule = scatteringToMatrix(Scattering); + isl_map_free(Scattering); isl_set_free(domain); // Statement name Modified: polly/trunk/lib/Pocc.cpp URL: http://llvm.org/viewvc/llvm-project/polly/trunk/lib/Pocc.cpp?rev=141256&r1=141255&r2=141256&view=diff ============================================================================== --- polly/trunk/lib/Pocc.cpp (original) +++ polly/trunk/lib/Pocc.cpp Wed Oct 5 19:04:05 2011 @@ -179,7 +179,7 @@ if ((*SI)->isFinalRead()) continue; - isl_map *scat = isl_map_copy((*SI)->getScattering()); + isl_map *scat = (*SI)->getScattering(); isl_map *projected = isl_map_project_out(scat, isl_dim_out, lastLoop, scatterDims - lastLoop); @@ -199,11 +199,9 @@ for (Scop::iterator SI = S.begin(), SE = S.end(); SI != SE; ++SI) { if ((*SI)->isFinalRead()) continue; - isl_map *scat = (*SI)->getScattering(); - - int scatDims = isl_map_n_out(scat); - isl_space *Space= isl_space_alloc(S.getCtx(), S.getNumParams(), scatDims, - scatDims + 1); + int scatDims = (*SI)->getNumScattering(); + isl_space *Space = isl_space_alloc(S.getCtx(), S.getNumParams(), scatDims, + scatDims + 1); isl_basic_map *map = isl_basic_map_universe(isl_space_copy(Space)); for (int i = 0; i <= lastLoop - 1; i++) { Modified: polly/trunk/lib/ScheduleOptimizer.cpp URL: http://llvm.org/viewvc/llvm-project/polly/trunk/lib/ScheduleOptimizer.cpp?rev=141256&r1=141255&r2=141256&view=diff ============================================================================== --- polly/trunk/lib/ScheduleOptimizer.cpp (original) +++ polly/trunk/lib/ScheduleOptimizer.cpp Wed Oct 5 19:04:05 2011 @@ -67,38 +67,41 @@ return 0; } -static void extendScattering(Scop &S, unsigned scatDimensions) { +static void extendScattering(Scop &S, unsigned NewDimensions) { for (Scop::iterator SI = S.begin(), SE = S.end(); SI != SE; ++SI) { - ScopStmt *stmt = *SI; + ScopStmt *Stmt = *SI; - if (stmt->isFinalRead()) + if (Stmt->isFinalRead()) continue; - isl_map *scattering = stmt->getScattering(); - isl_space *Space = isl_space_alloc(isl_map_get_ctx(scattering), 0, - isl_map_n_out(scattering), scatDimensions); - isl_basic_map *changeScattering = isl_basic_map_universe( - isl_space_copy(Space)); + unsigned OldDimensions = Stmt->getNumScattering(); + isl_space *Space; + isl_basic_map *ChangeScattering; + + Space = isl_space_alloc(Stmt->getIslCtx(), 0, OldDimensions, NewDimensions); + ChangeScattering = isl_basic_map_universe(isl_space_copy(Space)); isl_local_space *LocalSpace = isl_local_space_from_space(Space); - for (unsigned i = 0; i < isl_map_n_out(scattering); i++) { + for (unsigned i = 0; i < OldDimensions; i++) { isl_constraint *c = isl_equality_alloc(isl_local_space_copy(LocalSpace)); isl_constraint_set_coefficient_si(c, isl_dim_in, i, 1); isl_constraint_set_coefficient_si(c, isl_dim_out, i, -1); - changeScattering = isl_basic_map_add_constraint(changeScattering, c); + ChangeScattering = isl_basic_map_add_constraint(ChangeScattering, c); } - for (unsigned i = isl_map_n_out(scattering); i < scatDimensions; i++) { + for (unsigned i = OldDimensions; i < NewDimensions; i++) { isl_constraint *c = isl_equality_alloc(isl_local_space_copy(LocalSpace)); isl_constraint_set_coefficient_si(c, isl_dim_out, i, 1); - changeScattering = isl_basic_map_add_constraint(changeScattering, c); + ChangeScattering = isl_basic_map_add_constraint(ChangeScattering, c); } - isl_map *changeScatteringMap = isl_map_from_basic_map(changeScattering); + isl_map *ChangeScatteringMap = isl_map_from_basic_map(ChangeScattering); - isl_space *SpaceModel = isl_map_get_space(scattering); - changeScatteringMap = isl_map_align_params(changeScatteringMap, SpaceModel); - stmt->setScattering(isl_map_apply_range(scattering, changeScatteringMap)); + ChangeScatteringMap = isl_map_align_params(ChangeScatteringMap, + S.getParamSpace()); + isl_map *NewScattering = isl_map_apply_range(Stmt->getScattering(), + ChangeScatteringMap); + Stmt->setScattering(NewScattering); isl_local_space_free(LocalSpace); } } @@ -391,7 +394,7 @@ isl_union_set_from_set(domain)); isl_map *stmtSchedule; isl_union_map_foreach_map(stmtBand, getSingleMap, &stmtSchedule); - stmt->setScattering(isl_map_copy(stmtSchedule)); + stmt->setScattering(stmtSchedule); isl_union_map_free(stmtBand); } @@ -401,7 +404,7 @@ unsigned maxScatDims = 0; for (Scop::iterator SI = S.begin(), SE = S.end(); SI != SE; ++SI) - maxScatDims = std::max(isl_map_n_out((*SI)->getScattering()), maxScatDims); + maxScatDims = std::max((*SI)->getNumScattering(), maxScatDims); extendScattering(S, maxScatDims); return false; From grosser at fim.uni-passau.de Wed Oct 5 19:04:12 2011 From: grosser at fim.uni-passau.de (Tobias Grosser) Date: Thu, 06 Oct 2011 00:04:12 -0000 Subject: [llvm-commits] [polly] r141257 - in /polly/trunk: include/polly/ScopInfo.h lib/Analysis/Dependences.cpp lib/Analysis/ScopInfo.cpp lib/CodeGeneration.cpp lib/Exchange/JSONExporter.cpp Message-ID: <20111006000412.25CF42A6C12C@llvm.org> Author: grosser Date: Wed Oct 5 19:04:11 2011 New Revision: 141257 URL: http://llvm.org/viewvc/llvm-project?rev=141257&view=rev Log: ScopInfo: Only give away a copy of the access relation. Also take the chance and rename access functions to access relations. This is because we do not only allow plain functions to describe an access, but we can have any access relation that can be described with linear constraints. Modified: polly/trunk/include/polly/ScopInfo.h polly/trunk/lib/Analysis/Dependences.cpp polly/trunk/lib/Analysis/ScopInfo.cpp polly/trunk/lib/CodeGeneration.cpp polly/trunk/lib/Exchange/JSONExporter.cpp Modified: polly/trunk/include/polly/ScopInfo.h URL: http://llvm.org/viewvc/llvm-project/polly/trunk/include/polly/ScopInfo.h?rev=141257&r1=141256&r2=141257&view=diff ============================================================================== --- polly/trunk/include/polly/ScopInfo.h (original) +++ polly/trunk/include/polly/ScopInfo.h Wed Oct 5 19:04:11 2011 @@ -119,11 +119,10 @@ /// @brief Is this a read memory access? bool isRead() const { return Type == MemoryAccess::Read; } - isl_map *getAccessFunction() { return AccessRelation; } - isl_map *getAccessFunction() const { return AccessRelation; } + isl_map *getAccessRelation() const; /// @brief Get an isl string representing this access function. - std::string getAccessFunctionStr() const; + std::string getAccessRelationStr() const; const Value *getBaseAddr() const { return BaseAddr; @@ -134,9 +133,7 @@ } /// @brief Get the new access function imported from JSCOP file - isl_map *getNewAccessFunction() { - return newAccessRelation; - } + isl_map *getNewAccessRelation() const; /// @brief Get the stride of this memory access in the specified domain /// subset. @@ -154,7 +151,7 @@ ScopStmt *getStatement() const { return statement; } /// @brief Set the updated access relation read from JSCOP file. - void setNewAccessFunction(isl_map *newAccessRelation); + void setNewAccessRelation(isl_map *newAccessRelation); /// @brief Print the MemoryAccess. /// /// @param OS The output stream the MemoryAccess is printed to. Modified: polly/trunk/lib/Analysis/Dependences.cpp URL: http://llvm.org/viewvc/llvm-project/polly/trunk/lib/Analysis/Dependences.cpp?rev=141257&r1=141256&r2=141257&view=diff ============================================================================== --- polly/trunk/lib/Analysis/Dependences.cpp (original) +++ polly/trunk/lib/Analysis/Dependences.cpp Wed Oct 5 19:04:11 2011 @@ -97,7 +97,7 @@ for (ScopStmt::memacc_iterator MI = Stmt->memacc_begin(), ME = Stmt->memacc_end(); MI != ME; ++MI) { isl_set *domcp = Stmt->getDomain(); - isl_map *accdom = isl_map_copy((*MI)->getAccessFunction()); + isl_map *accdom = (*MI)->getAccessRelation(); accdom = isl_map_intersect_domain(accdom, domcp); Modified: polly/trunk/lib/Analysis/ScopInfo.cpp URL: http://llvm.org/viewvc/llvm-project/polly/trunk/lib/Analysis/ScopInfo.cpp?rev=141257&r1=141256&r2=141257&view=diff ============================================================================== --- polly/trunk/lib/Analysis/ScopInfo.cpp (original) +++ polly/trunk/lib/Analysis/ScopInfo.cpp Wed Oct 5 19:04:11 2011 @@ -295,8 +295,16 @@ BaseName = "MemRef_" + BaseName; } -std::string MemoryAccess::getAccessFunctionStr() const { - return stringFromIslObj(getAccessFunction()); +isl_map *MemoryAccess::getAccessRelation() const { + return isl_map_copy(AccessRelation); +} + +std::string MemoryAccess::getAccessRelationStr() const { + return stringFromIslObj(AccessRelation); +} + +isl_map *MemoryAccess::getNewAccessRelation() const { + return isl_map_copy(newAccessRelation); } isl_basic_map *MemoryAccess::createBasicAccessMap(ScopStmt *Statement) { @@ -358,7 +366,7 @@ void MemoryAccess::print(raw_ostream &OS) const { OS.indent(12) << (isRead() ? "Read" : "Write") << "Access := \n"; - OS.indent(16) << getAccessFunctionStr() << ";\n"; + OS.indent(16) << getAccessRelationStr() << ";\n"; } void MemoryAccess::dump() const { @@ -424,7 +432,7 @@ } isl_set *MemoryAccess::getStride(const isl_set *domainSubset) const { - isl_map *accessRelation = isl_map_copy(getAccessFunction()); + isl_map *accessRelation = getAccessRelation(); isl_set *scatteringDomain = isl_set_copy(const_cast(domainSubset)); isl_map *scattering = getStatement()->getScattering(); @@ -506,7 +514,7 @@ return isStrideOne; } -void MemoryAccess::setNewAccessFunction(isl_map *newAccess) { +void MemoryAccess::setNewAccessRelation(isl_map *newAccess) { isl_map_free(newAccessRelation); newAccessRelation = newAccess; } Modified: polly/trunk/lib/CodeGeneration.cpp URL: http://llvm.org/viewvc/llvm-project/polly/trunk/lib/CodeGeneration.cpp?rev=141257&r1=141256&r2=141257&view=diff ============================================================================== --- polly/trunk/lib/CodeGeneration.cpp (original) +++ polly/trunk/lib/CodeGeneration.cpp Wed Oct 5 19:04:11 2011 @@ -358,22 +358,26 @@ /// @brief Generate the operand address Value *generateLocationAccessed(const Instruction *Inst, const Value *pointer, ValueMapT &BBMap ) { - MemoryAccess &access = statement.getAccessFor(Inst); - isl_map *currentAccessRelation = access.getAccessFunction(); - isl_map *newAccessRelation = access.getNewAccessFunction(); + MemoryAccess &Access = statement.getAccessFor(Inst); + isl_map *CurrentAccessRelation = Access.getAccessRelation(); + isl_map *NewAccessRelation = Access.getNewAccessRelation(); - assert(isl_map_has_equal_space(currentAccessRelation, newAccessRelation) + assert(isl_map_has_equal_space(CurrentAccessRelation, NewAccessRelation) && "Current and new access function use different spaces"); - if (!newAccessRelation) { - Value *newPointer = getOperand(pointer, BBMap); - return newPointer; + Value *NewPointer; + + if (!NewAccessRelation) { + NewPointer = getOperand(pointer, BBMap); + } else { + Value *BaseAddr = const_cast(Access.getBaseAddr()); + NewPointer = getNewAccessOperand(NewAccessRelation, BaseAddr, pointer, + BBMap); } - Value *baseAddr = const_cast(access.getBaseAddr()); - Value *newPointer = getNewAccessOperand(newAccessRelation, baseAddr, - pointer, BBMap); - return newPointer; + isl_map_free(CurrentAccessRelation); + isl_map_free(NewAccessRelation); + return NewPointer; } Value *generateScalarLoad(const LoadInst *load, ValueMapT &BBMap) { Modified: polly/trunk/lib/Exchange/JSONExporter.cpp URL: http://llvm.org/viewvc/llvm-project/polly/trunk/lib/Exchange/JSONExporter.cpp?rev=141257&r1=141256&r2=141257&view=diff ============================================================================== --- polly/trunk/lib/Exchange/JSONExporter.cpp (original) +++ polly/trunk/lib/Exchange/JSONExporter.cpp Wed Oct 5 19:04:11 2011 @@ -117,7 +117,7 @@ Json::Value access; access["kind"] = (*MI)->isRead() ? "read" : "write"; - access["relation"] = (*MI)->getAccessFunctionStr(); + access["relation"] = (*MI)->getAccessRelationStr(); statement["accesses"].append(access); } @@ -247,11 +247,11 @@ return false; } - for (Scop::iterator SI = S->begin(), SE = S->end(); SI != SE; ++SI) { - ScopStmt *Stmt = *SI; + for (Scop::iterator SI = S->begin(), SE = S->end(); SI != SE; ++SI) { + ScopStmt *Stmt = *SI; - if (NewScattering.find(Stmt) != NewScattering.end()) - Stmt->setScattering(NewScattering[Stmt]); + if (NewScattering.find(Stmt) != NewScattering.end()) + Stmt->setScattering(NewScattering[Stmt]); } int statementIdx = 0; @@ -268,15 +268,17 @@ ["accesses"][memoryAccessIdx]["relation"]; isl_map *newAccessMap = isl_map_read_from_str(S->getIslCtx(), accesses.asCString()); - isl_map *currentAccessMap = (*MI)->getAccessFunction(); + isl_map *currentAccessMap = (*MI)->getAccessRelation(); if (!isl_map_has_equal_space(currentAccessMap, newAccessMap)) { errs() << "JScop file contains access function with incompatible " << "dimensions\n"; + isl_map_free(currentAccessMap); isl_map_free(newAccessMap); return false; } if (isl_map_dim(newAccessMap, isl_dim_out) != 1) { errs() << "New access map in JScop file should be single dimensional\n"; + isl_map_free(currentAccessMap); isl_map_free(newAccessMap); return false; } @@ -284,10 +286,11 @@ // Statistics. ++NewAccessMapFound; newAccessStrings.push_back(accesses.asCString()); - (*MI)->setNewAccessFunction(newAccessMap); + (*MI)->setNewAccessRelation(newAccessMap); } else { isl_map_free(newAccessMap); } + isl_map_free(currentAccessMap); memoryAccessIdx++; } statementIdx++; From stoklund at 2pi.dk Wed Oct 5 19:08:27 2011 From: stoklund at 2pi.dk (Jakob Stoklund Olesen) Date: Thu, 06 Oct 2011 00:08:27 -0000 Subject: [llvm-commits] [llvm] r141258 - in /llvm/trunk: include/llvm/Target/TargetRegisterInfo.h utils/TableGen/RegisterInfoEmitter.cpp Message-ID: <20111006000827.A319C2A6C12C@llvm.org> Author: stoklund Date: Wed Oct 5 19:08:27 2011 New Revision: 141258 URL: http://llvm.org/viewvc/llvm-project?rev=141258&view=rev Log: Remove the TRI::getSubRegisterRegClass() hook. This restores my karma after I added TRI::getSubClassWithSubReg(). Register constraints are applied 'backwards'. Starting from the register class required by an instruction operand, the correct question is: 'How can I constrain the super-register register class so all its sub-registers satisfy the instruction constraint?' The getMatchingSuperRegClass() hook answers that. We never need to go 'forwards': Starting from a super-register register class, what register class are the sub-registers in? The getSubRegisterRegClass() hook did that. Modified: llvm/trunk/include/llvm/Target/TargetRegisterInfo.h llvm/trunk/utils/TableGen/RegisterInfoEmitter.cpp Modified: llvm/trunk/include/llvm/Target/TargetRegisterInfo.h URL: http://llvm.org/viewvc/llvm-project/llvm/trunk/include/llvm/Target/TargetRegisterInfo.h?rev=141258&r1=141257&r2=141258&view=diff ============================================================================== --- llvm/trunk/include/llvm/Target/TargetRegisterInfo.h (original) +++ llvm/trunk/include/llvm/Target/TargetRegisterInfo.h Wed Oct 5 19:08:27 2011 @@ -42,16 +42,14 @@ const vt_iterator VTs; const unsigned *SubClassMask; const sc_iterator SuperClasses; - const sc_iterator SubRegClasses; const sc_iterator SuperRegClasses; public: TargetRegisterClass(const MCRegisterClass *MC, const EVT *vts, const unsigned *subcm, const TargetRegisterClass * const *supcs, - const TargetRegisterClass * const *subregcs, const TargetRegisterClass * const *superregcs) : MC(MC), VTs(vts), SubClassMask(subcm), SuperClasses(supcs), - SubRegClasses(subregcs), SuperRegClasses(superregcs) {} + SuperRegClasses(superregcs) {} virtual ~TargetRegisterClass() {} // Allow subclasses @@ -127,25 +125,6 @@ return I; } - /// subregclasses_begin / subregclasses_end - Loop over all of - /// the subreg register classes of this register class. - sc_iterator subregclasses_begin() const { - return SubRegClasses; - } - - sc_iterator subregclasses_end() const { - sc_iterator I = SubRegClasses; - while (*I != NULL) ++I; - return I; - } - - /// getSubRegisterRegClass - Return the register class of subregisters with - /// index SubIdx, or NULL if no such class exists. - const TargetRegisterClass* getSubRegisterRegClass(unsigned SubIdx) const { - assert(SubIdx>0 && "Invalid subregister index"); - return SubRegClasses[SubIdx-1]; - } - /// superregclasses_begin / superregclasses_end - Loop over all of /// the superreg register classes of this register class. sc_iterator superregclasses_begin() const { Modified: llvm/trunk/utils/TableGen/RegisterInfoEmitter.cpp URL: http://llvm.org/viewvc/llvm-project/llvm/trunk/utils/TableGen/RegisterInfoEmitter.cpp?rev=141258&r1=141257&r2=141258&view=diff ============================================================================== --- llvm/trunk/utils/TableGen/RegisterInfoEmitter.cpp (original) +++ llvm/trunk/utils/TableGen/RegisterInfoEmitter.cpp Wed Oct 5 19:08:27 2011 @@ -543,40 +543,17 @@ unsigned NumSubRegIndices = RegBank.getSubRegIndices().size(); if (NumSubRegIndices) { - // Emit the sub-register classes for each RegisterClass + // Compute the super-register classes for each RegisterClass for (unsigned rc = 0, e = RegisterClasses.size(); rc != e; ++rc) { const CodeGenRegisterClass &RC = *RegisterClasses[rc]; - std::vector SRC(NumSubRegIndices); for (DenseMap::const_iterator i = RC.SubRegClasses.begin(), e = RC.SubRegClasses.end(); i != e; ++i) { - // Build SRC array. - unsigned idx = RegBank.getSubRegIndexNo(i->first); - SRC.at(idx-1) = i->second; - // Find the register class number of i->second for SuperRegClassMap. const CodeGenRegisterClass *RC2 = RegBank.getRegClass(i->second); assert(RC2 && "Invalid register class in SubRegClasses"); SuperRegClassMap[RC2->EnumValue].insert(rc); } - - // Give the register class a legal C name if it's anonymous. - std::string Name = RC.getName(); - - OS << " // " << Name - << " Sub-register Classes...\n" - << " static const TargetRegisterClass* const " - << Name << "SubRegClasses[] = {\n "; - - for (unsigned idx = 0; idx != NumSubRegIndices; ++idx) { - if (idx) - OS << ", "; - if (SRC[idx]) - OS << "&" << getQualifiedName(SRC[idx]) << "RegClass"; - else - OS << "0"; - } - OS << "\n };\n\n"; } // Emit the super-register classes for each RegisterClass @@ -651,9 +628,7 @@ OS << "NullRegClasses, "; else OS << RC.getName() + "Superclasses, "; - OS << (NumSubRegIndices ? RC.getName() + "Sub" : std::string("Null")) - << "RegClasses, " - << (NumSubRegIndices ? RC.getName() + "Super" : std::string("Null")) + OS << (NumSubRegIndices ? RC.getName() + "Super" : std::string("Null")) << "RegClasses" << ") {}\n"; if (!RC.AltOrderSelect.empty()) { From krasin at chromium.org Wed Oct 5 19:33:06 2011 From: krasin at chromium.org (Ivan Krasin) Date: Wed, 5 Oct 2011 17:33:06 -0700 Subject: [llvm-commits] arm mc: fix relocation of an alias to an alias Message-ID: Hi llvm team! The patch attached fixes the problem that ARMELFObjectWriter::ExplicitRelSym didn't resolve aliases. For some reason, the single alias works just fine, but the alias to alias crashes llc with the following message: llc: /usr/local/google/home/krasin/llvm/include/llvm/MC/MCSymbol.h:111: const llvm::MCSection &llvm::MCSymbol::getSection() const: Assertion `isInSection() && "Invalid accessor!"' failed. The full background of this issue is available here: http://code.google.com/p/nativeclient/issues/detail?id=2340 OK to commit? krasin -------------- next part -------------- A non-text attachment was scrubbed... Name: arm_reloc_alias_alias.patch Type: text/x-patch Size: 1648 bytes Desc: not available Url : http://lists.cs.uiuc.edu/pipermail/llvm-commits/attachments/20111005/1009a4c9/attachment.bin From isanbard at gmail.com Wed Oct 5 19:53:34 2011 From: isanbard at gmail.com (Bill Wendling) Date: Thu, 06 Oct 2011 00:53:34 -0000 Subject: [llvm-commits] [llvm] r141263 - /llvm/trunk/lib/Target/ARM/ARMISelLowering.cpp Message-ID: <20111006005335.DD16E2A6C12C@llvm.org> Author: void Date: Wed Oct 5 19:53:33 2011 New Revision: 141263 URL: http://llvm.org/viewvc/llvm-project?rev=141263&view=rev Log: Add the MBBs before inserting the instructions. Doing it afterwards could lead to an infinite loop because of the def-use chains. Also use a frame load instead of store for the LD instruction. Modified: llvm/trunk/lib/Target/ARM/ARMISelLowering.cpp Modified: llvm/trunk/lib/Target/ARM/ARMISelLowering.cpp URL: http://llvm.org/viewvc/llvm-project/llvm/trunk/lib/Target/ARM/ARMISelLowering.cpp?rev=141263&r1=141262&r2=141263&view=diff ============================================================================== --- llvm/trunk/lib/Target/ARM/ARMISelLowering.cpp (original) +++ llvm/trunk/lib/Target/ARM/ARMISelLowering.cpp Wed Oct 5 19:53:33 2011 @@ -5636,6 +5636,16 @@ MachineBasicBlock *DispContBB = MF->CreateMachineBasicBlock(); DispatchBB->addSuccessor(DispContBB); + // Insert and renumber MBBs. + MachineBasicBlock *Last = &MF->back(); + MF->insert(MF->end(), DispatchBB); + MF->insert(MF->end(), DispContBB); + MF->insert(MF->end(), TrapBB); + MF->RenumberBlocks(Last); + + FIMMO = MF->getMachineMemOperand(MachinePointerInfo::getFixedStack(FI), + MachineMemOperand::MOLoad, 4, 4); + unsigned NewVReg1 = MRI->createVirtualRegister(TRC); AddDefaultPred(BuildMI(DispatchBB, dl, TII->get(ARM::t2LDRi12), NewVReg1) .addFrameIndex(FI) @@ -5649,27 +5659,6 @@ .addImm(ARMCC::HI) .addReg(ARM::CPSR); -/* - -BB#32: derived from LLVM BB %eh.sjlj.setjmp.catch - Predecessors according to CFG: BB#0 - %vreg11 = t2LDRi12 , 4, pred:14, pred:%noreg; mem:Volatile LD4[%sunkaddr131] rGPR:%vreg11 - t2CMPri %vreg11, 6, pred:14, pred:%noreg, %CPSR; rGPR:%vreg11 - t2Bcc , pred:8, pred:%CPSR - Successors according to CFG: BB#33 BB#35 - -BB#35: derived from LLVM BB %eh.sjlj.setjmp.catch - Predecessors according to CFG: BB#32 - %vreg12 = t2LEApcrelJT , 0, pred:14, pred:%noreg; rGPR:%vreg12 - %vreg13 = t2ADDrs %vreg12, %vreg11, 18, pred:14, pred:%noreg, opt:%noreg; GPRnopc:%vreg13 rGPR:%vreg12,%vreg11 - t2BR_JT %vreg13, %vreg11, , 0; GPRnopc:%vreg13 rGPR:%vreg11 - Successors according to CFG: BB#3 BB#28 BB#26 BB#24 BB#22 BB#20 BB#31 - -*/ - - FIMMO = MF->getMachineMemOperand(MachinePointerInfo::getFixedStack(FI), - MachineMemOperand::MOLoad, 4, 4); - unsigned NewVReg2 = MRI->createVirtualRegister(TRC); AddDefaultPred(BuildMI(DispContBB, dl, TII->get(ARM::t2LEApcrelJT), NewVReg2) .addJumpTableIndex(MJTI) @@ -5694,13 +5683,6 @@ I = LPadList.begin(), E = LPadList.end(); I != E; ++I) DispContBB->addSuccessor(*I); - // Insert and renumber MBBs. - MachineBasicBlock *Last = &MF->back(); - MF->insert(MF->end(), DispatchBB); - MF->insert(MF->end(), DispContBB); - MF->insert(MF->end(), TrapBB); - MF->RenumberBlocks(Last); - // The instruction is gone now. MI->eraseFromParent(); From peter at pcc.me.uk Wed Oct 5 20:51:55 2011 From: peter at pcc.me.uk (Peter Collingbourne) Date: Thu, 06 Oct 2011 01:51:55 -0000 Subject: [llvm-commits] [llvm] r141266 - in /llvm/trunk: ./ cmake/modules/ include/llvm/ lib/Target/ARM/ lib/Target/Alpha/ lib/Target/Blackfin/ lib/Target/CellSPU/ lib/Target/MBlaze/ lib/Target/MSP430/ lib/Target/Mips/ lib/Target/PTX/ lib/Target/PowerPC/ lib/Target/Sparc/ lib/Target/SystemZ/ lib/Target/X86/ lib/Target/XCore/ lib/VMCore/ utils/TableGen/ Message-ID: <20111006015157.4492D312800A@llvm.org> Author: pcc Date: Wed Oct 5 20:51:51 2011 New Revision: 141266 URL: http://llvm.org/viewvc/llvm-project?rev=141266&view=rev Log: Build system infrastructure for multiple tblgens. Removed: llvm/trunk/cmake/modules/CrossCompileLLVM.cmake Modified: llvm/trunk/CMakeLists.txt llvm/trunk/Makefile.rules llvm/trunk/cmake/modules/TableGen.cmake llvm/trunk/include/llvm/CMakeLists.txt llvm/trunk/lib/Target/ARM/CMakeLists.txt llvm/trunk/lib/Target/Alpha/CMakeLists.txt llvm/trunk/lib/Target/Blackfin/CMakeLists.txt llvm/trunk/lib/Target/CellSPU/CMakeLists.txt llvm/trunk/lib/Target/MBlaze/CMakeLists.txt llvm/trunk/lib/Target/MSP430/CMakeLists.txt llvm/trunk/lib/Target/Mips/CMakeLists.txt llvm/trunk/lib/Target/PTX/CMakeLists.txt llvm/trunk/lib/Target/PowerPC/CMakeLists.txt llvm/trunk/lib/Target/Sparc/CMakeLists.txt llvm/trunk/lib/Target/SystemZ/CMakeLists.txt llvm/trunk/lib/Target/X86/CMakeLists.txt llvm/trunk/lib/Target/XCore/CMakeLists.txt llvm/trunk/lib/VMCore/Makefile llvm/trunk/utils/TableGen/CMakeLists.txt llvm/trunk/utils/TableGen/Makefile Modified: llvm/trunk/CMakeLists.txt URL: http://llvm.org/viewvc/llvm-project/llvm/trunk/CMakeLists.txt?rev=141266&r1=141265&r2=141266&view=diff ============================================================================== --- llvm/trunk/CMakeLists.txt (original) +++ llvm/trunk/CMakeLists.txt Wed Oct 5 20:51:51 2011 @@ -187,6 +187,10 @@ include(AddLLVM) include(TableGen) +macro(llvm_tablegen) + tablegen(LLVM ${ARGN}) +endmacro() + if( MINGW ) # People report that -O3 is unreliable on MinGW. The traditional # build also uses -O2 for that reason: @@ -197,18 +201,8 @@ add_subdirectory(lib/Support) add_subdirectory(lib/TableGen) -set(LLVM_TABLEGEN "tblgen" CACHE - STRING "Native TableGen executable. Saves building one when cross-compiling.") -# Effective tblgen executable to be used: -set(LLVM_TABLEGEN_EXE ${LLVM_TABLEGEN}) - add_subdirectory(utils/TableGen) -if( CMAKE_CROSSCOMPILING ) - # This adds a dependency on target `tblgen', so must go after utils/TableGen - include( CrossCompileLLVM ) -endif( CMAKE_CROSSCOMPILING ) - add_subdirectory(include/llvm) add_subdirectory(lib) Modified: llvm/trunk/Makefile.rules URL: http://llvm.org/viewvc/llvm-project/llvm/trunk/Makefile.rules?rev=141266&r1=141265&r2=141266&view=diff ============================================================================== --- llvm/trunk/Makefile.rules (original) +++ llvm/trunk/Makefile.rules Wed Oct 5 20:51:51 2011 @@ -450,11 +450,11 @@ ifndef LLVMAS LLVMAS := $(LLVMToolDir)/llvm-as$(EXEEXT) endif -ifndef TBLGEN +ifndef LLVM_TBLGEN ifeq ($(LLVM_CROSS_COMPILING),1) - TBLGEN := $(BuildLLVMToolDir)/tblgen$(BUILD_EXEEXT) + LLVM_TBLGEN := $(BuildLLVMToolDir)/llvm-tblgen$(BUILD_EXEEXT) else - TBLGEN := $(LLVMToolDir)/tblgen$(EXEEXT) + LLVM_TBLGEN := $(LLVMToolDir)/llvm-tblgen$(EXEEXT) endif endif LLVM_CONFIG := $(LLVMToolDir)/llvm-config @@ -684,10 +684,11 @@ # When compiling under Mingw/Cygwin, the tblgen tool expects Windows # paths. In this case, the SYSPATH function (defined in # Makefile.config) transforms Unix paths into Windows paths. -TableGen = $(TBLGEN) -I $(call SYSPATH, $(PROJ_SRC_DIR)) \ +TableGen.Flags= -I $(call SYSPATH, $(PROJ_SRC_DIR)) \ -I $(call SYSPATH, $(LLVM_SRC_ROOT)/include) \ -I $(call SYSPATH, $(PROJ_SRC_ROOT)/include) \ -I $(call SYSPATH, $(PROJ_SRC_ROOT)/lib/Target) +LLVMTableGen = $(LLVM_TBLGEN) $(TableGen.Flags) Archive = $(AR) $(AR.Flags) LArchive = $(LLVMToolDir)/llvm-ar rcsf @@ -1700,87 +1701,87 @@ $(LLVM_SRC_ROOT)/include/llvm/CodeGen/ValueTypes.td) \ $(wildcard $(LLVM_SRC_ROOT)/include/llvm/Intrinsics*.td) -# All of these files depend on tblgen and the .td files. -$(INCTMPFiles) : $(TBLGEN) $(TDFiles) +# All .inc.tmp files depend on the .td files. +$(INCTMPFiles) : $(TDFiles) $(TARGET:%=$(ObjDir)/%GenRegisterInfo.inc.tmp): \ -$(ObjDir)/%GenRegisterInfo.inc.tmp : %.td $(ObjDir)/.dir +$(ObjDir)/%GenRegisterInfo.inc.tmp : %.td $(ObjDir)/.dir $(LLVM_TBLGEN) $(Echo) "Building $( Author: evancheng Date: Wed Oct 5 21:47:18 2011 New Revision: 141269 URL: http://llvm.org/viewvc/llvm-project?rev=141269&view=rev Log: Cosmetic change. Modified: llvm/trunk/include/llvm/Target/TargetLowering.h Modified: llvm/trunk/include/llvm/Target/TargetLowering.h URL: http://llvm.org/viewvc/llvm-project/llvm/trunk/include/llvm/Target/TargetLowering.h?rev=141269&r1=141268&r2=141269&view=diff ============================================================================== --- llvm/trunk/include/llvm/Target/TargetLowering.h (original) +++ llvm/trunk/include/llvm/Target/TargetLowering.h Wed Oct 5 21:47:18 2011 @@ -1532,6 +1532,22 @@ /// TODO: Handle pre/postinc as well. virtual bool isLegalAddressingMode(const AddrMode &AM, Type *Ty) const; + /// isLegalICmpImmediate - Return true if the specified immediate is legal + /// icmp immediate, that is the target has icmp instructions which can compare + /// a register against the immediate without having to materialize the + /// immediate into a register. + virtual bool isLegalICmpImmediate(int64_t Imm) const { + return true; + } + + /// isLegalAddImmediate - Return true if the specified immediate is legal + /// add immediate, that is the target has add instructions which can add + /// a register with the immediate without having to materialize the + /// immediate into a register. + virtual bool isLegalAddImmediate(int64_t Imm) const { + return true; + } + /// isTruncateFree - Return true if it's free to truncate a value of /// type Ty1 to type Ty2. e.g. On x86 it's free to truncate a i32 value in /// register EAX to i16 by referencing its sub-register AX. @@ -1566,22 +1582,6 @@ return false; } - /// isLegalICmpImmediate - Return true if the specified immediate is legal - /// icmp immediate, that is the target has icmp instructions which can compare - /// a register against the immediate without having to materialize the - /// immediate into a register. - virtual bool isLegalICmpImmediate(int64_t Imm) const { - return true; - } - - /// isLegalAddImmediate - Return true if the specified immediate is legal - /// add immediate, that is the target has add instructions which can add - /// a register with the immediate without having to materialize the - /// immediate into a register. - virtual bool isLegalAddImmediate(int64_t Imm) const { - return true; - } - //===--------------------------------------------------------------------===// // Div utility functions // From spop at codeaurora.org Wed Oct 5 22:30:35 2011 From: spop at codeaurora.org (Sebastian Pop) Date: Wed, 5 Oct 2011 22:30:35 -0500 Subject: [llvm-commits] [polly] r141212 - in /polly/trunk: utils/checkout_cloog.sh utils/get_cloog.sh www/get_started.html www/menu.html.incl In-Reply-To: <20111005211010.A9C8E312800A@llvm.org> References: <20111005211010.A9C8E312800A@llvm.org> Message-ID: On Wed, Oct 5, 2011 at 4:10 PM, Tobias Grosser wrote: > Added: polly/trunk/utils/checkout_cloog.sh > URL: http://llvm.org/viewvc/llvm-project/polly/trunk/utils/checkout_cloog.sh?rev=141212&view=auto > ============================================================================== > --- polly/trunk/utils/checkout_cloog.sh (added) > +++ polly/trunk/utils/checkout_cloog.sh Wed Oct ?5 16:10:10 2011 > @@ -0,0 +1,86 @@ > +#!/bin/sh > + > +CLOOG_HASH="cloog-0.16.3" > +ISL_HASH="cd1939ed06617d00159e8e51b72a804b467e98b4" > + > +check_command_line() { > + ?if [ "${1}x" = "x" ] || [ "${2}x" != "x" ] To test that the number of parameters is exactly one, you may want to use: if [ $# != 1 ] > > Modified: polly/trunk/www/get_started.html > URL: http://llvm.org/viewvc/llvm-project/polly/trunk/www/get_started.html?rev=141212&r1=141211&r2=141212&view=diff > ============================================================================== > --- polly/trunk/www/get_started.html (original) > +++ polly/trunk/www/get_started.html Wed Oct ?5 16:10:10 2011 > @@ -15,47 +15,69 @@ > > ?

Getting Started: Building and Installing Polly

> > +

Get the code

> + > +The Polly source code is available in the LLVM SVN repository as well as in an > +official a git mirror. It is added to the tools s/official a git/official git/ > +directory of the llvm sources. > +Polly and LLVM need to be checked out at the time. Checkouts s/at the time/at the same time/ > +Polly is tested and works with CLooG as of > +commit 225c2ed62fe37a4db22bf4b95c3731dab1a50dde > +and isl as of > +commit cd1939ed06617d00159e8e51b72a804b467e98b4. To get and install the > +relevant cloog version use the following commands: I guess that you will forget to update the doc page at one point in time. Why not pointing people to look at checkout_cloog.sh to get these sha keys? Sebastian Pop -- Qualcomm Innovation Center, Inc is a member of Code Aurora Forum From craig.topper at gmail.com Thu Oct 6 01:44:42 2011 From: craig.topper at gmail.com (Craig Topper) Date: Thu, 06 Oct 2011 06:44:42 -0000 Subject: [llvm-commits] [llvm] r141274 - in /llvm/trunk: lib/Target/X86/X86InstrInfo.td lib/Target/X86/X86RegisterInfo.td test/MC/X86/x86-32.s test/MC/X86/x86-64.s utils/TableGen/EDEmitter.cpp utils/TableGen/X86RecognizableInstr.cpp Message-ID: <20111006064451.84F482A6C12C@llvm.org> Author: ctopper Date: Thu Oct 6 01:44:41 2011 New Revision: 141274 URL: http://llvm.org/viewvc/llvm-project?rev=141274&view=rev Log: Fix assembling of xchg %eax, %eax to not use the NOP encoding of 0x90. This was done by creating a new register group that excludes AX registers. Fixes PR10345. Also added aliases for flipping the order of the operands of xchg , %eax. Modified: llvm/trunk/lib/Target/X86/X86InstrInfo.td llvm/trunk/lib/Target/X86/X86RegisterInfo.td llvm/trunk/test/MC/X86/x86-32.s llvm/trunk/test/MC/X86/x86-64.s llvm/trunk/utils/TableGen/EDEmitter.cpp llvm/trunk/utils/TableGen/X86RecognizableInstr.cpp Modified: llvm/trunk/lib/Target/X86/X86InstrInfo.td URL: http://llvm.org/viewvc/llvm-project/llvm/trunk/lib/Target/X86/X86InstrInfo.td?rev=141274&r1=141273&r2=141274&view=diff ============================================================================== --- llvm/trunk/lib/Target/X86/X86InstrInfo.td (original) +++ llvm/trunk/lib/Target/X86/X86InstrInfo.td Thu Oct 6 01:44:41 2011 @@ -1154,11 +1154,11 @@ "xchg{q}\t{$val, $src|$src, $val}", []>; } -def XCHG16ar : I<0x90, AddRegFrm, (outs), (ins GR16:$src), +def XCHG16ar : I<0x90, AddRegFrm, (outs), (ins GR16_NOAX:$src), "xchg{w}\t{$src, %ax|AX, $src}", []>, OpSize; -def XCHG32ar : I<0x90, AddRegFrm, (outs), (ins GR32:$src), +def XCHG32ar : I<0x90, AddRegFrm, (outs), (ins GR32_NOAX:$src), "xchg{l}\t{$src, %eax|EAX, $src}", []>; -def XCHG64ar : RI<0x90, AddRegFrm, (outs), (ins GR64:$src), +def XCHG64ar : RI<0x90, AddRegFrm, (outs), (ins GR64_NOAX:$src), "xchg{q}\t{$src, %rax|RAX, $src}", []>; @@ -1714,3 +1714,8 @@ def : InstAlias<"xchgw $mem, $val", (XCHG16rm GR16:$val, i16mem:$mem)>; def : InstAlias<"xchgl $mem, $val", (XCHG32rm GR32:$val, i32mem:$mem)>; def : InstAlias<"xchgq $mem, $val", (XCHG64rm GR64:$val, i64mem:$mem)>; + +// xchg: We accept "xchgX , %eax" and "xchgX %eax, " as synonyms. +def : InstAlias<"xchgw %ax, $src", (XCHG16ar GR16_NOAX:$src)>; +def : InstAlias<"xchgl %eax, $src", (XCHG32ar GR32_NOAX:$src)>; +def : InstAlias<"xchgq %rax, $src", (XCHG64ar GR64_NOAX:$src)>; Modified: llvm/trunk/lib/Target/X86/X86RegisterInfo.td URL: http://llvm.org/viewvc/llvm-project/llvm/trunk/lib/Target/X86/X86RegisterInfo.td?rev=141274&r1=141273&r2=141274&view=diff ============================================================================== --- llvm/trunk/lib/Target/X86/X86RegisterInfo.td (original) +++ llvm/trunk/lib/Target/X86/X86RegisterInfo.td Thu Oct 6 01:44:41 2011 @@ -390,6 +390,23 @@ (GR32_NOREX sub_32bit)]; } +// GR16_NOAX - GR16 registers except AX. +def GR16_NOAX : RegisterClass<"X86", [i16], 16, (sub GR16, AX)> { + let SubRegClasses = [(GR8 sub_8bit, sub_8bit_hi)]; +} + +// GR32_NOAX - GR32 registers except EAX. +def GR32_NOAX : RegisterClass<"X86", [i32], 32, (sub GR32, EAX)> { + let SubRegClasses = [(GR8 sub_8bit, sub_8bit_hi), (GR16_NOAX sub_16bit)]; +} + +// GR64_NOAX - GR64 registers except RAX. +def GR64_NOAX : RegisterClass<"X86", [i64], 64, (sub GR64, RAX)> { + let SubRegClasses = [(GR8 sub_8bit, sub_8bit_hi), + (GR16_NOAX sub_16bit), + (GR32_NOAX sub_32bit)]; +} + // GR32_NOSP - GR32 registers except ESP. def GR32_NOSP : RegisterClass<"X86", [i32], 32, (sub GR32, ESP)> { let SubRegClasses = [(GR8 sub_8bit, sub_8bit_hi), (GR16 sub_16bit)]; Modified: llvm/trunk/test/MC/X86/x86-32.s URL: http://llvm.org/viewvc/llvm-project/llvm/trunk/test/MC/X86/x86-32.s?rev=141274&r1=141273&r2=141274&view=diff ============================================================================== --- llvm/trunk/test/MC/X86/x86-32.s (original) +++ llvm/trunk/test/MC/X86/x86-32.s Thu Oct 6 01:44:41 2011 @@ -946,3 +946,19 @@ // CHECK: encoding: [0xde,0xe2] fsubp %st, %st(2) +// PR10345 +// CHECK: xchgl %eax, %eax +// CHECK: encoding: [0x87,0xc0] +xchgl %eax, %eax + +// CHECK: xchgw %ax, %ax +// CHECK: encoding: [0x66,0x87,0xc0] +xchgw %ax, %ax + +// CHECK: xchgl %ecx, %eax +// CHECK: encoding: [0x91] +xchgl %ecx, %eax + +// CHECK: xchgl %ecx, %eax +// CHECK: encoding: [0x91] +xchgl %eax, %ecx Modified: llvm/trunk/test/MC/X86/x86-64.s URL: http://llvm.org/viewvc/llvm-project/llvm/trunk/test/MC/X86/x86-64.s?rev=141274&r1=141273&r2=141274&view=diff ============================================================================== --- llvm/trunk/test/MC/X86/x86-64.s (original) +++ llvm/trunk/test/MC/X86/x86-64.s Thu Oct 6 01:44:41 2011 @@ -1170,3 +1170,24 @@ // CHECK: pclmulqdq $0, (%rdi), %xmm1 // CHECK: encoding: [0x66,0x0f,0x3a,0x44,0x0f,0x00] pclmulqdq $0, (%rdi), %xmm1 + +// PR10345 +// CHECK: xchgq %rax, %rax +// CHECK: encoding: [0x48,0x87,0xc0] +xchgq %rax, %rax + +// CHECK: xchgl %eax, %eax +// CHECK: encoding: [0x87,0xc0] +xchgl %eax, %eax + +// CHECK: xchgw %ax, %ax +// CHECK: encoding: [0x66,0x87,0xc0] +xchgw %ax, %ax + +// CHECK: xchgl %ecx, %eax +// CHECK: encoding: [0x91] +xchgl %ecx, %eax + +// CHECK: xchgl %ecx, %eax +// CHECK: encoding: [0x91] +xchgl %eax, %ecx Modified: llvm/trunk/utils/TableGen/EDEmitter.cpp URL: http://llvm.org/viewvc/llvm-project/llvm/trunk/utils/TableGen/EDEmitter.cpp?rev=141274&r1=141273&r2=141274&view=diff ============================================================================== --- llvm/trunk/utils/TableGen/EDEmitter.cpp (original) +++ llvm/trunk/utils/TableGen/EDEmitter.cpp Thu Oct 6 01:44:41 2011 @@ -256,12 +256,15 @@ REG("GR8"); REG("GR8_NOREX"); REG("GR16"); + REG("GR16_NOAX"); REG("GR32"); + REG("GR32_NOAX"); REG("GR32_NOREX"); REG("GR32_TC"); REG("FR32"); REG("RFP32"); REG("GR64"); + REG("GR64_NOAX"); REG("GR64_TC"); REG("FR64"); REG("VR64"); Modified: llvm/trunk/utils/TableGen/X86RecognizableInstr.cpp URL: http://llvm.org/viewvc/llvm-project/llvm/trunk/utils/TableGen/X86RecognizableInstr.cpp?rev=141274&r1=141273&r2=141274&view=diff ============================================================================== --- llvm/trunk/utils/TableGen/X86RecognizableInstr.cpp (original) +++ llvm/trunk/utils/TableGen/X86RecognizableInstr.cpp Thu Oct 6 01:44:41 2011 @@ -1064,6 +1064,9 @@ TYPE("offset32", TYPE_MOFFS32) TYPE("offset64", TYPE_MOFFS64) TYPE("VR256", TYPE_XMM256) + TYPE("GR16_NOAX", TYPE_Rv) + TYPE("GR32_NOAX", TYPE_Rv) + TYPE("GR64_NOAX", TYPE_R64) errs() << "Unhandled type string " << s << "\n"; llvm_unreachable("Unhandled type string"); } @@ -1205,6 +1208,9 @@ ENCODING("GR64", ENCODING_RO) ENCODING("GR16", ENCODING_Rv) ENCODING("GR8", ENCODING_RB) + ENCODING("GR16_NOAX", ENCODING_Rv) + ENCODING("GR32_NOAX", ENCODING_Rv) + ENCODING("GR64_NOAX", ENCODING_RO) errs() << "Unhandled opcode modifier encoding " << s << "\n"; llvm_unreachable("Unhandled opcode modifier encoding"); } From grosser at fim.uni-passau.de Thu Oct 6 01:53:21 2011 From: grosser at fim.uni-passau.de (Tobias Grosser) Date: Thu, 06 Oct 2011 06:53:21 -0000 Subject: [llvm-commits] [polly] r141275 - in /polly/trunk: utils/checkout_cloog.sh www/get_started.html Message-ID: <20111006065321.704182A6C12C@llvm.org> Author: grosser Date: Thu Oct 6 01:53:17 2011 New Revision: 141275 URL: http://llvm.org/viewvc/llvm-project?rev=141275&view=rev Log: Address Sebastians comments This also adds some other cleanups I performed on my way. Modified: polly/trunk/utils/checkout_cloog.sh polly/trunk/www/get_started.html Modified: polly/trunk/utils/checkout_cloog.sh URL: http://llvm.org/viewvc/llvm-project/polly/trunk/utils/checkout_cloog.sh?rev=141275&r1=141274&r2=141275&view=diff ============================================================================== --- polly/trunk/utils/checkout_cloog.sh (original) +++ polly/trunk/utils/checkout_cloog.sh Thu Oct 6 01:53:17 2011 @@ -1,14 +1,17 @@ #!/bin/sh -cloog_hash="0c252c88946b27b7b61a1a8d8fd7f94d2461dbfd" -isl_hash="56b7d238929980e62218525b4b3be121af386edf" +CLOOG_HASH="0c252c88946b27b7b61a1a8d8fd7f94d2461dbfd" +ISL_HASH="56b7d238929980e62218525b4b3be121af386edf" + +PWD=`pwd` check_command_line() { - if [ "${1}x" = "x" ] || [ "${2}x" != "x" ] + if [ $# -eq 1 ] then - echo "Usage: " ${0} '' - else CLOOG_DIR="${1}" + else + echo "Usage: " ${0} '' + exit 1 fi } @@ -27,15 +30,14 @@ exit 1 fi + # Make it absolute + cd ${CLOOG_DIR} + CLOOG_DIR=`pwd` + if ! [ -e "${CLOOG_DIR}/.git" ] then - IS_GIT=0 echo ":: No git checkout found" - if [ `ls -A ${CLOOG_DIR}` ] - then - echo but directory "'${CLOOG_DIR}'" contains files - exit 1 - fi + IS_GIT=0 else echo ":: Existing git repo found" IS_GIT=1 @@ -58,27 +60,31 @@ check_command_line $@ check_cloog_directory -cd ${CLOOG_DIR} - - - +ISL_DIR=${CLOOG_DIR}/isl if [ ${IS_GIT} -eq 0 ] then echo :: Performing initial checkout - run git clone http://repo.or.cz/r/cloog.git . - run git clone http://repo.or.cz/r/isl.git isl + run git clone http://repo.or.cz/r/cloog.git ${CLOOG_DIR} + run git clone http://repo.or.cz/r/isl.git ${ISL_DIR} fi echo :: Fetch versions required by Polly +run cd ${CLOOG_DIR} run git remote update -run git reset --hard "${CLOOG_HASH}" run cd isl run git remote update + +echo :: Setting CLooG version +run cd ${CLOOG_DIR} +run git reset --hard "${CLOOG_HASH}" + +echo :: Setting isl version +run cd ${ISL_DIR} run git reset --hard "${ISL_HASH}" -run cd .. echo :: Generating configure +run cd ${CLOOG_DIR} run ./autogen.sh echo :: If you install cloog/isl the first time run "'./configure'" followed by Modified: polly/trunk/www/get_started.html URL: http://llvm.org/viewvc/llvm-project/polly/trunk/www/get_started.html?rev=141275&r1=141274&r2=141275&view=diff ============================================================================== --- polly/trunk/www/get_started.html (original) +++ polly/trunk/www/get_started.html Thu Oct 6 01:53:17 2011 @@ -17,10 +17,10 @@

Get the code

-The Polly source code is available in the LLVM SVN repository as well as in an -official a git mirror. It is added to the tools +The Polly source code is available in the LLVM SVN repository as well as through +an official git mirror. It is added to the tools directory of the llvm sources. -Polly and LLVM need to be checked out at the time. Checkouts +Polly and LLVM need to be checked out at the same time. Checkouts from different dates may not work!

Set the directory layout:

@@ -52,11 +52,9 @@
 
 

CLooG/isl

-Polly is tested and works with CLooG as of -commit 0c252c88946b27b7b61a1a8d8fd7f94d2461dbfd -and isl as of -commit 56b7d238929980e62218525b4b3be121af386edf. To get and install the -relevant cloog version use the following commands: +Polly is tested with a fixed version of CLooG +and isl. To obtain the source code of CLooG (including isl) use +checkout_cloog.sh as available in ${POLLY_SRC}/utils/checkout_cloog.sh.

Set the directory layout:




From grosser at fim.uni-passau.de  Thu Oct  6 02:00:38 2011
From: grosser at fim.uni-passau.de (Tobias Grosser)
Date: Thu, 06 Oct 2011 08:00:38 +0100
Subject: [llvm-commits] [polly] r141212 - in /polly/trunk:
 utils/checkout_cloog.sh utils/get_cloog.sh www/get_started.html
 www/menu.html.incl
In-Reply-To: 
References: <20111005211010.A9C8E312800A@llvm.org>
	
Message-ID: <4E8D5216.6080209@fim.uni-passau.de>

Hi Sebastian,

thanks for reviewing.

On 10/06/2011 04:30 AM, Sebastian Pop wrote:
> On Wed, Oct 5, 2011 at 4:10 PM, Tobias Grosser
>   wrote:
>> Added: polly/trunk/utils/checkout_cloog.sh
>> URL: http://llvm.org/viewvc/llvm-project/polly/trunk/utils/checkout_cloog.sh?rev=141212&view=auto
>> ==============================================================================
>> --- polly/trunk/utils/checkout_cloog.sh (added)
>> +++ polly/trunk/utils/checkout_cloog.sh Wed Oct  5 16:10:10 2011
>> @@ -0,0 +1,86 @@
>> +#!/bin/sh
>> +
>> +CLOOG_HASH="cloog-0.16.3"
>> +ISL_HASH="cd1939ed06617d00159e8e51b72a804b467e98b4"
>> +
>> +check_command_line() {
>> +  if [ "${1}x" = "x" ] || [ "${2}x" != "x" ]
>
> To test that the number of parameters is exactly one, you may want to
> use:
>
>      if [ $# != 1 ]
Fixed.

>>
>> Modified: polly/trunk/www/get_started.html
>> URL: http://llvm.org/viewvc/llvm-project/polly/trunk/www/get_started.html?rev=141212&r1=141211&r2=141212&view=diff
>> ==============================================================================
>> --- polly/trunk/www/get_started.html (original)
>> +++ polly/trunk/www/get_started.html Wed Oct  5 16:10:10 2011
>> @@ -15,47 +15,69 @@
>>
>>   

Getting Started: Building and Installing Polly

>> >> +

Get the code

>> + >> +The Polly source code is available in the LLVM SVN repository as well as in an >> +official a git mirror. It is added to thetools > > s/official a git/official git/ > >> +directory of the llvm sources. >> +Polly and LLVM need to be checked out at the time. Checkouts > > s/at the time/at the same time/ OK. > >> +Polly is tested and works withCLooG as of >> +commit 225c2ed62fe37a4db22bf4b95c3731dab1a50dde >> +andisl as of >> +commit cd1939ed06617d00159e8e51b72a804b467e98b4. To get and install the >> +relevant cloog version use the following commands: > > I guess that you will forget to update the doc page at one point in > time. Why not pointing people to look at checkout_cloog.sh to get > these sha keys? You are right. I removed them here entirely and print them in checkout_cloog.sh. Interested users who do not want to run the script can lso find them at the top of the script source. Thanks again for reviewing. Tobi P.S.: I also fixed some more bugs that blocked the buildbot. From James.Molloy at arm.com Thu Oct 6 02:04:04 2011 From: James.Molloy at arm.com (James Molloy) Date: Thu, 6 Oct 2011 08:04:04 +0100 Subject: [llvm-commits] [llvm] r141231 - in /llvm/trunk/lib/TableGen: TGLexer.cpp TGLexer.h In-Reply-To: <20111005224242.AFEF72A6C12C@llvm.org> References: <20111005224242.AFEF72A6C12C@llvm.org> Message-ID: Hi David, --- llvm/trunk/lib/TableGen/TGLexer.cpp (original) +++ llvm/trunk/lib/TableGen/TGLexer.cpp Wed Oct 5 17:42:35 2011 @@ -228,6 +228,7 @@ if (Len == 5 && !memcmp(IdentStart, "class", 5)) return tgtok::Class; if (Len == 3 && !memcmp(IdentStart, "def", 3)) return tgtok::Def; + if (Len == 8 && !memcmp(IdentStart, "multidef", 3)) return tgtok::MultiDef; if (Len == 4 && !memcmp(IdentStart, "defm", 4)) return tgtok::Defm; if (Len == 10 && !memcmp(IdentStart, "multiclass", 10)) return tgtok::MultiClass; That doesn't look right, it looks like a copy-paste error. Would '8' not make more sense in the third parameter to memcmp? Cheers, James -----Original Message----- From: llvm-commits-bounces at cs.uiuc.edu [mailto:llvm-commits-bounces at cs.uiuc.edu] On Behalf Of David Greene Sent: 05 October 2011 23:43 To: llvm-commits at cs.uiuc.edu Subject: [llvm-commits] [llvm] r141231 - in /llvm/trunk/lib/TableGen: TGLexer.cpp TGLexer.h Author: greened Date: Wed Oct 5 17:42:35 2011 New Revision: 141231 URL: http://llvm.org/viewvc/llvm-project?rev=141231&view=rev Log: Lexer Support for Multidefs Add keyword support for multidefs. Modified: llvm/trunk/lib/TableGen/TGLexer.cpp llvm/trunk/lib/TableGen/TGLexer.h Modified: llvm/trunk/lib/TableGen/TGLexer.cpp URL: http://llvm.org/viewvc/llvm-project/llvm/trunk/lib/TableGen/TGLexer.cpp?rev=141231&r1=141230&r2=141231&view=diff ============================================================================== --- llvm/trunk/lib/TableGen/TGLexer.cpp (original) +++ llvm/trunk/lib/TableGen/TGLexer.cpp Wed Oct 5 17:42:35 2011 @@ -228,6 +228,7 @@ if (Len == 5 && !memcmp(IdentStart, "class", 5)) return tgtok::Class; if (Len == 3 && !memcmp(IdentStart, "def", 3)) return tgtok::Def; + if (Len == 8 && !memcmp(IdentStart, "multidef", 3)) return tgtok::MultiDef; if (Len == 4 && !memcmp(IdentStart, "defm", 4)) return tgtok::Defm; if (Len == 10 && !memcmp(IdentStart, "multiclass", 10)) return tgtok::MultiClass; Modified: llvm/trunk/lib/TableGen/TGLexer.h URL: http://llvm.org/viewvc/llvm-project/llvm/trunk/lib/TableGen/TGLexer.h?rev=141231&r1=141230&r2=141231&view=diff ============================================================================== --- llvm/trunk/lib/TableGen/TGLexer.h (original) +++ llvm/trunk/lib/TableGen/TGLexer.h Wed Oct 5 17:42:35 2011 @@ -41,7 +41,7 @@ equal, question, // = ? // Keywords. - Bit, Bits, Class, Code, Dag, Def, Defm, Field, In, Int, Let, List, + Bit, Bits, Class, Code, Dag, Def, MultiDef, Defm, Field, In, Int, Let, List, MultiClass, String, // !keywords. _______________________________________________ llvm-commits mailing list llvm-commits at cs.uiuc.edu http://lists.cs.uiuc.edu/mailman/listinfo/llvm-commits -- IMPORTANT NOTICE: The contents of this email and any attachments are confidential and may also be privileged. If you are not the intended recipient, please notify the sender immediately and do not disclose the contents to any other person, use it for any purpose, or store or copy the information in any medium. Thank you. From baldrick at free.fr Thu Oct 6 03:33:23 2011 From: baldrick at free.fr (Duncan Sands) Date: Thu, 06 Oct 2011 10:33:23 +0200 Subject: [llvm-commits] [llvm] r141219 - /llvm/trunk/lib/Analysis/ScalarEvolution.cpp In-Reply-To: <20111005220654.6CF752A6C12C@llvm.org> References: <20111005220654.6CF752A6C12C@llvm.org> Message-ID: <4E8D67D3.3070908@free.fr> Hi Andrew, > Fixes PR11070 - assert in SCEV getConstantEvolvingPHIOperands. testcase? Ciao, Duncan. From baldrick at free.fr Thu Oct 6 04:21:50 2011 From: baldrick at free.fr (Duncan Sands) Date: Thu, 06 Oct 2011 09:21:50 -0000 Subject: [llvm-commits] [dragonegg] r141280 - /dragonegg/trunk/src/Types.cpp Message-ID: <20111006092150.D8DAC2A6C12D@llvm.org> Author: baldrick Date: Thu Oct 6 04:21:48 2011 New Revision: 141280 URL: http://llvm.org/viewvc/llvm-project?rev=141280&view=rev Log: Hook up the returns_twice attribute to GCC's ECF_RETURNS_TWICE. While there, rearrange existing code and comments a bit. Modified: dragonegg/trunk/src/Types.cpp Modified: dragonegg/trunk/src/Types.cpp URL: http://llvm.org/viewvc/llvm-project/dragonegg/trunk/src/Types.cpp?rev=141280&r1=141279&r2=141280&view=diff ============================================================================== --- dragonegg/trunk/src/Types.cpp (original) +++ dragonegg/trunk/src/Types.cpp Thu Oct 6 04:21:48 2011 @@ -737,6 +737,14 @@ int flags = flags_from_decl_or_type(decl ? decl : type); + // Check for 'readnone' and 'readonly' function attributes. + if (flags & ECF_CONST) + FnAttributes |= Attribute::ReadNone; + else if (flags & ECF_PURE) + FnAttributes |= Attribute::ReadOnly; + + // TODO: Handle ECF_LOOPING_CONST_OR_PURE + // Check for 'noreturn' function attribute. if (flags & ECF_NORETURN) FnAttributes |= Attribute::NoReturn; @@ -745,20 +753,9 @@ if (flags & ECF_NOTHROW) FnAttributes |= Attribute::NoUnwind; - // Check for 'readnone' function attribute. - // Both PURE and CONST will be set if the user applied - // __attribute__((const)) to a function the compiler - // knows to be pure, such as log. A user or (more - // likely) libm implementor might know their local log - // is in fact const, so this should be valid (and gcc - // accepts it). But llvm IR does not allow both, so - // set only ReadNone. - if (flags & ECF_CONST) - FnAttributes |= Attribute::ReadNone; - - // Check for 'readonly' function attribute. - if (flags & ECF_PURE && !(flags & ECF_CONST)) - FnAttributes |= Attribute::ReadOnly; + // Check for 'returnstwice' function attribute. + if (flags & ECF_RETURNS_TWICE) + FnAttributes |= Attribute::ReturnsTwice; // Since they write the return value through a pointer, // 'sret' functions cannot be 'readnone' or 'readonly'. From edwintorok at gmail.com Thu Oct 6 05:52:00 2011 From: edwintorok at gmail.com (=?ISO-8859-1?Q?T=F6r=F6k_Edwin?=) Date: Thu, 06 Oct 2011 13:52:00 +0300 Subject: [llvm-commits] [llvm] r141234 - /llvm/trunk/test/TableGen/MultiDef.td In-Reply-To: <20111005224247.4D6262A6C12C@llvm.org> References: <20111005224247.4D6262A6C12C@llvm.org> Message-ID: <4E8D8850.5030409@gmail.com> On 2011-10-06 01:42, David Greene wrote: > Author: greened > Date: Wed Oct 5 17:42:47 2011 > New Revision: 141234 > > URL: http://llvm.org/viewvc/llvm-project?rev=141234&view=rev > Log: > Add a Multidef Test > > Add a simple test for multidefs. SVN r141274 make check fails. Is there something wrong with my build env? Failing Tests (2): LLVM :: TableGen/MultiDef.td LLVM :: TableGen/MultiPat.td tblgen: /home/edwin/HDD/edwin/llvm-git/llvm/lib/TableGen/Record.cpp:1336: virtual llvm::Init* llvm::VarInit::resolveListElementReference(llvm::Record&, const llvm::RecordVal*, unsigned int) const: Assertion `VI && "Invalid list element!"' failed. 0 tblgen 0x000000000057432f 1 tblgen 0x0000000000574819 2 libpthread.so.0 0x0000003585e0f020 3 libc.so.6 0x0000003585232405 gsignal + 53 4 libc.so.6 0x0000003585235680 abort + 384 5 libc.so.6 0x000000358522b5b1 __assert_fail + 241 6 tblgen 0x000000000054109f 7 tblgen 0x00000000005337e1 8 tblgen 0x000000000053a396 9 tblgen 0x000000000054cd87 10 tblgen 0x0000000000553a4c 11 tblgen 0x0000000000553cdb 12 tblgen 0x0000000000555a75 13 tblgen 0x0000000000555af3 14 tblgen 0x0000000000555b2a 15 tblgen 0x0000000000531757 16 tblgen 0x000000000040a220 17 libc.so.6 0x000000358521eead __libc_start_main + 253 18 tblgen 0x000000000040ba1d Stack dump: 0. Program arguments: /home/edwin/HDD/edwin/llvm-git/build/Release+Asserts/bin/tblgen /home/edwin/HDD/edwin/llvm-git/llvm/test/TableGen/MultiPat.td FileCheck error: '-' is empty. -- ******************** FAIL: LLVM :: TableGen/MultiDef.td (3881 of 5637) ******************** TEST 'LLVM :: TableGen/MultiDef.td' FAILED ******************** Script: -- /home/edwin/HDD/edwin/llvm-git/build/Release+Asserts/bin/tblgen /home/edwin/HDD/edwin/llvm-git/llvm/test/TableGen/MultiDef.td | /home/edwin/HDD/edwin/llvm-git/build/Release+Asserts/bin/FileCheck /home/edwin/HDD/edwin/llvm-git/llvm/test/TableGen/MultiDef.td /home/edwin/HDD/edwin/llvm-git/build/Release+Asserts/bin/tblgen /home/edwin/HDD/edwin/llvm-git/llvm/test/TableGen/MultiDef.td | /home/edwin/HDD/edwin/llvm-git/build/Release+Asserts/bin/FileCheck /home/edwin/HDD/edwin/llvm-git/llvm/test/TableGen/MultiDef.td -- Exit Code: 1 Command Output (stderr): -- /home/edwin/HDD/edwin/llvm-git/llvm/test/TableGen/MultiDef.td:12:3: error: expected 'let', 'def' or 'defm' in multiclass body multidef COUNT : Base; ^ FileCheck error: '-' is empty. Best regards, --Edwin From edwintorok at gmail.com Thu Oct 6 07:13:39 2011 From: edwintorok at gmail.com (=?ISO-8859-1?Q?T=F6r=F6k_Edwin?=) Date: Thu, 06 Oct 2011 15:13:39 +0300 Subject: [llvm-commits] Fix opcodes in C bindings In-Reply-To: <4E89BAF3.2040905@gmail.com> References: <4E89BAF3.2040905@gmail.com> Message-ID: <4E8D9B73.90507@gmail.com> On 2011-10-03 16:38, T?r?k Edwin wrote: > Hi, > > LLVMOpcode is out of sync with getOpcode() right now (was ok in 2.9 AFAICT). > > Attached patch introduces a function to map between Instruction::* opcodes and the opcodes declared in llvm-c/Core.h. > It does that by using the macros in Instruction.def, so that it will always be up-to-date as internal opcodes change. > When a new opcode is introduced you'll get a compile error in Core.cpp and will have to add it to llvm-c/Core.h > as well (at the end of the other opcodes). This way the C API opcodes can't get out-of-sync. > > The 2nd patch adds an LLVMGetInstructionOpcode to the C API, to allow it to inspect, not just create instructions. Ping? Best regards, --Edwin From edwintorok at gmail.com Thu Oct 6 07:12:16 2011 From: edwintorok at gmail.com (Torok Edwin) Date: Thu, 06 Oct 2011 12:12:16 -0000 Subject: [llvm-commits] [llvm] r141283 - /llvm/trunk/test/Bindings/Ocaml/vmcore.ml Message-ID: <20111006121217.688D02A6C12C@llvm.org> Author: edwin Date: Thu Oct 6 07:12:12 2011 New Revision: 141283 URL: http://llvm.org/viewvc/llvm-project?rev=141283&view=rev Log: add more tests for the OCaml bindings Modified: llvm/trunk/test/Bindings/Ocaml/vmcore.ml Modified: llvm/trunk/test/Bindings/Ocaml/vmcore.ml URL: http://llvm.org/viewvc/llvm-project/llvm/trunk/test/Bindings/Ocaml/vmcore.ml?rev=141283&r1=141282&r2=141283&view=diff ============================================================================== --- llvm/trunk/test/Bindings/Ocaml/vmcore.ml (original) +++ llvm/trunk/test/Bindings/Ocaml/vmcore.ml Thu Oct 6 07:12:12 2011 @@ -822,6 +822,18 @@ let b = builder_at_end context (append_block context "Bb01" fn) in ignore (build_ret_void b) end; + + group "ret aggregate"; + begin + (* RUN: grep {ret \{ i8, i64 \} \{ i8 4, i64 5 \}} < %t.ll + *) + let sty = struct_type context [| i8_type; i64_type |] in + let fty = function_type sty [| |] in + let fn = declare_function "XA6" fty m in + let b = builder_at_end context (append_block context "Bb01" fn) in + let agg = [| const_int i8_type 4; const_int i64_type 5 |] in + ignore (build_aggregate_ret agg b) + end; (* The rest of the tests will use one big function. *) let fty = function_type i32_type [| i32_type; i32_type |] in @@ -835,14 +847,26 @@ let bb00 = append_block context "Bb00" fn in ignore (build_unreachable (builder_at_end context bb00)); + (* see test/Feature/exception.ll *) let bblpad = append_block context "Bblpad" fn in let rt = struct_type context [| pointer_type i8_type; i32_type |] in let ft = var_arg_function_type i32_type [||] in - let personality = declare_function "__gxx_personality_v0" ft m in begin + let personality = declare_function "__gxx_personality_v0" ft m in + let ztic = declare_global (pointer_type i8_type) "_ZTIc" m in + let ztid = declare_global (pointer_type i8_type) "_ZTId" m in + let ztipkc = declare_global (pointer_type i8_type) "_ZTIPKc" m in + begin + set_global_constant true ztic; + set_global_constant true ztid; + set_global_constant true ztipkc; let lp = build_landingpad rt personality 0 "lpad" - (builder_at_end context bblpad) in - set_cleanup lp true; - ignore (build_unreachable (builder_at_end context bblpad)); + (builder_at_end context bblpad) in begin + set_cleanup lp true; + ignore (build_unreachable (builder_at_end context bblpad)); + end; + (* RUN: grep "landingpad.*personality.*__gxx_personality_v0" < %t.ll + * RUN: grep "cleanup" < %t.ll + * *) end; group "ret"; begin @@ -878,8 +902,9 @@ ignore (build_unreachable (builder_at_end context bb2)); let bb3 = append_block context "SwiBlock3" fn in ignore (build_unreachable (builder_at_end context bb3)); - let si = build_switch p1 bb3 1 (builder_at_end context bb1) in - ignore (add_case si (const_int i32_type 2) bb2) + let si = build_switch p1 bb3 1 (builder_at_end context bb1) in begin + ignore (add_case si (const_int i32_type 2) bb2); + end; end; group "indirectbr"; begin @@ -993,30 +1018,63 @@ * RUN: grep {%build_load = load i32\\* %build_array_alloca} < %t.ll * RUN: grep {store i32 %P2, i32\\* %build_alloca} < %t.ll * RUN: grep {%build_gep = getelementptr i32\\* %build_array_alloca, i32 %P2} < %t.ll + * RUN: grep {%build_in_bounds_gep = getelementptr inbounds i32\\* %build_array_alloca, i32 %P2} < %t.ll + * RUN: grep {%build_struct_gep = getelementptr inbounds.*%build_alloca2, i32 0, i32 1} < %t.ll *) let alloca = build_alloca i32_type "build_alloca" b in let array_alloca = build_array_alloca i32_type p2 "build_array_alloca" b in ignore(build_load array_alloca "build_load" b); ignore(build_store p2 alloca b); ignore(build_gep array_alloca [| p2 |] "build_gep" b); + ignore(build_in_bounds_gep array_alloca [| p2 |] "build_in_bounds_gep" b); + + let sty = struct_type context [| i32_type; i8_type |] in + let alloca2 = build_alloca sty "build_alloca2" b in + ignore(build_struct_gep alloca2 1 "build_struct_gep" b); + ignore(build_unreachable b) end; - + + group "string"; begin + let bb09 = append_block context "Bb09" fn in + let b = builder_at_end context bb09 in + let p = build_alloca (pointer_type i8_type) "p" b in + (* RUN: grep "build_global_string.*stringval" < %t.ll + * RUN: grep "store.*build_global_string1.*p" < %t.ll + * *) + ignore (build_global_string "stringval" "build_global_string" b); + let g = build_global_stringptr "stringval" "build_global_string1" b in + ignore (build_store g p b); + ignore(build_unreachable b); + end; + group "casts"; begin let void_ptr = pointer_type i8_type in (* RUN: grep {%build_trunc = trunc i32 %P1 to i8} < %t.ll + * RUN: grep {%build_trunc2 = trunc i32 %P1 to i8} < %t.ll + * RUN: grep {%build_trunc3 = trunc i32 %P1 to i8} < %t.ll * RUN: grep {%build_zext = zext i8 %build_trunc to i32} < %t.ll + * RUN: grep {%build_zext2 = zext i8 %build_trunc to i32} < %t.ll * RUN: grep {%build_sext = sext i32 %build_zext to i64} < %t.ll + * RUN: grep {%build_sext2 = sext i32 %build_zext to i64} < %t.ll + * RUN: grep {%build_sext3 = sext i32 %build_zext to i64} < %t.ll * RUN: grep {%build_uitofp = uitofp i64 %build_sext to float} < %t.ll * RUN: grep {%build_sitofp = sitofp i32 %build_zext to double} < %t.ll * RUN: grep {%build_fptoui = fptoui float %build_uitofp to i32} < %t.ll * RUN: grep {%build_fptosi = fptosi double %build_sitofp to i64} < %t.ll * RUN: grep {%build_fptrunc = fptrunc double %build_sitofp to float} < %t.ll + * RUN: grep {%build_fptrunc2 = fptrunc double %build_sitofp to float} < %t.ll * RUN: grep {%build_fpext = fpext float %build_fptrunc to double} < %t.ll + * RUN: grep {%build_fpext2 = fpext float %build_fptrunc to double} < %t.ll * RUN: grep {%build_inttoptr = inttoptr i32 %P1 to i8\\*} < %t.ll * RUN: grep {%build_ptrtoint = ptrtoint i8\\* %build_inttoptr to i64} < %t.ll + * RUN: grep {%build_ptrtoint2 = ptrtoint i8\\* %build_inttoptr to i64} < %t.ll * RUN: grep {%build_bitcast = bitcast i64 %build_ptrtoint to double} < %t.ll + * RUN: grep {%build_bitcast2 = bitcast i64 %build_ptrtoint to double} < %t.ll + * RUN: grep {%build_bitcast3 = bitcast i64 %build_ptrtoint to double} < %t.ll + * RUN: grep {%build_bitcast4 = bitcast i64 %build_ptrtoint to double} < %t.ll + * RUN: grep {%build_pointercast = bitcast i8\\* %build_inttoptr to i16\\*} < %t.ll *) let inst28 = build_trunc p1 i8_type "build_trunc" atentry in let inst29 = build_zext inst28 i32_type "build_zext" atentry in @@ -1029,7 +1087,20 @@ ignore(build_fpext inst35 double_type "build_fpext" atentry); let inst37 = build_inttoptr p1 void_ptr "build_inttoptr" atentry in let inst38 = build_ptrtoint inst37 i64_type "build_ptrtoint" atentry in - ignore(build_bitcast inst38 double_type "build_bitcast" atentry) + ignore(build_bitcast inst38 double_type "build_bitcast" atentry); + ignore(build_zext_or_bitcast inst38 double_type "build_bitcast2" atentry); + ignore(build_sext_or_bitcast inst38 double_type "build_bitcast3" atentry); + ignore(build_trunc_or_bitcast inst38 double_type "build_bitcast4" atentry); + ignore(build_pointercast inst37 (pointer_type i16_type) "build_pointercast" atentry); + + ignore(build_zext_or_bitcast inst28 i32_type "build_zext2" atentry); + ignore(build_sext_or_bitcast inst29 i64_type "build_sext2" atentry); + ignore(build_trunc_or_bitcast p1 i8_type "build_trunc2" atentry); + ignore(build_pointercast inst37 i64_type "build_ptrtoint2" atentry); + ignore(build_intcast inst29 i64_type "build_sext3" atentry); + ignore(build_intcast p1 i8_type "build_trunc3" atentry); + ignore(build_fpcast inst35 double_type "build_fpext2" atentry); + ignore(build_fpcast inst32 float_type "build_fptrunc2" atentry); end; group "comparisons"; begin @@ -1037,11 +1108,21 @@ * RUN: grep {%build_icmp_sle = icmp sle i32 %P2, %P1} < %t.ll * RUN: grep {%build_fcmp_false = fcmp false float %F1, %F2} < %t.ll * RUN: grep {%build_fcmp_true = fcmp true float %F2, %F1} < %t.ll + * RUN: grep {%build_is_null.*= icmp eq.*%X0,.*null} < %t.ll + * RUN: grep {%build_is_not_null = icmp ne i8\\* %X1, null} < %t.ll + * RUN: grep {%build_ptrdiff} < %t.ll *) ignore (build_icmp Icmp.Ne p1 p2 "build_icmp_ne" atentry); ignore (build_icmp Icmp.Sle p2 p1 "build_icmp_sle" atentry); ignore (build_fcmp Fcmp.False f1 f2 "build_fcmp_false" atentry); - ignore (build_fcmp Fcmp.True f2 f1 "build_fcmp_true" atentry) + ignore (build_fcmp Fcmp.True f2 f1 "build_fcmp_true" atentry); + let g0 = declare_global (pointer_type i8_type) "g0" m in + let g1 = declare_global (pointer_type i8_type) "g1" m in + let p0 = build_load g0 "X0" atentry in + let p1 = build_load g1 "X1" atentry in + ignore (build_is_null p0 "build_is_null" atentry); + ignore (build_is_not_null p1 "build_is_not_null" atentry); + ignore (build_ptrdiff p1 p0 "build_ptrdiff" atentry); end; group "miscellaneous"; begin @@ -1051,6 +1132,8 @@ * RUN: grep {%build_extractelement = extractelement <4 x i32> %Vec1, i32 %P2} < %t.ll * RUN: grep {%build_insertelement = insertelement <4 x i32> %Vec1, i32 %P1, i32 %P2} < %t.ll * RUN: grep {%build_shufflevector = shufflevector <4 x i32> %Vec1, <4 x i32> %Vec2, <4 x i32> } < %t.ll + * RUN: grep {%build_insertvalue0 = insertvalue.*%bl, i32 1, 0} < %t.ll + * RUN: grep {%build_extractvalue = extractvalue.*%build_insertvalue1, 1} < %t.ll *) let ci = build_call fn [| p2; p1 |] "build_call" atentry in insist (CallConv.c = instruction_call_conv ci); @@ -1077,10 +1160,19 @@ let t3 = const_vector [| one; one; zero; zero |] in let vec1 = build_insertelement t1 p1 p2 "Vec1" atentry in let vec2 = build_insertelement t2 p1 p2 "Vec2" atentry in + let sty = struct_type context [| i32_type; i8_type |] in ignore (build_extractelement vec1 p2 "build_extractelement" atentry); ignore (build_insertelement vec1 p1 p2 "build_insertelement" atentry); ignore (build_shufflevector vec1 vec2 t3 "build_shufflevector" atentry); + + let p = build_alloca sty "ba" atentry in + let agg = build_load p "bl" atentry in + let agg0 = build_insertvalue agg (const_int i32_type 1) 0 + "build_insertvalue0" atentry in + let agg1 = build_insertvalue agg0 (const_int i8_type 2) 1 + "build_insertvalue1" atentry in + ignore (build_extractvalue agg1 1 "build_extractvalue" atentry) end; group "metadata"; begin From edwintorok at gmail.com Thu Oct 6 07:12:35 2011 From: edwintorok at gmail.com (Torok Edwin) Date: Thu, 06 Oct 2011 12:12:35 -0000 Subject: [llvm-commits] [llvm] r141284 - in /llvm/trunk: bindings/ocaml/transforms/Makefile bindings/ocaml/transforms/ipo/ bindings/ocaml/transforms/ipo/Makefile bindings/ocaml/transforms/ipo/ipo_ocaml.c bindings/ocaml/transforms/ipo/llvm_ipo.ml bindings/ocaml/transforms/ipo/llvm_ipo.mli test/Bindings/Ocaml/ipo_opts.ml Message-ID: <20111006121237.ABCD1312800A@llvm.org> Author: edwin Date: Thu Oct 6 07:12:27 2011 New Revision: 141284 URL: http://llvm.org/viewvc/llvm-project?rev=141284&view=rev Log: ocaml bindings: add llvm_ipo based on IPO.h Added: llvm/trunk/bindings/ocaml/transforms/ipo/ llvm/trunk/bindings/ocaml/transforms/ipo/Makefile llvm/trunk/bindings/ocaml/transforms/ipo/ipo_ocaml.c llvm/trunk/bindings/ocaml/transforms/ipo/llvm_ipo.ml llvm/trunk/bindings/ocaml/transforms/ipo/llvm_ipo.mli llvm/trunk/test/Bindings/Ocaml/ipo_opts.ml Modified: llvm/trunk/bindings/ocaml/transforms/Makefile Modified: llvm/trunk/bindings/ocaml/transforms/Makefile URL: http://llvm.org/viewvc/llvm-project/llvm/trunk/bindings/ocaml/transforms/Makefile?rev=141284&r1=141283&r2=141284&view=diff ============================================================================== --- llvm/trunk/bindings/ocaml/transforms/Makefile (original) +++ llvm/trunk/bindings/ocaml/transforms/Makefile Thu Oct 6 07:12:27 2011 @@ -8,7 +8,7 @@ ##===----------------------------------------------------------------------===## LEVEL := ../../.. -DIRS = scalar +DIRS = scalar ipo ocamldoc: $(Verb) for i in $(DIRS) ; do \ Added: llvm/trunk/bindings/ocaml/transforms/ipo/Makefile URL: http://llvm.org/viewvc/llvm-project/llvm/trunk/bindings/ocaml/transforms/ipo/Makefile?rev=141284&view=auto ============================================================================== --- llvm/trunk/bindings/ocaml/transforms/ipo/Makefile (added) +++ llvm/trunk/bindings/ocaml/transforms/ipo/Makefile Thu Oct 6 07:12:27 2011 @@ -0,0 +1,20 @@ +##===- bindings/ocaml/transforms/scalar/Makefile -----------*- Makefile -*-===## +# +# The LLVM Compiler Infrastructure +# +# This file is distributed under the University of Illinois Open Source +# License. See LICENSE.TXT for details. +# +##===----------------------------------------------------------------------===## +# +# This is the makefile for the Objective Caml Llvm_scalar_opts interface. +# +##===----------------------------------------------------------------------===## + +LEVEL := ../../../.. +LIBRARYNAME := llvm_ipo +DONT_BUILD_RELINKED := 1 +UsedComponents := ipo +UsedOcamlInterfaces := llvm + +include ../../Makefile.ocaml Added: llvm/trunk/bindings/ocaml/transforms/ipo/ipo_ocaml.c URL: http://llvm.org/viewvc/llvm-project/llvm/trunk/bindings/ocaml/transforms/ipo/ipo_ocaml.c?rev=141284&view=auto ============================================================================== --- llvm/trunk/bindings/ocaml/transforms/ipo/ipo_ocaml.c (added) +++ llvm/trunk/bindings/ocaml/transforms/ipo/ipo_ocaml.c Thu Oct 6 07:12:27 2011 @@ -0,0 +1,104 @@ +/*===-- ipo_ocaml.c - LLVM Ocaml Glue -------------------*- C++ -*-===*\ +|* *| +|* The LLVM Compiler Infrastructure *| +|* *| +|* This file 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. *| +|* *| +|* Note that these functions intentionally take liberties with the CAMLparamX *| +|* macros, since most of the parameters are not GC heap objects. *| +|* *| +\*===----------------------------------------------------------------------===*/ + +#include "llvm-c/Transforms/IPO.h" +#include "caml/mlvalues.h" +#include "caml/misc.h" + +/* [`Module] Llvm.PassManager.t -> unit */ +CAMLprim value llvm_add_argument_promotion(LLVMPassManagerRef PM) { + LLVMAddArgumentPromotionPass(PM); + return Val_unit; +} + +/* [`Module] Llvm.PassManager.t -> unit */ +CAMLprim value llvm_add_constant_merge(LLVMPassManagerRef PM) { + LLVMAddConstantMergePass(PM); + return Val_unit; +} + +/* [`Module] Llvm.PassManager.t -> unit */ +CAMLprim value llvm_add_dead_arg_elimination(LLVMPassManagerRef PM) { + LLVMAddDeadArgEliminationPass(PM); + return Val_unit; +} + +/* [`Module] Llvm.PassManager.t -> unit */ +CAMLprim value llvm_add_function_attrs(LLVMPassManagerRef PM) { + LLVMAddFunctionAttrsPass(PM); + return Val_unit; +} + +/* [`Module] Llvm.PassManager.t -> unit */ +CAMLprim value llvm_add_function_inlining(LLVMPassManagerRef PM) { + LLVMAddFunctionInliningPass(PM); + return Val_unit; +} + +/* [`Module] Llvm.PassManager.t -> unit */ +CAMLprim value llvm_add_always_inliner_pass(LLVMPassManagerRef PM) { + LLVMAddAlwaysInlinerPass(PM); + return Val_unit; +} + +/* [`Module] Llvm.PassManager.t -> unit */ +CAMLprim value llvm_add_global_dce(LLVMPassManagerRef PM) { + LLVMAddGlobalDCEPass(PM); + return Val_unit; +} + +/* [`Module] Llvm.PassManager.t -> unit */ +CAMLprim value llvm_add_global_optimizer(LLVMPassManagerRef PM) { + LLVMAddGlobalOptimizerPass(PM); + return Val_unit; +} + +/* [`Module] Llvm.PassManager.t -> unit */ +CAMLprim value llvm_add_ipc_propagation(LLVMPassManagerRef PM) { + LLVMAddIPConstantPropagationPass(PM); + return Val_unit; +} + +/* [`Module] Llvm.PassManager.t -> unit */ +CAMLprim value llvm_add_prune_eh(LLVMPassManagerRef PM) { + LLVMAddPruneEHPass(PM); + return Val_unit; +} + +/* [`Module] Llvm.PassManager.t -> unit */ +CAMLprim value llvm_add_ipsccp(LLVMPassManagerRef PM) { + LLVMAddIPSCCPPass(PM); + return Val_unit; +} + +/* [`Module] Llvm.PassManager.t -> bool -> unit */ +CAMLprim value llvm_add_internalize(LLVMPassManagerRef PM, value AllButMain) { + LLVMAddInternalizePass(PM, Bool_val(AllButMain)); + return Val_unit; +} + +/* [`Module] Llvm.PassManager.t -> unit */ +CAMLprim value llvm_add_strip_dead_prototypes(LLVMPassManagerRef PM) { + LLVMAddStripDeadPrototypesPass(PM); + return Val_unit; +} + +/* [`Module] Llvm.PassManager.t -> unit */ +CAMLprim value llvm_add_strip_symbols(LLVMPassManagerRef PM) { + LLVMAddStripSymbolsPass(PM); + return Val_unit; +} Added: llvm/trunk/bindings/ocaml/transforms/ipo/llvm_ipo.ml URL: http://llvm.org/viewvc/llvm-project/llvm/trunk/bindings/ocaml/transforms/ipo/llvm_ipo.ml?rev=141284&view=auto ============================================================================== --- llvm/trunk/bindings/ocaml/transforms/ipo/llvm_ipo.ml (added) +++ llvm/trunk/bindings/ocaml/transforms/ipo/llvm_ipo.ml Thu Oct 6 07:12:27 2011 @@ -0,0 +1,65 @@ +(*===-- llvm_ipo.mli - LLVM Ocaml Interface ------------*- OCaml -*-===* + * + * The LLVM Compiler Infrastructure + * + * This file is distributed under the University of Illinois Open Source + * License. See LICENSE.TXT for details. + * + *===----------------------------------------------------------------------===*) + +(** IPO Transforms. + + This interface provides an ocaml API for LLVM interprocedural optimizations, the + classes in the [LLVMIPO] library. *) + +(** See llvm::createAddArgumentPromotionPass *) +external add_argument_promotion : [ | `Module ] Llvm.PassManager.t -> unit = + "llvm_add_argument_promotion" + +(** See llvm::createConstantMergePass function. *) +external add_constant_merge : [ | `Module ] Llvm.PassManager.t -> unit = + "llvm_add_constant_merge" + +(** See llvm::createDeadArgEliminationPass function. *) +external add_dead_arg_elimination : + [ | `Module ] Llvm.PassManager.t -> unit = "llvm_add_dead_arg_elimination" + +(** See llvm::createFunctionAttrsPass function. *) +external add_function_attrs : [ | `Module ] Llvm.PassManager.t -> unit = + "llvm_add_function_attrs" + +(** See llvm::createFunctionInliningPass function. *) +external add_function_inlining : [ | `Module ] Llvm.PassManager.t -> unit = + "llvm_add_function_inlining" + +(** See llvm::createGlobalDCEPass function. *) +external add_global_dce : [ | `Module ] Llvm.PassManager.t -> unit = + "llvm_add_global_dce" + +(** See llvm::createGlobalOptimizerPass function. *) +external add_global_optimizer : [ | `Module ] Llvm.PassManager.t -> unit = + "llvm_add_global_optimizer" + +(** See llvm::createIPConstantPropagationPass function. *) +external add_ipc_propagation : [ | `Module ] Llvm.PassManager.t -> unit = + "llvm_add_ipc_propagation" + +(** See llvm::createPruneEHPass function. *) +external add_prune_eh : [ | `Module ] Llvm.PassManager.t -> unit = + "llvm_add_prune_eh" + +(** See llvm::createIPSCCPPass function. *) +external add_ipsccp : [ | `Module ] Llvm.PassManager.t -> unit = + "llvm_add_ipsccp" + +(** See llvm::createInternalizePass function. *) +external add_internalize : [ | `Module ] Llvm.PassManager.t -> bool -> unit = + "llvm_add_internalize" + +(** See llvm::createStripDeadPrototypesPass function. *) +external add_strip_dead_prototypes : + [ | `Module ] Llvm.PassManager.t -> unit = "llvm_add_strip_dead_prototypes" + +(** See llvm::createStripSymbolsPass function. *) +external add_strip_symbols : [ | `Module ] Llvm.PassManager.t -> unit = + "llvm_add_strip_symbols" Added: llvm/trunk/bindings/ocaml/transforms/ipo/llvm_ipo.mli URL: http://llvm.org/viewvc/llvm-project/llvm/trunk/bindings/ocaml/transforms/ipo/llvm_ipo.mli?rev=141284&view=auto ============================================================================== --- llvm/trunk/bindings/ocaml/transforms/ipo/llvm_ipo.mli (added) +++ llvm/trunk/bindings/ocaml/transforms/ipo/llvm_ipo.mli Thu Oct 6 07:12:27 2011 @@ -0,0 +1,65 @@ +(*===-- llvm_ipo.mli - LLVM Ocaml Interface ------------*- OCaml -*-===* + * + * The LLVM Compiler Infrastructure + * + * This file is distributed under the University of Illinois Open Source + * License. See LICENSE.TXT for details. + * + *===----------------------------------------------------------------------===*) + +(** IPO Transforms. + + This interface provides an ocaml API for LLVM interprocedural optimizations, the + classes in the [LLVMIPO] library. *) + +(** See llvm::createAddArgumentPromotionPass *) +external add_argument_promotion : [ | `Module ] Llvm.PassManager.t -> unit = + + "llvm_add_argument_promotion" +(** See llvm::createConstantMergePass function. *) +external add_constant_merge : [ | `Module ] Llvm.PassManager.t -> unit = + "llvm_add_constant_merge" + +(** See llvm::createDeadArgEliminationPass function. *) +external add_dead_arg_elimination : + [ | `Module ] Llvm.PassManager.t -> unit = "llvm_add_dead_arg_elimination" + +(** See llvm::createFunctionAttrsPass function. *) +external add_function_attrs : [ | `Module ] Llvm.PassManager.t -> unit = + "llvm_add_function_attrs" + +(** See llvm::createFunctionInliningPass function. *) +external add_function_inlining : [ | `Module ] Llvm.PassManager.t -> unit = + "llvm_add_function_inlining" + +(** See llvm::createGlobalDCEPass function. *) +external add_global_dce : [ | `Module ] Llvm.PassManager.t -> unit = + "llvm_add_global_dce" + +(** See llvm::createGlobalOptimizerPass function. *) +external add_global_optimizer : [ | `Module ] Llvm.PassManager.t -> unit = + "llvm_add_global_optimizer" + +(** See llvm::createIPConstantPropagationPass function. *) +external add_ipc_propagation : [ | `Module ] Llvm.PassManager.t -> unit = + "llvm_add_ipc_propagation" + +(** See llvm::createPruneEHPass function. *) +external add_prune_eh : [ | `Module ] Llvm.PassManager.t -> unit = + "llvm_add_prune_eh" + +(** See llvm::createIPSCCPPass function. *) +external add_ipsccp : [ | `Module ] Llvm.PassManager.t -> unit = + "llvm_add_ipsccp" + +(** See llvm::createInternalizePass function. *) +external add_internalize : [ | `Module ] Llvm.PassManager.t -> bool -> unit = + "llvm_add_internalize" + +(** See llvm::createStripDeadPrototypesPass function. *) +external add_strip_dead_prototypes : + [ | `Module ] Llvm.PassManager.t -> unit = "llvm_add_strip_dead_prototypes" + +(** See llvm::createStripSymbolsPass function. *) +external add_strip_symbols : [ | `Module ] Llvm.PassManager.t -> unit = + "llvm_add_strip_symbols" Added: llvm/trunk/test/Bindings/Ocaml/ipo_opts.ml URL: http://llvm.org/viewvc/llvm-project/llvm/trunk/test/Bindings/Ocaml/ipo_opts.ml?rev=141284&view=auto ============================================================================== --- llvm/trunk/test/Bindings/Ocaml/ipo_opts.ml (added) +++ llvm/trunk/test/Bindings/Ocaml/ipo_opts.ml Thu Oct 6 07:12:27 2011 @@ -0,0 +1,73 @@ +(* RUN: %ocamlopt -warn-error A llvm.cmxa llvm_ipo.cmxa llvm_target.cmxa %s -o %t + * RUN: %t %t.bc + * XFAIL: vg_leak + *) + +(* Note: It takes several seconds for ocamlopt to link an executable with + libLLVMCore.a, so it's better to write a big test than a bunch of + little ones. *) + +open Llvm +open Llvm_ipo +open Llvm_target + +let context = global_context () +let void_type = Llvm.void_type context +let i8_type = Llvm.i8_type context + +(* Tiny unit test framework - really just to help find which line is busted *) +let print_checkpoints = false + +let suite name f = + if print_checkpoints then + prerr_endline (name ^ ":"); + f () + + +(*===-- Fixture -----------------------------------------------------------===*) + +let filename = Sys.argv.(1) +let m = create_module context filename + + +(*===-- Transforms --------------------------------------------------------===*) + +let test_transforms () = + let (++) x f = ignore (f x); x in + + let fty = function_type i8_type [| |] in + let fn = define_function "fn" fty m in + let fn2 = define_function "fn2" fty m in begin + ignore (build_ret (const_int i8_type 4) (builder_at_end context (entry_block fn))); + let b = builder_at_end context (entry_block fn2) in + ignore (build_ret (build_call fn [| |] "" b) b); + end; + + let td = TargetData.create (target_triple m) in + + ignore (PassManager.create () + ++ TargetData.add td + ++ add_argument_promotion + ++ add_constant_merge + ++ add_dead_arg_elimination + ++ add_function_attrs + ++ add_function_inlining + ++ add_global_dce + ++ add_global_optimizer + ++ add_ipc_propagation + ++ add_prune_eh + ++ add_ipsccp + ++ add_internalize + ++ add_strip_dead_prototypes + ++ add_strip_symbols + ++ PassManager.run_module m + ++ PassManager.dispose); + + TargetData.dispose td + + +(*===-- Driver ------------------------------------------------------------===*) + +let _ = + suite "transforms" test_transforms; + dispose_module m From edwintorok at gmail.com Thu Oct 6 07:13:00 2011 From: edwintorok at gmail.com (Torok Edwin) Date: Thu, 06 Oct 2011 12:13:00 -0000 Subject: [llvm-commits] [llvm] r141285 - in /llvm/trunk: bindings/ocaml/llvm/llvm.ml bindings/ocaml/llvm/llvm.mli bindings/ocaml/llvm/llvm_ocaml.c include/llvm-c/Core.h lib/VMCore/Core.cpp Message-ID: <20111006121301.BE9A52A6C12C@llvm.org> Author: edwin Date: Thu Oct 6 07:12:50 2011 New Revision: 141285 URL: http://llvm.org/viewvc/llvm-project?rev=141285&view=rev Log: C/OCaml API to retrieve struct name. Modified: llvm/trunk/bindings/ocaml/llvm/llvm.ml llvm/trunk/bindings/ocaml/llvm/llvm.mli llvm/trunk/bindings/ocaml/llvm/llvm_ocaml.c llvm/trunk/include/llvm-c/Core.h llvm/trunk/lib/VMCore/Core.cpp Modified: llvm/trunk/bindings/ocaml/llvm/llvm.ml URL: http://llvm.org/viewvc/llvm-project/llvm/trunk/bindings/ocaml/llvm/llvm.ml?rev=141285&r1=141284&r2=141285&view=diff ============================================================================== --- llvm/trunk/bindings/ocaml/llvm/llvm.ml (original) +++ llvm/trunk/bindings/ocaml/llvm/llvm.ml Thu Oct 6 07:12:50 2011 @@ -197,6 +197,7 @@ external struct_type : llcontext -> lltype array -> lltype = "llvm_struct_type" external packed_struct_type : llcontext -> lltype array -> lltype = "llvm_packed_struct_type" +external struct_name : lltype -> string option = "llvm_struct_name" external struct_element_types : lltype -> lltype array = "llvm_struct_element_types" external is_packed : lltype -> bool = "llvm_is_packed" Modified: llvm/trunk/bindings/ocaml/llvm/llvm.mli URL: http://llvm.org/viewvc/llvm-project/llvm/trunk/bindings/ocaml/llvm/llvm.mli?rev=141285&r1=141284&r2=141285&view=diff ============================================================================== --- llvm/trunk/bindings/ocaml/llvm/llvm.mli (original) +++ llvm/trunk/bindings/ocaml/llvm/llvm.mli Thu Oct 6 07:12:50 2011 @@ -372,6 +372,10 @@ [llvm::StructType::get]. *) val packed_struct_type : llcontext -> lltype array -> lltype +(** [struct_name ty] returns the name of the named structure type [ty], + * or None if the structure type is not named *) +val struct_name : lltype -> string option + (** [struct_element_types sty] returns the constituent types of the struct type [sty]. See the method [llvm::StructType::getElementType]. *) Modified: llvm/trunk/bindings/ocaml/llvm/llvm_ocaml.c URL: http://llvm.org/viewvc/llvm-project/llvm/trunk/bindings/ocaml/llvm/llvm_ocaml.c?rev=141285&r1=141284&r2=141285&view=diff ============================================================================== --- llvm/trunk/bindings/ocaml/llvm/llvm_ocaml.c (original) +++ llvm/trunk/bindings/ocaml/llvm/llvm_ocaml.c Thu Oct 6 07:12:50 2011 @@ -287,6 +287,20 @@ Wosize_val(ElementTypes), 1); } +/* lltype -> string option */ +CAMLprim value llvm_struct_name(LLVMTypeRef Ty) +{ + CAMLparam0(); + const char *C = LLVMGetStructName(Ty); + if (C) { + CAMLlocal1(result); + result = caml_alloc_small(1, 0); + Store_field(result, 0, caml_copy_string(C)); + CAMLreturn(result); + } + CAMLreturn(Val_int(0)); +} + /* lltype -> lltype array */ CAMLprim value llvm_struct_element_types(LLVMTypeRef StructTy) { value Tys = alloc(LLVMCountStructElementTypes(StructTy), 0); Modified: llvm/trunk/include/llvm-c/Core.h URL: http://llvm.org/viewvc/llvm-project/llvm/trunk/include/llvm-c/Core.h?rev=141285&r1=141284&r2=141285&view=diff ============================================================================== --- llvm/trunk/include/llvm-c/Core.h (original) +++ llvm/trunk/include/llvm-c/Core.h Thu Oct 6 07:12:50 2011 @@ -403,6 +403,7 @@ LLVMTypeRef LLVMStructType(LLVMTypeRef *ElementTypes, unsigned ElementCount, LLVMBool Packed); LLVMTypeRef LLVMStructCreateNamed(LLVMContextRef C, const char *Name); +const char *LLVMGetStructName(LLVMTypeRef Ty); void LLVMStructSetBody(LLVMTypeRef StructTy, LLVMTypeRef *ElementTypes, unsigned ElementCount, LLVMBool Packed); Modified: llvm/trunk/lib/VMCore/Core.cpp URL: http://llvm.org/viewvc/llvm-project/llvm/trunk/lib/VMCore/Core.cpp?rev=141285&r1=141284&r2=141285&view=diff ============================================================================== --- llvm/trunk/lib/VMCore/Core.cpp (original) +++ llvm/trunk/lib/VMCore/Core.cpp Thu Oct 6 07:12:50 2011 @@ -302,6 +302,14 @@ return wrap(StructType::create(*unwrap(C), Name)); } +const char *LLVMGetStructName(LLVMTypeRef Ty) +{ + StructType *Type = unwrap(Ty); + if (!Type->hasName()) + return 0; + return Type->getName().data(); +} + void LLVMStructSetBody(LLVMTypeRef StructTy, LLVMTypeRef *ElementTypes, unsigned ElementCount, LLVMBool Packed) { ArrayRef Tys(unwrap(ElementTypes), ElementCount); From edwintorok at gmail.com Thu Oct 6 07:13:11 2011 From: edwintorok at gmail.com (Torok Edwin) Date: Thu, 06 Oct 2011 12:13:11 -0000 Subject: [llvm-commits] [llvm] r141286 - in /llvm/trunk: bindings/ocaml/llvm/llvm.ml bindings/ocaml/llvm/llvm.mli bindings/ocaml/llvm/llvm_ocaml.c include/llvm-c/Core.h lib/VMCore/Core.cpp Message-ID: <20111006121312.0C2B02A6C12C@llvm.org> Author: edwin Date: Thu Oct 6 07:13:11 2011 New Revision: 141286 URL: http://llvm.org/viewvc/llvm-project?rev=141286&view=rev Log: ocaml/C bindings: getmdstring, add num_op, get_op should work on metadata too Modified: llvm/trunk/bindings/ocaml/llvm/llvm.ml llvm/trunk/bindings/ocaml/llvm/llvm.mli llvm/trunk/bindings/ocaml/llvm/llvm_ocaml.c llvm/trunk/include/llvm-c/Core.h llvm/trunk/lib/VMCore/Core.cpp Modified: llvm/trunk/bindings/ocaml/llvm/llvm.ml URL: http://llvm.org/viewvc/llvm-project/llvm/trunk/bindings/ocaml/llvm/llvm.ml?rev=141286&r1=141285&r2=141286&view=diff ============================================================================== --- llvm/trunk/bindings/ocaml/llvm/llvm.ml (original) +++ llvm/trunk/bindings/ocaml/llvm/llvm.ml Thu Oct 6 07:13:11 2011 @@ -281,6 +281,8 @@ (*--... Operations on metadata .......,.....................................--*) external mdstring : llcontext -> string -> llvalue = "llvm_mdstring" external mdnode : llcontext -> llvalue array -> llvalue = "llvm_mdnode" +external get_mdstring : llvalue -> string option = "llvm_get_mdstring" +external get_named_metadata : llmodule -> string -> llvalue array = "llvm_get_namedmd" (*--... Operations on scalar constants .....................................--*) external const_int : lltype -> int -> llvalue = "llvm_const_int" Modified: llvm/trunk/bindings/ocaml/llvm/llvm.mli URL: http://llvm.org/viewvc/llvm-project/llvm/trunk/bindings/ocaml/llvm/llvm.mli?rev=141286&r1=141285&r2=141286&view=diff ============================================================================== --- llvm/trunk/bindings/ocaml/llvm/llvm.mli (original) +++ llvm/trunk/bindings/ocaml/llvm/llvm.mli Thu Oct 6 07:13:11 2011 @@ -571,6 +571,14 @@ See the method [llvm::MDNode::get]. *) val mdnode : llcontext -> llvalue array -> llvalue +(** [get_mdstring v] returns the MDString. + * See the method [llvm::MDString::getString] *) +val get_mdstring : llvalue -> string option + +(** [get_named_metadata m name] return all the MDNodes belonging to the named + * metadata (if any). + * See the method [llvm::NamedMDNode::getOperand]. *) +val get_named_metadata : llmodule -> string -> llvalue array (** {7 Operations on scalar constants} *) Modified: llvm/trunk/bindings/ocaml/llvm/llvm_ocaml.c URL: http://llvm.org/viewvc/llvm-project/llvm/trunk/bindings/ocaml/llvm/llvm_ocaml.c?rev=141286&r1=141285&r2=141286&view=diff ============================================================================== --- llvm/trunk/bindings/ocaml/llvm/llvm_ocaml.c (original) +++ llvm/trunk/bindings/ocaml/llvm/llvm_ocaml.c Thu Oct 6 07:13:11 2011 @@ -24,6 +24,7 @@ #include "llvm/Config/config.h" #include #include +#include /* Can't use the recommended caml_named_value mechanism for backwards @@ -468,6 +469,32 @@ Wosize_val(ElementVals)); } +/* llvalue -> string option */ +CAMLprim value llvm_get_mdstring(LLVMValueRef V) { + CAMLparam0(); + const char *S; + unsigned Len; + + if ((S = LLVMGetMDString(V, &Len))) { + CAMLlocal2(Option, Str); + + Str = caml_alloc_string(Len); + memcpy(String_val(Str), S, Len); + Option = alloc(1,0); + Store_field(Option, 0, Str); + CAMLreturn(Option); + } + CAMLreturn(Val_int(0)); +} + +CAMLprim value llvm_get_namedmd(LLVMModuleRef M, value name) +{ + CAMLparam1(name); + CAMLlocal1(Nodes); + Nodes = alloc(LLVMGetNamedMetadataNumOperands(M, String_val(name)), 0); + LLVMGetNamedMetadataOperands(M, String_val(name), (LLVMValueRef *) Nodes); + CAMLreturn(Nodes); +} /*--... Operations on scalar constants .....................................--*/ /* lltype -> int -> llvalue */ Modified: llvm/trunk/include/llvm-c/Core.h URL: http://llvm.org/viewvc/llvm-project/llvm/trunk/include/llvm-c/Core.h?rev=141286&r1=141285&r2=141286&view=diff ============================================================================== --- llvm/trunk/include/llvm-c/Core.h (original) +++ llvm/trunk/include/llvm-c/Core.h Thu Oct 6 07:13:11 2011 @@ -550,6 +550,11 @@ LLVMValueRef LLVMMDNodeInContext(LLVMContextRef C, LLVMValueRef *Vals, unsigned Count); LLVMValueRef LLVMMDNode(LLVMValueRef *Vals, unsigned Count); +const char *LLVMGetMDString(LLVMValueRef V, unsigned* Len); +int LLVMGetMDNodeNumOperands(LLVMValueRef V); +LLVMValueRef *LLVMGetMDNodeOperand(LLVMValueRef V, unsigned i); +unsigned LLVMGetNamedMetadataNumOperands(LLVMModuleRef M, const char* name); +void LLVMGetNamedMetadataOperands(LLVMModuleRef M, const char* name, LLVMValueRef *Dest); /* Operations on scalar constants */ LLVMValueRef LLVMConstInt(LLVMTypeRef IntTy, unsigned long long N, Modified: llvm/trunk/lib/VMCore/Core.cpp URL: http://llvm.org/viewvc/llvm-project/llvm/trunk/lib/VMCore/Core.cpp?rev=141286&r1=141285&r2=141286&view=diff ============================================================================== --- llvm/trunk/lib/VMCore/Core.cpp (original) +++ llvm/trunk/lib/VMCore/Core.cpp Thu Oct 6 07:13:11 2011 @@ -456,7 +456,10 @@ /*--.. Operations on Users .................................................--*/ LLVMValueRef LLVMGetOperand(LLVMValueRef Val, unsigned Index) { - return wrap(unwrap(Val)->getOperand(Index)); + Value *V = unwrap(Val); + if (MDNode *MD = dyn_cast(V)) + return wrap(MD->getOperand(Index)); + return wrap(cast(V)->getOperand(Index)); } void LLVMSetOperand(LLVMValueRef Val, unsigned Index, LLVMValueRef Op) { @@ -464,7 +467,10 @@ } int LLVMGetNumOperands(LLVMValueRef Val) { - return unwrap(Val)->getNumOperands(); + Value *V = unwrap(Val); + if (MDNode *MD = dyn_cast(V)) + return MD->getNumOperands(); + return cast(V)->getNumOperands(); } /*--.. Operations on constants of any type .................................--*/ @@ -521,6 +527,32 @@ return LLVMMDNodeInContext(LLVMGetGlobalContext(), Vals, Count); } +const char *LLVMGetMDString(LLVMValueRef V, unsigned* Len) { + if (const MDString *S = dyn_cast(unwrap(V))) { + *Len = S->getString().size(); + return S->getString().data(); + } + *Len = 0; + return 0; +} + +unsigned LLVMGetNamedMetadataNumOperands(LLVMModuleRef M, const char* name) +{ + if (NamedMDNode *N = unwrap(M)->getNamedMetadata(name)) { + return N->getNumOperands(); + } + return 0; +} + +void LLVMGetNamedMetadataOperands(LLVMModuleRef M, const char* name, LLVMValueRef *Dest) +{ + NamedMDNode *N = unwrap(M)->getNamedMetadata(name); + if (!N) + return; + for (unsigned i=0;igetNumOperands();i++) + Dest[i] = wrap(N->getOperand(i)); +} + /*--.. Operations on scalar constants ......................................--*/ LLVMValueRef LLVMConstInt(LLVMTypeRef IntTy, unsigned long long N, From edwintorok at gmail.com Thu Oct 6 07:13:20 2011 From: edwintorok at gmail.com (Torok Edwin) Date: Thu, 06 Oct 2011 12:13:20 -0000 Subject: [llvm-commits] [llvm] r141287 - in /llvm/trunk: bindings/ocaml/llvm/llvm.ml bindings/ocaml/llvm/llvm.mli bindings/ocaml/llvm/llvm_ocaml.c include/llvm-c/Core.h lib/VMCore/Core.cpp Message-ID: <20111006121320.784CE2A6C12C@llvm.org> Author: edwin Date: Thu Oct 6 07:13:20 2011 New Revision: 141287 URL: http://llvm.org/viewvc/llvm-project?rev=141287&view=rev Log: add binding to read icmp predicate Modified: llvm/trunk/bindings/ocaml/llvm/llvm.ml llvm/trunk/bindings/ocaml/llvm/llvm.mli llvm/trunk/bindings/ocaml/llvm/llvm_ocaml.c llvm/trunk/include/llvm-c/Core.h llvm/trunk/lib/VMCore/Core.cpp Modified: llvm/trunk/bindings/ocaml/llvm/llvm.ml URL: http://llvm.org/viewvc/llvm-project/llvm/trunk/bindings/ocaml/llvm/llvm.ml?rev=141287&r1=141286&r2=141287&view=diff ============================================================================== --- llvm/trunk/bindings/ocaml/llvm/llvm.ml (original) +++ llvm/trunk/bindings/ocaml/llvm/llvm.ml Thu Oct 6 07:13:20 2011 @@ -705,6 +705,8 @@ external instr_pred : llvalue -> (llbasicblock, llvalue) llrev_pos = "llvm_instr_pred" +external icmp_predicate : llvalue -> Icmp.t option = "llvm_instr_icmp_predicate" + let rec iter_instrs_range f i e = if i = e then () else match i with Modified: llvm/trunk/bindings/ocaml/llvm/llvm.mli URL: http://llvm.org/viewvc/llvm-project/llvm/trunk/bindings/ocaml/llvm/llvm.mli?rev=141287&r1=141286&r2=141287&view=diff ============================================================================== --- llvm/trunk/bindings/ocaml/llvm/llvm.mli (original) +++ llvm/trunk/bindings/ocaml/llvm/llvm.mli Thu Oct 6 07:13:20 2011 @@ -1435,6 +1435,8 @@ val fold_right_instrs: (llvalue -> 'a -> 'a) -> llbasicblock -> 'a -> 'a +val icmp_predicate : llvalue -> Icmp.t option + (** {7 Operations on call sites} *) (** [instruction_call_conv ci] is the calling convention for the call or invoke Modified: llvm/trunk/bindings/ocaml/llvm/llvm_ocaml.c URL: http://llvm.org/viewvc/llvm-project/llvm/trunk/bindings/ocaml/llvm/llvm_ocaml.c?rev=141287&r1=141286&r2=141287&view=diff ============================================================================== --- llvm/trunk/bindings/ocaml/llvm/llvm_ocaml.c (original) +++ llvm/trunk/bindings/ocaml/llvm/llvm_ocaml.c Thu Oct 6 07:13:20 2011 @@ -1010,6 +1010,19 @@ LLVMGetInstructionParent) +/* llvalue -> ICmp.t */ +CAMLprim value llvm_instr_icmp_predicate(LLVMValueRef Val) { + CAMLparam0(); + int x = LLVMGetICmpPredicate(Val); + if (x) { + value Option = alloc(1, 0); + Field(Option, 0) = Val_int(x - LLVMIntEQ); + CAMLreturn(Option); + } + CAMLreturn(Val_int(0)); +} + + /*--... Operations on call sites ...........................................--*/ /* llvalue -> int */ Modified: llvm/trunk/include/llvm-c/Core.h URL: http://llvm.org/viewvc/llvm-project/llvm/trunk/include/llvm-c/Core.h?rev=141287&r1=141286&r2=141287&view=diff ============================================================================== --- llvm/trunk/include/llvm-c/Core.h (original) +++ llvm/trunk/include/llvm-c/Core.h Thu Oct 6 07:13:20 2011 @@ -783,6 +783,7 @@ LLVMValueRef LLVMGetNextInstruction(LLVMValueRef Inst); LLVMValueRef LLVMGetPreviousInstruction(LLVMValueRef Inst); void LLVMInstructionEraseFromParent(LLVMValueRef Inst); +LLVMIntPredicate LLVMGetICmpPredicate(LLVMValueRef Inst); /* Operations on call sites */ void LLVMSetInstructionCallConv(LLVMValueRef Instr, unsigned CC); Modified: llvm/trunk/lib/VMCore/Core.cpp URL: http://llvm.org/viewvc/llvm-project/llvm/trunk/lib/VMCore/Core.cpp?rev=141287&r1=141286&r2=141287&view=diff ============================================================================== --- llvm/trunk/lib/VMCore/Core.cpp (original) +++ llvm/trunk/lib/VMCore/Core.cpp Thu Oct 6 07:13:20 2011 @@ -1552,6 +1552,15 @@ unwrap(Inst)->eraseFromParent(); } +LLVMIntPredicate LLVMGetICmpPredicate(LLVMValueRef Inst) { + if (ICmpInst *I = dyn_cast(unwrap(Inst))) + return (LLVMIntPredicate)I->getPredicate(); + if (ConstantExpr *CE = dyn_cast(unwrap(Inst))) + if (CE->getOpcode() == Instruction::ICmp) + return (LLVMIntPredicate)CE->getPredicate(); + return (LLVMIntPredicate)0; +} + /*--.. Call and invoke instructions ........................................--*/ unsigned LLVMGetInstructionCallConv(LLVMValueRef Instr) { From edwintorok at gmail.com Thu Oct 6 07:13:28 2011 From: edwintorok at gmail.com (Torok Edwin) Date: Thu, 06 Oct 2011 12:13:28 -0000 Subject: [llvm-commits] [llvm] r141288 - in /llvm/trunk: bindings/ocaml/llvm/llvm.ml bindings/ocaml/llvm/llvm.mli bindings/ocaml/llvm/llvm_ocaml.c include/llvm-c/Core.h lib/VMCore/Core.cpp Message-ID: <20111006121328.7D63A2A6C12C@llvm.org> Author: edwin Date: Thu Oct 6 07:13:28 2011 New Revision: 141288 URL: http://llvm.org/viewvc/llvm-project?rev=141288&view=rev Log: ocaml/C bindings: type->isSized() Modified: llvm/trunk/bindings/ocaml/llvm/llvm.ml llvm/trunk/bindings/ocaml/llvm/llvm.mli llvm/trunk/bindings/ocaml/llvm/llvm_ocaml.c llvm/trunk/include/llvm-c/Core.h llvm/trunk/lib/VMCore/Core.cpp Modified: llvm/trunk/bindings/ocaml/llvm/llvm.ml URL: http://llvm.org/viewvc/llvm-project/llvm/trunk/bindings/ocaml/llvm/llvm.ml?rev=141288&r1=141287&r2=141288&view=diff ============================================================================== --- llvm/trunk/bindings/ocaml/llvm/llvm.ml (original) +++ llvm/trunk/bindings/ocaml/llvm/llvm.ml Thu Oct 6 07:13:28 2011 @@ -167,6 +167,7 @@ (*===-- Types -------------------------------------------------------------===*) external classify_type : lltype -> TypeKind.t = "llvm_classify_type" external type_context : lltype -> llcontext = "llvm_type_context" +external type_is_sized : lltype -> bool = "llvm_type_is_sized" (*--... Operations on integer types ........................................--*) external i1_type : llcontext -> lltype = "llvm_i1_type" Modified: llvm/trunk/bindings/ocaml/llvm/llvm.mli URL: http://llvm.org/viewvc/llvm-project/llvm/trunk/bindings/ocaml/llvm/llvm.mli?rev=141288&r1=141287&r2=141288&view=diff ============================================================================== --- llvm/trunk/bindings/ocaml/llvm/llvm.mli (original) +++ llvm/trunk/bindings/ocaml/llvm/llvm.mli Thu Oct 6 07:13:28 2011 @@ -271,6 +271,11 @@ See the method [llvm::Type::getTypeID]. *) val classify_type : lltype -> TypeKind.t +(** [type_is_sized ty] returns whether the type has a size or not. + * If it doesn't then it is not safe to call the [TargetData::] methods on it. + * *) +val type_is_sized : lltype -> bool + (** [type_context ty] returns the {!llcontext} corresponding to the type [ty]. See the method [llvm::Type::getContext]. *) val type_context : lltype -> llcontext Modified: llvm/trunk/bindings/ocaml/llvm/llvm_ocaml.c URL: http://llvm.org/viewvc/llvm-project/llvm/trunk/bindings/ocaml/llvm/llvm_ocaml.c?rev=141288&r1=141287&r2=141288&view=diff ============================================================================== --- llvm/trunk/bindings/ocaml/llvm/llvm_ocaml.c (original) +++ llvm/trunk/bindings/ocaml/llvm/llvm_ocaml.c Thu Oct 6 07:13:28 2011 @@ -172,6 +172,10 @@ return Val_int(LLVMGetTypeKind(Ty)); } +CAMLprim value llvm_type_is_sized(LLVMTypeRef Ty) { + return Val_bool(LLVMTypeIsSized(Ty)); +} + /* lltype -> llcontext */ CAMLprim LLVMContextRef llvm_type_context(LLVMTypeRef Ty) { return LLVMGetTypeContext(Ty); Modified: llvm/trunk/include/llvm-c/Core.h URL: http://llvm.org/viewvc/llvm-project/llvm/trunk/include/llvm-c/Core.h?rev=141288&r1=141287&r2=141288&view=diff ============================================================================== --- llvm/trunk/include/llvm-c/Core.h (original) +++ llvm/trunk/include/llvm-c/Core.h Thu Oct 6 07:13:28 2011 @@ -355,6 +355,7 @@ /** See llvm::LLVMTypeKind::getTypeID. */ LLVMTypeKind LLVMGetTypeKind(LLVMTypeRef Ty); +LLVMBool LLVMTypeIsSized(LLVMTypeRef Ty); /** See llvm::LLVMType::getContext. */ LLVMContextRef LLVMGetTypeContext(LLVMTypeRef Ty); Modified: llvm/trunk/lib/VMCore/Core.cpp URL: http://llvm.org/viewvc/llvm-project/llvm/trunk/lib/VMCore/Core.cpp?rev=141288&r1=141287&r2=141288&view=diff ============================================================================== --- llvm/trunk/lib/VMCore/Core.cpp (original) +++ llvm/trunk/lib/VMCore/Core.cpp Thu Oct 6 07:13:28 2011 @@ -167,6 +167,11 @@ } } +LLVMBool LLVMTypeIsSized(LLVMTypeRef Ty) +{ + return unwrap(Ty)->isSized(); +} + LLVMContextRef LLVMGetTypeContext(LLVMTypeRef Ty) { return wrap(&unwrap(Ty)->getContext()); } From edwintorok at gmail.com Thu Oct 6 07:13:32 2011 From: edwintorok at gmail.com (Torok Edwin) Date: Thu, 06 Oct 2011 12:13:32 -0000 Subject: [llvm-commits] [llvm] r141289 - /llvm/trunk/include/llvm-c/Core.h Message-ID: <20111006121332.E9FC02A6C12C@llvm.org> Author: edwin Date: Thu Oct 6 07:13:32 2011 New Revision: 141289 URL: http://llvm.org/viewvc/llvm-project?rev=141289&view=rev Log: Add uwtable, returnstwice and nonlazybind to the C bindings also. Modified: llvm/trunk/include/llvm-c/Core.h Modified: llvm/trunk/include/llvm-c/Core.h URL: http://llvm.org/viewvc/llvm-project/llvm/trunk/include/llvm-c/Core.h?rev=141289&r1=141288&r2=141289&view=diff ============================================================================== --- llvm/trunk/include/llvm-c/Core.h (original) +++ llvm/trunk/include/llvm-c/Core.h Thu Oct 6 07:13:32 2011 @@ -115,7 +115,10 @@ LLVMNoImplicitFloatAttribute = 1<<23, LLVMNakedAttribute = 1<<24, LLVMInlineHintAttribute = 1<<25, - LLVMStackAlignment = 7<<26 + LLVMStackAlignment = 7<<26, + LLVMReturnsTwice = 1 << 29, + LLVMUWTable = 1 << 30, + LLVMNonLazyBind = 1 << 31 } LLVMAttribute; typedef enum { From baldrick at free.fr Thu Oct 6 07:20:30 2011 From: baldrick at free.fr (Duncan Sands) Date: Thu, 06 Oct 2011 14:20:30 +0200 Subject: [llvm-commits] Fix opcodes in C bindings In-Reply-To: <4E8D9B73.90507@gmail.com> References: <4E89BAF3.2040905@gmail.com> <4E8D9B73.90507@gmail.com> Message-ID: <4E8D9D0E.1040702@free.fr> On 10/06/11 14:13, T?r?k Edwin wrote: > On 2011-10-03 16:38, T?r?k Edwin wrote: >> Hi, >> >> LLVMOpcode is out of sync with getOpcode() right now (was ok in 2.9 AFAICT). >> >> Attached patch introduces a function to map between Instruction::* opcodes and the opcodes declared in llvm-c/Core.h. >> It does that by using the macros in Instruction.def, so that it will always be up-to-date as internal opcodes change. >> When a new opcode is introduced you'll get a compile error in Core.cpp and will have to add it to llvm-c/Core.h >> as well (at the end of the other opcodes). This way the C API opcodes can't get out-of-sync. >> >> The 2nd patch adds an LLVMGetInstructionOpcode to the C API, to allow it to inspect, not just create instructions. > > Ping? It looks OK to me. Ciao, Duncan. From edwintorok at gmail.com Thu Oct 6 07:39:35 2011 From: edwintorok at gmail.com (Torok Edwin) Date: Thu, 06 Oct 2011 12:39:35 -0000 Subject: [llvm-commits] [llvm] r141290 - in /llvm/trunk: include/llvm-c/Core.h lib/VMCore/Core.cpp Message-ID: <20111006123936.CC6DB2A6C12C@llvm.org> Author: edwin Date: Thu Oct 6 07:39:34 2011 New Revision: 141290 URL: http://llvm.org/viewvc/llvm-project?rev=141290&view=rev Log: Don't require C bindings opcode numbers to be kept in sync. They are not in sync now, for example Bitcast would show up as LLVMCall. So instead introduce 2 functions that map to and from the opcodes in the C bindings. Modified: llvm/trunk/include/llvm-c/Core.h llvm/trunk/lib/VMCore/Core.cpp Modified: llvm/trunk/include/llvm-c/Core.h URL: http://llvm.org/viewvc/llvm-project/llvm/trunk/include/llvm-c/Core.h?rev=141290&r1=141289&r2=141290&view=diff ============================================================================== --- llvm/trunk/include/llvm-c/Core.h (original) +++ llvm/trunk/include/llvm-c/Core.h Thu Oct 6 07:39:34 2011 @@ -179,8 +179,8 @@ LLVMPHI = 44, LLVMCall = 45, LLVMSelect = 46, - /* UserOp1 */ - /* UserOp2 */ + LLVMUserOp1 = 47, + LLVMUserOp2 = 48, LLVMVAArg = 49, LLVMExtractElement = 50, LLVMInsertElement = 51, @@ -195,7 +195,9 @@ /* Exception Handling Operators */ LLVMResume = 58, - LLVMLandingPad = 59 + LLVMLandingPad = 59, + LLVMUnwind = 60 + } LLVMOpcode; Modified: llvm/trunk/lib/VMCore/Core.cpp URL: http://llvm.org/viewvc/llvm-project/llvm/trunk/lib/VMCore/Core.cpp?rev=141290&r1=141289&r2=141290&view=diff ============================================================================== --- llvm/trunk/lib/VMCore/Core.cpp (original) +++ llvm/trunk/lib/VMCore/Core.cpp Thu Oct 6 07:39:34 2011 @@ -654,10 +654,35 @@ return wrap(ConstantVector::get(makeArrayRef( unwrap(ScalarConstantVals, Size), Size))); } + +/*-- Opcode mapping */ + +static LLVMOpcode map_to_llvmopcode(int opcode) +{ + switch (opcode) { +#define HANDLE_INST(num, opc, clas) case num: return LLVM##opc; +#include "llvm/Instruction.def" +#undef HANDLE_INST + default: + assert(false && "Unhandled Opcode."); + } +} + +static int map_from_llvmopcode(LLVMOpcode code) +{ + switch (code) { +#define HANDLE_INST(num, opc, clas) case LLVM##opc: return num; +#include "llvm/Instruction.def" +#undef HANDLE_INST + default: + assert(false && "Unhandled Opcode."); + } +} + /*--.. Constant expressions ................................................--*/ LLVMOpcode LLVMGetConstOpcode(LLVMValueRef ConstantVal) { - return (LLVMOpcode)unwrap(ConstantVal)->getOpcode(); + return map_to_llvmopcode(unwrap(ConstantVal)->getOpcode()); } LLVMValueRef LLVMAlignOf(LLVMTypeRef Ty) { @@ -1919,7 +1944,7 @@ LLVMValueRef LLVMBuildBinOp(LLVMBuilderRef B, LLVMOpcode Op, LLVMValueRef LHS, LLVMValueRef RHS, const char *Name) { - return wrap(unwrap(B)->CreateBinOp(Instruction::BinaryOps(Op), unwrap(LHS), + return wrap(unwrap(B)->CreateBinOp(Instruction::BinaryOps(map_from_llvmopcode(Op)), unwrap(LHS), unwrap(RHS), Name)); } @@ -2106,7 +2131,7 @@ LLVMValueRef LLVMBuildCast(LLVMBuilderRef B, LLVMOpcode Op, LLVMValueRef Val, LLVMTypeRef DestTy, const char *Name) { - return wrap(unwrap(B)->CreateCast(Instruction::CastOps(Op), unwrap(Val), + return wrap(unwrap(B)->CreateCast(Instruction::CastOps(map_from_llvmopcode(Op)), unwrap(Val), unwrap(DestTy), Name)); } From clchiou at gmail.com Thu Oct 6 07:42:06 2011 From: clchiou at gmail.com (Che-Liang Chiou) Date: Thu, 6 Oct 2011 20:42:06 +0800 Subject: [llvm-commits] [llvm] r141079 - in /llvm/trunk/lib/TableGen: CMakeLists.txt Main.cpp TGPreprocessor.cpp TGPreprocessor.h In-Reply-To: <73740610-9873-41C1-A673-F20BF0108421@2pi.dk> References: <20111004151452.DE8AB2A6C12C@llvm.org> <73740610-9873-41C1-A673-F20BF0108421@2pi.dk> Message-ID: Hi, I have sent out proposal for discussion earlier (search title: proposal: add macro expansion of for-loop to TableGen). If you have any comments, please reply to that thread. Thanks! Regards, Che-Liang On Thu, Oct 6, 2011 at 7:47 AM, Jakob Stoklund Olesen wrote: > > On Oct 5, 2011, at 1:38 PM, Eli Friedman wrote: > >> On Tue, Oct 4, 2011 at 8:14 AM, Che-Liang Chiou wrote: >>> Author: clchiou >>> Date: Tue Oct ?4 10:14:51 2011 >>> New Revision: 141079 >>> >>> URL: http://llvm.org/viewvc/llvm-project?rev=141079&view=rev >>> Log: >>> tblgen: add preprocessor as a separate mode >>> >>> This patch adds a preprocessor that can expand nested for-loops for >>> saving some copy-n-paste in *.td files. >>> >>> The preprocessor is not yet integrated with TGParser, and so it has >>> no direct effect on *.td inputs. ?However, you may preprocess an td >>> input (and only preprocess it). >>> >>> To test the proprecessor, type: >>> ?tblgen -E -o $@ $< >> >> Has anyone reviewed this feature? ?At first glance, this patch doesn't >> seem like the direction we want to go with TableGen. > > We definitely shouldn't add both this and David's Greenspunning. > > /jakob > > From edwintorok at gmail.com Thu Oct 6 07:45:27 2011 From: edwintorok at gmail.com (=?ISO-8859-1?Q?T=F6r=F6k_Edwin?=) Date: Thu, 06 Oct 2011 15:45:27 +0300 Subject: [llvm-commits] Fix opcodes in C bindings In-Reply-To: <4E8D9D0E.1040702@free.fr> References: <4E89BAF3.2040905@gmail.com> <4E8D9B73.90507@gmail.com> <4E8D9D0E.1040702@free.fr> Message-ID: <4E8DA2E7.8000602@gmail.com> On 2011-10-06 15:20, Duncan Sands wrote: > On 10/06/11 14:13, T?r?k Edwin wrote: >> On 2011-10-03 16:38, T?r?k Edwin wrote: >>> Hi, >>> >>> LLVMOpcode is out of sync with getOpcode() right now (was ok in 2.9 AFAICT). >>> >>> Attached patch introduces a function to map between Instruction::* opcodes and the opcodes declared in llvm-c/Core.h. >>> It does that by using the macros in Instruction.def, so that it will always be up-to-date as internal opcodes change. >>> When a new opcode is introduced you'll get a compile error in Core.cpp and will have to add it to llvm-c/Core.h >>> as well (at the end of the other opcodes). This way the C API opcodes can't get out-of-sync. >>> >>> The 2nd patch adds an LLVMGetInstructionOpcode to the C API, to allow it to inspect, not just create instructions. >> >> Ping? > > It looks OK to me. > Thanks, committed. --Edwin From peter at pcc.me.uk Thu Oct 6 08:21:51 2011 From: peter at pcc.me.uk (Peter Collingbourne) Date: Thu, 06 Oct 2011 13:21:51 -0000 Subject: [llvm-commits] [llvm] r141293 - in /llvm/trunk/utils/TableGen: CMakeLists.txt ClangASTNodesEmitter.cpp ClangASTNodesEmitter.h ClangAttrEmitter.cpp ClangAttrEmitter.h ClangDiagnosticsEmitter.cpp ClangDiagnosticsEmitter.h ClangSACheckersEmitter.cpp ClangSACheckersEmitter.h NeonEmitter.cpp NeonEmitter.h OptParserEmitter.cpp OptParserEmitter.h TableGen.cpp Message-ID: <20111006132156.12F00312800A@llvm.org> Author: pcc Date: Thu Oct 6 08:21:42 2011 New Revision: 141293 URL: http://llvm.org/viewvc/llvm-project?rev=141293&view=rev Log: Remove the Clang tblgen backends from LLVM. Removed: llvm/trunk/utils/TableGen/ClangASTNodesEmitter.cpp llvm/trunk/utils/TableGen/ClangASTNodesEmitter.h llvm/trunk/utils/TableGen/ClangAttrEmitter.cpp llvm/trunk/utils/TableGen/ClangAttrEmitter.h llvm/trunk/utils/TableGen/ClangDiagnosticsEmitter.cpp llvm/trunk/utils/TableGen/ClangDiagnosticsEmitter.h llvm/trunk/utils/TableGen/ClangSACheckersEmitter.cpp llvm/trunk/utils/TableGen/ClangSACheckersEmitter.h llvm/trunk/utils/TableGen/NeonEmitter.cpp llvm/trunk/utils/TableGen/NeonEmitter.h llvm/trunk/utils/TableGen/OptParserEmitter.cpp llvm/trunk/utils/TableGen/OptParserEmitter.h Modified: llvm/trunk/utils/TableGen/CMakeLists.txt llvm/trunk/utils/TableGen/TableGen.cpp Modified: llvm/trunk/utils/TableGen/CMakeLists.txt URL: http://llvm.org/viewvc/llvm-project/llvm/trunk/utils/TableGen/CMakeLists.txt?rev=141293&r1=141292&r2=141293&view=diff ============================================================================== --- llvm/trunk/utils/TableGen/CMakeLists.txt (original) +++ llvm/trunk/utils/TableGen/CMakeLists.txt Thu Oct 6 08:21:42 2011 @@ -7,10 +7,6 @@ AsmWriterEmitter.cpp AsmWriterInst.cpp CallingConvEmitter.cpp - ClangASTNodesEmitter.cpp - ClangAttrEmitter.cpp - ClangDiagnosticsEmitter.cpp - ClangSACheckersEmitter.cpp CodeEmitterGen.cpp CodeGenDAGPatterns.cpp CodeGenInstruction.cpp @@ -28,8 +24,6 @@ InstrEnumEmitter.cpp InstrInfoEmitter.cpp IntrinsicEmitter.cpp - NeonEmitter.cpp - OptParserEmitter.cpp PseudoLoweringEmitter.cpp RegisterInfoEmitter.cpp SetTheory.cpp Removed: llvm/trunk/utils/TableGen/ClangASTNodesEmitter.cpp URL: http://llvm.org/viewvc/llvm-project/llvm/trunk/utils/TableGen/ClangASTNodesEmitter.cpp?rev=141292&view=auto ============================================================================== --- llvm/trunk/utils/TableGen/ClangASTNodesEmitter.cpp (original) +++ llvm/trunk/utils/TableGen/ClangASTNodesEmitter.cpp (removed) @@ -1,168 +0,0 @@ -//=== ClangASTNodesEmitter.cpp - Generate Clang AST node tables -*- C++ -*-===// -// -// The LLVM Compiler Infrastructure -// -// This file is distributed under the University of Illinois Open Source -// License. See LICENSE.TXT for details. -// -//===----------------------------------------------------------------------===// -// -// These tablegen backends emit Clang AST node tables -// -//===----------------------------------------------------------------------===// - -#include "ClangASTNodesEmitter.h" -#include -using namespace llvm; - -//===----------------------------------------------------------------------===// -// Statement Node Tables (.inc file) generation. -//===----------------------------------------------------------------------===// - -// Returns the first and last non-abstract subrecords -// Called recursively to ensure that nodes remain contiguous -std::pair ClangASTNodesEmitter::EmitNode( - const ChildMap &Tree, - raw_ostream &OS, - Record *Base) { - std::string BaseName = macroName(Base->getName()); - - ChildIterator i = Tree.lower_bound(Base), e = Tree.upper_bound(Base); - - Record *First = 0, *Last = 0; - // This might be the pseudo-node for Stmt; don't assume it has an Abstract - // bit - if (Base->getValue("Abstract") && !Base->getValueAsBit("Abstract")) - First = Last = Base; - - for (; i != e; ++i) { - Record *R = i->second; - bool Abstract = R->getValueAsBit("Abstract"); - std::string NodeName = macroName(R->getName()); - - OS << "#ifndef " << NodeName << "\n"; - OS << "# define " << NodeName << "(Type, Base) " - << BaseName << "(Type, Base)\n"; - OS << "#endif\n"; - - if (Abstract) - OS << "ABSTRACT_" << macroName(Root.getName()) << "(" << NodeName << "(" - << R->getName() << ", " << baseName(*Base) << "))\n"; - else - OS << NodeName << "(" << R->getName() << ", " - << baseName(*Base) << ")\n"; - - if (Tree.find(R) != Tree.end()) { - const std::pair &Result - = EmitNode(Tree, OS, R); - if (!First && Result.first) - First = Result.first; - if (Result.second) - Last = Result.second; - } else { - if (!Abstract) { - Last = R; - - if (!First) - First = R; - } - } - - OS << "#undef " << NodeName << "\n\n"; - } - - if (First) { - assert (Last && "Got a first node but not a last node for a range!"); - if (Base == &Root) - OS << "LAST_" << macroName(Root.getName()) << "_RANGE("; - else - OS << macroName(Root.getName()) << "_RANGE("; - OS << Base->getName() << ", " << First->getName() << ", " - << Last->getName() << ")\n\n"; - } - - return std::make_pair(First, Last); -} - -void ClangASTNodesEmitter::run(raw_ostream &OS) { - // Write the preamble - OS << "#ifndef ABSTRACT_" << macroName(Root.getName()) << "\n"; - OS << "# define ABSTRACT_" << macroName(Root.getName()) << "(Type) Type\n"; - OS << "#endif\n"; - - OS << "#ifndef " << macroName(Root.getName()) << "_RANGE\n"; - OS << "# define " - << macroName(Root.getName()) << "_RANGE(Base, First, Last)\n"; - OS << "#endif\n\n"; - - OS << "#ifndef LAST_" << macroName(Root.getName()) << "_RANGE\n"; - OS << "# define LAST_" - << macroName(Root.getName()) << "_RANGE(Base, First, Last) " - << macroName(Root.getName()) << "_RANGE(Base, First, Last)\n"; - OS << "#endif\n\n"; - - // Emit statements - const std::vector Stmts - = Records.getAllDerivedDefinitions(Root.getName()); - - ChildMap Tree; - - for (unsigned i = 0, e = Stmts.size(); i != e; ++i) { - Record *R = Stmts[i]; - - if (R->getValue("Base")) - Tree.insert(std::make_pair(R->getValueAsDef("Base"), R)); - else - Tree.insert(std::make_pair(&Root, R)); - } - - EmitNode(Tree, OS, &Root); - - OS << "#undef " << macroName(Root.getName()) << "\n"; - OS << "#undef " << macroName(Root.getName()) << "_RANGE\n"; - OS << "#undef LAST_" << macroName(Root.getName()) << "_RANGE\n"; - OS << "#undef ABSTRACT_" << macroName(Root.getName()) << "\n"; -} - -void ClangDeclContextEmitter::run(raw_ostream &OS) { - // FIXME: Find a .td file format to allow for this to be represented better. - - OS << "#ifndef DECL_CONTEXT\n"; - OS << "# define DECL_CONTEXT(DECL)\n"; - OS << "#endif\n"; - - OS << "#ifndef DECL_CONTEXT_BASE\n"; - OS << "# define DECL_CONTEXT_BASE(DECL) DECL_CONTEXT(DECL)\n"; - OS << "#endif\n"; - - typedef std::set RecordSet; - typedef std::vector RecordVector; - - RecordVector DeclContextsVector - = Records.getAllDerivedDefinitions("DeclContext"); - RecordVector Decls = Records.getAllDerivedDefinitions("Decl"); - RecordSet DeclContexts (DeclContextsVector.begin(), DeclContextsVector.end()); - - for (RecordVector::iterator i = Decls.begin(), e = Decls.end(); i != e; ++i) { - Record *R = *i; - - if (R->getValue("Base")) { - Record *B = R->getValueAsDef("Base"); - if (DeclContexts.find(B) != DeclContexts.end()) { - OS << "DECL_CONTEXT_BASE(" << B->getName() << ")\n"; - DeclContexts.erase(B); - } - } - } - - // To keep identical order, RecordVector may be used - // instead of RecordSet. - for (RecordVector::iterator - i = DeclContextsVector.begin(), e = DeclContextsVector.end(); - i != e; ++i) - if (DeclContexts.find(*i) != DeclContexts.end()) - OS << "DECL_CONTEXT(" << (*i)->getName() << ")\n"; - - OS << "#undef DECL_CONTEXT\n"; - OS << "#undef DECL_CONTEXT_BASE\n"; -} Removed: llvm/trunk/utils/TableGen/ClangASTNodesEmitter.h URL: http://llvm.org/viewvc/llvm-project/llvm/trunk/utils/TableGen/ClangASTNodesEmitter.h?rev=141292&view=auto ============================================================================== --- llvm/trunk/utils/TableGen/ClangASTNodesEmitter.h (original) +++ llvm/trunk/utils/TableGen/ClangASTNodesEmitter.h (removed) @@ -1,84 +0,0 @@ -//===- ClangASTNodesEmitter.h - Generate Clang AST node tables -*- C++ -*--===// -// -// The LLVM Compiler Infrastructure -// -// This file is distributed under the University of Illinois Open Source -// License. See LICENSE.TXT for details. -// -//===----------------------------------------------------------------------===// -// -// These tablegen backends emit Clang AST node tables -// -//===----------------------------------------------------------------------===// - -#ifndef CLANGAST_EMITTER_H -#define CLANGAST_EMITTER_H - -#include "llvm/TableGen/TableGenBackend.h" -#include "llvm/TableGen/Record.h" -#include -#include -#include - -namespace llvm { - -/// ClangASTNodesEmitter - The top-level class emits .inc files containing -/// declarations of Clang statements. -/// -class ClangASTNodesEmitter : public TableGenBackend { - // A map from a node to each of its derived nodes. - typedef std::multimap ChildMap; - typedef ChildMap::const_iterator ChildIterator; - - RecordKeeper &Records; - Record Root; - const std::string &BaseSuffix; - - // Create a macro-ized version of a name - static std::string macroName(std::string S) { - for (unsigned i = 0; i < S.size(); ++i) - S[i] = std::toupper(S[i]); - - return S; - } - - // Return the name to be printed in the base field. Normally this is - // the record's name plus the base suffix, but if it is the root node and - // the suffix is non-empty, it's just the suffix. - std::string baseName(Record &R) { - if (&R == &Root && !BaseSuffix.empty()) - return BaseSuffix; - - return R.getName() + BaseSuffix; - } - - std::pair EmitNode (const ChildMap &Tree, raw_ostream& OS, - Record *Base); -public: - explicit ClangASTNodesEmitter(RecordKeeper &R, const std::string &N, - const std::string &S) - : Records(R), Root(N, SMLoc(), R), BaseSuffix(S) - {} - - // run - Output the .inc file contents - void run(raw_ostream &OS); -}; - -/// ClangDeclContextEmitter - Emits an addendum to a .inc file to enumerate the -/// clang declaration contexts. -/// -class ClangDeclContextEmitter : public TableGenBackend { - RecordKeeper &Records; - -public: - explicit ClangDeclContextEmitter(RecordKeeper &R) - : Records(R) - {} - - // run - Output the .inc file contents - void run(raw_ostream &OS); -}; - -} // End llvm namespace - -#endif Removed: llvm/trunk/utils/TableGen/ClangAttrEmitter.cpp URL: http://llvm.org/viewvc/llvm-project/llvm/trunk/utils/TableGen/ClangAttrEmitter.cpp?rev=141292&view=auto ============================================================================== --- llvm/trunk/utils/TableGen/ClangAttrEmitter.cpp (original) +++ llvm/trunk/utils/TableGen/ClangAttrEmitter.cpp (removed) @@ -1,788 +0,0 @@ -//===- ClangAttrEmitter.cpp - Generate Clang attribute handling =-*- C++ -*--=// -// -// The LLVM Compiler Infrastructure -// -// This file is distributed under the University of Illinois Open Source -// License. See LICENSE.TXT for details. -// -//===----------------------------------------------------------------------===// -// -// These tablegen backends emit Clang attribute processing code -// -//===----------------------------------------------------------------------===// - -#include "ClangAttrEmitter.h" -#include "llvm/ADT/StringSwitch.h" -#include "llvm/TableGen/Record.h" -#include -#include - -using namespace llvm; - -static const std::vector -getValueAsListOfStrings(Record &R, StringRef FieldName) { - ListInit *List = R.getValueAsListInit(FieldName); - assert (List && "Got a null ListInit"); - - std::vector Strings; - Strings.reserve(List->getSize()); - - for (ListInit::const_iterator i = List->begin(), e = List->end(); - i != e; - ++i) { - assert(*i && "Got a null element in a ListInit"); - if (StringInit *S = dynamic_cast(*i)) - Strings.push_back(S->getValue()); - else if (CodeInit *C = dynamic_cast(*i)) - Strings.push_back(C->getValue()); - else - assert(false && "Got a non-string, non-code element in a ListInit"); - } - - return Strings; -} - -static std::string ReadPCHRecord(StringRef type) { - return StringSwitch(type) - .EndsWith("Decl *", "GetLocalDeclAs<" - + std::string(type, 0, type.size()-1) + ">(F, Record[Idx++])") - .Case("QualType", "getLocalType(F, Record[Idx++])") - .Case("Expr *", "ReadSubExpr()") - .Case("IdentifierInfo *", "GetIdentifierInfo(F, Record, Idx)") - .Case("SourceLocation", "ReadSourceLocation(F, Record, Idx)") - .Default("Record[Idx++]"); -} - -// Assumes that the way to get the value is SA->getname() -static std::string WritePCHRecord(StringRef type, StringRef name) { - return StringSwitch(type) - .EndsWith("Decl *", "AddDeclRef(" + std::string(name) + - ", Record);\n") - .Case("QualType", "AddTypeRef(" + std::string(name) + ", Record);\n") - .Case("Expr *", "AddStmt(" + std::string(name) + ");\n") - .Case("IdentifierInfo *", - "AddIdentifierRef(" + std::string(name) + ", Record);\n") - .Case("SourceLocation", - "AddSourceLocation(" + std::string(name) + ", Record);\n") - .Default("Record.push_back(" + std::string(name) + ");\n"); -} - -namespace { - class Argument { - std::string lowerName, upperName; - StringRef attrName; - - public: - Argument(Record &Arg, StringRef Attr) - : lowerName(Arg.getValueAsString("Name")), upperName(lowerName), - attrName(Attr) { - if (!lowerName.empty()) { - lowerName[0] = std::tolower(lowerName[0]); - upperName[0] = std::toupper(upperName[0]); - } - } - virtual ~Argument() {} - - StringRef getLowerName() const { return lowerName; } - StringRef getUpperName() const { return upperName; } - StringRef getAttrName() const { return attrName; } - - // These functions print the argument contents formatted in different ways. - virtual void writeAccessors(raw_ostream &OS) const = 0; - virtual void writeAccessorDefinitions(raw_ostream &OS) const {} - virtual void writeCloneArgs(raw_ostream &OS) const = 0; - virtual void writeCtorBody(raw_ostream &OS) const {} - virtual void writeCtorInitializers(raw_ostream &OS) const = 0; - virtual void writeCtorParameters(raw_ostream &OS) const = 0; - virtual void writeDeclarations(raw_ostream &OS) const = 0; - virtual void writePCHReadArgs(raw_ostream &OS) const = 0; - virtual void writePCHReadDecls(raw_ostream &OS) const = 0; - virtual void writePCHWrite(raw_ostream &OS) const = 0; - }; - - class SimpleArgument : public Argument { - std::string type; - - public: - SimpleArgument(Record &Arg, StringRef Attr, std::string T) - : Argument(Arg, Attr), type(T) - {} - - void writeAccessors(raw_ostream &OS) const { - OS << " " << type << " get" << getUpperName() << "() const {\n"; - OS << " return " << getLowerName() << ";\n"; - OS << " }"; - } - void writeCloneArgs(raw_ostream &OS) const { - OS << getLowerName(); - } - void writeCtorInitializers(raw_ostream &OS) const { - OS << getLowerName() << "(" << getUpperName() << ")"; - } - void writeCtorParameters(raw_ostream &OS) const { - OS << type << " " << getUpperName(); - } - void writeDeclarations(raw_ostream &OS) const { - OS << type << " " << getLowerName() << ";"; - } - void writePCHReadDecls(raw_ostream &OS) const { - std::string read = ReadPCHRecord(type); - OS << " " << type << " " << getLowerName() << " = " << read << ";\n"; - } - void writePCHReadArgs(raw_ostream &OS) const { - OS << getLowerName(); - } - void writePCHWrite(raw_ostream &OS) const { - OS << " " << WritePCHRecord(type, "SA->get" + - std::string(getUpperName()) + "()"); - } - }; - - class StringArgument : public Argument { - public: - StringArgument(Record &Arg, StringRef Attr) - : Argument(Arg, Attr) - {} - - void writeAccessors(raw_ostream &OS) const { - OS << " llvm::StringRef get" << getUpperName() << "() const {\n"; - OS << " return llvm::StringRef(" << getLowerName() << ", " - << getLowerName() << "Length);\n"; - OS << " }\n"; - OS << " unsigned get" << getUpperName() << "Length() const {\n"; - OS << " return " << getLowerName() << "Length;\n"; - OS << " }\n"; - OS << " void set" << getUpperName() - << "(ASTContext &C, llvm::StringRef S) {\n"; - OS << " " << getLowerName() << "Length = S.size();\n"; - OS << " this->" << getLowerName() << " = new (C, 1) char [" - << getLowerName() << "Length];\n"; - OS << " std::memcpy(this->" << getLowerName() << ", S.data(), " - << getLowerName() << "Length);\n"; - OS << " }"; - } - void writeCloneArgs(raw_ostream &OS) const { - OS << "get" << getUpperName() << "()"; - } - void writeCtorBody(raw_ostream &OS) const { - OS << " std::memcpy(" << getLowerName() << ", " << getUpperName() - << ".data(), " << getLowerName() << "Length);"; - } - void writeCtorInitializers(raw_ostream &OS) const { - OS << getLowerName() << "Length(" << getUpperName() << ".size())," - << getLowerName() << "(new (Ctx, 1) char[" << getLowerName() - << "Length])"; - } - void writeCtorParameters(raw_ostream &OS) const { - OS << "llvm::StringRef " << getUpperName(); - } - void writeDeclarations(raw_ostream &OS) const { - OS << "unsigned " << getLowerName() << "Length;\n"; - OS << "char *" << getLowerName() << ";"; - } - void writePCHReadDecls(raw_ostream &OS) const { - OS << " std::string " << getLowerName() - << "= ReadString(Record, Idx);\n"; - } - void writePCHReadArgs(raw_ostream &OS) const { - OS << getLowerName(); - } - void writePCHWrite(raw_ostream &OS) const { - OS << " AddString(SA->get" << getUpperName() << "(), Record);\n"; - } - }; - - class AlignedArgument : public Argument { - public: - AlignedArgument(Record &Arg, StringRef Attr) - : Argument(Arg, Attr) - {} - - void writeAccessors(raw_ostream &OS) const { - OS << " bool is" << getUpperName() << "Dependent() const;\n"; - - OS << " unsigned get" << getUpperName() << "(ASTContext &Ctx) const;\n"; - - OS << " bool is" << getUpperName() << "Expr() const {\n"; - OS << " return is" << getLowerName() << "Expr;\n"; - OS << " }\n"; - - OS << " Expr *get" << getUpperName() << "Expr() const {\n"; - OS << " assert(is" << getLowerName() << "Expr);\n"; - OS << " return " << getLowerName() << "Expr;\n"; - OS << " }\n"; - - OS << " TypeSourceInfo *get" << getUpperName() << "Type() const {\n"; - OS << " assert(!is" << getLowerName() << "Expr);\n"; - OS << " return " << getLowerName() << "Type;\n"; - OS << " }"; - } - void writeAccessorDefinitions(raw_ostream &OS) const { - OS << "bool " << getAttrName() << "Attr::is" << getUpperName() - << "Dependent() const {\n"; - OS << " if (is" << getLowerName() << "Expr)\n"; - OS << " return " << getLowerName() << "Expr && (" << getLowerName() - << "Expr->isValueDependent() || " << getLowerName() - << "Expr->isTypeDependent());\n"; - OS << " else\n"; - OS << " return " << getLowerName() - << "Type->getType()->isDependentType();\n"; - OS << "}\n"; - - // FIXME: Do not do the calculation here - // FIXME: Handle types correctly - // A null pointer means maximum alignment - // FIXME: Load the platform-specific maximum alignment, rather than - // 16, the x86 max. - OS << "unsigned " << getAttrName() << "Attr::get" << getUpperName() - << "(ASTContext &Ctx) const {\n"; - OS << " assert(!is" << getUpperName() << "Dependent());\n"; - OS << " if (is" << getLowerName() << "Expr)\n"; - OS << " return (" << getLowerName() << "Expr ? " << getLowerName() - << "Expr->EvaluateAsInt(Ctx).getZExtValue() : 16)" - << "* Ctx.getCharWidth();\n"; - OS << " else\n"; - OS << " return 0; // FIXME\n"; - OS << "}\n"; - } - void writeCloneArgs(raw_ostream &OS) const { - OS << "is" << getLowerName() << "Expr, is" << getLowerName() - << "Expr ? static_cast(" << getLowerName() - << "Expr) : " << getLowerName() - << "Type"; - } - void writeCtorBody(raw_ostream &OS) const { - OS << " if (is" << getLowerName() << "Expr)\n"; - OS << " " << getLowerName() << "Expr = reinterpret_cast(" - << getUpperName() << ");\n"; - OS << " else\n"; - OS << " " << getLowerName() - << "Type = reinterpret_cast(" << getUpperName() - << ");"; - } - void writeCtorInitializers(raw_ostream &OS) const { - OS << "is" << getLowerName() << "Expr(Is" << getUpperName() << "Expr)"; - } - void writeCtorParameters(raw_ostream &OS) const { - OS << "bool Is" << getUpperName() << "Expr, void *" << getUpperName(); - } - void writeDeclarations(raw_ostream &OS) const { - OS << "bool is" << getLowerName() << "Expr;\n"; - OS << "union {\n"; - OS << "Expr *" << getLowerName() << "Expr;\n"; - OS << "TypeSourceInfo *" << getLowerName() << "Type;\n"; - OS << "};"; - } - void writePCHReadArgs(raw_ostream &OS) const { - OS << "is" << getLowerName() << "Expr, " << getLowerName() << "Ptr"; - } - void writePCHReadDecls(raw_ostream &OS) const { - OS << " bool is" << getLowerName() << "Expr = Record[Idx++];\n"; - OS << " void *" << getLowerName() << "Ptr;\n"; - OS << " if (is" << getLowerName() << "Expr)\n"; - OS << " " << getLowerName() << "Ptr = ReadExpr(F);\n"; - OS << " else\n"; - OS << " " << getLowerName() - << "Ptr = GetTypeSourceInfo(F, Record, Idx);\n"; - } - void writePCHWrite(raw_ostream &OS) const { - OS << " Record.push_back(SA->is" << getUpperName() << "Expr());\n"; - OS << " if (SA->is" << getUpperName() << "Expr())\n"; - OS << " AddStmt(SA->get" << getUpperName() << "Expr());\n"; - OS << " else\n"; - OS << " AddTypeSourceInfo(SA->get" << getUpperName() - << "Type(), Record);\n"; - } - }; - - class VariadicArgument : public Argument { - std::string type; - - public: - VariadicArgument(Record &Arg, StringRef Attr, std::string T) - : Argument(Arg, Attr), type(T) - {} - - std::string getType() const { return type; } - - void writeAccessors(raw_ostream &OS) const { - OS << " typedef " << type << "* " << getLowerName() << "_iterator;\n"; - OS << " " << getLowerName() << "_iterator " << getLowerName() - << "_begin() const {\n"; - OS << " return " << getLowerName() << ";\n"; - OS << " }\n"; - OS << " " << getLowerName() << "_iterator " << getLowerName() - << "_end() const {\n"; - OS << " return " << getLowerName() << " + " << getLowerName() - << "Size;\n"; - OS << " }\n"; - OS << " unsigned " << getLowerName() << "_size() const {\n" - << " return " << getLowerName() << "Size;\n;"; - OS << " }"; - } - void writeCloneArgs(raw_ostream &OS) const { - OS << getLowerName() << ", " << getLowerName() << "Size"; - } - void writeCtorBody(raw_ostream &OS) const { - // FIXME: memcpy is not safe on non-trivial types. - OS << " std::memcpy(" << getLowerName() << ", " << getUpperName() - << ", " << getLowerName() << "Size * sizeof(" << getType() << "));\n"; - } - void writeCtorInitializers(raw_ostream &OS) const { - OS << getLowerName() << "Size(" << getUpperName() << "Size), " - << getLowerName() << "(new (Ctx, 16) " << getType() << "[" - << getLowerName() << "Size])"; - } - void writeCtorParameters(raw_ostream &OS) const { - OS << getType() << " *" << getUpperName() << ", unsigned " - << getUpperName() << "Size"; - } - void writeDeclarations(raw_ostream &OS) const { - OS << " unsigned " << getLowerName() << "Size;\n"; - OS << " " << getType() << " *" << getLowerName() << ";"; - } - void writePCHReadDecls(raw_ostream &OS) const { - OS << " unsigned " << getLowerName() << "Size = Record[Idx++];\n"; - OS << " llvm::SmallVector<" << type << ", 4> " << getLowerName() - << ";\n"; - OS << " " << getLowerName() << ".reserve(" << getLowerName() - << "Size);\n"; - OS << " for (unsigned i = " << getLowerName() << "Size; i; --i)\n"; - - std::string read = ReadPCHRecord(type); - OS << " " << getLowerName() << ".push_back(" << read << ");\n"; - } - void writePCHReadArgs(raw_ostream &OS) const { - OS << getLowerName() << ".data(), " << getLowerName() << "Size"; - } - void writePCHWrite(raw_ostream &OS) const{ - OS << " Record.push_back(SA->" << getLowerName() << "_size());\n"; - OS << " for (" << getAttrName() << "Attr::" << getLowerName() - << "_iterator i = SA->" << getLowerName() << "_begin(), e = SA->" - << getLowerName() << "_end(); i != e; ++i)\n"; - OS << " " << WritePCHRecord(type, "(*i)"); - } - }; - - class EnumArgument : public Argument { - std::string type; - std::vector values, enums; - public: - EnumArgument(Record &Arg, StringRef Attr) - : Argument(Arg, Attr), type(Arg.getValueAsString("Type")), - values(getValueAsListOfStrings(Arg, "Values")), - enums(getValueAsListOfStrings(Arg, "Enums")) - {} - - void writeAccessors(raw_ostream &OS) const { - OS << " " << type << " get" << getUpperName() << "() const {\n"; - OS << " return " << getLowerName() << ";\n"; - OS << " }"; - } - void writeCloneArgs(raw_ostream &OS) const { - OS << getLowerName(); - } - void writeCtorInitializers(raw_ostream &OS) const { - OS << getLowerName() << "(" << getUpperName() << ")"; - } - void writeCtorParameters(raw_ostream &OS) const { - OS << type << " " << getUpperName(); - } - void writeDeclarations(raw_ostream &OS) const { - // Calculate the various enum values - std::vector uniques(enums); - std::sort(uniques.begin(), uniques.end()); - uniques.erase(std::unique(uniques.begin(), uniques.end()), - uniques.end()); - // FIXME: Emit a proper error - assert(!uniques.empty()); - - std::vector::iterator i = uniques.begin(), - e = uniques.end(); - // The last one needs to not have a comma. - --e; - - OS << "public:\n"; - OS << " enum " << type << " {\n"; - for (; i != e; ++i) - OS << " " << *i << ",\n"; - OS << " " << *e << "\n"; - OS << " };\n"; - OS << "private:\n"; - OS << " " << type << " " << getLowerName() << ";"; - } - void writePCHReadDecls(raw_ostream &OS) const { - OS << " " << getAttrName() << "Attr::" << type << " " << getLowerName() - << "(static_cast<" << getAttrName() << "Attr::" << type - << ">(Record[Idx++]));\n"; - } - void writePCHReadArgs(raw_ostream &OS) const { - OS << getLowerName(); - } - void writePCHWrite(raw_ostream &OS) const { - OS << "Record.push_back(SA->get" << getUpperName() << "());\n"; - } - }; - - class VersionArgument : public Argument { - public: - VersionArgument(Record &Arg, StringRef Attr) - : Argument(Arg, Attr) - {} - - void writeAccessors(raw_ostream &OS) const { - OS << " VersionTuple get" << getUpperName() << "() const {\n"; - OS << " return " << getLowerName() << ";\n"; - OS << " }\n"; - OS << " void set" << getUpperName() - << "(ASTContext &C, VersionTuple V) {\n"; - OS << " " << getLowerName() << " = V;\n"; - OS << " }"; - } - void writeCloneArgs(raw_ostream &OS) const { - OS << "get" << getUpperName() << "()"; - } - void writeCtorBody(raw_ostream &OS) const { - } - void writeCtorInitializers(raw_ostream &OS) const { - OS << getLowerName() << "(" << getUpperName() << ")"; - } - void writeCtorParameters(raw_ostream &OS) const { - OS << "VersionTuple " << getUpperName(); - } - void writeDeclarations(raw_ostream &OS) const { - OS << "VersionTuple " << getLowerName() << ";\n"; - } - void writePCHReadDecls(raw_ostream &OS) const { - OS << " VersionTuple " << getLowerName() - << "= ReadVersionTuple(Record, Idx);\n"; - } - void writePCHReadArgs(raw_ostream &OS) const { - OS << getLowerName(); - } - void writePCHWrite(raw_ostream &OS) const { - OS << " AddVersionTuple(SA->get" << getUpperName() << "(), Record);\n"; - } - }; -} - -static Argument *createArgument(Record &Arg, StringRef Attr, - Record *Search = 0) { - if (!Search) - Search = &Arg; - - Argument *Ptr = 0; - llvm::StringRef ArgName = Search->getName(); - - if (ArgName == "AlignedArgument") Ptr = new AlignedArgument(Arg, Attr); - else if (ArgName == "EnumArgument") Ptr = new EnumArgument(Arg, Attr); - else if (ArgName == "ExprArgument") Ptr = new SimpleArgument(Arg, Attr, - "Expr *"); - else if (ArgName == "FunctionArgument") - Ptr = new SimpleArgument(Arg, Attr, "FunctionDecl *"); - else if (ArgName == "IdentifierArgument") - Ptr = new SimpleArgument(Arg, Attr, "IdentifierInfo *"); - else if (ArgName == "BoolArgument") Ptr = new SimpleArgument(Arg, Attr, - "bool"); - else if (ArgName == "IntArgument") Ptr = new SimpleArgument(Arg, Attr, "int"); - else if (ArgName == "StringArgument") Ptr = new StringArgument(Arg, Attr); - else if (ArgName == "TypeArgument") - Ptr = new SimpleArgument(Arg, Attr, "QualType"); - else if (ArgName == "UnsignedArgument") - Ptr = new SimpleArgument(Arg, Attr, "unsigned"); - else if (ArgName == "SourceLocArgument") - Ptr = new SimpleArgument(Arg, Attr, "SourceLocation"); - else if (ArgName == "VariadicUnsignedArgument") - Ptr = new VariadicArgument(Arg, Attr, "unsigned"); - else if (ArgName == "VariadicExprArgument") - Ptr = new VariadicArgument(Arg, Attr, "Expr *"); - else if (ArgName == "VersionArgument") - Ptr = new VersionArgument(Arg, Attr); - - if (!Ptr) { - std::vector Bases = Search->getSuperClasses(); - for (std::vector::iterator i = Bases.begin(), e = Bases.end(); - i != e; ++i) { - Ptr = createArgument(Arg, Attr, *i); - if (Ptr) - break; - } - } - return Ptr; -} - -void ClangAttrClassEmitter::run(raw_ostream &OS) { - OS << "// This file is generated by TableGen. Do not edit.\n\n"; - OS << "#ifndef LLVM_CLANG_ATTR_CLASSES_INC\n"; - OS << "#define LLVM_CLANG_ATTR_CLASSES_INC\n\n"; - - std::vector Attrs = Records.getAllDerivedDefinitions("Attr"); - - for (std::vector::iterator i = Attrs.begin(), e = Attrs.end(); - i != e; ++i) { - Record &R = **i; - const std::string &SuperName = R.getSuperClasses().back()->getName(); - - OS << "class " << R.getName() << "Attr : public " << SuperName << " {\n"; - - std::vector ArgRecords = R.getValueAsListOfDefs("Args"); - std::vector Args; - std::vector::iterator ai, ae; - Args.reserve(ArgRecords.size()); - - for (std::vector::iterator ri = ArgRecords.begin(), - re = ArgRecords.end(); - ri != re; ++ri) { - Record &ArgRecord = **ri; - Argument *Arg = createArgument(ArgRecord, R.getName()); - assert(Arg); - Args.push_back(Arg); - - Arg->writeDeclarations(OS); - OS << "\n\n"; - } - - ae = Args.end(); - - OS << "\n public:\n"; - OS << " " << R.getName() << "Attr(SourceRange R, ASTContext &Ctx\n"; - - for (ai = Args.begin(); ai != ae; ++ai) { - OS << " , "; - (*ai)->writeCtorParameters(OS); - OS << "\n"; - } - - OS << " )\n"; - OS << " : " << SuperName << "(attr::" << R.getName() << ", R)\n"; - - for (ai = Args.begin(); ai != ae; ++ai) { - OS << " , "; - (*ai)->writeCtorInitializers(OS); - OS << "\n"; - } - - OS << " {\n"; - - for (ai = Args.begin(); ai != ae; ++ai) { - (*ai)->writeCtorBody(OS); - OS << "\n"; - } - OS << " }\n\n"; - - OS << " virtual " << R.getName() << "Attr *clone (ASTContext &C) const;\n"; - - for (ai = Args.begin(); ai != ae; ++ai) { - (*ai)->writeAccessors(OS); - OS << "\n\n"; - } - - OS << R.getValueAsCode("AdditionalMembers"); - OS << "\n\n"; - - OS << " static bool classof(const Attr *A) { return A->getKind() == " - << "attr::" << R.getName() << "; }\n"; - OS << " static bool classof(const " << R.getName() - << "Attr *) { return true; }\n"; - OS << "};\n\n"; - } - - OS << "#endif\n"; -} - -void ClangAttrImplEmitter::run(raw_ostream &OS) { - OS << "// This file is generated by TableGen. Do not edit.\n\n"; - - std::vector Attrs = Records.getAllDerivedDefinitions("Attr"); - std::vector::iterator i = Attrs.begin(), e = Attrs.end(), ri, re; - std::vector::iterator ai, ae; - - for (; i != e; ++i) { - Record &R = **i; - std::vector ArgRecords = R.getValueAsListOfDefs("Args"); - std::vector Args; - for (ri = ArgRecords.begin(), re = ArgRecords.end(); ri != re; ++ri) - Args.push_back(createArgument(**ri, R.getName())); - - for (ai = Args.begin(), ae = Args.end(); ai != ae; ++ai) - (*ai)->writeAccessorDefinitions(OS); - - OS << R.getName() << "Attr *" << R.getName() - << "Attr::clone(ASTContext &C) const {\n"; - OS << " return new (C) " << R.getName() << "Attr(getLocation(), C"; - for (ai = Args.begin(); ai != ae; ++ai) { - OS << ", "; - (*ai)->writeCloneArgs(OS); - } - OS << ");\n}\n\n"; - } -} - -static void EmitAttrList(raw_ostream &OS, StringRef Class, - const std::vector &AttrList) { - std::vector::const_iterator i = AttrList.begin(), e = AttrList.end(); - - if (i != e) { - // Move the end iterator back to emit the last attribute. - for(--e; i != e; ++i) - OS << Class << "(" << (*i)->getName() << ")\n"; - - OS << "LAST_" << Class << "(" << (*i)->getName() << ")\n\n"; - } -} - -void ClangAttrListEmitter::run(raw_ostream &OS) { - OS << "// This file is generated by TableGen. Do not edit.\n\n"; - - OS << "#ifndef LAST_ATTR\n"; - OS << "#define LAST_ATTR(NAME) ATTR(NAME)\n"; - OS << "#endif\n\n"; - - OS << "#ifndef INHERITABLE_ATTR\n"; - OS << "#define INHERITABLE_ATTR(NAME) ATTR(NAME)\n"; - OS << "#endif\n\n"; - - OS << "#ifndef LAST_INHERITABLE_ATTR\n"; - OS << "#define LAST_INHERITABLE_ATTR(NAME) INHERITABLE_ATTR(NAME)\n"; - OS << "#endif\n\n"; - - OS << "#ifndef INHERITABLE_PARAM_ATTR\n"; - OS << "#define INHERITABLE_PARAM_ATTR(NAME) ATTR(NAME)\n"; - OS << "#endif\n\n"; - - OS << "#ifndef LAST_INHERITABLE_PARAM_ATTR\n"; - OS << "#define LAST_INHERITABLE_PARAM_ATTR(NAME)" - " INHERITABLE_PARAM_ATTR(NAME)\n"; - OS << "#endif\n\n"; - - Record *InhClass = Records.getClass("InheritableAttr"); - Record *InhParamClass = Records.getClass("InheritableParamAttr"); - std::vector Attrs = Records.getAllDerivedDefinitions("Attr"), - NonInhAttrs, InhAttrs, InhParamAttrs; - for (std::vector::iterator i = Attrs.begin(), e = Attrs.end(); - i != e; ++i) { - if ((*i)->isSubClassOf(InhParamClass)) - InhParamAttrs.push_back(*i); - else if ((*i)->isSubClassOf(InhClass)) - InhAttrs.push_back(*i); - else - NonInhAttrs.push_back(*i); - } - - EmitAttrList(OS, "INHERITABLE_PARAM_ATTR", InhParamAttrs); - EmitAttrList(OS, "INHERITABLE_ATTR", InhAttrs); - EmitAttrList(OS, "ATTR", NonInhAttrs); - - OS << "#undef LAST_ATTR\n"; - OS << "#undef INHERITABLE_ATTR\n"; - OS << "#undef LAST_INHERITABLE_ATTR\n"; - OS << "#undef LAST_INHERITABLE_PARAM_ATTR\n"; - OS << "#undef ATTR\n"; -} - -void ClangAttrPCHReadEmitter::run(raw_ostream &OS) { - OS << "// This file is generated by TableGen. Do not edit.\n\n"; - - Record *InhClass = Records.getClass("InheritableAttr"); - std::vector Attrs = Records.getAllDerivedDefinitions("Attr"), - ArgRecords; - std::vector::iterator i = Attrs.begin(), e = Attrs.end(), ai, ae; - std::vector Args; - std::vector::iterator ri, re; - - OS << " switch (Kind) {\n"; - OS << " default:\n"; - OS << " assert(0 && \"Unknown attribute!\");\n"; - OS << " break;\n"; - for (; i != e; ++i) { - Record &R = **i; - OS << " case attr::" << R.getName() << ": {\n"; - if (R.isSubClassOf(InhClass)) - OS << " bool isInherited = Record[Idx++];\n"; - ArgRecords = R.getValueAsListOfDefs("Args"); - Args.clear(); - for (ai = ArgRecords.begin(), ae = ArgRecords.end(); ai != ae; ++ai) { - Argument *A = createArgument(**ai, R.getName()); - Args.push_back(A); - A->writePCHReadDecls(OS); - } - OS << " New = new (Context) " << R.getName() << "Attr(Range, Context"; - for (ri = Args.begin(), re = Args.end(); ri != re; ++ri) { - OS << ", "; - (*ri)->writePCHReadArgs(OS); - } - OS << ");\n"; - if (R.isSubClassOf(InhClass)) - OS << " cast(New)->setInherited(isInherited);\n"; - OS << " break;\n"; - OS << " }\n"; - } - OS << " }\n"; -} - -void ClangAttrPCHWriteEmitter::run(raw_ostream &OS) { - Record *InhClass = Records.getClass("InheritableAttr"); - std::vector Attrs = Records.getAllDerivedDefinitions("Attr"), Args; - std::vector::iterator i = Attrs.begin(), e = Attrs.end(), ai, ae; - - OS << " switch (A->getKind()) {\n"; - OS << " default:\n"; - OS << " llvm_unreachable(\"Unknown attribute kind!\");\n"; - OS << " break;\n"; - for (; i != e; ++i) { - Record &R = **i; - OS << " case attr::" << R.getName() << ": {\n"; - Args = R.getValueAsListOfDefs("Args"); - if (R.isSubClassOf(InhClass) || !Args.empty()) - OS << " const " << R.getName() << "Attr *SA = cast<" << R.getName() - << "Attr>(A);\n"; - if (R.isSubClassOf(InhClass)) - OS << " Record.push_back(SA->isInherited());\n"; - for (ai = Args.begin(), ae = Args.end(); ai != ae; ++ai) - createArgument(**ai, R.getName())->writePCHWrite(OS); - OS << " break;\n"; - OS << " }\n"; - } - OS << " }\n"; -} - -void ClangAttrSpellingListEmitter::run(raw_ostream &OS) { - OS << "// This file is generated by TableGen. Do not edit.\n\n"; - - std::vector Attrs = Records.getAllDerivedDefinitions("Attr"); - - for (std::vector::iterator I = Attrs.begin(), E = Attrs.end(); I != E; ++I) { - Record &Attr = **I; - - std::vector Spellings = getValueAsListOfStrings(Attr, "Spellings"); - - for (std::vector::const_iterator I = Spellings.begin(), E = Spellings.end(); I != E; ++I) { - StringRef Spelling = *I; - OS << ".Case(\"" << Spelling << "\", true)\n"; - } - } - -} - -void ClangAttrLateParsedListEmitter::run(raw_ostream &OS) { - OS << "// This file is generated by TableGen. Do not edit.\n\n"; - - std::vector Attrs = Records.getAllDerivedDefinitions("Attr"); - - for (std::vector::iterator I = Attrs.begin(), E = Attrs.end(); - I != E; ++I) { - Record &Attr = **I; - - bool LateParsed = Attr.getValueAsBit("LateParsed"); - - if (LateParsed) { - std::vector Spellings = - getValueAsListOfStrings(Attr, "Spellings"); - - for (std::vector::const_iterator I = Spellings.begin(), - E = Spellings.end(); I != E; ++I) { - OS << ".Case(\"" << (*I) << "\", " << LateParsed << ")\n"; - } - } - } -} Removed: llvm/trunk/utils/TableGen/ClangAttrEmitter.h URL: http://llvm.org/viewvc/llvm-project/llvm/trunk/utils/TableGen/ClangAttrEmitter.h?rev=141292&view=auto ============================================================================== --- llvm/trunk/utils/TableGen/ClangAttrEmitter.h (original) +++ llvm/trunk/utils/TableGen/ClangAttrEmitter.h (removed) @@ -1,114 +0,0 @@ -//===- ClangAttrEmitter.h - Generate Clang attribute handling =-*- C++ -*--===// -// -// The LLVM Compiler Infrastructure -// -// This file is distributed under the University of Illinois Open Source -// License. See LICENSE.TXT for details. -// -//===----------------------------------------------------------------------===// -// -// These tablegen backends emit Clang attribute processing code -// -//===----------------------------------------------------------------------===// - -#ifndef CLANGATTR_EMITTER_H -#define CLANGATTR_EMITTER_H - -#include "llvm/TableGen/TableGenBackend.h" - -namespace llvm { - -/// ClangAttrClassEmitter - class emits the class defintions for attributes for -/// clang. -class ClangAttrClassEmitter : public TableGenBackend { - RecordKeeper &Records; - - public: - explicit ClangAttrClassEmitter(RecordKeeper &R) - : Records(R) - {} - - void run(raw_ostream &OS); -}; - -/// ClangAttrImplEmitter - class emits the class method defintions for -/// attributes for clang. -class ClangAttrImplEmitter : public TableGenBackend { - RecordKeeper &Records; - - public: - explicit ClangAttrImplEmitter(RecordKeeper &R) - : Records(R) - {} - - void run(raw_ostream &OS); -}; - -/// ClangAttrListEmitter - class emits the enumeration list for attributes for -/// clang. -class ClangAttrListEmitter : public TableGenBackend { - RecordKeeper &Records; - - public: - explicit ClangAttrListEmitter(RecordKeeper &R) - : Records(R) - {} - - void run(raw_ostream &OS); -}; - -/// ClangAttrPCHReadEmitter - class emits the code to read an attribute from -/// a clang precompiled header. -class ClangAttrPCHReadEmitter : public TableGenBackend { - RecordKeeper &Records; - -public: - explicit ClangAttrPCHReadEmitter(RecordKeeper &R) - : Records(R) - {} - - void run(raw_ostream &OS); -}; - -/// ClangAttrPCHWriteEmitter - class emits the code to read an attribute from -/// a clang precompiled header. -class ClangAttrPCHWriteEmitter : public TableGenBackend { - RecordKeeper &Records; - -public: - explicit ClangAttrPCHWriteEmitter(RecordKeeper &R) - : Records(R) - {} - - void run(raw_ostream &OS); -}; - -/// ClangAttrSpellingListEmitter - class emits the list of spellings for attributes for -/// clang. -class ClangAttrSpellingListEmitter : public TableGenBackend { - RecordKeeper &Records; - - public: - explicit ClangAttrSpellingListEmitter(RecordKeeper &R) - : Records(R) - {} - - void run(raw_ostream &OS); -}; - -/// ClangAttrLateParsedListEmitter emits the LateParsed property for attributes -/// for clang. -class ClangAttrLateParsedListEmitter : public TableGenBackend { - RecordKeeper &Records; - - public: - explicit ClangAttrLateParsedListEmitter(RecordKeeper &R) - : Records(R) - {} - - void run(raw_ostream &OS); -}; - -} - -#endif Removed: llvm/trunk/utils/TableGen/ClangDiagnosticsEmitter.cpp URL: http://llvm.org/viewvc/llvm-project/llvm/trunk/utils/TableGen/ClangDiagnosticsEmitter.cpp?rev=141292&view=auto ============================================================================== --- llvm/trunk/utils/TableGen/ClangDiagnosticsEmitter.cpp (original) +++ llvm/trunk/utils/TableGen/ClangDiagnosticsEmitter.cpp (removed) @@ -1,378 +0,0 @@ -//=- ClangDiagnosticsEmitter.cpp - Generate Clang diagnostics tables -*- C++ -*- -// -// The LLVM Compiler Infrastructure -// -// This file is distributed under the University of Illinois Open Source -// License. See LICENSE.TXT for details. -// -//===----------------------------------------------------------------------===// -// -// These tablegen backends emit Clang diagnostics tables. -// -//===----------------------------------------------------------------------===// - -#include "ClangDiagnosticsEmitter.h" -#include "llvm/TableGen/Record.h" -#include "llvm/Support/Debug.h" -#include "llvm/Support/Compiler.h" -#include "llvm/ADT/DenseSet.h" -#include "llvm/ADT/StringExtras.h" -#include "llvm/ADT/StringMap.h" -#include "llvm/ADT/SmallString.h" -#include "llvm/ADT/VectorExtras.h" -#include -#include -#include -using namespace llvm; - -//===----------------------------------------------------------------------===// -// Diagnostic category computation code. -//===----------------------------------------------------------------------===// - -namespace { -class DiagGroupParentMap { - RecordKeeper &Records; - std::map > Mapping; -public: - DiagGroupParentMap(RecordKeeper &records) : Records(records) { - std::vector DiagGroups - = Records.getAllDerivedDefinitions("DiagGroup"); - for (unsigned i = 0, e = DiagGroups.size(); i != e; ++i) { - std::vector SubGroups = - DiagGroups[i]->getValueAsListOfDefs("SubGroups"); - for (unsigned j = 0, e = SubGroups.size(); j != e; ++j) - Mapping[SubGroups[j]].push_back(DiagGroups[i]); - } - } - - const std::vector &getParents(const Record *Group) { - return Mapping[Group]; - } -}; -} // end anonymous namespace. - - -static std::string -getCategoryFromDiagGroup(const Record *Group, - DiagGroupParentMap &DiagGroupParents) { - // If the DiagGroup has a category, return it. - std::string CatName = Group->getValueAsString("CategoryName"); - if (!CatName.empty()) return CatName; - - // The diag group may the subgroup of one or more other diagnostic groups, - // check these for a category as well. - const std::vector &Parents = DiagGroupParents.getParents(Group); - for (unsigned i = 0, e = Parents.size(); i != e; ++i) { - CatName = getCategoryFromDiagGroup(Parents[i], DiagGroupParents); - if (!CatName.empty()) return CatName; - } - return ""; -} - -/// getDiagnosticCategory - Return the category that the specified diagnostic -/// lives in. -static std::string getDiagnosticCategory(const Record *R, - DiagGroupParentMap &DiagGroupParents) { - // If the diagnostic is in a group, and that group has a category, use it. - if (DefInit *Group = dynamic_cast(R->getValueInit("Group"))) { - // Check the diagnostic's diag group for a category. - std::string CatName = getCategoryFromDiagGroup(Group->getDef(), - DiagGroupParents); - if (!CatName.empty()) return CatName; - } - - // If the diagnostic itself has a category, get it. - return R->getValueAsString("CategoryName"); -} - -namespace { - class DiagCategoryIDMap { - RecordKeeper &Records; - StringMap CategoryIDs; - std::vector CategoryStrings; - public: - DiagCategoryIDMap(RecordKeeper &records) : Records(records) { - DiagGroupParentMap ParentInfo(Records); - - // The zero'th category is "". - CategoryStrings.push_back(""); - CategoryIDs[""] = 0; - - std::vector Diags = - Records.getAllDerivedDefinitions("Diagnostic"); - for (unsigned i = 0, e = Diags.size(); i != e; ++i) { - std::string Category = getDiagnosticCategory(Diags[i], ParentInfo); - if (Category.empty()) continue; // Skip diags with no category. - - unsigned &ID = CategoryIDs[Category]; - if (ID != 0) continue; // Already seen. - - ID = CategoryStrings.size(); - CategoryStrings.push_back(Category); - } - } - - unsigned getID(StringRef CategoryString) { - return CategoryIDs[CategoryString]; - } - - typedef std::vector::iterator iterator; - iterator begin() { return CategoryStrings.begin(); } - iterator end() { return CategoryStrings.end(); } - }; -} // end anonymous namespace. - - -//===----------------------------------------------------------------------===// -// Warning Tables (.inc file) generation. -//===----------------------------------------------------------------------===// - -void ClangDiagsDefsEmitter::run(raw_ostream &OS) { - // Write the #if guard - if (!Component.empty()) { - std::string ComponentName = UppercaseString(Component); - OS << "#ifdef " << ComponentName << "START\n"; - OS << "__" << ComponentName << "START = DIAG_START_" << ComponentName - << ",\n"; - OS << "#undef " << ComponentName << "START\n"; - OS << "#endif\n\n"; - } - - const std::vector &Diags = - Records.getAllDerivedDefinitions("Diagnostic"); - - DiagCategoryIDMap CategoryIDs(Records); - DiagGroupParentMap DGParentMap(Records); - - for (unsigned i = 0, e = Diags.size(); i != e; ++i) { - const Record &R = *Diags[i]; - // Filter by component. - if (!Component.empty() && Component != R.getValueAsString("Component")) - continue; - - OS << "DIAG(" << R.getName() << ", "; - OS << R.getValueAsDef("Class")->getName(); - OS << ", diag::" << R.getValueAsDef("DefaultMapping")->getName(); - - // Description string. - OS << ", \""; - OS.write_escaped(R.getValueAsString("Text")) << '"'; - - // Warning associated with the diagnostic. - if (DefInit *DI = dynamic_cast(R.getValueInit("Group"))) { - OS << ", \""; - OS.write_escaped(DI->getDef()->getValueAsString("GroupName")) << '"'; - } else { - OS << ", \"\""; - } - - // SFINAE bit - if (R.getValueAsBit("SFINAE")) - OS << ", true"; - else - OS << ", false"; - - // Access control bit - if (R.getValueAsBit("AccessControl")) - OS << ", true"; - else - OS << ", false"; - - // FIXME: This condition is just to avoid temporary revlock, it can be - // removed. - if (R.getValue("WarningNoWerror")) { - // Default warning has no Werror bit. - if (R.getValueAsBit("WarningNoWerror")) - OS << ", true"; - else - OS << ", false"; - - // Default warning show in system header bit. - if (R.getValueAsBit("WarningShowInSystemHeader")) - OS << ", true"; - else - OS << ", false"; - } - - // Category number. - OS << ", " << CategoryIDs.getID(getDiagnosticCategory(&R, DGParentMap)); - - // Brief - OS << ", \""; - OS.write_escaped(R.getValueAsString("Brief")) << '"'; - - // Explanation - OS << ", \""; - OS.write_escaped(R.getValueAsString("Explanation")) << '"'; - OS << ")\n"; - } -} - -//===----------------------------------------------------------------------===// -// Warning Group Tables generation -//===----------------------------------------------------------------------===// - -static std::string getDiagCategoryEnum(llvm::StringRef name) { - if (name.empty()) - return "DiagCat_None"; - llvm::SmallString<256> enumName = llvm::StringRef("DiagCat_"); - for (llvm::StringRef::iterator I = name.begin(), E = name.end(); I != E; ++I) - enumName += isalnum(*I) ? *I : '_'; - return enumName.str(); -} - -namespace { -struct GroupInfo { - std::vector DiagsInGroup; - std::vector SubGroups; - unsigned IDNo; -}; -} // end anonymous namespace. - -void ClangDiagGroupsEmitter::run(raw_ostream &OS) { - // Compute a mapping from a DiagGroup to all of its parents. - DiagGroupParentMap DGParentMap(Records); - - // Invert the 1-[0/1] mapping of diags to group into a one to many mapping of - // groups to diags in the group. - std::map DiagsInGroup; - - std::vector Diags = - Records.getAllDerivedDefinitions("Diagnostic"); - for (unsigned i = 0, e = Diags.size(); i != e; ++i) { - const Record *R = Diags[i]; - DefInit *DI = dynamic_cast(R->getValueInit("Group")); - if (DI == 0) continue; - std::string GroupName = DI->getDef()->getValueAsString("GroupName"); - DiagsInGroup[GroupName].DiagsInGroup.push_back(R); - } - - // Add all DiagGroup's to the DiagsInGroup list to make sure we pick up empty - // groups (these are warnings that GCC supports that clang never produces). - std::vector DiagGroups - = Records.getAllDerivedDefinitions("DiagGroup"); - for (unsigned i = 0, e = DiagGroups.size(); i != e; ++i) { - Record *Group = DiagGroups[i]; - GroupInfo &GI = DiagsInGroup[Group->getValueAsString("GroupName")]; - - std::vector SubGroups = Group->getValueAsListOfDefs("SubGroups"); - for (unsigned j = 0, e = SubGroups.size(); j != e; ++j) - GI.SubGroups.push_back(SubGroups[j]->getValueAsString("GroupName")); - } - - // Assign unique ID numbers to the groups. - unsigned IDNo = 0; - for (std::map::iterator - I = DiagsInGroup.begin(), E = DiagsInGroup.end(); I != E; ++I, ++IDNo) - I->second.IDNo = IDNo; - - // Walk through the groups emitting an array for each diagnostic of the diags - // that are mapped to. - OS << "\n#ifdef GET_DIAG_ARRAYS\n"; - unsigned MaxLen = 0; - for (std::map::iterator - I = DiagsInGroup.begin(), E = DiagsInGroup.end(); I != E; ++I) { - MaxLen = std::max(MaxLen, (unsigned)I->first.size()); - - std::vector &V = I->second.DiagsInGroup; - if (!V.empty()) { - OS << "static const short DiagArray" << I->second.IDNo << "[] = { "; - for (unsigned i = 0, e = V.size(); i != e; ++i) - OS << "diag::" << V[i]->getName() << ", "; - OS << "-1 };\n"; - } - - const std::vector &SubGroups = I->second.SubGroups; - if (!SubGroups.empty()) { - OS << "static const short DiagSubGroup" << I->second.IDNo << "[] = { "; - for (unsigned i = 0, e = SubGroups.size(); i != e; ++i) { - std::map::iterator RI = - DiagsInGroup.find(SubGroups[i]); - assert(RI != DiagsInGroup.end() && "Referenced without existing?"); - OS << RI->second.IDNo << ", "; - } - OS << "-1 };\n"; - } - } - OS << "#endif // GET_DIAG_ARRAYS\n\n"; - - // Emit the table now. - OS << "\n#ifdef GET_DIAG_TABLE\n"; - for (std::map::iterator - I = DiagsInGroup.begin(), E = DiagsInGroup.end(); I != E; ++I) { - // Group option string. - OS << " { "; - OS << I->first.size() << ", "; - OS << "\""; - OS.write_escaped(I->first) << "\"," - << std::string(MaxLen-I->first.size()+1, ' '); - - // Diagnostics in the group. - if (I->second.DiagsInGroup.empty()) - OS << "0, "; - else - OS << "DiagArray" << I->second.IDNo << ", "; - - // Subgroups. - if (I->second.SubGroups.empty()) - OS << 0; - else - OS << "DiagSubGroup" << I->second.IDNo; - OS << " },\n"; - } - OS << "#endif // GET_DIAG_TABLE\n\n"; - - // Emit the category table next. - DiagCategoryIDMap CategoriesByID(Records); - OS << "\n#ifdef GET_CATEGORY_TABLE\n"; - for (DiagCategoryIDMap::iterator I = CategoriesByID.begin(), - E = CategoriesByID.end(); I != E; ++I) - OS << "CATEGORY(\"" << *I << "\", " << getDiagCategoryEnum(*I) << ")\n"; - OS << "#endif // GET_CATEGORY_TABLE\n\n"; -} - -//===----------------------------------------------------------------------===// -// Diagnostic name index generation -//===----------------------------------------------------------------------===// - -namespace { -struct RecordIndexElement -{ - RecordIndexElement() {} - explicit RecordIndexElement(Record const &R): - Name(R.getName()) {} - - std::string Name; -}; - -struct RecordIndexElementSorter : - public std::binary_function { - - bool operator()(RecordIndexElement const &Lhs, - RecordIndexElement const &Rhs) const { - return Lhs.Name < Rhs.Name; - } - -}; - -} // end anonymous namespace. - -void ClangDiagsIndexNameEmitter::run(raw_ostream &OS) { - const std::vector &Diags = - Records.getAllDerivedDefinitions("Diagnostic"); - - std::vector Index; - Index.reserve(Diags.size()); - for (unsigned i = 0, e = Diags.size(); i != e; ++i) { - const Record &R = *(Diags[i]); - Index.push_back(RecordIndexElement(R)); - } - - std::sort(Index.begin(), Index.end(), RecordIndexElementSorter()); - - for (unsigned i = 0, e = Index.size(); i != e; ++i) { - const RecordIndexElement &R = Index[i]; - - OS << "DIAG_NAME_INDEX(" << R.Name << ")\n"; - } -} Removed: llvm/trunk/utils/TableGen/ClangDiagnosticsEmitter.h URL: http://llvm.org/viewvc/llvm-project/llvm/trunk/utils/TableGen/ClangDiagnosticsEmitter.h?rev=141292&view=auto ============================================================================== --- llvm/trunk/utils/TableGen/ClangDiagnosticsEmitter.h (original) +++ llvm/trunk/utils/TableGen/ClangDiagnosticsEmitter.h (removed) @@ -1,54 +0,0 @@ -//===- ClangDiagnosticsEmitter.h - Generate Clang diagnostics tables -*- C++ -*- -// -// The LLVM Compiler Infrastructure -// -// This file is distributed under the University of Illinois Open Source -// License. See LICENSE.TXT for details. -// -//===----------------------------------------------------------------------===// -// -// These tablegen backends emit Clang diagnostics tables. -// -//===----------------------------------------------------------------------===// - -#ifndef CLANGDIAGS_EMITTER_H -#define CLANGDIAGS_EMITTER_H - -#include "llvm/TableGen/TableGenBackend.h" - -namespace llvm { - -/// ClangDiagsDefsEmitter - The top-level class emits .def files containing -/// declarations of Clang diagnostics. -/// -class ClangDiagsDefsEmitter : public TableGenBackend { - RecordKeeper &Records; - const std::string& Component; -public: - explicit ClangDiagsDefsEmitter(RecordKeeper &R, const std::string& component) - : Records(R), Component(component) {} - - // run - Output the .def file contents - void run(raw_ostream &OS); -}; - -class ClangDiagGroupsEmitter : public TableGenBackend { - RecordKeeper &Records; -public: - explicit ClangDiagGroupsEmitter(RecordKeeper &R) : Records(R) {} - - void run(raw_ostream &OS); -}; - -class ClangDiagsIndexNameEmitter : public TableGenBackend { - RecordKeeper &Records; -public: - explicit ClangDiagsIndexNameEmitter(RecordKeeper &R) : Records(R) {} - - void run(raw_ostream &OS); -}; - - -} // End llvm namespace - -#endif Removed: llvm/trunk/utils/TableGen/ClangSACheckersEmitter.cpp URL: http://llvm.org/viewvc/llvm-project/llvm/trunk/utils/TableGen/ClangSACheckersEmitter.cpp?rev=141292&view=auto ============================================================================== --- llvm/trunk/utils/TableGen/ClangSACheckersEmitter.cpp (original) +++ llvm/trunk/utils/TableGen/ClangSACheckersEmitter.cpp (removed) @@ -1,319 +0,0 @@ -//=- ClangSACheckersEmitter.cpp - Generate Clang SA checkers tables -*- C++ -*- -// -// The LLVM Compiler Infrastructure -// -// This file is distributed under the University of Illinois Open Source -// License. See LICENSE.TXT for details. -// -//===----------------------------------------------------------------------===// -// -// This tablegen backend emits Clang Static Analyzer checkers tables. -// -//===----------------------------------------------------------------------===// - -#include "ClangSACheckersEmitter.h" -#include "llvm/TableGen/Record.h" -#include "llvm/ADT/DenseSet.h" -#include -#include -using namespace llvm; - -//===----------------------------------------------------------------------===// -// Static Analyzer Checkers Tables generation -//===----------------------------------------------------------------------===// - -/// \brief True if it is specified hidden or a parent package is specified -/// as hidden, otherwise false. -static bool isHidden(const Record &R) { - if (R.getValueAsBit("Hidden")) - return true; - // Not declared as hidden, check the parent package if it is hidden. - if (DefInit *DI = dynamic_cast(R.getValueInit("ParentPackage"))) - return isHidden(*DI->getDef()); - - return false; -} - -static bool isCheckerNamed(const Record *R) { - return !R->getValueAsString("CheckerName").empty(); -} - -static std::string getPackageFullName(const Record *R); - -static std::string getParentPackageFullName(const Record *R) { - std::string name; - if (DefInit *DI = dynamic_cast(R->getValueInit("ParentPackage"))) - name = getPackageFullName(DI->getDef()); - return name; -} - -static std::string getPackageFullName(const Record *R) { - std::string name = getParentPackageFullName(R); - if (!name.empty()) name += "."; - return name + R->getValueAsString("PackageName"); -} - -static std::string getCheckerFullName(const Record *R) { - std::string name = getParentPackageFullName(R); - if (isCheckerNamed(R)) { - if (!name.empty()) name += "."; - name += R->getValueAsString("CheckerName"); - } - return name; -} - -static std::string getStringValue(const Record &R, StringRef field) { - if (StringInit * - SI = dynamic_cast(R.getValueInit(field))) - return SI->getValue(); - return std::string(); -} - -namespace { -struct GroupInfo { - llvm::DenseSet Checkers; - llvm::DenseSet SubGroups; - bool Hidden; - unsigned Index; - - GroupInfo() : Hidden(false) { } -}; -} - -static void addPackageToCheckerGroup(const Record *package, const Record *group, - llvm::DenseMap &recordGroupMap) { - llvm::DenseSet &checkers = recordGroupMap[package]->Checkers; - for (llvm::DenseSet::iterator - I = checkers.begin(), E = checkers.end(); I != E; ++I) - recordGroupMap[group]->Checkers.insert(*I); - - llvm::DenseSet &subGroups = recordGroupMap[package]->SubGroups; - for (llvm::DenseSet::iterator - I = subGroups.begin(), E = subGroups.end(); I != E; ++I) - addPackageToCheckerGroup(*I, group, recordGroupMap); -} - -void ClangSACheckersEmitter::run(raw_ostream &OS) { - std::vector checkers = Records.getAllDerivedDefinitions("Checker"); - llvm::DenseMap checkerRecIndexMap; - for (unsigned i = 0, e = checkers.size(); i != e; ++i) - checkerRecIndexMap[checkers[i]] = i; - - // Invert the mapping of checkers to package/group into a one to many - // mapping of packages/groups to checkers. - std::map groupInfoByName; - llvm::DenseMap recordGroupMap; - - std::vector packages = Records.getAllDerivedDefinitions("Package"); - for (unsigned i = 0, e = packages.size(); i != e; ++i) { - Record *R = packages[i]; - std::string fullName = getPackageFullName(R); - if (!fullName.empty()) { - GroupInfo &info = groupInfoByName[fullName]; - info.Hidden = isHidden(*R); - recordGroupMap[R] = &info; - } - } - - std::vector - checkerGroups = Records.getAllDerivedDefinitions("CheckerGroup"); - for (unsigned i = 0, e = checkerGroups.size(); i != e; ++i) { - Record *R = checkerGroups[i]; - std::string name = R->getValueAsString("GroupName"); - if (!name.empty()) { - GroupInfo &info = groupInfoByName[name]; - recordGroupMap[R] = &info; - } - } - - for (unsigned i = 0, e = checkers.size(); i != e; ++i) { - Record *R = checkers[i]; - Record *package = 0; - if (DefInit * - DI = dynamic_cast(R->getValueInit("ParentPackage"))) - package = DI->getDef(); - if (!isCheckerNamed(R) && !package) - throw "Checker '" + R->getName() + "' is neither named, nor in a package!"; - - if (isCheckerNamed(R)) { - // Create a pseudo-group to hold this checker. - std::string fullName = getCheckerFullName(R); - GroupInfo &info = groupInfoByName[fullName]; - info.Hidden = R->getValueAsBit("Hidden"); - recordGroupMap[R] = &info; - info.Checkers.insert(R); - } else { - recordGroupMap[package]->Checkers.insert(R); - } - - Record *currR = isCheckerNamed(R) ? R : package; - // Insert the checker and its parent packages into the subgroups set of - // the corresponding parent package. - while (DefInit *DI - = dynamic_cast(currR->getValueInit("ParentPackage"))) { - Record *parentPackage = DI->getDef(); - recordGroupMap[parentPackage]->SubGroups.insert(currR); - currR = parentPackage; - } - // Insert the checker into the set of its group. - if (DefInit *DI = dynamic_cast(R->getValueInit("Group"))) - recordGroupMap[DI->getDef()]->Checkers.insert(R); - } - - // If a package is in group, add all its checkers and its sub-packages - // checkers into the group. - for (unsigned i = 0, e = packages.size(); i != e; ++i) - if (DefInit *DI = dynamic_cast(packages[i]->getValueInit("Group"))) - addPackageToCheckerGroup(packages[i], DI->getDef(), recordGroupMap); - - typedef std::map SortedRecords; - typedef llvm::DenseMap RecToSortIndex; - - SortedRecords sortedGroups; - RecToSortIndex groupToSortIndex; - OS << "\n#ifdef GET_GROUPS\n"; - { - for (unsigned i = 0, e = checkerGroups.size(); i != e; ++i) - sortedGroups[checkerGroups[i]->getValueAsString("GroupName")] - = checkerGroups[i]; - - unsigned sortIndex = 0; - for (SortedRecords::iterator - I = sortedGroups.begin(), E = sortedGroups.end(); I != E; ++I) { - const Record *R = I->second; - - OS << "GROUP(" << "\""; - OS.write_escaped(R->getValueAsString("GroupName")) << "\""; - OS << ")\n"; - - groupToSortIndex[R] = sortIndex++; - } - } - OS << "#endif // GET_GROUPS\n\n"; - - OS << "\n#ifdef GET_PACKAGES\n"; - { - SortedRecords sortedPackages; - for (unsigned i = 0, e = packages.size(); i != e; ++i) - sortedPackages[getPackageFullName(packages[i])] = packages[i]; - - for (SortedRecords::iterator - I = sortedPackages.begin(), E = sortedPackages.end(); I != E; ++I) { - const Record &R = *I->second; - - OS << "PACKAGE(" << "\""; - OS.write_escaped(getPackageFullName(&R)) << "\", "; - // Group index - if (DefInit *DI = dynamic_cast(R.getValueInit("Group"))) - OS << groupToSortIndex[DI->getDef()] << ", "; - else - OS << "-1, "; - // Hidden bit - if (isHidden(R)) - OS << "true"; - else - OS << "false"; - OS << ")\n"; - } - } - OS << "#endif // GET_PACKAGES\n\n"; - - OS << "\n#ifdef GET_CHECKERS\n"; - for (unsigned i = 0, e = checkers.size(); i != e; ++i) { - const Record &R = *checkers[i]; - - OS << "CHECKER(" << "\""; - std::string name; - if (isCheckerNamed(&R)) - name = getCheckerFullName(&R); - OS.write_escaped(name) << "\", "; - OS << R.getName() << ", "; - OS << getStringValue(R, "DescFile") << ", "; - OS << "\""; - OS.write_escaped(getStringValue(R, "HelpText")) << "\", "; - // Group index - if (DefInit *DI = dynamic_cast(R.getValueInit("Group"))) - OS << groupToSortIndex[DI->getDef()] << ", "; - else - OS << "-1, "; - // Hidden bit - if (isHidden(R)) - OS << "true"; - else - OS << "false"; - OS << ")\n"; - } - OS << "#endif // GET_CHECKERS\n\n"; - - unsigned index = 0; - for (std::map::iterator - I = groupInfoByName.begin(), E = groupInfoByName.end(); I != E; ++I) - I->second.Index = index++; - - // Walk through the packages/groups/checkers emitting an array for each - // set of checkers and an array for each set of subpackages. - - OS << "\n#ifdef GET_MEMBER_ARRAYS\n"; - unsigned maxLen = 0; - for (std::map::iterator - I = groupInfoByName.begin(), E = groupInfoByName.end(); I != E; ++I) { - maxLen = std::max(maxLen, (unsigned)I->first.size()); - - llvm::DenseSet &checkers = I->second.Checkers; - if (!checkers.empty()) { - OS << "static const short CheckerArray" << I->second.Index << "[] = { "; - // Make the output order deterministic. - std::map sorted; - for (llvm::DenseSet::iterator - I = checkers.begin(), E = checkers.end(); I != E; ++I) - sorted[(*I)->getID()] = *I; - - for (std::map::iterator - I = sorted.begin(), E = sorted.end(); I != E; ++I) - OS << checkerRecIndexMap[I->second] << ", "; - OS << "-1 };\n"; - } - - llvm::DenseSet &subGroups = I->second.SubGroups; - if (!subGroups.empty()) { - OS << "static const short SubPackageArray" << I->second.Index << "[] = { "; - // Make the output order deterministic. - std::map sorted; - for (llvm::DenseSet::iterator - I = subGroups.begin(), E = subGroups.end(); I != E; ++I) - sorted[(*I)->getID()] = *I; - - for (std::map::iterator - I = sorted.begin(), E = sorted.end(); I != E; ++I) { - OS << recordGroupMap[I->second]->Index << ", "; - } - OS << "-1 };\n"; - } - } - OS << "#endif // GET_MEMBER_ARRAYS\n\n"; - - OS << "\n#ifdef GET_CHECKNAME_TABLE\n"; - for (std::map::iterator - I = groupInfoByName.begin(), E = groupInfoByName.end(); I != E; ++I) { - // Group option string. - OS << " { \""; - OS.write_escaped(I->first) << "\"," - << std::string(maxLen-I->first.size()+1, ' '); - - if (I->second.Checkers.empty()) - OS << "0, "; - else - OS << "CheckerArray" << I->second.Index << ", "; - - // Subgroups. - if (I->second.SubGroups.empty()) - OS << "0, "; - else - OS << "SubPackageArray" << I->second.Index << ", "; - - OS << (I->second.Hidden ? "true" : "false"); - - OS << " },\n"; - } - OS << "#endif // GET_CHECKNAME_TABLE\n\n"; -} Removed: llvm/trunk/utils/TableGen/ClangSACheckersEmitter.h URL: http://llvm.org/viewvc/llvm-project/llvm/trunk/utils/TableGen/ClangSACheckersEmitter.h?rev=141292&view=auto ============================================================================== --- llvm/trunk/utils/TableGen/ClangSACheckersEmitter.h (original) +++ llvm/trunk/utils/TableGen/ClangSACheckersEmitter.h (removed) @@ -1,31 +0,0 @@ -//===- ClangSACheckersEmitter.h - Generate Clang SA checkers tables -*- C++ -*- -// -// The LLVM Compiler Infrastructure -// -// This file is distributed under the University of Illinois Open Source -// License. See LICENSE.TXT for details. -// -//===----------------------------------------------------------------------===// -// -// This tablegen backend emits Clang Static Analyzer checkers tables. -// -//===----------------------------------------------------------------------===// - -#ifndef CLANGSACHECKERS_EMITTER_H -#define CLANGSACHECKERS_EMITTER_H - -#include "llvm/TableGen/TableGenBackend.h" - -namespace llvm { - -class ClangSACheckersEmitter : public TableGenBackend { - RecordKeeper &Records; -public: - explicit ClangSACheckersEmitter(RecordKeeper &R) : Records(R) {} - - void run(raw_ostream &OS); -}; - -} // End llvm namespace - -#endif Removed: llvm/trunk/utils/TableGen/NeonEmitter.cpp URL: http://llvm.org/viewvc/llvm-project/llvm/trunk/utils/TableGen/NeonEmitter.cpp?rev=141292&view=auto ============================================================================== --- llvm/trunk/utils/TableGen/NeonEmitter.cpp (original) +++ llvm/trunk/utils/TableGen/NeonEmitter.cpp (removed) @@ -1,1551 +0,0 @@ -//===- NeonEmitter.cpp - Generate arm_neon.h for use with clang -*- C++ -*-===// -// -// The LLVM Compiler Infrastructure -// -// This file is distributed under the University of Illinois Open Source -// License. See LICENSE.TXT for details. -// -//===----------------------------------------------------------------------===// -// -// This tablegen backend is responsible for emitting arm_neon.h, which includes -// a declaration and definition of each function specified by the ARM NEON -// compiler interface. See ARM document DUI0348B. -// -// Each NEON instruction is implemented in terms of 1 or more functions which -// are suffixed with the element type of the input vectors. Functions may be -// implemented in terms of generic vector operations such as +, *, -, etc. or -// by calling a __builtin_-prefixed function which will be handled by clang's -// CodeGen library. -// -// Additional validation code can be generated by this file when runHeader() is -// called, rather than the normal run() entry point. A complete set of tests -// for Neon intrinsics can be generated by calling the runTests() entry point. -// -//===----------------------------------------------------------------------===// - -#include "NeonEmitter.h" -#include "llvm/TableGen/Error.h" -#include "llvm/ADT/SmallString.h" -#include "llvm/ADT/SmallVector.h" -#include "llvm/ADT/StringExtras.h" -#include - -using namespace llvm; - -/// ParseTypes - break down a string such as "fQf" into a vector of StringRefs, -/// which each StringRef representing a single type declared in the string. -/// for "fQf" we would end up with 2 StringRefs, "f", and "Qf", representing -/// 2xfloat and 4xfloat respectively. -static void ParseTypes(Record *r, std::string &s, - SmallVectorImpl &TV) { - const char *data = s.data(); - int len = 0; - - for (unsigned i = 0, e = s.size(); i != e; ++i, ++len) { - if (data[len] == 'P' || data[len] == 'Q' || data[len] == 'U') - continue; - - switch (data[len]) { - case 'c': - case 's': - case 'i': - case 'l': - case 'h': - case 'f': - break; - default: - throw TGError(r->getLoc(), - "Unexpected letter: " + std::string(data + len, 1)); - break; - } - TV.push_back(StringRef(data, len + 1)); - data += len + 1; - len = -1; - } -} - -/// Widen - Convert a type code into the next wider type. char -> short, -/// short -> int, etc. -static char Widen(const char t) { - switch (t) { - case 'c': - return 's'; - case 's': - return 'i'; - case 'i': - return 'l'; - case 'h': - return 'f'; - default: throw "unhandled type in widen!"; - } - return '\0'; -} - -/// Narrow - Convert a type code into the next smaller type. short -> char, -/// float -> half float, etc. -static char Narrow(const char t) { - switch (t) { - case 's': - return 'c'; - case 'i': - return 's'; - case 'l': - return 'i'; - case 'f': - return 'h'; - default: throw "unhandled type in narrow!"; - } - return '\0'; -} - -/// For a particular StringRef, return the base type code, and whether it has -/// the quad-vector, polynomial, or unsigned modifiers set. -static char ClassifyType(StringRef ty, bool &quad, bool &poly, bool &usgn) { - unsigned off = 0; - - // remember quad. - if (ty[off] == 'Q') { - quad = true; - ++off; - } - - // remember poly. - if (ty[off] == 'P') { - poly = true; - ++off; - } - - // remember unsigned. - if (ty[off] == 'U') { - usgn = true; - ++off; - } - - // base type to get the type string for. - return ty[off]; -} - -/// ModType - Transform a type code and its modifiers based on a mod code. The -/// mod code definitions may be found at the top of arm_neon.td. -static char ModType(const char mod, char type, bool &quad, bool &poly, - bool &usgn, bool &scal, bool &cnst, bool &pntr) { - switch (mod) { - case 't': - if (poly) { - poly = false; - usgn = true; - } - break; - case 'u': - usgn = true; - poly = false; - if (type == 'f') - type = 'i'; - break; - case 'x': - usgn = false; - poly = false; - if (type == 'f') - type = 'i'; - break; - case 'f': - if (type == 'h') - quad = true; - type = 'f'; - usgn = false; - break; - case 'g': - quad = false; - break; - case 'w': - type = Widen(type); - quad = true; - break; - case 'n': - type = Widen(type); - break; - case 'i': - type = 'i'; - scal = true; - break; - case 'l': - type = 'l'; - scal = true; - usgn = true; - break; - case 's': - case 'a': - scal = true; - break; - case 'k': - quad = true; - break; - case 'c': - cnst = true; - case 'p': - pntr = true; - scal = true; - break; - case 'h': - type = Narrow(type); - if (type == 'h') - quad = false; - break; - case 'e': - type = Narrow(type); - usgn = true; - break; - default: - break; - } - return type; -} - -/// TypeString - for a modifier and type, generate the name of the typedef for -/// that type. QUc -> uint8x8_t. -static std::string TypeString(const char mod, StringRef typestr) { - bool quad = false; - bool poly = false; - bool usgn = false; - bool scal = false; - bool cnst = false; - bool pntr = false; - - if (mod == 'v') - return "void"; - if (mod == 'i') - return "int"; - - // base type to get the type string for. - char type = ClassifyType(typestr, quad, poly, usgn); - - // Based on the modifying character, change the type and width if necessary. - type = ModType(mod, type, quad, poly, usgn, scal, cnst, pntr); - - SmallString<128> s; - - if (usgn) - s.push_back('u'); - - switch (type) { - case 'c': - s += poly ? "poly8" : "int8"; - if (scal) - break; - s += quad ? "x16" : "x8"; - break; - case 's': - s += poly ? "poly16" : "int16"; - if (scal) - break; - s += quad ? "x8" : "x4"; - break; - case 'i': - s += "int32"; - if (scal) - break; - s += quad ? "x4" : "x2"; - break; - case 'l': - s += "int64"; - if (scal) - break; - s += quad ? "x2" : "x1"; - break; - case 'h': - s += "float16"; - if (scal) - break; - s += quad ? "x8" : "x4"; - break; - case 'f': - s += "float32"; - if (scal) - break; - s += quad ? "x4" : "x2"; - break; - default: - throw "unhandled type!"; - break; - } - - if (mod == '2') - s += "x2"; - if (mod == '3') - s += "x3"; - if (mod == '4') - s += "x4"; - - // Append _t, finishing the type string typedef type. - s += "_t"; - - if (cnst) - s += " const"; - - if (pntr) - s += " *"; - - return s.str(); -} - -/// BuiltinTypeString - for a modifier and type, generate the clang -/// BuiltinsARM.def prototype code for the function. See the top of clang's -/// Builtins.def for a description of the type strings. -static std::string BuiltinTypeString(const char mod, StringRef typestr, - ClassKind ck, bool ret) { - bool quad = false; - bool poly = false; - bool usgn = false; - bool scal = false; - bool cnst = false; - bool pntr = false; - - if (mod == 'v') - return "v"; // void - if (mod == 'i') - return "i"; // int - - // base type to get the type string for. - char type = ClassifyType(typestr, quad, poly, usgn); - - // Based on the modifying character, change the type and width if necessary. - type = ModType(mod, type, quad, poly, usgn, scal, cnst, pntr); - - // All pointers are void* pointers. Change type to 'v' now. - if (pntr) { - usgn = false; - poly = false; - type = 'v'; - } - // Treat half-float ('h') types as unsigned short ('s') types. - if (type == 'h') { - type = 's'; - usgn = true; - } - usgn = usgn | poly | ((ck == ClassI || ck == ClassW) && scal && type != 'f'); - - if (scal) { - SmallString<128> s; - - if (usgn) - s.push_back('U'); - else if (type == 'c') - s.push_back('S'); // make chars explicitly signed - - if (type == 'l') // 64-bit long - s += "LLi"; - else - s.push_back(type); - - if (cnst) - s.push_back('C'); - if (pntr) - s.push_back('*'); - return s.str(); - } - - // Since the return value must be one type, return a vector type of the - // appropriate width which we will bitcast. An exception is made for - // returning structs of 2, 3, or 4 vectors which are returned in a sret-like - // fashion, storing them to a pointer arg. - if (ret) { - if (mod >= '2' && mod <= '4') - return "vv*"; // void result with void* first argument - if (mod == 'f' || (ck != ClassB && type == 'f')) - return quad ? "V4f" : "V2f"; - if (ck != ClassB && type == 's') - return quad ? "V8s" : "V4s"; - if (ck != ClassB && type == 'i') - return quad ? "V4i" : "V2i"; - if (ck != ClassB && type == 'l') - return quad ? "V2LLi" : "V1LLi"; - - return quad ? "V16Sc" : "V8Sc"; - } - - // Non-return array types are passed as individual vectors. - if (mod == '2') - return quad ? "V16ScV16Sc" : "V8ScV8Sc"; - if (mod == '3') - return quad ? "V16ScV16ScV16Sc" : "V8ScV8ScV8Sc"; - if (mod == '4') - return quad ? "V16ScV16ScV16ScV16Sc" : "V8ScV8ScV8ScV8Sc"; - - if (mod == 'f' || (ck != ClassB && type == 'f')) - return quad ? "V4f" : "V2f"; - if (ck != ClassB && type == 's') - return quad ? "V8s" : "V4s"; - if (ck != ClassB && type == 'i') - return quad ? "V4i" : "V2i"; - if (ck != ClassB && type == 'l') - return quad ? "V2LLi" : "V1LLi"; - - return quad ? "V16Sc" : "V8Sc"; -} - -/// MangleName - Append a type or width suffix to a base neon function name, -/// and insert a 'q' in the appropriate location if the operation works on -/// 128b rather than 64b. E.g. turn "vst2_lane" into "vst2q_lane_f32", etc. -static std::string MangleName(const std::string &name, StringRef typestr, - ClassKind ck) { - if (name == "vcvt_f32_f16") - return name; - - bool quad = false; - bool poly = false; - bool usgn = false; - char type = ClassifyType(typestr, quad, poly, usgn); - - std::string s = name; - - switch (type) { - case 'c': - switch (ck) { - case ClassS: s += poly ? "_p8" : usgn ? "_u8" : "_s8"; break; - case ClassI: s += "_i8"; break; - case ClassW: s += "_8"; break; - default: break; - } - break; - case 's': - switch (ck) { - case ClassS: s += poly ? "_p16" : usgn ? "_u16" : "_s16"; break; - case ClassI: s += "_i16"; break; - case ClassW: s += "_16"; break; - default: break; - } - break; - case 'i': - switch (ck) { - case ClassS: s += usgn ? "_u32" : "_s32"; break; - case ClassI: s += "_i32"; break; - case ClassW: s += "_32"; break; - default: break; - } - break; - case 'l': - switch (ck) { - case ClassS: s += usgn ? "_u64" : "_s64"; break; - case ClassI: s += "_i64"; break; - case ClassW: s += "_64"; break; - default: break; - } - break; - case 'h': - switch (ck) { - case ClassS: - case ClassI: s += "_f16"; break; - case ClassW: s += "_16"; break; - default: break; - } - break; - case 'f': - switch (ck) { - case ClassS: - case ClassI: s += "_f32"; break; - case ClassW: s += "_32"; break; - default: break; - } - break; - default: - throw "unhandled type!"; - break; - } - if (ck == ClassB) - s += "_v"; - - // Insert a 'q' before the first '_' character so that it ends up before - // _lane or _n on vector-scalar operations. - if (quad) { - size_t pos = s.find('_'); - s = s.insert(pos, "q"); - } - return s; -} - -/// UseMacro - Examine the prototype string to determine if the intrinsic -/// should be defined as a preprocessor macro instead of an inline function. -static bool UseMacro(const std::string &proto) { - // If this builtin takes an immediate argument, we need to #define it rather - // than use a standard declaration, so that SemaChecking can range check - // the immediate passed by the user. - if (proto.find('i') != std::string::npos) - return true; - - // Pointer arguments need to use macros to avoid hiding aligned attributes - // from the pointer type. - if (proto.find('p') != std::string::npos || - proto.find('c') != std::string::npos) - return true; - - return false; -} - -/// MacroArgUsedDirectly - Return true if argument i for an intrinsic that is -/// defined as a macro should be accessed directly instead of being first -/// assigned to a local temporary. -static bool MacroArgUsedDirectly(const std::string &proto, unsigned i) { - // True for constant ints (i), pointers (p) and const pointers (c). - return (proto[i] == 'i' || proto[i] == 'p' || proto[i] == 'c'); -} - -// Generate the string "(argtype a, argtype b, ...)" -static std::string GenArgs(const std::string &proto, StringRef typestr) { - bool define = UseMacro(proto); - char arg = 'a'; - - std::string s; - s += "("; - - for (unsigned i = 1, e = proto.size(); i != e; ++i, ++arg) { - if (define) { - // Some macro arguments are used directly instead of being assigned - // to local temporaries; prepend an underscore prefix to make their - // names consistent with the local temporaries. - if (MacroArgUsedDirectly(proto, i)) - s += "__"; - } else { - s += TypeString(proto[i], typestr) + " __"; - } - s.push_back(arg); - if ((i + 1) < e) - s += ", "; - } - - s += ")"; - return s; -} - -// Macro arguments are not type-checked like inline function arguments, so -// assign them to local temporaries to get the right type checking. -static std::string GenMacroLocals(const std::string &proto, StringRef typestr) { - char arg = 'a'; - std::string s; - bool generatedLocal = false; - - for (unsigned i = 1, e = proto.size(); i != e; ++i, ++arg) { - // Do not create a temporary for an immediate argument. - // That would defeat the whole point of using a macro! - // FIXME: For other (non-immediate) arguments that are used directly, a - // local temporary (or some other method) is still needed to get the - // correct type checking, even if that temporary is not used for anything. - // This is omitted for now because it turns out the the use of - // "__extension__" in the macro disables any warnings from the pointer - // assignment. - if (MacroArgUsedDirectly(proto, i)) - continue; - generatedLocal = true; - - s += TypeString(proto[i], typestr) + " __"; - s.push_back(arg); - s += " = ("; - s.push_back(arg); - s += "); "; - } - - if (generatedLocal) - s += "\\\n "; - return s; -} - -// Use the vmovl builtin to sign-extend or zero-extend a vector. -static std::string Extend(StringRef typestr, const std::string &a) { - std::string s; - s = MangleName("vmovl", typestr, ClassS); - s += "(" + a + ")"; - return s; -} - -static std::string Duplicate(unsigned nElts, StringRef typestr, - const std::string &a) { - std::string s; - - s = "(" + TypeString('d', typestr) + "){ "; - for (unsigned i = 0; i != nElts; ++i) { - s += a; - if ((i + 1) < nElts) - s += ", "; - } - s += " }"; - - return s; -} - -static std::string SplatLane(unsigned nElts, const std::string &vec, - const std::string &lane) { - std::string s = "__builtin_shufflevector(" + vec + ", " + vec; - for (unsigned i = 0; i < nElts; ++i) - s += ", " + lane; - s += ")"; - return s; -} - -static unsigned GetNumElements(StringRef typestr, bool &quad) { - quad = false; - bool dummy = false; - char type = ClassifyType(typestr, quad, dummy, dummy); - unsigned nElts = 0; - switch (type) { - case 'c': nElts = 8; break; - case 's': nElts = 4; break; - case 'i': nElts = 2; break; - case 'l': nElts = 1; break; - case 'h': nElts = 4; break; - case 'f': nElts = 2; break; - default: - throw "unhandled type!"; - break; - } - if (quad) nElts <<= 1; - return nElts; -} - -// Generate the definition for this intrinsic, e.g. "a + b" for OpAdd. -static std::string GenOpString(OpKind op, const std::string &proto, - StringRef typestr) { - bool quad; - unsigned nElts = GetNumElements(typestr, quad); - bool define = UseMacro(proto); - - std::string ts = TypeString(proto[0], typestr); - std::string s; - if (!define) { - s = "return "; - } - - switch(op) { - case OpAdd: - s += "__a + __b;"; - break; - case OpAddl: - s += Extend(typestr, "__a") + " + " + Extend(typestr, "__b") + ";"; - break; - case OpAddw: - s += "__a + " + Extend(typestr, "__b") + ";"; - break; - case OpSub: - s += "__a - __b;"; - break; - case OpSubl: - s += Extend(typestr, "__a") + " - " + Extend(typestr, "__b") + ";"; - break; - case OpSubw: - s += "__a - " + Extend(typestr, "__b") + ";"; - break; - case OpMulN: - s += "__a * " + Duplicate(nElts, typestr, "__b") + ";"; - break; - case OpMulLane: - s += "__a * " + SplatLane(nElts, "__b", "__c") + ";"; - break; - case OpMul: - s += "__a * __b;"; - break; - case OpMullLane: - s += MangleName("vmull", typestr, ClassS) + "(__a, " + - SplatLane(nElts, "__b", "__c") + ");"; - break; - case OpMlaN: - s += "__a + (__b * " + Duplicate(nElts, typestr, "__c") + ");"; - break; - case OpMlaLane: - s += "__a + (__b * " + SplatLane(nElts, "__c", "__d") + ");"; - break; - case OpMla: - s += "__a + (__b * __c);"; - break; - case OpMlalN: - s += "__a + " + MangleName("vmull", typestr, ClassS) + "(__b, " + - Duplicate(nElts, typestr, "__c") + ");"; - break; - case OpMlalLane: - s += "__a + " + MangleName("vmull", typestr, ClassS) + "(__b, " + - SplatLane(nElts, "__c", "__d") + ");"; - break; - case OpMlal: - s += "__a + " + MangleName("vmull", typestr, ClassS) + "(__b, __c);"; - break; - case OpMlsN: - s += "__a - (__b * " + Duplicate(nElts, typestr, "__c") + ");"; - break; - case OpMlsLane: - s += "__a - (__b * " + SplatLane(nElts, "__c", "__d") + ");"; - break; - case OpMls: - s += "__a - (__b * __c);"; - break; - case OpMlslN: - s += "__a - " + MangleName("vmull", typestr, ClassS) + "(__b, " + - Duplicate(nElts, typestr, "__c") + ");"; - break; - case OpMlslLane: - s += "__a - " + MangleName("vmull", typestr, ClassS) + "(__b, " + - SplatLane(nElts, "__c", "__d") + ");"; - break; - case OpMlsl: - s += "__a - " + MangleName("vmull", typestr, ClassS) + "(__b, __c);"; - break; - case OpQDMullLane: - s += MangleName("vqdmull", typestr, ClassS) + "(__a, " + - SplatLane(nElts, "__b", "__c") + ");"; - break; - case OpQDMlalLane: - s += MangleName("vqdmlal", typestr, ClassS) + "(__a, __b, " + - SplatLane(nElts, "__c", "__d") + ");"; - break; - case OpQDMlslLane: - s += MangleName("vqdmlsl", typestr, ClassS) + "(__a, __b, " + - SplatLane(nElts, "__c", "__d") + ");"; - break; - case OpQDMulhLane: - s += MangleName("vqdmulh", typestr, ClassS) + "(__a, " + - SplatLane(nElts, "__b", "__c") + ");"; - break; - case OpQRDMulhLane: - s += MangleName("vqrdmulh", typestr, ClassS) + "(__a, " + - SplatLane(nElts, "__b", "__c") + ");"; - break; - case OpEq: - s += "(" + ts + ")(__a == __b);"; - break; - case OpGe: - s += "(" + ts + ")(__a >= __b);"; - break; - case OpLe: - s += "(" + ts + ")(__a <= __b);"; - break; - case OpGt: - s += "(" + ts + ")(__a > __b);"; - break; - case OpLt: - s += "(" + ts + ")(__a < __b);"; - break; - case OpNeg: - s += " -__a;"; - break; - case OpNot: - s += " ~__a;"; - break; - case OpAnd: - s += "__a & __b;"; - break; - case OpOr: - s += "__a | __b;"; - break; - case OpXor: - s += "__a ^ __b;"; - break; - case OpAndNot: - s += "__a & ~__b;"; - break; - case OpOrNot: - s += "__a | ~__b;"; - break; - case OpCast: - s += "(" + ts + ")__a;"; - break; - case OpConcat: - s += "(" + ts + ")__builtin_shufflevector((int64x1_t)__a"; - s += ", (int64x1_t)__b, 0, 1);"; - break; - case OpHi: - s += "(" + ts + - ")__builtin_shufflevector((int64x2_t)__a, (int64x2_t)__a, 1);"; - break; - case OpLo: - s += "(" + ts + - ")__builtin_shufflevector((int64x2_t)__a, (int64x2_t)__a, 0);"; - break; - case OpDup: - s += Duplicate(nElts, typestr, "__a") + ";"; - break; - case OpDupLane: - s += SplatLane(nElts, "__a", "__b") + ";"; - break; - case OpSelect: - // ((0 & 1) | (~0 & 2)) - s += "(" + ts + ")"; - ts = TypeString(proto[1], typestr); - s += "((__a & (" + ts + ")__b) | "; - s += "(~__a & (" + ts + ")__c));"; - break; - case OpRev16: - s += "__builtin_shufflevector(__a, __a"; - for (unsigned i = 2; i <= nElts; i += 2) - for (unsigned j = 0; j != 2; ++j) - s += ", " + utostr(i - j - 1); - s += ");"; - break; - case OpRev32: { - unsigned WordElts = nElts >> (1 + (int)quad); - s += "__builtin_shufflevector(__a, __a"; - for (unsigned i = WordElts; i <= nElts; i += WordElts) - for (unsigned j = 0; j != WordElts; ++j) - s += ", " + utostr(i - j - 1); - s += ");"; - break; - } - case OpRev64: { - unsigned DblWordElts = nElts >> (int)quad; - s += "__builtin_shufflevector(__a, __a"; - for (unsigned i = DblWordElts; i <= nElts; i += DblWordElts) - for (unsigned j = 0; j != DblWordElts; ++j) - s += ", " + utostr(i - j - 1); - s += ");"; - break; - } - case OpAbdl: { - std::string abd = MangleName("vabd", typestr, ClassS) + "(__a, __b)"; - if (typestr[0] != 'U') { - // vabd results are always unsigned and must be zero-extended. - std::string utype = "U" + typestr.str(); - s += "(" + TypeString(proto[0], typestr) + ")"; - abd = "(" + TypeString('d', utype) + ")" + abd; - s += Extend(utype, abd) + ";"; - } else { - s += Extend(typestr, abd) + ";"; - } - break; - } - case OpAba: - s += "__a + " + MangleName("vabd", typestr, ClassS) + "(__b, __c);"; - break; - case OpAbal: { - s += "__a + "; - std::string abd = MangleName("vabd", typestr, ClassS) + "(__b, __c)"; - if (typestr[0] != 'U') { - // vabd results are always unsigned and must be zero-extended. - std::string utype = "U" + typestr.str(); - s += "(" + TypeString(proto[0], typestr) + ")"; - abd = "(" + TypeString('d', utype) + ")" + abd; - s += Extend(utype, abd) + ";"; - } else { - s += Extend(typestr, abd) + ";"; - } - break; - } - default: - throw "unknown OpKind!"; - break; - } - return s; -} - -static unsigned GetNeonEnum(const std::string &proto, StringRef typestr) { - unsigned mod = proto[0]; - unsigned ret = 0; - - if (mod == 'v' || mod == 'f') - mod = proto[1]; - - bool quad = false; - bool poly = false; - bool usgn = false; - bool scal = false; - bool cnst = false; - bool pntr = false; - - // Base type to get the type string for. - char type = ClassifyType(typestr, quad, poly, usgn); - - // Based on the modifying character, change the type and width if necessary. - type = ModType(mod, type, quad, poly, usgn, scal, cnst, pntr); - - if (usgn) - ret |= 0x08; - if (quad && proto[1] != 'g') - ret |= 0x10; - - switch (type) { - case 'c': - ret |= poly ? 5 : 0; - break; - case 's': - ret |= poly ? 6 : 1; - break; - case 'i': - ret |= 2; - break; - case 'l': - ret |= 3; - break; - case 'h': - ret |= 7; - break; - case 'f': - ret |= 4; - break; - default: - throw "unhandled type!"; - break; - } - return ret; -} - -// Generate the definition for this intrinsic, e.g. __builtin_neon_cls(a) -static std::string GenBuiltin(const std::string &name, const std::string &proto, - StringRef typestr, ClassKind ck) { - std::string s; - - // If this builtin returns a struct 2, 3, or 4 vectors, pass it as an implicit - // sret-like argument. - bool sret = (proto[0] >= '2' && proto[0] <= '4'); - - bool define = UseMacro(proto); - - // Check if the prototype has a scalar operand with the type of the vector - // elements. If not, bitcasting the args will take care of arg checking. - // The actual signedness etc. will be taken care of with special enums. - if (proto.find('s') == std::string::npos) - ck = ClassB; - - if (proto[0] != 'v') { - std::string ts = TypeString(proto[0], typestr); - - if (define) { - if (sret) - s += ts + " r; "; - else - s += "(" + ts + ")"; - } else if (sret) { - s += ts + " r; "; - } else { - s += "return (" + ts + ")"; - } - } - - bool splat = proto.find('a') != std::string::npos; - - s += "__builtin_neon_"; - if (splat) { - // Call the non-splat builtin: chop off the "_n" suffix from the name. - std::string vname(name, 0, name.size()-2); - s += MangleName(vname, typestr, ck); - } else { - s += MangleName(name, typestr, ck); - } - s += "("; - - // Pass the address of the return variable as the first argument to sret-like - // builtins. - if (sret) - s += "&r, "; - - char arg = 'a'; - for (unsigned i = 1, e = proto.size(); i != e; ++i, ++arg) { - std::string args = std::string(&arg, 1); - - // Use the local temporaries instead of the macro arguments. - args = "__" + args; - - bool argQuad = false; - bool argPoly = false; - bool argUsgn = false; - bool argScalar = false; - bool dummy = false; - char argType = ClassifyType(typestr, argQuad, argPoly, argUsgn); - argType = ModType(proto[i], argType, argQuad, argPoly, argUsgn, argScalar, - dummy, dummy); - - // Handle multiple-vector values specially, emitting each subvector as an - // argument to the __builtin. - if (proto[i] >= '2' && proto[i] <= '4') { - // Check if an explicit cast is needed. - if (argType != 'c' || argPoly || argUsgn) - args = (argQuad ? "(int8x16_t)" : "(int8x8_t)") + args; - - for (unsigned vi = 0, ve = proto[i] - '0'; vi != ve; ++vi) { - s += args + ".val[" + utostr(vi) + "]"; - if ((vi + 1) < ve) - s += ", "; - } - if ((i + 1) < e) - s += ", "; - - continue; - } - - if (splat && (i + 1) == e) - args = Duplicate(GetNumElements(typestr, argQuad), typestr, args); - - // Check if an explicit cast is needed. - if ((splat || !argScalar) && - ((ck == ClassB && argType != 'c') || argPoly || argUsgn)) { - std::string argTypeStr = "c"; - if (ck != ClassB) - argTypeStr = argType; - if (argQuad) - argTypeStr = "Q" + argTypeStr; - args = "(" + TypeString('d', argTypeStr) + ")" + args; - } - - s += args; - if ((i + 1) < e) - s += ", "; - } - - // Extra constant integer to hold type class enum for this function, e.g. s8 - if (ck == ClassB) - s += ", " + utostr(GetNeonEnum(proto, typestr)); - - s += ");"; - - if (proto[0] != 'v' && sret) { - if (define) - s += " r;"; - else - s += " return r;"; - } - return s; -} - -static std::string GenBuiltinDef(const std::string &name, - const std::string &proto, - StringRef typestr, ClassKind ck) { - std::string s("BUILTIN(__builtin_neon_"); - - // If all types are the same size, bitcasting the args will take care - // of arg checking. The actual signedness etc. will be taken care of with - // special enums. - if (proto.find('s') == std::string::npos) - ck = ClassB; - - s += MangleName(name, typestr, ck); - s += ", \""; - - for (unsigned i = 0, e = proto.size(); i != e; ++i) - s += BuiltinTypeString(proto[i], typestr, ck, i == 0); - - // Extra constant integer to hold type class enum for this function, e.g. s8 - if (ck == ClassB) - s += "i"; - - s += "\", \"n\")"; - return s; -} - -static std::string GenIntrinsic(const std::string &name, - const std::string &proto, - StringRef outTypeStr, StringRef inTypeStr, - OpKind kind, ClassKind classKind) { - assert(!proto.empty() && ""); - bool define = UseMacro(proto); - std::string s; - - // static always inline + return type - if (define) - s += "#define "; - else - s += "__ai " + TypeString(proto[0], outTypeStr) + " "; - - // Function name with type suffix - std::string mangledName = MangleName(name, outTypeStr, ClassS); - if (outTypeStr != inTypeStr) { - // If the input type is different (e.g., for vreinterpret), append a suffix - // for the input type. String off a "Q" (quad) prefix so that MangleName - // does not insert another "q" in the name. - unsigned typeStrOff = (inTypeStr[0] == 'Q' ? 1 : 0); - StringRef inTypeNoQuad = inTypeStr.substr(typeStrOff); - mangledName = MangleName(mangledName, inTypeNoQuad, ClassS); - } - s += mangledName; - - // Function arguments - s += GenArgs(proto, inTypeStr); - - // Definition. - if (define) { - s += " __extension__ ({ \\\n "; - s += GenMacroLocals(proto, inTypeStr); - } else { - s += " { \\\n "; - } - - if (kind != OpNone) - s += GenOpString(kind, proto, outTypeStr); - else - s += GenBuiltin(name, proto, outTypeStr, classKind); - if (define) - s += " })"; - else - s += " }"; - s += "\n"; - return s; -} - -/// run - Read the records in arm_neon.td and output arm_neon.h. arm_neon.h -/// is comprised of type definitions and function declarations. -void NeonEmitter::run(raw_ostream &OS) { - OS << - "/*===---- arm_neon.h - ARM Neon intrinsics ------------------------------" - "---===\n" - " *\n" - " * Permission is hereby granted, free of charge, to any person obtaining " - "a copy\n" - " * of this software and associated documentation files (the \"Software\")," - " to deal\n" - " * in the Software without restriction, including without limitation the " - "rights\n" - " * to use, copy, modify, merge, publish, distribute, sublicense, " - "and/or sell\n" - " * copies of the Software, and to permit persons to whom the Software is\n" - " * furnished to do so, subject to the following conditions:\n" - " *\n" - " * The above copyright notice and this permission notice shall be " - "included in\n" - " * all copies or substantial portions of the Software.\n" - " *\n" - " * THE SOFTWARE IS PROVIDED \"AS IS\", WITHOUT WARRANTY OF ANY KIND, " - "EXPRESS OR\n" - " * IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF " - "MERCHANTABILITY,\n" - " * FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT " - "SHALL THE\n" - " * AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR " - "OTHER\n" - " * LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, " - "ARISING FROM,\n" - " * OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER " - "DEALINGS IN\n" - " * THE SOFTWARE.\n" - " *\n" - " *===--------------------------------------------------------------------" - "---===\n" - " */\n\n"; - - OS << "#ifndef __ARM_NEON_H\n"; - OS << "#define __ARM_NEON_H\n\n"; - - OS << "#ifndef __ARM_NEON__\n"; - OS << "#error \"NEON support not enabled\"\n"; - OS << "#endif\n\n"; - - OS << "#include \n\n"; - - // Emit NEON-specific scalar typedefs. - OS << "typedef float float32_t;\n"; - OS << "typedef int8_t poly8_t;\n"; - OS << "typedef int16_t poly16_t;\n"; - OS << "typedef uint16_t float16_t;\n"; - - // Emit Neon vector typedefs. - std::string TypedefTypes("cQcsQsiQilQlUcQUcUsQUsUiQUiUlQUlhQhfQfPcQPcPsQPs"); - SmallVector TDTypeVec; - ParseTypes(0, TypedefTypes, TDTypeVec); - - // Emit vector typedefs. - for (unsigned i = 0, e = TDTypeVec.size(); i != e; ++i) { - bool dummy, quad = false, poly = false; - (void) ClassifyType(TDTypeVec[i], quad, poly, dummy); - if (poly) - OS << "typedef __attribute__((neon_polyvector_type("; - else - OS << "typedef __attribute__((neon_vector_type("; - - unsigned nElts = GetNumElements(TDTypeVec[i], quad); - OS << utostr(nElts) << "))) "; - if (nElts < 10) - OS << " "; - - OS << TypeString('s', TDTypeVec[i]); - OS << " " << TypeString('d', TDTypeVec[i]) << ";\n"; - } - OS << "\n"; - - // Emit struct typedefs. - for (unsigned vi = 2; vi != 5; ++vi) { - for (unsigned i = 0, e = TDTypeVec.size(); i != e; ++i) { - std::string ts = TypeString('d', TDTypeVec[i]); - std::string vs = TypeString('0' + vi, TDTypeVec[i]); - OS << "typedef struct " << vs << " {\n"; - OS << " " << ts << " val"; - OS << "[" << utostr(vi) << "]"; - OS << ";\n} "; - OS << vs << ";\n\n"; - } - } - - OS << "#define __ai static __attribute__((__always_inline__))\n\n"; - - std::vector RV = Records.getAllDerivedDefinitions("Inst"); - - // Emit vmovl, vmull and vabd intrinsics first so they can be used by other - // intrinsics. (Some of the saturating multiply instructions are also - // used to implement the corresponding "_lane" variants, but tablegen - // sorts the records into alphabetical order so that the "_lane" variants - // come after the intrinsics they use.) - emitIntrinsic(OS, Records.getDef("VMOVL")); - emitIntrinsic(OS, Records.getDef("VMULL")); - emitIntrinsic(OS, Records.getDef("VABD")); - - for (unsigned i = 0, e = RV.size(); i != e; ++i) { - Record *R = RV[i]; - if (R->getName() != "VMOVL" && - R->getName() != "VMULL" && - R->getName() != "VABD") - emitIntrinsic(OS, R); - } - - OS << "#undef __ai\n\n"; - OS << "#endif /* __ARM_NEON_H */\n"; -} - -/// emitIntrinsic - Write out the arm_neon.h header file definitions for the -/// intrinsics specified by record R. -void NeonEmitter::emitIntrinsic(raw_ostream &OS, Record *R) { - std::string name = R->getValueAsString("Name"); - std::string Proto = R->getValueAsString("Prototype"); - std::string Types = R->getValueAsString("Types"); - - SmallVector TypeVec; - ParseTypes(R, Types, TypeVec); - - OpKind kind = OpMap[R->getValueAsDef("Operand")->getName()]; - - ClassKind classKind = ClassNone; - if (R->getSuperClasses().size() >= 2) - classKind = ClassMap[R->getSuperClasses()[1]]; - if (classKind == ClassNone && kind == OpNone) - throw TGError(R->getLoc(), "Builtin has no class kind"); - - for (unsigned ti = 0, te = TypeVec.size(); ti != te; ++ti) { - if (kind == OpReinterpret) { - bool outQuad = false; - bool dummy = false; - (void)ClassifyType(TypeVec[ti], outQuad, dummy, dummy); - for (unsigned srcti = 0, srcte = TypeVec.size(); - srcti != srcte; ++srcti) { - bool inQuad = false; - (void)ClassifyType(TypeVec[srcti], inQuad, dummy, dummy); - if (srcti == ti || inQuad != outQuad) - continue; - OS << GenIntrinsic(name, Proto, TypeVec[ti], TypeVec[srcti], - OpCast, ClassS); - } - } else { - OS << GenIntrinsic(name, Proto, TypeVec[ti], TypeVec[ti], - kind, classKind); - } - } - OS << "\n"; -} - -static unsigned RangeFromType(const char mod, StringRef typestr) { - // base type to get the type string for. - bool quad = false, dummy = false; - char type = ClassifyType(typestr, quad, dummy, dummy); - type = ModType(mod, type, quad, dummy, dummy, dummy, dummy, dummy); - - switch (type) { - case 'c': - return (8 << (int)quad) - 1; - case 'h': - case 's': - return (4 << (int)quad) - 1; - case 'f': - case 'i': - return (2 << (int)quad) - 1; - case 'l': - return (1 << (int)quad) - 1; - default: - throw "unhandled type!"; - break; - } - assert(0 && "unreachable"); - return 0; -} - -/// runHeader - Emit a file with sections defining: -/// 1. the NEON section of BuiltinsARM.def. -/// 2. the SemaChecking code for the type overload checking. -/// 3. the SemaChecking code for validation of intrinsic immedate arguments. -void NeonEmitter::runHeader(raw_ostream &OS) { - std::vector RV = Records.getAllDerivedDefinitions("Inst"); - - StringMap EmittedMap; - - // Generate BuiltinsARM.def for NEON - OS << "#ifdef GET_NEON_BUILTINS\n"; - for (unsigned i = 0, e = RV.size(); i != e; ++i) { - Record *R = RV[i]; - OpKind k = OpMap[R->getValueAsDef("Operand")->getName()]; - if (k != OpNone) - continue; - - std::string Proto = R->getValueAsString("Prototype"); - - // Functions with 'a' (the splat code) in the type prototype should not get - // their own builtin as they use the non-splat variant. - if (Proto.find('a') != std::string::npos) - continue; - - std::string Types = R->getValueAsString("Types"); - SmallVector TypeVec; - ParseTypes(R, Types, TypeVec); - - if (R->getSuperClasses().size() < 2) - throw TGError(R->getLoc(), "Builtin has no class kind"); - - std::string name = R->getValueAsString("Name"); - ClassKind ck = ClassMap[R->getSuperClasses()[1]]; - - for (unsigned ti = 0, te = TypeVec.size(); ti != te; ++ti) { - // Generate the BuiltinsARM.def declaration for this builtin, ensuring - // that each unique BUILTIN() macro appears only once in the output - // stream. - std::string bd = GenBuiltinDef(name, Proto, TypeVec[ti], ck); - if (EmittedMap.count(bd)) - continue; - - EmittedMap[bd] = OpNone; - OS << bd << "\n"; - } - } - OS << "#endif\n\n"; - - // Generate the overloaded type checking code for SemaChecking.cpp - OS << "#ifdef GET_NEON_OVERLOAD_CHECK\n"; - for (unsigned i = 0, e = RV.size(); i != e; ++i) { - Record *R = RV[i]; - OpKind k = OpMap[R->getValueAsDef("Operand")->getName()]; - if (k != OpNone) - continue; - - std::string Proto = R->getValueAsString("Prototype"); - std::string Types = R->getValueAsString("Types"); - std::string name = R->getValueAsString("Name"); - - // Functions with 'a' (the splat code) in the type prototype should not get - // their own builtin as they use the non-splat variant. - if (Proto.find('a') != std::string::npos) - continue; - - // Functions which have a scalar argument cannot be overloaded, no need to - // check them if we are emitting the type checking code. - if (Proto.find('s') != std::string::npos) - continue; - - SmallVector TypeVec; - ParseTypes(R, Types, TypeVec); - - if (R->getSuperClasses().size() < 2) - throw TGError(R->getLoc(), "Builtin has no class kind"); - - int si = -1, qi = -1; - unsigned mask = 0, qmask = 0; - for (unsigned ti = 0, te = TypeVec.size(); ti != te; ++ti) { - // Generate the switch case(s) for this builtin for the type validation. - bool quad = false, poly = false, usgn = false; - (void) ClassifyType(TypeVec[ti], quad, poly, usgn); - - if (quad) { - qi = ti; - qmask |= 1 << GetNeonEnum(Proto, TypeVec[ti]); - } else { - si = ti; - mask |= 1 << GetNeonEnum(Proto, TypeVec[ti]); - } - } - if (mask) - OS << "case ARM::BI__builtin_neon_" - << MangleName(name, TypeVec[si], ClassB) - << ": mask = " << "0x" << utohexstr(mask) << "; break;\n"; - if (qmask) - OS << "case ARM::BI__builtin_neon_" - << MangleName(name, TypeVec[qi], ClassB) - << ": mask = " << "0x" << utohexstr(qmask) << "; break;\n"; - } - OS << "#endif\n\n"; - - // Generate the intrinsic range checking code for shift/lane immediates. - OS << "#ifdef GET_NEON_IMMEDIATE_CHECK\n"; - for (unsigned i = 0, e = RV.size(); i != e; ++i) { - Record *R = RV[i]; - - OpKind k = OpMap[R->getValueAsDef("Operand")->getName()]; - if (k != OpNone) - continue; - - std::string name = R->getValueAsString("Name"); - std::string Proto = R->getValueAsString("Prototype"); - std::string Types = R->getValueAsString("Types"); - - // Functions with 'a' (the splat code) in the type prototype should not get - // their own builtin as they use the non-splat variant. - if (Proto.find('a') != std::string::npos) - continue; - - // Functions which do not have an immediate do not need to have range - // checking code emitted. - size_t immPos = Proto.find('i'); - if (immPos == std::string::npos) - continue; - - SmallVector TypeVec; - ParseTypes(R, Types, TypeVec); - - if (R->getSuperClasses().size() < 2) - throw TGError(R->getLoc(), "Builtin has no class kind"); - - ClassKind ck = ClassMap[R->getSuperClasses()[1]]; - - for (unsigned ti = 0, te = TypeVec.size(); ti != te; ++ti) { - std::string namestr, shiftstr, rangestr; - - if (R->getValueAsBit("isVCVT_N")) { - // VCVT between floating- and fixed-point values takes an immediate - // in the range 1 to 32. - ck = ClassB; - rangestr = "l = 1; u = 31"; // upper bound = l + u - } else if (Proto.find('s') == std::string::npos) { - // Builtins which are overloaded by type will need to have their upper - // bound computed at Sema time based on the type constant. - ck = ClassB; - if (R->getValueAsBit("isShift")) { - shiftstr = ", true"; - - // Right shifts have an 'r' in the name, left shifts do not. - if (name.find('r') != std::string::npos) - rangestr = "l = 1; "; - } - rangestr += "u = RFT(TV" + shiftstr + ")"; - } else { - // The immediate generally refers to a lane in the preceding argument. - assert(immPos > 0 && "unexpected immediate operand"); - rangestr = "u = " + utostr(RangeFromType(Proto[immPos-1], TypeVec[ti])); - } - // Make sure cases appear only once by uniquing them in a string map. - namestr = MangleName(name, TypeVec[ti], ck); - if (EmittedMap.count(namestr)) - continue; - EmittedMap[namestr] = OpNone; - - // Calculate the index of the immediate that should be range checked. - unsigned immidx = 0; - - // Builtins that return a struct of multiple vectors have an extra - // leading arg for the struct return. - if (Proto[0] >= '2' && Proto[0] <= '4') - ++immidx; - - // Add one to the index for each argument until we reach the immediate - // to be checked. Structs of vectors are passed as multiple arguments. - for (unsigned ii = 1, ie = Proto.size(); ii != ie; ++ii) { - switch (Proto[ii]) { - default: immidx += 1; break; - case '2': immidx += 2; break; - case '3': immidx += 3; break; - case '4': immidx += 4; break; - case 'i': ie = ii + 1; break; - } - } - OS << "case ARM::BI__builtin_neon_" << MangleName(name, TypeVec[ti], ck) - << ": i = " << immidx << "; " << rangestr << "; break;\n"; - } - } - OS << "#endif\n\n"; -} - -/// GenTest - Write out a test for the intrinsic specified by the name and -/// type strings, including the embedded patterns for FileCheck to match. -static std::string GenTest(const std::string &name, - const std::string &proto, - StringRef outTypeStr, StringRef inTypeStr, - bool isShift) { - assert(!proto.empty() && ""); - std::string s; - - // Function name with type suffix - std::string mangledName = MangleName(name, outTypeStr, ClassS); - if (outTypeStr != inTypeStr) { - // If the input type is different (e.g., for vreinterpret), append a suffix - // for the input type. String off a "Q" (quad) prefix so that MangleName - // does not insert another "q" in the name. - unsigned typeStrOff = (inTypeStr[0] == 'Q' ? 1 : 0); - StringRef inTypeNoQuad = inTypeStr.substr(typeStrOff); - mangledName = MangleName(mangledName, inTypeNoQuad, ClassS); - } - - // Emit the FileCheck patterns. - s += "// CHECK: test_" + mangledName + "\n"; - // s += "// CHECK: \n"; // FIXME: + expected instruction opcode. - - // Emit the start of the test function. - s += TypeString(proto[0], outTypeStr) + " test_" + mangledName + "("; - char arg = 'a'; - std::string comma; - for (unsigned i = 1, e = proto.size(); i != e; ++i, ++arg) { - // Do not create arguments for values that must be immediate constants. - if (proto[i] == 'i') - continue; - s += comma + TypeString(proto[i], inTypeStr) + " "; - s.push_back(arg); - comma = ", "; - } - s += ") { \\\n "; - - if (proto[0] != 'v') - s += "return "; - s += mangledName + "("; - arg = 'a'; - for (unsigned i = 1, e = proto.size(); i != e; ++i, ++arg) { - if (proto[i] == 'i') { - // For immediate operands, test the maximum value. - if (isShift) - s += "1"; // FIXME - else - // The immediate generally refers to a lane in the preceding argument. - s += utostr(RangeFromType(proto[i-1], inTypeStr)); - } else { - s.push_back(arg); - } - if ((i + 1) < e) - s += ", "; - } - s += ");\n}\n\n"; - return s; -} - -/// runTests - Write out a complete set of tests for all of the Neon -/// intrinsics. -void NeonEmitter::runTests(raw_ostream &OS) { - OS << - "// RUN: %clang_cc1 -triple thumbv7-apple-darwin \\\n" - "// RUN: -target-cpu cortex-a9 -ffreestanding -S -o - %s | FileCheck %s\n" - "\n" - "#include \n" - "\n"; - - std::vector RV = Records.getAllDerivedDefinitions("Inst"); - for (unsigned i = 0, e = RV.size(); i != e; ++i) { - Record *R = RV[i]; - std::string name = R->getValueAsString("Name"); - std::string Proto = R->getValueAsString("Prototype"); - std::string Types = R->getValueAsString("Types"); - bool isShift = R->getValueAsBit("isShift"); - - SmallVector TypeVec; - ParseTypes(R, Types, TypeVec); - - OpKind kind = OpMap[R->getValueAsDef("Operand")->getName()]; - for (unsigned ti = 0, te = TypeVec.size(); ti != te; ++ti) { - if (kind == OpReinterpret) { - bool outQuad = false; - bool dummy = false; - (void)ClassifyType(TypeVec[ti], outQuad, dummy, dummy); - for (unsigned srcti = 0, srcte = TypeVec.size(); - srcti != srcte; ++srcti) { - bool inQuad = false; - (void)ClassifyType(TypeVec[srcti], inQuad, dummy, dummy); - if (srcti == ti || inQuad != outQuad) - continue; - OS << GenTest(name, Proto, TypeVec[ti], TypeVec[srcti], isShift); - } - } else { - OS << GenTest(name, Proto, TypeVec[ti], TypeVec[ti], isShift); - } - } - OS << "\n"; - } -} - Removed: llvm/trunk/utils/TableGen/NeonEmitter.h URL: http://llvm.org/viewvc/llvm-project/llvm/trunk/utils/TableGen/NeonEmitter.h?rev=141292&view=auto ============================================================================== --- llvm/trunk/utils/TableGen/NeonEmitter.h (original) +++ llvm/trunk/utils/TableGen/NeonEmitter.h (removed) @@ -1,176 +0,0 @@ -//===- NeonEmitter.h - Generate arm_neon.h for use with clang ---*- C++ -*-===// -// -// The LLVM Compiler Infrastructure -// -// This file is distributed under the University of Illinois Open Source -// License. See LICENSE.TXT for details. -// -//===----------------------------------------------------------------------===// -// -// This tablegen backend is responsible for emitting arm_neon.h, which includes -// a declaration and definition of each function specified by the ARM NEON -// compiler interface. See ARM document DUI0348B. -// -//===----------------------------------------------------------------------===// - -#ifndef NEON_EMITTER_H -#define NEON_EMITTER_H - -#include "llvm/TableGen/Record.h" -#include "llvm/TableGen/TableGenBackend.h" -#include "llvm/ADT/DenseMap.h" -#include "llvm/ADT/StringMap.h" - -enum OpKind { - OpNone, - OpAdd, - OpAddl, - OpAddw, - OpSub, - OpSubl, - OpSubw, - OpMul, - OpMla, - OpMlal, - OpMls, - OpMlsl, - OpMulN, - OpMlaN, - OpMlsN, - OpMlalN, - OpMlslN, - OpMulLane, - OpMullLane, - OpMlaLane, - OpMlsLane, - OpMlalLane, - OpMlslLane, - OpQDMullLane, - OpQDMlalLane, - OpQDMlslLane, - OpQDMulhLane, - OpQRDMulhLane, - OpEq, - OpGe, - OpLe, - OpGt, - OpLt, - OpNeg, - OpNot, - OpAnd, - OpOr, - OpXor, - OpAndNot, - OpOrNot, - OpCast, - OpConcat, - OpDup, - OpDupLane, - OpHi, - OpLo, - OpSelect, - OpRev16, - OpRev32, - OpRev64, - OpReinterpret, - OpAbdl, - OpAba, - OpAbal -}; - -enum ClassKind { - ClassNone, - ClassI, // generic integer instruction, e.g., "i8" suffix - ClassS, // signed/unsigned/poly, e.g., "s8", "u8" or "p8" suffix - ClassW, // width-specific instruction, e.g., "8" suffix - ClassB // bitcast arguments with enum argument to specify type -}; - -namespace llvm { - - class NeonEmitter : public TableGenBackend { - RecordKeeper &Records; - StringMap OpMap; - DenseMap ClassMap; - - public: - NeonEmitter(RecordKeeper &R) : Records(R) { - OpMap["OP_NONE"] = OpNone; - OpMap["OP_ADD"] = OpAdd; - OpMap["OP_ADDL"] = OpAddl; - OpMap["OP_ADDW"] = OpAddw; - OpMap["OP_SUB"] = OpSub; - OpMap["OP_SUBL"] = OpSubl; - OpMap["OP_SUBW"] = OpSubw; - OpMap["OP_MUL"] = OpMul; - OpMap["OP_MLA"] = OpMla; - OpMap["OP_MLAL"] = OpMlal; - OpMap["OP_MLS"] = OpMls; - OpMap["OP_MLSL"] = OpMlsl; - OpMap["OP_MUL_N"] = OpMulN; - OpMap["OP_MLA_N"] = OpMlaN; - OpMap["OP_MLS_N"] = OpMlsN; - OpMap["OP_MLAL_N"] = OpMlalN; - OpMap["OP_MLSL_N"] = OpMlslN; - OpMap["OP_MUL_LN"]= OpMulLane; - OpMap["OP_MULL_LN"] = OpMullLane; - OpMap["OP_MLA_LN"]= OpMlaLane; - OpMap["OP_MLS_LN"]= OpMlsLane; - OpMap["OP_MLAL_LN"] = OpMlalLane; - OpMap["OP_MLSL_LN"] = OpMlslLane; - OpMap["OP_QDMULL_LN"] = OpQDMullLane; - OpMap["OP_QDMLAL_LN"] = OpQDMlalLane; - OpMap["OP_QDMLSL_LN"] = OpQDMlslLane; - OpMap["OP_QDMULH_LN"] = OpQDMulhLane; - OpMap["OP_QRDMULH_LN"] = OpQRDMulhLane; - OpMap["OP_EQ"] = OpEq; - OpMap["OP_GE"] = OpGe; - OpMap["OP_LE"] = OpLe; - OpMap["OP_GT"] = OpGt; - OpMap["OP_LT"] = OpLt; - OpMap["OP_NEG"] = OpNeg; - OpMap["OP_NOT"] = OpNot; - OpMap["OP_AND"] = OpAnd; - OpMap["OP_OR"] = OpOr; - OpMap["OP_XOR"] = OpXor; - OpMap["OP_ANDN"] = OpAndNot; - OpMap["OP_ORN"] = OpOrNot; - OpMap["OP_CAST"] = OpCast; - OpMap["OP_CONC"] = OpConcat; - OpMap["OP_HI"] = OpHi; - OpMap["OP_LO"] = OpLo; - OpMap["OP_DUP"] = OpDup; - OpMap["OP_DUP_LN"] = OpDupLane; - OpMap["OP_SEL"] = OpSelect; - OpMap["OP_REV16"] = OpRev16; - OpMap["OP_REV32"] = OpRev32; - OpMap["OP_REV64"] = OpRev64; - OpMap["OP_REINT"] = OpReinterpret; - OpMap["OP_ABDL"] = OpAbdl; - OpMap["OP_ABA"] = OpAba; - OpMap["OP_ABAL"] = OpAbal; - - Record *SI = R.getClass("SInst"); - Record *II = R.getClass("IInst"); - Record *WI = R.getClass("WInst"); - ClassMap[SI] = ClassS; - ClassMap[II] = ClassI; - ClassMap[WI] = ClassW; - } - - // run - Emit arm_neon.h.inc - void run(raw_ostream &o); - - // runHeader - Emit all the __builtin prototypes used in arm_neon.h - void runHeader(raw_ostream &o); - - // runTests - Emit tests for all the Neon intrinsics. - void runTests(raw_ostream &o); - - private: - void emitIntrinsic(raw_ostream &OS, Record *R); - }; - -} // End llvm namespace - -#endif Removed: llvm/trunk/utils/TableGen/OptParserEmitter.cpp URL: http://llvm.org/viewvc/llvm-project/llvm/trunk/utils/TableGen/OptParserEmitter.cpp?rev=141292&view=auto ============================================================================== --- llvm/trunk/utils/TableGen/OptParserEmitter.cpp (original) +++ llvm/trunk/utils/TableGen/OptParserEmitter.cpp (removed) @@ -1,194 +0,0 @@ -//===- OptParserEmitter.cpp - Table Driven Command Line Parsing -----------===// -// -// The LLVM Compiler Infrastructure -// -// This file is distributed under the University of Illinois Open Source -// License. See LICENSE.TXT for details. -// -//===----------------------------------------------------------------------===// - -#include "OptParserEmitter.h" -#include "llvm/TableGen/Record.h" -#include "llvm/ADT/STLExtras.h" -using namespace llvm; - -static int StrCmpOptionName(const char *A, const char *B) { - char a = *A, b = *B; - while (a == b) { - if (a == '\0') - return 0; - - a = *++A; - b = *++B; - } - - if (a == '\0') // A is a prefix of B. - return 1; - if (b == '\0') // B is a prefix of A. - return -1; - - // Otherwise lexicographic. - return (a < b) ? -1 : 1; -} - -static int CompareOptionRecords(const void *Av, const void *Bv) { - const Record *A = *(Record**) Av; - const Record *B = *(Record**) Bv; - - // Sentinel options precede all others and are only ordered by precedence. - bool ASent = A->getValueAsDef("Kind")->getValueAsBit("Sentinel"); - bool BSent = B->getValueAsDef("Kind")->getValueAsBit("Sentinel"); - if (ASent != BSent) - return ASent ? -1 : 1; - - // Compare options by name, unless they are sentinels. - if (!ASent) - if (int Cmp = StrCmpOptionName(A->getValueAsString("Name").c_str(), - B->getValueAsString("Name").c_str())) - return Cmp; - - // Then by the kind precedence; - int APrec = A->getValueAsDef("Kind")->getValueAsInt("Precedence"); - int BPrec = B->getValueAsDef("Kind")->getValueAsInt("Precedence"); - assert(APrec != BPrec && "Options are equivalent!"); - return APrec < BPrec ? -1 : 1; -} - -static const std::string getOptionName(const Record &R) { - // Use the record name unless EnumName is defined. - if (dynamic_cast(R.getValueInit("EnumName"))) - return R.getName(); - - return R.getValueAsString("EnumName"); -} - -static raw_ostream &write_cstring(raw_ostream &OS, llvm::StringRef Str) { - OS << '"'; - OS.write_escaped(Str); - OS << '"'; - return OS; -} - -void OptParserEmitter::run(raw_ostream &OS) { - // Get the option groups and options. - const std::vector &Groups = - Records.getAllDerivedDefinitions("OptionGroup"); - std::vector Opts = Records.getAllDerivedDefinitions("Option"); - - if (GenDefs) - EmitSourceFileHeader("Option Parsing Definitions", OS); - else - EmitSourceFileHeader("Option Parsing Table", OS); - - array_pod_sort(Opts.begin(), Opts.end(), CompareOptionRecords); - if (GenDefs) { - OS << "#ifndef OPTION\n"; - OS << "#error \"Define OPTION prior to including this file!\"\n"; - OS << "#endif\n\n"; - - OS << "/////////\n"; - OS << "// Groups\n\n"; - for (unsigned i = 0, e = Groups.size(); i != e; ++i) { - const Record &R = *Groups[i]; - - // Start a single option entry. - OS << "OPTION("; - - // The option string. - OS << '"' << R.getValueAsString("Name") << '"'; - - // The option identifier name. - OS << ", "<< getOptionName(R); - - // The option kind. - OS << ", Group"; - - // The containing option group (if any). - OS << ", "; - if (const DefInit *DI = dynamic_cast(R.getValueInit("Group"))) - OS << getOptionName(*DI->getDef()); - else - OS << "INVALID"; - - // The other option arguments (unused for groups). - OS << ", INVALID, 0, 0"; - - // The option help text. - if (!dynamic_cast(R.getValueInit("HelpText"))) { - OS << ",\n"; - OS << " "; - write_cstring(OS, R.getValueAsString("HelpText")); - } else - OS << ", 0"; - - // The option meta-variable name (unused). - OS << ", 0)\n"; - } - OS << "\n"; - - OS << "//////////\n"; - OS << "// Options\n\n"; - for (unsigned i = 0, e = Opts.size(); i != e; ++i) { - const Record &R = *Opts[i]; - - // Start a single option entry. - OS << "OPTION("; - - // The option string. - write_cstring(OS, R.getValueAsString("Name")); - - // The option identifier name. - OS << ", "<< getOptionName(R); - - // The option kind. - OS << ", " << R.getValueAsDef("Kind")->getValueAsString("Name"); - - // The containing option group (if any). - OS << ", "; - if (const DefInit *DI = dynamic_cast(R.getValueInit("Group"))) - OS << getOptionName(*DI->getDef()); - else - OS << "INVALID"; - - // The option alias (if any). - OS << ", "; - if (const DefInit *DI = dynamic_cast(R.getValueInit("Alias"))) - OS << getOptionName(*DI->getDef()); - else - OS << "INVALID"; - - // The option flags. - const ListInit *LI = R.getValueAsListInit("Flags"); - if (LI->empty()) { - OS << ", 0"; - } else { - OS << ", "; - for (unsigned i = 0, e = LI->size(); i != e; ++i) { - if (i) - OS << " | "; - OS << dynamic_cast(LI->getElement(i))->getDef()->getName(); - } - } - - // The option parameter field. - OS << ", " << R.getValueAsInt("NumArgs"); - - // The option help text. - if (!dynamic_cast(R.getValueInit("HelpText"))) { - OS << ",\n"; - OS << " "; - write_cstring(OS, R.getValueAsString("HelpText")); - } else - OS << ", 0"; - - // The option meta-variable name. - OS << ", "; - if (!dynamic_cast(R.getValueInit("MetaVarName"))) - write_cstring(OS, R.getValueAsString("MetaVarName")); - else - OS << "0"; - - OS << ")\n"; - } - } -} Removed: llvm/trunk/utils/TableGen/OptParserEmitter.h URL: http://llvm.org/viewvc/llvm-project/llvm/trunk/utils/TableGen/OptParserEmitter.h?rev=141292&view=auto ============================================================================== --- llvm/trunk/utils/TableGen/OptParserEmitter.h (original) +++ llvm/trunk/utils/TableGen/OptParserEmitter.h (removed) @@ -1,34 +0,0 @@ -//===- OptParserEmitter.h - Table Driven Command Line Parsing ---*- C++ -*-===// -// -// The LLVM Compiler Infrastructure -// -// This file is distributed under the University of Illinois Open Source -// License. See LICENSE.TXT for details. -// -//===----------------------------------------------------------------------===// - -#ifndef UTILS_TABLEGEN_OPTPARSEREMITTER_H -#define UTILS_TABLEGEN_OPTPARSEREMITTER_H - -#include "llvm/TableGen/TableGenBackend.h" - -namespace llvm { - /// OptParserEmitter - This tablegen backend takes an input .td file - /// describing a list of options and emits a data structure for parsing and - /// working with those options when given an input command line. - class OptParserEmitter : public TableGenBackend { - RecordKeeper &Records; - bool GenDefs; - - public: - OptParserEmitter(RecordKeeper &R, bool _GenDefs) - : Records(R), GenDefs(_GenDefs) {} - - /// run - Output the option parsing information. - /// - /// \param GenHeader - Generate the header describing the option IDs.x - void run(raw_ostream &OS); - }; -} - -#endif Modified: llvm/trunk/utils/TableGen/TableGen.cpp URL: http://llvm.org/viewvc/llvm-project/llvm/trunk/utils/TableGen/TableGen.cpp?rev=141293&r1=141292&r2=141293&view=diff ============================================================================== --- llvm/trunk/utils/TableGen/TableGen.cpp (original) +++ llvm/trunk/utils/TableGen/TableGen.cpp Thu Oct 6 08:21:42 2011 @@ -14,10 +14,6 @@ #include "AsmMatcherEmitter.h" #include "AsmWriterEmitter.h" #include "CallingConvEmitter.h" -#include "ClangASTNodesEmitter.h" -#include "ClangAttrEmitter.h" -#include "ClangDiagnosticsEmitter.h" -#include "ClangSACheckersEmitter.h" #include "CodeEmitterGen.h" #include "DAGISelEmitter.h" #include "DisassemblerEmitter.h" @@ -25,8 +21,6 @@ #include "FastISelEmitter.h" #include "InstrInfoEmitter.h" #include "IntrinsicEmitter.h" -#include "NeonEmitter.h" -#include "OptParserEmitter.h" #include "PseudoLoweringEmitter.h" #include "RegisterInfoEmitter.h" #include "ARMDecoderEmitter.h" @@ -54,29 +48,12 @@ GenDisassembler, GenPseudoLowering, GenCallingConv, - GenClangAttrClasses, - GenClangAttrImpl, - GenClangAttrList, - GenClangAttrPCHRead, - GenClangAttrPCHWrite, - GenClangAttrSpellingList, - GenClangAttrLateParsedList, - GenClangDiagsDefs, - GenClangDiagGroups, - GenClangDiagsIndexName, - GenClangDeclNodes, - GenClangStmtNodes, - GenClangSACheckers, GenDAGISel, GenFastISel, - GenOptParserDefs, GenOptParserImpl, GenSubtarget, GenIntrinsic, GenTgtIntrinsic, GenEDInfo, - GenArmNeon, - GenArmNeonSema, - GenArmNeonTest, PrintEnums, PrintSets }; @@ -108,53 +85,14 @@ "Generate a DAG instruction selector"), clEnumValN(GenFastISel, "gen-fast-isel", "Generate a \"fast\" instruction selector"), - clEnumValN(GenOptParserDefs, "gen-opt-parser-defs", - "Generate option definitions"), - clEnumValN(GenOptParserImpl, "gen-opt-parser-impl", - "Generate option parser implementation"), clEnumValN(GenSubtarget, "gen-subtarget", "Generate subtarget enumerations"), clEnumValN(GenIntrinsic, "gen-intrinsic", "Generate intrinsic information"), clEnumValN(GenTgtIntrinsic, "gen-tgt-intrinsic", "Generate target intrinsic information"), - clEnumValN(GenClangAttrClasses, "gen-clang-attr-classes", - "Generate clang attribute clases"), - clEnumValN(GenClangAttrImpl, "gen-clang-attr-impl", - "Generate clang attribute implementations"), - clEnumValN(GenClangAttrList, "gen-clang-attr-list", - "Generate a clang attribute list"), - clEnumValN(GenClangAttrPCHRead, "gen-clang-attr-pch-read", - "Generate clang PCH attribute reader"), - clEnumValN(GenClangAttrPCHWrite, "gen-clang-attr-pch-write", - "Generate clang PCH attribute writer"), - clEnumValN(GenClangAttrSpellingList, - "gen-clang-attr-spelling-list", - "Generate a clang attribute spelling list"), - clEnumValN(GenClangAttrLateParsedList, - "gen-clang-attr-late-parsed-list", - "Generate a clang attribute LateParsed list"), - clEnumValN(GenClangDiagsDefs, "gen-clang-diags-defs", - "Generate Clang diagnostics definitions"), - clEnumValN(GenClangDiagGroups, "gen-clang-diag-groups", - "Generate Clang diagnostic groups"), - clEnumValN(GenClangDiagsIndexName, - "gen-clang-diags-index-name", - "Generate Clang diagnostic name index"), - clEnumValN(GenClangDeclNodes, "gen-clang-decl-nodes", - "Generate Clang AST declaration nodes"), - clEnumValN(GenClangStmtNodes, "gen-clang-stmt-nodes", - "Generate Clang AST statement nodes"), - clEnumValN(GenClangSACheckers, "gen-clang-sa-checkers", - "Generate Clang Static Analyzer checkers"), clEnumValN(GenEDInfo, "gen-enhanced-disassembly-info", "Generate enhanced disassembly info"), - clEnumValN(GenArmNeon, "gen-arm-neon", - "Generate arm_neon.h for clang"), - clEnumValN(GenArmNeonSema, "gen-arm-neon-sema", - "Generate ARM NEON sema support for clang"), - clEnumValN(GenArmNeonTest, "gen-arm-neon-test", - "Generate ARM NEON tests for clang"), clEnumValN(PrintEnums, "print-enums", "Print enum values for a class"), clEnumValN(PrintSets, "print-sets", @@ -164,11 +102,6 @@ cl::opt Class("class", cl::desc("Print Enum list for this class"), cl::value_desc("class name")); - - cl::opt - ClangComponent("clang-component", - cl::desc("Only use warnings from specified component"), - cl::value_desc("component"), cl::Hidden); } class LLVMTableGenAction : public TableGenAction { @@ -199,58 +132,12 @@ case GenAsmMatcher: AsmMatcherEmitter(Records).run(OS); break; - case GenClangAttrClasses: - ClangAttrClassEmitter(Records).run(OS); - break; - case GenClangAttrImpl: - ClangAttrImplEmitter(Records).run(OS); - break; - case GenClangAttrList: - ClangAttrListEmitter(Records).run(OS); - break; - case GenClangAttrPCHRead: - ClangAttrPCHReadEmitter(Records).run(OS); - break; - case GenClangAttrPCHWrite: - ClangAttrPCHWriteEmitter(Records).run(OS); - break; - case GenClangAttrSpellingList: - ClangAttrSpellingListEmitter(Records).run(OS); - break; - case GenClangAttrLateParsedList: - ClangAttrLateParsedListEmitter(Records).run(OS); - break; - case GenClangDiagsDefs: - ClangDiagsDefsEmitter(Records, ClangComponent).run(OS); - break; - case GenClangDiagGroups: - ClangDiagGroupsEmitter(Records).run(OS); - break; - case GenClangDiagsIndexName: - ClangDiagsIndexNameEmitter(Records).run(OS); - break; - case GenClangDeclNodes: - ClangASTNodesEmitter(Records, "Decl", "Decl").run(OS); - ClangDeclContextEmitter(Records).run(OS); - break; - case GenClangStmtNodes: - ClangASTNodesEmitter(Records, "Stmt", "").run(OS); - break; - case GenClangSACheckers: - ClangSACheckersEmitter(Records).run(OS); - break; case GenDisassembler: DisassemblerEmitter(Records).run(OS); break; case GenPseudoLowering: PseudoLoweringEmitter(Records).run(OS); break; - case GenOptParserDefs: - OptParserEmitter(Records, true).run(OS); - break; - case GenOptParserImpl: - OptParserEmitter(Records, false).run(OS); - break; case GenDAGISel: DAGISelEmitter(Records).run(OS); break; @@ -269,15 +156,6 @@ case GenEDInfo: EDEmitter(Records).run(OS); break; - case GenArmNeon: - NeonEmitter(Records).run(OS); - break; - case GenArmNeonSema: - NeonEmitter(Records).runHeader(OS); - break; - case GenArmNeonTest: - NeonEmitter(Records).runTests(OS); - break; case PrintEnums: { std::vector Recs = Records.getAllDerivedDefinitions(Class); From peter at pcc.me.uk Thu Oct 6 08:40:04 2011 From: peter at pcc.me.uk (Peter Collingbourne) Date: Thu, 06 Oct 2011 13:40:04 -0000 Subject: [llvm-commits] [llvm] r141294 - in /llvm/trunk/test: ./ TableGen/ lib/ Message-ID: <20111006134006.90766312800A@llvm.org> Author: pcc Date: Thu Oct 6 08:39:59 2011 New Revision: 141294 URL: http://llvm.org/viewvc/llvm-project?rev=141294&view=rev Log: s/tblgen/llvm-tblgen/g in a few missed places, including the tests Modified: llvm/trunk/test/TableGen/2003-08-03-PassCode.td llvm/trunk/test/TableGen/2006-09-18-LargeInt.td llvm/trunk/test/TableGen/2010-03-24-PrematureDefaults.td llvm/trunk/test/TableGen/AnonDefinitionOnDemand.td llvm/trunk/test/TableGen/BitsInitOverflow.td llvm/trunk/test/TableGen/CStyleComment.td llvm/trunk/test/TableGen/Dag.td llvm/trunk/test/TableGen/DefmInherit.td llvm/trunk/test/TableGen/DefmInsideMultiClass.td llvm/trunk/test/TableGen/FieldAccess.td llvm/trunk/test/TableGen/ForwardRef.td llvm/trunk/test/TableGen/GeneralList.td llvm/trunk/test/TableGen/Include.td llvm/trunk/test/TableGen/IntBitInit.td llvm/trunk/test/TableGen/LazyChange.td llvm/trunk/test/TableGen/LetInsideMultiClasses.td llvm/trunk/test/TableGen/ListArgs.td llvm/trunk/test/TableGen/ListArgsSimple.td llvm/trunk/test/TableGen/ListConversion.td llvm/trunk/test/TableGen/ListManip.td llvm/trunk/test/TableGen/ListOfList.td llvm/trunk/test/TableGen/ListSlices.td llvm/trunk/test/TableGen/LoLoL.td llvm/trunk/test/TableGen/MultiClass.td llvm/trunk/test/TableGen/MultiClassDefName.td llvm/trunk/test/TableGen/MultiClassInherit.td llvm/trunk/test/TableGen/MultiDef.td llvm/trunk/test/TableGen/MultiPat.td llvm/trunk/test/TableGen/SetTheory.td llvm/trunk/test/TableGen/Slice.td llvm/trunk/test/TableGen/String.td llvm/trunk/test/TableGen/SuperSubclassSameName.td llvm/trunk/test/TableGen/TargetInstrInfo.td llvm/trunk/test/TableGen/TargetInstrSpec.td llvm/trunk/test/TableGen/TemplateArgRename.td llvm/trunk/test/TableGen/Tree.td llvm/trunk/test/TableGen/TreeNames.td llvm/trunk/test/TableGen/UnsetBitInit.td llvm/trunk/test/TableGen/UnterminatedComment.td llvm/trunk/test/TableGen/cast.td llvm/trunk/test/TableGen/defmclass.td llvm/trunk/test/TableGen/eq.td llvm/trunk/test/TableGen/eqbit.td llvm/trunk/test/TableGen/foreach.td llvm/trunk/test/TableGen/if.td llvm/trunk/test/TableGen/ifbit.td llvm/trunk/test/TableGen/lisp.td llvm/trunk/test/TableGen/nested-comment.td llvm/trunk/test/TableGen/strconcat.td llvm/trunk/test/TableGen/subst.td llvm/trunk/test/TableGen/subst2.td llvm/trunk/test/TableGen/usevalname.td llvm/trunk/test/lib/llvm.exp llvm/trunk/test/lit.cfg Modified: llvm/trunk/test/TableGen/2003-08-03-PassCode.td URL: http://llvm.org/viewvc/llvm-project/llvm/trunk/test/TableGen/2003-08-03-PassCode.td?rev=141294&r1=141293&r2=141294&view=diff ============================================================================== --- llvm/trunk/test/TableGen/2003-08-03-PassCode.td (original) +++ llvm/trunk/test/TableGen/2003-08-03-PassCode.td Thu Oct 6 08:39:59 2011 @@ -1,4 +1,4 @@ -// RUN: tblgen %s +// RUN: llvm-tblgen %s // XFAIL: vg_leak class test { Modified: llvm/trunk/test/TableGen/2006-09-18-LargeInt.td URL: http://llvm.org/viewvc/llvm-project/llvm/trunk/test/TableGen/2006-09-18-LargeInt.td?rev=141294&r1=141293&r2=141294&view=diff ============================================================================== --- llvm/trunk/test/TableGen/2006-09-18-LargeInt.td (original) +++ llvm/trunk/test/TableGen/2006-09-18-LargeInt.td Thu Oct 6 08:39:59 2011 @@ -1,4 +1,4 @@ -// RUN: tblgen %s | grep -- 4294901760 +// RUN: llvm-tblgen %s | grep -- 4294901760 // XFAIL: vg_leak def X { Modified: llvm/trunk/test/TableGen/2010-03-24-PrematureDefaults.td URL: http://llvm.org/viewvc/llvm-project/llvm/trunk/test/TableGen/2010-03-24-PrematureDefaults.td?rev=141294&r1=141293&r2=141294&view=diff ============================================================================== --- llvm/trunk/test/TableGen/2010-03-24-PrematureDefaults.td (original) +++ llvm/trunk/test/TableGen/2010-03-24-PrematureDefaults.td Thu Oct 6 08:39:59 2011 @@ -1,4 +1,4 @@ -// RUN: tblgen %s | FileCheck %s +// RUN: llvm-tblgen %s | FileCheck %s // XFAIL: vg_leak class A x = 1> { Modified: llvm/trunk/test/TableGen/AnonDefinitionOnDemand.td URL: http://llvm.org/viewvc/llvm-project/llvm/trunk/test/TableGen/AnonDefinitionOnDemand.td?rev=141294&r1=141293&r2=141294&view=diff ============================================================================== --- llvm/trunk/test/TableGen/AnonDefinitionOnDemand.td (original) +++ llvm/trunk/test/TableGen/AnonDefinitionOnDemand.td Thu Oct 6 08:39:59 2011 @@ -1,4 +1,4 @@ -// RUN: tblgen < %s +// RUN: llvm-tblgen < %s // XFAIL: vg_leak class foo { int THEVAL = X; } Modified: llvm/trunk/test/TableGen/BitsInitOverflow.td URL: http://llvm.org/viewvc/llvm-project/llvm/trunk/test/TableGen/BitsInitOverflow.td?rev=141294&r1=141293&r2=141294&view=diff ============================================================================== --- llvm/trunk/test/TableGen/BitsInitOverflow.td (original) +++ llvm/trunk/test/TableGen/BitsInitOverflow.td Thu Oct 6 08:39:59 2011 @@ -1,4 +1,4 @@ -// RUN: not tblgen %s 2> /dev/null +// RUN: not llvm-tblgen %s 2> /dev/null def { bits<2> X = 5; // bitfield is too small, reject Modified: llvm/trunk/test/TableGen/CStyleComment.td URL: http://llvm.org/viewvc/llvm-project/llvm/trunk/test/TableGen/CStyleComment.td?rev=141294&r1=141293&r2=141294&view=diff ============================================================================== --- llvm/trunk/test/TableGen/CStyleComment.td (original) +++ llvm/trunk/test/TableGen/CStyleComment.td Thu Oct 6 08:39:59 2011 @@ -1,6 +1,6 @@ // Test that multiline, nested, comments work correctly. // -// RUN: tblgen < %s +// RUN: llvm-tblgen < %s // XFAIL: vg_leak /* Foo Modified: llvm/trunk/test/TableGen/Dag.td URL: http://llvm.org/viewvc/llvm-project/llvm/trunk/test/TableGen/Dag.td?rev=141294&r1=141293&r2=141294&view=diff ============================================================================== --- llvm/trunk/test/TableGen/Dag.td (original) +++ llvm/trunk/test/TableGen/Dag.td Thu Oct 6 08:39:59 2011 @@ -1,4 +1,4 @@ -// RUN: tblgen %s | FileCheck %s +// RUN: llvm-tblgen %s | FileCheck %s // XFAIL: vg_leak //===----------------------------------------------------------------------===// Modified: llvm/trunk/test/TableGen/DefmInherit.td URL: http://llvm.org/viewvc/llvm-project/llvm/trunk/test/TableGen/DefmInherit.td?rev=141294&r1=141293&r2=141294&view=diff ============================================================================== --- llvm/trunk/test/TableGen/DefmInherit.td (original) +++ llvm/trunk/test/TableGen/DefmInherit.td Thu Oct 6 08:39:59 2011 @@ -1,4 +1,4 @@ -// RUN: tblgen %s | grep {zing = 4} | count 4 +// RUN: llvm-tblgen %s | grep {zing = 4} | count 4 // XFAIL: vg_leak class C1 { Modified: llvm/trunk/test/TableGen/DefmInsideMultiClass.td URL: http://llvm.org/viewvc/llvm-project/llvm/trunk/test/TableGen/DefmInsideMultiClass.td?rev=141294&r1=141293&r2=141294&view=diff ============================================================================== --- llvm/trunk/test/TableGen/DefmInsideMultiClass.td (original) +++ llvm/trunk/test/TableGen/DefmInsideMultiClass.td Thu Oct 6 08:39:59 2011 @@ -1,4 +1,4 @@ -// RUN: tblgen %s | grep ADDPSrr | count 1 +// RUN: llvm-tblgen %s | grep ADDPSrr | count 1 // XFAIL: vg_leak class Instruction opc, string Name> { Modified: llvm/trunk/test/TableGen/FieldAccess.td URL: http://llvm.org/viewvc/llvm-project/llvm/trunk/test/TableGen/FieldAccess.td?rev=141294&r1=141293&r2=141294&view=diff ============================================================================== --- llvm/trunk/test/TableGen/FieldAccess.td (original) +++ llvm/trunk/test/TableGen/FieldAccess.td Thu Oct 6 08:39:59 2011 @@ -1,4 +1,4 @@ -// RUN: tblgen %s +// RUN: llvm-tblgen %s // XFAIL: vg_leak class Bla Modified: llvm/trunk/test/TableGen/ForwardRef.td URL: http://llvm.org/viewvc/llvm-project/llvm/trunk/test/TableGen/ForwardRef.td?rev=141294&r1=141293&r2=141294&view=diff ============================================================================== --- llvm/trunk/test/TableGen/ForwardRef.td (original) +++ llvm/trunk/test/TableGen/ForwardRef.td Thu Oct 6 08:39:59 2011 @@ -1,4 +1,4 @@ -// RUN: tblgen %s -o - +// RUN: llvm-tblgen %s -o - // XFAIL: vg_leak class bar { Modified: llvm/trunk/test/TableGen/GeneralList.td URL: http://llvm.org/viewvc/llvm-project/llvm/trunk/test/TableGen/GeneralList.td?rev=141294&r1=141293&r2=141294&view=diff ============================================================================== --- llvm/trunk/test/TableGen/GeneralList.td (original) +++ llvm/trunk/test/TableGen/GeneralList.td Thu Oct 6 08:39:59 2011 @@ -1,4 +1,4 @@ -// RUN: tblgen %s +// RUN: llvm-tblgen %s // XFAIL: vg_leak // // Test to make sure that lists work with any data-type Modified: llvm/trunk/test/TableGen/Include.td URL: http://llvm.org/viewvc/llvm-project/llvm/trunk/test/TableGen/Include.td?rev=141294&r1=141293&r2=141294&view=diff ============================================================================== --- llvm/trunk/test/TableGen/Include.td (original) +++ llvm/trunk/test/TableGen/Include.td Thu Oct 6 08:39:59 2011 @@ -1,4 +1,4 @@ -// RUN: tblgen -I %p %s +// RUN: llvm-tblgen -I %p %s // XFAIL: vg_leak def BeforeInclude; Modified: llvm/trunk/test/TableGen/IntBitInit.td URL: http://llvm.org/viewvc/llvm-project/llvm/trunk/test/TableGen/IntBitInit.td?rev=141294&r1=141293&r2=141294&view=diff ============================================================================== --- llvm/trunk/test/TableGen/IntBitInit.td (original) +++ llvm/trunk/test/TableGen/IntBitInit.td Thu Oct 6 08:39:59 2011 @@ -1,4 +1,4 @@ -// RUN: tblgen %s +// RUN: llvm-tblgen %s // XFAIL: vg_leak def { bit A = 1; Modified: llvm/trunk/test/TableGen/LazyChange.td URL: http://llvm.org/viewvc/llvm-project/llvm/trunk/test/TableGen/LazyChange.td?rev=141294&r1=141293&r2=141294&view=diff ============================================================================== --- llvm/trunk/test/TableGen/LazyChange.td (original) +++ llvm/trunk/test/TableGen/LazyChange.td Thu Oct 6 08:39:59 2011 @@ -1,4 +1,4 @@ -// RUN: tblgen %s | grep {int Y = 3} +// RUN: llvm-tblgen %s | grep {int Y = 3} // XFAIL: vg_leak class C { Modified: llvm/trunk/test/TableGen/LetInsideMultiClasses.td URL: http://llvm.org/viewvc/llvm-project/llvm/trunk/test/TableGen/LetInsideMultiClasses.td?rev=141294&r1=141293&r2=141294&view=diff ============================================================================== --- llvm/trunk/test/TableGen/LetInsideMultiClasses.td (original) +++ llvm/trunk/test/TableGen/LetInsideMultiClasses.td Thu Oct 6 08:39:59 2011 @@ -1,4 +1,4 @@ -// RUN: tblgen %s | grep "bit IsDouble = 1;" | count 3 +// RUN: llvm-tblgen %s | grep "bit IsDouble = 1;" | count 3 // XFAIL: vg_leak class Instruction opc, string Name> { Modified: llvm/trunk/test/TableGen/ListArgs.td URL: http://llvm.org/viewvc/llvm-project/llvm/trunk/test/TableGen/ListArgs.td?rev=141294&r1=141293&r2=141294&view=diff ============================================================================== --- llvm/trunk/test/TableGen/ListArgs.td (original) +++ llvm/trunk/test/TableGen/ListArgs.td Thu Oct 6 08:39:59 2011 @@ -1,4 +1,4 @@ -// RUN: tblgen %s +// RUN: llvm-tblgen %s // XFAIL: vg_leak class B v> { Modified: llvm/trunk/test/TableGen/ListArgsSimple.td URL: http://llvm.org/viewvc/llvm-project/llvm/trunk/test/TableGen/ListArgsSimple.td?rev=141294&r1=141293&r2=141294&view=diff ============================================================================== --- llvm/trunk/test/TableGen/ListArgsSimple.td (original) +++ llvm/trunk/test/TableGen/ListArgsSimple.td Thu Oct 6 08:39:59 2011 @@ -1,4 +1,4 @@ -// RUN: tblgen %s +// RUN: llvm-tblgen %s // XFAIL: vg_leak class B { Modified: llvm/trunk/test/TableGen/ListConversion.td URL: http://llvm.org/viewvc/llvm-project/llvm/trunk/test/TableGen/ListConversion.td?rev=141294&r1=141293&r2=141294&view=diff ============================================================================== --- llvm/trunk/test/TableGen/ListConversion.td (original) +++ llvm/trunk/test/TableGen/ListConversion.td Thu Oct 6 08:39:59 2011 @@ -1,4 +1,4 @@ -// RUN: tblgen %s +// RUN: llvm-tblgen %s // XFAIL: vg_leak class A; class B : A; Modified: llvm/trunk/test/TableGen/ListManip.td URL: http://llvm.org/viewvc/llvm-project/llvm/trunk/test/TableGen/ListManip.td?rev=141294&r1=141293&r2=141294&view=diff ============================================================================== --- llvm/trunk/test/TableGen/ListManip.td (original) +++ llvm/trunk/test/TableGen/ListManip.td Thu Oct 6 08:39:59 2011 @@ -1,4 +1,4 @@ -// RUN: tblgen %s +// RUN: llvm-tblgen %s // XFAIL: vg_leak class Bli Modified: llvm/trunk/test/TableGen/ListOfList.td URL: http://llvm.org/viewvc/llvm-project/llvm/trunk/test/TableGen/ListOfList.td?rev=141294&r1=141293&r2=141294&view=diff ============================================================================== --- llvm/trunk/test/TableGen/ListOfList.td (original) +++ llvm/trunk/test/TableGen/ListOfList.td Thu Oct 6 08:39:59 2011 @@ -1,6 +1,6 @@ -// RUN tblgen %s | FileCheck %s +// RUN llvm-tblgen %s | FileCheck %s -// RUN: tblgen %s | grep {foo} | count 1 +// RUN: llvm-tblgen %s | grep {foo} | count 1 class Base { string text = t; Modified: llvm/trunk/test/TableGen/ListSlices.td URL: http://llvm.org/viewvc/llvm-project/llvm/trunk/test/TableGen/ListSlices.td?rev=141294&r1=141293&r2=141294&view=diff ============================================================================== --- llvm/trunk/test/TableGen/ListSlices.td (original) +++ llvm/trunk/test/TableGen/ListSlices.td Thu Oct 6 08:39:59 2011 @@ -1,4 +1,4 @@ -// RUN: tblgen %s +// RUN: llvm-tblgen %s // XFAIL: vg_leak def A { Modified: llvm/trunk/test/TableGen/LoLoL.td URL: http://llvm.org/viewvc/llvm-project/llvm/trunk/test/TableGen/LoLoL.td?rev=141294&r1=141293&r2=141294&view=diff ============================================================================== --- llvm/trunk/test/TableGen/LoLoL.td (original) +++ llvm/trunk/test/TableGen/LoLoL.td Thu Oct 6 08:39:59 2011 @@ -1,4 +1,4 @@ -// RUN: tblgen %s | FileCheck %s +// RUN: llvm-tblgen %s | FileCheck %s class Base v> { list values = v; Modified: llvm/trunk/test/TableGen/MultiClass.td URL: http://llvm.org/viewvc/llvm-project/llvm/trunk/test/TableGen/MultiClass.td?rev=141294&r1=141293&r2=141294&view=diff ============================================================================== --- llvm/trunk/test/TableGen/MultiClass.td (original) +++ llvm/trunk/test/TableGen/MultiClass.td Thu Oct 6 08:39:59 2011 @@ -1,4 +1,4 @@ -// RUN: tblgen %s | grep {zing = 4} | count 2 +// RUN: llvm-tblgen %s | grep {zing = 4} | count 2 // XFAIL: vg_leak class C1 { Modified: llvm/trunk/test/TableGen/MultiClassDefName.td URL: http://llvm.org/viewvc/llvm-project/llvm/trunk/test/TableGen/MultiClassDefName.td?rev=141294&r1=141293&r2=141294&view=diff ============================================================================== --- llvm/trunk/test/TableGen/MultiClassDefName.td (original) +++ llvm/trunk/test/TableGen/MultiClassDefName.td Thu Oct 6 08:39:59 2011 @@ -1,4 +1,4 @@ -// RUN: tblgen %s | grep WorldHelloCC | count 1 +// RUN: llvm-tblgen %s | grep WorldHelloCC | count 1 // XFAIL: vg_leak class C { Modified: llvm/trunk/test/TableGen/MultiClassInherit.td URL: http://llvm.org/viewvc/llvm-project/llvm/trunk/test/TableGen/MultiClassInherit.td?rev=141294&r1=141293&r2=141294&view=diff ============================================================================== --- llvm/trunk/test/TableGen/MultiClassInherit.td (original) +++ llvm/trunk/test/TableGen/MultiClassInherit.td Thu Oct 6 08:39:59 2011 @@ -1,4 +1,4 @@ -// RUN: tblgen %s | grep {zing = 4} | count 28 +// RUN: llvm-tblgen %s | grep {zing = 4} | count 28 // XFAIL: vg_leak class C1 { Modified: llvm/trunk/test/TableGen/MultiDef.td URL: http://llvm.org/viewvc/llvm-project/llvm/trunk/test/TableGen/MultiDef.td?rev=141294&r1=141293&r2=141294&view=diff ============================================================================== --- llvm/trunk/test/TableGen/MultiDef.td (original) +++ llvm/trunk/test/TableGen/MultiDef.td Thu Oct 6 08:39:59 2011 @@ -1,5 +1,5 @@ -// RUN: tblgen %s | FileCheck %s -// RUN: tblgen %s | FileCheck %s +// RUN: llvm-tblgen %s | FileCheck %s +// RUN: llvm-tblgen %s | FileCheck %s class Base { int value = i; Modified: llvm/trunk/test/TableGen/MultiPat.td URL: http://llvm.org/viewvc/llvm-project/llvm/trunk/test/TableGen/MultiPat.td?rev=141294&r1=141293&r2=141294&view=diff ============================================================================== --- llvm/trunk/test/TableGen/MultiPat.td (original) +++ llvm/trunk/test/TableGen/MultiPat.td Thu Oct 6 08:39:59 2011 @@ -1,4 +1,4 @@ -// RUN: tblgen %s | FileCheck %s +// RUN: llvm-tblgen %s | FileCheck %s class ValueType { int Size = size; Modified: llvm/trunk/test/TableGen/SetTheory.td URL: http://llvm.org/viewvc/llvm-project/llvm/trunk/test/TableGen/SetTheory.td?rev=141294&r1=141293&r2=141294&view=diff ============================================================================== --- llvm/trunk/test/TableGen/SetTheory.td (original) +++ llvm/trunk/test/TableGen/SetTheory.td Thu Oct 6 08:39:59 2011 @@ -1,5 +1,5 @@ // Test evaluation of set operations in dags. -// RUN: tblgen -print-sets %s | FileCheck %s +// RUN: llvm-tblgen -print-sets %s | FileCheck %s // XFAIL: vg_leak // // The -print-sets driver configures a primitive SetTheory instance that Modified: llvm/trunk/test/TableGen/Slice.td URL: http://llvm.org/viewvc/llvm-project/llvm/trunk/test/TableGen/Slice.td?rev=141294&r1=141293&r2=141294&view=diff ============================================================================== --- llvm/trunk/test/TableGen/Slice.td (original) +++ llvm/trunk/test/TableGen/Slice.td Thu Oct 6 08:39:59 2011 @@ -1,5 +1,5 @@ -// RUN: tblgen %s | grep {\\\[(set} | count 2 -// RUN: tblgen %s | grep {\\\[\\\]} | count 2 +// RUN: llvm-tblgen %s | grep {\\\[(set} | count 2 +// RUN: llvm-tblgen %s | grep {\\\[\\\]} | count 2 // XFAIL: vg_leak class ValueType { Modified: llvm/trunk/test/TableGen/String.td URL: http://llvm.org/viewvc/llvm-project/llvm/trunk/test/TableGen/String.td?rev=141294&r1=141293&r2=141294&view=diff ============================================================================== --- llvm/trunk/test/TableGen/String.td (original) +++ llvm/trunk/test/TableGen/String.td Thu Oct 6 08:39:59 2011 @@ -1,4 +1,4 @@ -// RUN: tblgen %s +// RUN: llvm-tblgen %s // XFAIL: vg_leak class x { string y = "missing terminating '\"' character"; Modified: llvm/trunk/test/TableGen/SuperSubclassSameName.td URL: http://llvm.org/viewvc/llvm-project/llvm/trunk/test/TableGen/SuperSubclassSameName.td?rev=141294&r1=141293&r2=141294&view=diff ============================================================================== --- llvm/trunk/test/TableGen/SuperSubclassSameName.td (original) +++ llvm/trunk/test/TableGen/SuperSubclassSameName.td Thu Oct 6 08:39:59 2011 @@ -1,4 +1,4 @@ -// RUN: tblgen < %s +// RUN: llvm-tblgen < %s // XFAIL: vg_leak // Test for template arguments that have the same name as superclass template // arguments. Modified: llvm/trunk/test/TableGen/TargetInstrInfo.td URL: http://llvm.org/viewvc/llvm-project/llvm/trunk/test/TableGen/TargetInstrInfo.td?rev=141294&r1=141293&r2=141294&view=diff ============================================================================== --- llvm/trunk/test/TableGen/TargetInstrInfo.td (original) +++ llvm/trunk/test/TableGen/TargetInstrInfo.td Thu Oct 6 08:39:59 2011 @@ -1,6 +1,6 @@ // This test describes how we eventually want to describe instructions in // the target independent code generators. -// RUN: tblgen %s +// RUN: llvm-tblgen %s // XFAIL: vg_leak // Target indep stuff. Modified: llvm/trunk/test/TableGen/TargetInstrSpec.td URL: http://llvm.org/viewvc/llvm-project/llvm/trunk/test/TableGen/TargetInstrSpec.td?rev=141294&r1=141293&r2=141294&view=diff ============================================================================== --- llvm/trunk/test/TableGen/TargetInstrSpec.td (original) +++ llvm/trunk/test/TableGen/TargetInstrSpec.td Thu Oct 6 08:39:59 2011 @@ -1,5 +1,5 @@ -// RUN: tblgen %s | grep {\\\[(set VR128:\$dst, (int_x86_sse2_add_pd VR128:\$src1, VR128:\$src2))\\\]} | count 1 -// RUN: tblgen %s | grep {\\\[(set VR128:\$dst, (int_x86_sse2_add_ps VR128:\$src1, VR128:\$src2))\\\]} | count 1 +// RUN: llvm-tblgen %s | grep {\\\[(set VR128:\$dst, (int_x86_sse2_add_pd VR128:\$src1, VR128:\$src2))\\\]} | count 1 +// RUN: llvm-tblgen %s | grep {\\\[(set VR128:\$dst, (int_x86_sse2_add_ps VR128:\$src1, VR128:\$src2))\\\]} | count 1 // XFAIL: vg_leak class ValueType { Modified: llvm/trunk/test/TableGen/TemplateArgRename.td URL: http://llvm.org/viewvc/llvm-project/llvm/trunk/test/TableGen/TemplateArgRename.td?rev=141294&r1=141293&r2=141294&view=diff ============================================================================== --- llvm/trunk/test/TableGen/TemplateArgRename.td (original) +++ llvm/trunk/test/TableGen/TemplateArgRename.td Thu Oct 6 08:39:59 2011 @@ -1,4 +1,4 @@ -// RUN: tblgen %s +// RUN: llvm-tblgen %s // XFAIL: vg_leak // Make sure there is no collision between XX and XX. Modified: llvm/trunk/test/TableGen/Tree.td URL: http://llvm.org/viewvc/llvm-project/llvm/trunk/test/TableGen/Tree.td?rev=141294&r1=141293&r2=141294&view=diff ============================================================================== --- llvm/trunk/test/TableGen/Tree.td (original) +++ llvm/trunk/test/TableGen/Tree.td Thu Oct 6 08:39:59 2011 @@ -1,5 +1,5 @@ // This tests to make sure we can parse tree patterns. -// RUN: tblgen %s +// RUN: llvm-tblgen %s // XFAIL: vg_leak class TreeNode; Modified: llvm/trunk/test/TableGen/TreeNames.td URL: http://llvm.org/viewvc/llvm-project/llvm/trunk/test/TableGen/TreeNames.td?rev=141294&r1=141293&r2=141294&view=diff ============================================================================== --- llvm/trunk/test/TableGen/TreeNames.td (original) +++ llvm/trunk/test/TableGen/TreeNames.td Thu Oct 6 08:39:59 2011 @@ -1,5 +1,5 @@ // This tests to make sure we can parse tree patterns with names. -// RUN: tblgen %s +// RUN: llvm-tblgen %s // XFAIL: vg_leak class TreeNode; Modified: llvm/trunk/test/TableGen/UnsetBitInit.td URL: http://llvm.org/viewvc/llvm-project/llvm/trunk/test/TableGen/UnsetBitInit.td?rev=141294&r1=141293&r2=141294&view=diff ============================================================================== --- llvm/trunk/test/TableGen/UnsetBitInit.td (original) +++ llvm/trunk/test/TableGen/UnsetBitInit.td Thu Oct 6 08:39:59 2011 @@ -1,4 +1,4 @@ -// RUN: tblgen %s +// RUN: llvm-tblgen %s // XFAIL: vg_leak class x { field bits<32> A; Modified: llvm/trunk/test/TableGen/UnterminatedComment.td URL: http://llvm.org/viewvc/llvm-project/llvm/trunk/test/TableGen/UnterminatedComment.td?rev=141294&r1=141293&r2=141294&view=diff ============================================================================== --- llvm/trunk/test/TableGen/UnterminatedComment.td (original) +++ llvm/trunk/test/TableGen/UnterminatedComment.td Thu Oct 6 08:39:59 2011 @@ -1,4 +1,4 @@ -// RUN: not tblgen < %s >& /dev/null +// RUN: not llvm-tblgen < %s >& /dev/null def x; Modified: llvm/trunk/test/TableGen/cast.td URL: http://llvm.org/viewvc/llvm-project/llvm/trunk/test/TableGen/cast.td?rev=141294&r1=141293&r2=141294&view=diff ============================================================================== --- llvm/trunk/test/TableGen/cast.td (original) +++ llvm/trunk/test/TableGen/cast.td Thu Oct 6 08:39:59 2011 @@ -1,4 +1,4 @@ -// RUN: tblgen %s | grep {add_ps} | count 3 +// RUN: llvm-tblgen %s | grep {add_ps} | count 3 // XFAIL: vg_leak class ValueType { Modified: llvm/trunk/test/TableGen/defmclass.td URL: http://llvm.org/viewvc/llvm-project/llvm/trunk/test/TableGen/defmclass.td?rev=141294&r1=141293&r2=141294&view=diff ============================================================================== --- llvm/trunk/test/TableGen/defmclass.td (original) +++ llvm/trunk/test/TableGen/defmclass.td Thu Oct 6 08:39:59 2011 @@ -1,4 +1,4 @@ -// RUN: tblgen %s | FileCheck %s +// RUN: llvm-tblgen %s | FileCheck %s // XFAIL: vg_leak class XD { bits<4> Prefix = 11; } Modified: llvm/trunk/test/TableGen/eq.td URL: http://llvm.org/viewvc/llvm-project/llvm/trunk/test/TableGen/eq.td?rev=141294&r1=141293&r2=141294&view=diff ============================================================================== --- llvm/trunk/test/TableGen/eq.td (original) +++ llvm/trunk/test/TableGen/eq.td Thu Oct 6 08:39:59 2011 @@ -1,4 +1,4 @@ -// RUN: tblgen %s | FileCheck %s +// RUN: llvm-tblgen %s | FileCheck %s // XFAIL: vg_leak // CHECK: Value = 0 // CHECK: Value = 1 Modified: llvm/trunk/test/TableGen/eqbit.td URL: http://llvm.org/viewvc/llvm-project/llvm/trunk/test/TableGen/eqbit.td?rev=141294&r1=141293&r2=141294&view=diff ============================================================================== --- llvm/trunk/test/TableGen/eqbit.td (original) +++ llvm/trunk/test/TableGen/eqbit.td Thu Oct 6 08:39:59 2011 @@ -1,4 +1,4 @@ -// RUN: tblgen %s | FileCheck %s +// RUN: llvm-tblgen %s | FileCheck %s // XFAIL: vg_leak // CHECK: a = 6 // CHECK: a = 5 Modified: llvm/trunk/test/TableGen/foreach.td URL: http://llvm.org/viewvc/llvm-project/llvm/trunk/test/TableGen/foreach.td?rev=141294&r1=141293&r2=141294&view=diff ============================================================================== --- llvm/trunk/test/TableGen/foreach.td (original) +++ llvm/trunk/test/TableGen/foreach.td Thu Oct 6 08:39:59 2011 @@ -1,6 +1,6 @@ -// RUN: tblgen %s | grep {Jr} | count 2 -// RUN: tblgen %s | grep {Sr} | count 2 -// RUN: tblgen %s | grep {NAME} | count 1 +// RUN: llvm-tblgen %s | grep {Jr} | count 2 +// RUN: llvm-tblgen %s | grep {Sr} | count 2 +// RUN: llvm-tblgen %s | grep {NAME} | count 1 // XFAIL: vg_leak // Variables for foreach Modified: llvm/trunk/test/TableGen/if.td URL: http://llvm.org/viewvc/llvm-project/llvm/trunk/test/TableGen/if.td?rev=141294&r1=141293&r2=141294&view=diff ============================================================================== --- llvm/trunk/test/TableGen/if.td (original) +++ llvm/trunk/test/TableGen/if.td Thu Oct 6 08:39:59 2011 @@ -1,4 +1,4 @@ -// RUN: tblgen %s | FileCheck %s +// RUN: llvm-tblgen %s | FileCheck %s // XFAIL: vg_leak // Support for an `!if' operator as part of a `let' statement. Modified: llvm/trunk/test/TableGen/ifbit.td URL: http://llvm.org/viewvc/llvm-project/llvm/trunk/test/TableGen/ifbit.td?rev=141294&r1=141293&r2=141294&view=diff ============================================================================== --- llvm/trunk/test/TableGen/ifbit.td (original) +++ llvm/trunk/test/TableGen/ifbit.td Thu Oct 6 08:39:59 2011 @@ -1,4 +1,4 @@ -// RUN: tblgen %s | FileCheck %s +// RUN: llvm-tblgen %s | FileCheck %s // XFAIL: vg_leak // CHECK: a = 6 // CHECK: a = 5 Modified: llvm/trunk/test/TableGen/lisp.td URL: http://llvm.org/viewvc/llvm-project/llvm/trunk/test/TableGen/lisp.td?rev=141294&r1=141293&r2=141294&view=diff ============================================================================== --- llvm/trunk/test/TableGen/lisp.td (original) +++ llvm/trunk/test/TableGen/lisp.td Thu Oct 6 08:39:59 2011 @@ -1,4 +1,4 @@ -// RUN: tblgen %s | grep {} +// RUN: llvm-tblgen %s | grep {} // XFAIL: vg_leak class List n> { Modified: llvm/trunk/test/TableGen/nested-comment.td URL: http://llvm.org/viewvc/llvm-project/llvm/trunk/test/TableGen/nested-comment.td?rev=141294&r1=141293&r2=141294&view=diff ============================================================================== --- llvm/trunk/test/TableGen/nested-comment.td (original) +++ llvm/trunk/test/TableGen/nested-comment.td Thu Oct 6 08:39:59 2011 @@ -1,4 +1,4 @@ -// RUN: tblgen < %s +// RUN: llvm-tblgen < %s // XFAIL: vg_leak /* foo Modified: llvm/trunk/test/TableGen/strconcat.td URL: http://llvm.org/viewvc/llvm-project/llvm/trunk/test/TableGen/strconcat.td?rev=141294&r1=141293&r2=141294&view=diff ============================================================================== --- llvm/trunk/test/TableGen/strconcat.td (original) +++ llvm/trunk/test/TableGen/strconcat.td Thu Oct 6 08:39:59 2011 @@ -1,4 +1,4 @@ -// RUN: tblgen %s | grep fufoo +// RUN: llvm-tblgen %s | grep fufoo // XFAIL: vg_leak class Y { Modified: llvm/trunk/test/TableGen/subst.td URL: http://llvm.org/viewvc/llvm-project/llvm/trunk/test/TableGen/subst.td?rev=141294&r1=141293&r2=141294&view=diff ============================================================================== --- llvm/trunk/test/TableGen/subst.td (original) +++ llvm/trunk/test/TableGen/subst.td Thu Oct 6 08:39:59 2011 @@ -1,9 +1,9 @@ -// RUN: tblgen %s | grep {Smith} | count 7 -// RUN: tblgen %s | grep {Johnson} | count 2 -// RUN: tblgen %s | grep {FIRST} | count 1 -// RUN: tblgen %s | grep {LAST} | count 1 -// RUN: tblgen %s | grep {TVAR} | count 2 -// RUN: tblgen %s | grep {Bogus} | count 1 +// RUN: llvm-tblgen %s | grep {Smith} | count 7 +// RUN: llvm-tblgen %s | grep {Johnson} | count 2 +// RUN: llvm-tblgen %s | grep {FIRST} | count 1 +// RUN: llvm-tblgen %s | grep {LAST} | count 1 +// RUN: llvm-tblgen %s | grep {TVAR} | count 2 +// RUN: llvm-tblgen %s | grep {Bogus} | count 1 // XFAIL: vg_leak class Honorific { Modified: llvm/trunk/test/TableGen/subst2.td URL: http://llvm.org/viewvc/llvm-project/llvm/trunk/test/TableGen/subst2.td?rev=141294&r1=141293&r2=141294&view=diff ============================================================================== --- llvm/trunk/test/TableGen/subst2.td (original) +++ llvm/trunk/test/TableGen/subst2.td Thu Oct 6 08:39:59 2011 @@ -1,4 +1,4 @@ -// RUN: tblgen %s | FileCheck %s +// RUN: llvm-tblgen %s | FileCheck %s // XFAIL: vg_leak // CHECK: No subst // CHECK: No foo Modified: llvm/trunk/test/TableGen/usevalname.td URL: http://llvm.org/viewvc/llvm-project/llvm/trunk/test/TableGen/usevalname.td?rev=141294&r1=141293&r2=141294&view=diff ============================================================================== --- llvm/trunk/test/TableGen/usevalname.td (original) +++ llvm/trunk/test/TableGen/usevalname.td Thu Oct 6 08:39:59 2011 @@ -1,4 +1,4 @@ -// RUN: tblgen %s | FileCheck %s +// RUN: llvm-tblgen %s | FileCheck %s // XFAIL: vg_leak class Instr pat> { Modified: llvm/trunk/test/lib/llvm.exp URL: http://llvm.org/viewvc/llvm-project/llvm/trunk/test/lib/llvm.exp?rev=141294&r1=141293&r2=141294&view=diff ============================================================================== --- llvm/trunk/test/lib/llvm.exp (original) +++ llvm/trunk/test/lib/llvm.exp Thu Oct 6 08:39:59 2011 @@ -111,7 +111,7 @@ regsub -all {llvm-ranlib } $new_line "$valgrind llvm-ranlib " new_line regsub -all {([^a-zA-Z_-])opt } $new_line "\\1$valgrind opt " new_line regsub -all {^opt } $new_line "$valgrind opt " new_line - regsub -all {tblgen } $new_line "$valgrind tblgen " new_line + regsub -all {llvm-tblgen } $new_line "$valgrind llvm-tblgen " new_line regsub -all "not $valgrind " $new_line "$valgrind not " new_line return $new_line Modified: llvm/trunk/test/lit.cfg URL: http://llvm.org/viewvc/llvm-project/llvm/trunk/test/lit.cfg?rev=141294&r1=141293&r2=141294&view=diff ============================================================================== --- llvm/trunk/test/lit.cfg (original) +++ llvm/trunk/test/lit.cfg Thu Oct 6 08:39:59 2011 @@ -198,7 +198,7 @@ # Don't match '.opt', '-opt', # '^opt' or '/opt'. r"\bmacho-dump\b", r"(? References: <20111004151452.DE8AB2A6C12C@llvm.org> <73740610-9873-41C1-A673-F20BF0108421@2pi.dk> Message-ID: <5FF789B2-7BC9-4B8B-A2D1-10F0DDFF9FA0@2pi.dk> On Oct 6, 2011, at 5:42 AM, Che-Liang Chiou wrote: > I have sent out proposal for discussion earlier (search title: > proposal: add macro expansion of for-loop to TableGen). If you have > any comments, please reply to that thread. Thanks! I am sorry nobody replied to that! However, you cannot add major feature without submitting the patch for review on llvm-commits first. Please revert this patch, and let us discuss. http://llvm.org/docs/DeveloperPolicy.html#reviews /jakob From stoklund at 2pi.dk Thu Oct 6 09:30:33 2011 From: stoklund at 2pi.dk (Jakob Stoklund Olesen) Date: Thu, 6 Oct 2011 07:30:33 -0700 Subject: [llvm-commits] [llvm] r141230 - /llvm/trunk/include/llvm/TableGen/Record.h In-Reply-To: <20111005224225.1A0252A6C12C@llvm.org> References: <20111005224225.1A0252A6C12C@llvm.org> Message-ID: On Oct 5, 2011, at 3:42 PM, David Greene wrote: > Author: greened > Date: Wed Oct 5 17:42:17 2011 > New Revision: 141230 > > URL: http://llvm.org/viewvc/llvm-project?rev=141230&view=rev > Log: > Add Multidef Data Structures > > Add a set of data structures and members analogous to those used for > multiclass defs. These will represent a new kind of multiclass def: a > multidef. The idea behind the multidef is to process a list of items > and create a def record for each one inside the enclosing multiclass. > This allows the user to dynamically create a set of defs based on the > contents of a list. Hi David, Was this new feature reviewed? I liked Che-Liang Chiou's for loops better: http://lists.cs.uiuc.edu/pipermail/llvmdev/2011-August/042669.html It seems very limiting that multidefs only can be used inside multiclasses. /jakob From greened at obbligato.org Thu Oct 6 09:38:12 2011 From: greened at obbligato.org (David A. Greene) Date: Thu, 06 Oct 2011 09:38:12 -0500 Subject: [llvm-commits] [llvm] r141231 - in /llvm/trunk/lib/TableGen: TGLexer.cpp TGLexer.h In-Reply-To: (James Molloy's message of "Thu, 6 Oct 2011 08:04:04 +0100") References: <20111005224242.AFEF72A6C12C@llvm.org> Message-ID: James Molloy writes: > Hi David, > > --- llvm/trunk/lib/TableGen/TGLexer.cpp (original) > +++ llvm/trunk/lib/TableGen/TGLexer.cpp Wed Oct 5 17:42:35 2011 > @@ -228,6 +228,7 @@ > > if (Len == 5 && !memcmp(IdentStart, "class", 5)) return tgtok::Class; > if (Len == 3 && !memcmp(IdentStart, "def", 3)) return tgtok::Def; > + if (Len == 8 && !memcmp(IdentStart, "multidef", 3)) return tgtok::MultiDef; > if (Len == 4 && !memcmp(IdentStart, "defm", 4)) return tgtok::Defm; > if (Len == 10 && !memcmp(IdentStart, "multiclass", 10)) > return tgtok::MultiClass; > > That doesn't look right, it looks like a copy-paste error. Would '8' not make more sense in the third parameter to memcmp? Yep. Will fix. Thanks! -Dave From greened at obbligato.org Thu Oct 6 09:37:55 2011 From: greened at obbligato.org (David Greene) Date: Thu, 06 Oct 2011 14:37:55 -0000 Subject: [llvm-commits] [llvm] r141295 - /llvm/trunk/lib/TableGen/TGLexer.cpp Message-ID: <20111006143800.A63352A6C12C@llvm.org> Author: greened Date: Thu Oct 6 09:37:47 2011 New Revision: 141295 URL: http://llvm.org/viewvc/llvm-project?rev=141295&view=rev Log: Fix Typo Compare the entire keyword string. Modified: llvm/trunk/lib/TableGen/TGLexer.cpp Modified: llvm/trunk/lib/TableGen/TGLexer.cpp URL: http://llvm.org/viewvc/llvm-project/llvm/trunk/lib/TableGen/TGLexer.cpp?rev=141295&r1=141294&r2=141295&view=diff ============================================================================== --- llvm/trunk/lib/TableGen/TGLexer.cpp (original) +++ llvm/trunk/lib/TableGen/TGLexer.cpp Thu Oct 6 09:37:47 2011 @@ -228,7 +228,7 @@ if (Len == 5 && !memcmp(IdentStart, "class", 5)) return tgtok::Class; if (Len == 3 && !memcmp(IdentStart, "def", 3)) return tgtok::Def; - if (Len == 8 && !memcmp(IdentStart, "multidef", 3)) return tgtok::MultiDef; + if (Len == 8 && !memcmp(IdentStart, "multidef", 8)) return tgtok::MultiDef; if (Len == 4 && !memcmp(IdentStart, "defm", 4)) return tgtok::Defm; if (Len == 10 && !memcmp(IdentStart, "multiclass", 10)) return tgtok::MultiClass; From greened at obbligato.org Thu Oct 6 09:50:15 2011 From: greened at obbligato.org (David A. Greene) Date: Thu, 06 Oct 2011 09:50:15 -0500 Subject: [llvm-commits] [llvm] r141234 - /llvm/trunk/test/TableGen/MultiDef.td In-Reply-To: <4E8D8850.5030409@gmail.com> (=?utf-8?B?IlTDtnLDtms=?= Edwin"'s message of "Thu, 06 Oct 2011 13:52:00 +0300") References: <20111005224247.4D6262A6C12C@llvm.org> <4E8D8850.5030409@gmail.com> Message-ID: T?r?k Edwin writes: > On 2011-10-06 01:42, David Greene wrote: >> Author: greened >> Date: Wed Oct 5 17:42:47 2011 >> New Revision: 141234 >> >> URL: http://llvm.org/viewvc/llvm-project?rev=141234&view=rev >> Log: >> Add a Multidef Test >> >> Add a simple test for multidefs. > > > SVN r141274 make check fails. Is there something wrong with my build env? Huh. I built and checked each revision before committing. I'll double-check... > Failing Tests (2): > LLVM :: TableGen/MultiDef.td > LLVM :: TableGen/MultiPat.td Hrm...I see it now too. Strange. I double-checked my build logs and I did not see this problem before commit. ToT works. -Dave From peter at pcc.me.uk Thu Oct 6 10:18:21 2011 From: peter at pcc.me.uk (Peter Collingbourne) Date: Thu, 6 Oct 2011 16:18:21 +0100 Subject: [llvm-commits] [llvm] r141234 - /llvm/trunk/test/TableGen/MultiDef.td In-Reply-To: References: <20111005224247.4D6262A6C12C@llvm.org> <4E8D8850.5030409@gmail.com> Message-ID: <20111006151821.GA26936@pcc.me.uk> On Thu, Oct 06, 2011 at 09:50:15AM -0500, David A. Greene wrote: > T?r?k Edwin writes: > > > On 2011-10-06 01:42, David Greene wrote: > >> Author: greened > >> Date: Wed Oct 5 17:42:47 2011 > >> New Revision: 141234 > >> > >> URL: http://llvm.org/viewvc/llvm-project?rev=141234&view=rev > >> Log: > >> Add a Multidef Test > >> > >> Add a simple test for multidefs. > > > > > > SVN r141274 make check fails. Is there something wrong with my build env? > > Huh. I built and checked each revision before committing. I'll > double-check... > > > Failing Tests (2): > > LLVM :: TableGen/MultiDef.td > > LLVM :: TableGen/MultiPat.td > > Hrm...I see it now too. Strange. I double-checked my build logs and I > did not see this problem before commit. > > ToT works. Sorry, this was my fault. I forgot to update the tests when I renamed tblgen to llvm-tblgen. This should be fixed in r141294. Thanks, -- Peter From edwintorok at gmail.com Thu Oct 6 10:19:20 2011 From: edwintorok at gmail.com (=?ISO-8859-1?Q?T=F6r=F6k_Edwin?=) Date: Thu, 06 Oct 2011 18:19:20 +0300 Subject: [llvm-commits] [llvm] r141234 - /llvm/trunk/test/TableGen/MultiDef.td In-Reply-To: <20111006151821.GA26936@pcc.me.uk> References: <20111005224247.4D6262A6C12C@llvm.org> <4E8D8850.5030409@gmail.com> <20111006151821.GA26936@pcc.me.uk> Message-ID: <4E8DC6F8.3060202@gmail.com> On 2011-10-06 18:18, Peter Collingbourne wrote: > On Thu, Oct 06, 2011 at 09:50:15AM -0500, David A. Greene wrote: >> T?r?k Edwin writes: >> >>> On 2011-10-06 01:42, David Greene wrote: >>>> Author: greened >>>> Date: Wed Oct 5 17:42:47 2011 >>>> New Revision: 141234 >>>> >>>> URL: http://llvm.org/viewvc/llvm-project?rev=141234&view=rev >>>> Log: >>>> Add a Multidef Test >>>> >>>> Add a simple test for multidefs. >>> >>> >>> SVN r141274 make check fails. Is there something wrong with my build env? >> >> Huh. I built and checked each revision before committing. I'll >> double-check... >> >>> Failing Tests (2): >>> LLVM :: TableGen/MultiDef.td >>> LLVM :: TableGen/MultiPat.td >> >> Hrm...I see it now too. Strange. I double-checked my build logs and I >> did not see this problem before commit. >> >> ToT works. > > Sorry, this was my fault. I forgot to update the tests when I renamed > tblgen to llvm-tblgen. This should be fixed in r141294. Yes ToT works here as well now. Best regards, --Edwin From stoklund at 2pi.dk Thu Oct 6 10:34:07 2011 From: stoklund at 2pi.dk (Jakob Stoklund Olesen) Date: Thu, 6 Oct 2011 08:34:07 -0700 Subject: [llvm-commits] [llvm] r141229 - in /llvm/trunk/lib/TableGen: TGParser.cpp TGParser.h In-Reply-To: <20111005224207.9796E2A6C12C@llvm.org> References: <20111005224207.9796E2A6C12C@llvm.org> Message-ID: <5A5B045E-4738-417A-A5BD-6D23D989CB30@2pi.dk> On Oct 5, 2011, at 3:42 PM, David Greene wrote: > Author: greened > Date: Wed Oct 5 17:42:07 2011 > New Revision: 141229 > > URL: http://llvm.org/viewvc/llvm-project?rev=141229&view=rev > Log: > Refactor Multiclass Def Processing > > Move the code to instantiate a multiclass def, bind its arguments and > resolve its members into three helper functions. These will be reused > to support a new kind of multiclass def: a multidef. > > Modified: > llvm/trunk/lib/TableGen/TGParser.cpp > llvm/trunk/lib/TableGen/TGParser.h Hi David, Was this new feature reviewed? I liked Che-Liang Chiou's for loops better: http://lists.cs.uiuc.edu/pipermail/llvmdev/2011-August/042669.html /jakob From greened at obbligato.org Thu Oct 6 11:41:03 2011 From: greened at obbligato.org (David A. Greene) Date: Thu, 06 Oct 2011 11:41:03 -0500 Subject: [llvm-commits] [llvm] r141230 - /llvm/trunk/include/llvm/TableGen/Record.h In-Reply-To: (Jakob Stoklund Olesen's message of "Thu, 6 Oct 2011 07:30:33 -0700") References: <20111005224225.1A0252A6C12C@llvm.org> Message-ID: Jakob Stoklund Olesen writes: > I liked Che-Liang Chiou's for loops better: http://lists.cs.uiuc.edu/pipermail/llvmdev/2011-August/042669.html Yes, I think that could work. One thing I think could use some tweaking: (Equivalent TableGen code with a for-loop) ---------------------------------------- multiclass PTX_FLOAT_4OP { for nbit = [32, 32, 64, 64], op_suffix = [r, i, r, i], op_type = [RegF32, f32imm, RegF64, f64imm], op_node_type = [RegF32, fpimm, RegF64, fpimm] in { def rr#op_suffix#nbit : InstPTX<(outs RegF#nbit:$d), (ins RegF#nbit:$a, RegF#nbit:$b, #op_type:$c), !strconcat(opcstr, ".f#nbit\t$d, $a, $b, $c"), [(set RegF#nbit:$d, (opnode2 (opnode1 RegF#nbit:$a, RegF#nbit:$b), #op_node_type:$c))]>; } } It looks as if this does a "zip iterator" on the various lists. I would also like the ability do generate the "cross product." Nested for loops would allow that. Is nesting part of the proposal? >From my very cursory glance, this looks like a good improvement. I don't like the idea of it being a separate preprocessing phase however, because I can imagine the utility of having it interoperate with other TableGen constructs. -Dave From benny.kra at googlemail.com Thu Oct 6 13:23:57 2011 From: benny.kra at googlemail.com (Benjamin Kramer) Date: Thu, 06 Oct 2011 18:23:57 -0000 Subject: [llvm-commits] [llvm] r141299 - /llvm/trunk/lib/TableGen/TGLexer.cpp Message-ID: <20111006182357.6A8322A6C12C@llvm.org> Author: d0k Date: Thu Oct 6 13:23:56 2011 New Revision: 141299 URL: http://llvm.org/viewvc/llvm-project?rev=141299&view=rev Log: Simplify code. No functionality change. Modified: llvm/trunk/lib/TableGen/TGLexer.cpp Modified: llvm/trunk/lib/TableGen/TGLexer.cpp URL: http://llvm.org/viewvc/llvm-project/llvm/trunk/lib/TableGen/TGLexer.cpp?rev=141299&r1=141298&r2=141299&view=diff ============================================================================== --- llvm/trunk/lib/TableGen/TGLexer.cpp (original) +++ llvm/trunk/lib/TableGen/TGLexer.cpp Thu Oct 6 13:23:56 2011 @@ -208,40 +208,38 @@ tgtok::TokKind TGLexer::LexIdentifier() { // The first letter is [a-zA-Z_#]. const char *IdentStart = TokStart; - + // Match the rest of the identifier regex: [0-9a-zA-Z_#]* while (isalpha(*CurPtr) || isdigit(*CurPtr) || *CurPtr == '_' || *CurPtr == '#') ++CurPtr; - - + // Check to see if this identifier is a keyword. - unsigned Len = CurPtr-IdentStart; - - if (Len == 3 && !memcmp(IdentStart, "int", 3)) return tgtok::Int; - if (Len == 3 && !memcmp(IdentStart, "bit", 3)) return tgtok::Bit; - if (Len == 4 && !memcmp(IdentStart, "bits", 4)) return tgtok::Bits; - if (Len == 6 && !memcmp(IdentStart, "string", 6)) return tgtok::String; - if (Len == 4 && !memcmp(IdentStart, "list", 4)) return tgtok::List; - if (Len == 4 && !memcmp(IdentStart, "code", 4)) return tgtok::Code; - if (Len == 3 && !memcmp(IdentStart, "dag", 3)) return tgtok::Dag; - - if (Len == 5 && !memcmp(IdentStart, "class", 5)) return tgtok::Class; - if (Len == 3 && !memcmp(IdentStart, "def", 3)) return tgtok::Def; - if (Len == 8 && !memcmp(IdentStart, "multidef", 8)) return tgtok::MultiDef; - if (Len == 4 && !memcmp(IdentStart, "defm", 4)) return tgtok::Defm; - if (Len == 10 && !memcmp(IdentStart, "multiclass", 10)) - return tgtok::MultiClass; - if (Len == 5 && !memcmp(IdentStart, "field", 5)) return tgtok::Field; - if (Len == 3 && !memcmp(IdentStart, "let", 3)) return tgtok::Let; - if (Len == 2 && !memcmp(IdentStart, "in", 2)) return tgtok::In; - - if (Len == 7 && !memcmp(IdentStart, "include", 7)) { + StringRef Str(IdentStart, CurPtr-IdentStart); + + if (Str == "int") return tgtok::Int; + if (Str == "bit") return tgtok::Bit; + if (Str == "bits") return tgtok::Bits; + if (Str == "string") return tgtok::String; + if (Str == "list") return tgtok::List; + if (Str == "code") return tgtok::Code; + if (Str == "dag") return tgtok::Dag; + + if (Str == "class") return tgtok::Class; + if (Str == "def") return tgtok::Def; + if (Str == "multidef") return tgtok::MultiDef; + if (Str == "defm") return tgtok::Defm; + if (Str == "multiclass") return tgtok::MultiClass; + if (Str == "field") return tgtok::Field; + if (Str == "let") return tgtok::Let; + if (Str == "in") return tgtok::In; + + if (Str == "include") { if (LexInclude()) return tgtok::Error; return Lex(); } - - CurStrVal.assign(IdentStart, CurPtr); + + CurStrVal.assign(Str.begin(), Str.end()); return tgtok::Id; } From nicholas at mxc.ca Thu Oct 6 13:41:29 2011 From: nicholas at mxc.ca (Nick Lewycky) Date: Thu, 06 Oct 2011 11:41:29 -0700 Subject: [llvm-commits] [llvm] r141299 - /llvm/trunk/lib/TableGen/TGLexer.cpp In-Reply-To: <20111006182357.6A8322A6C12C@llvm.org> References: <20111006182357.6A8322A6C12C@llvm.org> Message-ID: <4E8DF659.609@mxc.ca> Benjamin Kramer wrote: > Author: d0k > Date: Thu Oct 6 13:23:56 2011 > New Revision: 141299 > > URL: http://llvm.org/viewvc/llvm-project?rev=141299&view=rev > Log: > Simplify code. No functionality change. > > Modified: > llvm/trunk/lib/TableGen/TGLexer.cpp > > + if (Str == "int") return tgtok::Int; > + if (Str == "bit") return tgtok::Bit; > + if (Str == "bits") return tgtok::Bits; > + if (Str == "string") return tgtok::String; > + if (Str == "list") return tgtok::List; > + if (Str == "code") return tgtok::Code; > + if (Str == "dag") return tgtok::Dag; This sounds like a job for ADT/StringSwitch.h! Nick From grosser at fim.uni-passau.de Thu Oct 6 13:49:38 2011 From: grosser at fim.uni-passau.de (Tobias Grosser) Date: Thu, 06 Oct 2011 18:49:38 -0000 Subject: [llvm-commits] [polly] r141303 - /polly/trunk/www/menu.html.incl Message-ID: <20111006184938.12ADE2A6C12C@llvm.org> Author: grosser Date: Thu Oct 6 13:49:37 2011 New Revision: 141303 URL: http://llvm.org/viewvc/llvm-project?rev=141303&view=rev Log: Change location of our buildbot Modified: polly/trunk/www/menu.html.incl Modified: polly/trunk/www/menu.html.incl URL: http://llvm.org/viewvc/llvm-project/polly/trunk/www/menu.html.incl?rev=141303&r1=141302&r2=141303&view=diff ============================================================================== --- polly/trunk/www/menu.html.incl (original) +++ polly/trunk/www/menu.html.incl Thu Oct 6 13:49:37 2011 @@ -21,7 +21,7 @@ polly-dev Mailing List Bug Reports - Buildbot + Buildbot
-

-A special "multidef" may be used inside a multiclass to generate -several defs given a list of values. -

- -
-
-class Base<int i> {
-  int value = i;
-}
-
-multiclass Multi<list<int> values> {
-  def ONE : Base<values[0]>;
-  def TWO : Base<values[1]>;
-
-  multidef COUNT<values, int v, 2> : Base<v>;
-}
-
-defm List : Multi<[1, 2, 3, 4, 5, 6]<;
-...
-
-// Results
-def ListCOUNT {
-  int v = ?;
-  int value = v;
-  list Multi::values = [1, 2, 3, 4, 5, 6];
-}
-def ListONE {
-  int value = 1;
-}
-def ListTWO {
-  int value = 2;
-}
-def MD2.ListCOUNT {
-  int value = 3;
-}
-def MD3.ListCOUNT {
-  int value = 4;
-}
-def MD4.ListCOUNT {
-  int value = 5;
-}
-def MD5.ListCOUNT {
-  int value = 6;
-}
-
-
- -

-A multidef takes three "arguments" in the <> notation after the multidef -name. The first is a list of items to process. The second is a declaration. -This declaration creates a temporary name used as an iterator. It picks up the -value of each processed list item as TableGen generates defs from the multidef. -This temporary may be named and passed into the multidef body as shown in the -example above. This provides a powerful way to generate defs with various -values from a single multidef. The final "argument" is an integer value -indicating where in the list to begin processing. In the above example we -chose to begin list processing with the third item (index 2). -

Modified: llvm/trunk/include/llvm/TableGen/Record.h URL: http://llvm.org/viewvc/llvm-project/llvm/trunk/include/llvm/TableGen/Record.h?rev=141378&r1=141377&r2=141378&view=diff ============================================================================== --- llvm/trunk/include/llvm/TableGen/Record.h (original) +++ llvm/trunk/include/llvm/TableGen/Record.h Fri Oct 7 13:25:05 2011 @@ -1568,23 +1568,6 @@ typedef std::vector RecordVector; RecordVector DefPrototypes; - struct MultiDef { - Record *Rec; // The base record for all defs generated. - // This serves as the multiclass def prototype. - TypedInit *List; // A list of values to process. - // Each one generates a new def. - IntInit *Start; // This specified the list index from which to start - // processing. - std::string ItemName; // The name of a temporary iterator value to - // track the current list item being processed. - - MultiDef(Record *R, TypedInit *L, IntInit *S, const std::string &I) - : Rec(R), List(L), Start(S), ItemName(I) {}; - }; - - typedef std::vector MultiDefVector; - MultiDefVector MultiDefPrototypes; - void dump() const; MultiClass(const std::string &Name, SMLoc Loc, RecordKeeper &Records) : Modified: llvm/trunk/lib/TableGen/TGLexer.cpp URL: http://llvm.org/viewvc/llvm-project/llvm/trunk/lib/TableGen/TGLexer.cpp?rev=141378&r1=141377&r2=141378&view=diff ============================================================================== --- llvm/trunk/lib/TableGen/TGLexer.cpp (original) +++ llvm/trunk/lib/TableGen/TGLexer.cpp Fri Oct 7 13:25:05 2011 @@ -232,7 +232,6 @@ .Case("dag", tgtok::Dag) .Case("class", tgtok::Class) .Case("def", tgtok::Def) - .Case("multidef", tgtok::MultiDef) .Case("defm", tgtok::Defm) .Case("multiclass", tgtok::MultiClass) .Case("field", tgtok::Field) Modified: llvm/trunk/lib/TableGen/TGLexer.h URL: http://llvm.org/viewvc/llvm-project/llvm/trunk/lib/TableGen/TGLexer.h?rev=141378&r1=141377&r2=141378&view=diff ============================================================================== --- llvm/trunk/lib/TableGen/TGLexer.h (original) +++ llvm/trunk/lib/TableGen/TGLexer.h Fri Oct 7 13:25:05 2011 @@ -41,7 +41,7 @@ equal, question, // = ? // Keywords. - Bit, Bits, Class, Code, Dag, Def, MultiDef, Defm, Field, In, Int, Let, List, + Bit, Bits, Class, Code, Dag, Def, Defm, Field, In, Int, Let, List, MultiClass, String, // !keywords. Modified: llvm/trunk/lib/TableGen/TGParser.cpp URL: http://llvm.org/viewvc/llvm-project/llvm/trunk/lib/TableGen/TGParser.cpp?rev=141378&r1=141377&r2=141378&view=diff ============================================================================== --- llvm/trunk/lib/TableGen/TGParser.cpp (original) +++ llvm/trunk/lib/TableGen/TGParser.cpp Fri Oct 7 13:25:05 2011 @@ -1720,90 +1720,6 @@ return false; } - -/// ParseMultiDef - Parse and return a multiclass multidef, return the record -/// corresponding to it. This returns null on error. -/// -/// MultiDefInst ::= MULTIDEF ObjectName '<' Value ',' Declaration ',' -/// Value '>' ObjectBody -/// -bool TGParser::ParseMultiDef(MultiClass *CurMultiClass) { - assert(CurMultiClass && "No multiclass for multidef!"); - - SMLoc DefLoc = Lex.getLoc(); - assert(Lex.getCode() == tgtok::MultiDef && "Unknown tok"); - Lex.Lex(); // Eat the 'multidef' token. - - // Parse ObjectName and make a record for it. - Record *CurRec = new Record(ParseObjectName(), DefLoc, Records); - - if (Lex.getCode() != tgtok::less) - return TokError("multidef init requires a non-empty list of values"); - Lex.Lex(); // Eat the '<' - - Init *ListI = ParseValue(CurRec, 0); - if (ListI == 0) - return TokError("First multidef init must be of list type"); - - if (Lex.getCode() != tgtok::comma) - return TokError("expected comma in multidef"); - Lex.Lex(); // Eat the comma - - std::string ItemName = ParseDeclaration(CurRec, false/*Not a template arg*/); - if (ItemName.empty()) - return TokError("expected declaration in multidef"); - - if (Lex.getCode() != tgtok::comma) - return TokError("expected comma in multidef"); - Lex.Lex(); // Eat the comma - - Init *IntI = ParseValue(CurRec, 0); - if (IntI == 0) - return TokError("expected integer value in multidef"); - - if (Lex.getCode() != tgtok::greater) - return TokError("multidef init requires a non-empty list of values"); - Lex.Lex(); // Eat the '>' - - TypedInit *List = dynamic_cast(ListI); - if (dynamic_cast(List->getType()) == 0) - return TokError("First multidef init must be of list type"); - - IntInit *Int = dynamic_cast(IntI); - if (Int == 0) - return TokError("Second multidef init must be a constant integer"); - - // Add it to the multiclass. - for (unsigned i = 0, e = CurMultiClass->MultiDefPrototypes.size(); - i != e; ++i) - if (CurMultiClass->MultiDefPrototypes[i].Rec->getName() - == CurRec->getName()) - return Error(DefLoc, "multidef '" + CurRec->getName() + - "' already defined in this multiclass!"); - - CurMultiClass->MultiDefPrototypes.push_back( - MultiClass::MultiDef(CurRec, List, Int, ItemName)); - - if (ParseObjectBody(CurRec)) - return true; - - // If ObjectBody has template arguments, it's an error. - assert(CurRec->getTemplateArgs().empty() && "How'd this get template args?"); - - // Copy the template arguments for the multiclass into the - // multidef. - const std::vector &TArgs = CurMultiClass->Rec.getTemplateArgs(); - - for (unsigned i = 0, e = TArgs.size(); i != e; ++i) { - const RecordVal *RV = CurMultiClass->Rec.getValue(TArgs[i]); - assert(RV && "Template arg doesn't exist?"); - CurRec->addValue(*RV); - } - - return false; -} - - /// ParseClass - Parse a tblgen class definition. /// /// ClassInst ::= CLASS ID TemplateArgList? ObjectBody @@ -1989,12 +1905,10 @@ while (Lex.getCode() != tgtok::r_brace) { switch (Lex.getCode()) { default: - return TokError("expected 'let', 'def', 'defm' or 'multidef'" - "in multiclass body"); + return TokError("expected 'let', 'def' or 'defm' in multiclass body"); case tgtok::Let: case tgtok::Def: case tgtok::Defm: - case tgtok::MultiDef: if (ParseObject(CurMultiClass)) return true; break; @@ -2177,92 +2091,6 @@ NewRecDefs.push_back(CurRec); } - // Loop over multidefs, instantiating them. - for (unsigned i = 0, e = MC->MultiDefPrototypes.size(); i != e; ++i) { - // Each multidef generates a set of defs, one per item in the - // given list. - - // Resolve the list now. This record serves as a base class for - // the individual records created below. - - Record *DefProto = MC->MultiDefPrototypes[i].Rec; - TypedInit *List = MC->MultiDefPrototypes[i].List; - IntInit *Start = MC->MultiDefPrototypes[i].Start; - - // This is the name of the second item in the multidef <> list. - // It is a temporary iterator that holds the current value of - // the list element being processed. - std::string &ItemName = MC->MultiDefPrototypes[i].ItemName; - - Record *BaseRec = InstantiateMulticlassDef(*MC, DefProto, DefmPrefix, - DefmPrefixLoc); - - // Make the list a member of the base record. - RecordVal ListV("__MDListInit__", List->getType(), 0); - ListV.setValue(List); - BaseRec->addValue(ListV); - - // Resolve the base multidef record to template args. This - // should resolve the list. We don't delete the arguments - // values because we want the created defs to inherit them. - // Each list item needs to be resolved against these values. - // They will be deleted when we do final processing of the - // instantiated def. - if (ResolveMulticlassDefArgs(*MC, BaseRec, DefmPrefixLoc, - SubClassLoc, TArgs, TemplateVals, - false/*Do not delete args*/)) - return Error(SubClassLoc, "could not instantiate def"); - - RecordVal *ListVP = BaseRec->getValue("__MDListInit__"); - ListInit *ListIn = dynamic_cast(ListVP->getValue()); - if (ListIn == 0) - return Error(SubClassLoc, "multidef init must be of list type"); - - // Remove the temporary list since we've resolve it and don't - // need it to be part of the defs. - BaseRec->removeValue("__MDListInit__"); - - // For each item in the list, create a def. - for(int64_t it = Start->getValue(); it < ListIn->getSize(); ++it) { - std::stringstream id; - id << it; - - // Create a record prefixed with MD., where is an - // incrementing value. This guarantees that defs created via - // multidefs are named uniquely. - Record *CurRec = InstantiateMulticlassDef(*MC, BaseRec, - "MD" + id.str() + ".", - DefmPrefixLoc); - - // Get the list item and resolve it. - Init *ItemVal = ListIn->resolveListElementReference(*CurRec, 0, it); - - if (!ItemVal) - return Error(SubClassLoc, "invalid list item"); - - // Set the temporary item (iterator) value now. - if (SetValue(CurRec, SubClassLoc, ItemName, std::vector(), ItemVal)) { - Error(DefmPrefixLoc, "when instantiating this defm"); - return true; - } - - // Resolve it next. - CurRec->resolveReferencesTo(CurRec->getValue(ItemName)); - - // Remove it. - CurRec->removeValue(ItemName); - - // Now instantiate the def as if it had been declared directly - // as part of the multicass. - if (ResolveMulticlassDefArgs(*MC, CurRec, DefmPrefixLoc, - SubClassLoc, TArgs, TemplateVals, - true/*Delete args*/)) - return Error(SubClassLoc, "could not instantiate def"); - - if (ResolveMulticlassDef(*MC, CurRec, DefProto, DefmPrefixLoc)) - return Error(SubClassLoc, "could not instantiate def"); - } - } if (Lex.getCode() != tgtok::comma) break; Lex.Lex(); // eat ','. @@ -2327,7 +2155,6 @@ /// ParseObject /// Object ::= ClassInst /// Object ::= DefInst -/// Object ::= MultiDefInst /// Object ::= MultiClassInst /// Object ::= DefMInst /// Object ::= LETCommand '{' ObjectList '}' @@ -2338,7 +2165,6 @@ return TokError("Expected class, def, defm, multiclass or let definition"); case tgtok::Let: return ParseTopLevelLet(MC); case tgtok::Def: return ParseDef(MC); - case tgtok::MultiDef: return ParseMultiDef(MC); case tgtok::Defm: return ParseDefm(MC); case tgtok::Class: return ParseClass(); case tgtok::MultiClass: return ParseMultiClass(); Modified: llvm/trunk/lib/TableGen/TGParser.h URL: http://llvm.org/viewvc/llvm-project/llvm/trunk/lib/TableGen/TGParser.h?rev=141378&r1=141377&r2=141378&view=diff ============================================================================== --- llvm/trunk/lib/TableGen/TGParser.h (original) +++ llvm/trunk/lib/TableGen/TGParser.h Fri Oct 7 13:25:05 2011 @@ -100,7 +100,6 @@ SMLoc DefmPrefixLoc); bool ParseDefm(MultiClass *CurMultiClass); bool ParseDef(MultiClass *CurMultiClass); - bool ParseMultiDef(MultiClass *CurMultiClass); bool ParseTopLevelLet(MultiClass *CurMultiClass); std::vector ParseLetList(); Removed: llvm/trunk/test/TableGen/MultiDef.td URL: http://llvm.org/viewvc/llvm-project/llvm/trunk/test/TableGen/MultiDef.td?rev=141377&view=auto ============================================================================== --- llvm/trunk/test/TableGen/MultiDef.td (original) +++ llvm/trunk/test/TableGen/MultiDef.td (removed) @@ -1,18 +0,0 @@ -// RUN: llvm-tblgen %s | FileCheck %s -// RUN: llvm-tblgen %s | FileCheck %s - -class Base { - int value = i; -} - -multiclass Multi values> { - def ONE : Base; - def TWO : Base; - - multidef COUNT : Base; -} - -defm List : Multi<[1, 2, 3, 4, 5, 6]>; - -// CHECK: MD4.ListCOUNT -// CHECK: int value = 6 Modified: llvm/trunk/test/TableGen/MultiPat.td URL: http://llvm.org/viewvc/llvm-project/llvm/trunk/test/TableGen/MultiPat.td?rev=141378&r1=141377&r2=141378&view=diff ============================================================================== --- llvm/trunk/test/TableGen/MultiPat.td (original) +++ llvm/trunk/test/TableGen/MultiPat.td Fri Oct 7 13:25:05 2011 @@ -83,21 +83,10 @@ // Define intrinsics def int_x86_sse2_add_ps : Intrinsic<"addps">; def int_x86_sse2_add_pd : Intrinsic<"addpd">; -def int_x86_sse2_sub_ps : Intrinsic<"subps">; -def int_x86_sse2_sub_pd : Intrinsic<"subpd">; def INTRINSIC : Intrinsic<"Dummy">; def bitconvert; -def add; -def sub; -class MakePatImpl patterns> : Pat; -class MakePat patterns, - string suffix, - string intr> : MakePatImpl(!subst("SUFFIX", suffix, intr)), - !subst(REGCLASS, VR128, - !subst(MNEMONIC, set, Decls.operand)))))>; +class MakePat patterns> : Pat; class Base opcode, dag opnds, dag iopnds, string asmstr, Intrinsic intr, list> patterns> @@ -106,7 +95,12 @@ !foreach(Decls.operand, Decls.pattern, !subst(INTRINSIC, intr, !subst(REGCLASS, VR128, - !subst(MNEMONIC, set, Decls.operand)))))>; + !subst(MNEMONIC, set, Decls.operand)))))>, + MakePat; multiclass arith opcode, string asmstr, string intr, list> patterns> { def PS : Base(!subst("SUFFIX", "_pd", intr)), patterns>; - - multidef pats, 1> : MakePat; - multidef pats, 1> : MakePat; } defm ADD : arith<0x58, "add", "int_x86_sse2_addSUFFIX", // rr Patterns [[(set REGCLASS:$dst, (INTRINSIC REGCLASS:$src1, REGCLASS:$src2))], [(set REGCLASS:$dst, (bitconvert (INTRINSIC REGCLASS:$src1, REGCLASS:$src2))), - (MNEMONIC REGCLASS:$dst, REGCLASS:$src)], - [(set REGCLASS:$dst, (add (INTRINSIC REGCLASS:$src1, REGCLASS:$src2))), - (MNEMONIC (add REGCLASS:$dst, REGCLASS:$src))]]>; + (MNEMONIC REGCLASS:$dst, REGCLASS:$src)]]>; // CHECK: [(set VR128:$dst, (int_x86_sse2_add_pd VR128:$src1, VR128:$src2))] // CHECK: [(set VR128:$dst, (int_x86_sse2_add_ps VR128:$src1, VR128:$src2))] -// CHECK: (set VR128:$dst, (add (int_x86_sse2_add_ps VR128:$src1, VR128:$src2))) -// CHECK: (set VR128:$dst, (add (int_x86_sse2_add_pd VR128:$src1, VR128:$src2))) - -defm SUB : arith<0x59, "sub", "int_x86_sse2_subSUFFIX", - // rr Patterns - [[(set REGCLASS:$dst, (INTRINSIC REGCLASS:$src1, REGCLASS:$src2))]]>; - -// CHECK: [(set VR128:$dst, (int_x86_sse2_sub_pd VR128:$src1, VR128:$src2))] -// CHECK: [(set VR128:$dst, (int_x86_sse2_sub_ps VR128:$src1, VR128:$src2))] Modified: llvm/trunk/utils/emacs/tablegen-mode.el URL: http://llvm.org/viewvc/llvm-project/llvm/trunk/utils/emacs/tablegen-mode.el?rev=141378&r1=141377&r2=141378&view=diff ============================================================================== --- llvm/trunk/utils/emacs/tablegen-mode.el (original) +++ llvm/trunk/utils/emacs/tablegen-mode.el Fri Oct 7 13:25:05 2011 @@ -13,7 +13,7 @@ (defvar tablegen-font-lock-keywords (let ((kw (regexp-opt '("class" "defm" "def" "field" "include" "in" - "let" "multiclass" "multidef") + "let" "multiclass") 'words)) (type-kw (regexp-opt '("bit" "bits" "code" "dag" "int" "list" "string") 'words)) Modified: llvm/trunk/utils/vim/tablegen.vim URL: http://llvm.org/viewvc/llvm-project/llvm/trunk/utils/vim/tablegen.vim?rev=141378&r1=141377&r2=141378&view=diff ============================================================================== --- llvm/trunk/utils/vim/tablegen.vim (original) +++ llvm/trunk/utils/vim/tablegen.vim Fri Oct 7 13:25:05 2011 @@ -14,7 +14,7 @@ syn case match -syn keyword tgKeyword def let in code dag field include defm multidef +syn keyword tgKeyword def let in code dag field include defm syn keyword tgType class int string list bit bits multiclass syn match tgNumber /\<\d\+\>/ From isanbard at gmail.com Fri Oct 7 13:25:38 2011 From: isanbard at gmail.com (Bill Wendling) Date: Fri, 07 Oct 2011 18:25:38 -0000 Subject: [llvm-commits] [llvm] r141379 - in /llvm/trunk: include/llvm-c/Object.h include/llvm/Object/COFF.h include/llvm/Object/ObjectFile.h lib/Object/COFFObjectFile.cpp lib/Object/ELFObjectFile.cpp lib/Object/MachOObjectFile.cpp lib/Object/Object.cpp tools/llvm-objdump/MachODump.cpp tools/llvm-objdump/llvm-objdump.cpp Message-ID: <20111007182538.2CDC7312800A@llvm.org> Author: void Date: Fri Oct 7 13:25:37 2011 New Revision: 141379 URL: http://llvm.org/viewvc/llvm-project?rev=141379&view=rev Log: Revert 141376 and 141377 due to breaking the build. --- Reverse-merging r141377 into '.': U tools/llvm-objdump/MachODump.cpp --- Reverse-merging r141376 into '.': U include/llvm/Object/COFF.h U include/llvm/Object/ObjectFile.h U include/llvm-c/Object.h U tools/llvm-objdump/llvm-objdump.cpp U lib/Object/MachOObjectFile.cpp U lib/Object/COFFObjectFile.cpp U lib/Object/Object.cpp U lib/Object/ELFObjectFile.cpp Modified: llvm/trunk/include/llvm-c/Object.h llvm/trunk/include/llvm/Object/COFF.h llvm/trunk/include/llvm/Object/ObjectFile.h llvm/trunk/lib/Object/COFFObjectFile.cpp llvm/trunk/lib/Object/ELFObjectFile.cpp llvm/trunk/lib/Object/MachOObjectFile.cpp llvm/trunk/lib/Object/Object.cpp llvm/trunk/tools/llvm-objdump/MachODump.cpp llvm/trunk/tools/llvm-objdump/llvm-objdump.cpp Modified: llvm/trunk/include/llvm-c/Object.h URL: http://llvm.org/viewvc/llvm-project/llvm/trunk/include/llvm-c/Object.h?rev=141379&r1=141378&r2=141379&view=diff ============================================================================== --- llvm/trunk/include/llvm-c/Object.h (original) +++ llvm/trunk/include/llvm-c/Object.h Fri Oct 7 13:25:37 2011 @@ -59,14 +59,14 @@ return reinterpret_cast(const_cast(OF)); } - inline section_iterator *unwrap(LLVMSectionIteratorRef SI) { - return reinterpret_cast(SI); + inline ObjectFile::section_iterator *unwrap(LLVMSectionIteratorRef SI) { + return reinterpret_cast(SI); } inline LLVMSectionIteratorRef - wrap(const section_iterator *SI) { + wrap(const ObjectFile::section_iterator *SI) { return reinterpret_cast - (const_cast(SI)); + (const_cast(SI)); } } } Modified: llvm/trunk/include/llvm/Object/COFF.h URL: http://llvm.org/viewvc/llvm-project/llvm/trunk/include/llvm/Object/COFF.h?rev=141379&r1=141378&r2=141379&view=diff ============================================================================== --- llvm/trunk/include/llvm/Object/COFF.h (original) +++ llvm/trunk/include/llvm/Object/COFF.h Fri Oct 7 13:25:37 2011 @@ -84,8 +84,6 @@ error_code getSection(int32_t index, const coff_section *&Res) const; error_code getString(uint32_t offset, StringRef &Res) const; - error_code getSymbol(uint32_t index, - const coff_symbol *&Res) const; const coff_symbol *toSymb(DataRefImpl Symb) const; const coff_section *toSec(DataRefImpl Sec) const; @@ -112,8 +110,6 @@ virtual error_code isSectionBSS(DataRefImpl Sec, bool &Res) const; virtual error_code sectionContainsSymbol(DataRefImpl Sec, DataRefImpl Symb, bool &Result) const; - virtual relocation_iterator getSectionRelBegin(DataRefImpl Sec) const; - virtual relocation_iterator getSectionRelEnd(DataRefImpl Sec) const; virtual error_code getRelocationNext(DataRefImpl Rel, RelocationRef &Res) const; @@ -123,19 +119,16 @@ SymbolRef &Res) const; virtual error_code getRelocationType(DataRefImpl Rel, uint32_t &Res) const; - virtual error_code getRelocationTypeName(DataRefImpl Rel, - SmallVectorImpl &Result) const; virtual error_code getRelocationAdditionalInfo(DataRefImpl Rel, int64_t &Res) const; - virtual error_code getRelocationValueString(DataRefImpl Rel, - SmallVectorImpl &Result) const; - public: COFFObjectFile(MemoryBuffer *Object, error_code &ec); virtual symbol_iterator begin_symbols() const; virtual symbol_iterator end_symbols() const; virtual section_iterator begin_sections() const; virtual section_iterator end_sections() const; + virtual relocation_iterator begin_relocations() const; + virtual relocation_iterator end_relocations() const; virtual uint8_t getBytesInAddress() const; virtual StringRef getFileFormatName() const; Modified: llvm/trunk/include/llvm/Object/ObjectFile.h URL: http://llvm.org/viewvc/llvm-project/llvm/trunk/include/llvm/Object/ObjectFile.h?rev=141379&r1=141378&r2=141379&view=diff ============================================================================== --- llvm/trunk/include/llvm/Object/ObjectFile.h (original) +++ llvm/trunk/include/llvm/Object/ObjectFile.h Fri Oct 7 13:25:37 2011 @@ -28,50 +28,11 @@ union DataRefImpl { struct { - // ELF needs this for relocations. This entire union should probably be a - // char[max(8, sizeof(uintptr_t))] and require the impl to cast. - uint16_t a, b; - uint32_t c; - } w; - struct { uint32_t a, b; } d; uintptr_t p; }; -template -class content_iterator { - content_type Current; -public: - content_iterator(content_type symb) - : Current(symb) {} - - const content_type* operator->() const { - return &Current; - } - - const content_type &operator*() const { - return Current; - } - - bool operator==(const content_iterator &other) const { - return Current == other.Current; - } - - bool operator!=(const content_iterator &other) const { - return !(*this == other); - } - - content_iterator& increment(error_code &err) { - content_type next; - if (error_code ec = Current.getNext(next)) - err = ec; - else - Current = next; - return *this; - } -}; - static bool operator ==(const DataRefImpl &a, const DataRefImpl &b) { // Check bitwise identical. This is the only legal way to compare a union w/o // knowing which member is in use. @@ -121,7 +82,6 @@ /// such as library functions error_code isGlobal(bool &Result) const; }; -typedef content_iterator symbol_iterator; /// RelocationRef - This is a value type class that represents a single /// relocation in the list of relocations in the object file. @@ -143,20 +103,8 @@ error_code getAddress(uint64_t &Result) const; error_code getSymbol(SymbolRef &Result) const; error_code getType(uint32_t &Result) const; - - /// @brief Get a string that represents the type of this relocation. - /// - /// This is for display purposes only. - error_code getTypeName(SmallVectorImpl &Result) const; error_code getAdditionalInfo(int64_t &Result) const; - - /// @brief Get a string that represents the calculation of the value of this - /// relocation. - /// - /// This is for display purposes only. - error_code getValueString(SmallVectorImpl &Result) const; }; -typedef content_iterator relocation_iterator; /// SectionRef - This is a value type class that represents a single section in /// the list of sections in the object file. @@ -187,11 +135,7 @@ error_code isBSS(bool &Result) const; error_code containsSymbol(SymbolRef S, bool &Result) const; - - relocation_iterator begin_relocations() const; - relocation_iterator end_relocations() const; }; -typedef content_iterator section_iterator; const uint64_t UnknownAddressOrSize = ~0ULL; @@ -241,8 +185,6 @@ virtual error_code isSectionBSS(DataRefImpl Sec, bool &Res) const = 0; virtual error_code sectionContainsSymbol(DataRefImpl Sec, DataRefImpl Symb, bool &Result) const = 0; - virtual relocation_iterator getSectionRelBegin(DataRefImpl Sec) const = 0; - virtual relocation_iterator getSectionRelEnd(DataRefImpl Sec) const = 0; // Same as above for RelocationRef. @@ -255,14 +197,46 @@ SymbolRef &Res) const = 0; virtual error_code getRelocationType(DataRefImpl Rel, uint32_t &Res) const = 0; - virtual error_code getRelocationTypeName(DataRefImpl Rel, - SmallVectorImpl &Result) const = 0; virtual error_code getRelocationAdditionalInfo(DataRefImpl Rel, int64_t &Res) const = 0; - virtual error_code getRelocationValueString(DataRefImpl Rel, - SmallVectorImpl &Result) const = 0; public: + template + class content_iterator { + content_type Current; + public: + content_iterator(content_type symb) + : Current(symb) {} + + const content_type* operator->() const { + return &Current; + } + + const content_type &operator*() const { + return Current; + } + + bool operator==(const content_iterator &other) const { + return Current == other.Current; + } + + bool operator!=(const content_iterator &other) const { + return !(*this == other); + } + + content_iterator& increment(error_code &err) { + content_type next; + if (error_code ec = Current.getNext(next)) + err = ec; + else + Current = next; + return *this; + } + }; + + typedef content_iterator symbol_iterator; + typedef content_iterator section_iterator; + typedef content_iterator relocation_iterator; virtual symbol_iterator begin_symbols() const = 0; virtual symbol_iterator end_symbols() const = 0; @@ -270,6 +244,9 @@ virtual section_iterator begin_sections() const = 0; virtual section_iterator end_sections() const = 0; + virtual relocation_iterator begin_relocations() const = 0; + virtual relocation_iterator end_relocations() const = 0; + /// @brief The number of bytes used to represent an address in this object /// file format. virtual uint8_t getBytesInAddress() const = 0; @@ -389,14 +366,6 @@ Result); } -inline relocation_iterator SectionRef::begin_relocations() const { - return OwningObject->getSectionRelBegin(SectionPimpl); -} - -inline relocation_iterator SectionRef::end_relocations() const { - return OwningObject->getSectionRelEnd(SectionPimpl); -} - /// RelocationRef inline RelocationRef::RelocationRef(DataRefImpl RelocationP, @@ -424,20 +393,10 @@ return OwningObject->getRelocationType(RelocationPimpl, Result); } -inline error_code RelocationRef::getTypeName(SmallVectorImpl &Result) - const { - return OwningObject->getRelocationTypeName(RelocationPimpl, Result); -} - inline error_code RelocationRef::getAdditionalInfo(int64_t &Result) const { return OwningObject->getRelocationAdditionalInfo(RelocationPimpl, Result); } -inline error_code RelocationRef::getValueString(SmallVectorImpl &Result) - const { - return OwningObject->getRelocationValueString(RelocationPimpl, Result); -} - } // end namespace object } // end namespace llvm Modified: llvm/trunk/lib/Object/COFFObjectFile.cpp URL: http://llvm.org/viewvc/llvm-project/llvm/trunk/lib/Object/COFFObjectFile.cpp?rev=141379&r1=141378&r2=141379&view=diff ============================================================================== --- llvm/trunk/lib/Object/COFFObjectFile.cpp (original) +++ llvm/trunk/lib/Object/COFFObjectFile.cpp Fri Oct 7 13:25:37 2011 @@ -12,7 +12,6 @@ //===----------------------------------------------------------------------===// #include "llvm/Object/COFF.h" -#include "llvm/ADT/SmallString.h" #include "llvm/ADT/StringSwitch.h" #include "llvm/ADT/Triple.h" @@ -365,33 +364,6 @@ return object_error::success; } -relocation_iterator COFFObjectFile::getSectionRelBegin(DataRefImpl Sec) const { - const coff_section *sec = toSec(Sec); - DataRefImpl ret; - std::memset(&ret, 0, sizeof(ret)); - if (sec->NumberOfRelocations == 0) - ret.p = 0; - else - ret.p = reinterpret_cast(base() + sec->PointerToRelocations); - - return relocation_iterator(RelocationRef(ret, this)); -} - -relocation_iterator COFFObjectFile::getSectionRelEnd(DataRefImpl Sec) const { - const coff_section *sec = toSec(Sec); - DataRefImpl ret; - std::memset(&ret, 0, sizeof(ret)); - if (sec->NumberOfRelocations == 0) - ret.p = 0; - else - ret.p = reinterpret_cast( - reinterpret_cast( - base() + sec->PointerToRelocations) - + sec->NumberOfRelocations); - - return relocation_iterator(RelocationRef(ret, this)); -} - COFFObjectFile::COFFObjectFile(MemoryBuffer *Object, error_code &ec) : ObjectFile(Binary::isCOFF, Object, ec) { // Check that we at least have enough room for a header. @@ -455,14 +427,14 @@ ec = object_error::success; } -symbol_iterator COFFObjectFile::begin_symbols() const { +ObjectFile::symbol_iterator COFFObjectFile::begin_symbols() const { DataRefImpl ret; std::memset(&ret, 0, sizeof(DataRefImpl)); ret.p = reinterpret_cast(SymbolTable); return symbol_iterator(SymbolRef(ret, this)); } -symbol_iterator COFFObjectFile::end_symbols() const { +ObjectFile::symbol_iterator COFFObjectFile::end_symbols() const { // The symbol table ends where the string table begins. DataRefImpl ret; std::memset(&ret, 0, sizeof(DataRefImpl)); @@ -470,14 +442,14 @@ return symbol_iterator(SymbolRef(ret, this)); } -section_iterator COFFObjectFile::begin_sections() const { +ObjectFile::section_iterator COFFObjectFile::begin_sections() const { DataRefImpl ret; std::memset(&ret, 0, sizeof(DataRefImpl)); ret.p = reinterpret_cast(SectionTable); return section_iterator(SectionRef(ret, this)); } -section_iterator COFFObjectFile::end_sections() const { +ObjectFile::section_iterator COFFObjectFile::end_sections() const { DataRefImpl ret; std::memset(&ret, 0, sizeof(DataRefImpl)); ret.p = reinterpret_cast(SectionTable + Header->NumberOfSections); @@ -536,27 +508,42 @@ return object_error::success; } -error_code COFFObjectFile::getSymbol(uint32_t index, - const coff_symbol *&Result) const { - if (index > 0 && index < Header->NumberOfSymbols) - Result = SymbolTable + index; - else - return object_error::parse_failed; - return object_error::success; -} - const coff_relocation *COFFObjectFile::toRel(DataRefImpl Rel) const { - return reinterpret_cast(Rel.p); + assert(Rel.d.b < Header->NumberOfSections && "Section index out of range!"); + const coff_section *Sect = NULL; + getSection(Rel.d.b, Sect); + assert(Rel.d.a < Sect->NumberOfRelocations && "Relocation index out of range!"); + return + reinterpret_cast(base() + + Sect->PointerToRelocations) + + Rel.d.a; } error_code COFFObjectFile::getRelocationNext(DataRefImpl Rel, RelocationRef &Res) const { - ++*reinterpret_cast(&Rel.p); + const coff_section *Sect = NULL; + if (error_code ec = getSection(Rel.d.b, Sect)) + return ec; + if (++Rel.d.a >= Sect->NumberOfRelocations) { + Rel.d.a = 0; + while (++Rel.d.b < Header->NumberOfSections) { + const coff_section *Sect = NULL; + getSection(Rel.d.b, Sect); + if (Sect->NumberOfRelocations > 0) + break; + } + } Res = RelocationRef(Rel, this); return object_error::success; } error_code COFFObjectFile::getRelocationAddress(DataRefImpl Rel, uint64_t &Res) const { - Res = toRel(Rel)->VirtualAddress; + const coff_section *Sect = NULL; + if (error_code ec = getSection(Rel.d.b, Sect)) + return ec; + const coff_relocation* R = toRel(Rel); + Res = reinterpret_cast(base() + + Sect->PointerToRawData + + R->VirtualAddress); return object_error::success; } error_code COFFObjectFile::getRelocationSymbol(DataRefImpl Rel, @@ -573,82 +560,24 @@ Res = R->Type; return object_error::success; } - -#define LLVM_COFF_SWITCH_RELOC_TYPE_NAME(enum) \ - case COFF::enum: res = #enum; break; - -error_code COFFObjectFile::getRelocationTypeName(DataRefImpl Rel, - SmallVectorImpl &Result) const { - const coff_relocation *reloc = toRel(Rel); - StringRef res; - switch (Header->Machine) { - case COFF::IMAGE_FILE_MACHINE_AMD64: - switch (reloc->Type) { - LLVM_COFF_SWITCH_RELOC_TYPE_NAME(IMAGE_REL_AMD64_ABSOLUTE); - LLVM_COFF_SWITCH_RELOC_TYPE_NAME(IMAGE_REL_AMD64_ADDR64); - LLVM_COFF_SWITCH_RELOC_TYPE_NAME(IMAGE_REL_AMD64_ADDR32); - LLVM_COFF_SWITCH_RELOC_TYPE_NAME(IMAGE_REL_AMD64_ADDR32NB); - LLVM_COFF_SWITCH_RELOC_TYPE_NAME(IMAGE_REL_AMD64_REL32); - LLVM_COFF_SWITCH_RELOC_TYPE_NAME(IMAGE_REL_AMD64_REL32_1); - LLVM_COFF_SWITCH_RELOC_TYPE_NAME(IMAGE_REL_AMD64_REL32_2); - LLVM_COFF_SWITCH_RELOC_TYPE_NAME(IMAGE_REL_AMD64_REL32_3); - LLVM_COFF_SWITCH_RELOC_TYPE_NAME(IMAGE_REL_AMD64_REL32_4); - LLVM_COFF_SWITCH_RELOC_TYPE_NAME(IMAGE_REL_AMD64_REL32_5); - LLVM_COFF_SWITCH_RELOC_TYPE_NAME(IMAGE_REL_AMD64_SECTION); - LLVM_COFF_SWITCH_RELOC_TYPE_NAME(IMAGE_REL_AMD64_SECREL); - LLVM_COFF_SWITCH_RELOC_TYPE_NAME(IMAGE_REL_AMD64_SECREL7); - LLVM_COFF_SWITCH_RELOC_TYPE_NAME(IMAGE_REL_AMD64_TOKEN); - LLVM_COFF_SWITCH_RELOC_TYPE_NAME(IMAGE_REL_AMD64_SREL32); - LLVM_COFF_SWITCH_RELOC_TYPE_NAME(IMAGE_REL_AMD64_PAIR); - LLVM_COFF_SWITCH_RELOC_TYPE_NAME(IMAGE_REL_AMD64_SSPAN32); - default: - res = "Unknown"; - } - break; - case COFF::IMAGE_FILE_MACHINE_I386: - switch (reloc->Type) { - LLVM_COFF_SWITCH_RELOC_TYPE_NAME(IMAGE_REL_I386_ABSOLUTE); - LLVM_COFF_SWITCH_RELOC_TYPE_NAME(IMAGE_REL_I386_DIR16); - LLVM_COFF_SWITCH_RELOC_TYPE_NAME(IMAGE_REL_I386_REL16); - LLVM_COFF_SWITCH_RELOC_TYPE_NAME(IMAGE_REL_I386_DIR32); - LLVM_COFF_SWITCH_RELOC_TYPE_NAME(IMAGE_REL_I386_DIR32NB); - LLVM_COFF_SWITCH_RELOC_TYPE_NAME(IMAGE_REL_I386_SEG12); - LLVM_COFF_SWITCH_RELOC_TYPE_NAME(IMAGE_REL_I386_SECTION); - LLVM_COFF_SWITCH_RELOC_TYPE_NAME(IMAGE_REL_I386_SECREL); - LLVM_COFF_SWITCH_RELOC_TYPE_NAME(IMAGE_REL_I386_TOKEN); - LLVM_COFF_SWITCH_RELOC_TYPE_NAME(IMAGE_REL_I386_SECREL7); - LLVM_COFF_SWITCH_RELOC_TYPE_NAME(IMAGE_REL_I386_REL32); - default: - res = "Unknown"; - } - break; - default: - res = "Unknown"; - } - Result.append(res.begin(), res.end()); - return object_error::success; -} - -#undef LLVM_COFF_SWITCH_RELOC_TYPE_NAME - error_code COFFObjectFile::getRelocationAdditionalInfo(DataRefImpl Rel, int64_t &Res) const { Res = 0; return object_error::success; } -error_code COFFObjectFile::getRelocationValueString(DataRefImpl Rel, - SmallVectorImpl &Result) const { - const coff_relocation *reloc = toRel(Rel); - const coff_symbol *symb; - if (error_code ec = getSymbol(reloc->SymbolTableIndex, symb)) return ec; - DataRefImpl sym; - ::memset(&sym, 0, sizeof(sym)); - sym.p = reinterpret_cast(symb); - StringRef symname; - if (error_code ec = getSymbolName(sym, symname)) return ec; - Result.append(symname.begin(), symname.end()); - return object_error::success; +ObjectFile::relocation_iterator COFFObjectFile::begin_relocations() const { + DataRefImpl ret; + ret.d.a = 0; + ret.d.b = 1; + return relocation_iterator(RelocationRef(ret, this)); } +ObjectFile::relocation_iterator COFFObjectFile::end_relocations() const { + DataRefImpl ret; + ret.d.a = 0; + ret.d.b = Header->NumberOfSections; + return relocation_iterator(RelocationRef(ret, this)); +} + namespace llvm { Modified: llvm/trunk/lib/Object/ELFObjectFile.cpp URL: http://llvm.org/viewvc/llvm-project/llvm/trunk/lib/Object/ELFObjectFile.cpp?rev=141379&r1=141378&r2=141379&view=diff ============================================================================== --- llvm/trunk/lib/Object/ELFObjectFile.cpp (original) +++ llvm/trunk/lib/Object/ELFObjectFile.cpp Fri Oct 7 13:25:37 2011 @@ -20,8 +20,6 @@ #include "llvm/Support/Endian.h" #include "llvm/Support/ErrorHandling.h" #include "llvm/Support/MemoryBuffer.h" -#include "llvm/Support/raw_ostream.h" -#include #include #include @@ -288,7 +286,6 @@ typedef SmallVector Sections_t; typedef DenseMap IndexMap_t; - typedef DenseMap > RelocMap_t; const Elf_Ehdr *Header; const Elf_Shdr *SectionHeaderTable; @@ -296,22 +293,12 @@ const Elf_Shdr *dot_strtab_sec; // Symbol header string table. Sections_t SymbolTableSections; IndexMap_t SymbolTableSectionsIndexMap; - - /// @brief Map sections to an array of relocation sections that reference - /// them sorted by section index. - RelocMap_t SectionRelocMap; - - /// @brief Get the relocation section that contains \a Rel. - const Elf_Shdr *getRelSection(DataRefImpl Rel) const { - return getSection(Rel.w.b); - } + Sections_t RelocationTableSections; void validateSymbol(DataRefImpl Symb) const; bool isRelocationHasAddend(DataRefImpl Rel) const; template - const T *getEntry(uint16_t Section, uint32_t Entry) const; - template - const T *getEntry(const Elf_Shdr *Section, uint32_t Entry) const; + const T *getEntry(DataRefImpl Entry, Sections_t Sections) const; const Elf_Sym *getSymbol(DataRefImpl Symb) const; const Elf_Shdr *getSection(DataRefImpl index) const; const Elf_Shdr *getSection(uint16_t index) const; @@ -319,7 +306,6 @@ const Elf_Rela *getRela(DataRefImpl Rela) const; const char *getString(uint16_t section, uint32_t offset) const; const char *getString(const Elf_Shdr *section, uint32_t offset) const; - error_code getSymbolName(const Elf_Sym *Symb, StringRef &Res) const; protected: virtual error_code getSymbolNext(DataRefImpl Symb, SymbolRef &Res) const; @@ -342,8 +328,6 @@ virtual error_code isSectionBSS(DataRefImpl Sec, bool &Res) const; virtual error_code sectionContainsSymbol(DataRefImpl Sec, DataRefImpl Symb, bool &Result) const; - virtual relocation_iterator getSectionRelBegin(DataRefImpl Sec) const; - virtual relocation_iterator getSectionRelEnd(DataRefImpl Sec) const; virtual error_code getRelocationNext(DataRefImpl Rel, RelocationRef &Res) const; @@ -353,12 +337,8 @@ SymbolRef &Res) const; virtual error_code getRelocationType(DataRefImpl Rel, uint32_t &Res) const; - virtual error_code getRelocationTypeName(DataRefImpl Rel, - SmallVectorImpl &Result) const; virtual error_code getRelocationAdditionalInfo(DataRefImpl Rel, int64_t &Res) const; - virtual error_code getRelocationValueString(DataRefImpl Rel, - SmallVectorImpl &Result) const; public: ELFObjectFile(MemoryBuffer *Object, error_code &ec); @@ -366,6 +346,8 @@ virtual symbol_iterator end_symbols() const; virtual section_iterator begin_sections() const; virtual section_iterator end_sections() const; + virtual relocation_iterator begin_relocations() const; + virtual relocation_iterator end_relocations() const; virtual uint8_t getBytesInAddress() const; virtual StringRef getFileFormatName() const; @@ -422,7 +404,18 @@ StringRef &Result) const { validateSymbol(Symb); const Elf_Sym *symb = getSymbol(Symb); - return getSymbolName(symb, Result); + if (symb->st_name == 0) { + const Elf_Shdr *section = getSection(symb->st_shndx); + if (!section) + Result = ""; + else + Result = getString(dot_shstrtab_sec, section->sh_name); + return object_error::success; + } + + // Use the default symbol table name section. + Result = getString(dot_strtab_sec, symb->st_name); + return object_error::success; } template @@ -719,65 +712,24 @@ return object_error::success; } -template -relocation_iterator ELFObjectFile - ::getSectionRelBegin(DataRefImpl Sec) const { - DataRefImpl RelData; - memset(&RelData, 0, sizeof(RelData)); - const Elf_Shdr *sec = reinterpret_cast(Sec.p); - RelocMap_t::const_iterator ittr = SectionRelocMap.find(sec); - if (sec != 0 && ittr != SectionRelocMap.end()) { - RelData.w.a = getSection(ittr->second[0])->sh_link; - RelData.w.b = ittr->second[0]; - RelData.w.c = 0; - } - return relocation_iterator(RelocationRef(RelData, this)); -} - -template -relocation_iterator ELFObjectFile - ::getSectionRelEnd(DataRefImpl Sec) const { - DataRefImpl RelData; - memset(&RelData, 0, sizeof(RelData)); - const Elf_Shdr *sec = reinterpret_cast(Sec.p); - RelocMap_t::const_iterator ittr = SectionRelocMap.find(sec); - if (sec != 0 && ittr != SectionRelocMap.end()) { - // Get the index of the last relocation section for this section. - std::size_t relocsecindex = ittr->second[ittr->second.size() - 1]; - const Elf_Shdr *relocsec = getSection(relocsecindex); - RelData.w.a = relocsec->sh_link; - RelData.w.b = relocsecindex; - RelData.w.c = relocsec->sh_size / relocsec->sh_entsize; - } - return relocation_iterator(RelocationRef(RelData, this)); -} - // Relocations template error_code ELFObjectFile ::getRelocationNext(DataRefImpl Rel, RelocationRef &Result) const { - ++Rel.w.c; - const Elf_Shdr *relocsec = getSection(Rel.w.b); - if (Rel.w.c >= (relocsec->sh_size / relocsec->sh_entsize)) { - // We have reached the end of the relocations for this section. See if there - // is another relocation section. - RelocMap_t::mapped_type &relocseclist = - SectionRelocMap.lookup(getSection(Rel.w.a)); - - // Do a binary search for the current reloc section index (which must be - // present). Then get the next one. - RelocMap_t::mapped_type::const_iterator loc = - std::lower_bound(relocseclist.begin(), relocseclist.end(), Rel.w.b); - ++loc; - - // If there is no next one, don't do anything. The ++Rel.w.c above sets Rel - // to the end iterator. - if (loc != relocseclist.end()) { - Rel.w.b = *loc; - Rel.w.a = 0; + const Elf_Shdr *RelocationTableSection = RelocationTableSections[Rel.d.b]; + + // Check to see if we are at the end of this relocation table. + if (++Rel.d.a >= RelocationTableSection->getEntityCount()) { + // We are at the end. If there are other relocation tables, jump to them. + Rel.d.a = 0; + // Otherwise return the terminator. + if (++Rel.d.b >= SymbolTableSections.size()) { + Rel.d.a = std::numeric_limits::max(); + Rel.d.b = std::numeric_limits::max(); } } + Result = RelocationRef(Rel, this); return object_error::success; } @@ -787,7 +739,7 @@ ::getRelocationSymbol(DataRefImpl Rel, SymbolRef &Result) const { uint32_t symbolIdx; - const Elf_Shdr *sec = getSection(Rel.w.b); + const Elf_Shdr *sec = RelocationTableSections[Rel.d.b]; switch (sec->sh_type) { default : report_fatal_error("Invalid section type in Rel!"); @@ -815,7 +767,7 @@ ::getRelocationAddress(DataRefImpl Rel, uint64_t &Result) const { uint64_t offset; - const Elf_Shdr *sec = getSection(Rel.w.b); + const Elf_Shdr *sec = RelocationTableSections[Rel.d.b]; switch (sec->sh_type) { default : report_fatal_error("Invalid section type in Rel!"); @@ -829,7 +781,8 @@ } } - Result = offset; + const Elf_Shdr *secAddr = getSection(sec->sh_info); + Result = offset + reinterpret_cast(base() + secAddr->sh_offset); return object_error::success; } @@ -837,7 +790,7 @@ error_code ELFObjectFile ::getRelocationType(DataRefImpl Rel, uint32_t &Result) const { - const Elf_Shdr *sec = getSection(Rel.w.b); + const Elf_Shdr *sec = RelocationTableSections[Rel.d.b]; switch (sec->sh_type) { default : report_fatal_error("Invalid section type in Rel!"); @@ -853,127 +806,11 @@ return object_error::success; } -#define LLVM_ELF_SWITCH_RELOC_TYPE_NAME(enum) \ - case ELF::enum: res = #enum; break; - -template -error_code ELFObjectFile - ::getRelocationTypeName(DataRefImpl Rel, - SmallVectorImpl &Result) const { - const Elf_Shdr *sec = getSection(Rel.w.b); - uint8_t type; - StringRef res; - switch (sec->sh_type) { - default : - return object_error::parse_failed; - case ELF::SHT_REL : { - type = getRel(Rel)->getType(); - break; - } - case ELF::SHT_RELA : { - type = getRela(Rel)->getType(); - break; - } - } - switch (Header->e_machine) { - case ELF::EM_X86_64: - switch (type) { - LLVM_ELF_SWITCH_RELOC_TYPE_NAME(R_X86_64_NONE); - LLVM_ELF_SWITCH_RELOC_TYPE_NAME(R_X86_64_64); - LLVM_ELF_SWITCH_RELOC_TYPE_NAME(R_X86_64_PC32); - LLVM_ELF_SWITCH_RELOC_TYPE_NAME(R_X86_64_GOT32); - LLVM_ELF_SWITCH_RELOC_TYPE_NAME(R_X86_64_PLT32); - LLVM_ELF_SWITCH_RELOC_TYPE_NAME(R_X86_64_COPY); - LLVM_ELF_SWITCH_RELOC_TYPE_NAME(R_X86_64_GLOB_DAT); - LLVM_ELF_SWITCH_RELOC_TYPE_NAME(R_X86_64_JUMP_SLOT); - LLVM_ELF_SWITCH_RELOC_TYPE_NAME(R_X86_64_RELATIVE); - LLVM_ELF_SWITCH_RELOC_TYPE_NAME(R_X86_64_GOTPCREL); - LLVM_ELF_SWITCH_RELOC_TYPE_NAME(R_X86_64_32); - LLVM_ELF_SWITCH_RELOC_TYPE_NAME(R_X86_64_32S); - LLVM_ELF_SWITCH_RELOC_TYPE_NAME(R_X86_64_16); - LLVM_ELF_SWITCH_RELOC_TYPE_NAME(R_X86_64_PC16); - LLVM_ELF_SWITCH_RELOC_TYPE_NAME(R_X86_64_8); - LLVM_ELF_SWITCH_RELOC_TYPE_NAME(R_X86_64_PC8); - LLVM_ELF_SWITCH_RELOC_TYPE_NAME(R_X86_64_DTPMOD64); - LLVM_ELF_SWITCH_RELOC_TYPE_NAME(R_X86_64_DTPOFF64); - LLVM_ELF_SWITCH_RELOC_TYPE_NAME(R_X86_64_TPOFF64); - LLVM_ELF_SWITCH_RELOC_TYPE_NAME(R_X86_64_TLSGD); - LLVM_ELF_SWITCH_RELOC_TYPE_NAME(R_X86_64_TLSLD); - LLVM_ELF_SWITCH_RELOC_TYPE_NAME(R_X86_64_DTPOFF32); - LLVM_ELF_SWITCH_RELOC_TYPE_NAME(R_X86_64_GOTTPOFF); - LLVM_ELF_SWITCH_RELOC_TYPE_NAME(R_X86_64_TPOFF32); - LLVM_ELF_SWITCH_RELOC_TYPE_NAME(R_X86_64_PC64); - LLVM_ELF_SWITCH_RELOC_TYPE_NAME(R_X86_64_GOTOFF64); - LLVM_ELF_SWITCH_RELOC_TYPE_NAME(R_X86_64_GOTPC32); - LLVM_ELF_SWITCH_RELOC_TYPE_NAME(R_X86_64_SIZE32); - LLVM_ELF_SWITCH_RELOC_TYPE_NAME(R_X86_64_SIZE64); - LLVM_ELF_SWITCH_RELOC_TYPE_NAME(R_X86_64_GOTPC32_TLSDESC); - LLVM_ELF_SWITCH_RELOC_TYPE_NAME(R_X86_64_TLSDESC_CALL); - LLVM_ELF_SWITCH_RELOC_TYPE_NAME(R_X86_64_TLSDESC); - default: - res = "Unknown"; - } - break; - case ELF::EM_386: - switch (type) { - LLVM_ELF_SWITCH_RELOC_TYPE_NAME(R_386_NONE); - LLVM_ELF_SWITCH_RELOC_TYPE_NAME(R_386_32); - LLVM_ELF_SWITCH_RELOC_TYPE_NAME(R_386_PC32); - LLVM_ELF_SWITCH_RELOC_TYPE_NAME(R_386_GOT32); - LLVM_ELF_SWITCH_RELOC_TYPE_NAME(R_386_PLT32); - LLVM_ELF_SWITCH_RELOC_TYPE_NAME(R_386_COPY); - LLVM_ELF_SWITCH_RELOC_TYPE_NAME(R_386_GLOB_DAT); - LLVM_ELF_SWITCH_RELOC_TYPE_NAME(R_386_JUMP_SLOT); - LLVM_ELF_SWITCH_RELOC_TYPE_NAME(R_386_RELATIVE); - LLVM_ELF_SWITCH_RELOC_TYPE_NAME(R_386_GOTOFF); - LLVM_ELF_SWITCH_RELOC_TYPE_NAME(R_386_GOTPC); - LLVM_ELF_SWITCH_RELOC_TYPE_NAME(R_386_32PLT); - LLVM_ELF_SWITCH_RELOC_TYPE_NAME(R_386_TLS_TPOFF); - LLVM_ELF_SWITCH_RELOC_TYPE_NAME(R_386_TLS_IE); - LLVM_ELF_SWITCH_RELOC_TYPE_NAME(R_386_TLS_GOTIE); - LLVM_ELF_SWITCH_RELOC_TYPE_NAME(R_386_TLS_LE); - LLVM_ELF_SWITCH_RELOC_TYPE_NAME(R_386_TLS_GD); - LLVM_ELF_SWITCH_RELOC_TYPE_NAME(R_386_TLS_LDM); - LLVM_ELF_SWITCH_RELOC_TYPE_NAME(R_386_16); - LLVM_ELF_SWITCH_RELOC_TYPE_NAME(R_386_PC16); - LLVM_ELF_SWITCH_RELOC_TYPE_NAME(R_386_8); - LLVM_ELF_SWITCH_RELOC_TYPE_NAME(R_386_PC8); - LLVM_ELF_SWITCH_RELOC_TYPE_NAME(R_386_TLS_GD_32); - LLVM_ELF_SWITCH_RELOC_TYPE_NAME(R_386_TLS_GD_PUSH); - LLVM_ELF_SWITCH_RELOC_TYPE_NAME(R_386_TLS_GD_CALL); - LLVM_ELF_SWITCH_RELOC_TYPE_NAME(R_386_TLS_GD_POP); - LLVM_ELF_SWITCH_RELOC_TYPE_NAME(R_386_TLS_LDM_32); - LLVM_ELF_SWITCH_RELOC_TYPE_NAME(R_386_TLS_LDM_PUSH); - LLVM_ELF_SWITCH_RELOC_TYPE_NAME(R_386_TLS_LDM_CALL); - LLVM_ELF_SWITCH_RELOC_TYPE_NAME(R_386_TLS_LDM_POP); - LLVM_ELF_SWITCH_RELOC_TYPE_NAME(R_386_TLS_LDO_32); - LLVM_ELF_SWITCH_RELOC_TYPE_NAME(R_386_TLS_IE_32); - LLVM_ELF_SWITCH_RELOC_TYPE_NAME(R_386_TLS_LE_32); - LLVM_ELF_SWITCH_RELOC_TYPE_NAME(R_386_TLS_DTPMOD32); - LLVM_ELF_SWITCH_RELOC_TYPE_NAME(R_386_TLS_DTPOFF32); - LLVM_ELF_SWITCH_RELOC_TYPE_NAME(R_386_TLS_TPOFF32); - LLVM_ELF_SWITCH_RELOC_TYPE_NAME(R_386_TLS_GOTDESC); - LLVM_ELF_SWITCH_RELOC_TYPE_NAME(R_386_TLS_DESC_CALL); - LLVM_ELF_SWITCH_RELOC_TYPE_NAME(R_386_TLS_DESC); - LLVM_ELF_SWITCH_RELOC_TYPE_NAME(R_386_IRELATIVE); - default: - res = "Unknown"; - } - break; - default: - res = "Unknown"; - } - Result.append(res.begin(), res.end()); - return object_error::success; -} - -#undef LLVM_ELF_SWITCH_RELOC_TYPE_NAME - template error_code ELFObjectFile ::getRelocationAdditionalInfo(DataRefImpl Rel, int64_t &Result) const { - const Elf_Shdr *sec = getSection(Rel.w.b); + const Elf_Shdr *sec = RelocationTableSections[Rel.d.b]; switch (sec->sh_type) { default : report_fatal_error("Invalid section type in Rel!"); @@ -988,60 +825,7 @@ } } -template -error_code ELFObjectFile - ::getRelocationValueString(DataRefImpl Rel, - SmallVectorImpl &Result) const { - const Elf_Shdr *sec = getSection(Rel.w.b); - uint8_t type; - StringRef res; - int64_t addend = 0; - uint16_t symbol_index = 0; - switch (sec->sh_type) { - default : - return object_error::parse_failed; - case ELF::SHT_REL : { - type = getRel(Rel)->getType(); - symbol_index = getRel(Rel)->getSymbol(); - // TODO: Read implicit addend from section data. - break; - } - case ELF::SHT_RELA : { - type = getRela(Rel)->getType(); - symbol_index = getRela(Rel)->getSymbol(); - addend = getRela(Rel)->r_addend; - break; - } - } - const Elf_Sym *symb = getEntry(sec->sh_link, symbol_index); - StringRef symname; - if (error_code ec = getSymbolName(symb, symname)) - return ec; - switch (Header->e_machine) { - case ELF::EM_X86_64: - switch (type) { - case ELF::R_X86_64_32S: - res = symname; - break; - case ELF::R_X86_64_PC32: { - std::string fmtbuf; - raw_string_ostream fmt(fmtbuf); - fmt << symname << (addend < 0 ? "" : "+") << addend << "-P"; - fmt.flush(); - Result.append(fmtbuf.begin(), fmtbuf.end()); - } - break; - default: - res = "Unknown"; - } - break; - default: - res = "Unknown"; - } - if (Result.empty()) - Result.append(res.begin(), res.end()); - return object_error::success; -} + template ELFObjectFile::ELFObjectFile(MemoryBuffer *Object @@ -1065,24 +849,19 @@ // To find the symbol tables we walk the section table to find SHT_STMTAB. - const Elf_Shdr* sh = reinterpret_cast(SectionHeaderTable); + const Elf_Shdr* sh = + reinterpret_cast(SectionHeaderTable); for (unsigned i = 0; i < Header->e_shnum; ++i) { if (sh->sh_type == ELF::SHT_SYMTAB) { SymbolTableSectionsIndexMap[i] = SymbolTableSections.size(); SymbolTableSections.push_back(sh); } if (sh->sh_type == ELF::SHT_REL || sh->sh_type == ELF::SHT_RELA) { - SectionRelocMap[getSection(sh->sh_link)].push_back(i); + RelocationTableSections.push_back(sh); } ++sh; } - // Sort section relocation lists by index. - for (RelocMap_t::iterator i = SectionRelocMap.begin(), - e = SectionRelocMap.end(); i != e; ++i) { - std::sort(i->second.begin(), i->second.end()); - } - // Get string table sections. dot_shstrtab_sec = getSection(Header->e_shstrndx); if (dot_shstrtab_sec) { @@ -1115,8 +894,8 @@ } template -symbol_iterator ELFObjectFile - ::begin_symbols() const { +ObjectFile::symbol_iterator ELFObjectFile + ::begin_symbols() const { DataRefImpl SymbolData; memset(&SymbolData, 0, sizeof(SymbolData)); if (SymbolTableSections.size() == 0) { @@ -1130,8 +909,8 @@ } template -symbol_iterator ELFObjectFile - ::end_symbols() const { +ObjectFile::symbol_iterator ELFObjectFile + ::end_symbols() const { DataRefImpl SymbolData; memset(&SymbolData, 0, sizeof(SymbolData)); SymbolData.d.a = std::numeric_limits::max(); @@ -1140,8 +919,8 @@ } template -section_iterator ELFObjectFile - ::begin_sections() const { +ObjectFile::section_iterator ELFObjectFile + ::begin_sections() const { DataRefImpl ret; memset(&ret, 0, sizeof(DataRefImpl)); ret.p = reinterpret_cast(base() + Header->e_shoff); @@ -1149,8 +928,8 @@ } template -section_iterator ELFObjectFile - ::end_sections() const { +ObjectFile::section_iterator ELFObjectFile + ::end_sections() const { DataRefImpl ret; memset(&ret, 0, sizeof(DataRefImpl)); ret.p = reinterpret_cast(base() @@ -1160,6 +939,31 @@ } template +ObjectFile::relocation_iterator ELFObjectFile + ::begin_relocations() const { + DataRefImpl RelData; + memset(&RelData, 0, sizeof(RelData)); + if (RelocationTableSections.size() == 0) { + RelData.d.a = std::numeric_limits::max(); + RelData.d.b = std::numeric_limits::max(); + } else { + RelData.d.a = 0; + RelData.d.b = 0; + } + return relocation_iterator(RelocationRef(RelData, this)); +} + +template +ObjectFile::relocation_iterator ELFObjectFile + ::end_relocations() const { + DataRefImpl RelData; + memset(&RelData, 0, sizeof(RelData)); + RelData.d.a = std::numeric_limits::max(); + RelData.d.b = std::numeric_limits::max(); + return relocation_iterator(RelocationRef(RelData, this)); +} + +template uint8_t ELFObjectFile::getBytesInAddress() const { return is64Bits ? 8 : 4; } @@ -1208,49 +1012,41 @@ } } - template template inline const T * -ELFObjectFile::getEntry(uint16_t Section, - uint32_t Entry) const { - return getEntry(getSection(Section), Entry); -} - -template -template -inline const T * -ELFObjectFile::getEntry(const Elf_Shdr * Section, - uint32_t Entry) const { +ELFObjectFile::getEntry(DataRefImpl Entry, + Sections_t Sections) const { + const Elf_Shdr *sec = Sections[Entry.d.b]; return reinterpret_cast( base() - + Section->sh_offset - + (Entry * Section->sh_entsize)); + + sec->sh_offset + + (Entry.d.a * sec->sh_entsize)); } template const typename ELFObjectFile::Elf_Sym * ELFObjectFile::getSymbol(DataRefImpl Symb) const { - return getEntry(SymbolTableSections[Symb.d.b], Symb.d.a); + return getEntry(Symb, SymbolTableSections); } template const typename ELFObjectFile::Elf_Rel * ELFObjectFile::getRel(DataRefImpl Rel) const { - return getEntry(Rel.w.b, Rel.w.c); + return getEntry(Rel, RelocationTableSections); } template const typename ELFObjectFile::Elf_Rela * ELFObjectFile::getRela(DataRefImpl Rela) const { - return getEntry(Rela.w.b, Rela.w.c); + return getEntry(Rela, RelocationTableSections); } template const typename ELFObjectFile::Elf_Shdr * ELFObjectFile::getSection(DataRefImpl Symb) const { const Elf_Shdr *sec = getSection(Symb.d.b); - if (sec->sh_type != ELF::SHT_SYMTAB || sec->sh_type != ELF::SHT_DYNSYM) + if (sec->sh_type != ELF::SHT_SYMTAB) // FIXME: Proper error handling. report_fatal_error("Invalid symbol table section!"); return sec; @@ -1288,24 +1084,6 @@ return (const char *)base() + section->sh_offset + offset; } -template -error_code ELFObjectFile - ::getSymbolName(const Elf_Sym *symb, - StringRef &Result) const { - if (symb->st_name == 0) { - const Elf_Shdr *section = getSection(symb->st_shndx); - if (!section) - Result = ""; - else - Result = getString(dot_shstrtab_sec, section->sh_name); - return object_error::success; - } - - // Use the default symbol table name section. - Result = getString(dot_strtab_sec, symb->st_name); - return object_error::success; -} - // EI_CLASS, EI_DATA. static std::pair getElfArchType(MemoryBuffer *Object) { Modified: llvm/trunk/lib/Object/MachOObjectFile.cpp URL: http://llvm.org/viewvc/llvm-project/llvm/trunk/lib/Object/MachOObjectFile.cpp?rev=141379&r1=141378&r2=141379&view=diff ============================================================================== --- llvm/trunk/lib/Object/MachOObjectFile.cpp (original) +++ llvm/trunk/lib/Object/MachOObjectFile.cpp Fri Oct 7 13:25:37 2011 @@ -39,6 +39,8 @@ virtual symbol_iterator end_symbols() const; virtual section_iterator begin_sections() const; virtual section_iterator end_sections() const; + virtual relocation_iterator begin_relocations() const; + virtual relocation_iterator end_relocations() const; virtual uint8_t getBytesInAddress() const; virtual StringRef getFileFormatName() const; @@ -65,8 +67,6 @@ virtual error_code isSectionBSS(DataRefImpl Sec, bool &Res) const; virtual error_code sectionContainsSymbol(DataRefImpl DRI, DataRefImpl S, bool &Result) const; - virtual relocation_iterator getSectionRelBegin(DataRefImpl Sec) const; - virtual relocation_iterator getSectionRelEnd(DataRefImpl Sec) const; virtual error_code getRelocationNext(DataRefImpl Rel, RelocationRef &Res) const; @@ -76,13 +76,8 @@ SymbolRef &Res) const; virtual error_code getRelocationType(DataRefImpl Rel, uint32_t &Res) const; - virtual error_code getRelocationTypeName(DataRefImpl Rel, - SmallVectorImpl &Result) const; virtual error_code getRelocationAdditionalInfo(DataRefImpl Rel, int64_t &Res) const; - virtual error_code getRelocationValueString(DataRefImpl Rel, - SmallVectorImpl &Result) const; - private: MachOObject *MachOObj; mutable uint32_t RegisteredStringTable; @@ -101,7 +96,6 @@ InMemoryStruct &Res) const; void getRelocation(DataRefImpl Rel, InMemoryStruct &Res) const; - std::size_t getSectionIndex(DataRefImpl Sec) const; }; MachOObjectFile::MachOObjectFile(MemoryBuffer *Object, MachOObject *MOO, @@ -330,7 +324,7 @@ } -symbol_iterator MachOObjectFile::begin_symbols() const { +ObjectFile::symbol_iterator MachOObjectFile::begin_symbols() const { // DRI.d.a = segment number; DRI.d.b = symbol index. DataRefImpl DRI; DRI.d.a = DRI.d.b = 0; @@ -338,7 +332,7 @@ return symbol_iterator(SymbolRef(DRI, this)); } -symbol_iterator MachOObjectFile::end_symbols() const { +ObjectFile::symbol_iterator MachOObjectFile::end_symbols() const { DataRefImpl DRI; DRI.d.a = MachOObj->getHeader().NumLoadCommands; DRI.d.b = 0; @@ -386,13 +380,6 @@ MachOObj->ReadSection(LCI, DRI.d.b, Res); } -std::size_t MachOObjectFile::getSectionIndex(DataRefImpl Sec) const { - SectionList::const_iterator loc = - std::find(Sections.begin(), Sections.end(), Sec); - assert(loc != Sections.end() && "Sec is not a valid section!"); - return std::distance(Sections.begin(), loc); -} - void MachOObjectFile::getSection64(DataRefImpl DRI, InMemoryStruct &Res) const { @@ -524,37 +511,14 @@ return object_error::success; } -relocation_iterator MachOObjectFile::getSectionRelBegin(DataRefImpl Sec) const { - DataRefImpl ret; - ret.d.a = 0; - ret.d.b = getSectionIndex(Sec); - return relocation_iterator(RelocationRef(ret, this)); -} -relocation_iterator MachOObjectFile::getSectionRelEnd(DataRefImpl Sec) const { - uint32_t last_reloc; - if (is64BitLoadCommand(MachOObj, Sec)) { - InMemoryStruct Sect; - getSection64(Sec, Sect); - last_reloc = Sect->NumRelocationTableEntries; - } else { - InMemoryStruct Sect; - getSection(Sec, Sect); - last_reloc = Sect->NumRelocationTableEntries; - } - DataRefImpl ret; - ret.d.a = last_reloc; - ret.d.b = getSectionIndex(Sec); - return relocation_iterator(RelocationRef(ret, this)); -} - -section_iterator MachOObjectFile::begin_sections() const { +ObjectFile::section_iterator MachOObjectFile::begin_sections() const { DataRefImpl DRI; DRI.d.a = DRI.d.b = 0; moveToNextSection(DRI); return section_iterator(SectionRef(DRI, this)); } -section_iterator MachOObjectFile::end_sections() const { +ObjectFile::section_iterator MachOObjectFile::end_sections() const { DataRefImpl DRI; DRI.d.a = MachOObj->getHeader().NumLoadCommands; DRI.d.b = 0; @@ -581,6 +545,23 @@ error_code MachOObjectFile::getRelocationNext(DataRefImpl Rel, RelocationRef &Res) const { ++Rel.d.a; + while (Rel.d.b < Sections.size()) { + unsigned relocationCount; + if (MachOObj->is64Bit()) { + InMemoryStruct Sect; + getSection64(Sections[Rel.d.b], Sect); + relocationCount = Sect->NumRelocationTableEntries; + } else { + InMemoryStruct Sect; + getSection(Sections[Rel.d.b], Sect); + relocationCount = Sect->NumRelocationTableEntries; + } + if (Rel.d.a < relocationCount) + break; + + Rel.d.a = 0; + ++Rel.d.b; + } Res = RelocationRef(Rel, this); return object_error::success; } @@ -629,10 +610,6 @@ Res = RE->Word1; return object_error::success; } -error_code MachOObjectFile::getRelocationTypeName(DataRefImpl Rel, - SmallVectorImpl &Result) const { - return object_error::success; -} error_code MachOObjectFile::getRelocationAdditionalInfo(DataRefImpl Rel, int64_t &Res) const { InMemoryStruct RE; @@ -654,9 +631,16 @@ } return object_error::success; } -error_code MachOObjectFile::getRelocationValueString(DataRefImpl Rel, - SmallVectorImpl &Result) const { - return object_error::success; +ObjectFile::relocation_iterator MachOObjectFile::begin_relocations() const { + DataRefImpl ret; + ret.d.a = ret.d.b = 0; + return relocation_iterator(RelocationRef(ret, this)); +} +ObjectFile::relocation_iterator MachOObjectFile::end_relocations() const { + DataRefImpl ret; + ret.d.a = 0; + ret.d.b = Sections.size(); + return relocation_iterator(RelocationRef(ret, this)); } /*===-- Miscellaneous -----------------------------------------------------===*/ Modified: llvm/trunk/lib/Object/Object.cpp URL: http://llvm.org/viewvc/llvm-project/llvm/trunk/lib/Object/Object.cpp?rev=141379&r1=141378&r2=141379&view=diff ============================================================================== --- llvm/trunk/lib/Object/Object.cpp (original) +++ llvm/trunk/lib/Object/Object.cpp Fri Oct 7 13:25:37 2011 @@ -27,8 +27,8 @@ } LLVMSectionIteratorRef LLVMGetSections(LLVMObjectFileRef ObjectFile) { - section_iterator SI = unwrap(ObjectFile)->begin_sections(); - return wrap(new section_iterator(SI)); + ObjectFile::section_iterator SI = unwrap(ObjectFile)->begin_sections(); + return wrap(new ObjectFile::section_iterator(SI)); } void LLVMDisposeSectionIterator(LLVMSectionIteratorRef SI) { Modified: llvm/trunk/tools/llvm-objdump/MachODump.cpp URL: http://llvm.org/viewvc/llvm-project/llvm/trunk/tools/llvm-objdump/MachODump.cpp?rev=141379&r1=141378&r2=141379&view=diff ============================================================================== --- llvm/trunk/tools/llvm-objdump/MachODump.cpp (original) +++ llvm/trunk/tools/llvm-objdump/MachODump.cpp Fri Oct 7 13:25:37 2011 @@ -122,7 +122,7 @@ return S; } -// Print additional information about an address, if available. +// Print addtitional information about an address, if available. static void DumpAddress(uint64_t Address, ArrayRef
Sections, MachOObject *MachOObj, raw_ostream &OS) { for (unsigned i = 0; i != Sections.size(); ++i) { @@ -298,7 +298,7 @@ AsmPrinterVariant, *AsmInfo, *STI)); if (!InstrAnalysis || !AsmInfo || !STI || !DisAsm || !IP) { - errs() << "error: couldn't initialize disassembler for target " + errs() << "error: couldn't initialize disassmbler for target " << TripleName << '\n'; return; } @@ -573,7 +573,7 @@ IP->printInst(&Inst.Inst, outs(), ""); // Look for relocations inside this instructions, if there is one - // print its target and additional information if available. + // print its target and additional information if availbable. for (unsigned j = 0; j != Relocs.size(); ++j) if (Relocs[j].first >= Sections[SectIdx].Address + Inst.Address && Relocs[j].first < Sections[SectIdx].Address + Inst.Address + Modified: llvm/trunk/tools/llvm-objdump/llvm-objdump.cpp URL: http://llvm.org/viewvc/llvm-project/llvm/trunk/tools/llvm-objdump/llvm-objdump.cpp?rev=141379&r1=141378&r2=141379&view=diff ============================================================================== --- llvm/trunk/tools/llvm-objdump/llvm-objdump.cpp (original) +++ llvm/trunk/tools/llvm-objdump/llvm-objdump.cpp Fri Oct 7 13:25:37 2011 @@ -155,7 +155,7 @@ << ":\tfile format " << Obj->getFileFormatName() << "\n\n"; error_code ec; - for (section_iterator i = Obj->begin_sections(), + for (ObjectFile::section_iterator i = Obj->begin_sections(), e = Obj->end_sections(); i != e; i.increment(ec)) { if (error(ec)) break; @@ -165,7 +165,7 @@ // Make a list of all the symbols in this section. std::vector > Symbols; - for (symbol_iterator si = Obj->begin_symbols(), + for (ObjectFile::symbol_iterator si = Obj->begin_symbols(), se = Obj->end_symbols(); si != se; si.increment(ec)) { bool contains; From grosbach at apple.com Fri Oct 7 13:27:04 2011 From: grosbach at apple.com (Jim Grosbach) Date: Fri, 07 Oct 2011 18:27:04 -0000 Subject: [llvm-commits] [llvm] r141380 - /llvm/trunk/lib/Target/ARM/AsmParser/ARMAsmParser.cpp Message-ID: <20111007182705.07C752A6C12D@llvm.org> Author: grosbach Date: Fri Oct 7 13:27:04 2011 New Revision: 141380 URL: http://llvm.org/viewvc/llvm-project?rev=141380&view=rev Log: Improve ARM assembly parser diagnostic for unexpected tokens. Consider: mov r8, r11 fred Previously, we issued the not very informative: x.s:6:1: error: unexpected token in argument list ^ Now we generate: x.s:5:14: error: unexpected token in argument list mov r8, r11 fred ^ Modified: llvm/trunk/lib/Target/ARM/AsmParser/ARMAsmParser.cpp Modified: llvm/trunk/lib/Target/ARM/AsmParser/ARMAsmParser.cpp URL: http://llvm.org/viewvc/llvm-project/llvm/trunk/lib/Target/ARM/AsmParser/ARMAsmParser.cpp?rev=141380&r1=141379&r2=141380&view=diff ============================================================================== --- llvm/trunk/lib/Target/ARM/AsmParser/ARMAsmParser.cpp (original) +++ llvm/trunk/lib/Target/ARM/AsmParser/ARMAsmParser.cpp Fri Oct 7 13:27:04 2011 @@ -3617,8 +3617,9 @@ } if (getLexer().isNot(AsmToken::EndOfStatement)) { + SMLoc Loc = getLexer().getLoc(); Parser.EatToEndOfStatement(); - return TokError("unexpected token in argument list"); + return Error(Loc, "unexpected token in argument list"); } Parser.Lex(); // Consume the EndOfStatement From echristo at apple.com Fri Oct 7 13:50:45 2011 From: echristo at apple.com (Eric Christopher) Date: Fri, 07 Oct 2011 11:50:45 -0700 Subject: [llvm-commits] [llvm] r141365 - in /llvm/trunk: lib/Target/ARM/ARMISelDAGToDAG.cpp lib/Target/ARM/ARMISelLowering.cpp lib/Target/ARM/ARMInstrInfo.td lib/Target/ARM/ARMInstrThumb2.td test/CodeGen/ARM/iabs.ll test/CodeGen/Thumb/iabs.ll In-Reply-To: References: <20111007161509.46571312800A@llvm.org> <5751F138-40A5-4245-840D-D24DC0D54194@apple.com> Message-ID: <40E1F4C6-5513-4B4C-BF3F-053162FD213D@apple.com> On Oct 7, 2011, at 10:50 AM, Anton Korobeynikov wrote: > Hello David, > >> One of our builders is getting an error from the assembler after this change: >> >> /var/folders/+E/+EgeYw01FF8FkfNihyEYQU+++TM/-Tmp-/floatsidf-B8VdeE.s:19:cannot honor width suffix -- `rsb r0,r0,#0' >> clang: error: assembler command failed with exit code 1 (use -v to see invocation) > Will you please provide the .S output for the code in question? llvm/projects/compiler-rt/lib/floatsidf.c compiled with ToT clang. -eric From anton at korobeynikov.info Fri Oct 7 13:52:24 2011 From: anton at korobeynikov.info (Anton Korobeynikov) Date: Fri, 7 Oct 2011 22:52:24 +0400 Subject: [llvm-commits] [llvm] r141365 - in /llvm/trunk: lib/Target/ARM/ARMISelDAGToDAG.cpp lib/Target/ARM/ARMISelLowering.cpp lib/Target/ARM/ARMInstrInfo.td lib/Target/ARM/ARMInstrThumb2.td test/CodeGen/ARM/iabs.ll test/CodeGen/Thumb/iabs.ll In-Reply-To: <40E1F4C6-5513-4B4C-BF3F-053162FD213D@apple.com> References: <20111007161509.46571312800A@llvm.org> <5751F138-40A5-4245-840D-D24DC0D54194@apple.com> <40E1F4C6-5513-4B4C-BF3F-053162FD213D@apple.com> Message-ID: Hi Eric, > llvm/projects/compiler-rt/lib/floatsidf.c > compiled with ToT clang. Which mode? ARM? Thumb2? Thumb1? For which ARM arch? compiler-rt has many different modes :) -- With best regards, Anton Korobeynikov Faculty of Mathematics and Mechanics, Saint Petersburg State University From lattner at apple.com Fri Oct 7 13:55:20 2011 From: lattner at apple.com (Tanya Lattner) Date: Fri, 07 Oct 2011 11:55:20 -0700 Subject: [llvm-commits] [PATCH] Linker Changes to not destroy source module Message-ID: Attached is a patch that makes it possible to use the linker without destroying the source module. This is so the source module can be linked to multiple other destination modules. For all that used LinkModules() before, they will continue to destroy the source module as before. Chris has reviewed this for me already, but if anyone else wants to take a look, please do. If no objections, I'll commit it. I have some other linker work that is going in on top of it. Thanks, Tanya -------------- next part -------------- A non-text attachment was scrubbed... Name: linker-preservesource.patch Type: application/octet-stream Size: 11486 bytes Desc: not available Url : http://lists.cs.uiuc.edu/pipermail/llvm-commits/attachments/20111007/ba8f3384/attachment.obj From echristo at apple.com Fri Oct 7 13:56:42 2011 From: echristo at apple.com (Eric Christopher) Date: Fri, 07 Oct 2011 11:56:42 -0700 Subject: [llvm-commits] [llvm] r141365 - in /llvm/trunk: lib/Target/ARM/ARMISelDAGToDAG.cpp lib/Target/ARM/ARMISelLowering.cpp lib/Target/ARM/ARMInstrInfo.td lib/Target/ARM/ARMInstrThumb2.td test/CodeGen/ARM/iabs.ll test/CodeGen/Thumb/iabs.ll In-Reply-To: References: <20111007161509.46571312800A@llvm.org> <5751F138-40A5-4245-840D-D24DC0D54194@apple.com> <40E1F4C6-5513-4B4C-BF3F-053162FD213D@apple.com> Message-ID: <6144A303-F54E-4A0F-B69D-DB9B94037F47@apple.com> On Oct 7, 2011, at 11:52 AM, Anton Korobeynikov wrote: > Hi Eric, > >> llvm/projects/compiler-rt/lib/floatsidf.c >> compiled with ToT clang. > Which mode? ARM? Thumb2? Thumb1? For which ARM arch? compiler-rt has > many different modes :) armv6 it looks like :) COMPILE: clang_darwin/cc_kext/armv6: /Volumes/Data/sources/llvm/projects/compiler-rt/lib/floatsidf.c /var/folders/9p/2n1d124n1fd9bvkb815y0j6r0000gp/T/floatsidf-TXq5db.s:19:cannot honor width suffix -- `rsb r0,r0,#0' clang: error: assembler command failed with exit code 1 (use -v to see invocation) -eric From criswell at uiuc.edu Fri Oct 7 14:11:46 2011 From: criswell at uiuc.edu (John Criswell) Date: Fri, 07 Oct 2011 19:11:46 -0000 Subject: [llvm-commits] [poolalloc] r141383 - /poolalloc/trunk/lib/DSA/Local.cpp Message-ID: <20111007191146.7B54D312800A@llvm.org> Author: criswell Date: Fri Oct 7 14:11:46 2011 New Revision: 141383 URL: http://llvm.org/viewvc/llvm-project?rev=141383&view=rev Log: Added comments. No functionality changes. Modified: poolalloc/trunk/lib/DSA/Local.cpp Modified: poolalloc/trunk/lib/DSA/Local.cpp URL: http://llvm.org/viewvc/llvm-project/poolalloc/trunk/lib/DSA/Local.cpp?rev=141383&r1=141382&r2=141383&view=diff ============================================================================== --- poolalloc/trunk/lib/DSA/Local.cpp (original) +++ poolalloc/trunk/lib/DSA/Local.cpp Fri Oct 7 14:11:46 2011 @@ -362,7 +362,12 @@ } void GraphBuilder::visitLoadInst(LoadInst &LI) { - DSNodeHandle Ptr = getValueDest(LI.getOperand(0)); + // + // Create a DSNode for the poiner dereferenced by the load. If the DSNode + // is NULL, do nothing more (this can occur if the load is loading from a + // NULL pointer constant (bugpoint can generate such code). + // + DSNodeHandle Ptr = getValueDest(LI.getPointerOperand()); if (Ptr.isNull()) return; // Load from null // Make that the node is read from... From bigcheesegs at gmail.com Fri Oct 7 14:25:32 2011 From: bigcheesegs at gmail.com (Michael J. Spencer) Date: Fri, 07 Oct 2011 19:25:32 -0000 Subject: [llvm-commits] [llvm] r141385 - in /llvm/trunk: include/llvm-c/Object.h include/llvm/Object/COFF.h include/llvm/Object/ObjectFile.h lib/Object/COFFObjectFile.cpp lib/Object/ELFObjectFile.cpp lib/Object/MachOObjectFile.cpp lib/Object/Object.cpp tools/llvm-objdump/llvm-objdump.cpp Message-ID: <20111007192532.D40EB2A6C12D@llvm.org> Author: mspencer Date: Fri Oct 7 14:25:32 2011 New Revision: 141385 URL: http://llvm.org/viewvc/llvm-project?rev=141385&view=rev Log: Change relocation API to be per section. This time without breaking GCC. Modified: llvm/trunk/include/llvm-c/Object.h llvm/trunk/include/llvm/Object/COFF.h llvm/trunk/include/llvm/Object/ObjectFile.h llvm/trunk/lib/Object/COFFObjectFile.cpp llvm/trunk/lib/Object/ELFObjectFile.cpp llvm/trunk/lib/Object/MachOObjectFile.cpp llvm/trunk/lib/Object/Object.cpp llvm/trunk/tools/llvm-objdump/llvm-objdump.cpp Modified: llvm/trunk/include/llvm-c/Object.h URL: http://llvm.org/viewvc/llvm-project/llvm/trunk/include/llvm-c/Object.h?rev=141385&r1=141384&r2=141385&view=diff ============================================================================== --- llvm/trunk/include/llvm-c/Object.h (original) +++ llvm/trunk/include/llvm-c/Object.h Fri Oct 7 14:25:32 2011 @@ -59,14 +59,14 @@ return reinterpret_cast(const_cast(OF)); } - inline ObjectFile::section_iterator *unwrap(LLVMSectionIteratorRef SI) { - return reinterpret_cast(SI); + inline section_iterator *unwrap(LLVMSectionIteratorRef SI) { + return reinterpret_cast(SI); } inline LLVMSectionIteratorRef - wrap(const ObjectFile::section_iterator *SI) { + wrap(const section_iterator *SI) { return reinterpret_cast - (const_cast(SI)); + (const_cast(SI)); } } } Modified: llvm/trunk/include/llvm/Object/COFF.h URL: http://llvm.org/viewvc/llvm-project/llvm/trunk/include/llvm/Object/COFF.h?rev=141385&r1=141384&r2=141385&view=diff ============================================================================== --- llvm/trunk/include/llvm/Object/COFF.h (original) +++ llvm/trunk/include/llvm/Object/COFF.h Fri Oct 7 14:25:32 2011 @@ -84,6 +84,8 @@ error_code getSection(int32_t index, const coff_section *&Res) const; error_code getString(uint32_t offset, StringRef &Res) const; + error_code getSymbol(uint32_t index, + const coff_symbol *&Res) const; const coff_symbol *toSymb(DataRefImpl Symb) const; const coff_section *toSec(DataRefImpl Sec) const; @@ -110,6 +112,8 @@ virtual error_code isSectionBSS(DataRefImpl Sec, bool &Res) const; virtual error_code sectionContainsSymbol(DataRefImpl Sec, DataRefImpl Symb, bool &Result) const; + virtual relocation_iterator getSectionRelBegin(DataRefImpl Sec) const; + virtual relocation_iterator getSectionRelEnd(DataRefImpl Sec) const; virtual error_code getRelocationNext(DataRefImpl Rel, RelocationRef &Res) const; @@ -119,16 +123,19 @@ SymbolRef &Res) const; virtual error_code getRelocationType(DataRefImpl Rel, uint32_t &Res) const; + virtual error_code getRelocationTypeName(DataRefImpl Rel, + SmallVectorImpl &Result) const; virtual error_code getRelocationAdditionalInfo(DataRefImpl Rel, int64_t &Res) const; + virtual error_code getRelocationValueString(DataRefImpl Rel, + SmallVectorImpl &Result) const; + public: COFFObjectFile(MemoryBuffer *Object, error_code &ec); virtual symbol_iterator begin_symbols() const; virtual symbol_iterator end_symbols() const; virtual section_iterator begin_sections() const; virtual section_iterator end_sections() const; - virtual relocation_iterator begin_relocations() const; - virtual relocation_iterator end_relocations() const; virtual uint8_t getBytesInAddress() const; virtual StringRef getFileFormatName() const; Modified: llvm/trunk/include/llvm/Object/ObjectFile.h URL: http://llvm.org/viewvc/llvm-project/llvm/trunk/include/llvm/Object/ObjectFile.h?rev=141385&r1=141384&r2=141385&view=diff ============================================================================== --- llvm/trunk/include/llvm/Object/ObjectFile.h (original) +++ llvm/trunk/include/llvm/Object/ObjectFile.h Fri Oct 7 14:25:32 2011 @@ -28,11 +28,50 @@ union DataRefImpl { struct { + // ELF needs this for relocations. This entire union should probably be a + // char[max(8, sizeof(uintptr_t))] and require the impl to cast. + uint16_t a, b; + uint32_t c; + } w; + struct { uint32_t a, b; } d; uintptr_t p; }; +template +class content_iterator { + content_type Current; +public: + content_iterator(content_type symb) + : Current(symb) {} + + const content_type* operator->() const { + return &Current; + } + + const content_type &operator*() const { + return Current; + } + + bool operator==(const content_iterator &other) const { + return Current == other.Current; + } + + bool operator!=(const content_iterator &other) const { + return !(*this == other); + } + + content_iterator& increment(error_code &err) { + content_type next; + if (error_code ec = Current.getNext(next)) + err = ec; + else + Current = next; + return *this; + } +}; + static bool operator ==(const DataRefImpl &a, const DataRefImpl &b) { // Check bitwise identical. This is the only legal way to compare a union w/o // knowing which member is in use. @@ -82,6 +121,7 @@ /// such as library functions error_code isGlobal(bool &Result) const; }; +typedef content_iterator symbol_iterator; /// RelocationRef - This is a value type class that represents a single /// relocation in the list of relocations in the object file. @@ -103,8 +143,20 @@ error_code getAddress(uint64_t &Result) const; error_code getSymbol(SymbolRef &Result) const; error_code getType(uint32_t &Result) const; + + /// @brief Get a string that represents the type of this relocation. + /// + /// This is for display purposes only. + error_code getTypeName(SmallVectorImpl &Result) const; error_code getAdditionalInfo(int64_t &Result) const; + + /// @brief Get a string that represents the calculation of the value of this + /// relocation. + /// + /// This is for display purposes only. + error_code getValueString(SmallVectorImpl &Result) const; }; +typedef content_iterator relocation_iterator; /// SectionRef - This is a value type class that represents a single section in /// the list of sections in the object file. @@ -135,7 +187,11 @@ error_code isBSS(bool &Result) const; error_code containsSymbol(SymbolRef S, bool &Result) const; + + relocation_iterator begin_relocations() const; + relocation_iterator end_relocations() const; }; +typedef content_iterator section_iterator; const uint64_t UnknownAddressOrSize = ~0ULL; @@ -185,6 +241,8 @@ virtual error_code isSectionBSS(DataRefImpl Sec, bool &Res) const = 0; virtual error_code sectionContainsSymbol(DataRefImpl Sec, DataRefImpl Symb, bool &Result) const = 0; + virtual relocation_iterator getSectionRelBegin(DataRefImpl Sec) const = 0; + virtual relocation_iterator getSectionRelEnd(DataRefImpl Sec) const = 0; // Same as above for RelocationRef. @@ -197,46 +255,14 @@ SymbolRef &Res) const = 0; virtual error_code getRelocationType(DataRefImpl Rel, uint32_t &Res) const = 0; + virtual error_code getRelocationTypeName(DataRefImpl Rel, + SmallVectorImpl &Result) const = 0; virtual error_code getRelocationAdditionalInfo(DataRefImpl Rel, int64_t &Res) const = 0; + virtual error_code getRelocationValueString(DataRefImpl Rel, + SmallVectorImpl &Result) const = 0; public: - template - class content_iterator { - content_type Current; - public: - content_iterator(content_type symb) - : Current(symb) {} - - const content_type* operator->() const { - return &Current; - } - - const content_type &operator*() const { - return Current; - } - - bool operator==(const content_iterator &other) const { - return Current == other.Current; - } - - bool operator!=(const content_iterator &other) const { - return !(*this == other); - } - - content_iterator& increment(error_code &err) { - content_type next; - if (error_code ec = Current.getNext(next)) - err = ec; - else - Current = next; - return *this; - } - }; - - typedef content_iterator symbol_iterator; - typedef content_iterator section_iterator; - typedef content_iterator relocation_iterator; virtual symbol_iterator begin_symbols() const = 0; virtual symbol_iterator end_symbols() const = 0; @@ -244,9 +270,6 @@ virtual section_iterator begin_sections() const = 0; virtual section_iterator end_sections() const = 0; - virtual relocation_iterator begin_relocations() const = 0; - virtual relocation_iterator end_relocations() const = 0; - /// @brief The number of bytes used to represent an address in this object /// file format. virtual uint8_t getBytesInAddress() const = 0; @@ -366,6 +389,14 @@ Result); } +inline relocation_iterator SectionRef::begin_relocations() const { + return OwningObject->getSectionRelBegin(SectionPimpl); +} + +inline relocation_iterator SectionRef::end_relocations() const { + return OwningObject->getSectionRelEnd(SectionPimpl); +} + /// RelocationRef inline RelocationRef::RelocationRef(DataRefImpl RelocationP, @@ -393,10 +424,20 @@ return OwningObject->getRelocationType(RelocationPimpl, Result); } +inline error_code RelocationRef::getTypeName(SmallVectorImpl &Result) + const { + return OwningObject->getRelocationTypeName(RelocationPimpl, Result); +} + inline error_code RelocationRef::getAdditionalInfo(int64_t &Result) const { return OwningObject->getRelocationAdditionalInfo(RelocationPimpl, Result); } +inline error_code RelocationRef::getValueString(SmallVectorImpl &Result) + const { + return OwningObject->getRelocationValueString(RelocationPimpl, Result); +} + } // end namespace object } // end namespace llvm Modified: llvm/trunk/lib/Object/COFFObjectFile.cpp URL: http://llvm.org/viewvc/llvm-project/llvm/trunk/lib/Object/COFFObjectFile.cpp?rev=141385&r1=141384&r2=141385&view=diff ============================================================================== --- llvm/trunk/lib/Object/COFFObjectFile.cpp (original) +++ llvm/trunk/lib/Object/COFFObjectFile.cpp Fri Oct 7 14:25:32 2011 @@ -12,6 +12,7 @@ //===----------------------------------------------------------------------===// #include "llvm/Object/COFF.h" +#include "llvm/ADT/SmallString.h" #include "llvm/ADT/StringSwitch.h" #include "llvm/ADT/Triple.h" @@ -364,6 +365,33 @@ return object_error::success; } +relocation_iterator COFFObjectFile::getSectionRelBegin(DataRefImpl Sec) const { + const coff_section *sec = toSec(Sec); + DataRefImpl ret; + std::memset(&ret, 0, sizeof(ret)); + if (sec->NumberOfRelocations == 0) + ret.p = 0; + else + ret.p = reinterpret_cast(base() + sec->PointerToRelocations); + + return relocation_iterator(RelocationRef(ret, this)); +} + +relocation_iterator COFFObjectFile::getSectionRelEnd(DataRefImpl Sec) const { + const coff_section *sec = toSec(Sec); + DataRefImpl ret; + std::memset(&ret, 0, sizeof(ret)); + if (sec->NumberOfRelocations == 0) + ret.p = 0; + else + ret.p = reinterpret_cast( + reinterpret_cast( + base() + sec->PointerToRelocations) + + sec->NumberOfRelocations); + + return relocation_iterator(RelocationRef(ret, this)); +} + COFFObjectFile::COFFObjectFile(MemoryBuffer *Object, error_code &ec) : ObjectFile(Binary::isCOFF, Object, ec) { // Check that we at least have enough room for a header. @@ -427,14 +455,14 @@ ec = object_error::success; } -ObjectFile::symbol_iterator COFFObjectFile::begin_symbols() const { +symbol_iterator COFFObjectFile::begin_symbols() const { DataRefImpl ret; std::memset(&ret, 0, sizeof(DataRefImpl)); ret.p = reinterpret_cast(SymbolTable); return symbol_iterator(SymbolRef(ret, this)); } -ObjectFile::symbol_iterator COFFObjectFile::end_symbols() const { +symbol_iterator COFFObjectFile::end_symbols() const { // The symbol table ends where the string table begins. DataRefImpl ret; std::memset(&ret, 0, sizeof(DataRefImpl)); @@ -442,14 +470,14 @@ return symbol_iterator(SymbolRef(ret, this)); } -ObjectFile::section_iterator COFFObjectFile::begin_sections() const { +section_iterator COFFObjectFile::begin_sections() const { DataRefImpl ret; std::memset(&ret, 0, sizeof(DataRefImpl)); ret.p = reinterpret_cast(SectionTable); return section_iterator(SectionRef(ret, this)); } -ObjectFile::section_iterator COFFObjectFile::end_sections() const { +section_iterator COFFObjectFile::end_sections() const { DataRefImpl ret; std::memset(&ret, 0, sizeof(DataRefImpl)); ret.p = reinterpret_cast(SectionTable + Header->NumberOfSections); @@ -508,42 +536,28 @@ return object_error::success; } +error_code COFFObjectFile::getSymbol(uint32_t index, + const coff_symbol *&Result) const { + if (index > 0 && index < Header->NumberOfSymbols) + Result = SymbolTable + index; + else + return object_error::parse_failed; + return object_error::success; +} + const coff_relocation *COFFObjectFile::toRel(DataRefImpl Rel) const { - assert(Rel.d.b < Header->NumberOfSections && "Section index out of range!"); - const coff_section *Sect = NULL; - getSection(Rel.d.b, Sect); - assert(Rel.d.a < Sect->NumberOfRelocations && "Relocation index out of range!"); - return - reinterpret_cast(base() + - Sect->PointerToRelocations) + - Rel.d.a; + return reinterpret_cast(Rel.p); } error_code COFFObjectFile::getRelocationNext(DataRefImpl Rel, RelocationRef &Res) const { - const coff_section *Sect = NULL; - if (error_code ec = getSection(Rel.d.b, Sect)) - return ec; - if (++Rel.d.a >= Sect->NumberOfRelocations) { - Rel.d.a = 0; - while (++Rel.d.b < Header->NumberOfSections) { - const coff_section *Sect = NULL; - getSection(Rel.d.b, Sect); - if (Sect->NumberOfRelocations > 0) - break; - } - } + Rel.p = reinterpret_cast( + reinterpret_cast(Rel.p) + 1); Res = RelocationRef(Rel, this); return object_error::success; } error_code COFFObjectFile::getRelocationAddress(DataRefImpl Rel, uint64_t &Res) const { - const coff_section *Sect = NULL; - if (error_code ec = getSection(Rel.d.b, Sect)) - return ec; - const coff_relocation* R = toRel(Rel); - Res = reinterpret_cast(base() + - Sect->PointerToRawData + - R->VirtualAddress); + Res = toRel(Rel)->VirtualAddress; return object_error::success; } error_code COFFObjectFile::getRelocationSymbol(DataRefImpl Rel, @@ -560,25 +574,83 @@ Res = R->Type; return object_error::success; } + +#define LLVM_COFF_SWITCH_RELOC_TYPE_NAME(enum) \ + case COFF::enum: res = #enum; break; + +error_code COFFObjectFile::getRelocationTypeName(DataRefImpl Rel, + SmallVectorImpl &Result) const { + const coff_relocation *reloc = toRel(Rel); + StringRef res; + switch (Header->Machine) { + case COFF::IMAGE_FILE_MACHINE_AMD64: + switch (reloc->Type) { + LLVM_COFF_SWITCH_RELOC_TYPE_NAME(IMAGE_REL_AMD64_ABSOLUTE); + LLVM_COFF_SWITCH_RELOC_TYPE_NAME(IMAGE_REL_AMD64_ADDR64); + LLVM_COFF_SWITCH_RELOC_TYPE_NAME(IMAGE_REL_AMD64_ADDR32); + LLVM_COFF_SWITCH_RELOC_TYPE_NAME(IMAGE_REL_AMD64_ADDR32NB); + LLVM_COFF_SWITCH_RELOC_TYPE_NAME(IMAGE_REL_AMD64_REL32); + LLVM_COFF_SWITCH_RELOC_TYPE_NAME(IMAGE_REL_AMD64_REL32_1); + LLVM_COFF_SWITCH_RELOC_TYPE_NAME(IMAGE_REL_AMD64_REL32_2); + LLVM_COFF_SWITCH_RELOC_TYPE_NAME(IMAGE_REL_AMD64_REL32_3); + LLVM_COFF_SWITCH_RELOC_TYPE_NAME(IMAGE_REL_AMD64_REL32_4); + LLVM_COFF_SWITCH_RELOC_TYPE_NAME(IMAGE_REL_AMD64_REL32_5); + LLVM_COFF_SWITCH_RELOC_TYPE_NAME(IMAGE_REL_AMD64_SECTION); + LLVM_COFF_SWITCH_RELOC_TYPE_NAME(IMAGE_REL_AMD64_SECREL); + LLVM_COFF_SWITCH_RELOC_TYPE_NAME(IMAGE_REL_AMD64_SECREL7); + LLVM_COFF_SWITCH_RELOC_TYPE_NAME(IMAGE_REL_AMD64_TOKEN); + LLVM_COFF_SWITCH_RELOC_TYPE_NAME(IMAGE_REL_AMD64_SREL32); + LLVM_COFF_SWITCH_RELOC_TYPE_NAME(IMAGE_REL_AMD64_PAIR); + LLVM_COFF_SWITCH_RELOC_TYPE_NAME(IMAGE_REL_AMD64_SSPAN32); + default: + res = "Unknown"; + } + break; + case COFF::IMAGE_FILE_MACHINE_I386: + switch (reloc->Type) { + LLVM_COFF_SWITCH_RELOC_TYPE_NAME(IMAGE_REL_I386_ABSOLUTE); + LLVM_COFF_SWITCH_RELOC_TYPE_NAME(IMAGE_REL_I386_DIR16); + LLVM_COFF_SWITCH_RELOC_TYPE_NAME(IMAGE_REL_I386_REL16); + LLVM_COFF_SWITCH_RELOC_TYPE_NAME(IMAGE_REL_I386_DIR32); + LLVM_COFF_SWITCH_RELOC_TYPE_NAME(IMAGE_REL_I386_DIR32NB); + LLVM_COFF_SWITCH_RELOC_TYPE_NAME(IMAGE_REL_I386_SEG12); + LLVM_COFF_SWITCH_RELOC_TYPE_NAME(IMAGE_REL_I386_SECTION); + LLVM_COFF_SWITCH_RELOC_TYPE_NAME(IMAGE_REL_I386_SECREL); + LLVM_COFF_SWITCH_RELOC_TYPE_NAME(IMAGE_REL_I386_TOKEN); + LLVM_COFF_SWITCH_RELOC_TYPE_NAME(IMAGE_REL_I386_SECREL7); + LLVM_COFF_SWITCH_RELOC_TYPE_NAME(IMAGE_REL_I386_REL32); + default: + res = "Unknown"; + } + break; + default: + res = "Unknown"; + } + Result.append(res.begin(), res.end()); + return object_error::success; +} + +#undef LLVM_COFF_SWITCH_RELOC_TYPE_NAME + error_code COFFObjectFile::getRelocationAdditionalInfo(DataRefImpl Rel, int64_t &Res) const { Res = 0; return object_error::success; } -ObjectFile::relocation_iterator COFFObjectFile::begin_relocations() const { - DataRefImpl ret; - ret.d.a = 0; - ret.d.b = 1; - return relocation_iterator(RelocationRef(ret, this)); -} -ObjectFile::relocation_iterator COFFObjectFile::end_relocations() const { - DataRefImpl ret; - ret.d.a = 0; - ret.d.b = Header->NumberOfSections; - return relocation_iterator(RelocationRef(ret, this)); +error_code COFFObjectFile::getRelocationValueString(DataRefImpl Rel, + SmallVectorImpl &Result) const { + const coff_relocation *reloc = toRel(Rel); + const coff_symbol *symb; + if (error_code ec = getSymbol(reloc->SymbolTableIndex, symb)) return ec; + DataRefImpl sym; + ::memset(&sym, 0, sizeof(sym)); + sym.p = reinterpret_cast(symb); + StringRef symname; + if (error_code ec = getSymbolName(sym, symname)) return ec; + Result.append(symname.begin(), symname.end()); + return object_error::success; } - namespace llvm { ObjectFile *ObjectFile::createCOFFObjectFile(MemoryBuffer *Object) { Modified: llvm/trunk/lib/Object/ELFObjectFile.cpp URL: http://llvm.org/viewvc/llvm-project/llvm/trunk/lib/Object/ELFObjectFile.cpp?rev=141385&r1=141384&r2=141385&view=diff ============================================================================== --- llvm/trunk/lib/Object/ELFObjectFile.cpp (original) +++ llvm/trunk/lib/Object/ELFObjectFile.cpp Fri Oct 7 14:25:32 2011 @@ -20,6 +20,8 @@ #include "llvm/Support/Endian.h" #include "llvm/Support/ErrorHandling.h" #include "llvm/Support/MemoryBuffer.h" +#include "llvm/Support/raw_ostream.h" +#include #include #include @@ -286,6 +288,7 @@ typedef SmallVector Sections_t; typedef DenseMap IndexMap_t; + typedef DenseMap > RelocMap_t; const Elf_Ehdr *Header; const Elf_Shdr *SectionHeaderTable; @@ -293,12 +296,22 @@ const Elf_Shdr *dot_strtab_sec; // Symbol header string table. Sections_t SymbolTableSections; IndexMap_t SymbolTableSectionsIndexMap; - Sections_t RelocationTableSections; + + /// @brief Map sections to an array of relocation sections that reference + /// them sorted by section index. + RelocMap_t SectionRelocMap; + + /// @brief Get the relocation section that contains \a Rel. + const Elf_Shdr *getRelSection(DataRefImpl Rel) const { + return getSection(Rel.w.b); + } void validateSymbol(DataRefImpl Symb) const; bool isRelocationHasAddend(DataRefImpl Rel) const; template - const T *getEntry(DataRefImpl Entry, Sections_t Sections) const; + const T *getEntry(uint16_t Section, uint32_t Entry) const; + template + const T *getEntry(const Elf_Shdr *Section, uint32_t Entry) const; const Elf_Sym *getSymbol(DataRefImpl Symb) const; const Elf_Shdr *getSection(DataRefImpl index) const; const Elf_Shdr *getSection(uint16_t index) const; @@ -306,6 +319,7 @@ const Elf_Rela *getRela(DataRefImpl Rela) const; const char *getString(uint16_t section, uint32_t offset) const; const char *getString(const Elf_Shdr *section, uint32_t offset) const; + error_code getSymbolName(const Elf_Sym *Symb, StringRef &Res) const; protected: virtual error_code getSymbolNext(DataRefImpl Symb, SymbolRef &Res) const; @@ -328,6 +342,8 @@ virtual error_code isSectionBSS(DataRefImpl Sec, bool &Res) const; virtual error_code sectionContainsSymbol(DataRefImpl Sec, DataRefImpl Symb, bool &Result) const; + virtual relocation_iterator getSectionRelBegin(DataRefImpl Sec) const; + virtual relocation_iterator getSectionRelEnd(DataRefImpl Sec) const; virtual error_code getRelocationNext(DataRefImpl Rel, RelocationRef &Res) const; @@ -337,8 +353,12 @@ SymbolRef &Res) const; virtual error_code getRelocationType(DataRefImpl Rel, uint32_t &Res) const; + virtual error_code getRelocationTypeName(DataRefImpl Rel, + SmallVectorImpl &Result) const; virtual error_code getRelocationAdditionalInfo(DataRefImpl Rel, int64_t &Res) const; + virtual error_code getRelocationValueString(DataRefImpl Rel, + SmallVectorImpl &Result) const; public: ELFObjectFile(MemoryBuffer *Object, error_code &ec); @@ -346,8 +366,6 @@ virtual symbol_iterator end_symbols() const; virtual section_iterator begin_sections() const; virtual section_iterator end_sections() const; - virtual relocation_iterator begin_relocations() const; - virtual relocation_iterator end_relocations() const; virtual uint8_t getBytesInAddress() const; virtual StringRef getFileFormatName() const; @@ -404,18 +422,7 @@ StringRef &Result) const { validateSymbol(Symb); const Elf_Sym *symb = getSymbol(Symb); - if (symb->st_name == 0) { - const Elf_Shdr *section = getSection(symb->st_shndx); - if (!section) - Result = ""; - else - Result = getString(dot_shstrtab_sec, section->sh_name); - return object_error::success; - } - - // Use the default symbol table name section. - Result = getString(dot_strtab_sec, symb->st_name); - return object_error::success; + return getSymbolName(symb, Result); } template @@ -712,24 +719,65 @@ return object_error::success; } +template +relocation_iterator ELFObjectFile + ::getSectionRelBegin(DataRefImpl Sec) const { + DataRefImpl RelData; + memset(&RelData, 0, sizeof(RelData)); + const Elf_Shdr *sec = reinterpret_cast(Sec.p); + typename RelocMap_t::const_iterator ittr = SectionRelocMap.find(sec); + if (sec != 0 && ittr != SectionRelocMap.end()) { + RelData.w.a = getSection(ittr->second[0])->sh_link; + RelData.w.b = ittr->second[0]; + RelData.w.c = 0; + } + return relocation_iterator(RelocationRef(RelData, this)); +} + +template +relocation_iterator ELFObjectFile + ::getSectionRelEnd(DataRefImpl Sec) const { + DataRefImpl RelData; + memset(&RelData, 0, sizeof(RelData)); + const Elf_Shdr *sec = reinterpret_cast(Sec.p); + typename RelocMap_t::const_iterator ittr = SectionRelocMap.find(sec); + if (sec != 0 && ittr != SectionRelocMap.end()) { + // Get the index of the last relocation section for this section. + std::size_t relocsecindex = ittr->second[ittr->second.size() - 1]; + const Elf_Shdr *relocsec = getSection(relocsecindex); + RelData.w.a = relocsec->sh_link; + RelData.w.b = relocsecindex; + RelData.w.c = relocsec->sh_size / relocsec->sh_entsize; + } + return relocation_iterator(RelocationRef(RelData, this)); +} + // Relocations template error_code ELFObjectFile ::getRelocationNext(DataRefImpl Rel, RelocationRef &Result) const { - const Elf_Shdr *RelocationTableSection = RelocationTableSections[Rel.d.b]; - - // Check to see if we are at the end of this relocation table. - if (++Rel.d.a >= RelocationTableSection->getEntityCount()) { - // We are at the end. If there are other relocation tables, jump to them. - Rel.d.a = 0; - // Otherwise return the terminator. - if (++Rel.d.b >= SymbolTableSections.size()) { - Rel.d.a = std::numeric_limits::max(); - Rel.d.b = std::numeric_limits::max(); + ++Rel.w.c; + const Elf_Shdr *relocsec = getSection(Rel.w.b); + if (Rel.w.c >= (relocsec->sh_size / relocsec->sh_entsize)) { + // We have reached the end of the relocations for this section. See if there + // is another relocation section. + typename RelocMap_t::mapped_type &relocseclist = + SectionRelocMap.lookup(getSection(Rel.w.a)); + + // Do a binary search for the current reloc section index (which must be + // present). Then get the next one. + typename RelocMap_t::mapped_type::const_iterator loc = + std::lower_bound(relocseclist.begin(), relocseclist.end(), Rel.w.b); + ++loc; + + // If there is no next one, don't do anything. The ++Rel.w.c above sets Rel + // to the end iterator. + if (loc != relocseclist.end()) { + Rel.w.b = *loc; + Rel.w.a = 0; } } - Result = RelocationRef(Rel, this); return object_error::success; } @@ -739,7 +787,7 @@ ::getRelocationSymbol(DataRefImpl Rel, SymbolRef &Result) const { uint32_t symbolIdx; - const Elf_Shdr *sec = RelocationTableSections[Rel.d.b]; + const Elf_Shdr *sec = getSection(Rel.w.b); switch (sec->sh_type) { default : report_fatal_error("Invalid section type in Rel!"); @@ -767,7 +815,7 @@ ::getRelocationAddress(DataRefImpl Rel, uint64_t &Result) const { uint64_t offset; - const Elf_Shdr *sec = RelocationTableSections[Rel.d.b]; + const Elf_Shdr *sec = getSection(Rel.w.b); switch (sec->sh_type) { default : report_fatal_error("Invalid section type in Rel!"); @@ -781,8 +829,7 @@ } } - const Elf_Shdr *secAddr = getSection(sec->sh_info); - Result = offset + reinterpret_cast(base() + secAddr->sh_offset); + Result = offset; return object_error::success; } @@ -790,7 +837,7 @@ error_code ELFObjectFile ::getRelocationType(DataRefImpl Rel, uint32_t &Result) const { - const Elf_Shdr *sec = RelocationTableSections[Rel.d.b]; + const Elf_Shdr *sec = getSection(Rel.w.b); switch (sec->sh_type) { default : report_fatal_error("Invalid section type in Rel!"); @@ -806,11 +853,127 @@ return object_error::success; } +#define LLVM_ELF_SWITCH_RELOC_TYPE_NAME(enum) \ + case ELF::enum: res = #enum; break; + +template +error_code ELFObjectFile + ::getRelocationTypeName(DataRefImpl Rel, + SmallVectorImpl &Result) const { + const Elf_Shdr *sec = getSection(Rel.w.b); + uint8_t type; + StringRef res; + switch (sec->sh_type) { + default : + return object_error::parse_failed; + case ELF::SHT_REL : { + type = getRel(Rel)->getType(); + break; + } + case ELF::SHT_RELA : { + type = getRela(Rel)->getType(); + break; + } + } + switch (Header->e_machine) { + case ELF::EM_X86_64: + switch (type) { + LLVM_ELF_SWITCH_RELOC_TYPE_NAME(R_X86_64_NONE); + LLVM_ELF_SWITCH_RELOC_TYPE_NAME(R_X86_64_64); + LLVM_ELF_SWITCH_RELOC_TYPE_NAME(R_X86_64_PC32); + LLVM_ELF_SWITCH_RELOC_TYPE_NAME(R_X86_64_GOT32); + LLVM_ELF_SWITCH_RELOC_TYPE_NAME(R_X86_64_PLT32); + LLVM_ELF_SWITCH_RELOC_TYPE_NAME(R_X86_64_COPY); + LLVM_ELF_SWITCH_RELOC_TYPE_NAME(R_X86_64_GLOB_DAT); + LLVM_ELF_SWITCH_RELOC_TYPE_NAME(R_X86_64_JUMP_SLOT); + LLVM_ELF_SWITCH_RELOC_TYPE_NAME(R_X86_64_RELATIVE); + LLVM_ELF_SWITCH_RELOC_TYPE_NAME(R_X86_64_GOTPCREL); + LLVM_ELF_SWITCH_RELOC_TYPE_NAME(R_X86_64_32); + LLVM_ELF_SWITCH_RELOC_TYPE_NAME(R_X86_64_32S); + LLVM_ELF_SWITCH_RELOC_TYPE_NAME(R_X86_64_16); + LLVM_ELF_SWITCH_RELOC_TYPE_NAME(R_X86_64_PC16); + LLVM_ELF_SWITCH_RELOC_TYPE_NAME(R_X86_64_8); + LLVM_ELF_SWITCH_RELOC_TYPE_NAME(R_X86_64_PC8); + LLVM_ELF_SWITCH_RELOC_TYPE_NAME(R_X86_64_DTPMOD64); + LLVM_ELF_SWITCH_RELOC_TYPE_NAME(R_X86_64_DTPOFF64); + LLVM_ELF_SWITCH_RELOC_TYPE_NAME(R_X86_64_TPOFF64); + LLVM_ELF_SWITCH_RELOC_TYPE_NAME(R_X86_64_TLSGD); + LLVM_ELF_SWITCH_RELOC_TYPE_NAME(R_X86_64_TLSLD); + LLVM_ELF_SWITCH_RELOC_TYPE_NAME(R_X86_64_DTPOFF32); + LLVM_ELF_SWITCH_RELOC_TYPE_NAME(R_X86_64_GOTTPOFF); + LLVM_ELF_SWITCH_RELOC_TYPE_NAME(R_X86_64_TPOFF32); + LLVM_ELF_SWITCH_RELOC_TYPE_NAME(R_X86_64_PC64); + LLVM_ELF_SWITCH_RELOC_TYPE_NAME(R_X86_64_GOTOFF64); + LLVM_ELF_SWITCH_RELOC_TYPE_NAME(R_X86_64_GOTPC32); + LLVM_ELF_SWITCH_RELOC_TYPE_NAME(R_X86_64_SIZE32); + LLVM_ELF_SWITCH_RELOC_TYPE_NAME(R_X86_64_SIZE64); + LLVM_ELF_SWITCH_RELOC_TYPE_NAME(R_X86_64_GOTPC32_TLSDESC); + LLVM_ELF_SWITCH_RELOC_TYPE_NAME(R_X86_64_TLSDESC_CALL); + LLVM_ELF_SWITCH_RELOC_TYPE_NAME(R_X86_64_TLSDESC); + default: + res = "Unknown"; + } + break; + case ELF::EM_386: + switch (type) { + LLVM_ELF_SWITCH_RELOC_TYPE_NAME(R_386_NONE); + LLVM_ELF_SWITCH_RELOC_TYPE_NAME(R_386_32); + LLVM_ELF_SWITCH_RELOC_TYPE_NAME(R_386_PC32); + LLVM_ELF_SWITCH_RELOC_TYPE_NAME(R_386_GOT32); + LLVM_ELF_SWITCH_RELOC_TYPE_NAME(R_386_PLT32); + LLVM_ELF_SWITCH_RELOC_TYPE_NAME(R_386_COPY); + LLVM_ELF_SWITCH_RELOC_TYPE_NAME(R_386_GLOB_DAT); + LLVM_ELF_SWITCH_RELOC_TYPE_NAME(R_386_JUMP_SLOT); + LLVM_ELF_SWITCH_RELOC_TYPE_NAME(R_386_RELATIVE); + LLVM_ELF_SWITCH_RELOC_TYPE_NAME(R_386_GOTOFF); + LLVM_ELF_SWITCH_RELOC_TYPE_NAME(R_386_GOTPC); + LLVM_ELF_SWITCH_RELOC_TYPE_NAME(R_386_32PLT); + LLVM_ELF_SWITCH_RELOC_TYPE_NAME(R_386_TLS_TPOFF); + LLVM_ELF_SWITCH_RELOC_TYPE_NAME(R_386_TLS_IE); + LLVM_ELF_SWITCH_RELOC_TYPE_NAME(R_386_TLS_GOTIE); + LLVM_ELF_SWITCH_RELOC_TYPE_NAME(R_386_TLS_LE); + LLVM_ELF_SWITCH_RELOC_TYPE_NAME(R_386_TLS_GD); + LLVM_ELF_SWITCH_RELOC_TYPE_NAME(R_386_TLS_LDM); + LLVM_ELF_SWITCH_RELOC_TYPE_NAME(R_386_16); + LLVM_ELF_SWITCH_RELOC_TYPE_NAME(R_386_PC16); + LLVM_ELF_SWITCH_RELOC_TYPE_NAME(R_386_8); + LLVM_ELF_SWITCH_RELOC_TYPE_NAME(R_386_PC8); + LLVM_ELF_SWITCH_RELOC_TYPE_NAME(R_386_TLS_GD_32); + LLVM_ELF_SWITCH_RELOC_TYPE_NAME(R_386_TLS_GD_PUSH); + LLVM_ELF_SWITCH_RELOC_TYPE_NAME(R_386_TLS_GD_CALL); + LLVM_ELF_SWITCH_RELOC_TYPE_NAME(R_386_TLS_GD_POP); + LLVM_ELF_SWITCH_RELOC_TYPE_NAME(R_386_TLS_LDM_32); + LLVM_ELF_SWITCH_RELOC_TYPE_NAME(R_386_TLS_LDM_PUSH); + LLVM_ELF_SWITCH_RELOC_TYPE_NAME(R_386_TLS_LDM_CALL); + LLVM_ELF_SWITCH_RELOC_TYPE_NAME(R_386_TLS_LDM_POP); + LLVM_ELF_SWITCH_RELOC_TYPE_NAME(R_386_TLS_LDO_32); + LLVM_ELF_SWITCH_RELOC_TYPE_NAME(R_386_TLS_IE_32); + LLVM_ELF_SWITCH_RELOC_TYPE_NAME(R_386_TLS_LE_32); + LLVM_ELF_SWITCH_RELOC_TYPE_NAME(R_386_TLS_DTPMOD32); + LLVM_ELF_SWITCH_RELOC_TYPE_NAME(R_386_TLS_DTPOFF32); + LLVM_ELF_SWITCH_RELOC_TYPE_NAME(R_386_TLS_TPOFF32); + LLVM_ELF_SWITCH_RELOC_TYPE_NAME(R_386_TLS_GOTDESC); + LLVM_ELF_SWITCH_RELOC_TYPE_NAME(R_386_TLS_DESC_CALL); + LLVM_ELF_SWITCH_RELOC_TYPE_NAME(R_386_TLS_DESC); + LLVM_ELF_SWITCH_RELOC_TYPE_NAME(R_386_IRELATIVE); + default: + res = "Unknown"; + } + break; + default: + res = "Unknown"; + } + Result.append(res.begin(), res.end()); + return object_error::success; +} + +#undef LLVM_ELF_SWITCH_RELOC_TYPE_NAME + template error_code ELFObjectFile ::getRelocationAdditionalInfo(DataRefImpl Rel, int64_t &Result) const { - const Elf_Shdr *sec = RelocationTableSections[Rel.d.b]; + const Elf_Shdr *sec = getSection(Rel.w.b); switch (sec->sh_type) { default : report_fatal_error("Invalid section type in Rel!"); @@ -825,7 +988,60 @@ } } - +template +error_code ELFObjectFile + ::getRelocationValueString(DataRefImpl Rel, + SmallVectorImpl &Result) const { + const Elf_Shdr *sec = getSection(Rel.w.b); + uint8_t type; + StringRef res; + int64_t addend = 0; + uint16_t symbol_index = 0; + switch (sec->sh_type) { + default : + return object_error::parse_failed; + case ELF::SHT_REL : { + type = getRel(Rel)->getType(); + symbol_index = getRel(Rel)->getSymbol(); + // TODO: Read implicit addend from section data. + break; + } + case ELF::SHT_RELA : { + type = getRela(Rel)->getType(); + symbol_index = getRela(Rel)->getSymbol(); + addend = getRela(Rel)->r_addend; + break; + } + } + const Elf_Sym *symb = getEntry(sec->sh_link, symbol_index); + StringRef symname; + if (error_code ec = getSymbolName(symb, symname)) + return ec; + switch (Header->e_machine) { + case ELF::EM_X86_64: + switch (type) { + case ELF::R_X86_64_32S: + res = symname; + break; + case ELF::R_X86_64_PC32: { + std::string fmtbuf; + raw_string_ostream fmt(fmtbuf); + fmt << symname << (addend < 0 ? "" : "+") << addend << "-P"; + fmt.flush(); + Result.append(fmtbuf.begin(), fmtbuf.end()); + } + break; + default: + res = "Unknown"; + } + break; + default: + res = "Unknown"; + } + if (Result.empty()) + Result.append(res.begin(), res.end()); + return object_error::success; +} template ELFObjectFile::ELFObjectFile(MemoryBuffer *Object @@ -849,19 +1065,24 @@ // To find the symbol tables we walk the section table to find SHT_STMTAB. - const Elf_Shdr* sh = - reinterpret_cast(SectionHeaderTable); + const Elf_Shdr* sh = reinterpret_cast(SectionHeaderTable); for (unsigned i = 0; i < Header->e_shnum; ++i) { if (sh->sh_type == ELF::SHT_SYMTAB) { SymbolTableSectionsIndexMap[i] = SymbolTableSections.size(); SymbolTableSections.push_back(sh); } if (sh->sh_type == ELF::SHT_REL || sh->sh_type == ELF::SHT_RELA) { - RelocationTableSections.push_back(sh); + SectionRelocMap[getSection(sh->sh_link)].push_back(i); } ++sh; } + // Sort section relocation lists by index. + for (typename RelocMap_t::iterator i = SectionRelocMap.begin(), + e = SectionRelocMap.end(); i != e; ++i) { + std::sort(i->second.begin(), i->second.end()); + } + // Get string table sections. dot_shstrtab_sec = getSection(Header->e_shstrndx); if (dot_shstrtab_sec) { @@ -894,8 +1115,8 @@ } template -ObjectFile::symbol_iterator ELFObjectFile - ::begin_symbols() const { +symbol_iterator ELFObjectFile + ::begin_symbols() const { DataRefImpl SymbolData; memset(&SymbolData, 0, sizeof(SymbolData)); if (SymbolTableSections.size() == 0) { @@ -909,8 +1130,8 @@ } template -ObjectFile::symbol_iterator ELFObjectFile - ::end_symbols() const { +symbol_iterator ELFObjectFile + ::end_symbols() const { DataRefImpl SymbolData; memset(&SymbolData, 0, sizeof(SymbolData)); SymbolData.d.a = std::numeric_limits::max(); @@ -919,8 +1140,8 @@ } template -ObjectFile::section_iterator ELFObjectFile - ::begin_sections() const { +section_iterator ELFObjectFile + ::begin_sections() const { DataRefImpl ret; memset(&ret, 0, sizeof(DataRefImpl)); ret.p = reinterpret_cast(base() + Header->e_shoff); @@ -928,8 +1149,8 @@ } template -ObjectFile::section_iterator ELFObjectFile - ::end_sections() const { +section_iterator ELFObjectFile + ::end_sections() const { DataRefImpl ret; memset(&ret, 0, sizeof(DataRefImpl)); ret.p = reinterpret_cast(base() @@ -939,31 +1160,6 @@ } template -ObjectFile::relocation_iterator ELFObjectFile - ::begin_relocations() const { - DataRefImpl RelData; - memset(&RelData, 0, sizeof(RelData)); - if (RelocationTableSections.size() == 0) { - RelData.d.a = std::numeric_limits::max(); - RelData.d.b = std::numeric_limits::max(); - } else { - RelData.d.a = 0; - RelData.d.b = 0; - } - return relocation_iterator(RelocationRef(RelData, this)); -} - -template -ObjectFile::relocation_iterator ELFObjectFile - ::end_relocations() const { - DataRefImpl RelData; - memset(&RelData, 0, sizeof(RelData)); - RelData.d.a = std::numeric_limits::max(); - RelData.d.b = std::numeric_limits::max(); - return relocation_iterator(RelocationRef(RelData, this)); -} - -template uint8_t ELFObjectFile::getBytesInAddress() const { return is64Bits ? 8 : 4; } @@ -1012,41 +1208,49 @@ } } + template template inline const T * -ELFObjectFile::getEntry(DataRefImpl Entry, - Sections_t Sections) const { - const Elf_Shdr *sec = Sections[Entry.d.b]; +ELFObjectFile::getEntry(uint16_t Section, + uint32_t Entry) const { + return getEntry(getSection(Section), Entry); +} + +template +template +inline const T * +ELFObjectFile::getEntry(const Elf_Shdr * Section, + uint32_t Entry) const { return reinterpret_cast( base() - + sec->sh_offset - + (Entry.d.a * sec->sh_entsize)); + + Section->sh_offset + + (Entry * Section->sh_entsize)); } template const typename ELFObjectFile::Elf_Sym * ELFObjectFile::getSymbol(DataRefImpl Symb) const { - return getEntry(Symb, SymbolTableSections); + return getEntry(SymbolTableSections[Symb.d.b], Symb.d.a); } template const typename ELFObjectFile::Elf_Rel * ELFObjectFile::getRel(DataRefImpl Rel) const { - return getEntry(Rel, RelocationTableSections); + return getEntry(Rel.w.b, Rel.w.c); } template const typename ELFObjectFile::Elf_Rela * ELFObjectFile::getRela(DataRefImpl Rela) const { - return getEntry(Rela, RelocationTableSections); + return getEntry(Rela.w.b, Rela.w.c); } template const typename ELFObjectFile::Elf_Shdr * ELFObjectFile::getSection(DataRefImpl Symb) const { const Elf_Shdr *sec = getSection(Symb.d.b); - if (sec->sh_type != ELF::SHT_SYMTAB) + if (sec->sh_type != ELF::SHT_SYMTAB || sec->sh_type != ELF::SHT_DYNSYM) // FIXME: Proper error handling. report_fatal_error("Invalid symbol table section!"); return sec; @@ -1084,6 +1288,24 @@ return (const char *)base() + section->sh_offset + offset; } +template +error_code ELFObjectFile + ::getSymbolName(const Elf_Sym *symb, + StringRef &Result) const { + if (symb->st_name == 0) { + const Elf_Shdr *section = getSection(symb->st_shndx); + if (!section) + Result = ""; + else + Result = getString(dot_shstrtab_sec, section->sh_name); + return object_error::success; + } + + // Use the default symbol table name section. + Result = getString(dot_strtab_sec, symb->st_name); + return object_error::success; +} + // EI_CLASS, EI_DATA. static std::pair getElfArchType(MemoryBuffer *Object) { Modified: llvm/trunk/lib/Object/MachOObjectFile.cpp URL: http://llvm.org/viewvc/llvm-project/llvm/trunk/lib/Object/MachOObjectFile.cpp?rev=141385&r1=141384&r2=141385&view=diff ============================================================================== --- llvm/trunk/lib/Object/MachOObjectFile.cpp (original) +++ llvm/trunk/lib/Object/MachOObjectFile.cpp Fri Oct 7 14:25:32 2011 @@ -39,8 +39,6 @@ virtual symbol_iterator end_symbols() const; virtual section_iterator begin_sections() const; virtual section_iterator end_sections() const; - virtual relocation_iterator begin_relocations() const; - virtual relocation_iterator end_relocations() const; virtual uint8_t getBytesInAddress() const; virtual StringRef getFileFormatName() const; @@ -67,6 +65,8 @@ virtual error_code isSectionBSS(DataRefImpl Sec, bool &Res) const; virtual error_code sectionContainsSymbol(DataRefImpl DRI, DataRefImpl S, bool &Result) const; + virtual relocation_iterator getSectionRelBegin(DataRefImpl Sec) const; + virtual relocation_iterator getSectionRelEnd(DataRefImpl Sec) const; virtual error_code getRelocationNext(DataRefImpl Rel, RelocationRef &Res) const; @@ -76,8 +76,13 @@ SymbolRef &Res) const; virtual error_code getRelocationType(DataRefImpl Rel, uint32_t &Res) const; + virtual error_code getRelocationTypeName(DataRefImpl Rel, + SmallVectorImpl &Result) const; virtual error_code getRelocationAdditionalInfo(DataRefImpl Rel, int64_t &Res) const; + virtual error_code getRelocationValueString(DataRefImpl Rel, + SmallVectorImpl &Result) const; + private: MachOObject *MachOObj; mutable uint32_t RegisteredStringTable; @@ -96,6 +101,7 @@ InMemoryStruct &Res) const; void getRelocation(DataRefImpl Rel, InMemoryStruct &Res) const; + std::size_t getSectionIndex(DataRefImpl Sec) const; }; MachOObjectFile::MachOObjectFile(MemoryBuffer *Object, MachOObject *MOO, @@ -324,7 +330,7 @@ } -ObjectFile::symbol_iterator MachOObjectFile::begin_symbols() const { +symbol_iterator MachOObjectFile::begin_symbols() const { // DRI.d.a = segment number; DRI.d.b = symbol index. DataRefImpl DRI; DRI.d.a = DRI.d.b = 0; @@ -332,7 +338,7 @@ return symbol_iterator(SymbolRef(DRI, this)); } -ObjectFile::symbol_iterator MachOObjectFile::end_symbols() const { +symbol_iterator MachOObjectFile::end_symbols() const { DataRefImpl DRI; DRI.d.a = MachOObj->getHeader().NumLoadCommands; DRI.d.b = 0; @@ -380,6 +386,13 @@ MachOObj->ReadSection(LCI, DRI.d.b, Res); } +std::size_t MachOObjectFile::getSectionIndex(DataRefImpl Sec) const { + SectionList::const_iterator loc = + std::find(Sections.begin(), Sections.end(), Sec); + assert(loc != Sections.end() && "Sec is not a valid section!"); + return std::distance(Sections.begin(), loc); +} + void MachOObjectFile::getSection64(DataRefImpl DRI, InMemoryStruct &Res) const { @@ -511,14 +524,37 @@ return object_error::success; } -ObjectFile::section_iterator MachOObjectFile::begin_sections() const { +relocation_iterator MachOObjectFile::getSectionRelBegin(DataRefImpl Sec) const { + DataRefImpl ret; + ret.d.a = 0; + ret.d.b = getSectionIndex(Sec); + return relocation_iterator(RelocationRef(ret, this)); +} +relocation_iterator MachOObjectFile::getSectionRelEnd(DataRefImpl Sec) const { + uint32_t last_reloc; + if (is64BitLoadCommand(MachOObj, Sec)) { + InMemoryStruct Sect; + getSection64(Sec, Sect); + last_reloc = Sect->NumRelocationTableEntries; + } else { + InMemoryStruct Sect; + getSection(Sec, Sect); + last_reloc = Sect->NumRelocationTableEntries; + } + DataRefImpl ret; + ret.d.a = last_reloc; + ret.d.b = getSectionIndex(Sec); + return relocation_iterator(RelocationRef(ret, this)); +} + +section_iterator MachOObjectFile::begin_sections() const { DataRefImpl DRI; DRI.d.a = DRI.d.b = 0; moveToNextSection(DRI); return section_iterator(SectionRef(DRI, this)); } -ObjectFile::section_iterator MachOObjectFile::end_sections() const { +section_iterator MachOObjectFile::end_sections() const { DataRefImpl DRI; DRI.d.a = MachOObj->getHeader().NumLoadCommands; DRI.d.b = 0; @@ -545,23 +581,6 @@ error_code MachOObjectFile::getRelocationNext(DataRefImpl Rel, RelocationRef &Res) const { ++Rel.d.a; - while (Rel.d.b < Sections.size()) { - unsigned relocationCount; - if (MachOObj->is64Bit()) { - InMemoryStruct Sect; - getSection64(Sections[Rel.d.b], Sect); - relocationCount = Sect->NumRelocationTableEntries; - } else { - InMemoryStruct Sect; - getSection(Sections[Rel.d.b], Sect); - relocationCount = Sect->NumRelocationTableEntries; - } - if (Rel.d.a < relocationCount) - break; - - Rel.d.a = 0; - ++Rel.d.b; - } Res = RelocationRef(Rel, this); return object_error::success; } @@ -610,6 +629,10 @@ Res = RE->Word1; return object_error::success; } +error_code MachOObjectFile::getRelocationTypeName(DataRefImpl Rel, + SmallVectorImpl &Result) const { + return object_error::success; +} error_code MachOObjectFile::getRelocationAdditionalInfo(DataRefImpl Rel, int64_t &Res) const { InMemoryStruct RE; @@ -631,16 +654,9 @@ } return object_error::success; } -ObjectFile::relocation_iterator MachOObjectFile::begin_relocations() const { - DataRefImpl ret; - ret.d.a = ret.d.b = 0; - return relocation_iterator(RelocationRef(ret, this)); -} -ObjectFile::relocation_iterator MachOObjectFile::end_relocations() const { - DataRefImpl ret; - ret.d.a = 0; - ret.d.b = Sections.size(); - return relocation_iterator(RelocationRef(ret, this)); +error_code MachOObjectFile::getRelocationValueString(DataRefImpl Rel, + SmallVectorImpl &Result) const { + return object_error::success; } /*===-- Miscellaneous -----------------------------------------------------===*/ Modified: llvm/trunk/lib/Object/Object.cpp URL: http://llvm.org/viewvc/llvm-project/llvm/trunk/lib/Object/Object.cpp?rev=141385&r1=141384&r2=141385&view=diff ============================================================================== --- llvm/trunk/lib/Object/Object.cpp (original) +++ llvm/trunk/lib/Object/Object.cpp Fri Oct 7 14:25:32 2011 @@ -27,8 +27,8 @@ } LLVMSectionIteratorRef LLVMGetSections(LLVMObjectFileRef ObjectFile) { - ObjectFile::section_iterator SI = unwrap(ObjectFile)->begin_sections(); - return wrap(new ObjectFile::section_iterator(SI)); + section_iterator SI = unwrap(ObjectFile)->begin_sections(); + return wrap(new section_iterator(SI)); } void LLVMDisposeSectionIterator(LLVMSectionIteratorRef SI) { Modified: llvm/trunk/tools/llvm-objdump/llvm-objdump.cpp URL: http://llvm.org/viewvc/llvm-project/llvm/trunk/tools/llvm-objdump/llvm-objdump.cpp?rev=141385&r1=141384&r2=141385&view=diff ============================================================================== --- llvm/trunk/tools/llvm-objdump/llvm-objdump.cpp (original) +++ llvm/trunk/tools/llvm-objdump/llvm-objdump.cpp Fri Oct 7 14:25:32 2011 @@ -155,7 +155,7 @@ << ":\tfile format " << Obj->getFileFormatName() << "\n\n"; error_code ec; - for (ObjectFile::section_iterator i = Obj->begin_sections(), + for (section_iterator i = Obj->begin_sections(), e = Obj->end_sections(); i != e; i.increment(ec)) { if (error(ec)) break; @@ -165,7 +165,7 @@ // Make a list of all the symbols in this section. std::vector > Symbols; - for (ObjectFile::symbol_iterator si = Obj->begin_symbols(), + for (symbol_iterator si = Obj->begin_symbols(), se = Obj->end_symbols(); si != se; si.increment(ec)) { bool contains; From bigcheesegs at gmail.com Fri Oct 7 14:25:47 2011 From: bigcheesegs at gmail.com (Michael J. Spencer) Date: Fri, 07 Oct 2011 19:25:47 -0000 Subject: [llvm-commits] [llvm] r141386 - /llvm/trunk/tools/llvm-objdump/MachODump.cpp Message-ID: <20111007192547.7AFD8312800A@llvm.org> Author: mspencer Date: Fri Oct 7 14:25:47 2011 New Revision: 141386 URL: http://llvm.org/viewvc/llvm-project?rev=141386&view=rev Log: Fix spelling in comment. Modified: llvm/trunk/tools/llvm-objdump/MachODump.cpp Modified: llvm/trunk/tools/llvm-objdump/MachODump.cpp URL: http://llvm.org/viewvc/llvm-project/llvm/trunk/tools/llvm-objdump/MachODump.cpp?rev=141386&r1=141385&r2=141386&view=diff ============================================================================== --- llvm/trunk/tools/llvm-objdump/MachODump.cpp (original) +++ llvm/trunk/tools/llvm-objdump/MachODump.cpp Fri Oct 7 14:25:47 2011 @@ -122,7 +122,7 @@ return S; } -// Print addtitional information about an address, if available. +// Print additional information about an address, if available. static void DumpAddress(uint64_t Address, ArrayRef
Sections, MachOObject *MachOObj, raw_ostream &OS) { for (unsigned i = 0; i != Sections.size(); ++i) { @@ -298,7 +298,7 @@ AsmPrinterVariant, *AsmInfo, *STI)); if (!InstrAnalysis || !AsmInfo || !STI || !DisAsm || !IP) { - errs() << "error: couldn't initialize disassmbler for target " + errs() << "error: couldn't initialize disassembler for target " << TripleName << '\n'; return; } @@ -573,7 +573,7 @@ IP->printInst(&Inst.Inst, outs(), ""); // Look for relocations inside this instructions, if there is one - // print its target and additional information if availbable. + // print its target and additional information if available. for (unsigned j = 0; j != Relocs.size(); ++j) if (Relocs[j].first >= Sections[SectIdx].Address + Inst.Address && Relocs[j].first < Sections[SectIdx].Address + Inst.Address + From criswell at uiuc.edu Fri Oct 7 14:37:14 2011 From: criswell at uiuc.edu (John Criswell) Date: Fri, 07 Oct 2011 19:37:14 -0000 Subject: [llvm-commits] [poolalloc] r141388 - /poolalloc/trunk/lib/DSA/Local.cpp Message-ID: <20111007193714.8201F312800A@llvm.org> Author: criswell Date: Fri Oct 7 14:37:14 2011 New Revision: 141388 URL: http://llvm.org/viewvc/llvm-project?rev=141388&view=rev Log: Added support for the new atomicrmw instruction. Fixed a misspelling in a comment. Modified: poolalloc/trunk/lib/DSA/Local.cpp Modified: poolalloc/trunk/lib/DSA/Local.cpp URL: http://llvm.org/viewvc/llvm-project/poolalloc/trunk/lib/DSA/Local.cpp?rev=141388&r1=141387&r2=141388&view=diff ============================================================================== --- poolalloc/trunk/lib/DSA/Local.cpp (original) +++ poolalloc/trunk/lib/DSA/Local.cpp Fri Oct 7 14:37:14 2011 @@ -118,6 +118,7 @@ void visitSelectInst(SelectInst &SI); void visitLoadInst(LoadInst &LI); void visitStoreInst(StoreInst &SI); + void visitAtomicRMWInst(AtomicRMWInst &I); void visitReturnInst(ReturnInst &RI); void visitVAArgInst(VAArgInst &I); void visitIntToPtrInst(IntToPtrInst &I); @@ -363,7 +364,7 @@ void GraphBuilder::visitLoadInst(LoadInst &LI) { // - // Create a DSNode for the poiner dereferenced by the load. If the DSNode + // Create a DSNode for the pointer dereferenced by the load. If the DSNode // is NULL, do nothing more (this can occur if the load is loading from a // NULL pointer constant (bugpoint can generate such code). // @@ -414,6 +415,30 @@ Dest.getNode()->mergeTypeInfo(StoredTy, Dest.getOffset()); } +void GraphBuilder::visitAtomicRMWInst(AtomicRMWInst &I) { + // + // Create a DSNode for the dereferenced pointer . If the DSNode is NULL, do + // nothing more (this can occur if the pointer is a NULL constant; bugpoint + // can generate such code). + // + DSNodeHandle Ptr = getValueDest(I.getPointerOperand()); + if (Ptr.isNull()) return; + + // + // Make that the memory object is read and written. + // + Ptr.getNode()->setReadMarker(); + Ptr.getNode()->setModifiedMarker(); + + // + // Modify the DSNode so that it has the loaded/written type at the + // appropriate offset. + // + Ptr.getNode()->growSizeForType(I.getType(), Ptr.getOffset()); + Ptr.getNode()->mergeTypeInfo(I.getType(), Ptr.getOffset()); + return; +} + void GraphBuilder::visitReturnInst(ReturnInst &RI) { if (RI.getNumOperands() && isa(RI.getOperand(0)->getType())) G.getOrCreateReturnNodeFor(*FB).mergeWith(getValueDest(RI.getOperand(0))); From bigcheesegs at gmail.com Fri Oct 7 14:46:13 2011 From: bigcheesegs at gmail.com (Michael J. Spencer) Date: Fri, 07 Oct 2011 19:46:13 -0000 Subject: [llvm-commits] [llvm] r141389 - in /llvm/trunk: lib/Object/ELFObjectFile.cpp tools/llvm-nm/llvm-nm.cpp Message-ID: <20111007194613.1ED87312800A@llvm.org> Author: mspencer Date: Fri Oct 7 14:46:12 2011 New Revision: 141389 URL: http://llvm.org/viewvc/llvm-project?rev=141389&view=rev Log: Fix GCC again. Modified: llvm/trunk/lib/Object/ELFObjectFile.cpp llvm/trunk/tools/llvm-nm/llvm-nm.cpp Modified: llvm/trunk/lib/Object/ELFObjectFile.cpp URL: http://llvm.org/viewvc/llvm-project/llvm/trunk/lib/Object/ELFObjectFile.cpp?rev=141389&r1=141388&r2=141389&view=diff ============================================================================== --- llvm/trunk/lib/Object/ELFObjectFile.cpp (original) +++ llvm/trunk/lib/Object/ELFObjectFile.cpp Fri Oct 7 14:46:12 2011 @@ -762,7 +762,7 @@ if (Rel.w.c >= (relocsec->sh_size / relocsec->sh_entsize)) { // We have reached the end of the relocations for this section. See if there // is another relocation section. - typename RelocMap_t::mapped_type &relocseclist = + typename RelocMap_t::mapped_type relocseclist = SectionRelocMap.lookup(getSection(Rel.w.a)); // Do a binary search for the current reloc section index (which must be Modified: llvm/trunk/tools/llvm-nm/llvm-nm.cpp URL: http://llvm.org/viewvc/llvm-project/llvm/trunk/tools/llvm-nm/llvm-nm.cpp?rev=141389&r1=141388&r2=141389&view=diff ============================================================================== --- llvm/trunk/tools/llvm-nm/llvm-nm.cpp (original) +++ llvm/trunk/tools/llvm-nm/llvm-nm.cpp Fri Oct 7 14:46:12 2011 @@ -271,9 +271,9 @@ static void DumpSymbolNamesFromObject(ObjectFile *obj) { error_code ec; - for (ObjectFile::symbol_iterator i = obj->begin_symbols(), - e = obj->end_symbols(); - i != e; i.increment(ec)) { + for (symbol_iterator i = obj->begin_symbols(), + e = obj->end_symbols(); + i != e; i.increment(ec)) { if (error(ec)) break; bool internal; if (error(i->isInternal(internal))) break; From bigcheesegs at gmail.com Fri Oct 7 14:52:41 2011 From: bigcheesegs at gmail.com (Michael J. Spencer) Date: Fri, 07 Oct 2011 19:52:41 -0000 Subject: [llvm-commits] [llvm] r141392 - in /llvm/trunk/tools: llvm-dwarfdump/llvm-dwarfdump.cpp llvm-size/llvm-size.cpp Message-ID: <20111007195242.0A22C312800A@llvm.org> Author: mspencer Date: Fri Oct 7 14:52:41 2011 New Revision: 141392 URL: http://llvm.org/viewvc/llvm-project?rev=141392&view=rev Log: Fix a few changes I missed. Modified: llvm/trunk/tools/llvm-dwarfdump/llvm-dwarfdump.cpp llvm/trunk/tools/llvm-size/llvm-size.cpp Modified: llvm/trunk/tools/llvm-dwarfdump/llvm-dwarfdump.cpp URL: http://llvm.org/viewvc/llvm-project/llvm/trunk/tools/llvm-dwarfdump/llvm-dwarfdump.cpp?rev=141392&r1=141391&r2=141392&view=diff ============================================================================== --- llvm/trunk/tools/llvm-dwarfdump/llvm-dwarfdump.cpp (original) +++ llvm/trunk/tools/llvm-dwarfdump/llvm-dwarfdump.cpp Fri Oct 7 14:52:41 2011 @@ -56,9 +56,9 @@ StringRef DebugStringSection; error_code ec; - for (ObjectFile::section_iterator i = Obj->begin_sections(), - e = Obj->end_sections(); - i != e; i.increment(ec)) { + for (section_iterator i = Obj->begin_sections(), + e = Obj->end_sections(); + i != e; i.increment(ec)) { StringRef name; i->getName(name); StringRef data; Modified: llvm/trunk/tools/llvm-size/llvm-size.cpp URL: http://llvm.org/viewvc/llvm-project/llvm/trunk/tools/llvm-size/llvm-size.cpp?rev=141392&r1=141391&r2=141392&view=diff ============================================================================== --- llvm/trunk/tools/llvm-size/llvm-size.cpp (original) +++ llvm/trunk/tools/llvm-size/llvm-size.cpp Fri Oct 7 14:52:41 2011 @@ -112,9 +112,9 @@ std::size_t max_size_len = strlen("size"); std::size_t max_addr_len = strlen("addr"); error_code ec; - for (ObjectFile::section_iterator i = o->begin_sections(), - e = o->end_sections(); i != e; - i.increment(ec)) { + for (section_iterator i = o->begin_sections(), + e = o->end_sections(); i != e; + i.increment(ec)) { if (error(ec)) return; uint64_t size = 0; @@ -154,9 +154,9 @@ << "%#" << max_addr_len << radix_fmt << "\n"; // Print each section. - for (ObjectFile::section_iterator i = o->begin_sections(), - e = o->end_sections(); i != e; - i.increment(ec)) { + for (section_iterator i = o->begin_sections(), + e = o->end_sections(); i != e; + i.increment(ec)) { if (error(ec)) return; @@ -190,9 +190,9 @@ // Make one pass over the section table to calculate sizes. error_code ec; - for (ObjectFile::section_iterator i = o->begin_sections(), - e = o->end_sections(); i != e; - i.increment(ec)) { + for (section_iterator i = o->begin_sections(), + e = o->end_sections(); i != e; + i.increment(ec)) { if (error(ec)) return; From daniel at zuster.org Fri Oct 7 14:54:42 2011 From: daniel at zuster.org (Daniel Dunbar) Date: Fri, 07 Oct 2011 19:54:42 -0000 Subject: [llvm-commits] [zorg] r141393 - in /zorg/trunk/zorg/llvmlab: ./ __init__.py Message-ID: <20111007195442.B6CE4312800A@llvm.org> Author: ddunbar Date: Fri Oct 7 14:54:42 2011 New Revision: 141393 URL: http://llvm.org/viewvc/llvm-project?rev=141393&view=rev Log: llvmlab: Stub out dummy llvmlab plugin for the lab.llvm.org installation. - Won't work yet because we haven't moved that config over to using the "phase_config" description objects. Added: zorg/trunk/zorg/llvmlab/ zorg/trunk/zorg/llvmlab/__init__.py Added: zorg/trunk/zorg/llvmlab/__init__.py URL: http://llvm.org/viewvc/llvm-project/zorg/trunk/zorg/llvmlab/__init__.py?rev=141393&view=auto ============================================================================== --- zorg/trunk/zorg/llvmlab/__init__.py (added) +++ zorg/trunk/zorg/llvmlab/__init__.py Fri Oct 7 14:54:42 2011 @@ -0,0 +1,55 @@ +""" +lab.llvm.org site specific customizations for the LLVM Lab web app. +""" + +import os +import sys + +# Allow direct import of the master configuration files. +g_master_dir = os.path.join(os.path.dirname(__file__), + "..", "..", "buildbot", "llvmlab", "master") +if g_master_dir not in sys.path: + sys.path.append(g_master_dir) +try: + from config import phase_config +except: + # FIXME: Remove this once actual phase_config object is in place. + class DummyConfig: + phases = [] + phase_config = DummyConfig() + +import llvmlab.ci.config +import llvmlab.ci.summary + +def construct_config(): + phases = [] + builders = [] + published_builds = [] + + # Add hard coded builders. + builders.append(llvmlab.ci.config.Builder("Validated Build")) + + for phase in phase_config.phases: + # Add the phase object. + phase_builder = "phase%d - %s" % (phase['number'], phase['name']) + phases.append(llvmlab.ci.config.Phase( + phase['title'], phase['number'], phase_builder, + [b['name'] for b in phase['builders']], + phase['description'])) + + # Add the builder objects. + builders.append(llvmlab.ci.config.Builder(phase_builder)) + for b in phase['builders']: + builders.append(llvmlab.ci.config.Builder(b['name'])) + + return llvmlab.ci.config.Config(phases, builders, published_builds, + "Validated Build") + +def register(app): + # Construct the LLVM Lab dashboard configuration object directly from the + # buildbot phase_config module. + config = construct_config() + app.config.summary = llvmlab.ci.summary.Summary( + config, app.config.status) + + print >>sys.stderr, "note: loaded lab.llvm.org extensions" From daniel at zuster.org Fri Oct 7 14:54:46 2011 From: daniel at zuster.org (Daniel Dunbar) Date: Fri, 07 Oct 2011 19:54:46 -0000 Subject: [llvm-commits] [zorg] r141394 - in /zorg/trunk/llvmlab/docs: ./ Makefile README.txt _templates/ _templates/index.html _templates/indexsidebar.html _templates/layout.html conf.py contents.rst intro.rst make.bat Message-ID: <20111007195446.7D7032A6C12D@llvm.org> Author: ddunbar Date: Fri Oct 7 14:54:46 2011 New Revision: 141394 URL: http://llvm.org/viewvc/llvm-project?rev=141394&view=rev Log: llvmlab: Stub out some simple Sphinx documentation structure. Added: zorg/trunk/llvmlab/docs/ zorg/trunk/llvmlab/docs/Makefile zorg/trunk/llvmlab/docs/README.txt zorg/trunk/llvmlab/docs/_templates/ zorg/trunk/llvmlab/docs/_templates/index.html zorg/trunk/llvmlab/docs/_templates/indexsidebar.html zorg/trunk/llvmlab/docs/_templates/layout.html zorg/trunk/llvmlab/docs/conf.py zorg/trunk/llvmlab/docs/contents.rst zorg/trunk/llvmlab/docs/intro.rst zorg/trunk/llvmlab/docs/make.bat Added: zorg/trunk/llvmlab/docs/Makefile URL: http://llvm.org/viewvc/llvm-project/zorg/trunk/llvmlab/docs/Makefile?rev=141394&view=auto ============================================================================== --- zorg/trunk/llvmlab/docs/Makefile (added) +++ zorg/trunk/llvmlab/docs/Makefile Fri Oct 7 14:54:46 2011 @@ -0,0 +1,120 @@ +# Makefile for Sphinx documentation +# + +# You can set these variables from the command line. +SPHINXOPTS = +SPHINXBUILD = sphinx-build +PAPER = +BUILDDIR = _build + +# Internal variables. +PAPEROPT_a4 = -D latex_paper_size=a4 +PAPEROPT_letter = -D latex_paper_size=letter +ALLSPHINXOPTS = -d $(BUILDDIR)/doctrees $(PAPEROPT_$(PAPER)) $(SPHINXOPTS) . + +.PHONY: help clean html dirhtml singlehtml pickle json htmlhelp qthelp epub latex changes linkcheck doctest + +all: html + +help: + @echo "Please use \`make ' where is one of" + @echo " html to make standalone HTML files" + @echo " dirhtml to make HTML files named index.html in directories" + @echo " singlehtml to make a single large HTML file" + @echo " pickle to make pickle files" + @echo " json to make JSON files" + @echo " htmlhelp to make HTML files and a HTML help project" + @echo " qthelp to make HTML files and a qthelp project" + @echo " devhelp to make HTML files and a Devhelp project" + @echo " epub to make an epub" + @echo " latex to make LaTeX files, you can set PAPER=a4 or PAPER=letter" + @echo " latexpdf to make LaTeX files and run them through pdflatex" + @echo " changes to make an overview of all changed/added/deprecated items" + @echo " linkcheck to check all external links for integrity" + @echo " doctest to run all doctests embedded in the documentation (if enabled)" + +clean: + -rm -rf $(BUILDDIR)/* + +html: + $(SPHINXBUILD) -b html $(ALLSPHINXOPTS) $(BUILDDIR)/html + @echo + @echo "Build finished. The HTML pages are in $(BUILDDIR)/html." + +dirhtml: + $(SPHINXBUILD) -b dirhtml $(ALLSPHINXOPTS) $(BUILDDIR)/dirhtml + @echo + @echo "Build finished. The HTML pages are in $(BUILDDIR)/dirhtml." + +singlehtml: + $(SPHINXBUILD) -b singlehtml $(ALLSPHINXOPTS) $(BUILDDIR)/singlehtml + @echo + @echo "Build finished. The HTML page is in $(BUILDDIR)/singlehtml." + +pickle: + $(SPHINXBUILD) -b pickle $(ALLSPHINXOPTS) $(BUILDDIR)/pickle + @echo + @echo "Build finished; now you can process the pickle files." + +json: + $(SPHINXBUILD) -b json $(ALLSPHINXOPTS) $(BUILDDIR)/json + @echo + @echo "Build finished; now you can process the JSON files." + +htmlhelp: + $(SPHINXBUILD) -b htmlhelp $(ALLSPHINXOPTS) $(BUILDDIR)/htmlhelp + @echo + @echo "Build finished; now you can run HTML Help Workshop with the" \ + ".hhp project file in $(BUILDDIR)/htmlhelp." + +qthelp: + $(SPHINXBUILD) -b qthelp $(ALLSPHINXOPTS) $(BUILDDIR)/qthelp + @echo + @echo "Build finished; now you can run "qcollectiongenerator" with the" \ + ".qhcp project file in $(BUILDDIR)/qthelp, like this:" + @echo "# qcollectiongenerator $(BUILDDIR)/qthelp/LNT.qhcp" + @echo "To view the help file:" + @echo "# assistant -collectionFile $(BUILDDIR)/qthelp/LNT.qhc" + +devhelp: + $(SPHINXBUILD) -b devhelp $(ALLSPHINXOPTS) _build/devhelp + @echo + @echo "Build finished." + @echo "To view the help file:" + @echo "# mkdir -p $$HOME/.local/share/devhelp/LNT" + @echo "# ln -s _build/devhelp $$HOME/.local/share/devhelp/LNT" + @echo "# devhelp" + +epub: + $(SPHINXBUILD) -b epub $(ALLSPHINXOPTS) $(BUILDDIR)/epub + @echo + @echo "Build finished. The epub file is in $(BUILDDIR)/epub." + +latex: + $(SPHINXBUILD) -b latex $(ALLSPHINXOPTS) $(BUILDDIR)/latex + @echo + @echo "Build finished; the LaTeX files are in $(BUILDDIR)/latex." + @echo "Run \`make all-pdf' or \`make all-ps' in that directory to" \ + "run these through (pdf)latex." + +latexpdf: latex + $(SPHINXBUILD) -b latex $(ALLSPHINXOPTS) _build/latex + @echo "Running LaTeX files through pdflatex..." + make -C _build/latex all-pdf + @echo "pdflatex finished; the PDF files are in _build/latex." + +changes: + $(SPHINXBUILD) -b changes $(ALLSPHINXOPTS) $(BUILDDIR)/changes + @echo + @echo "The overview file is in $(BUILDDIR)/changes." + +linkcheck: + $(SPHINXBUILD) -b linkcheck $(ALLSPHINXOPTS) $(BUILDDIR)/linkcheck + @echo + @echo "Link check complete; look for any errors in the above output " \ + "or in $(BUILDDIR)/linkcheck/output.txt." + +doctest: + $(SPHINXBUILD) -b doctest $(ALLSPHINXOPTS) $(BUILDDIR)/doctest + @echo "Testing of doctests in the sources finished, look at the " \ + "results in $(BUILDDIR)/doctest/output.txt." Added: zorg/trunk/llvmlab/docs/README.txt URL: http://llvm.org/viewvc/llvm-project/zorg/trunk/llvmlab/docs/README.txt?rev=141394&view=auto ============================================================================== --- zorg/trunk/llvmlab/docs/README.txt (added) +++ zorg/trunk/llvmlab/docs/README.txt Fri Oct 7 14:54:46 2011 @@ -0,0 +1,7 @@ +llvmlab Documentation +===================== + +The llvmlab documentation is written using the Sphinx documentation generator. It is +currently tested with Sphinx 1.0dev. + +We currently use the 'nature' theme and a Beaker inspired structure. Added: zorg/trunk/llvmlab/docs/_templates/index.html URL: http://llvm.org/viewvc/llvm-project/zorg/trunk/llvmlab/docs/_templates/index.html?rev=141394&view=auto ============================================================================== --- zorg/trunk/llvmlab/docs/_templates/index.html (added) +++ zorg/trunk/llvmlab/docs/_templates/index.html Fri Oct 7 14:54:46 2011 @@ -0,0 +1,37 @@ +{% extends "layout.html" %} +{% set title = 'llvmlab' %} +{% block body %} +

llvmlab - LLVM Dashboard

+ +

+ llvmlab is a dashboard for the LLVM project. + + This is the web page for the llvmlab software itself, the current online + version of the server is available + at http://lab.llvm.org/lab/. +

+ +

Documentation

+ + + +
+ + + + +
+ +

Source

+

llvmlab is available in the LLVM "zorg" SVN repository: + svn co + + http://llvm.org/svn/llvm-project/zorg/trunk/llvmlab.

+ +{% endblock %} Added: zorg/trunk/llvmlab/docs/_templates/indexsidebar.html URL: http://llvm.org/viewvc/llvm-project/zorg/trunk/llvmlab/docs/_templates/indexsidebar.html?rev=141394&view=auto ============================================================================== --- zorg/trunk/llvmlab/docs/_templates/indexsidebar.html (added) +++ zorg/trunk/llvmlab/docs/_templates/indexsidebar.html Fri Oct 7 14:54:46 2011 @@ -0,0 +1,4 @@ +

Bugs

+ +

llvmlab bugs should be reported at the + LLVM Bugzilla.

Added: zorg/trunk/llvmlab/docs/_templates/layout.html URL: http://llvm.org/viewvc/llvm-project/zorg/trunk/llvmlab/docs/_templates/layout.html?rev=141394&view=auto ============================================================================== --- zorg/trunk/llvmlab/docs/_templates/layout.html (added) +++ zorg/trunk/llvmlab/docs/_templates/layout.html Fri Oct 7 14:54:46 2011 @@ -0,0 +1,13 @@ +{% extends "!layout.html" %} + +{% block extrahead %} + +{% endblock %} + +{% block rootrellink %} +
  • Home | 
  • +
  • Documentation»
  • +{% endblock %} Added: zorg/trunk/llvmlab/docs/conf.py URL: http://llvm.org/viewvc/llvm-project/zorg/trunk/llvmlab/docs/conf.py?rev=141394&view=auto ============================================================================== --- zorg/trunk/llvmlab/docs/conf.py (added) +++ zorg/trunk/llvmlab/docs/conf.py Fri Oct 7 14:54:46 2011 @@ -0,0 +1,241 @@ +# -*- coding: utf-8 -*- +# +# Documentation build configuration file. +# +# This file is execfile()d with the current directory set to its containing dir. +# +# Note that not all possible configuration values are present in this +# autogenerated file. +# +# All configuration values have a default; values that are commented out +# serve to show the default. + +import datetime, sys, os + +# If extensions (or modules to document with autodoc) are in another directory, +# add these directories to sys.path here. If the directory is relative to the +# documentation root, use os.path.abspath to make it absolute, like shown here. +sys.path.append(os.path.abspath('..')) + +import llvmlab + +project = "llvmlab" +project_module = llvmlab + +# -- General configuration ----------------------------------------------------- + +# If your documentation needs a minimal Sphinx version, state it here. +#needs_sphinx = '1.0' + +# Add any Sphinx extension module names here, as strings. They can be extensions +# coming with Sphinx (named 'sphinx.ext.*') or your custom ones. +extensions = ['sphinx.ext.autodoc', 'sphinx.ext.doctest', 'sphinx.ext.coverage'] + +# Add any paths that contain templates here, relative to this directory. +templates_path = ['_templates'] + +# The suffix of source filenames. +source_suffix = '.rst' + +# The encoding of source files. +#source_encoding = 'utf-8-sig' + +# The master toctree document. +master_doc = 'contents' + +# General information about the project. +copyright = u'%s, %s' % (datetime.datetime.now().year, + project_module.__author__) + +# The version info for the project you're documenting, acts as replacement for +# |version| and |release|, also used in various other places throughout the +# built documents. +# +# The short X.Y version. +version = project_module.__version__ +# The full version, including alpha/beta/rc tags. +release = project_module.__version__ + +# The language for content autogenerated by Sphinx. Refer to documentation +# for a list of supported languages. +#language = None + +# There are two options for replacing |today|: either, you set today to some +# non-false value, then it is used: +#today = '' +# Else, today_fmt is used as the format for a strftime call. +today_fmt = '%Y-%m-%d' + +# List of patterns, relative to source directory, that match files and +# directories to ignore when looking for source files. +exclude_patterns = ['_build'] + +# The reST default role (used for this markup: `text`) to use for all documents. +#default_role = None + +# If true, '()' will be appended to :func: etc. cross-reference text. +#add_function_parentheses = True + +# If true, the current module name will be prepended to all description +# unit titles (such as .. function::). +#add_module_names = True + +# If true, sectionauthor and moduleauthor directives will be shown in the +# output. They are ignored by default. +show_authors = True + +# The name of the Pygments (syntax highlighting) style to use. +pygments_style = 'sphinx' + +# A list of ignored prefixes for module index sorting. +#modindex_common_prefix = [] + + +# -- Options for HTML output --------------------------------------------------- + +# The theme to use for HTML and HTML Help pages. Major themes that come with +# Sphinx are currently 'default' and 'sphinxdoc'. +html_theme = 'nature' + +# Theme options are theme-specific and customize the look and feel of a theme +# further. For a list of options available for each theme, see the +# documentation. +#html_theme_options = {} + +# Add any paths that contain custom themes here, relative to this directory. +#html_theme_path = [] + +# The name for this set of Sphinx documents. If None, it defaults to +# " v documentation". +#html_title = None + +# A shorter title for the navigation bar. Default is the same as html_title. +#html_short_title = None + +# The name of an image file (relative to this directory) to place at the top +# of the sidebar. +#html_logo = None + +# The name of an image file (within the static path) to use as favicon of the +# docs. This file should be a Windows icon file (.ico) being 16x16 or 32x32 +# pixels large. +#html_favicon = None + +# Add any paths that contain custom static files (such as style sheets) here, +# relative to this directory. They are copied after the builtin static files, +# so a file named "default.css" will overwrite the builtin "default.css". +#html_static_path = ['_static'] + +# If not '', a 'Last updated on:' timestamp is inserted at every page bottom, +# using the given strftime format. +html_last_updated_fmt = '%Y-%m-%d' + +# If true, SmartyPants will be used to convert quotes and dashes to +# typographically correct entities. +#html_use_smartypants = True + +# Custom sidebar templates, maps document names to template names. +html_sidebars = {'index': 'indexsidebar.html'} + +# Additional templates that should be rendered to pages, maps page names to +# template names. +html_additional_pages = {'index': 'index.html'} + +# If false, no module index is generated. +#html_use_modindex = True + +# If false, no index is generated. +#html_use_index = True + +# If true, the index is split into individual pages for each letter. +#html_split_index = False + +# If true, links to the reST sources are added to the pages. +html_show_sourcelink = False + +# If true, "Created using Sphinx" is shown in the HTML footer. Default is True. +#html_show_sphinx = True + +# If true, "(C) Copyright ..." is shown in the HTML footer. Default is True. +#html_show_copyright = True + +# If true, an OpenSearch description file will be output, and all pages will +# contain a tag referring to it. The value of this option must be the +# base URL from which the finished HTML is served. +#html_use_opensearch = '' + +# If nonempty, this is the file name suffix for HTML files (e.g. ".xhtml"). +#html_file_suffix = '' + +# Output file base name for HTML help builder. +htmlhelp_basename = '%sdoc' % project + + +# -- Options for LaTeX output -------------------------------------------------- + +# The paper size ('letter' or 'a4'). +#latex_paper_size = 'letter' + +# The font size ('10pt', '11pt' or '12pt'). +#latex_font_size = '10pt' + +# Grouping the document tree into LaTeX files. List of tuples +# (source start file, target name, title, author, documentclass [howto/manual]). +latex_documents = [ + ('contents', '%s.tex' % project, u'%s Documentation' % project, + project_module.__author__, 'manual'), +] + +# The name of an image file (relative to this directory) to place at the top of +# the title page. +#latex_logo = None + +# For "manual" documents, if this is true, then toplevel headings are parts, +# not chapters. +#latex_use_parts = False + +# Additional stuff for the LaTeX preamble. +#latex_preamble = '' + +# Documents to append as an appendix to all manuals. +#latex_appendices = [] + +# If false, no module index is generated. +#latex_use_modindex = True + + +# -- Options for Epub output --------------------------------------------------- + +# Bibliographic Dublin Core info. +#epub_title = '' +#epub_author = '' +#epub_publisher = '' +#epub_copyright = '' + +# The language of the text. It defaults to the language option +# or en if the language is not set. +#epub_language = '' + +# The scheme of the identifier. Typical schemes are ISBN or URL. +#epub_scheme = '' + +# The unique identifier of the text. This can be a ISBN number +# or the project homepage. +#epub_identifier = '' + +# A unique identification for the text. +#epub_uid = '' + +# HTML files that should be inserted before the pages created by sphinx. +# The format is a list of tuples containing the path and title. +#epub_pre_files = [] + +# HTML files shat should be inserted after the pages created by sphinx. +# The format is a list of tuples containing the path and title. +#epub_post_files = [] + +# A list of files that should not be packed into the epub file. +#epub_exclude_files = [] + +# The depth of the table of contents in toc.ncx. +#epub_tocdepth = 3 Added: zorg/trunk/llvmlab/docs/contents.rst URL: http://llvm.org/viewvc/llvm-project/zorg/trunk/llvmlab/docs/contents.rst?rev=141394&view=auto ============================================================================== --- zorg/trunk/llvmlab/docs/contents.rst (added) +++ zorg/trunk/llvmlab/docs/contents.rst Fri Oct 7 14:54:46 2011 @@ -0,0 +1,15 @@ +.. _contents: + +Contents +======== + +.. toctree:: + :maxdepth: 2 + + intro + +Indices and tables +================== + +* :ref:`genindex` +* :ref:`search` Added: zorg/trunk/llvmlab/docs/intro.rst URL: http://llvm.org/viewvc/llvm-project/zorg/trunk/llvmlab/docs/intro.rst?rev=141394&view=auto ============================================================================== --- zorg/trunk/llvmlab/docs/intro.rst (added) +++ zorg/trunk/llvmlab/docs/intro.rst Fri Oct 7 14:54:46 2011 @@ -0,0 +1,70 @@ +.. _intro: + +Introduction +============ + +Installation +------------ + +These are the (current) rough steps to get a working llvmlab server: + + 1. Install llvmlab:: + + python setup.py install + + It is recommended that you install llvmlab into a virtualenv. If you are + developing the software, you presumably want to use:: + + python setup.py develop + + 2. Create a new llvmlab installation:: + + llvmlab create \ + --master-url http://example.com:8010 \ + --plugin-module zorg.llvmlab + path/to/install-dir + + This will create the llvmlab configuration file, the default database, and a + .wsgi wrapper to create the application. If using this instance for + development, you may want to add the ``--debug-server`` argument to default + to running the server in debug mode. + + The ``--master-url`` should be used to point the lab at the buildbot + installation it is intended to monitor. You can monitor ``lab.llvm.org`` for + quick testing purposes, but **please** do not leave this running for an + extended time, as it puts a certain amount of load on the buildbot + installation. If you want to run longer tests, please run a local buildbot + master and monitor that. + + The ``--plugin-module`` argument is required in order for the dashboard to + work, it is how the dashboard loads the information about the buildbot + configuration. The module path is expected to be importable, so you may need + to extend the PYTHONPATH to support that (e.g., + ``PYTHONPATH=/path/to/zorg/repo`` would allow the default ``lab.llvm.org`` + plugin named above to be imported). + + If using this instance for deployment, you *certainly* want to provide the + ``--admin-email`` and ``--admin-password`` arguments to override the + defaults. You may also need to modify the generated ``app.cfg`` file to + change the default SMTP relay server (used for mailing error messages). + + You can execute the generated WSGI app directly to run with the builtin web + server, or use:: + + env LLVMLAB_CONFIG=/path/to/instance/lab.cfg llvmlab runserver + + which may eventually provide additional command line options. Neither of + these servers is recommended for production use. + + 3. Add the 'app.wsgi' app to your Apache configuration. You should set also + configure the WSGIDaemonProcess and WSGIProcessGroup variables if not + already done. + + If running in a virtualenv you will need to configure that as well; see the + `modwsgi wiki `_. + + +Architecture +------------ + +The llvmlab web app is currently implemented as a WSGI web app using Flask. Added: zorg/trunk/llvmlab/docs/make.bat URL: http://llvm.org/viewvc/llvm-project/zorg/trunk/llvmlab/docs/make.bat?rev=141394&view=auto ============================================================================== --- zorg/trunk/llvmlab/docs/make.bat (added) +++ zorg/trunk/llvmlab/docs/make.bat Fri Oct 7 14:54:46 2011 @@ -0,0 +1,113 @@ + at ECHO OFF + +REM Command file for Sphinx documentation + +set SPHINXBUILD=sphinx-build +set BUILDDIR=_build +set ALLSPHINXOPTS=-d %BUILDDIR%/doctrees %SPHINXOPTS% . +if NOT "%PAPER%" == "" ( + set ALLSPHINXOPTS=-D latex_paper_size=%PAPER% %ALLSPHINXOPTS% +) + +if "%1" == "" goto help + +if "%1" == "help" ( + :help + echo.Please use `make ^` where ^ is one of + echo. html to make standalone HTML files + echo. dirhtml to make HTML files named index.html in directories + echo. pickle to make pickle files + echo. json to make JSON files + echo. htmlhelp to make HTML files and a HTML help project + echo. qthelp to make HTML files and a qthelp project + echo. latex to make LaTeX files, you can set PAPER=a4 or PAPER=letter + echo. changes to make an overview over all changed/added/deprecated items + echo. linkcheck to check all external links for integrity + echo. doctest to run all doctests embedded in the documentation if enabled + goto end +) + +if "%1" == "clean" ( + for /d %%i in (%BUILDDIR%\*) do rmdir /q /s %%i + del /q /s %BUILDDIR%\* + goto end +) + +if "%1" == "html" ( + %SPHINXBUILD% -b html %ALLSPHINXOPTS% %BUILDDIR%/html + echo. + echo.Build finished. The HTML pages are in %BUILDDIR%/html. + goto end +) + +if "%1" == "dirhtml" ( + %SPHINXBUILD% -b dirhtml %ALLSPHINXOPTS% %BUILDDIR%/dirhtml + echo. + echo.Build finished. The HTML pages are in %BUILDDIR%/dirhtml. + goto end +) + +if "%1" == "pickle" ( + %SPHINXBUILD% -b pickle %ALLSPHINXOPTS% %BUILDDIR%/pickle + echo. + echo.Build finished; now you can process the pickle files. + goto end +) + +if "%1" == "json" ( + %SPHINXBUILD% -b json %ALLSPHINXOPTS% %BUILDDIR%/json + echo. + echo.Build finished; now you can process the JSON files. + goto end +) + +if "%1" == "htmlhelp" ( + %SPHINXBUILD% -b htmlhelp %ALLSPHINXOPTS% %BUILDDIR%/htmlhelp + echo. + echo.Build finished; now you can run HTML Help Workshop with the ^ +.hhp project file in %BUILDDIR%/htmlhelp. + goto end +) + +if "%1" == "qthelp" ( + %SPHINXBUILD% -b qthelp %ALLSPHINXOPTS% %BUILDDIR%/qthelp + echo. + echo.Build finished; now you can run "qcollectiongenerator" with the ^ +.qhcp project file in %BUILDDIR%/qthelp, like this: + echo.^> qcollectiongenerator %BUILDDIR%\qthelp\LNT.qhcp + echo.To view the help file: + echo.^> assistant -collectionFile %BUILDDIR%\qthelp\LNT.ghc + goto end +) + +if "%1" == "latex" ( + %SPHINXBUILD% -b latex %ALLSPHINXOPTS% %BUILDDIR%/latex + echo. + echo.Build finished; the LaTeX files are in %BUILDDIR%/latex. + goto end +) + +if "%1" == "changes" ( + %SPHINXBUILD% -b changes %ALLSPHINXOPTS% %BUILDDIR%/changes + echo. + echo.The overview file is in %BUILDDIR%/changes. + goto end +) + +if "%1" == "linkcheck" ( + %SPHINXBUILD% -b linkcheck %ALLSPHINXOPTS% %BUILDDIR%/linkcheck + echo. + echo.Link check complete; look for any errors in the above output ^ +or in %BUILDDIR%/linkcheck/output.txt. + goto end +) + +if "%1" == "doctest" ( + %SPHINXBUILD% -b doctest %ALLSPHINXOPTS% %BUILDDIR%/doctest + echo. + echo.Testing of doctests in the sources finished, look at the ^ +results in %BUILDDIR%/doctest/output.txt. + goto end +) + +:end From daniel at zuster.org Fri Oct 7 14:54:52 2011 From: daniel at zuster.org (Daniel Dunbar) Date: Fri, 07 Oct 2011 19:54:52 -0000 Subject: [llvm-commits] [zorg] r141396 - /zorg/trunk/lnt/lnt/tests/nt.py Message-ID: <20111007195452.53D44312800A@llvm.org> Author: ddunbar Date: Fri Oct 7 14:54:52 2011 New Revision: 141396 URL: http://llvm.org/viewvc/llvm-project?rev=141396&view=rev Log: LNT/nt: Factor out NT report loading. Modified: zorg/trunk/lnt/lnt/tests/nt.py Modified: zorg/trunk/lnt/lnt/tests/nt.py URL: http://llvm.org/viewvc/llvm-project/zorg/trunk/lnt/lnt/tests/nt.py?rev=141396&r1=141395&r2=141396&view=diff ============================================================================== --- zorg/trunk/lnt/lnt/tests/nt.py (original) +++ zorg/trunk/lnt/lnt/tests/nt.py Fri Oct 7 14:54:52 2011 @@ -18,6 +18,112 @@ def timestamp(): return datetime.utcnow().strftime('%Y-%m-%d %H:%M:%S') +def load_nt_report_file(report_path, opts): + # Compute the test samples to report. + sample_keys = [] + if opts.test_style == "simple": + test_namespace = 'nts' + sample_keys.append(('compile', 'CC_Time', None, 'CC')) + sample_keys.append(('exec', 'Exec_Time', None, 'Exec')) + else: + test_namespace = 'nightlytest' + sample_keys.append(('gcc.compile', 'GCCAS', 'time')) + sample_keys.append(('bc.compile', 'Bytecode', 'size')) + if opts.test_llc: + sample_keys.append(('llc.compile', 'LLC compile', 'time')) + if opts.test_llcbeta: + sample_keys.append(('llc-beta.compile', 'LLC-BETA compile', 'time')) + if opts.test_jit: + sample_keys.append(('jit.compile', 'JIT codegen', 'time')) + sample_keys.append(('gcc.exec', 'GCC', 'time')) + if opts.test_cbe: + sample_keys.append(('cbe.exec', 'CBE', 'time')) + if opts.test_llc: + sample_keys.append(('llc.exec', 'LLC', 'time')) + if opts.test_llcbeta: + sample_keys.append(('llc-beta.exec', 'LLC-BETA', 'time')) + if opts.test_jit: + sample_keys.append(('jit.exec', 'JIT', 'time')) + + # Load the report file. + report_file = open(report_path, 'rb') + reader_it = iter(csv.reader(report_file)) + + # Get the header. + header = reader_it.next() + if header[0] != 'Program': + fatal('unexpected report file, missing header') + + # Verify we have the keys we expect. + if 'Program' not in header: + fatal('missing key %r in report header' % 'Program') + for item in sample_keys: + if item[1] not in header: + fatal('missing key %r in report header' % item[1]) + + # We don't use the test info, currently. + test_info = {} + test_samples = [] + for row in reader_it: + record = dict(zip(header, row)) + + program = record['Program'] + if opts.only_test is not None: + program = os.path.join(opts.only_test, program) + test_base_name = '%s.%s' % (test_namespace, program.replace('.','_')) + + # Check if this is a subtest result, in which case we ignore missing + # values. + if '_Subtest_' in test_base_name: + is_subtest = True + test_base_name = test_base_name.replace('_Subtest_', '.') + else: + is_subtest = False + + for info in sample_keys: + if len(info) == 3: + name,key,tname = info + success_key = None + else: + name,key,tname,success_key = info + + test_name = '%s.%s' % (test_base_name, name) + value = record[key] + if success_key is None: + success_value = value + else: + success_value = record[success_key] + + # FIXME: Move to simpler and more succinct format, using .failed. + if success_value == '*': + if is_subtest: + continue + status_value = lnt.testing.FAIL + elif success_value == 'xfail': + status_value = lnt.testing.XFAIL + else: + status_value = lnt.testing.PASS + + if test_namespace == 'nightlytest': + test_samples.append(lnt.testing.TestSamples( + test_name + '.success', + [status_value != lnt.testing.FAIL], test_info)) + else: + if status_value != lnt.testing.PASS: + test_samples.append(lnt.testing.TestSamples( + test_name + '.status', [status_value], test_info)) + if value != '*': + if tname is None: + test_samples.append(lnt.testing.TestSamples( + test_name, [float(value)], test_info)) + else: + test_samples.append(lnt.testing.TestSamples( + test_name + '.' + tname, [float(value)], test_info)) + + report_file.close() + + return test_namespace, test_samples + def run_test(nick_prefix, opts, iteration): if opts.llvm_src_root: llvm_source_version = get_source_version(opts.llvm_src_root) @@ -383,114 +489,14 @@ end_time = timestamp() - # Compute the test samples to report. - sample_keys = [] - if opts.test_style == "simple": - test_namespace = 'nts' - sample_keys.append(('compile', 'CC_Time', None, 'CC')) - sample_keys.append(('exec', 'Exec_Time', None, 'Exec')) - else: - test_namespace = 'nightlytest' - sample_keys.append(('gcc.compile', 'GCCAS', 'time')) - sample_keys.append(('bc.compile', 'Bytecode', 'size')) - if opts.test_llc: - sample_keys.append(('llc.compile', 'LLC compile', 'time')) - if opts.test_llcbeta: - sample_keys.append(('llc-beta.compile', 'LLC-BETA compile', 'time')) - if opts.test_jit: - sample_keys.append(('jit.compile', 'JIT codegen', 'time')) - sample_keys.append(('gcc.exec', 'GCC', 'time')) - if opts.test_cbe: - sample_keys.append(('cbe.exec', 'CBE', 'time')) - if opts.test_llc: - sample_keys.append(('llc.exec', 'LLC', 'time')) - if opts.test_llcbeta: - sample_keys.append(('llc-beta.exec', 'LLC-BETA', 'time')) - if opts.test_jit: - sample_keys.append(('jit.exec', 'JIT', 'time')) - # Load the test samples. print >>sys.stderr, '%s: loading test data...' % timestamp() - test_samples = [] # If nightly test went screwy, it won't have produced a report. if not os.path.exists(report_path): fatal('nightly test failed, no report generated') - report_file = open(report_path, 'rb') - reader_it = iter(csv.reader(report_file)) - - # Get the header. - header = reader_it.next() - if header[0] != 'Program': - fatal('unexpected report file, missing header') - - # Verify we have the keys we expect. - if 'Program' not in header: - fatal('missing key %r in report header' % 'Program') - for item in sample_keys: - if item[1] not in header: - fatal('missing key %r in report header' % item[1]) - - # We don't use the test info, currently. - test_info = {} - for row in reader_it: - record = dict(zip(header, row)) - - program = record['Program'] - if opts.only_test is not None: - program = os.path.join(opts.only_test, program) - test_base_name = '%s.%s' % (test_namespace, program.replace('.','_')) - - # Check if this is a subtest result, in which case we ignore missing - # values. - if '_Subtest_' in test_base_name: - is_subtest = True - test_base_name = test_base_name.replace('_Subtest_', '.') - else: - is_subtest = False - - for info in sample_keys: - if len(info) == 3: - name,key,tname = info - success_key = None - else: - name,key,tname,success_key = info - - test_name = '%s.%s' % (test_base_name, name) - value = record[key] - if success_key is None: - success_value = value - else: - success_value = record[success_key] - - # FIXME: Move to simpler and more succinct format, using .failed. - if success_value == '*': - if is_subtest: - continue - status_value = lnt.testing.FAIL - elif success_value == 'xfail': - status_value = lnt.testing.XFAIL - else: - status_value = lnt.testing.PASS - - if test_namespace == 'nightlytest': - test_samples.append(lnt.testing.TestSamples( - test_name + '.success', - [status_value != lnt.testing.FAIL], test_info)) - else: - if status_value != lnt.testing.PASS: - test_samples.append(lnt.testing.TestSamples( - test_name + '.status', [status_value], test_info)) - if value != '*': - if tname is None: - test_samples.append(lnt.testing.TestSamples( - test_name, [float(value)], test_info)) - else: - test_samples.append(lnt.testing.TestSamples( - test_name + '.' + tname, [float(value)], test_info)) - - report_file.close() + test_namespace, test_samples = load_nt_report_file(report_path, opts) # Collect the machine and run info. # From daniel at zuster.org Fri Oct 7 14:54:54 2011 From: daniel at zuster.org (Daniel Dunbar) Date: Fri, 07 Oct 2011 19:54:54 -0000 Subject: [llvm-commits] [zorg] r141397 - in /zorg/trunk/lnt/docs: todo.rst todo.txt Message-ID: <20111007195454.EFE77312800A@llvm.org> Author: ddunbar Date: Fri Oct 7 14:54:54 2011 New Revision: 141397 URL: http://llvm.org/viewvc/llvm-project?rev=141397&view=rev Log: LNT/docs: Fix todo doc name. Added: zorg/trunk/lnt/docs/todo.rst - copied, changed from r141396, zorg/trunk/lnt/docs/todo.txt Removed: zorg/trunk/lnt/docs/todo.txt Copied: zorg/trunk/lnt/docs/todo.rst (from r141396, zorg/trunk/lnt/docs/todo.txt) URL: http://llvm.org/viewvc/llvm-project/zorg/trunk/lnt/docs/todo.rst?p2=zorg/trunk/lnt/docs/todo.rst&p1=zorg/trunk/lnt/docs/todo.txt&r1=141396&r2=141397&rev=141397&view=diff ============================================================================== (empty) Removed: zorg/trunk/lnt/docs/todo.txt URL: http://llvm.org/viewvc/llvm-project/zorg/trunk/lnt/docs/todo.txt?rev=141396&view=auto ============================================================================== --- zorg/trunk/lnt/docs/todo.txt (original) +++ zorg/trunk/lnt/docs/todo.txt (removed) @@ -1,31 +0,0 @@ -.. _todo: - -TODO -==== - -This is a TODO list of major and minor features for LNT. - -Major Features --------------- - -Too many to name! - -Minor Features --------------- - -Optimize test distribution format for common cases. - - 1. We should left the test info higher in the format, so that it can easily be - shared by a large number of samples. - - 2. We should specify test samples in an array instead of objects, to avoid - requiring repetitive 'Name' and 'Data' keys. - - 3. We should support [test, sample] in addition to [test, [sample, ...]]. - - 4. If we changed the .success marker to be .failure, then having [test] be a - shortcut for [test, 0] would be fairly nice, and in the visualization we would - automatically get the right defaulting for absent tests. - -These changes would significantly compact the archive format, which improves -performance across the board. From daniel at zuster.org Fri Oct 7 14:54:57 2011 From: daniel at zuster.org (Daniel Dunbar) Date: Fri, 07 Oct 2011 19:54:57 -0000 Subject: [llvm-commits] [zorg] r141398 - /zorg/trunk/lnt/lnt/tests/nt.py Message-ID: <20111007195457.69B042A6C12D@llvm.org> Author: ddunbar Date: Fri Oct 7 14:54:57 2011 New Revision: 141398 URL: http://llvm.org/viewvc/llvm-project?rev=141398&view=rev Log: LNT/nt: Tidy up some code. Modified: zorg/trunk/lnt/lnt/tests/nt.py Modified: zorg/trunk/lnt/lnt/tests/nt.py URL: http://llvm.org/viewvc/llvm-project/zorg/trunk/lnt/lnt/tests/nt.py?rev=141398&r1=141397&r2=141398&view=diff ============================================================================== --- zorg/trunk/lnt/lnt/tests/nt.py (original) +++ zorg/trunk/lnt/lnt/tests/nt.py Fri Oct 7 14:54:57 2011 @@ -259,10 +259,6 @@ make_variables['USE_REFERENCE_OUTPUT'] = '1' make_variables['TEST'] = opts.test_style - # Support disabling test suite externals separately from providing path. - if not opts.test_externals: - opts.test_suite_externals = '/dev/null' - # Get compiler info. cc_info = lnt.testing.util.compilers.get_cc_info(opts.cc_under_test, target_flags) @@ -948,6 +944,10 @@ parser.error('invalid --liblto-path argument %r' % ( opts.liblto_path,)) + # Support disabling test suite externals separately from providing path. + if not opts.test_externals: + opts.test_suite_externals = '/dev/null' + # Set up iOS simulator options. if opts.ios_simulator_sdk: # Warn if the user asked to run under an iOS simulator SDK, but From daniel at zuster.org Fri Oct 7 14:54:59 2011 From: daniel at zuster.org (Daniel Dunbar) Date: Fri, 07 Oct 2011 19:54:59 -0000 Subject: [llvm-commits] [zorg] r141399 - /zorg/trunk/lnt/lnt/tests/nt.py Message-ID: <20111007195459.D5B13312800A@llvm.org> Author: ddunbar Date: Fri Oct 7 14:54:59 2011 New Revision: 141399 URL: http://llvm.org/viewvc/llvm-project?rev=141399&view=rev Log: LNT/nt: Factor out compute_run_make_variables(). Modified: zorg/trunk/lnt/lnt/tests/nt.py Modified: zorg/trunk/lnt/lnt/tests/nt.py URL: http://llvm.org/viewvc/llvm-project/zorg/trunk/lnt/lnt/tests/nt.py?rev=141399&r1=141398&r2=141399&view=diff ============================================================================== --- zorg/trunk/lnt/lnt/tests/nt.py (original) +++ zorg/trunk/lnt/lnt/tests/nt.py Fri Oct 7 14:54:59 2011 @@ -124,29 +124,8 @@ return test_namespace, test_samples -def run_test(nick_prefix, opts, iteration): - if opts.llvm_src_root: - llvm_source_version = get_source_version(opts.llvm_src_root) - else: - llvm_source_version = None - - # Compute TARGET_FLAGS. - target_flags = [] - - # FIXME: Eliminate this blanket option. - target_flags.extend(opts.cflags) - - # Pass flags to backend. - for f in opts.mllvm: - target_flags.extend(['-mllvm', f]) - - if opts.arch is not None: - target_flags.append('-arch') - target_flags.append(opts.arch) - if opts.isysroot is not None: - target_flags.append('-isysroot') - target_flags.append(opts.isysroot) - +def compute_run_make_variables(opts, llvm_source_version, target_flags, + cc_info): # Set the make variables to use. make_variables = { 'TARGET_CC' : opts.cc_reference, @@ -259,10 +238,6 @@ make_variables['USE_REFERENCE_OUTPUT'] = '1' make_variables['TEST'] = opts.test_style - # Get compiler info. - cc_info = lnt.testing.util.compilers.get_cc_info(opts.cc_under_test, - target_flags) - # Set CC_UNDER_TEST_IS_CLANG when appropriate. if cc_info.get('cc_name') in ('apple_clang', 'clang'): make_variables['CC_UNDER_TEST_IS_CLANG'] = '1' @@ -319,6 +294,40 @@ else: warning("unable to infer ARCH, some tests may not run correctly!") + return make_variables + +def run_test(nick_prefix, opts, iteration): + if opts.llvm_src_root: + llvm_source_version = get_source_version(opts.llvm_src_root) + else: + llvm_source_version = None + + # Compute TARGET_FLAGS. + target_flags = [] + + # FIXME: Eliminate this blanket option. + target_flags.extend(opts.cflags) + + # Pass flags to backend. + for f in opts.mllvm: + target_flags.extend(['-mllvm', f]) + + if opts.arch is not None: + target_flags.append('-arch') + target_flags.append(opts.arch) + if opts.isysroot is not None: + target_flags.append('-isysroot') + target_flags.append(opts.isysroot) + + # Get compiler info. + cc_info = lnt.testing.util.compilers.get_cc_info(opts.cc_under_test, + target_flags) + cc_target = cc_info.get('cc_target') + + # Compute the make variables. + make_variables = compute_run_make_variables(opts, llvm_source_version, + target_flags, cc_info) + # Stash the variables we want to report. public_make_variables = make_variables.copy() From daniel at zuster.org Fri Oct 7 14:55:02 2011 From: daniel at zuster.org (Daniel Dunbar) Date: Fri, 07 Oct 2011 19:55:02 -0000 Subject: [llvm-commits] [zorg] r141400 - /zorg/trunk/lnt/lnt/tests/nt.py Message-ID: <20111007195502.6EED0312800A@llvm.org> Author: ddunbar Date: Fri Oct 7 14:55:02 2011 New Revision: 141400 URL: http://llvm.org/viewvc/llvm-project?rev=141400&view=rev Log: LNT/nt: Factor out execute_nt_tests(). Modified: zorg/trunk/lnt/lnt/tests/nt.py Modified: zorg/trunk/lnt/lnt/tests/nt.py URL: http://llvm.org/viewvc/llvm-project/zorg/trunk/lnt/lnt/tests/nt.py?rev=141400&r1=141399&r2=141400&view=diff ============================================================================== --- zorg/trunk/lnt/lnt/tests/nt.py (original) +++ zorg/trunk/lnt/lnt/tests/nt.py Fri Oct 7 14:55:02 2011 @@ -18,6 +18,44 @@ def timestamp(): return datetime.utcnow().strftime('%Y-%m-%d %H:%M:%S') +def execute_nt_tests(test_log, make_variables, basedir, opts): + common_args = ['make', '-k'] + common_args.extend('%s=%s' % (k,v) for k,v in make_variables.items()) + if opts.only_test is not None: + common_args.extend(['-C',opts.only_test]) + + # Run a separate 'make build' step if --build-threads was given. + if opts.build_threads > 0: + args = common_args + ['-j', str(opts.build_threads), 'build'] + print >>test_log, '%s: running: %s' % (timestamp(), + ' '.join('"%s"' % a + for a in args)) + test_log.flush() + + print >>sys.stderr, '%s: building -j%u...' % (timestamp(), + opts.build_threads) + p = subprocess.Popen(args=args, stdin=None, stdout=test_log, + stderr=subprocess.STDOUT, cwd=basedir, + env=os.environ) + res = p.wait() + + # Then 'make report'. + args = common_args + ['-j', str(opts.threads), + 'report', 'report.%s.csv' % opts.test_style] + print >>test_log, '%s: running: %s' % (timestamp(), + ' '.join('"%s"' % a + for a in args)) + test_log.flush() + + # FIXME: We shouldn't need to set env=os.environ here, but if we don't + # somehow MACOSX_DEPLOYMENT_TARGET gets injected into the environment on OS + # X (which changes the driver behavior and causes generally weirdness). + print >>sys.stderr, '%s: testing -j%u...' % (timestamp(), opts.threads) + p = subprocess.Popen(args=args, stdin=None, stdout=test_log, + stderr=subprocess.STDOUT, cwd=basedir, + env=os.environ) + res = p.wait() + def load_nt_report_file(report_path, opts): # Compute the test samples to report. sample_keys = [] @@ -150,7 +188,7 @@ make_variables['TARGET_LLCFLAGS'] = ' '.join(target_llcflags) # Set up environment overrides if requested, to effectively run under the - # specified the Darwin iOS simulator. + # specified Darwin iOS simulator. # # See /D/P/../Developer/Tools/RunPlatformUnitTests. if opts.ios_simulator_sdk is not None: @@ -377,7 +415,8 @@ if needs_clean and opts.timestamp_build: fatal('refusing to reuse pre-existing build dir %r' % basedir) - # FIXME: Auto-remove old test directories. + # FIXME: Auto-remove old test directories in the source directory (which + # cause make horrible fits). print >>sys.stderr, '%s: starting test in %r' % (timestamp(), basedir) @@ -454,42 +493,8 @@ test_log_path = os.path.join(basedir, 'test.log') test_log = open(test_log_path, 'w') - common_args = ['make', '-k'] - common_args.extend('%s=%s' % (k,v) for k,v in make_variables.items()) - if opts.only_test is not None: - common_args.extend(['-C',opts.only_test]) - - # Run a separate 'make build' step if --build-threads was given. - if opts.build_threads > 0: - args = common_args + ['-j', str(opts.build_threads), 'build'] - print >>test_log, '%s: running: %s' % (timestamp(), - ' '.join('"%s"' % a - for a in args)) - test_log.flush() - - print >>sys.stderr, '%s: building -j%u...' % (timestamp(), - opts.build_threads) - p = subprocess.Popen(args=args, stdin=None, stdout=test_log, - stderr=subprocess.STDOUT, cwd=basedir, - env=os.environ) - res = p.wait() - - # Then 'make report'. - args = common_args + ['-j', str(opts.threads), - 'report', 'report.%s.csv' % opts.test_style] - print >>test_log, '%s: running: %s' % (timestamp(), - ' '.join('"%s"' % a - for a in args)) - test_log.flush() + execute_nt_tests(test_log, make_variables, basedir, opts) - # FIXME: We shouldn't need to set env=os.environ here, but if we don't - # somehow MACOSX_DEPLOYMENT_TARGET gets injected into the environment on OS - # X (which changes the driver behavior and causes generally weirdness). - print >>sys.stderr, '%s: testing -j%u...' % (timestamp(), opts.threads) - p = subprocess.Popen(args=args, stdin=None, stdout=test_log, - stderr=subprocess.STDOUT, cwd=basedir, - env=os.environ) - res = p.wait() test_log.close() end_time = timestamp() From daniel at zuster.org Fri Oct 7 14:55:05 2011 From: daniel at zuster.org (Daniel Dunbar) Date: Fri, 07 Oct 2011 19:55:05 -0000 Subject: [llvm-commits] [zorg] r141401 - in /zorg/trunk/lnt: docs/tests.rst lnt/tests/nt.py Message-ID: <20111007195505.42C33312800A@llvm.org> Author: ddunbar Date: Fri Oct 7 14:55:05 2011 New Revision: 141401 URL: http://llvm.org/viewvc/llvm-project?rev=141401&view=rev Log: LNT/nt: Sketch minimal support for "LNT-based" test modules in the LLVM test-suite. - This is an extension mechanism to allow easily slotting in tests that are complicated or otherwise hard to fit into the strict nightly test model. Modified: zorg/trunk/lnt/docs/tests.rst zorg/trunk/lnt/lnt/tests/nt.py Modified: zorg/trunk/lnt/docs/tests.rst URL: http://llvm.org/viewvc/llvm-project/zorg/trunk/lnt/docs/tests.rst?rev=141401&r1=141400&r2=141401&view=diff ============================================================================== --- zorg/trunk/lnt/docs/tests.rst (original) +++ zorg/trunk/lnt/docs/tests.rst Fri Oct 7 14:55:05 2011 @@ -146,3 +146,16 @@ TOTAL IMPORT TIME: 5.57s and view the results on our local server. + +LNT-based NT test modules ++++++++++++++++++++++++++ + +In order to support more complicated tests, or tests which are not easily +integrated into the more strict SingleSource or MultiSource layout of the LLVM +test-suite module, the ``nt`` built-in test provides a mechanism for LLVM +test-suite tests that just define an extension test module. These tests are +passed the user configuration parameters for a test run and expected to return +back the test results in the LNT native format. + +For more information, see the example tests in the LLVM test-suite repository +under the ``LNT/Examples`` directory. Modified: zorg/trunk/lnt/lnt/tests/nt.py URL: http://llvm.org/viewvc/llvm-project/zorg/trunk/lnt/lnt/tests/nt.py?rev=141401&r1=141400&r2=141401&view=diff ============================================================================== --- zorg/trunk/lnt/lnt/tests/nt.py (original) +++ zorg/trunk/lnt/lnt/tests/nt.py Fri Oct 7 14:55:05 2011 @@ -5,6 +5,7 @@ import subprocess import sys import time +import traceback from datetime import datetime @@ -15,9 +16,113 @@ from lnt.testing.util.commands import capture, which from lnt.testing.util.rcs import get_source_version +### + +class TestModule(object): + """ + Base class for extension test modules. + """ + + def main(self): + raise NotImplementedError + + def execute_test(self, options): + abstract + +### + def timestamp(): return datetime.utcnow().strftime('%Y-%m-%d %H:%M:%S') +def execute_test_modules(test_log, test_modules, test_module_variables, + basedir, opts): + # For now, we don't execute these in parallel, but we do forward the + # parallel build options to the test. + test_modules.sort() + + results = [] + for name in test_modules: + # First, load the test module file. + locals = globals = {} + test_path = os.path.join(opts.test_suite_root, 'LNTBased', name) + module_path = os.path.join(test_path, 'TestModule') + module_file = open(module_path) + try: + exec module_file in locals, globals + except: + fatal("unable to import test module: %r" % module_path) + + # Lookup and instantiate the test class. + test_class = globals.get('test_class') + if test_class is None: + fatal("no 'test_class' global in import test module: %r" % ( + module_path,)) + try: + test_instance = test_class() + except: + fatal("unable to instantiate test class for: %r" % module_path) + + # Execute the tests. + try: + test_samples = test_instance.execute_test(test_module_variables) + except: + info = traceback.format_exc() + fatal("exception executing tests for: %r\n%s" % ( + module_path, info)) + + # Check that the test samples are in the expected format. + is_ok = True + try: + test_samples = list(test_samples) + for item in test_samples: + if not isinstance(item, lnt.testing.TestSamples): + is_ok = False + break + except: + is_ok = False + if not is_ok: + fatal("test module did not return samples list: %r" % ( + module_path,)) + + results.append((name, test_samples)) + + return results + +def compute_test_module_variables(make_variables, opts): + # Set the test module options, which we try and restrict to a tighter subset + # than what we pass to the LNT makefiles. + test_module_variables = { + 'CC' : make_variables['TARGET_CC'], + 'CXX' : make_variables['TARGET_CXX'], + 'CFLAGS' : make_variables['TARGET_FLAGS'], + 'CXXFLAGS' : make_variables['TARGET_FLAGS'], + 'OPTFLAGS' : make_variables['OPTFLAGS'] } + + # Add the remote execution variables. + if opts.remote: + test_module_variables['REMOTE_HOST'] = make_variables['REMOTE_HOST'] + test_module_variables['REMOTE_USER'] = make_variables['REMOTE_USER'] + test_module_variables['REMOTE_PORT'] = make_variables['REMOTE_PORT'] + test_module_variables['REMOTE_CLIENT'] = make_variables['REMOTE_CLIENT'] + + # Add miscellaneous optional variables. + if 'LD_ENV_OVERRIDES' in make_variables: + value = make_variables['LD_ENV_OVERRIDES'] + assert value.startswith('env ') + test_module_variables['LINK_ENVIRONMENT_OVERRIDES'] = value[4:] + + # This isn't possible currently, just here to mark what the option variable + # would be called. + if 'COMPILE_ENVIRONMENT_OVERRIDES' in make_variables: + test_module_variables['COMPILE_ENVIRONMENT_OVERRIDES'] = \ + make_variables['COMPILE_ENVIRONMENT_OVERRIDES'] + + if 'EXECUTION_ENVIRONMENT_OVERRIDES' in make_variables: + test_module_variables['EXECUTION_ENVIRONMENT_OVERRIDES'] = \ + make_variables['EXECUTION_ENVIRONMENT_OVERRIDES'] + + return test_module_variables + def execute_nt_tests(test_log, make_variables, basedir, opts): common_args = ['make', '-k'] common_args.extend('%s=%s' % (k,v) for k,v in make_variables.items()) @@ -160,7 +265,7 @@ report_file.close() - return test_namespace, test_samples + return test_samples def compute_run_make_variables(opts, llvm_source_version, target_flags, cc_info): @@ -376,6 +481,24 @@ make_variables['REMOTE_PORT'] = str(opts.remote_port) make_variables['REMOTE_CLIENT'] = opts.remote_client + # Compute the test module variables, which are a restricted subset of the + # make variables. + test_module_variables = compute_test_module_variables(make_variables, opts) + + # Scan for LNT-based test modules. + print >>sys.stderr, "%s: scanning for LNT-based test modules" % ( + timestamp(),) + test_modules = [] + test_modules_path = os.path.join(opts.test_suite_root, 'LNTBased') + for dirpath,dirnames,filenames in os.walk(test_modules_path): + if 'TestModule' not in filenames: + continue + + assert dirpath.startswith(test_modules_path + '/') + test_modules.append(dirpath[len(test_modules_path) + 1:]) + print >>sys.stderr, "%s: found %d LNT-based test modules" % ( + timestamp(), len(test_modules)) + nick = nick_prefix if opts.auto_name: # Construct the nickname from a few key parameters. @@ -450,7 +573,7 @@ # If running with --only-test, creating any dirs which might be missing and # copy Makefiles. - if opts.only_test is not None: + if opts.only_test is not None and not opts.only_test.startswith("LNTBased"): suffix = '' for component in opts.only_test.split('/'): suffix = os.path.join(suffix, component) @@ -493,20 +616,39 @@ test_log_path = os.path.join(basedir, 'test.log') test_log = open(test_log_path, 'w') - execute_nt_tests(test_log, make_variables, basedir, opts) + # Run the make driven tests if needed. + run_nightly_test = (opts.only_test is None or + not opts.only_test.startswith("LNTBased")) + if run_nightly_test: + execute_nt_tests(test_log, make_variables, basedir, opts) + + # Run the extension test modules, if needed. + test_module_results = execute_test_modules(test_log, test_modules, + test_module_variables, basedir, + opts) test_log.close() end_time = timestamp() - # Load the test samples. - print >>sys.stderr, '%s: loading test data...' % timestamp() + # Load the nightly test samples. + if opts.test_style == "simple": + test_namespace = 'nts' + else: + test_namespace = 'nightlytest' + if run_nightly_test: + print >>sys.stderr, '%s: loading nightly test data...' % timestamp() + # If nightly test went screwy, it won't have produced a report. + if not os.path.exists(report_path): + fatal('nightly test failed, no report generated') - # If nightly test went screwy, it won't have produced a report. - if not os.path.exists(report_path): - fatal('nightly test failed, no report generated') + test_samples = load_nt_report_file(report_path, opts) + else: + test_samples = [] - test_namespace, test_samples = load_nt_report_file(report_path, opts) + # Merge in the test samples from all of the test modules. + for module,results in test_module_results: + test_samples.extend(results) # Collect the machine and run info. # From daniel at zuster.org Fri Oct 7 14:55:07 2011 From: daniel at zuster.org (Daniel Dunbar) Date: Fri, 07 Oct 2011 19:55:07 -0000 Subject: [llvm-commits] [zorg] r141402 - /zorg/trunk/lnt/lnt/tests/nt.py Message-ID: <20111007195507.B0E23312800A@llvm.org> Author: ddunbar Date: Fri Oct 7 14:55:07 2011 New Revision: 141402 URL: http://llvm.org/viewvc/llvm-project?rev=141402&view=rev Log: LNT/nt: Enforce that test modules don't add duplicate tests. Modified: zorg/trunk/lnt/lnt/tests/nt.py Modified: zorg/trunk/lnt/lnt/tests/nt.py URL: http://llvm.org/viewvc/llvm-project/zorg/trunk/lnt/lnt/tests/nt.py?rev=141402&r1=141401&r2=141402&view=diff ============================================================================== --- zorg/trunk/lnt/lnt/tests/nt.py (original) +++ zorg/trunk/lnt/lnt/tests/nt.py Fri Oct 7 14:55:07 2011 @@ -647,7 +647,13 @@ test_samples = [] # Merge in the test samples from all of the test modules. + existing_tests = set(s.name for s in test_samples) for module,results in test_module_results: + for s in results: + if s.name in existing_tests: + fatal("test module %r added duplicate test: %r" % ( + module, s.name)) + existing_tests.add(s.name) test_samples.extend(results) # Collect the machine and run info. From daniel at zuster.org Fri Oct 7 14:55:10 2011 From: daniel at zuster.org (Daniel Dunbar) Date: Fri, 07 Oct 2011 19:55:10 -0000 Subject: [llvm-commits] [zorg] r141403 - /zorg/trunk/lnt/lnt/testing/util/rcs.py Message-ID: <20111007195510.A4C27312800A@llvm.org> Author: ddunbar Date: Fri Oct 7 14:55:10 2011 New Revision: 141403 URL: http://llvm.org/viewvc/llvm-project?rev=141403&view=rev Log: lnt.testing.util.rcs: Update get_source_version to manually extract the commit revision instead of parsing git-svn output, which was irritatingly slow. Modified: zorg/trunk/lnt/lnt/testing/util/rcs.py Modified: zorg/trunk/lnt/lnt/testing/util/rcs.py URL: http://llvm.org/viewvc/llvm-project/zorg/trunk/lnt/lnt/testing/util/rcs.py?rev=141403&r1=141402&r2=141403&view=diff ============================================================================== --- zorg/trunk/lnt/lnt/testing/util/rcs.py (original) +++ zorg/trunk/lnt/lnt/testing/util/rcs.py Fri Oct 7 14:55:10 2011 @@ -1,6 +1,8 @@ +import re import os from lnt.testing.util import commands +_git_svn_id_re = re.compile("^ git-svn-id: [^@]*@([0-9]+) .*$") def get_source_version(path): """get_source_version(path) -> str or None @@ -12,11 +14,17 @@ return commands.capture(['/bin/sh', '-c', 'cd "%s" && svnversion' % path]).strip() elif os.path.exists(os.path.join(path, ".git", "svn")): + # git-svn is pitifully slow, extract the revision manually. res = commands.capture(['/bin/sh', '-c', - 'cd "%s" && git svn info' % path]).strip() - for ln in res.split("\n"): - if ln.startswith("Revision:"): - return ln.split(':',1)[1].strip() + ('cd "%s" && ' + 'git log -1') % path] + ).strip() + last_line = res.split("\n")[-1] + m = _git_svn_id_re.match(last_line) + if not m: + commands.warning("unable to understand git svn log: %r" % res) + return + return m.group(1) elif os.path.exists(os.path.join(path, ".git")): return commands.capture(['/bin/sh', '-c', ('cd "%s" && ' From daniel at zuster.org Fri Oct 7 14:55:15 2011 From: daniel at zuster.org (Daniel Dunbar) Date: Fri, 07 Oct 2011 19:55:15 -0000 Subject: [llvm-commits] [zorg] r141405 - /zorg/trunk/lnt/lnt/tests/nt.py Message-ID: <20111007195515.BCBF43128018@llvm.org> Author: ddunbar Date: Fri Oct 7 14:55:15 2011 New Revision: 141405 URL: http://llvm.org/viewvc/llvm-project?rev=141405&view=rev Log: LNT/nt: Add/clarify log output. Modified: zorg/trunk/lnt/lnt/tests/nt.py Modified: zorg/trunk/lnt/lnt/tests/nt.py URL: http://llvm.org/viewvc/llvm-project/zorg/trunk/lnt/lnt/tests/nt.py?rev=141405&r1=141404&r2=141405&view=diff ============================================================================== --- zorg/trunk/lnt/lnt/tests/nt.py (original) +++ zorg/trunk/lnt/lnt/tests/nt.py Fri Oct 7 14:55:15 2011 @@ -40,6 +40,7 @@ # parallel build options to the test. test_modules.sort() + print >>sys.stderr, '%s: executing test modules' % (timestamp(),) results = [] for name in test_modules: # First, load the test module file. @@ -137,8 +138,8 @@ for a in args)) test_log.flush() - print >>sys.stderr, '%s: building -j%u...' % (timestamp(), - opts.build_threads) + print >>sys.stderr, '%s: building "nightly tests" with -j%u...' % ( + timestamp(), opts.build_threads) p = subprocess.Popen(args=args, stdin=None, stdout=test_log, stderr=subprocess.STDOUT, cwd=basedir, env=os.environ) @@ -155,7 +156,8 @@ # FIXME: We shouldn't need to set env=os.environ here, but if we don't # somehow MACOSX_DEPLOYMENT_TARGET gets injected into the environment on OS # X (which changes the driver behavior and causes generally weirdness). - print >>sys.stderr, '%s: testing -j%u...' % (timestamp(), opts.threads) + print >>sys.stderr, '%s: executing "nightly tests" with -j%u...' % ( + timestamp(), opts.threads) p = subprocess.Popen(args=args, stdin=None, stdout=test_log, stderr=subprocess.STDOUT, cwd=basedir, env=os.environ) @@ -440,10 +442,13 @@ return make_variables def run_test(nick_prefix, opts, iteration): + print >>sys.stderr, "%s: checking source versions" % ( + timestamp(),) if opts.llvm_src_root: llvm_source_version = get_source_version(opts.llvm_src_root) else: llvm_source_version = None + test_suite_source_version = get_source_version(opts.test_suite_root) # Compute TARGET_FLAGS. target_flags = [] @@ -656,6 +661,7 @@ existing_tests.add(s.name) test_samples.extend(results) + print >>sys.stderr, '%s: capturing machine information' % (timestamp(),) # Collect the machine and run info. # # FIXME: Import full range of data that the Clang tests are using? @@ -704,7 +710,7 @@ # so we are more likely to be accurate. if llvm_source_version is not None: run_info['llvm_revision'] = llvm_source_version - run_info['test_suite_revision'] = get_source_version(opts.test_suite_root) + run_info['test_suite_revision'] = test_suite_source_version run_info.update(public_make_variables) # Set the run order from the user, if given. From daniel at zuster.org Fri Oct 7 14:55:18 2011 From: daniel at zuster.org (Daniel Dunbar) Date: Fri, 07 Oct 2011 19:55:18 -0000 Subject: [llvm-commits] [zorg] r141406 - in /zorg/trunk/lnt: docs/tests.rst lnt/tests/nt.py Message-ID: <20111007195518.ACFB33128018@llvm.org> Author: ddunbar Date: Fri Oct 7 14:55:18 2011 New Revision: 141406 URL: http://llvm.org/viewvc/llvm-project?rev=141406&view=rev Log: LNT/nt: Pass a few more parameters to the test module (for supporting tests that want to build code) and add documentation on the parameters passed to test modules. Modified: zorg/trunk/lnt/docs/tests.rst zorg/trunk/lnt/lnt/tests/nt.py Modified: zorg/trunk/lnt/docs/tests.rst URL: http://llvm.org/viewvc/llvm-project/zorg/trunk/lnt/docs/tests.rst?rev=141406&r1=141405&r2=141406&view=diff ============================================================================== --- zorg/trunk/lnt/docs/tests.rst (original) +++ zorg/trunk/lnt/docs/tests.rst Fri Oct 7 14:55:18 2011 @@ -157,5 +157,59 @@ passed the user configuration parameters for a test run and expected to return back the test results in the LNT native format. +Test modules are defined by providing a ``TestModule`` file in a subdirectory of +the ``LNTBased`` root directory inside the LLVM test-suite repository. The +``TestModule`` file is expected to be a well-formed Python module that provides +a ``test_class`` global variable which should be a subclass of the +``lnt.tests.nt.TestModule`` abstract base class. + +The test class should override the ``execute_test`` method which is passed an +options dictionary containg the NT user parameters which apply to test +execution, and the test should return the test results as a list of +``lnt.testing.TestSamples`` objects. + +The ``execute_test`` method is passed the following options which apply to how +tests should be executed: + + * ``THREADS`` - The number of parallel processes to run during testing. + + * ``BUILD_THREADS`` - The number of parallel processes to use while building + tests (if applicable). + +The method is passed the following options which specify how and whether tests +should be executed remotely. If any of these parameters are present then all are +guaranteed to be present. + + * ``REMOTE_HOST`` - The host name of the remote machine to execute tests on. + + * ``REMOTE_USER`` - The user to log in to the remote machine as. + + * ``REMOTE_PORT`` - The port to connect to the remote machine on. + + * ``REMOTE_CLIENT`` - The ``rsh`` compatible client to use to connect to the + remote machine with. + +The method is passed the following options which specify how to build the tests: + + * ``CC`` - The C compiler command to use. + + * ``CXX`` - The C++ compiler command to use. + + * ``CFLAGS`` - The compiler flags to use for building C code. + + * ``CXXFLAGS`` - The compiler flags to use for building C++ code. + +The method is passed the following optional parameters which specify the +environment to use for various commands: + + * ``COMPILE_ENVIRONMENT_OVERRIDES`` [optional] - If given, a ``env`` style list + of environment overrides to use when compiling. + + * ``LINK_ENVIRONMENT_OVERRIDES`` [optional] - If given, a ``env`` style list of + environment overrides to use when linking. + + * ``EXECUTION_ENVIRONMENT_OVERRIDES`` [optional] - If given, a ``env`` style list of + environment overrides to use when executing tests. + For more information, see the example tests in the LLVM test-suite repository under the ``LNT/Examples`` directory. Modified: zorg/trunk/lnt/lnt/tests/nt.py URL: http://llvm.org/viewvc/llvm-project/zorg/trunk/lnt/lnt/tests/nt.py?rev=141406&r1=141405&r2=141406&view=diff ============================================================================== --- zorg/trunk/lnt/lnt/tests/nt.py (original) +++ zorg/trunk/lnt/lnt/tests/nt.py Fri Oct 7 14:55:18 2011 @@ -13,7 +13,7 @@ import lnt.testing.util.compilers from lnt.testing.util.commands import note, warning, error, fatal -from lnt.testing.util.commands import capture, which +from lnt.testing.util.commands import capture, mkdir_p, which from lnt.testing.util.rcs import get_source_version ### @@ -46,6 +46,7 @@ # First, load the test module file. locals = globals = {} test_path = os.path.join(opts.test_suite_root, 'LNTBased', name) + test_obj_path = os.path.join(basedir, 'LNTBased', name) module_path = os.path.join(test_path, 'TestModule') module_file = open(module_path) try: @@ -63,9 +64,19 @@ except: fatal("unable to instantiate test class for: %r" % module_path) + if not isinstance(test_instance, TestModule): + fatal("invalid test class (expected lnt.tests.nt.TestModule " + "subclass) for: %r" % module_path) + + # Create the per test variables, and ensure the output directory exists. + variables = test_module_variables.copy() + variables['SRCROOT'] = test_path + variables['OBJROOT'] = test_obj_path + mkdir_p(test_obj_path) + # Execute the tests. try: - test_samples = test_instance.execute_test(test_module_variables) + test_samples = test_instance.execute_test(variables) except: info = traceback.format_exc() fatal("exception executing tests for: %r\n%s" % ( @@ -95,9 +106,10 @@ test_module_variables = { 'CC' : make_variables['TARGET_CC'], 'CXX' : make_variables['TARGET_CXX'], - 'CFLAGS' : make_variables['TARGET_FLAGS'], - 'CXXFLAGS' : make_variables['TARGET_FLAGS'], - 'OPTFLAGS' : make_variables['OPTFLAGS'] } + 'CFLAGS' : (make_variables['TARGET_FLAGS'] + ' ' + + make_variables['OPTFLAGS']), + 'CXXFLAGS' : (make_variables['TARGET_FLAGS'] + ' ' + + make_variables['OPTFLAGS']) } # Add the remote execution variables. if opts.remote: @@ -122,6 +134,11 @@ test_module_variables['EXECUTION_ENVIRONMENT_OVERRIDES'] = \ make_variables['EXECUTION_ENVIRONMENT_OVERRIDES'] + # We pass the test execution values as variables too, this might be better + # passed as actual arguments. + test_module_variables['THREADS'] = opts.threads + test_module_variables['BUILD_THREADS'] = opts.build_threads or opts.threads + return test_module_variables def execute_nt_tests(test_log, make_variables, basedir, opts): From daniel at zuster.org Fri Oct 7 14:55:21 2011 From: daniel at zuster.org (Daniel Dunbar) Date: Fri, 07 Oct 2011 19:55:21 -0000 Subject: [llvm-commits] [zorg] r141407 - /zorg/trunk/lnt/lnt/tests/nt.py Message-ID: <20111007195521.4A4B32A6C12D@llvm.org> Author: ddunbar Date: Fri Oct 7 14:55:21 2011 New Revision: 141407 URL: http://llvm.org/viewvc/llvm-project?rev=141407&view=rev Log: LNT/nt: Factor out scan_for_test_modules(), and properly support --only-test inside LNTBased test directories. - Also, by default don't include example test directories. Modified: zorg/trunk/lnt/lnt/tests/nt.py Modified: zorg/trunk/lnt/lnt/tests/nt.py URL: http://llvm.org/viewvc/llvm-project/zorg/trunk/lnt/lnt/tests/nt.py?rev=141407&r1=141406&r2=141407&view=diff ============================================================================== --- zorg/trunk/lnt/lnt/tests/nt.py (original) +++ zorg/trunk/lnt/lnt/tests/nt.py Fri Oct 7 14:55:21 2011 @@ -34,6 +34,31 @@ def timestamp(): return datetime.utcnow().strftime('%Y-%m-%d %H:%M:%S') +def scan_for_test_modules(opts): + base_modules_path = os.path.join(opts.test_suite_root, 'LNTBased') + if opts.only_test is None: + test_modules_path = base_modules_path + elif opts.only_test.startswith('LNTBased'): + test_modules_path = os.path.join(opts.test_suite_root, opts.only_test) + else: + return + + for dirpath,dirnames,filenames in os.walk(test_modules_path): + # Ignore the example tests, unless requested. + if not opts.include_test_examples and 'Examples' in dirnames: + dirnames.remove('Examples') + + # Check if this directory defines a test module. + if 'TestModule' not in filenames: + continue + + # If so, don't traverse any lower. + del dirnames[:] + + # Add to the list of test modules. + assert dirpath.startswith(base_modules_path + '/') + yield dirpath[len(base_modules_path) + 1:] + def execute_test_modules(test_log, test_modules, test_module_variables, basedir, opts): # For now, we don't execute these in parallel, but we do forward the @@ -510,14 +535,7 @@ # Scan for LNT-based test modules. print >>sys.stderr, "%s: scanning for LNT-based test modules" % ( timestamp(),) - test_modules = [] - test_modules_path = os.path.join(opts.test_suite_root, 'LNTBased') - for dirpath,dirnames,filenames in os.walk(test_modules_path): - if 'TestModule' not in filenames: - continue - - assert dirpath.startswith(test_modules_path + '/') - test_modules.append(dirpath[len(test_modules_path) + 1:]) + test_modules = list(scan_for_test_modules(opts)) print >>sys.stderr, "%s: found %d LNT-based test modules" % ( timestamp(), len(test_modules)) @@ -968,6 +986,10 @@ group.add_option("", "--only-test", dest="only_test", metavar="PATH", help="Only run tests under PATH", type=str, default=None) + group.add_option("", "--include-test-examples", + dest="include_test_examples", + help="Include test module examples [%default]", + action="store_true", default=False) parser.add_option_group(group) group = OptionGroup(parser, "Test Execution") From daniel at zuster.org Fri Oct 7 14:55:13 2011 From: daniel at zuster.org (Daniel Dunbar) Date: Fri, 07 Oct 2011 19:55:13 -0000 Subject: [llvm-commits] [zorg] r141404 - /zorg/trunk/lnt/lnt/testing/util/commands.py Message-ID: <20111007195513.563FA312800A@llvm.org> Author: ddunbar Date: Fri Oct 7 14:55:13 2011 New Revision: 141404 URL: http://llvm.org/viewvc/llvm-project?rev=141404&view=rev Log: lnt.testing.util.commands: Add an mkdir_p utility command. Modified: zorg/trunk/lnt/lnt/testing/util/commands.py Modified: zorg/trunk/lnt/lnt/testing/util/commands.py URL: http://llvm.org/viewvc/llvm-project/zorg/trunk/lnt/lnt/testing/util/commands.py?rev=141404&r1=141403&r2=141404&view=diff ============================================================================== --- zorg/trunk/lnt/lnt/testing/util/commands.py (original) +++ zorg/trunk/lnt/lnt/testing/util/commands.py Fri Oct 7 14:55:13 2011 @@ -31,6 +31,25 @@ if e.errno != errno.ENOENT: raise +def mkdir_p(path): + """mkdir_p(path) - Make the "path" directory, if it does not exist; this + will also make directories for any missing parent directories.""" + import errno + + if not path or os.path.exists(path): + return + + parent = os.path.dirname(path) + if parent != path: + mkdir_p(parent) + + try: + os.mkdir(path) + except OSError,e: + # Ignore EEXIST, which may occur during a race condition. + if e.errno != errno.EEXIST: + raise + def capture(args, include_stderr=False): import subprocess """capture(command) - Run the given command (or argv list) in a shell and From stoklund at 2pi.dk Fri Oct 7 15:15:54 2011 From: stoklund at 2pi.dk (Jakob Stoklund Olesen) Date: Fri, 07 Oct 2011 20:15:54 -0000 Subject: [llvm-commits] [llvm] r141410 - in /llvm/trunk/lib/Target/X86: X86InstrExtension.td X86InstrInfo.cpp Message-ID: <20111007201554.BD5093128018@llvm.org> Author: stoklund Date: Fri Oct 7 15:15:54 2011 New Revision: 141410 URL: http://llvm.org/viewvc/llvm-project?rev=141410&view=rev Log: Constrain both operands on MOVZX32_NOREXrr8. This instruction is explicitly encoded without an REX prefix, so both operands but be *_NOREX. Also add an assertion to copyPhysReg() that fires when the MOV8rr_NOREX constraints are not satisfied. This fixes a miscompilation in 20040709-2 in the gcc test suite. Modified: llvm/trunk/lib/Target/X86/X86InstrExtension.td llvm/trunk/lib/Target/X86/X86InstrInfo.cpp Modified: llvm/trunk/lib/Target/X86/X86InstrExtension.td URL: http://llvm.org/viewvc/llvm-project/llvm/trunk/lib/Target/X86/X86InstrExtension.td?rev=141410&r1=141409&r2=141410&view=diff ============================================================================== --- llvm/trunk/lib/Target/X86/X86InstrExtension.td (original) +++ llvm/trunk/lib/Target/X86/X86InstrExtension.td Fri Oct 7 15:15:54 2011 @@ -76,12 +76,12 @@ // except that they use GR32_NOREX for the output operand register class // instead of GR32. This allows them to operate on h registers on x86-64. def MOVZX32_NOREXrr8 : I<0xB6, MRMSrcReg, - (outs GR32_NOREX:$dst), (ins GR8:$src), + (outs GR32_NOREX:$dst), (ins GR8_NOREX:$src), "movz{bl|x}\t{$src, $dst|$dst, $src}", []>, TB; let mayLoad = 1 in def MOVZX32_NOREXrm8 : I<0xB6, MRMSrcMem, - (outs GR32_NOREX:$dst), (ins i8mem:$src), + (outs GR32_NOREX:$dst), (ins i8mem_NOREX:$src), "movz{bl|x}\t{$src, $dst|$dst, $src}", []>, TB; Modified: llvm/trunk/lib/Target/X86/X86InstrInfo.cpp URL: http://llvm.org/viewvc/llvm-project/llvm/trunk/lib/Target/X86/X86InstrInfo.cpp?rev=141410&r1=141409&r2=141410&view=diff ============================================================================== --- llvm/trunk/lib/Target/X86/X86InstrInfo.cpp (original) +++ llvm/trunk/lib/Target/X86/X86InstrInfo.cpp Fri Oct 7 15:15:54 2011 @@ -2189,9 +2189,12 @@ // Copying to or from a physical H register on x86-64 requires a NOREX // move. Otherwise use a normal move. if ((isHReg(DestReg) || isHReg(SrcReg)) && - TM.getSubtarget().is64Bit()) + TM.getSubtarget().is64Bit()) { Opc = X86::MOV8rr_NOREX; - else + // Both operands must be encodable without an REX prefix. + assert(X86::GR8_NOREXRegClass.contains(SrcReg, DestReg) && + "8-bit H register can not be copied outside GR8_NOREX"); + } else Opc = X86::MOV8rr; } else if (X86::VR128RegClass.contains(DestReg, SrcReg)) Opc = HasAVX ? X86::VMOVAPSrr : X86::MOVAPSrr; From nicholas at mxc.ca Fri Oct 7 15:56:23 2011 From: nicholas at mxc.ca (Nick Lewycky) Date: Fri, 07 Oct 2011 20:56:23 -0000 Subject: [llvm-commits] [llvm] r141412 - /llvm/trunk/lib/MC/ELFObjectWriter.cpp Message-ID: <20111007205623.9F0782A6C12D@llvm.org> Author: nicholas Date: Fri Oct 7 15:56:23 2011 New Revision: 141412 URL: http://llvm.org/viewvc/llvm-project?rev=141412&view=rev Log: Clarify/fix typo. No functionality change. Modified: llvm/trunk/lib/MC/ELFObjectWriter.cpp Modified: llvm/trunk/lib/MC/ELFObjectWriter.cpp URL: http://llvm.org/viewvc/llvm-project/llvm/trunk/lib/MC/ELFObjectWriter.cpp?rev=141412&r1=141411&r2=141412&view=diff ============================================================================== --- llvm/trunk/lib/MC/ELFObjectWriter.cpp (original) +++ llvm/trunk/lib/MC/ELFObjectWriter.cpp Fri Oct 7 15:56:23 2011 @@ -125,7 +125,7 @@ // e_shnum = # of section header ents if (NumberOfSections >= ELF::SHN_LORESERVE) - Write16(0); + Write16(ELF::SHN_UNDEF); else Write16(NumberOfSections); @@ -1233,7 +1233,7 @@ FileOff = OS.tell(); - // ... and then the remainting sections ... + // ... and then the remaining sections ... for (unsigned i = NumRegularSections + 1; i < NumSections; ++i) WriteDataSectionData(Asm, Layout, *Sections[i]); } From nicholas at mxc.ca Fri Oct 7 15:58:24 2011 From: nicholas at mxc.ca (Nick Lewycky) Date: Fri, 07 Oct 2011 20:58:24 -0000 Subject: [llvm-commits] [llvm] r141413 - /llvm/trunk/lib/MC/ELFObjectWriter.cpp Message-ID: <20111007205824.6F9EF3128018@llvm.org> Author: nicholas Date: Fri Oct 7 15:58:24 2011 New Revision: 141413 URL: http://llvm.org/viewvc/llvm-project?rev=141413&view=rev Log: Don't emit a shstrtabindex in the reserved range. Spotted by inspection and patch by Cary Coutant! Modified: llvm/trunk/lib/MC/ELFObjectWriter.cpp Modified: llvm/trunk/lib/MC/ELFObjectWriter.cpp URL: http://llvm.org/viewvc/llvm-project/llvm/trunk/lib/MC/ELFObjectWriter.cpp?rev=141413&r1=141412&r2=141413&view=diff ============================================================================== --- llvm/trunk/lib/MC/ELFObjectWriter.cpp (original) +++ llvm/trunk/lib/MC/ELFObjectWriter.cpp Fri Oct 7 15:58:24 2011 @@ -130,7 +130,7 @@ Write16(NumberOfSections); // e_shstrndx = Section # of '.shstrtab' - if (NumberOfSections >= ELF::SHN_LORESERVE) + if (ShstrtabIndex >= ELF::SHN_LORESERVE) Write16(ELF::SHN_XINDEX); else Write16(ShstrtabIndex); From krasin at google.com Fri Oct 7 16:00:29 2011 From: krasin at google.com (Ivan Krasin) Date: Fri, 7 Oct 2011 14:00:29 -0700 Subject: [llvm-commits] arm mc: fix relocation of an alias to an alias In-Reply-To: <8AE16CFC-D9D4-431B-9716-C8493971AEF0@apple.com> References: <8AE16CFC-D9D4-431B-9716-C8493971AEF0@apple.com> Message-ID: Nick, could you please take a quick look? I see your recent change to this file. On Fri, Oct 7, 2011 at 9:49 AM, Jim Grosbach wrote: > This looks OK to me, but I'd really like if someone more familiar with the ELF bits would review the details. > > -Jim > > On Oct 5, 2011, at 5:33 PM, Ivan Krasin wrote: > >> Hi llvm team! >> >> The patch attached fixes the problem that >> ARMELFObjectWriter::ExplicitRelSym didn't resolve aliases. >> For some reason, the single alias works just fine, but the alias to >> alias crashes llc with the following message: >> >> llc: /usr/local/google/home/krasin/llvm/include/llvm/MC/MCSymbol.h:111: >> const llvm::MCSection &llvm::MCSymbol::getSection() const: Assertion >> `isInSection() && "Invalid accessor!"' failed. >> >> The full background of this issue is available here: >> http://code.google.com/p/nativeclient/issues/detail?id=2340 >> >> OK to commit? >> >> krasin >> _______________________________________________ >> llvm-commits mailing list >> llvm-commits at cs.uiuc.edu >> http://lists.cs.uiuc.edu/mailman/listinfo/llvm-commits > > From isanbard at gmail.com Fri Oct 7 16:25:38 2011 From: isanbard at gmail.com (Bill Wendling) Date: Fri, 07 Oct 2011 21:25:38 -0000 Subject: [llvm-commits] [llvm] r141416 - in /llvm/trunk: include/llvm/CodeGen/ISDOpcodes.h lib/CodeGen/SelectionDAG/SelectionDAGBuilder.cpp lib/Target/ARM/ARMISelLowering.cpp Message-ID: <20111007212538.4A6653128018@llvm.org> Author: void Date: Fri Oct 7 16:25:38 2011 New Revision: 141416 URL: http://llvm.org/viewvc/llvm-project?rev=141416&view=rev Log: Thread the chain through the eh.sjlj.setjmp intrinsic, like it's documented to do. This will be useful later on with the new SJLJ stuff. Modified: llvm/trunk/include/llvm/CodeGen/ISDOpcodes.h llvm/trunk/lib/CodeGen/SelectionDAG/SelectionDAGBuilder.cpp llvm/trunk/lib/Target/ARM/ARMISelLowering.cpp Modified: llvm/trunk/include/llvm/CodeGen/ISDOpcodes.h URL: http://llvm.org/viewvc/llvm-project/llvm/trunk/include/llvm/CodeGen/ISDOpcodes.h?rev=141416&r1=141415&r2=141416&view=diff ============================================================================== --- llvm/trunk/include/llvm/CodeGen/ISDOpcodes.h (original) +++ llvm/trunk/include/llvm/CodeGen/ISDOpcodes.h Fri Oct 7 16:25:38 2011 @@ -95,7 +95,7 @@ // execution to HANDLER. Many platform-related details also :) EH_RETURN, - // OUTCHAIN = EH_SJLJ_SETJMP(INCHAIN, buffer) + // RESULT, OUTCHAIN = EH_SJLJ_SETJMP(INCHAIN, buffer) // This corresponds to the eh.sjlj.setjmp intrinsic. // It takes an input chain and a pointer to the jump buffer as inputs // and returns an outchain. Modified: llvm/trunk/lib/CodeGen/SelectionDAG/SelectionDAGBuilder.cpp URL: http://llvm.org/viewvc/llvm-project/llvm/trunk/lib/CodeGen/SelectionDAG/SelectionDAGBuilder.cpp?rev=141416&r1=141415&r2=141416&view=diff ============================================================================== --- llvm/trunk/lib/CodeGen/SelectionDAG/SelectionDAGBuilder.cpp (original) +++ llvm/trunk/lib/CodeGen/SelectionDAG/SelectionDAGBuilder.cpp Fri Oct 7 16:25:38 2011 @@ -4744,8 +4744,14 @@ return 0; } case Intrinsic::eh_sjlj_setjmp: { - setValue(&I, DAG.getNode(ISD::EH_SJLJ_SETJMP, dl, MVT::i32, getRoot(), - getValue(I.getArgOperand(0)))); + SDValue Ops[2]; + Ops[0] = getRoot(); + Ops[1] = getValue(I.getArgOperand(0)); + SDValue Op = DAG.getNode(ISD::EH_SJLJ_SETJMP, dl, + DAG.getVTList(MVT::i32, MVT::Other), + Ops, 2); + setValue(&I, Op.getValue(0)); + DAG.setRoot(Op.getValue(1)); return 0; } case Intrinsic::eh_sjlj_longjmp: { Modified: llvm/trunk/lib/Target/ARM/ARMISelLowering.cpp URL: http://llvm.org/viewvc/llvm-project/llvm/trunk/lib/Target/ARM/ARMISelLowering.cpp?rev=141416&r1=141415&r2=141416&view=diff ============================================================================== --- llvm/trunk/lib/Target/ARM/ARMISelLowering.cpp (original) +++ llvm/trunk/lib/Target/ARM/ARMISelLowering.cpp Fri Oct 7 16:25:38 2011 @@ -2210,7 +2210,8 @@ ARMTargetLowering::LowerEH_SJLJ_SETJMP(SDValue Op, SelectionDAG &DAG) const { DebugLoc dl = Op.getDebugLoc(); SDValue Val = DAG.getConstant(0, MVT::i32); - return DAG.getNode(ARMISD::EH_SJLJ_SETJMP, dl, MVT::i32, Op.getOperand(0), + return DAG.getNode(ARMISD::EH_SJLJ_SETJMP, dl, + DAG.getVTList(MVT::i32, MVT::Other), Op.getOperand(0), Op.getOperand(1), Val); } From nlewycky at google.com Fri Oct 7 16:32:05 2011 From: nlewycky at google.com (Nick Lewycky) Date: Fri, 7 Oct 2011 14:32:05 -0700 Subject: [llvm-commits] arm mc: fix relocation of an alias to an alias In-Reply-To: References: <8AE16CFC-D9D4-431B-9716-C8493971AEF0@apple.com> Message-ID: On 7 October 2011 14:00, Ivan Krasin wrote: > Nick, > > could you please take a quick look? I see your recent change to this file. > It's not clear to me that this is correct. Aliases can be weak and you shouldn't follow them if they are. (And the IR-level optimizers should probably be folding away aliases that are marked 'internal', so there's no sense doing it here.) Nick On Fri, Oct 7, 2011 at 9:49 AM, Jim Grosbach wrote: > > This looks OK to me, but I'd really like if someone more familiar with > the ELF bits would review the details. > > > > -Jim > > > > On Oct 5, 2011, at 5:33 PM, Ivan Krasin wrote: > > > >> Hi llvm team! > >> > >> The patch attached fixes the problem that > >> ARMELFObjectWriter::ExplicitRelSym didn't resolve aliases. > >> For some reason, the single alias works just fine, but the alias to > >> alias crashes llc with the following message: > >> > >> llc: /usr/local/google/home/krasin/llvm/include/llvm/MC/MCSymbol.h:111: > >> const llvm::MCSection &llvm::MCSymbol::getSection() const: Assertion > >> `isInSection() && "Invalid accessor!"' failed. > >> > >> The full background of this issue is available here: > >> http://code.google.com/p/nativeclient/issues/detail?id=2340 > >> > >> OK to commit? > >> > >> krasin > >> > _______________________________________________ > >> llvm-commits mailing list > >> llvm-commits at cs.uiuc.edu > >> http://lists.cs.uiuc.edu/mailman/listinfo/llvm-commits > > > > > -------------- next part -------------- An HTML attachment was scrubbed... URL: http://lists.cs.uiuc.edu/pipermail/llvm-commits/attachments/20111007/46e73b03/attachment.html From anton at korobeynikov.info Fri Oct 7 16:37:20 2011 From: anton at korobeynikov.info (Anton Korobeynikov) Date: Sat, 8 Oct 2011 01:37:20 +0400 Subject: [llvm-commits] arm mc: fix relocation of an alias to an alias In-Reply-To: References: <8AE16CFC-D9D4-431B-9716-C8493971AEF0@apple.com> Message-ID: Hi Ivan, > could you please take a quick look? I see your recent change to this file. Patch generally looks ok for me as well. Does it handle "complex" aliases, e.g. when alias is gep of the aliasee? How such aliases are represented? Thanks! -- With best regards, Anton Korobeynikov Faculty of Mathematics and Mechanics, Saint Petersburg State University From apazos at codeaurora.org Fri Oct 7 16:39:16 2011 From: apazos at codeaurora.org (Ana Pazos) Date: Fri, 7 Oct 2011 14:39:16 -0700 Subject: [llvm-commits] [llvm] r141365 - in /llvm/trunk: lib/Target/ARM/ARMISelDAGToDAG.cpp lib/Target/ARM/ARMISelLowering.cpp lib/Target/ARM/ARMInstrInfo.td lib/Target/ARM/ARMInstrThumb2.td test/CodeGen/ARM/iabs.ll test/CodeGen/Thumb/iabs.ll In-Reply-To: <6144A303-F54E-4A0F-B69D-DB9B94037F47@apple.com> References: <20111007161509.46571312800A@llvm.org> <5751F138-40A5-4245-840D-D24DC0D54194@apple.com> <40E1F4C6-5513-4B4C-BF3F-053162FD213D@apple.com> <6144A303-F54E-4A0F-B69D-DB9B94037F47@apple.com> Message-ID: <000001cc8539$8fef3370$afcd9a50$@org> Hi Anton and Eric, I tried to reproduce the issue with the latest LLVM code and compile-rt tests. The file floatsidf.c compiled fine. This is command line I used: clang -c -ccc-host-triple armv6-none-linux-gnueabi -mfloat-abi=softfp -integrated-as -O3 -o floatsidf.o floatsidf.c What is your command line? Did you set any other flags? Disassembled floatsidf.o file: 00000000 <__aeabi_i2d>: 0: e92d4800 push {fp, lr} 4: e3500000 cmp r0, #0 8: 1a000002 bne 18 <__aeabi_i2d+0x18> c: ed9f0b16 vldr d0, [pc, #88] ; 6c <__aeabi_i2d+0x6c> 10: ec510b10 vmov r0, r1, d0 14: e8bd8800 pop {fp, pc} 18: e1b01000 movs r1, r0 1c: e2000102 and r0, r0, #-2147483648 ; 0x80000000 20: 42611000 rsbmi r1, r1, #0 24: e16fef11 clz lr, r1 28: e26e301f rsb r3, lr, #31 2c: e263c034 rsb ip, r3, #52 ; 0x34 30: e26c2020 rsb r2, ip, #32 34: e2633014 rsb r3, r3, #20 38: e3530000 cmp r3, #0 3c: e1a02231 lsr r2, r1, r2 40: a1a02311 lslge r2, r1, r3 44: e3a0301e mov r3, #30 48: e3833b01 orr r3, r3, #1024 ; 0x400 4c: e043300e sub r3, r3, lr 50: e2222601 eor r2, r2, #1048576 ; 0x100000 54: e0822a03 add r2, r2, r3, lsl #20 58: e1a01c11 lsl r1, r1, ip 5c: e1820000 orr r0, r2, r0 60: ec401b10 vmov d0, r1, r0 64: ec510b10 vmov r0, r1, d0 68: e8bd8800 pop {fp, pc} Note: from floatsidf.i file: void __aeabi_i2d() __attribute__((alias("__" "floatsidf")));; Thanks, Ana. -- Qualcomm Innovation Center, Inc is a member of Code Aurora Forum -----Original Message----- From: llvm-commits-bounces at cs.uiuc.edu [mailto:llvm-commits-bounces at cs.uiuc.edu] On Behalf Of Eric Christopher Sent: Friday, October 07, 2011 11:57 AM To: Anton Korobeynikov Cc: llvm-commits at cs.uiuc.edu Subject: Re: [llvm-commits] [llvm] r141365 - in /llvm/trunk: lib/Target/ARM/ARMISelDAGToDAG.cpp lib/Target/ARM/ARMISelLowering.cpp lib/Target/ARM/ARMInstrInfo.td lib/Target/ARM/ARMInstrThumb2.td test/CodeGen/ARM/iabs.ll test/CodeGen/Thumb/iabs.ll On Oct 7, 2011, at 11:52 AM, Anton Korobeynikov wrote: > Hi Eric, > >> llvm/projects/compiler-rt/lib/floatsidf.c >> compiled with ToT clang. > Which mode? ARM? Thumb2? Thumb1? For which ARM arch? compiler-rt has > many different modes :) armv6 it looks like :) COMPILE: clang_darwin/cc_kext/armv6: /Volumes/Data/sources/llvm/projects/compiler-rt/lib/floatsidf.c /var/folders/9p/2n1d124n1fd9bvkb815y0j6r0000gp/T/floatsidf-TXq5db.s:19:canno t honor width suffix -- `rsb r0,r0,#0' clang: error: assembler command failed with exit code 1 (use -v to see invocation) -eric _______________________________________________ llvm-commits mailing list llvm-commits at cs.uiuc.edu http://lists.cs.uiuc.edu/mailman/listinfo/llvm-commits From anton at korobeynikov.info Fri Oct 7 16:40:07 2011 From: anton at korobeynikov.info (Anton Korobeynikov) Date: Sat, 8 Oct 2011 01:40:07 +0400 Subject: [llvm-commits] arm mc: fix relocation of an alias to an alias In-Reply-To: References: <8AE16CFC-D9D4-431B-9716-C8493971AEF0@apple.com> Message-ID: > It's not clear to me that this is correct. Aliases can be weak and you > shouldn't follow them if they are. Good point > (And the IR-level optimizers should > probably be folding away aliases that are marked 'internal', so there's no > sense doing it here.) We did this once during codegen, but after MC-ization we don't do. -- With best regards, Anton Korobeynikov Faculty of Mathematics and Mechanics, Saint Petersburg State University From krasin at google.com Fri Oct 7 16:42:08 2011 From: krasin at google.com (Ivan Krasin) Date: Fri, 7 Oct 2011 14:42:08 -0700 Subject: [llvm-commits] arm mc: fix relocation of an alias to an alias In-Reply-To: References: <8AE16CFC-D9D4-431B-9716-C8493971AEF0@apple.com> Message-ID: On Fri, Oct 7, 2011 at 2:32 PM, Nick Lewycky wrote: > On 7 October 2011 14:00, Ivan Krasin wrote: >> >> Nick, >> >> could you please take a quick look? I see your recent change to this file. > > It's not clear to me that this is correct. Aliases can be weak and you > shouldn't follow them if they are. If I don't follow them, llc will crash. (And the IR-level optimizers should > probably be folding away aliases that are marked 'internal', so there's no > sense doing it here.) Sorry, I have not got the point. At this stage ELF file is being emitted. There's no IR-level optimizers ahead. Could you please explain it a little bit? > Nick >> >> On Fri, Oct 7, 2011 at 9:49 AM, Jim Grosbach wrote: >> > This looks OK to me, but I'd really like if someone more familiar with >> > the ELF bits would review the details. >> > >> > -Jim >> > >> > On Oct 5, 2011, at 5:33 PM, Ivan Krasin wrote: >> > >> >> Hi llvm team! >> >> >> >> The patch attached fixes the problem that >> >> ARMELFObjectWriter::ExplicitRelSym didn't resolve aliases. >> >> For some reason, the single alias works just fine, but the alias to >> >> alias crashes llc with the following message: >> >> >> >> llc: /usr/local/google/home/krasin/llvm/include/llvm/MC/MCSymbol.h:111: >> >> const llvm::MCSection &llvm::MCSymbol::getSection() const: Assertion >> >> `isInSection() && "Invalid accessor!"' failed. >> >> >> >> The full background of this issue is available here: >> >> http://code.google.com/p/nativeclient/issues/detail?id=2340 >> >> >> >> OK to commit? >> >> >> >> krasin >> >> >> >> _______________________________________________ >> >> llvm-commits mailing list >> >> llvm-commits at cs.uiuc.edu >> >> http://lists.cs.uiuc.edu/mailman/listinfo/llvm-commits >> > >> > > > From krasin at google.com Fri Oct 7 16:43:02 2011 From: krasin at google.com (Ivan Krasin) Date: Fri, 7 Oct 2011 14:43:02 -0700 Subject: [llvm-commits] arm mc: fix relocation of an alias to an alias In-Reply-To: References: <8AE16CFC-D9D4-431B-9716-C8493971AEF0@apple.com> Message-ID: On Fri, Oct 7, 2011 at 2:37 PM, Anton Korobeynikov wrote: > Hi Ivan, > >> could you please take a quick look? I see your recent change to this file. > Patch generally looks ok for me as well. Does it handle "complex" > aliases, e.g. when alias is gep of the aliasee? How such aliases are > represented? I will add more cases for different kinds of aliases to the test. Thanks for the suggestion! > > Thanks! > > -- > With best regards, Anton Korobeynikov > Faculty of Mathematics and Mechanics, Saint Petersburg State University > From krasin at google.com Fri Oct 7 16:44:26 2011 From: krasin at google.com (Ivan Krasin) Date: Fri, 7 Oct 2011 14:44:26 -0700 Subject: [llvm-commits] arm mc: fix relocation of an alias to an alias In-Reply-To: References: <8AE16CFC-D9D4-431B-9716-C8493971AEF0@apple.com> Message-ID: On Fri, Oct 7, 2011 at 2:42 PM, Ivan Krasin wrote: > On Fri, Oct 7, 2011 at 2:32 PM, Nick Lewycky wrote: >> On 7 October 2011 14:00, Ivan Krasin wrote: >>> >>> Nick, >>> >>> could you please take a quick look? I see your recent change to this file. >> >> It's not clear to me that this is correct. Aliases can be weak and you >> shouldn't follow them if they are. > If I don't follow them, llc will crash. I mean, that probably, there's another issue here, not related to what I'm trying to fix. Anyway, I will add weak alias test case as well, and we'll see what happens there. > (And the IR-level optimizers should >> probably be folding away aliases that are marked 'internal', so there's no >> sense doing it here.) > Sorry, I have not got the point. At this stage ELF file is being > emitted. There's no IR-level optimizers ahead. Could you please > explain it a little bit? > >> Nick >>> >>> On Fri, Oct 7, 2011 at 9:49 AM, Jim Grosbach wrote: >>> > This looks OK to me, but I'd really like if someone more familiar with >>> > the ELF bits would review the details. >>> > >>> > -Jim >>> > >>> > On Oct 5, 2011, at 5:33 PM, Ivan Krasin wrote: >>> > >>> >> Hi llvm team! >>> >> >>> >> The patch attached fixes the problem that >>> >> ARMELFObjectWriter::ExplicitRelSym didn't resolve aliases. >>> >> For some reason, the single alias works just fine, but the alias to >>> >> alias crashes llc with the following message: >>> >> >>> >> llc: /usr/local/google/home/krasin/llvm/include/llvm/MC/MCSymbol.h:111: >>> >> const llvm::MCSection &llvm::MCSymbol::getSection() const: Assertion >>> >> `isInSection() && "Invalid accessor!"' failed. >>> >> >>> >> The full background of this issue is available here: >>> >> http://code.google.com/p/nativeclient/issues/detail?id=2340 >>> >> >>> >> OK to commit? >>> >> >>> >> krasin >>> >> >>> >> _______________________________________________ >>> >> llvm-commits mailing list >>> >> llvm-commits at cs.uiuc.edu >>> >> http://lists.cs.uiuc.edu/mailman/listinfo/llvm-commits >>> > >>> > >> >> > From eli.friedman at gmail.com Fri Oct 7 16:44:43 2011 From: eli.friedman at gmail.com (Eli Friedman) Date: Fri, 7 Oct 2011 14:44:43 -0700 Subject: [llvm-commits] [llvm] r141365 - in /llvm/trunk: lib/Target/ARM/ARMISelDAGToDAG.cpp lib/Target/ARM/ARMISelLowering.cpp lib/Target/ARM/ARMInstrInfo.td lib/Target/ARM/ARMInstrThumb2.td test/CodeGen/ARM/iabs.ll test/CodeGen/Thumb/iabs.ll In-Reply-To: <000001cc8539$8fef3370$afcd9a50$@org> References: <20111007161509.46571312800A@llvm.org> <5751F138-40A5-4245-840D-D24DC0D54194@apple.com> <40E1F4C6-5513-4B4C-BF3F-053162FD213D@apple.com> <6144A303-F54E-4A0F-B69D-DB9B94037F47@apple.com> <000001cc8539$8fef3370$afcd9a50$@org> Message-ID: On Fri, Oct 7, 2011 at 2:39 PM, Ana Pazos wrote: > Hi Anton and Eric, > > I tried to reproduce the issue with the latest LLVM code and compile-rt > tests. > > The file floatsidf.c compiled fine. > > This is command line I used: > clang -c -ccc-host-triple armv6-none-linux-gnueabi -mfloat-abi=softfp > -integrated-as -O3 -o floatsidf.o floatsidf.c > > What is your command line? Did you set any other flags? Try adding -mthumb. -Eli From echristo at apple.com Fri Oct 7 16:45:48 2011 From: echristo at apple.com (Eric Christopher) Date: Fri, 07 Oct 2011 14:45:48 -0700 Subject: [llvm-commits] [llvm] r141365 - in /llvm/trunk: lib/Target/ARM/ARMISelDAGToDAG.cpp lib/Target/ARM/ARMISelLowering.cpp lib/Target/ARM/ARMInstrInfo.td lib/Target/ARM/ARMInstrThumb2.td test/CodeGen/ARM/iabs.ll test/CodeGen/Thumb/iabs.ll In-Reply-To: <000001cc8539$8fef3370$afcd9a50$@org> References: <20111007161509.46571312800A@llvm.org> <5751F138-40A5-4245-840D-D24DC0D54194@apple.com> <40E1F4C6-5513-4B4C-BF3F-053162FD213D@apple.com> <6144A303-F54E-4A0F-B69D-DB9B94037F47@apple.com> <000001cc8539$8fef3370$afcd9a50$@org> Message-ID: <37126EFD-F15A-4B00-A1BD-D3B527C5F88E@apple.com> Given that you're targeting a different OS and triple I'm not surprised it didn't work. :) You may want to try using -mthumb, or here's the command line and output I gave to Anton earlier: [yendi:Data/builds/build-llvm] echristo% /Volumes/Data/builds/build-llvm/Debug+Asserts/bin/clang -no-integrated-as -ccc-install-dir /Developer/Platforms/iPhoneOS.platform/Developer/usr/bin/ -arch armv6 -fvisibility=hidden -DVISIBILITY_HIDDEN -mkernel -DKERNEL_USE -Wall -Werror -O3 -fomit-frame-pointer -miphoneos-version-min=1.0 -mthumb -c -o /Volumes/Data/builds/build-llvm/tools/clang/runtime/compiler-rt/clang_darwin/cc_kext/armv6/SubDir.lib/floatsidf.o /Volumes/Data/sources/llvm/projects/compiler-rt/lib/floatsidf.c -v clang version 3.0 (trunk 141374) Target: arm-apple-darwin11.2.0 Thread model: posix "/Volumes/Data/builds/build-llvm/Debug+Asserts/bin/clang" -cc1 -triple thumbv6-apple-ios1.0.0 -S -disable-free -main-file-name floatsidf.c -static-define -mrelocation-model static -fforbid-guard-variables -target-abi apcs-gnu -target-cpu arm1136jf-s -mfloat-abi soft -target-feature +soft-float-abi -backend-option -arm-long-calls -backend-option -arm-strict-align -backend-option -arm-darwin-use-movt=0 -target-linker-version 127.2 -v -coverage-file /var/folders/9p/2n1d124n1fd9bvkb815y0j6r0000gp/T/floatsidf-DlaN0M.s -resource-dir /Volumes/Data/builds/build-llvm/Debug+Asserts/bin/../lib/clang/3.0 -D VISIBILITY_HIDDEN -D KERNEL_USE -fmodule-cache-path /var/folders/9p/2n1d124n1fd9bvkb815y0j6r0000gp/T/clang-module-cache -O3 -Wall -Werror -fno-dwarf2-cfi-asm -ferror-limit 19 -fmessage-length 80 -fvisibility hidden -ffreestanding -fno-builtin -fblocks -fblocks-runtime-optional -fno-rtti -fno-use-cxa-atexit -fsjlj-exceptions -fno-common -fdiagnostics-show-option -fcolor-diagnostics -o /var/folders/9p/2n1d124n1fd9bvkb815y0j6r0000gp/T/floatsidf-DlaN0M.s -x c /Volumes/Data/sources/llvm/projects/compiler-rt/lib/floatsidf.c clang -cc1 version 3.0 based upon llvm 3.0svn hosted on x86_64-apple-darwin11.2.0 #include "..." search starts here: #include <...> search starts here: /usr/local/include /Volumes/Data/builds/build-llvm/Debug+Asserts/bin/../lib/clang/3.0/include /usr/include /System/Library/Frameworks (framework directory) /Library/Frameworks (framework directory) End of search list. "/Developer/Platforms/iPhoneOS.platform/Developer/usr/bin/as" -arch armv6 -static -o /Volumes/Data/builds/build-llvm/tools/clang/runtime/compiler-rt/clang_darwin/cc_kext/armv6/SubDir.lib/floatsidf.o /var/folders/9p/2n1d124n1fd9bvkb815y0j6r0000gp/T/floatsidf-DlaN0M.s /var/folders/9p/2n1d124n1fd9bvkb815y0j6r0000gp/T/floatsidf-DlaN0M.s:19:cannot honor width suffix -- `rsb r0,r0,#0' clang: error: assembler command failed with exit code 1 (use -v to see invocation) which definitely duplicates the problem. -eric On Oct 7, 2011, at 2:39 PM, Ana Pazos wrote: > Hi Anton and Eric, > > I tried to reproduce the issue with the latest LLVM code and compile-rt > tests. > > The file floatsidf.c compiled fine. > > This is command line I used: > clang -c -ccc-host-triple armv6-none-linux-gnueabi -mfloat-abi=softfp > -integrated-as -O3 -o floatsidf.o floatsidf.c > > What is your command line? Did you set any other flags? > > > Disassembled floatsidf.o file: > 00000000 <__aeabi_i2d>: > 0: e92d4800 push {fp, lr} > 4: e3500000 cmp r0, #0 > 8: 1a000002 bne 18 <__aeabi_i2d+0x18> > c: ed9f0b16 vldr d0, [pc, #88] ; 6c <__aeabi_i2d+0x6c> > 10: ec510b10 vmov r0, r1, d0 > 14: e8bd8800 pop {fp, pc} > 18: e1b01000 movs r1, r0 > 1c: e2000102 and r0, r0, #-2147483648 ; 0x80000000 > 20: 42611000 rsbmi r1, r1, #0 > 24: e16fef11 clz lr, r1 > 28: e26e301f rsb r3, lr, #31 > 2c: e263c034 rsb ip, r3, #52 ; 0x34 > 30: e26c2020 rsb r2, ip, #32 > 34: e2633014 rsb r3, r3, #20 > 38: e3530000 cmp r3, #0 > 3c: e1a02231 lsr r2, r1, r2 > 40: a1a02311 lslge r2, r1, r3 > 44: e3a0301e mov r3, #30 > 48: e3833b01 orr r3, r3, #1024 ; 0x400 > 4c: e043300e sub r3, r3, lr > 50: e2222601 eor r2, r2, #1048576 ; 0x100000 > 54: e0822a03 add r2, r2, r3, lsl #20 > 58: e1a01c11 lsl r1, r1, ip > 5c: e1820000 orr r0, r2, r0 > 60: ec401b10 vmov d0, r1, r0 > 64: ec510b10 vmov r0, r1, d0 > 68: e8bd8800 pop {fp, pc} > > Note: from floatsidf.i file: void __aeabi_i2d() __attribute__((alias("__" > "floatsidf")));; > > Thanks, > Ana. > -- > Qualcomm Innovation Center, Inc is a member of Code Aurora Forum > > > -----Original Message----- > From: llvm-commits-bounces at cs.uiuc.edu > [mailto:llvm-commits-bounces at cs.uiuc.edu] On Behalf Of Eric Christopher > Sent: Friday, October 07, 2011 11:57 AM > To: Anton Korobeynikov > Cc: llvm-commits at cs.uiuc.edu > Subject: Re: [llvm-commits] [llvm] r141365 - in /llvm/trunk: > lib/Target/ARM/ARMISelDAGToDAG.cpp lib/Target/ARM/ARMISelLowering.cpp > lib/Target/ARM/ARMInstrInfo.td lib/Target/ARM/ARMInstrThumb2.td > test/CodeGen/ARM/iabs.ll test/CodeGen/Thumb/iabs.ll > > > On Oct 7, 2011, at 11:52 AM, Anton Korobeynikov wrote: > >> Hi Eric, >> >>> llvm/projects/compiler-rt/lib/floatsidf.c >>> compiled with ToT clang. >> Which mode? ARM? Thumb2? Thumb1? For which ARM arch? compiler-rt has >> many different modes :) > > armv6 it looks like :) > > COMPILE: clang_darwin/cc_kext/armv6: > /Volumes/Data/sources/llvm/projects/compiler-rt/lib/floatsidf.c > > /var/folders/9p/2n1d124n1fd9bvkb815y0j6r0000gp/T/floatsidf-TXq5db.s:19:canno > t honor width suffix -- `rsb r0,r0,#0' > clang: error: assembler command failed with exit code 1 (use -v to see > invocation) > > > -eric > _______________________________________________ > llvm-commits mailing list > llvm-commits at cs.uiuc.edu > http://lists.cs.uiuc.edu/mailman/listinfo/llvm-commits > From anton at korobeynikov.info Fri Oct 7 16:47:50 2011 From: anton at korobeynikov.info (Anton Korobeynikov) Date: Sat, 8 Oct 2011 01:47:50 +0400 Subject: [llvm-commits] [llvm] r141365 - in /llvm/trunk: lib/Target/ARM/ARMISelDAGToDAG.cpp lib/Target/ARM/ARMISelLowering.cpp lib/Target/ARM/ARMInstrInfo.td lib/Target/ARM/ARMInstrThumb2.td test/CodeGen/ARM/iabs.ll test/CodeGen/Thumb/iabs.ll In-Reply-To: <000001cc8539$8fef3370$afcd9a50$@org> References: <20111007161509.46571312800A@llvm.org> <5751F138-40A5-4245-840D-D24DC0D54194@apple.com> <40E1F4C6-5513-4B4C-BF3F-053162FD213D@apple.com> <6144A303-F54E-4A0F-B69D-DB9B94037F47@apple.com> <000001cc8539$8fef3370$afcd9a50$@org> Message-ID: Hello Ana, > This is command line I used: > clang -c -ccc-host-triple armv6-none-linux-gnueabi -mfloat-abi=softfp > -integrated-as -O3 -o floatsidf.o floatsidf.c Do not use integrated-as here. The full cmdline (thanks to Eric!) is: /Volumes/Data/builds/build-llvm/Debug+Asserts/bin/clang -no-integrated-as -ccc-install-dir /Developer/Platforms/iPhoneOS.platform/Developer/usr/bin/ -arch armv6 -fvisibility=hidden -DVISIBILITY_HIDDEN -mkernel -DKERNEL_USE -Wall -Werror -O3 -fomit-frame-pointer -miphoneos-version-min=1.0 -mthumb -c -o /Volumes/Data/builds/build-llvm/tools/clang/runtime/compiler-rt/clang_darwin/cc_kext/armv6/SubDir.lib/floatsidf.o /Volumes/Data/sources/llvm/projects/compiler-rt/lib/floatsidf.c -v You should at least add -mthumb. For me it seems it tried to assemble thumb-2 code in thumb-1 mode. I will provide more info in 5 mins. -- With best regards, Anton Korobeynikov Faculty of Mathematics and Mechanics, Saint Petersburg State University From anton at korobeynikov.info Fri Oct 7 16:58:29 2011 From: anton at korobeynikov.info (Anton Korobeynikov) Date: Sat, 8 Oct 2011 01:58:29 +0400 Subject: [llvm-commits] [llvm] r141365 - in /llvm/trunk: lib/Target/ARM/ARMISelDAGToDAG.cpp lib/Target/ARM/ARMISelLowering.cpp lib/Target/ARM/ARMInstrInfo.td lib/Target/ARM/ARMInstrThumb2.td test/CodeGen/ARM/iabs.ll test/CodeGen/Thumb/iabs.ll In-Reply-To: <000001cc8539$8fef3370$afcd9a50$@org> References: <20111007161509.46571312800A@llvm.org> <5751F138-40A5-4245-840D-D24DC0D54194@apple.com> <40E1F4C6-5513-4B4C-BF3F-053162FD213D@apple.com> <6144A303-F54E-4A0F-B69D-DB9B94037F47@apple.com> <000001cc8539$8fef3370$afcd9a50$@org> Message-ID: Hi Ana, > What is your command line? Did you set any other flags? Attached is .ll and .s. For me it seems we should just disable this transform in Thumb1 mode. What do you think? -- With best regards, Anton Korobeynikov Faculty of Mathematics and Mechanics, Saint Petersburg State University -------------- next part -------------- A non-text attachment was scrubbed... Name: floatsidf.o.ll Type: application/octet-stream Size: 1252 bytes Desc: not available Url : http://lists.cs.uiuc.edu/pipermail/llvm-commits/attachments/20111008/fd85a53b/attachment.obj -------------- next part -------------- A non-text attachment was scrubbed... Name: floatsidf.s Type: application/octet-stream Size: 1478 bytes Desc: not available Url : http://lists.cs.uiuc.edu/pipermail/llvm-commits/attachments/20111008/fd85a53b/attachment-0001.obj From anton at korobeynikov.info Fri Oct 7 17:00:26 2011 From: anton at korobeynikov.info (Anton Korobeynikov) Date: Sat, 8 Oct 2011 02:00:26 +0400 Subject: [llvm-commits] arm mc: fix relocation of an alias to an alias In-Reply-To: References: <8AE16CFC-D9D4-431B-9716-C8493971AEF0@apple.com> Message-ID: Ivan, >> It's not clear to me that this is correct. Aliases can be weak and you >> shouldn't follow them if they are. > If I don't follow them, llc will crash. But you cannot! If alias is weak it can be overridden. -- With best regards, Anton Korobeynikov Faculty of Mathematics and Mechanics, Saint Petersburg State University From krasin at google.com Fri Oct 7 17:03:24 2011 From: krasin at google.com (Ivan Krasin) Date: Fri, 7 Oct 2011 15:03:24 -0700 Subject: [llvm-commits] arm mc: fix relocation of an alias to an alias In-Reply-To: References: <8AE16CFC-D9D4-431B-9716-C8493971AEF0@apple.com> Message-ID: On Fri, Oct 7, 2011 at 3:00 PM, Anton Korobeynikov wrote: > Ivan, > >>> It's not clear to me that this is correct. Aliases can be weak and you >>> shouldn't follow them if they are. >> If I don't follow them, llc will crash. > But you cannot! If alias is weak it can be overridden. Yes, yes, I understand that. That's completely valid point (thx, Nick!), but it just shows that the code needs more attention. I will come back to this thread when I would add test cases and (probably) fix the code. > > -- > With best regards, Anton Korobeynikov > Faculty of Mathematics and Mechanics, Saint Petersburg State University > From isanbard at gmail.com Fri Oct 7 17:08:37 2011 From: isanbard at gmail.com (Bill Wendling) Date: Fri, 07 Oct 2011 22:08:37 -0000 Subject: [llvm-commits] [llvm] r141419 - in /llvm/trunk/lib/Target/ARM: ARMISelLowering.cpp ARMISelLowering.h Message-ID: <20111007220837.AEACB3128018@llvm.org> Author: void Date: Fri Oct 7 17:08:37 2011 New Revision: 141419 URL: http://llvm.org/viewvc/llvm-project?rev=141419&view=rev Log: Take the code that was emitted for the llvm.eh.dispatch.setup intrinsic and emit it with the new SjLj emitter stuff. This way there's no need to emit that kind-of-hacky intrinsic. Modified: llvm/trunk/lib/Target/ARM/ARMISelLowering.cpp llvm/trunk/lib/Target/ARM/ARMISelLowering.h Modified: llvm/trunk/lib/Target/ARM/ARMISelLowering.cpp URL: http://llvm.org/viewvc/llvm-project/llvm/trunk/lib/Target/ARM/ARMISelLowering.cpp?rev=141419&r1=141418&r2=141419&view=diff ============================================================================== --- llvm/trunk/lib/Target/ARM/ARMISelLowering.cpp (original) +++ llvm/trunk/lib/Target/ARM/ARMISelLowering.cpp Fri Oct 7 17:08:37 2011 @@ -5491,6 +5491,52 @@ return BB; } +/// EmitBasePointerRecalculation - For functions using a base pointer, we +/// rematerialize it (via the frame pointer). +void ARMTargetLowering:: +EmitBasePointerRecalculation(MachineInstr *MI, MachineBasicBlock *MBB, + MachineBasicBlock *DispatchBB) const { + const TargetInstrInfo *TII = getTargetMachine().getInstrInfo(); + const ARMBaseInstrInfo *AII = static_cast(TII); + MachineFunction &MF = *MI->getParent()->getParent(); + ARMFunctionInfo *AFI = MF.getInfo(); + const ARMBaseRegisterInfo &RI = AII->getRegisterInfo(); + + if (!RI.hasBasePointer(MF)) return; + + MachineBasicBlock::iterator MBBI = MI; + + int32_t NumBytes = AFI->getFramePtrSpillOffset(); + unsigned FramePtr = RI.getFrameRegister(MF); + assert(MF.getTarget().getFrameLowering()->hasFP(MF) && + "Base pointer without frame pointer?"); + + if (AFI->isThumb2Function()) + llvm::emitT2RegPlusImmediate(*MBB, MBBI, MI->getDebugLoc(), ARM::R6, + FramePtr, -NumBytes, ARMCC::AL, 0, *AII); + else if (AFI->isThumbFunction()) + llvm::emitThumbRegPlusImmediate(*MBB, MBBI, MI->getDebugLoc(), ARM::R6, + FramePtr, -NumBytes, *AII, RI); + else + llvm::emitARMRegPlusImmediate(*MBB, MBBI, MI->getDebugLoc(), ARM::R6, + FramePtr, -NumBytes, ARMCC::AL, 0, *AII); + + if (!RI.needsStackRealignment(MF)) return; + + // If there's dynamic realignment, adjust for it. + MachineFrameInfo *MFI = MF.getFrameInfo(); + unsigned MaxAlign = MFI->getMaxAlignment(); + assert(!AFI->isThumb1OnlyFunction()); + + // Emit bic r6, r6, MaxAlign + unsigned bicOpc = AFI->isThumbFunction() ? ARM::t2BICri : ARM::BICri; + AddDefaultCC( + AddDefaultPred( + BuildMI(*MBB, MBBI, MI->getDebugLoc(), TII->get(bicOpc), ARM::R6) + .addReg(ARM::R6, RegState::Kill) + .addImm(MaxAlign - 1))); +} + /// SetupEntryBlockForSjLj - Insert code into the entry block that creates and /// registers the function context. void ARMTargetLowering:: @@ -5525,6 +5571,8 @@ MF->getMachineMemOperand(MachinePointerInfo::getFixedStack(FI), MachineMemOperand::MOStore, 4, 4); + EmitBasePointerRecalculation(MI, MBB, DispatchBB); + // Load the address of the dispatch MBB into the jump buffer. if (isThumb2) { // Incoming value: jbuf @@ -5736,6 +5784,7 @@ .addFrameIndex(FI) .addImm(1) .addMemOperand(FIMMOLd)); + AddDefaultPred(BuildMI(DispatchBB, dl, TII->get(ARM::tCMPi8)) .addReg(NewVReg1) .addImm(LPadList.size())); Modified: llvm/trunk/lib/Target/ARM/ARMISelLowering.h URL: http://llvm.org/viewvc/llvm-project/llvm/trunk/lib/Target/ARM/ARMISelLowering.h?rev=141419&r1=141418&r2=141419&view=diff ============================================================================== --- llvm/trunk/lib/Target/ARM/ARMISelLowering.h (original) +++ llvm/trunk/lib/Target/ARM/ARMISelLowering.h Fri Oct 7 17:08:37 2011 @@ -512,6 +512,9 @@ bool signExtend, ARMCC::CondCodes Cond) const; + void EmitBasePointerRecalculation(MachineInstr *MI, MachineBasicBlock *MBB, + MachineBasicBlock *DispatchBB) const; + void SetupEntryBlockForSjLj(MachineInstr *MI, MachineBasicBlock *MBB, MachineBasicBlock *DispatchBB, int FI) const; From daniel at zuster.org Fri Oct 7 17:10:01 2011 From: daniel at zuster.org (Daniel Dunbar) Date: Fri, 07 Oct 2011 22:10:01 -0000 Subject: [llvm-commits] [zorg] r141420 - /zorg/trunk/lnt/lnt/tests/nt.py Message-ID: <20111007221001.126E42A6C12D@llvm.org> Author: ddunbar Date: Fri Oct 7 17:10:00 2011 New Revision: 141420 URL: http://llvm.org/viewvc/llvm-project?rev=141420&view=rev Log: LNT/nt: Follow links during the test module discovery, see comment. Modified: zorg/trunk/lnt/lnt/tests/nt.py Modified: zorg/trunk/lnt/lnt/tests/nt.py URL: http://llvm.org/viewvc/llvm-project/zorg/trunk/lnt/lnt/tests/nt.py?rev=141420&r1=141419&r2=141420&view=diff ============================================================================== --- zorg/trunk/lnt/lnt/tests/nt.py (original) +++ zorg/trunk/lnt/lnt/tests/nt.py Fri Oct 7 17:10:00 2011 @@ -43,7 +43,12 @@ else: return - for dirpath,dirnames,filenames in os.walk(test_modules_path): + # We follow links here because we want to support the ability for having + # various "suites" of LNTBased tests in separate repositories, and allowing + # users to just checkout them out elsewhere and link them into their LLVM + # test-suite source tree. + for dirpath,dirnames,filenames in os.walk(test_modules_path, + followlinks = True): # Ignore the example tests, unless requested. if not opts.include_test_examples and 'Examples' in dirnames: dirnames.remove('Examples') From daniel at zuster.org Fri Oct 7 17:10:12 2011 From: daniel at zuster.org (Daniel Dunbar) Date: Fri, 07 Oct 2011 22:10:12 -0000 Subject: [llvm-commits] [test-suite] r141421 - in /test-suite/trunk/LNTBased: ./ Examples/ Examples/README.txt Examples/Simple/ Examples/Simple/README.txt Examples/Simple/TestModule README.txt Message-ID: <20111007221012.81DFB3128018@llvm.org> Author: ddunbar Date: Fri Oct 7 17:10:12 2011 New Revision: 141421 URL: http://llvm.org/viewvc/llvm-project?rev=141421&view=rev Log: test-suite/LNTBased: Add an example of how to define a minimal LNTBased test. Added: test-suite/trunk/LNTBased/ test-suite/trunk/LNTBased/Examples/ test-suite/trunk/LNTBased/Examples/README.txt test-suite/trunk/LNTBased/Examples/Simple/ test-suite/trunk/LNTBased/Examples/Simple/README.txt test-suite/trunk/LNTBased/Examples/Simple/TestModule test-suite/trunk/LNTBased/README.txt Added: test-suite/trunk/LNTBased/Examples/README.txt URL: http://llvm.org/viewvc/llvm-project/test-suite/trunk/LNTBased/Examples/README.txt?rev=141421&view=auto ============================================================================== --- test-suite/trunk/LNTBased/Examples/README.txt (added) +++ test-suite/trunk/LNTBased/Examples/README.txt Fri Oct 7 17:10:12 2011 @@ -0,0 +1 @@ +This directory contains LNT-based example tests. Added: test-suite/trunk/LNTBased/Examples/Simple/README.txt URL: http://llvm.org/viewvc/llvm-project/test-suite/trunk/LNTBased/Examples/Simple/README.txt?rev=141421&view=auto ============================================================================== --- test-suite/trunk/LNTBased/Examples/Simple/README.txt (added) +++ test-suite/trunk/LNTBased/Examples/Simple/README.txt Fri Oct 7 17:10:12 2011 @@ -0,0 +1 @@ +This is a minimal LNT-based NT test module. Added: test-suite/trunk/LNTBased/Examples/Simple/TestModule URL: http://llvm.org/viewvc/llvm-project/test-suite/trunk/LNTBased/Examples/Simple/TestModule?rev=141421&view=auto ============================================================================== --- test-suite/trunk/LNTBased/Examples/Simple/TestModule (added) +++ test-suite/trunk/LNTBased/Examples/Simple/TestModule Fri Oct 7 17:10:12 2011 @@ -0,0 +1,40 @@ +#!/usr/bin/env python +# -*- Python -*- + +# We import test functionity from LNT. +from lnt.tests import nt +from lnt.testing import TestSamples, PASS, FAIL, XFAIL + +# Test module classes are currently required to subclass 'nt.TestModule'. +class Simple(nt.TestModule): + def execute_test(self, options): + # The options dictionary defines the user command line parameters that + # are supposed to apply to the test. Some important variables which are + # guaranteed to be present are: + # ... FIXME + + # We are expected to return a list of test samples, which will be merged + # with all the other reports. + # + # There are no constraints on the test names (i.e., they do not need to + # match the directory structure as the SingleSource or MultiSource tests + # would), but must be unique. + # + # The tests should follow the current LNT test schema for reporting test + # status (success and failure). The current schema is that status is + # reported as an additional test with the '.status' suffix and + # appropriate test codes (defined by the 'lnt.testing' module, see + # below). If no '.status' result is reported, the test is assumed to + # have passed. + return [ + TestSamples('nts.LNT/Examples/Simple.compile', [1.0]), + TestSamples('nts.LNT/Examples/Simple.exec', [1.0]), + TestSamples('nts.LNT/Examples/Simple.exec.status', [FAIL])] + +# This is the only required entry point to the module. +test_class = Simple + +# This is not required, but allows users with LNT in the environment (required +# for initial imports to work) to execute this test directly. +if __name__ == '__main__': + test_class().main() Added: test-suite/trunk/LNTBased/README.txt URL: http://llvm.org/viewvc/llvm-project/test-suite/trunk/LNTBased/README.txt?rev=141421&view=auto ============================================================================== --- test-suite/trunk/LNTBased/README.txt (added) +++ test-suite/trunk/LNTBased/README.txt Fri Oct 7 17:10:12 2011 @@ -0,0 +1,14 @@ +llvm-test LNT-based tests +========================= + +This directory contains test components designed to run as part of the LNT based +"nightly test" infrastructure. + +These test components are designed to impose minimal requirements on the code +being tested or on how the test is run. Instead, the tests must provide an +extension module that will be run by LNT and will be passed the user parameters +(compiler to test, optimization flags, etc.), and is expected to return back an +LNT testing report. + +Tests are auto-discovered by the LNT 'nt' test by looking for the TestModule +extension module files. See the 'Examples' sub-directory for more information. From criswell at uiuc.edu Fri Oct 7 17:21:38 2011 From: criswell at uiuc.edu (John Criswell) Date: Fri, 07 Oct 2011 22:21:38 -0000 Subject: [llvm-commits] [poolalloc] r141426 - /poolalloc/trunk/lib/DSA/Local.cpp Message-ID: <20111007222138.EDE202A6C12D@llvm.org> Author: criswell Date: Fri Oct 7 17:21:38 2011 New Revision: 141426 URL: http://llvm.org/viewvc/llvm-project?rev=141426&view=rev Log: Added support for the cmpxchg instruction. Modified: poolalloc/trunk/lib/DSA/Local.cpp Modified: poolalloc/trunk/lib/DSA/Local.cpp URL: http://llvm.org/viewvc/llvm-project/poolalloc/trunk/lib/DSA/Local.cpp?rev=141426&r1=141425&r2=141426&view=diff ============================================================================== --- poolalloc/trunk/lib/DSA/Local.cpp (original) +++ poolalloc/trunk/lib/DSA/Local.cpp Fri Oct 7 17:21:38 2011 @@ -118,6 +118,7 @@ void visitSelectInst(SelectInst &SI); void visitLoadInst(LoadInst &LI); void visitStoreInst(StoreInst &SI); + void visitAtomicCmpXchgInst(AtomicCmpXchgInst &I); void visitAtomicRMWInst(AtomicRMWInst &I); void visitReturnInst(ReturnInst &RI); void visitVAArgInst(VAArgInst &I); @@ -415,6 +416,57 @@ Dest.getNode()->mergeTypeInfo(StoredTy, Dest.getOffset()); } +void GraphBuilder::visitAtomicCmpXchgInst(AtomicCmpXchgInst &I) { + if (isa(I.getType())) { + visitInstruction (I); + return; + } + + // + // Create a DSNode for the dereferenced pointer . If the DSNode is NULL, do + // nothing more (this can occur if the pointer is a NULL constant; bugpoint + // can generate such code). + // + DSNodeHandle Ptr = getValueDest(I.getPointerOperand()); + if (Ptr.isNull()) return; + + // + // Make that the memory object is read and written. + // + Ptr.getNode()->setReadMarker(); + Ptr.getNode()->setModifiedMarker(); + + // + // If the result of the compare-and-swap is a pointer, then we need to do + // a few things: + // o Merge the compare and swap values (which are pointers) with the result + // o Merge the DSNode of the pointer *within* the memory object with the + // DSNode of the compare, swap, and result DSNode. + // + if (isa(I.getType())) { + // + // Get the DSNodeHandle of the memory object returned from the load. Make + // it the DSNodeHandle of the instruction's result. + // + DSNodeHandle FieldPtr = getLink (Ptr); + setDestTo(I, getLink(Ptr)); + + // + // Merge the result, compare, and swap values of the instruction. + // + FieldPtr.mergeWith (getValueDest (I.getCompareOperand())); + FieldPtr.mergeWith (getValueDest (I.getNewValOperand())); + } + + // + // Modify the DSNode so that it has the loaded/written type at the + // appropriate offset. + // + Ptr.getNode()->growSizeForType(I.getType(), Ptr.getOffset()); + Ptr.getNode()->mergeTypeInfo(I.getType(), Ptr.getOffset()); + return; +} + void GraphBuilder::visitAtomicRMWInst(AtomicRMWInst &I) { // // Create a DSNode for the dereferenced pointer . If the DSNode is NULL, do From criswell at uiuc.edu Fri Oct 7 17:22:46 2011 From: criswell at uiuc.edu (John Criswell) Date: Fri, 07 Oct 2011 22:22:46 -0000 Subject: [llvm-commits] [poolalloc] r141427 - /poolalloc/trunk/lib/DSA/Local.cpp Message-ID: <20111007222246.8041E2A6C12D@llvm.org> Author: criswell Date: Fri Oct 7 17:22:46 2011 New Revision: 141427 URL: http://llvm.org/viewvc/llvm-project?rev=141427&view=rev Log: Removed old code for old atomic intrinsics. Modified: poolalloc/trunk/lib/DSA/Local.cpp Modified: poolalloc/trunk/lib/DSA/Local.cpp URL: http://llvm.org/viewvc/llvm-project/poolalloc/trunk/lib/DSA/Local.cpp?rev=141427&r1=141426&r2=141427&view=diff ============================================================================== --- poolalloc/trunk/lib/DSA/Local.cpp (original) +++ poolalloc/trunk/lib/DSA/Local.cpp Fri Oct 7 17:22:46 2011 @@ -984,39 +984,6 @@ return true; } -#if 0 - case Intrinsic::atomic_cmp_swap: { - DSNodeHandle Ptr = getValueDest(*CS.arg_begin()); - Ptr.getNode()->setReadMarker(); - Ptr.getNode()->setModifiedMarker(); - if (isa(F->getReturnType())) { - setDestTo(*(CS.getInstruction()), getValueDest(*(CS.arg_begin() + 1))); - getValueDest(*(CS.arg_begin() + 1)) - .mergeWith(getValueDest(*(CS.arg_begin() + 2))); - } - } - case Intrinsic::atomic_swap: - case Intrinsic::atomic_load_add: - case Intrinsic::atomic_load_sub: - case Intrinsic::atomic_load_and: - case Intrinsic::atomic_load_nand: - case Intrinsic::atomic_load_or: - case Intrinsic::atomic_load_xor: - case Intrinsic::atomic_load_max: - case Intrinsic::atomic_load_min: - case Intrinsic::atomic_load_umax: - case Intrinsic::atomic_load_umin: - { - DSNodeHandle Ptr = getValueDest(*CS.arg_begin()); - Ptr.getNode()->setReadMarker(); - Ptr.getNode()->setModifiedMarker(); - if (isa(F->getReturnType())) - setDestTo(*CS.getInstruction(), getValueDest(*(CS.arg_begin() + 1))); - } -#endif - - - case Intrinsic::prefetch: return true; From isanbard at gmail.com Fri Oct 7 18:06:01 2011 From: isanbard at gmail.com (Bill Wendling) Date: Fri, 07 Oct 2011 23:06:01 -0000 Subject: [llvm-commits] [llvm] r141435 - /llvm/trunk/include/llvm/CodeGen/MachineBasicBlock.h Message-ID: <20111007230601.7DD902A6C12D@llvm.org> Author: void Date: Fri Oct 7 18:06:01 2011 New Revision: 141435 URL: http://llvm.org/viewvc/llvm-project?rev=141435&view=rev Log: Add a bool value to set the IsLandingPad flag to. Modified: llvm/trunk/include/llvm/CodeGen/MachineBasicBlock.h Modified: llvm/trunk/include/llvm/CodeGen/MachineBasicBlock.h URL: http://llvm.org/viewvc/llvm-project/llvm/trunk/include/llvm/CodeGen/MachineBasicBlock.h?rev=141435&r1=141434&r2=141435&view=diff ============================================================================== --- llvm/trunk/include/llvm/CodeGen/MachineBasicBlock.h (original) +++ llvm/trunk/include/llvm/CodeGen/MachineBasicBlock.h Fri Oct 7 18:06:01 2011 @@ -232,7 +232,7 @@ /// setIsLandingPad - Indicates the block is a landing pad. That is /// this basic block is entered via an exception handler. - void setIsLandingPad() { IsLandingPad = true; } + void setIsLandingPad(bool V = true) { IsLandingPad = V; } /// getLandingPadSuccessor - If this block has a successor that is a landing /// pad, return it. Otherwise return NULL. From isanbard at gmail.com Fri Oct 7 18:18:02 2011 From: isanbard at gmail.com (Bill Wendling) Date: Fri, 07 Oct 2011 23:18:02 -0000 Subject: [llvm-commits] [llvm] r141436 - /llvm/trunk/lib/Target/ARM/ARMISelLowering.cpp Message-ID: <20111007231802.864663128018@llvm.org> Author: void Date: Fri Oct 7 18:18:02 2011 New Revision: 141436 URL: http://llvm.org/viewvc/llvm-project?rev=141436&view=rev Log: Take all of the invoke basic blocks and make the dispatch basic block their new successor. Remove the old landing pad from their successor list, because it's now the successor of the dispatch block. Now that the landing pad blocks are no longer the destination of invokes, we can mark them as normal basic blocks instead of landing pads. This more closely resembles what the CFG is actually doing. Modified: llvm/trunk/lib/Target/ARM/ARMISelLowering.cpp Modified: llvm/trunk/lib/Target/ARM/ARMISelLowering.cpp URL: http://llvm.org/viewvc/llvm-project/llvm/trunk/lib/Target/ARM/ARMISelLowering.cpp?rev=141436&r1=141435&r2=141436&view=diff ============================================================================== --- llvm/trunk/lib/Target/ARM/ARMISelLowering.cpp (original) +++ llvm/trunk/lib/Target/ARM/ARMISelLowering.cpp Fri Oct 7 18:18:02 2011 @@ -5699,12 +5699,15 @@ // Get an ordered list of the machine basic blocks for the jump table. std::vector LPadList; + SmallPtrSet InvokeBBs; LPadList.reserve(CallSiteNumToLPad.size()); for (unsigned I = 1; I <= MaxCSNum; ++I) { SmallVectorImpl &MBBList = CallSiteNumToLPad[I]; for (SmallVectorImpl::iterator - II = MBBList.begin(), IE = MBBList.end(); II != IE; ++II) + II = MBBList.begin(), IE = MBBList.end(); II != IE; ++II) { LPadList.push_back(*II); + InvokeBBs.insert((*II)->pred_begin(), (*II)->pred_end()); + } } assert(!LPadList.empty() && @@ -5721,7 +5724,6 @@ // Shove the dispatch's address into the return slot in the function context. MachineBasicBlock *DispatchBB = MF->CreateMachineBasicBlock(); DispatchBB->setIsLandingPad(); - MBB->addSuccessor(DispatchBB); MachineBasicBlock *TrapBB = MF->CreateMachineBasicBlock(); BuildMI(TrapBB, dl, TII->get(Subtarget->isThumb() ? ARM::tTRAP : ARM::TRAP)); @@ -5873,9 +5875,31 @@ } // Add the jump table entries as successors to the MBB. + MachineBasicBlock *PrevMBB = 0; for (std::vector::iterator - I = LPadList.begin(), E = LPadList.end(); I != E; ++I) - DispContBB->addSuccessor(*I); + I = LPadList.begin(), E = LPadList.end(); I != E; ++I) { + MachineBasicBlock *CurMBB = *I; + if (PrevMBB != CurMBB) + DispContBB->addSuccessor(CurMBB); + PrevMBB = CurMBB; + } + + // Remove the landing pad successor from the invoke block and replace it with + // the new dispatch block. + for (SmallPtrSet::iterator + I = InvokeBBs.begin(), E = InvokeBBs.end(); I != E; ++I) { + MachineBasicBlock *BB = *I; + for (MachineBasicBlock::succ_iterator + SI = BB->succ_begin(), SE = BB->succ_end(); SI != SE; ++SI) { + MachineBasicBlock *SMBB = *SI; + if (SMBB->isLandingPad()) { + BB->removeSuccessor(SMBB); + SMBB->setIsLandingPad(false); + } + } + + BB->addSuccessor(DispatchBB); + } // The instruction is gone now. MI->eraseFromParent(); From grosbach at apple.com Fri Oct 7 18:24:09 2011 From: grosbach at apple.com (Jim Grosbach) Date: Fri, 07 Oct 2011 23:24:09 -0000 Subject: [llvm-commits] [llvm] r141438 - /llvm/trunk/lib/Target/ARM/AsmParser/ARMAsmParser.cpp Message-ID: <20111007232409.491BE2A6C12D@llvm.org> Author: grosbach Date: Fri Oct 7 18:24:09 2011 New Revision: 141438 URL: http://llvm.org/viewvc/llvm-project?rev=141438&view=rev Log: ARM prefix asmparser operand kind enums for readability. Modified: llvm/trunk/lib/Target/ARM/AsmParser/ARMAsmParser.cpp Modified: llvm/trunk/lib/Target/ARM/AsmParser/ARMAsmParser.cpp URL: http://llvm.org/viewvc/llvm-project/llvm/trunk/lib/Target/ARM/AsmParser/ARMAsmParser.cpp?rev=141438&r1=141437&r2=141438&view=diff ============================================================================== --- llvm/trunk/lib/Target/ARM/AsmParser/ARMAsmParser.cpp (original) +++ llvm/trunk/lib/Target/ARM/AsmParser/ARMAsmParser.cpp Fri Oct 7 18:24:09 2011 @@ -242,28 +242,28 @@ /// instruction. class ARMOperand : public MCParsedAsmOperand { enum KindTy { - CondCode, - CCOut, - ITCondMask, - CoprocNum, - CoprocReg, - Immediate, - FPImmediate, - MemBarrierOpt, - Memory, - PostIndexRegister, - MSRMask, - ProcIFlags, - Register, - RegisterList, - DPRRegisterList, - SPRRegisterList, - ShiftedRegister, - ShiftedImmediate, - ShifterImmediate, - RotateImmediate, - BitfieldDescriptor, - Token + k_CondCode, + k_CCOut, + k_ITCondMask, + k_CoprocNum, + k_CoprocReg, + k_Immediate, + k_FPImmediate, + k_MemBarrierOpt, + k_Memory, + k_PostIndexRegister, + k_MSRMask, + k_ProcIFlags, + k_Register, + k_RegisterList, + k_DPRRegisterList, + k_SPRRegisterList, + k_ShiftedRegister, + k_ShiftedImmediate, + k_ShifterImmediate, + k_RotateImmediate, + k_BitfieldDescriptor, + k_Token } Kind; SMLoc StartLoc, EndLoc; @@ -361,62 +361,62 @@ StartLoc = o.StartLoc; EndLoc = o.EndLoc; switch (Kind) { - case CondCode: + case k_CondCode: CC = o.CC; break; - case ITCondMask: + case k_ITCondMask: ITMask = o.ITMask; break; - case Token: + case k_Token: Tok = o.Tok; break; - case CCOut: - case Register: + case k_CCOut: + case k_Register: Reg = o.Reg; break; - case RegisterList: - case DPRRegisterList: - case SPRRegisterList: + case k_RegisterList: + case k_DPRRegisterList: + case k_SPRRegisterList: Registers = o.Registers; break; - case CoprocNum: - case CoprocReg: + case k_CoprocNum: + case k_CoprocReg: Cop = o.Cop; break; - case Immediate: + case k_Immediate: Imm = o.Imm; break; - case FPImmediate: + case k_FPImmediate: FPImm = o.FPImm; break; - case MemBarrierOpt: + case k_MemBarrierOpt: MBOpt = o.MBOpt; break; - case Memory: + case k_Memory: Mem = o.Mem; break; - case PostIndexRegister: + case k_PostIndexRegister: PostIdxReg = o.PostIdxReg; break; - case MSRMask: + case k_MSRMask: MMask = o.MMask; break; - case ProcIFlags: + case k_ProcIFlags: IFlags = o.IFlags; break; - case ShifterImmediate: + case k_ShifterImmediate: ShifterImm = o.ShifterImm; break; - case ShiftedRegister: + case k_ShiftedRegister: RegShiftedReg = o.RegShiftedReg; break; - case ShiftedImmediate: + case k_ShiftedImmediate: RegShiftedImm = o.RegShiftedImm; break; - case RotateImmediate: + case k_RotateImmediate: RotImm = o.RotImm; break; - case BitfieldDescriptor: + case k_BitfieldDescriptor: Bitfield = o.Bitfield; break; } @@ -428,66 +428,66 @@ SMLoc getEndLoc() const { return EndLoc; } ARMCC::CondCodes getCondCode() const { - assert(Kind == CondCode && "Invalid access!"); + assert(Kind == k_CondCode && "Invalid access!"); return CC.Val; } unsigned getCoproc() const { - assert((Kind == CoprocNum || Kind == CoprocReg) && "Invalid access!"); + assert((Kind == k_CoprocNum || Kind == k_CoprocReg) && "Invalid access!"); return Cop.Val; } StringRef getToken() const { - assert(Kind == Token && "Invalid access!"); + assert(Kind == k_Token && "Invalid access!"); return StringRef(Tok.Data, Tok.Length); } unsigned getReg() const { - assert((Kind == Register || Kind == CCOut) && "Invalid access!"); + assert((Kind == k_Register || Kind == k_CCOut) && "Invalid access!"); return Reg.RegNum; } const SmallVectorImpl &getRegList() const { - assert((Kind == RegisterList || Kind == DPRRegisterList || - Kind == SPRRegisterList) && "Invalid access!"); + assert((Kind == k_RegisterList || Kind == k_DPRRegisterList || + Kind == k_SPRRegisterList) && "Invalid access!"); return Registers; } const MCExpr *getImm() const { - assert(Kind == Immediate && "Invalid access!"); + assert(Kind == k_Immediate && "Invalid access!"); return Imm.Val; } unsigned getFPImm() const { - assert(Kind == FPImmediate && "Invalid access!"); + assert(Kind == k_FPImmediate && "Invalid access!"); return FPImm.Val; } ARM_MB::MemBOpt getMemBarrierOpt() const { - assert(Kind == MemBarrierOpt && "Invalid access!"); + assert(Kind == k_MemBarrierOpt && "Invalid access!"); return MBOpt.Val; } ARM_PROC::IFlags getProcIFlags() const { - assert(Kind == ProcIFlags && "Invalid access!"); + assert(Kind == k_ProcIFlags && "Invalid access!"); return IFlags.Val; } unsigned getMSRMask() const { - assert(Kind == MSRMask && "Invalid access!"); + assert(Kind == k_MSRMask && "Invalid access!"); return MMask.Val; } - bool isCoprocNum() const { return Kind == CoprocNum; } - bool isCoprocReg() const { return Kind == CoprocReg; } - bool isCondCode() const { return Kind == CondCode; } - bool isCCOut() const { return Kind == CCOut; } - bool isITMask() const { return Kind == ITCondMask; } - bool isITCondCode() const { return Kind == CondCode; } - bool isImm() const { return Kind == Immediate; } - bool isFPImm() const { return Kind == FPImmediate; } + bool isCoprocNum() const { return Kind == k_CoprocNum; } + bool isCoprocReg() const { return Kind == k_CoprocReg; } + bool isCondCode() const { return Kind == k_CondCode; } + bool isCCOut() const { return Kind == k_CCOut; } + bool isITMask() const { return Kind == k_ITCondMask; } + bool isITCondCode() const { return Kind == k_CondCode; } + bool isImm() const { return Kind == k_Immediate; } + bool isFPImm() const { return Kind == k_FPImmediate; } bool isImm8s4() const { - if (Kind != Immediate) + if (Kind != k_Immediate) return false; const MCConstantExpr *CE = dyn_cast(getImm()); if (!CE) return false; @@ -495,7 +495,7 @@ return ((Value & 3) == 0) && Value >= -1020 && Value <= 1020; } bool isImm0_1020s4() const { - if (Kind != Immediate) + if (Kind != k_Immediate) return false; const MCConstantExpr *CE = dyn_cast(getImm()); if (!CE) return false; @@ -503,7 +503,7 @@ return ((Value & 3) == 0) && Value >= 0 && Value <= 1020; } bool isImm0_508s4() const { - if (Kind != Immediate) + if (Kind != k_Immediate) return false; const MCConstantExpr *CE = dyn_cast(getImm()); if (!CE) return false; @@ -511,7 +511,7 @@ return ((Value & 3) == 0) && Value >= 0 && Value <= 508; } bool isImm0_255() const { - if (Kind != Immediate) + if (Kind != k_Immediate) return false; const MCConstantExpr *CE = dyn_cast(getImm()); if (!CE) return false; @@ -519,7 +519,7 @@ return Value >= 0 && Value < 256; } bool isImm0_7() const { - if (Kind != Immediate) + if (Kind != k_Immediate) return false; const MCConstantExpr *CE = dyn_cast(getImm()); if (!CE) return false; @@ -527,7 +527,7 @@ return Value >= 0 && Value < 8; } bool isImm0_15() const { - if (Kind != Immediate) + if (Kind != k_Immediate) return false; const MCConstantExpr *CE = dyn_cast(getImm()); if (!CE) return false; @@ -535,7 +535,7 @@ return Value >= 0 && Value < 16; } bool isImm0_31() const { - if (Kind != Immediate) + if (Kind != k_Immediate) return false; const MCConstantExpr *CE = dyn_cast(getImm()); if (!CE) return false; @@ -543,7 +543,7 @@ return Value >= 0 && Value < 32; } bool isImm1_16() const { - if (Kind != Immediate) + if (Kind != k_Immediate) return false; const MCConstantExpr *CE = dyn_cast(getImm()); if (!CE) return false; @@ -551,7 +551,7 @@ return Value > 0 && Value < 17; } bool isImm1_32() const { - if (Kind != Immediate) + if (Kind != k_Immediate) return false; const MCConstantExpr *CE = dyn_cast(getImm()); if (!CE) return false; @@ -559,7 +559,7 @@ return Value > 0 && Value < 33; } bool isImm0_65535() const { - if (Kind != Immediate) + if (Kind != k_Immediate) return false; const MCConstantExpr *CE = dyn_cast(getImm()); if (!CE) return false; @@ -567,7 +567,7 @@ return Value >= 0 && Value < 65536; } bool isImm0_65535Expr() const { - if (Kind != Immediate) + if (Kind != k_Immediate) return false; const MCConstantExpr *CE = dyn_cast(getImm()); // If it's not a constant expression, it'll generate a fixup and be @@ -577,7 +577,7 @@ return Value >= 0 && Value < 65536; } bool isImm24bit() const { - if (Kind != Immediate) + if (Kind != k_Immediate) return false; const MCConstantExpr *CE = dyn_cast(getImm()); if (!CE) return false; @@ -585,7 +585,7 @@ return Value >= 0 && Value <= 0xffffff; } bool isImmThumbSR() const { - if (Kind != Immediate) + if (Kind != k_Immediate) return false; const MCConstantExpr *CE = dyn_cast(getImm()); if (!CE) return false; @@ -593,7 +593,7 @@ return Value > 0 && Value < 33; } bool isPKHLSLImm() const { - if (Kind != Immediate) + if (Kind != k_Immediate) return false; const MCConstantExpr *CE = dyn_cast(getImm()); if (!CE) return false; @@ -601,7 +601,7 @@ return Value >= 0 && Value < 32; } bool isPKHASRImm() const { - if (Kind != Immediate) + if (Kind != k_Immediate) return false; const MCConstantExpr *CE = dyn_cast(getImm()); if (!CE) return false; @@ -609,7 +609,7 @@ return Value > 0 && Value <= 32; } bool isARMSOImm() const { - if (Kind != Immediate) + if (Kind != k_Immediate) return false; const MCConstantExpr *CE = dyn_cast(getImm()); if (!CE) return false; @@ -617,7 +617,7 @@ return ARM_AM::getSOImmVal(Value) != -1; } bool isT2SOImm() const { - if (Kind != Immediate) + if (Kind != k_Immediate) return false; const MCConstantExpr *CE = dyn_cast(getImm()); if (!CE) return false; @@ -625,37 +625,37 @@ return ARM_AM::getT2SOImmVal(Value) != -1; } bool isSetEndImm() const { - if (Kind != Immediate) + if (Kind != k_Immediate) return false; const MCConstantExpr *CE = dyn_cast(getImm()); if (!CE) return false; int64_t Value = CE->getValue(); return Value == 1 || Value == 0; } - bool isReg() const { return Kind == Register; } - bool isRegList() const { return Kind == RegisterList; } - bool isDPRRegList() const { return Kind == DPRRegisterList; } - bool isSPRRegList() const { return Kind == SPRRegisterList; } - bool isToken() const { return Kind == Token; } - bool isMemBarrierOpt() const { return Kind == MemBarrierOpt; } - bool isMemory() const { return Kind == Memory; } - bool isShifterImm() const { return Kind == ShifterImmediate; } - bool isRegShiftedReg() const { return Kind == ShiftedRegister; } - bool isRegShiftedImm() const { return Kind == ShiftedImmediate; } - bool isRotImm() const { return Kind == RotateImmediate; } - bool isBitfield() const { return Kind == BitfieldDescriptor; } - bool isPostIdxRegShifted() const { return Kind == PostIndexRegister; } + bool isReg() const { return Kind == k_Register; } + bool isRegList() const { return Kind == k_RegisterList; } + bool isDPRRegList() const { return Kind == k_DPRRegisterList; } + bool isSPRRegList() const { return Kind == k_SPRRegisterList; } + bool isToken() const { return Kind == k_Token; } + bool isMemBarrierOpt() const { return Kind == k_MemBarrierOpt; } + bool isMemory() const { return Kind == k_Memory; } + bool isShifterImm() const { return Kind == k_ShifterImmediate; } + bool isRegShiftedReg() const { return Kind == k_ShiftedRegister; } + bool isRegShiftedImm() const { return Kind == k_ShiftedImmediate; } + bool isRotImm() const { return Kind == k_RotateImmediate; } + bool isBitfield() const { return Kind == k_BitfieldDescriptor; } + bool isPostIdxRegShifted() const { return Kind == k_PostIndexRegister; } bool isPostIdxReg() const { - return Kind == PostIndexRegister && PostIdxReg.ShiftTy == ARM_AM::no_shift; + return Kind == k_PostIndexRegister && PostIdxReg.ShiftTy == ARM_AM::no_shift; } bool isMemNoOffset() const { - if (Kind != Memory) + if (Kind != k_Memory) return false; // No offset of any kind. return Mem.OffsetRegNum == 0 && Mem.OffsetImm == 0; } bool isAddrMode2() const { - if (Kind != Memory) + if (Kind != k_Memory) return false; // Check for register offset. if (Mem.OffsetRegNum) return true; @@ -665,7 +665,7 @@ return Val > -4096 && Val < 4096; } bool isAM2OffsetImm() const { - if (Kind != Immediate) + if (Kind != k_Immediate) return false; // Immediate offset in range [-4095, 4095]. const MCConstantExpr *CE = dyn_cast(getImm()); @@ -674,7 +674,7 @@ return Val > -4096 && Val < 4096; } bool isAddrMode3() const { - if (Kind != Memory) + if (Kind != k_Memory) return false; // No shifts are legal for AM3. if (Mem.ShiftType != ARM_AM::no_shift) return false; @@ -686,9 +686,9 @@ return Val > -256 && Val < 256; } bool isAM3Offset() const { - if (Kind != Immediate && Kind != PostIndexRegister) + if (Kind != k_Immediate && Kind != k_PostIndexRegister) return false; - if (Kind == PostIndexRegister) + if (Kind == k_PostIndexRegister) return PostIdxReg.ShiftTy == ARM_AM::no_shift; // Immediate offset in range [-255, 255]. const MCConstantExpr *CE = dyn_cast(getImm()); @@ -698,7 +698,7 @@ return (Val > -256 && Val < 256) || Val == INT32_MIN; } bool isAddrMode5() const { - if (Kind != Memory) + if (Kind != k_Memory) return false; // Check for register offset. if (Mem.OffsetRegNum) return false; @@ -709,24 +709,24 @@ Val == INT32_MIN; } bool isMemTBB() const { - if (Kind != Memory || !Mem.OffsetRegNum || Mem.isNegative || + if (Kind != k_Memory || !Mem.OffsetRegNum || Mem.isNegative || Mem.ShiftType != ARM_AM::no_shift) return false; return true; } bool isMemTBH() const { - if (Kind != Memory || !Mem.OffsetRegNum || Mem.isNegative || + if (Kind != k_Memory || !Mem.OffsetRegNum || Mem.isNegative || Mem.ShiftType != ARM_AM::lsl || Mem.ShiftImm != 1) return false; return true; } bool isMemRegOffset() const { - if (Kind != Memory || !Mem.OffsetRegNum) + if (Kind != k_Memory || !Mem.OffsetRegNum) return false; return true; } bool isT2MemRegOffset() const { - if (Kind != Memory || !Mem.OffsetRegNum || Mem.isNegative) + if (Kind != k_Memory || !Mem.OffsetRegNum || Mem.isNegative) return false; // Only lsl #{0, 1, 2, 3} allowed. if (Mem.ShiftType == ARM_AM::no_shift) @@ -738,14 +738,14 @@ bool isMemThumbRR() const { // Thumb reg+reg addressing is simple. Just two registers, a base and // an offset. No shifts, negations or any other complicating factors. - if (Kind != Memory || !Mem.OffsetRegNum || Mem.isNegative || + if (Kind != k_Memory || !Mem.OffsetRegNum || Mem.isNegative || Mem.ShiftType != ARM_AM::no_shift) return false; return isARMLowRegister(Mem.BaseRegNum) && (!Mem.OffsetRegNum || isARMLowRegister(Mem.OffsetRegNum)); } bool isMemThumbRIs4() const { - if (Kind != Memory || Mem.OffsetRegNum != 0 || + if (Kind != k_Memory || Mem.OffsetRegNum != 0 || !isARMLowRegister(Mem.BaseRegNum)) return false; // Immediate offset, multiple of 4 in range [0, 124]. @@ -754,7 +754,7 @@ return Val >= 0 && Val <= 124 && (Val % 4) == 0; } bool isMemThumbRIs2() const { - if (Kind != Memory || Mem.OffsetRegNum != 0 || + if (Kind != k_Memory || Mem.OffsetRegNum != 0 || !isARMLowRegister(Mem.BaseRegNum)) return false; // Immediate offset, multiple of 4 in range [0, 62]. @@ -763,7 +763,7 @@ return Val >= 0 && Val <= 62 && (Val % 2) == 0; } bool isMemThumbRIs1() const { - if (Kind != Memory || Mem.OffsetRegNum != 0 || + if (Kind != k_Memory || Mem.OffsetRegNum != 0 || !isARMLowRegister(Mem.BaseRegNum)) return false; // Immediate offset in range [0, 31]. @@ -772,7 +772,7 @@ return Val >= 0 && Val <= 31; } bool isMemThumbSPI() const { - if (Kind != Memory || Mem.OffsetRegNum != 0 || Mem.BaseRegNum != ARM::SP) + if (Kind != k_Memory || Mem.OffsetRegNum != 0 || Mem.BaseRegNum != ARM::SP) return false; // Immediate offset, multiple of 4 in range [0, 1020]. if (!Mem.OffsetImm) return true; @@ -780,7 +780,7 @@ return Val >= 0 && Val <= 1020 && (Val % 4) == 0; } bool isMemImm8s4Offset() const { - if (Kind != Memory || Mem.OffsetRegNum != 0) + if (Kind != k_Memory || Mem.OffsetRegNum != 0) return false; // Immediate offset a multiple of 4 in range [-1020, 1020]. if (!Mem.OffsetImm) return true; @@ -788,7 +788,7 @@ return Val >= -1020 && Val <= 1020 && (Val & 3) == 0; } bool isMemImm0_1020s4Offset() const { - if (Kind != Memory || Mem.OffsetRegNum != 0) + if (Kind != k_Memory || Mem.OffsetRegNum != 0) return false; // Immediate offset a multiple of 4 in range [0, 1020]. if (!Mem.OffsetImm) return true; @@ -796,7 +796,7 @@ return Val >= 0 && Val <= 1020 && (Val & 3) == 0; } bool isMemImm8Offset() const { - if (Kind != Memory || Mem.OffsetRegNum != 0) + if (Kind != k_Memory || Mem.OffsetRegNum != 0) return false; // Immediate offset in range [-255, 255]. if (!Mem.OffsetImm) return true; @@ -804,7 +804,7 @@ return (Val == INT32_MIN) || (Val > -256 && Val < 256); } bool isMemPosImm8Offset() const { - if (Kind != Memory || Mem.OffsetRegNum != 0) + if (Kind != k_Memory || Mem.OffsetRegNum != 0) return false; // Immediate offset in range [0, 255]. if (!Mem.OffsetImm) return true; @@ -812,7 +812,7 @@ return Val >= 0 && Val < 256; } bool isMemNegImm8Offset() const { - if (Kind != Memory || Mem.OffsetRegNum != 0) + if (Kind != k_Memory || Mem.OffsetRegNum != 0) return false; // Immediate offset in range [-255, -1]. if (!Mem.OffsetImm) return true; @@ -823,10 +823,10 @@ // If we have an immediate that's not a constant, treat it as a label // reference needing a fixup. If it is a constant, it's something else // and we reject it. - if (Kind == Immediate && !isa(getImm())) + if (Kind == k_Immediate && !isa(getImm())) return true; - if (Kind != Memory || Mem.OffsetRegNum != 0) + if (Kind != k_Memory || Mem.OffsetRegNum != 0) return false; // Immediate offset in range [0, 4095]. if (!Mem.OffsetImm) return true; @@ -837,10 +837,10 @@ // If we have an immediate that's not a constant, treat it as a label // reference needing a fixup. If it is a constant, it's something else // and we reject it. - if (Kind == Immediate && !isa(getImm())) + if (Kind == k_Immediate && !isa(getImm())) return true; - if (Kind != Memory || Mem.OffsetRegNum != 0) + if (Kind != k_Memory || Mem.OffsetRegNum != 0) return false; // Immediate offset in range [-4095, 4095]. if (!Mem.OffsetImm) return true; @@ -848,7 +848,7 @@ return (Val > -4096 && Val < 4096) || (Val == INT32_MIN); } bool isPostIdxImm8() const { - if (Kind != Immediate) + if (Kind != k_Immediate) return false; const MCConstantExpr *CE = dyn_cast(getImm()); if (!CE) return false; @@ -856,8 +856,8 @@ return (Val > -256 && Val < 256) || (Val == INT32_MIN); } - bool isMSRMask() const { return Kind == MSRMask; } - bool isProcIFlags() const { return Kind == ProcIFlags; } + bool isMSRMask() const { return Kind == k_MSRMask; } + bool isProcIFlags() const { return Kind == k_ProcIFlags; } void addExpr(MCInst &Inst, const MCExpr *Expr) const { // Add as immediates when possible. Null MCExpr = 0. @@ -1150,7 +1150,7 @@ void addAM3OffsetOperands(MCInst &Inst, unsigned N) const { assert(N == 2 && "Invalid number of operands!"); - if (Kind == PostIndexRegister) { + if (Kind == k_PostIndexRegister) { int32_t Val = ARM_AM::getAM3Opc(PostIdxReg.isAdd ? ARM_AM::add : ARM_AM::sub, 0); Inst.addOperand(MCOperand::CreateReg(PostIdxReg.RegNum)); @@ -1216,7 +1216,7 @@ void addMemUImm12OffsetOperands(MCInst &Inst, unsigned N) const { assert(N == 2 && "Invalid number of operands!"); // If this is an immediate, it's a label reference. - if (Kind == Immediate) { + if (Kind == k_Immediate) { addExpr(Inst, getImm()); Inst.addOperand(MCOperand::CreateImm(0)); return; @@ -1231,7 +1231,7 @@ void addMemImm12OffsetOperands(MCInst &Inst, unsigned N) const { assert(N == 2 && "Invalid number of operands!"); // If this is an immediate, it's a label reference. - if (Kind == Immediate) { + if (Kind == k_Immediate) { addExpr(Inst, getImm()); Inst.addOperand(MCOperand::CreateImm(0)); return; @@ -1346,7 +1346,7 @@ virtual void print(raw_ostream &OS) const; static ARMOperand *CreateITMask(unsigned Mask, SMLoc S) { - ARMOperand *Op = new ARMOperand(ITCondMask); + ARMOperand *Op = new ARMOperand(k_ITCondMask); Op->ITMask.Mask = Mask; Op->StartLoc = S; Op->EndLoc = S; @@ -1354,7 +1354,7 @@ } static ARMOperand *CreateCondCode(ARMCC::CondCodes CC, SMLoc S) { - ARMOperand *Op = new ARMOperand(CondCode); + ARMOperand *Op = new ARMOperand(k_CondCode); Op->CC.Val = CC; Op->StartLoc = S; Op->EndLoc = S; @@ -1362,7 +1362,7 @@ } static ARMOperand *CreateCoprocNum(unsigned CopVal, SMLoc S) { - ARMOperand *Op = new ARMOperand(CoprocNum); + ARMOperand *Op = new ARMOperand(k_CoprocNum); Op->Cop.Val = CopVal; Op->StartLoc = S; Op->EndLoc = S; @@ -1370,7 +1370,7 @@ } static ARMOperand *CreateCoprocReg(unsigned CopVal, SMLoc S) { - ARMOperand *Op = new ARMOperand(CoprocReg); + ARMOperand *Op = new ARMOperand(k_CoprocReg); Op->Cop.Val = CopVal; Op->StartLoc = S; Op->EndLoc = S; @@ -1378,7 +1378,7 @@ } static ARMOperand *CreateCCOut(unsigned RegNum, SMLoc S) { - ARMOperand *Op = new ARMOperand(CCOut); + ARMOperand *Op = new ARMOperand(k_CCOut); Op->Reg.RegNum = RegNum; Op->StartLoc = S; Op->EndLoc = S; @@ -1386,7 +1386,7 @@ } static ARMOperand *CreateToken(StringRef Str, SMLoc S) { - ARMOperand *Op = new ARMOperand(Token); + ARMOperand *Op = new ARMOperand(k_Token); Op->Tok.Data = Str.data(); Op->Tok.Length = Str.size(); Op->StartLoc = S; @@ -1395,7 +1395,7 @@ } static ARMOperand *CreateReg(unsigned RegNum, SMLoc S, SMLoc E) { - ARMOperand *Op = new ARMOperand(Register); + ARMOperand *Op = new ARMOperand(k_Register); Op->Reg.RegNum = RegNum; Op->StartLoc = S; Op->EndLoc = E; @@ -1407,7 +1407,7 @@ unsigned ShiftReg, unsigned ShiftImm, SMLoc S, SMLoc E) { - ARMOperand *Op = new ARMOperand(ShiftedRegister); + ARMOperand *Op = new ARMOperand(k_ShiftedRegister); Op->RegShiftedReg.ShiftTy = ShTy; Op->RegShiftedReg.SrcReg = SrcReg; Op->RegShiftedReg.ShiftReg = ShiftReg; @@ -1421,7 +1421,7 @@ unsigned SrcReg, unsigned ShiftImm, SMLoc S, SMLoc E) { - ARMOperand *Op = new ARMOperand(ShiftedImmediate); + ARMOperand *Op = new ARMOperand(k_ShiftedImmediate); Op->RegShiftedImm.ShiftTy = ShTy; Op->RegShiftedImm.SrcReg = SrcReg; Op->RegShiftedImm.ShiftImm = ShiftImm; @@ -1432,7 +1432,7 @@ static ARMOperand *CreateShifterImm(bool isASR, unsigned Imm, SMLoc S, SMLoc E) { - ARMOperand *Op = new ARMOperand(ShifterImmediate); + ARMOperand *Op = new ARMOperand(k_ShifterImmediate); Op->ShifterImm.isASR = isASR; Op->ShifterImm.Imm = Imm; Op->StartLoc = S; @@ -1441,7 +1441,7 @@ } static ARMOperand *CreateRotImm(unsigned Imm, SMLoc S, SMLoc E) { - ARMOperand *Op = new ARMOperand(RotateImmediate); + ARMOperand *Op = new ARMOperand(k_RotateImmediate); Op->RotImm.Imm = Imm; Op->StartLoc = S; Op->EndLoc = E; @@ -1450,7 +1450,7 @@ static ARMOperand *CreateBitfield(unsigned LSB, unsigned Width, SMLoc S, SMLoc E) { - ARMOperand *Op = new ARMOperand(BitfieldDescriptor); + ARMOperand *Op = new ARMOperand(k_BitfieldDescriptor); Op->Bitfield.LSB = LSB; Op->Bitfield.Width = Width; Op->StartLoc = S; @@ -1461,13 +1461,13 @@ static ARMOperand * CreateRegList(const SmallVectorImpl > &Regs, SMLoc StartLoc, SMLoc EndLoc) { - KindTy Kind = RegisterList; + KindTy Kind = k_RegisterList; if (ARMMCRegisterClasses[ARM::DPRRegClassID].contains(Regs.front().first)) - Kind = DPRRegisterList; + Kind = k_DPRRegisterList; else if (ARMMCRegisterClasses[ARM::SPRRegClassID]. contains(Regs.front().first)) - Kind = SPRRegisterList; + Kind = k_SPRRegisterList; ARMOperand *Op = new ARMOperand(Kind); for (SmallVectorImpl >::const_iterator @@ -1480,7 +1480,7 @@ } static ARMOperand *CreateImm(const MCExpr *Val, SMLoc S, SMLoc E) { - ARMOperand *Op = new ARMOperand(Immediate); + ARMOperand *Op = new ARMOperand(k_Immediate); Op->Imm.Val = Val; Op->StartLoc = S; Op->EndLoc = E; @@ -1488,7 +1488,7 @@ } static ARMOperand *CreateFPImm(unsigned Val, SMLoc S, MCContext &Ctx) { - ARMOperand *Op = new ARMOperand(FPImmediate); + ARMOperand *Op = new ARMOperand(k_FPImmediate); Op->FPImm.Val = Val; Op->StartLoc = S; Op->EndLoc = S; @@ -1502,7 +1502,7 @@ unsigned ShiftImm, bool isNegative, SMLoc S, SMLoc E) { - ARMOperand *Op = new ARMOperand(Memory); + ARMOperand *Op = new ARMOperand(k_Memory); Op->Mem.BaseRegNum = BaseRegNum; Op->Mem.OffsetImm = OffsetImm; Op->Mem.OffsetRegNum = OffsetRegNum; @@ -1518,7 +1518,7 @@ ARM_AM::ShiftOpc ShiftTy, unsigned ShiftImm, SMLoc S, SMLoc E) { - ARMOperand *Op = new ARMOperand(PostIndexRegister); + ARMOperand *Op = new ARMOperand(k_PostIndexRegister); Op->PostIdxReg.RegNum = RegNum; Op->PostIdxReg.isAdd = isAdd; Op->PostIdxReg.ShiftTy = ShiftTy; @@ -1529,7 +1529,7 @@ } static ARMOperand *CreateMemBarrierOpt(ARM_MB::MemBOpt Opt, SMLoc S) { - ARMOperand *Op = new ARMOperand(MemBarrierOpt); + ARMOperand *Op = new ARMOperand(k_MemBarrierOpt); Op->MBOpt.Val = Opt; Op->StartLoc = S; Op->EndLoc = S; @@ -1537,7 +1537,7 @@ } static ARMOperand *CreateProcIFlags(ARM_PROC::IFlags IFlags, SMLoc S) { - ARMOperand *Op = new ARMOperand(ProcIFlags); + ARMOperand *Op = new ARMOperand(k_ProcIFlags); Op->IFlags.Val = IFlags; Op->StartLoc = S; Op->EndLoc = S; @@ -1545,7 +1545,7 @@ } static ARMOperand *CreateMSRMask(unsigned MMask, SMLoc S) { - ARMOperand *Op = new ARMOperand(MSRMask); + ARMOperand *Op = new ARMOperand(k_MSRMask); Op->MMask.Val = MMask; Op->StartLoc = S; Op->EndLoc = S; @@ -1557,17 +1557,17 @@ void ARMOperand::print(raw_ostream &OS) const { switch (Kind) { - case FPImmediate: + case k_FPImmediate: OS << ""; break; - case CondCode: + case k_CondCode: OS << ""; break; - case CCOut: + case k_CCOut: OS << ""; break; - case ITCondMask: { + case k_ITCondMask: { static char MaskStr[][6] = { "()", "(t)", "(e)", "(tt)", "(et)", "(te)", "(ee)", "(ttt)", "(ett)", "(tet)", "(eet)", "(tte)", "(ete)", "(tee)", "(eee)" }; @@ -1575,27 +1575,27 @@ OS << ""; break; } - case CoprocNum: + case k_CoprocNum: OS << ""; break; - case CoprocReg: + case k_CoprocReg: OS << ""; break; - case MSRMask: + case k_MSRMask: OS << ""; break; - case Immediate: + case k_Immediate: getImm()->print(OS); break; - case MemBarrierOpt: + case k_MemBarrierOpt: OS << ""; break; - case Memory: + case k_Memory: OS << ""; break; - case PostIndexRegister: + case k_PostIndexRegister: OS << "post-idx register " << (PostIdxReg.isAdd ? "" : "-") << PostIdxReg.RegNum; if (PostIdxReg.ShiftTy != ARM_AM::no_shift) @@ -1603,7 +1603,7 @@ << PostIdxReg.ShiftImm; OS << ">"; break; - case ProcIFlags: { + case k_ProcIFlags: { OS << "= 0; --i) @@ -1612,14 +1612,14 @@ OS << ">"; break; } - case Register: + case k_Register: OS << ""; break; - case ShifterImmediate: + case k_ShifterImmediate: OS << ""; break; - case ShiftedRegister: + case k_ShiftedRegister: OS << ""; break; - case ShiftedImmediate: + case k_ShiftedImmediate: OS << ""; break; - case RotateImmediate: + case k_RotateImmediate: OS << ""; break; - case BitfieldDescriptor: + case k_BitfieldDescriptor: OS << ""; break; - case RegisterList: - case DPRRegisterList: - case SPRRegisterList: { + case k_RegisterList: + case k_DPRRegisterList: + case k_SPRRegisterList: { OS << " &RegList = getRegList(); @@ -1656,7 +1656,7 @@ OS << ">"; break; } - case Token: + case k_Token: OS << "'" << getToken() << "'"; break; } @@ -3640,8 +3640,8 @@ // ARM mode 'blx' need special handling, as the register operand version // is predicable, but the label operand version is not. So, we can't rely // on the Mnemonic based checking to correctly figure out when to put - // a CondCode operand in the list. If we're trying to match the label - // version, remove the CondCode operand here. + // a k_CondCode operand in the list. If we're trying to match the label + // version, remove the k_CondCode operand here. if (!isThumb() && Mnemonic == "blx" && Operands.size() == 3 && static_cast(Operands[2])->isImm()) { ARMOperand *Op = static_cast(Operands[1]); From nicholas at mxc.ca Fri Oct 7 18:28:32 2011 From: nicholas at mxc.ca (Nick Lewycky) Date: Fri, 07 Oct 2011 23:28:32 -0000 Subject: [llvm-commits] [llvm] r141439 - /llvm/trunk/lib/MC/ELFObjectWriter.cpp Message-ID: <20111007232832.9084F3128018@llvm.org> Author: nicholas Date: Fri Oct 7 18:28:32 2011 New Revision: 141439 URL: http://llvm.org/viewvc/llvm-project?rev=141439&view=rev Log: Remove extraneous curlies. No functionality change. Modified: llvm/trunk/lib/MC/ELFObjectWriter.cpp Modified: llvm/trunk/lib/MC/ELFObjectWriter.cpp URL: http://llvm.org/viewvc/llvm-project/llvm/trunk/lib/MC/ELFObjectWriter.cpp?rev=141439&r1=141438&r2=141439&view=diff ============================================================================== --- llvm/trunk/lib/MC/ELFObjectWriter.cpp (original) +++ llvm/trunk/lib/MC/ELFObjectWriter.cpp Fri Oct 7 18:28:32 2011 @@ -1001,11 +1001,10 @@ // Nothing to do. break; - case ELF::SHT_GROUP: { + case ELF::SHT_GROUP: sh_link = SymbolTableIndex; sh_info = GroupSymbolIndex; break; - } default: assert(0 && "FIXME: sh_type value not supported!"); From nicholas at mxc.ca Fri Oct 7 18:29:53 2011 From: nicholas at mxc.ca (Nick Lewycky) Date: Fri, 07 Oct 2011 23:29:53 -0000 Subject: [llvm-commits] [llvm] r141440 - /llvm/trunk/lib/MC/ELFObjectWriter.cpp Message-ID: <20111007232953.2FB943128018@llvm.org> Author: nicholas Date: Fri Oct 7 18:29:53 2011 New Revision: 141440 URL: http://llvm.org/viewvc/llvm-project?rev=141440&view=rev Log: Don't emit the symbol table entry for the .symtab_shndx section either. Modified: llvm/trunk/lib/MC/ELFObjectWriter.cpp Modified: llvm/trunk/lib/MC/ELFObjectWriter.cpp URL: http://llvm.org/viewvc/llvm-project/llvm/trunk/lib/MC/ELFObjectWriter.cpp?rev=141440&r1=141439&r2=141440&view=diff ============================================================================== --- llvm/trunk/lib/MC/ELFObjectWriter.cpp (original) +++ llvm/trunk/lib/MC/ELFObjectWriter.cpp Fri Oct 7 18:29:53 2011 @@ -302,7 +302,8 @@ if (Section.getType() == ELF::SHT_RELA || Section.getType() == ELF::SHT_REL || Section.getType() == ELF::SHT_STRTAB || - Section.getType() == ELF::SHT_SYMTAB) + Section.getType() == ELF::SHT_SYMTAB || + Section.getType() == ELF::SHT_SYMTAB_SHNDX) continue; WriteSymbolEntry(SymtabF, ShndxF, 0, ELF::STT_SECTION, 0, 0, ELF::STV_DEFAULT, SectionIndexMap.lookup(&Section), false); From eli.friedman at gmail.com Fri Oct 7 18:40:49 2011 From: eli.friedman at gmail.com (Eli Friedman) Date: Fri, 07 Oct 2011 23:40:49 -0000 Subject: [llvm-commits] [llvm] r141441 - in /llvm/trunk: lib/Support/APFloat.cpp lib/Support/APInt.cpp unittests/ADT/APIntTest.cpp Message-ID: <20111007234050.0D6E62A6C12D@llvm.org> Author: efriedma Date: Fri Oct 7 18:40:49 2011 New Revision: 141441 URL: http://llvm.org/viewvc/llvm-project?rev=141441&view=rev Log: Fix APInt::operator*= so that it computes the correct result for large integers where there is unsigned overflow. Fix APFloat::toString so that it doesn't depend on the incorrect behavior in common cases (and computes the correct result in some rare cases). Fixes PR11086. Modified: llvm/trunk/lib/Support/APFloat.cpp llvm/trunk/lib/Support/APInt.cpp llvm/trunk/unittests/ADT/APIntTest.cpp Modified: llvm/trunk/lib/Support/APFloat.cpp URL: http://llvm.org/viewvc/llvm-project/llvm/trunk/lib/Support/APFloat.cpp?rev=141441&r1=141440&r2=141441&view=diff ============================================================================== --- llvm/trunk/lib/Support/APFloat.cpp (original) +++ llvm/trunk/lib/Support/APFloat.cpp Fri Oct 7 18:40:49 2011 @@ -3455,7 +3455,7 @@ // <= semantics->precision + e * 137 / 59 // (log_2(5) ~ 2.321928 < 2.322034 ~ 137/59) - unsigned precision = semantics->precision + 137 * texp / 59; + unsigned precision = semantics->precision + (137 * texp + 136) / 59; // Multiply significand by 5^e. // N * 5^0101 == N * 5^(1*1) * 5^(0*2) * 5^(1*4) * 5^(0*8) Modified: llvm/trunk/lib/Support/APInt.cpp URL: http://llvm.org/viewvc/llvm-project/llvm/trunk/lib/Support/APInt.cpp?rev=141441&r1=141440&r2=141441&view=diff ============================================================================== --- llvm/trunk/lib/Support/APInt.cpp (original) +++ llvm/trunk/lib/Support/APInt.cpp Fri Oct 7 18:40:49 2011 @@ -386,6 +386,7 @@ clearAllBits(); unsigned wordsToCopy = destWords >= getNumWords() ? getNumWords() : destWords; memcpy(pVal, dest, wordsToCopy * APINT_WORD_SIZE); + clearUnusedBits(); // delete dest array and return delete[] dest; @@ -471,7 +472,7 @@ return APInt(BitWidth, VAL * RHS.VAL); APInt Result(*this); Result *= RHS; - return Result.clearUnusedBits(); + return Result; } APInt APInt::operator+(const APInt& RHS) const { Modified: llvm/trunk/unittests/ADT/APIntTest.cpp URL: http://llvm.org/viewvc/llvm-project/llvm/trunk/unittests/ADT/APIntTest.cpp?rev=141441&r1=141440&r2=141441&view=diff ============================================================================== --- llvm/trunk/unittests/ADT/APIntTest.cpp (original) +++ llvm/trunk/unittests/ADT/APIntTest.cpp Fri Oct 7 18:40:49 2011 @@ -441,4 +441,13 @@ #endif #endif +TEST(APIntTest, mul_clear) { + APInt ValA(65, -1ULL); + APInt ValB(65, 4); + APInt ValC(65, 0); + ValC = ValA * ValB; + ValA *= ValB; + EXPECT_EQ(ValA.toString(10, false), ValC.toString(10, false)); +} + } From atrick at apple.com Fri Oct 7 18:46:21 2011 From: atrick at apple.com (Andrew Trick) Date: Fri, 07 Oct 2011 23:46:21 -0000 Subject: [llvm-commits] [llvm] r141442 - in /llvm/trunk: include/llvm/Analysis/ScalarEvolutionExpander.h lib/Analysis/ScalarEvolutionExpander.cpp lib/Transforms/Scalar/LoopStrengthReduce.cpp Message-ID: <20111007234621.E85FF3128018@llvm.org> Author: atrick Date: Fri Oct 7 18:46:21 2011 New Revision: 141442 URL: http://llvm.org/viewvc/llvm-project?rev=141442&view=rev Log: LSR should only reuse phis that match its formula. Fixes rdar://problem/5064068 Modified: llvm/trunk/include/llvm/Analysis/ScalarEvolutionExpander.h llvm/trunk/lib/Analysis/ScalarEvolutionExpander.cpp llvm/trunk/lib/Transforms/Scalar/LoopStrengthReduce.cpp Modified: llvm/trunk/include/llvm/Analysis/ScalarEvolutionExpander.h URL: http://llvm.org/viewvc/llvm-project/llvm/trunk/include/llvm/Analysis/ScalarEvolutionExpander.h?rev=141442&r1=141441&r2=141442&view=diff ============================================================================== --- llvm/trunk/include/llvm/Analysis/ScalarEvolutionExpander.h (original) +++ llvm/trunk/include/llvm/Analysis/ScalarEvolutionExpander.h Fri Oct 7 18:46:21 2011 @@ -64,6 +64,11 @@ /// in a more literal form. bool CanonicalMode; + /// When invoked from LSR, the expander is in "strength reduction" mode. The + /// only difference is that phi's are only reused if they are already in + /// "expanded" form. + bool LSRMode; + typedef IRBuilder BuilderType; BuilderType Builder; @@ -73,7 +78,8 @@ /// SCEVExpander - Construct a SCEVExpander in "canonical" mode. explicit SCEVExpander(ScalarEvolution &se, const char *name) : SE(se), IVName(name), IVIncInsertLoop(0), IVIncInsertPos(0), - CanonicalMode(true), Builder(se.getContext(), TargetFolder(se.TD)) {} + CanonicalMode(true), LSRMode(false), + Builder(se.getContext(), TargetFolder(se.TD)) {} /// clear - Erase the contents of the InsertedExpressions map so that users /// trying to expand the same expression into multiple BasicBlocks or @@ -88,8 +94,7 @@ /// canonical induction variable of the specified type for the specified /// loop (inserting one if there is none). A canonical induction variable /// starts at zero and steps by one on each iteration. - PHINode *getOrInsertCanonicalInductionVariable(const Loop *L, - Type *Ty); + PHINode *getOrInsertCanonicalInductionVariable(const Loop *L, Type *Ty); /// expandCodeFor - Insert code to directly compute the specified SCEV /// expression into the program. The inserted code is inserted into the @@ -127,13 +132,14 @@ /// is useful for late optimization passes. void disableCanonicalMode() { CanonicalMode = false; } + void enableLSRMode() { LSRMode = true; } + /// clearInsertPoint - Clear the current insertion point. This is useful /// if the instruction that had been serving as the insertion point may /// have been deleted. void clearInsertPoint() { Builder.ClearInsertionPoint(); } - private: LLVMContext &getContext() const { return SE.getContext(); } @@ -208,6 +214,11 @@ void restoreInsertPoint(BasicBlock *BB, BasicBlock::iterator I); + bool isNormalAddRecExprPHI(PHINode *PN, Instruction *IncV, const Loop *L); + + bool isExpandedAddRecExprPHI(PHINode *PN, Instruction *IncV, const Loop *L, + Type *ExpandTy); + Value *expandAddRecExprLiterally(const SCEVAddRecExpr *); PHINode *getAddRecExprPHILiterally(const SCEVAddRecExpr *Normalized, const Loop *L, Modified: llvm/trunk/lib/Analysis/ScalarEvolutionExpander.cpp URL: http://llvm.org/viewvc/llvm-project/llvm/trunk/lib/Analysis/ScalarEvolutionExpander.cpp?rev=141442&r1=141441&r2=141442&view=diff ============================================================================== --- llvm/trunk/lib/Analysis/ScalarEvolutionExpander.cpp (original) +++ llvm/trunk/lib/Analysis/ScalarEvolutionExpander.cpp Fri Oct 7 18:46:21 2011 @@ -17,6 +17,7 @@ #include "llvm/Analysis/LoopInfo.h" #include "llvm/IntrinsicInst.h" #include "llvm/LLVMContext.h" +#include "llvm/Support/Debug.h" #include "llvm/Target/TargetData.h" #include "llvm/ADT/STLExtras.h" @@ -843,6 +844,82 @@ } } +/// Determine if this is a well-behaved chain of instructions leading back to +/// the PHI. If so, it may be reused by expanded expressions. +bool SCEVExpander::isNormalAddRecExprPHI(PHINode *PN, Instruction *IncV, + const Loop *L) { + if (IncV->getNumOperands() == 0 || isa(IncV) || + (isa(IncV) && !isa(IncV))) + return false; + // If any of the operands don't dominate the insert position, bail. + // Addrec operands are always loop-invariant, so this can only happen + // if there are instructions which haven't been hoisted. + if (L == IVIncInsertLoop) { + for (User::op_iterator OI = IncV->op_begin()+1, + OE = IncV->op_end(); OI != OE; ++OI) + if (Instruction *OInst = dyn_cast(OI)) + if (!SE.DT->dominates(OInst, IVIncInsertPos)) + return false; + } + // Advance to the next instruction. + IncV = dyn_cast(IncV->getOperand(0)); + if (!IncV) + return false; + + if (IncV->mayHaveSideEffects()) + return false; + + if (IncV != PN) + return true; + + return isNormalAddRecExprPHI(PN, IncV, L); +} + +/// Determine if this cyclic phi is in a form that would have been generated by +/// LSR. We don't care if the phi was actually expanded in this pass, as long +/// as it is in a low-cost form, for example, no implied multiplication. This +/// should match any patterns generated by getAddRecExprPHILiterally and +/// expandAddtoGEP. +bool SCEVExpander::isExpandedAddRecExprPHI(PHINode *PN, Instruction *IncV, + const Loop *L, Type *ExpandTy) { + switch (IncV->getOpcode()) { + // Check for a simple Add/Sub or GEP of a loop invariant step. + case Instruction::Add: + case Instruction::Sub: + return IncV->getOperand(0) == PN + && L->isLoopInvariant(IncV->getOperand(1)); + case Instruction::BitCast: + IncV = dyn_cast(IncV->getOperand(0)); + if (!IncV) + return false; + // fall-thru to GEP handling + case Instruction::GetElementPtr: { + // This must be a pointer addition of constants (pretty) or some number of + // address-size elements (ugly). + for (Instruction::op_iterator I = IncV->op_begin()+1, E = IncV->op_end(); + I != E; ++I) { + if (isa(*I)) + continue; + // ugly geps have 2 operands. + // i1* is used by the expander to represent an address-size element. + if (IncV->getNumOperands() != 2) + return false; + unsigned AS = cast(ExpandTy)->getAddressSpace(); + if (IncV->getType() != Type::getInt1PtrTy(SE.getContext(), AS) + && IncV->getType() != Type::getInt8PtrTy(SE.getContext(), AS)) + return false; + break; + } + IncV = dyn_cast(IncV->getOperand(0)); + if (IncV && IncV->getOpcode() == Instruction::BitCast) + IncV = dyn_cast(IncV->getOperand(0)); + return IncV == PN; + } + default: + return false; + } +} + /// getAddRecExprPHILiterally - Helper for expandAddRecExprLiterally. Expand /// the base addrec, which is the addrec without any non-loop-dominating /// values, and return the PHI. @@ -854,70 +931,45 @@ assert((!IVIncInsertLoop||IVIncInsertPos) && "Uninitialized insert position"); // Reuse a previously-inserted PHI, if present. - for (BasicBlock::iterator I = L->getHeader()->begin(); - PHINode *PN = dyn_cast(I); ++I) - if (SE.isSCEVable(PN->getType()) && - (SE.getEffectiveSCEVType(PN->getType()) == - SE.getEffectiveSCEVType(Normalized->getType())) && - SE.getSCEV(PN) == Normalized) - if (BasicBlock *LatchBlock = L->getLoopLatch()) { - Instruction *IncV = - cast(PN->getIncomingValueForBlock(LatchBlock)); - - // Determine if this is a well-behaved chain of instructions leading - // back to the PHI. It probably will be, if we're scanning an inner - // loop already visited by LSR for example, but it wouldn't have - // to be. + BasicBlock *LatchBlock = L->getLoopLatch(); + if (LatchBlock) { + for (BasicBlock::iterator I = L->getHeader()->begin(); + PHINode *PN = dyn_cast(I); ++I) { + if (!SE.isSCEVable(PN->getType()) || + (SE.getEffectiveSCEVType(PN->getType()) != + SE.getEffectiveSCEVType(Normalized->getType())) || + SE.getSCEV(PN) != Normalized) + continue; + + Instruction *IncV = + cast(PN->getIncomingValueForBlock(LatchBlock)); + + if (LSRMode) { + if (!isExpandedAddRecExprPHI(PN, IncV, L, ExpandTy)) + continue; + } + else { + if (!isNormalAddRecExprPHI(PN, IncV, L)) + continue; + } + // Ok, the add recurrence looks usable. + // Remember this PHI, even in post-inc mode. + InsertedValues.insert(PN); + // Remember the increment. + rememberInstruction(IncV); + if (L == IVIncInsertLoop) do { - if (IncV->getNumOperands() == 0 || isa(IncV) || - (isa(IncV) && !isa(IncV))) { - IncV = 0; - break; - } - // If any of the operands don't dominate the insert position, bail. - // Addrec operands are always loop-invariant, so this can only happen - // if there are instructions which haven't been hoisted. - if (L == IVIncInsertLoop) { - for (User::op_iterator OI = IncV->op_begin()+1, - OE = IncV->op_end(); OI != OE; ++OI) - if (Instruction *OInst = dyn_cast(OI)) - if (!SE.DT->dominates(OInst, IVIncInsertPos)) { - IncV = 0; - break; - } - } - if (!IncV) + if (SE.DT->dominates(IncV, IVIncInsertPos)) break; - // Advance to the next instruction. - IncV = dyn_cast(IncV->getOperand(0)); - if (!IncV) - break; - if (IncV->mayHaveSideEffects()) { - IncV = 0; - break; - } + // Make sure the increment is where we want it. But don't move it + // down past a potential existing post-inc user. + IncV->moveBefore(IVIncInsertPos); + IVIncInsertPos = IncV; + IncV = cast(IncV->getOperand(0)); } while (IncV != PN); - - if (IncV) { - // Ok, the add recurrence looks usable. - // Remember this PHI, even in post-inc mode. - InsertedValues.insert(PN); - // Remember the increment. - IncV = cast(PN->getIncomingValueForBlock(LatchBlock)); - rememberInstruction(IncV); - if (L == IVIncInsertLoop) - do { - if (SE.DT->dominates(IncV, IVIncInsertPos)) - break; - // Make sure the increment is where we want it. But don't move it - // down past a potential existing post-inc user. - IncV->moveBefore(IVIncInsertPos); - IVIncInsertPos = IncV; - IncV = cast(IncV->getOperand(0)); - } while (IncV != PN); - return PN; - } - } + return PN; + } + } // Save the original insertion point so we can restore it when we're done. BasicBlock *SaveInsertBB = Builder.GetInsertBlock(); Modified: llvm/trunk/lib/Transforms/Scalar/LoopStrengthReduce.cpp URL: http://llvm.org/viewvc/llvm-project/llvm/trunk/lib/Transforms/Scalar/LoopStrengthReduce.cpp?rev=141442&r1=141441&r2=141442&view=diff ============================================================================== --- llvm/trunk/lib/Transforms/Scalar/LoopStrengthReduce.cpp (original) +++ llvm/trunk/lib/Transforms/Scalar/LoopStrengthReduce.cpp Fri Oct 7 18:46:21 2011 @@ -3770,6 +3770,7 @@ SCEVExpander Rewriter(SE, "lsr"); Rewriter.disableCanonicalMode(); + Rewriter.enableLSRMode(); Rewriter.setIVIncInsertPos(L, IVIncInsertPos); // Expand the new value definitions and update the users. From grosbach at apple.com Fri Oct 7 18:56:00 2011 From: grosbach at apple.com (Jim Grosbach) Date: Fri, 07 Oct 2011 23:56:00 -0000 Subject: [llvm-commits] [llvm] r141446 - in /llvm/trunk: lib/Target/ARM/ARMInstrFormats.td lib/Target/ARM/ARMInstrNEON.td lib/Target/ARM/AsmParser/ARMAsmParser.cpp lib/Target/ARM/InstPrinter/ARMInstPrinter.cpp lib/Target/ARM/InstPrinter/ARMInstPrinter.h test/MC/ARM/neont2-dup-encoding.s utils/TableGen/EDEmitter.cpp Message-ID: <20111007235600.6994C2A6C12D@llvm.org> Author: grosbach Date: Fri Oct 7 18:56:00 2011 New Revision: 141446 URL: http://llvm.org/viewvc/llvm-project?rev=141446&view=rev Log: ARM NEON assembly parsing and encoding for VDUP(scalar). Modified: llvm/trunk/lib/Target/ARM/ARMInstrFormats.td llvm/trunk/lib/Target/ARM/ARMInstrNEON.td llvm/trunk/lib/Target/ARM/AsmParser/ARMAsmParser.cpp llvm/trunk/lib/Target/ARM/InstPrinter/ARMInstPrinter.cpp llvm/trunk/lib/Target/ARM/InstPrinter/ARMInstPrinter.h llvm/trunk/test/MC/ARM/neont2-dup-encoding.s llvm/trunk/utils/TableGen/EDEmitter.cpp Modified: llvm/trunk/lib/Target/ARM/ARMInstrFormats.td URL: http://llvm.org/viewvc/llvm-project/llvm/trunk/lib/Target/ARM/ARMInstrFormats.td?rev=141446&r1=141445&r2=141446&view=diff ============================================================================== --- llvm/trunk/lib/Target/ARM/ARMInstrFormats.td (original) +++ llvm/trunk/lib/Target/ARM/ARMInstrFormats.td Fri Oct 7 18:56:00 2011 @@ -1951,7 +1951,6 @@ bits<5> Vd; bits<5> Vm; - bits<4> lane; let Inst{22} = Vd{4}; let Inst{15-12} = Vd{3-0}; Modified: llvm/trunk/lib/Target/ARM/ARMInstrNEON.td URL: http://llvm.org/viewvc/llvm-project/llvm/trunk/lib/Target/ARM/ARMInstrNEON.td?rev=141446&r1=141445&r2=141446&view=diff ============================================================================== --- llvm/trunk/lib/Target/ARM/ARMInstrNEON.td (original) +++ llvm/trunk/lib/Target/ARM/ARMInstrNEON.td Fri Oct 7 18:56:00 2011 @@ -11,6 +11,35 @@ // //===----------------------------------------------------------------------===// + +//===----------------------------------------------------------------------===// +// NEON-specific Operands. +//===----------------------------------------------------------------------===// +def VectorIndex8Operand : AsmOperandClass { let Name = "VectorIndex8"; } +def VectorIndex16Operand : AsmOperandClass { let Name = "VectorIndex16"; } +def VectorIndex32Operand : AsmOperandClass { let Name = "VectorIndex32"; } +def VectorIndex8 : Operand, ImmLeaf { + let ParserMatchClass = VectorIndex8Operand; + let PrintMethod = "printVectorIndex"; + let MIOperandInfo = (ops i32imm); +} +def VectorIndex16 : Operand, ImmLeaf { + let ParserMatchClass = VectorIndex16Operand; + let PrintMethod = "printVectorIndex"; + let MIOperandInfo = (ops i32imm); +} +def VectorIndex32 : Operand, ImmLeaf { + let ParserMatchClass = VectorIndex32Operand; + let PrintMethod = "printVectorIndex"; + let MIOperandInfo = (ops i32imm); +} + //===----------------------------------------------------------------------===// // NEON-specific DAG Nodes. //===----------------------------------------------------------------------===// @@ -4518,36 +4547,42 @@ // VDUP : Vector Duplicate Lane (from scalar to all elements) class VDUPLND op19_16, string OpcodeStr, string Dt, - ValueType Ty> - : NVDupLane + : NVDupLane; class VDUPLNQ op19_16, string OpcodeStr, string Dt, - ValueType ResTy, ValueType OpTy> - : NVDupLane + : NVDupLane; + VectorIndex32:$lane)))]>; // Inst{19-16} is partially specified depending on the element size. -def VDUPLN8d : VDUPLND<{?,?,?,1}, "vdup", "8", v8i8> { +def VDUPLN8d : VDUPLND<{?,?,?,1}, "vdup", "8", v8i8, VectorIndex8> { + bits<3> lane; let Inst{19-17} = lane{2-0}; } -def VDUPLN16d : VDUPLND<{?,?,1,0}, "vdup", "16", v4i16> { +def VDUPLN16d : VDUPLND<{?,?,1,0}, "vdup", "16", v4i16, VectorIndex16> { + bits<2> lane; let Inst{19-18} = lane{1-0}; } -def VDUPLN32d : VDUPLND<{?,1,0,0}, "vdup", "32", v2i32> { +def VDUPLN32d : VDUPLND<{?,1,0,0}, "vdup", "32", v2i32, VectorIndex32> { + bits<1> lane; let Inst{19} = lane{0}; } -def VDUPLN8q : VDUPLNQ<{?,?,?,1}, "vdup", "8", v16i8, v8i8> { +def VDUPLN8q : VDUPLNQ<{?,?,?,1}, "vdup", "8", v16i8, v8i8, VectorIndex8> { + bits<3> lane; let Inst{19-17} = lane{2-0}; } -def VDUPLN16q : VDUPLNQ<{?,?,1,0}, "vdup", "16", v8i16, v4i16> { +def VDUPLN16q : VDUPLNQ<{?,?,1,0}, "vdup", "16", v8i16, v4i16, VectorIndex16> { + bits<2> lane; let Inst{19-18} = lane{1-0}; } -def VDUPLN32q : VDUPLNQ<{?,1,0,0}, "vdup", "32", v4i32, v2i32> { +def VDUPLN32q : VDUPLNQ<{?,1,0,0}, "vdup", "32", v4i32, v2i32, VectorIndex32> { + bits<1> lane; let Inst{19} = lane{0}; } Modified: llvm/trunk/lib/Target/ARM/AsmParser/ARMAsmParser.cpp URL: http://llvm.org/viewvc/llvm-project/llvm/trunk/lib/Target/ARM/AsmParser/ARMAsmParser.cpp?rev=141446&r1=141445&r2=141446&view=diff ============================================================================== --- llvm/trunk/lib/Target/ARM/AsmParser/ARMAsmParser.cpp (original) +++ llvm/trunk/lib/Target/ARM/AsmParser/ARMAsmParser.cpp Fri Oct 7 18:56:00 2011 @@ -254,6 +254,7 @@ k_PostIndexRegister, k_MSRMask, k_ProcIFlags, + k_VectorIndex, k_Register, k_RegisterList, k_DPRRegisterList, @@ -304,6 +305,10 @@ } Reg; struct { + unsigned Val; + } VectorIndex; + + struct { const MCExpr *Val; } Imm; @@ -419,6 +424,9 @@ case k_BitfieldDescriptor: Bitfield = o.Bitfield; break; + case k_VectorIndex: + VectorIndex = o.VectorIndex; + break; } } @@ -463,6 +471,11 @@ return FPImm.Val; } + unsigned getVectorIndex() const { + assert(Kind == k_VectorIndex && "Invalid access!"); + return VectorIndex.Val; + } + ARM_MB::MemBOpt getMemBarrierOpt() const { assert(Kind == k_MemBarrierOpt && "Invalid access!"); return MBOpt.Val; @@ -859,6 +872,21 @@ bool isMSRMask() const { return Kind == k_MSRMask; } bool isProcIFlags() const { return Kind == k_ProcIFlags; } + bool isVectorIndex8() const { + if (Kind != k_VectorIndex) return false; + return VectorIndex.Val < 8; + } + bool isVectorIndex16() const { + if (Kind != k_VectorIndex) return false; + return VectorIndex.Val < 4; + } + bool isVectorIndex32() const { + if (Kind != k_VectorIndex) return false; + return VectorIndex.Val < 2; + } + + + void addExpr(MCInst &Inst, const MCExpr *Expr) const { // Add as immediates when possible. Null MCExpr = 0. if (Expr == 0) @@ -1343,6 +1371,21 @@ Inst.addOperand(MCOperand::CreateImm(unsigned(getProcIFlags()))); } + void addVectorIndex8Operands(MCInst &Inst, unsigned N) const { + assert(N == 1 && "Invalid number of operands!"); + Inst.addOperand(MCOperand::CreateImm(getVectorIndex())); + } + + void addVectorIndex16Operands(MCInst &Inst, unsigned N) const { + assert(N == 1 && "Invalid number of operands!"); + Inst.addOperand(MCOperand::CreateImm(getVectorIndex())); + } + + void addVectorIndex32Operands(MCInst &Inst, unsigned N) const { + assert(N == 1 && "Invalid number of operands!"); + Inst.addOperand(MCOperand::CreateImm(getVectorIndex())); + } + virtual void print(raw_ostream &OS) const; static ARMOperand *CreateITMask(unsigned Mask, SMLoc S) { @@ -1479,6 +1522,15 @@ return Op; } + static ARMOperand *CreateVectorIndex(unsigned Idx, SMLoc S, SMLoc E, + MCContext &Ctx) { + ARMOperand *Op = new ARMOperand(k_VectorIndex); + Op->VectorIndex.Val = Idx; + Op->StartLoc = S; + Op->EndLoc = E; + return Op; + } + static ARMOperand *CreateImm(const MCExpr *Val, SMLoc S, SMLoc E) { ARMOperand *Op = new ARMOperand(k_Immediate); Op->Imm.Val = Val; @@ -1659,6 +1711,9 @@ case k_Token: OS << "'" << getToken() << "'"; break; + case k_VectorIndex: + OS << ""; + break; } } @@ -1700,6 +1755,39 @@ if (!RegNum) return -1; Parser.Lex(); // Eat identifier token. + +#if 0 + // Also check for an index operand. This is only legal for vector registers, + // but that'll get caught OK in operand matching, so we don't need to + // explicitly filter everything else out here. + if (Parser.getTok().is(AsmToken::LBrac)) { + SMLoc SIdx = Parser.getTok().getLoc(); + Parser.Lex(); // Eat left bracket token. + + const MCExpr *ImmVal; + SMLoc ExprLoc = Parser.getTok().getLoc(); + if (getParser().ParseExpression(ImmVal)) + return MatchOperand_ParseFail; + const MCConstantExpr *MCE = dyn_cast(ImmVal); + if (!MCE) { + TokError("immediate value expected for vector index"); + return MatchOperand_ParseFail; + } + + SMLoc E = Parser.getTok().getLoc(); + if (Parser.getTok().isNot(AsmToken::RBrac)) { + Error(E, "']' expected"); + return MatchOperand_ParseFail; + } + + Parser.Lex(); // Eat right bracket token. + + Operands.push_back(ARMOperand::CreateVectorIndex(MCE->getValue(), + SIdx, E, + getContext())); + } +#endif + return RegNum; } @@ -1815,6 +1903,37 @@ Operands.push_back(ARMOperand::CreateToken(ExclaimTok.getString(), ExclaimTok.getLoc())); Parser.Lex(); // Eat exclaim token + return false; + } + + // Also check for an index operand. This is only legal for vector registers, + // but that'll get caught OK in operand matching, so we don't need to + // explicitly filter everything else out here. + if (Parser.getTok().is(AsmToken::LBrac)) { + SMLoc SIdx = Parser.getTok().getLoc(); + Parser.Lex(); // Eat left bracket token. + + const MCExpr *ImmVal; + SMLoc ExprLoc = Parser.getTok().getLoc(); + if (getParser().ParseExpression(ImmVal)) + return MatchOperand_ParseFail; + const MCConstantExpr *MCE = dyn_cast(ImmVal); + if (!MCE) { + TokError("immediate value expected for vector index"); + return MatchOperand_ParseFail; + } + + SMLoc E = Parser.getTok().getLoc(); + if (Parser.getTok().isNot(AsmToken::RBrac)) { + Error(E, "']' expected"); + return MatchOperand_ParseFail; + } + + Parser.Lex(); // Eat right bracket token. + + Operands.push_back(ARMOperand::CreateVectorIndex(MCE->getValue(), + SIdx, E, + getContext())); } return false; Modified: llvm/trunk/lib/Target/ARM/InstPrinter/ARMInstPrinter.cpp URL: http://llvm.org/viewvc/llvm-project/llvm/trunk/lib/Target/ARM/InstPrinter/ARMInstPrinter.cpp?rev=141446&r1=141445&r2=141446&view=diff ============================================================================== --- llvm/trunk/lib/Target/ARM/InstPrinter/ARMInstPrinter.cpp (original) +++ llvm/trunk/lib/Target/ARM/InstPrinter/ARMInstPrinter.cpp Fri Oct 7 18:56:00 2011 @@ -981,3 +981,8 @@ case 3: O << "24"; break; } } + +void ARMInstPrinter::printVectorIndex(const MCInst *MI, unsigned OpNum, + raw_ostream &O) { + O << "[" << MI->getOperand(OpNum).getImm() << "]"; +} Modified: llvm/trunk/lib/Target/ARM/InstPrinter/ARMInstPrinter.h URL: http://llvm.org/viewvc/llvm-project/llvm/trunk/lib/Target/ARM/InstPrinter/ARMInstPrinter.h?rev=141446&r1=141445&r2=141446&view=diff ============================================================================== --- llvm/trunk/lib/Target/ARM/InstPrinter/ARMInstPrinter.h (original) +++ llvm/trunk/lib/Target/ARM/InstPrinter/ARMInstPrinter.h Fri Oct 7 18:56:00 2011 @@ -127,6 +127,7 @@ void printPCLabel(const MCInst *MI, unsigned OpNum, raw_ostream &O); void printT2LdrLabelOperand(const MCInst *MI, unsigned OpNum, raw_ostream &O); + void printVectorIndex(const MCInst *MI, unsigned OpNum, raw_ostream &O); }; } // end namespace llvm Modified: llvm/trunk/test/MC/ARM/neont2-dup-encoding.s URL: http://llvm.org/viewvc/llvm-project/llvm/trunk/test/MC/ARM/neont2-dup-encoding.s?rev=141446&r1=141445&r2=141446&view=diff ============================================================================== --- llvm/trunk/test/MC/ARM/neont2-dup-encoding.s (original) +++ llvm/trunk/test/MC/ARM/neont2-dup-encoding.s Fri Oct 7 18:56:00 2011 @@ -16,16 +16,28 @@ @ CHECK: vdup.16 q8, r5 @ encoding: [0xa0,0xee,0xb0,0x5b] @ CHECK: vdup.32 q7, r6 @ encoding: [0xae,0xee,0x10,0x6b] -@ vdup.8 d16, d16[1] -@ vdup.16 d16, d16[1] -@ vdup.32 d16, d16[1] -@ vdup.8 q8, d16[1] -@ vdup.16 q8, d16[1] -@ vdup.32 q8, d16[1] + vdup.8 d16, d11[0] + vdup.16 d17, d12[0] + vdup.32 d18, d13[0] + vdup.8 q3, d10[0] + vdup.16 q9, d9[0] + vdup.32 q8, d8[0] + vdup.8 d16, d11[1] + vdup.16 d17, d12[1] + vdup.32 d18, d13[1] + vdup.8 q3, d10[1] + vdup.16 q9, d9[1] + vdup.32 q8, d8[1] -@ FIXME: vdup.8 d16, d16[1] @ encoding: [0x20,0x0c,0xf3,0xff] -@ FIXME: vdup.16 d16, d16[1] @ encoding: [0x20,0x0c,0xf6,0xff] -@ FIXME: vdup.32 d16, d16[1] @ encoding: [0x20,0x0c,0xfc,0xff] -@ FIXME: vdup.8 q8, d16[1] @ encoding: [0x60,0x0c,0xf3,0xff] -@ FIXME: vdup.16 q8, d16[1] @ encoding: [0x60,0x0c,0xf6,0xff] -@ FIXME: vdup.32 q8, d16[1] @ encoding: [0x60,0x0c,0xfc,0xff] +@ CHECK: vdup.8 d16, d11[0] @ encoding: [0xf1,0xff,0x0b,0x0c] +@ CHECK: vdup.16 d17, d12[0] @ encoding: [0xf2,0xff,0x0c,0x1c] +@ CHECK: vdup.32 d18, d13[0] @ encoding: [0xf4,0xff,0x0d,0x2c] +@ CHECK: vdup.8 q3, d10[0] @ encoding: [0xb1,0xff,0x4a,0x6c] +@ CHECK: vdup.16 q9, d9[0] @ encoding: [0xf2,0xff,0x49,0x2c] +@ CHECK: vdup.32 q8, d8[0] @ encoding: [0xf4,0xff,0x48,0x0c] +@ CHECK: vdup.8 d16, d11[1] @ encoding: [0xf3,0xff,0x0b,0x0c] +@ CHECK: vdup.16 d17, d12[1] @ encoding: [0xf6,0xff,0x0c,0x1c] +@ CHECK: vdup.32 d18, d13[1] @ encoding: [0xfc,0xff,0x0d,0x2c] +@ CHECK: vdup.8 q3, d10[1] @ encoding: [0xb3,0xff,0x4a,0x6c] +@ CHECK: vdup.16 q9, d9[1] @ encoding: [0xf6,0xff,0x49,0x2c] +@ CHECK: vdup.32 q8, d8[1] @ encoding: [0xfc,0xff,0x48,0x0c] Modified: llvm/trunk/utils/TableGen/EDEmitter.cpp URL: http://llvm.org/viewvc/llvm-project/llvm/trunk/utils/TableGen/EDEmitter.cpp?rev=141446&r1=141445&r2=141446&view=diff ============================================================================== --- llvm/trunk/utils/TableGen/EDEmitter.cpp (original) +++ llvm/trunk/utils/TableGen/EDEmitter.cpp Fri Oct 7 18:56:00 2011 @@ -624,6 +624,9 @@ IMM("postidx_imm8s4"); IMM("imm_sr"); IMM("imm1_31"); + IMM("VectorIndex8"); + IMM("VectorIndex16"); + IMM("VectorIndex32"); MISC("brtarget", "kOperandTypeARMBranchTarget"); // ? MISC("uncondbrtarget", "kOperandTypeARMBranchTarget"); // ? From grosbach at apple.com Fri Oct 7 18:57:03 2011 From: grosbach at apple.com (Jim Grosbach) Date: Fri, 07 Oct 2011 23:57:03 -0000 Subject: [llvm-commits] [llvm] r141447 - /llvm/trunk/test/MC/ARM/neon-dup-encoding.s Message-ID: <20111007235703.829143128018@llvm.org> Author: grosbach Date: Fri Oct 7 18:57:03 2011 New Revision: 141447 URL: http://llvm.org/viewvc/llvm-project?rev=141447&view=rev Log: Enable ARM mode VDUP(scalar) tests. Modified: llvm/trunk/test/MC/ARM/neon-dup-encoding.s Modified: llvm/trunk/test/MC/ARM/neon-dup-encoding.s URL: http://llvm.org/viewvc/llvm-project/llvm/trunk/test/MC/ARM/neon-dup-encoding.s?rev=141447&r1=141446&r2=141447&view=diff ============================================================================== --- llvm/trunk/test/MC/ARM/neon-dup-encoding.s (original) +++ llvm/trunk/test/MC/ARM/neon-dup-encoding.s Fri Oct 7 18:57:03 2011 @@ -16,18 +16,18 @@ @ CHECK: vdup.16 q8, r0 @ encoding: [0xb0,0x0b,0xa0,0xee] @ CHECK: vdup.32 q8, r0 @ encoding: [0x90,0x0b,0xa0,0xee] -@ vdup.8 d16, d16[1] -@ vdup.16 d16, d16[1] -@ vdup.32 d16, d16[1] + vdup.8 d16, d16[1] + vdup.16 d16, d16[1] + vdup.32 d16, d16[1] -@ FIXME: vdup.8 d16, d16[1] @ encoding: [0x20,0x0c,0xf3,0xf3] -@ FIXME: vdup.16 d16, d16[1] @ encoding: [0x20,0x0c,0xf6,0xf3] -@ FIXME: vdup.32 d16, d16[1] @ encoding: [0x20,0x0c,0xfc,0xf3] +@ CHECK: vdup.8 d16, d16[1] @ encoding: [0x20,0x0c,0xf3,0xf3] +@ CHECK: vdup.16 d16, d16[1] @ encoding: [0x20,0x0c,0xf6,0xf3] +@ CHECK: vdup.32 d16, d16[1] @ encoding: [0x20,0x0c,0xfc,0xf3] -@ vdup.8 q8, d16[1] -@ vdup.16 q8, d16[1] -@ vdup.32 q8, d16[1] + vdup.8 q8, d16[1] + vdup.16 q8, d16[1] + vdup.32 q8, d16[1] -@ FIXME: vdup.8 q8, d16[1] @ encoding: [0x60,0x0c,0xf3,0xf3] -@ FIXME: vdup.16 q8, d16[1] @ encoding: [0x60,0x0c,0xf6,0xf3] -@ FIXME: vdup.32 q8, d16[1] @ encoding: [0x60,0x0c,0xfc,0xf3] +@ CHECK: vdup.8 q8, d16[1] @ encoding: [0x60,0x0c,0xf3,0xf3] +@ CHECK: vdup.16 q8, d16[1] @ encoding: [0x60,0x0c,0xf6,0xf3] +@ CHECK: vdup.32 q8, d16[1] @ encoding: [0x60,0x0c,0xfc,0xf3] From apazos at codeaurora.org Fri Oct 7 19:08:34 2011 From: apazos at codeaurora.org (Ana Pazos) Date: Fri, 7 Oct 2011 17:08:34 -0700 Subject: [llvm-commits] [llvm] r141365 - in /llvm/trunk: lib/Target/ARM/ARMISelDAGToDAG.cpp lib/Target/ARM/ARMISelLowering.cpp lib/Target/ARM/ARMInstrInfo.td lib/Target/ARM/ARMInstrThumb2.td test/CodeGen/ARM/iabs.ll test/CodeGen/Thumb/iabs.ll In-Reply-To: References: <20111007161509.46571312800A@llvm.org> <5751F138-40A5-4245-840D-D24DC0D54194@apple.com> <40E1F4C6-5513-4B4C-BF3F-053162FD213D@apple.com> <6144A303-F54E-4A0F-B69D-DB9B94037F47@apple.com> <000001cc8539$8fef3370$afcd9a50$@org> Message-ID: <001901cc854e$6bb43fe0$431cbfa0$@org> Folks, I tried to find the ARM Architecture Reference Manual for ARMv6 from ARM website. It is not available anymore according to this FAQ: "The original ARM v6 Architecture Reference Manual for the ARM11 cores (ARM DDI 0100I) is superseded by the ARMv7-AR Architecture Reference Manual which is now the definitive document for Applications and Real-Time variants of the v6 and v7 ARM Architecture, including all ARM11-class cores." http://infocenter.arm.com/help/index.jsp?topic=/com.arm.doc.faqs/ka6657.html But the Architecture Reference Manual for ARMv7A and ARMV7AR (ARM DDI 0406B) page A8-285 says this about RSB immediate instruction: "The immediate value to be added to the value obtained from . The only permitted value for encoding T1 is 0. See Modified immediate constants in Thumb instructions on page A6-17 or Modified immediate constants in ARM instructions on page A5-9 for the range of values for encoding T2 or A1". http://infocenter.arm.com/help/index.jsp?topic=/com.arm.doc.ddi0406b/index.html So it should be ok to encode rsb with immediate value 0 in Thumb1 mode... Not sure why the assembler complains: arm-none-linux-gnueabi-gcc -march=armv6 floatsidf.s -o floatsidf.o floatsidf.s: Assembler messages: