Chris Lattner
|
a45c5af87b
|
Implement a trivial optimization to reduce the number of compares emitted.
For:
register short X;
if (!X) {
We now produce:
%tmp = load i16* %X ; <i16> [#uses=1]
%tobool = icmp ne i16 %tmp, 0 ; <i1> [#uses=1]
%lnot = xor i1 %tobool, true ; <i1> [#uses=1]
br i1 %lnot, label %ifthen, label %ifend
instead of:
%tmp = load i16* %X ; <i16> [#uses=1]
%tobool = icmp ne i16 %tmp, 0 ; <i1> [#uses=1]
%lnot = xor i1 %tobool, true ; <i1> [#uses=1]
%lnot.ext = zext i1 %lnot to i32 ; <i32> [#uses=1]
%tobool1 = icmp ne i32 %lnot.ext, 0 ; <i1> [#uses=1]
br i1 %tobool1, label %ifthen, label %ifend
llvm-svn: 39560
|
2007-06-02 19:47:04 +00:00 |
Chris Lattner
|
f0106d2578
|
Refactor EvaluateScalarValueToBool out of if statement emission, so it can
be shared.
Implement infrastructure for unary operator emission.
Implement basic logical not support. We now compile:
register short X;
if (!X) {
into:
%tmp = load i16* %X ; <i16> [#uses=1]
%tobool = icmp ne i16 %tmp, 0 ; <i1> [#uses=1]
%lnot = xor i1 %tobool, true ; <i1> [#uses=1]
zext i1 %lnot to i32 ; <i32>:0 [#uses=1]
%tobool1 = icmp ne i32 %0, 0 ; <i1> [#uses=1]
br i1 %tobool1, label %ifthen, label %ifend
llvm-svn: 39559
|
2007-06-02 19:33:17 +00:00 |
Chris Lattner
|
d7f58867e5
|
Implement scaffolding for lvalues. Implement block vardecl lvalues.
This allows us to translate:
int func() {
register int X;
{
int Y;
return 1+X+Y;
}
}
into:
define i32 @func() {
entry:
%X = alloca i32 ; <i32*> [#uses=1]
%Y = alloca i32 ; <i32*> [#uses=1]
%allocapt = bitcast i32 undef to i32 ; <i32> [#uses=0]
%tmp = load i32* %X ; <i32> [#uses=1]
%tmp1 = add i32 1, %tmp ; <i32> [#uses=1]
%tmp2 = load i32* %Y ; <i32> [#uses=1]
%tmp3 = add i32 %tmp1, %tmp2 ; <i32> [#uses=1]
ret i32 %tmp3
; No predecessors!
ret i32 undef
}
llvm-svn: 39555
|
2007-06-02 05:24:33 +00:00 |
Chris Lattner
|
03df12294b
|
Add initial support for fixed-size local vardecls. This allows us to compile:
int func() {
register int X;
{
int Y;
into:
define i32 @func() {
entry:
%X = alloca i32 ; <i32*> [#uses=0]
%Y = alloca i32 ; <i32*> [#uses=0]
%allocapt = bitcast i32 undef to i32 ; <i32> [#uses=0]
...
llvm-svn: 39553
|
2007-06-02 04:53:11 +00:00 |
Chris Lattner
|
84915fa79b
|
Start stubbing out decl codegen.
llvm-svn: 39550
|
2007-06-02 04:16:21 +00:00 |
Chris Lattner
|
3f3dbeedd3
|
implement codegen support for return of void and simple scalars.
llvm-svn: 39547
|
2007-06-02 03:19:07 +00:00 |
Chris Lattner
|
adb6372aa5
|
Add support for functions that return non-void.
llvm-svn: 39546
|
2007-06-02 03:02:07 +00:00 |
Chris Lattner
|
db91b16755
|
stub out codegen of binary plus. We now compile:
if (11 + 42) {
to:
%tmp = add i32 11, 42 ; <i32> [#uses=1]
%tobool = icmp ne i32 %tmp, 0 ; <i1> [#uses=1]
br i1 %tobool, label %ifthen, label %ifend
but this doesn't handle any of the interesting/hard stuff yet.
llvm-svn: 39545
|
2007-06-02 00:16:28 +00:00 |
Chris Lattner
|
e47e440c42
|
split stmt/expr codegen into their own files.
llvm-svn: 39540
|
2007-06-01 18:02:12 +00:00 |
Chris Lattner
|
dc6e3feade
|
emit a return at the end of the function. Run the llvm verifier.
llvm-svn: 39534
|
2007-05-30 22:55:31 +00:00 |
Chris Lattner
|
5269c0377c
|
Add support for codegen'ing paren exprs and if stmts. We can now codegen:
void test() {
goto l;
l:
if (11) {
j: ;
}
}
into:
define void @test() {
entry:
br label %l
l: ; preds = %entry
icmp ne i32 11, 0 ; <i1>:0 [#uses=1]
br i1 %0, label %ifthen, label %ifend
ifthen: ; preds = %l
br label %j
j: ; preds = %ifthen
br label %ifend
ifend: ; preds = %j, %l
}
whoa... :)
llvm-svn: 39533
|
2007-05-30 21:03:58 +00:00 |
Chris Lattner
|
208ae96a8c
|
implement codegen of integer literals.
llvm-svn: 39530
|
2007-05-30 17:57:17 +00:00 |
Chris Lattner
|
ac24820fa5
|
Implement codegen support for labels and gotos. We now compile:
void test1() {
foo:
goto foo;
goto foo;
goto foo;
}
void test() {
goto l;
l:
;
}
into:
define void @test1() {
entry:
br label %foo
foo: ; preds = %0, %foo, %entry
br label %foo
; No predecessors!
br label %foo
; No predecessors!
}
define void @test() {
entry:
br label %l
l: ; preds = %entry
}
llvm-svn: 39524
|
2007-05-30 00:13:02 +00:00 |
Chris Lattner
|
308f431017
|
Add codegen support for NullStmt and CompoundStmt. {;;{};;} is now ours!
llvm-svn: 39522
|
2007-05-29 23:50:05 +00:00 |
Chris Lattner
|
d1af2d2956
|
Implement conversion of clang ast types to LLVM types, at least for some trivial
cases.
llvm-svn: 39519
|
2007-05-29 23:17:50 +00:00 |
Chris Lattner
|
bed314465a
|
Reorganize codegen files.
llvm-svn: 39504
|
2007-05-28 01:07:47 +00:00 |
Chris Lattner
|
f97fe38cb5
|
Initial scaffolding for an -emit-llvm mode. This requires the LLVM VMCore
library to be built for the driver to link.
llvm-svn: 39495
|
2007-05-24 06:29:05 +00:00 |