[LLVMdev] How to extract loop body into a new function?
Shah, Mrunal J
mrunal.shah at gatech.edu
Sat Dec 6 20:00:02 PST 2008
False Alarm!!
Still don't know how to do it!
I am trying to write a transformation pass to extract a loop body into a function.
For example:
The Loop in question is:
for (i2 = 0; i2 < LOOP_SIZE; i2++) {
A[B[i2]] = 2 * B[i2];
}
The IR for which is:
bb13: ; preds = %bb13, %bb
%i2.0.reg2mem.0 = phi i32 [ 0, %bb ], [ %indvar.next62, %bb13 ] ; <i32> [#uses=2]
%tmp15 = getelementptr [25 x i32]* %B, i32 0, i32 %i2.0.reg2mem.0 ; <i32*> [#uses=1]
%tmp16 = load i32* %tmp15, align 4 ; <i32> [#uses=2]
%tmp20 = shl i32 %tmp16, 1 ; <i32> [#uses=1]
%tmp21 = getelementptr [25 x i32]* %A, i32 0, i32 %tmp16 ; <i32*> [#uses=1]
store i32 %tmp20, i32* %tmp21, align 4
%indvar.next62 = add i32 %i2.0.reg2mem.0, 1 ; <i32> [#uses=2]
%exitcond63 = icmp eq i32 %indvar.next62, 25 ; <i1> [#uses=1]
br i1 %exitcond63, label %bb30, label %bb13
I want to be able to extract:
A[B[i2]] = 2 * B[i2];
into a function
myfunc() {
A[B[i2]] = 2 * B[i2];
}
How can I do this?
Any hints??
Thanks,
Mrunal
----- Original Message -----
From: "Mrunal J Shah" <mrunal.shah at gatech.edu>
To: "LLVM Developers Mailing List" <llvmdev at cs.uiuc.edu>
Sent: Saturday, December 6, 2008 8:46:00 PM GMT -05:00 US/Canada Eastern
Subject: Re: [LLVMdev] How to extract loop body into a new function?
Sorry!
It worked with ExtractBasicBlock()
----- Original Message -----
From: "Mrunal J Shah" <mrunal.shah at gatech.edu>
To: "llvmdev" <llvmdev at cs.uiuc.edu>
Sent: Saturday, December 6, 2008 8:30:33 PM GMT -05:00 US/Canada Eastern
Subject: [LLVMdev] How to extract loop body into a new function?
Hi All,
I am having trouble extracting loop body into a new function. The ExtractLoop() or ExtractBasicBlock() extracts the entire loop along with the header into a new function. All I want is to extract the body of the loop into a new function(without the header).
Is this possible?
Thanks,
Mrunal
_______________________________________________
LLVM Developers mailing list
LLVMdev at cs.uiuc.edu http://llvm.cs.uiuc.edu
http://lists.cs.uiuc.edu/mailman/listinfo/llvmdev
_______________________________________________
LLVM Developers mailing list
LLVMdev at cs.uiuc.edu http://llvm.cs.uiuc.edu
http://lists.cs.uiuc.edu/mailman/listinfo/llvmdev
More information about the llvm-dev
mailing list