[LLVMdev] Initial cut at a instruction raising patch
Richard Pennington
rich at pennware.com
Sat Aug 8 08:37:35 PDT 2009
Hi,
This patch raises selected instructions to function calls. I've dome
some preliminary testing and I works:
; 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
-------------- next part --------------
An embedded and charset-unspecified text was scrubbed...
Name: raiseinstructions.patch
URL: <http://lists.llvm.org/pipermail/llvm-dev/attachments/20090808/c0c7fb2a/attachment.ksh>
More information about the llvm-dev
mailing list