[LLVMdev] Initial cut at a instruction raising patch
Chris Lattner
clattner at apple.com
Sat Aug 8 11:32:05 PDT 2009
On Aug 8, 2009, at 8:37 AM, Richard Pennington wrote:
> Hi,
>
> This patch raises selected instructions to function calls. I've dome
> some preliminary testing and I works:
Out of curiosity, why do you want this?
-Chris
>
> ; ModuleID = 'raise.o'
> target datalayout = "e-p:32:32-i1:8:0-i8:8:0-i16:16:0-i32:32:0-
> i32:32:0-i64:32:0-f32:32:0-f64:32:0-f96:32:0-v64:64:64-v128:128:0-
> a0:0"
> target triple = "i386-pc-linux-gnu"
>
> define i32 @main(i32, i8**, ...) nounwind {
> entry:
> %argc = alloca i32 ; <i32*> [#uses=1]
> store i32 %0, i32* %argc
> %argv = alloca i8** ; <i8***> [#uses=1]
> store i8** %1, i8*** %argv
> %retval = alloca i32 ; <i32*> [#uses=2]
> store i32 0, i32* %retval
> %ll = alloca i64 ; <i64*> [#uses=3]
> %l = alloca i32 ; <i32*> [#uses=3]
> %2 = load i32* %l ; <i32> [#uses=1]
> %3 = load i32* %l ; <i32> [#uses=1]
> %4 = add i32 %2, %3 ; <i32> [#uses=1]
> store i32 %4, i32* %l
> %5 = load i64* %ll ; <i64> [#uses=1]
> %6 = load i64* %ll ; <i64> [#uses=1]
> %7 = add i64 %5, %6 ; <i64> [#uses=1]
> store i64 %7, i64* %ll
> br label %return
>
> return: ; preds = %entry
> %8 = load i32* %retval ; <i32> [#uses=1]
> ret i32 %8
> }
>
> becomes
>
> target datalayout = "e-p:32:32-i1:8:0-i8:8:0-i16:16:0-i32:32:0-
> i32:32:0-i64:32:0-f32:32:0-f64:32:0-f96:32:0-v64:64:64-v128:128:0-
> a0:0"
> target triple = "i386-pc-linux-gnu"
>
> define i32 @main(i32, i8**, ...) nounwind {
> entry:
> %argc = alloca i32 ; <i32*> [#uses=1]
> store i32 %0, i32* %argc
> %argv = alloca i8** ; <i8***> [#uses=1]
> store i8** %1, i8*** %argv
> %retval = alloca i32 ; <i32*> [#uses=2]
> store i32 0, i32* %retval
> %ll = alloca i64 ; <i64*> [#uses=3]
> %l = alloca i32 ; <i32*> [#uses=3]
> %2 = load i32* %l ; <i32> [#uses=1]
> %3 = load i32* %l ; <i32> [#uses=1]
> %4 = tail call i32 @addl(i32 %2, i32 %3) ;
> <i32> [#uses=1]
> store i32 %4, i32* %l
> %5 = load i64* %ll ; <i64> [#uses=1]
> %6 = load i64* %ll ; <i64> [#uses=1]
> %7 = tail call i64 @addll(i64 %5, i64 %6) ;
> <i64> [#uses=1]
> store i64 %7, i64* %ll
> br label %return
>
> return: ; preds = %entry
> %8 = load i32* %retval ; <i32> [#uses=1]
> ret i32 %8
> }
>
> declare i32 @addl(i32, i32)
>
> declare i64 @addll(i64, i64)
>
> Could you give me any comments/criticisms?
>
> Thanks!
>
> -Rich
> <
> raiseinstructions.patch
> >_______________________________________________
> 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