[LLVMdev] problem with sgt's on Sparc machine
Christine Cheng
clcheng at stanford.edu
Thu Sep 15 15:15:09 PDT 2011
Hi guys,
Thanks for the input. However, it seems that the code still produces the
wrong output on a Sparc machine.
My current llvm_print.bc code is:
--------------------------------------------------------------------------------------------------
; MduleID = '<stdin>'
target datalayout =
"e-p:32:32:32-i1:8:8-i8:8:8-i16:16:16-i32:32:32-i64:64:64-f32:32:32-f64:64:64-v64:64:64-n32"
target triple = "sparc-unknown-linux"
@P = global i32 1
@dP = global i32 1
@.str = private constant [4 x i8] c"%d\0A\00", align 1
define i32 @main() nounwind {
entry:
%. = load i32* @P, align 4
%t1 = tail call i32 (i8*, ...)* @printf(i8* noalias getelementptr
inbounds ([4 x i8]* @.str, i32 0, i32 0), i32 %. ) nounwind
%d. = load i32* @dP, align 4
%t2 = tail call i32 (i8*, ...)* @printf(i8* noalias getelementptr
inbounds ([4 x i8]* @.str, i32 0, i32 0), i32 %d. ) nounwind
%0 = icmp sgt i32 %., 0
%1 = tail call i32 (i8*, ...)* @printf(i8* noalias getelementptr inbounds
([4 x i8]* @.str, i32 0, i32 0), i1 %0 ) nounwind
%2 = icmp sgt i32 %d., 0
%3 = tail call i32 (i8*, ...)* @printf(i8* noalias getelementptr
inbounds ([4 x i8]* @.str, i32 0, i32 0), i1 %2 ) nounwind
%t3 = icmp eq i32 %d., %d.
%t4 = tail call i32 (i8*, ...)* @printf(i8* noalias getelementptr
inbounds ([4 x i8]* @.str, i32 0, i32 0), i1 %t3 ) nounwind
%4 = icmp sgt i32 1, 0
%5 = icmp sgt i32 1, 0
%6 = tail call i32 (i8*, ...)* @printf(i8* noalias getelementptr
inbounds ([4 x i8]* @.str, i32 0, i32 0), i1 %4 ) nounwind
%7 = tail call i32 (i8*, ...)* @printf(i8* noalias getelementptr
inbounds ([4 x i8]* @.str, i32 0, i32 0), i1 %5 ) nounwind
ret i32 undef
}
declare i32 @printf(i8* nocapture, ...) nounwind
--------------------------------------------------------------------------------------------------
The output is still:
1
1
0
0
1
1
1
which should be all ones. Is there a sign error somewhere?
Thanks a lot!
Christine
On Thu, Sep 15, 2011 at 11:28 AM, Bruno Cardoso Lopes <
bruno.cardoso at gmail.com> wrote:
> On Thu, Sep 15, 2011 at 11:06 AM, Christine Cheng <clcheng at stanford.edu>
> wrote:
> > Hi Duncan,
> >
> > Thanks for the reply! There is no LLVM on the Sparc machine so I cannot
> > compile my code there into .s file. How shall I modify the target data
> > layout and triple so it works on Sparc? Basically I got these from
> compiling
> > C code using llvm-gcc.
>
> You can use clang for that:
> clang -ccc-host-triple sparc-unknown-linux -ccc-clang-archs sparc ...
>
>
> --
> Bruno Cardoso Lopes
> http://www.brunocardoso.cc
>
-------------- next part --------------
An HTML attachment was scrubbed...
URL: <http://lists.llvm.org/pipermail/llvm-dev/attachments/20110915/069d0be7/attachment.html>
More information about the llvm-dev
mailing list