Chris Lattner
183c231cf9
compound assignmetns work for scalars.
...
llvm-svn: 41449
2007-08-26 16:52:57 +00:00
Chris Lattner
c141c1b390
implement conversions of complex to bool.
...
llvm-svn: 41448
2007-08-26 16:52:28 +00:00
Chris Lattner
268fcce4f0
remove ConvertScalarValueToBool.
...
llvm-svn: 41447
2007-08-26 16:46:58 +00:00
Chris Lattner
e004438f4a
reimplement ConvertScalarValueToBool in CGExprScalar.cpp
...
llvm-svn: 41446
2007-08-26 16:42:57 +00:00
Chris Lattner
42e6b8150a
refactor some code to expose compex->scalar conversion to CGF
...
llvm-svn: 41445
2007-08-26 16:34:22 +00:00
Chris Lattner
b84bb95b44
be slightly more volatile correct
...
llvm-svn: 41444
2007-08-26 16:22:13 +00:00
Chris Lattner
f6dcc9df7e
these fixme's are easy :)
...
llvm-svn: 41442
2007-08-26 07:30:49 +00:00
Chris Lattner
b753f66339
implement a fixme, add a couple more :)
...
llvm-svn: 41441
2007-08-26 07:29:23 +00:00
Chris Lattner
5de3b174c8
there are no conversions from aggregates to scalars.
...
llvm-svn: 41440
2007-08-26 07:26:12 +00:00
Chris Lattner
08c611e4dc
implement conversions from complex to scalar types.
...
llvm-svn: 41439
2007-08-26 07:21:11 +00:00
Chris Lattner
46c7161311
Omit EmitConversion
...
llvm-svn: 41438
2007-08-26 07:16:41 +00:00
Chris Lattner
45067906ad
Fix return of aggregate and return of complex.
...
llvm-svn: 41437
2007-08-26 07:14:44 +00:00
Chris Lattner
44d3e74e22
these implicit conversions are now explicit :)
...
llvm-svn: 41436
2007-08-26 07:09:42 +00:00
Chris Lattner
cf3da8495a
remove uses of EmitConversion
...
llvm-svn: 41435
2007-08-26 07:08:39 +00:00
Chris Lattner
798da7033f
implicit casts take care of this code, remove it now.
...
llvm-svn: 41434
2007-08-26 07:06:24 +00:00
Chris Lattner
3474c202ab
refactor scalar conversions out into CGExprScalar.cpp
...
llvm-svn: 41433
2007-08-26 06:48:56 +00:00
Chris Lattner
7460f9620c
Implement casts from scalar -> complex and complex->complex.
...
llvm-svn: 41429
2007-08-26 05:57:57 +00:00
Chris Lattner
b5e1262437
implement codegen of __imag of a scalar. Our impl doesn't suffer from
...
GCC bug PR33192.
llvm-svn: 41427
2007-08-26 05:29:21 +00:00
Chris Lattner
9de9527ad6
Make initialization of complex vars work.
...
llvm-svn: 41426
2007-08-26 05:13:54 +00:00
Chris Lattner
a01d898ff5
fix codegen of pre/post inc/dec of a pointer.
...
llvm-svn: 41425
2007-08-26 05:10:16 +00:00
Chris Lattner
c7f06ca780
tolerate unimplemented codegen better
...
llvm-svn: 41424
2007-08-26 05:06:40 +00:00
Chris Lattner
e7a160b37d
int X[] isn't a VLA. This improves support for stdio.h on darwin.
...
llvm-svn: 41423
2007-08-26 05:02:07 +00:00
Chris Lattner
57c269b5d3
implement rudimentary union layout support.
...
llvm-svn: 41421
2007-08-26 04:50:19 +00:00
Chris Lattner
881440f5d2
Don't make unknown builtins fatal errors yet.
...
llvm-svn: 41419
2007-08-26 04:17:05 +00:00
Chris Lattner
c5221650b3
remove a bunch of dead code
...
llvm-svn: 41418
2007-08-26 04:13:58 +00:00
Chris Lattner
0fffcb5b28
implement codegen for complex literals.
...
llvm-svn: 41414
2007-08-26 03:51:12 +00:00
Chris Lattner
27f00282e9
The new correct compound assignment operators exposed a bug in codegen.
...
llvm-svn: 41405
2007-08-25 21:56:20 +00:00
Chris Lattner
9f0ad96b3e
implement codegen for real/imag. TODO: imag of non-complex.
...
llvm-svn: 41376
2007-08-24 21:20:17 +00:00
Chris Lattner
3d966d6556
Teach emit-llvm for scalars to properly handle compound assignment
...
operators in all their glory :)
llvm-svn: 41373
2007-08-24 21:00:35 +00:00
Chris Lattner
100198f3f7
print the computation type for compound assignment operators in dumps.
...
llvm-svn: 41361
2007-08-24 16:24:49 +00:00
Chris Lattner
2da04b3322
completely refactor codegen of scalar expressions out into its own CGExprScalar.cpp file.
...
This patch temporarily breaks compound assignment operators, but greatly simplifies many
things.
llvm-svn: 41355
2007-08-24 05:35:26 +00:00
Chris Lattner
11e0de5193
rename two files.
...
llvm-svn: 41350
2007-08-24 02:22:53 +00:00
Chris Lattner
db0d60d5b5
implement codegen of builtin_choose_expr for complex.
...
llvm-svn: 41349
2007-08-24 02:18:47 +00:00
Chris Lattner
8ad56707ea
stub out complex -> bool conversion.
...
llvm-svn: 41347
2007-08-24 00:01:20 +00:00
Chris Lattner
0b984995b7
implement complex subtraction
...
llvm-svn: 41345
2007-08-23 23:46:33 +00:00
Chris Lattner
08b15df766
implement passing of complex and aggregates through call args.
...
llvm-svn: 41344
2007-08-23 23:43:33 +00:00
Chris Lattner
1aaab49a3e
add support for codegen of calls returning complex.
...
llvm-svn: 41336
2007-08-23 21:38:16 +00:00
Chris Lattner
cb1ffbc12e
add some fixme's, implement complex struct members.
...
llvm-svn: 41256
2007-08-21 22:33:41 +00:00
Chris Lattner
d34c999b67
implement codegen for --/++
...
llvm-svn: 41255
2007-08-21 22:25:29 +00:00
Chris Lattner
875a519ca6
implement __extension__ and unary~ for complex.
...
llvm-svn: 41249
2007-08-21 20:41:44 +00:00
Chris Lattner
ad4569eacb
implement codegen for complex unary +/-
...
llvm-svn: 41247
2007-08-21 20:08:23 +00:00
Chris Lattner
d614e7a553
minor nicities.
...
llvm-svn: 41244
2007-08-21 18:51:13 +00:00
Chris Lattner
a0733a777b
implement support for complex subscripts.
...
llvm-svn: 41240
2007-08-21 18:03:58 +00:00
Chris Lattner
e0e54120b2
allow support for volatile lvalues even though it's still not right.
...
llvm-svn: 41239
2007-08-21 18:02:02 +00:00
Anders Carlsson
76f4a902d7
Implement parsing and code generation of Objective-C string literals.
...
llvm-svn: 41238
2007-08-21 17:43:55 +00:00
Chris Lattner
2dc2af3515
add a new builder ivar.
...
llvm-svn: 41237
2007-08-21 17:39:38 +00:00
Chris Lattner
4b0e7873f6
move EmitLoadOfComplex/EmitStoreOfComplex into ComplexExprEmitter.
...
llvm-svn: 41236
2007-08-21 17:28:34 +00:00
Chris Lattner
3cf417b369
implement comma for complex.
...
llvm-svn: 41235
2007-08-21 17:15:50 +00:00
Chris Lattner
64be48fede
and/or/xor are invalid for complex, even integer complex apparently.
...
llvm-svn: 41234
2007-08-21 17:12:50 +00:00
Chris Lattner
bf1bd0dcc7
simplify code slightly
...
llvm-svn: 41233
2007-08-21 17:03:38 +00:00
Chris Lattner
96d7256d62
reimplement support for complex comparisons, add support for integer complex compares.
...
llvm-svn: 41231
2007-08-21 16:57:55 +00:00
Chris Lattner
6ce75dff4d
reimplement complex mul
...
llvm-svn: 41226
2007-08-21 16:34:16 +00:00
Chris Lattner
b01cc9d49a
update some comments.
...
llvm-svn: 41218
2007-08-21 05:54:53 +00:00
Chris Lattner
cbfc73b26c
Split complex arithmetic codegen out from aggregate codegen.
...
This means that we get rid of tons of intermediate allocas. For
example:
void foo(double _Complex a, double _Complex b) {
a = b+a+a;
}
this used to have 4 temporary allocas, now it has zero of them.
This also simplifies the individual visitor methods because they
now can all operate on real/imag pairs instead of having to
load/store all over the place.
llvm-svn: 41217
2007-08-21 05:54:00 +00:00
Chris Lattner
926792f726
simplify this a bit to remove indirection
...
llvm-svn: 41216
2007-08-21 05:02:10 +00:00
Chris Lattner
835635d85a
reimplement addition of complex numbers.
...
llvm-svn: 41215
2007-08-21 04:59:27 +00:00
Chris Lattner
cd9fb2401d
Add the ability to visit binary operators without having to
...
match on binop then explicitly switching again.
llvm-svn: 41214
2007-08-21 04:43:17 +00:00
Chris Lattner
4758b40df0
switch aggregate expr codegen to use a visitor to localize most of the nasty
...
details in its own file.
llvm-svn: 41213
2007-08-21 04:25:47 +00:00
Anders Carlsson
b04ea61b79
Implement code generation for constant CFStrings.
...
llvm-svn: 41206
2007-08-21 00:21:21 +00:00
Chris Lattner
76ba849ed3
Fix array->pointer decay. This unbreaks test/CodeGen/array.c
...
llvm-svn: 41202
2007-08-20 22:37:10 +00:00
Anders Carlsson
1d8e521022
Add support for code generation of builtins.
...
llvm-svn: 41188
2007-08-20 18:05:56 +00:00
Ted Kremenek
c81614d5d1
Modified ArraySubscriptExpr to have accessors getLHS and getRHS in addition
...
to getBase and getIdx. getBase and getIdx now return a "normalized" view
of the expression (e.g., always "A[4]" instead of possibly "4[A]"). getLHS
and getRHS return the expressions with syntactic fidelity to the original
source code.
Also modified client code of ArraySubscriptExpr, including the AST dumper
and pretty printer, the return-stack value checker, and the LLVM code
generator.
llvm-svn: 41180
2007-08-20 16:18:38 +00:00
Anders Carlsson
f087c0c1c6
Add preliminary support for converting struct types.
...
llvm-svn: 41145
2007-08-17 22:00:32 +00:00
Chris Lattner
6278e6ac30
start splitting out aggregate value computation from EmitExpr into EmitAggExpr.
...
aggregate value and scalar expression computation are very different, this
gets them away from each other. This causes a temporary regression on some
complex number examples.
llvm-svn: 41014
2007-08-11 00:04:45 +00:00
Chris Lattner
d79671fdf2
New file, just a placeholder for now.
...
llvm-svn: 41002
2007-08-10 20:13:28 +00:00
Chris Lattner
8eab8ff127
fix a codegen bug handling ocuvector element exprs.
...
llvm-svn: 40995
2007-08-10 17:10:08 +00:00
Chris Lattner
90d9120453
implement initial codegen for aggregate return functions. This implements
...
codegen for:
_Complex double bar(int);
void test(_Complex double*);
void test2(int c) {
_Complex double X;
X = bar(1);
test(&X);
}
llvm-svn: 40993
2007-08-10 17:02:28 +00:00
Chris Lattner
02697701d9
Fix a bug handling function -> pointer decay and avoid emitting a noop
...
bitcast.
llvm-svn: 40992
2007-08-10 16:33:59 +00:00
Chris Lattner
87f4836184
now that implicit conversions are explicit, we can eliminate
...
EmitUsualArithmeticConversions.
llvm-svn: 40931
2007-08-08 17:49:18 +00:00
Chris Lattner
5ebb2fed89
now that implicit conversions are explicit, we can eliminate
...
EmitExprWithUsualUnaryConversions.
llvm-svn: 40929
2007-08-08 17:43:05 +00:00
Chris Lattner
81a9688e93
Implement codegen for __builtin_choose_expr. For example:
...
struct X { int A; };
void foo() {
struct X s;
int i;
i = __builtin_choose_expr(0, s, i);
}
compiles to:
%tmp = load i32* %i ; <i32> [#uses=1]
store i32 %tmp, i32* %i
wow :)
llvm-svn: 40801
2007-08-04 00:20:15 +00:00
Chris Lattner
4048005ad8
implement codegen support for __builtin_types_compatible_p
...
llvm-svn: 40788
2007-08-03 17:51:03 +00:00
Chris Lattner
d268a7a268
Rename AddrLabel and OCUVectorComponent -> AddrLabelExpr and OCUVectorElementExpr respectively. This is for consistency with other expr nodes end with *Expr.
...
llvm-svn: 40785
2007-08-03 17:31:20 +00:00
Chris Lattner
3a44aa7461
implement codegen for multidest ocuvector expressions, like:
...
vec2.yx = vec2; // reverse
llvm-svn: 40782
2007-08-03 16:37:04 +00:00
Chris Lattner
41d480e4d8
add codegen support for storing into a single-element ocu lvalue, such as:
...
vec2.x = f;
llvm-svn: 40781
2007-08-03 16:28:33 +00:00
Chris Lattner
40ff701674
refactor handling of ocuvector lvalue->rvalue codegen into its own method.
...
llvm-svn: 40780
2007-08-03 16:18:34 +00:00
Chris Lattner
fb837dccac
In the common case where we are shuffling a vector, emit an
...
llvm vector shuffle instead of a bunch of insert/extract operations.
For: vec4 = vec4.yyyy; // splat
Emit:
%tmp1 = shufflevector <4 x float> %tmp, <4 x float> undef, <4 x i32> < i32 1, i32 1, i32 1, i32 1 >
instead of:
%tmp1 = extractelement <4 x float> %tmp, i32 1
%tmp2 = insertelement <4 x float> undef, float %tmp1, i32 0
%tmp3 = extractelement <4 x float> %tmp, i32 1
%tmp4 = insertelement <4 x float> %tmp2, float %tmp3, i32 1
%tmp5 = extractelement <4 x float> %tmp, i32 1
%tmp6 = insertelement <4 x float> %tmp4, float %tmp5, i32 2
%tmp7 = extractelement <4 x float> %tmp, i32 1
%tmp8 = insertelement <4 x float> %tmp6, float %tmp7, i32 3
llvm-svn: 40779
2007-08-03 16:09:33 +00:00
Chris Lattner
a1036f9155
Add support for scalar-returning element accesses like V.x
...
llvm-svn: 40777
2007-08-03 15:52:31 +00:00
Chris Lattner
73ab9b3c14
implement lvalue to rvalue conversion for ocuvector components. We can now compile stuff
...
like this:
typedef __attribute__(( ocu_vector_type(4) )) float float4;
float4 test1(float4 V) {
return V.wzyx+V;
}
to:
_test1:
pshufd $27, %xmm0, %xmm1
addps %xmm0, %xmm1
movaps %xmm1, %xmm0
ret
and:
_test1:
mfspr r2, 256
oris r3, r2, 4096
mtspr 256, r3
li r3, lo16(LCPI1_0)
lis r4, ha16(LCPI1_0)
lvx v3, r4, r3
vperm v3, v2, v2, v3
vaddfp v2, v3, v2
mtspr 256, r2
blr
llvm-svn: 40771
2007-08-03 00:16:29 +00:00
Chris Lattner
9e751cae27
add support for codegen of an OCUVectorComponent as an lvalue.
...
We can now codegen:
vec4.xy;
as nothing!
llvm-svn: 40769
2007-08-02 23:37:31 +00:00
Chris Lattner
acbd22aaec
silence some warnings.
...
llvm-svn: 40761
2007-08-02 21:50:34 +00:00
Chris Lattner
7b9f04eb19
update this to build with LLVM ToT
...
llvm-svn: 40665
2007-08-01 06:24:52 +00:00
Anders Carlsson
625bfc8716
Implement code generation for __func__, __FUNCTION__ and __PRETTY_FUNCTION__
...
llvm-svn: 40162
2007-07-21 05:21:51 +00:00
Chris Lattner
2ac26568d4
silence a warning by treating ocuvectors the same as vectors.
...
llvm-svn: 40037
2007-07-19 05:13:51 +00:00
Chris Lattner
3f8c6e6e74
implement codegen support for sizeof/alignof
...
llvm-svn: 40009
2007-07-18 18:12:07 +00:00
Chris Lattner
e73e4322d6
Implement break and continue. Patch by Anders Carlsson!
...
llvm-svn: 39927
2007-07-16 21:28:45 +00:00
Chris Lattner
651f0e9c8f
Add a hack (mirroring llvm-gcc) to pointer difference
...
codegen to compile:
int test(int *A, int *B) {
return A-B;
}
into:
_test:
movl 4(%esp), %eax
subl 8(%esp), %eax
sarl $2, %eax
ret
instead of:
_test:
movl 4(%esp), %eax
subl 8(%esp), %eax
movl %eax, %ecx
sarl $31, %ecx
shrl $30, %ecx
addl %ecx, %eax
sarl $2, %eax
ret
llvm-svn: 39902
2007-07-16 05:43:05 +00:00
Chris Lattner
0e9d6226ca
Refactor code so that isIntegerConstantExpr has an ASTContext available.
...
llvm-svn: 39884
2007-07-15 23:26:56 +00:00
Gabor Greif
e97cd7e65c
add FIXME and un-XFAIL test
...
llvm-svn: 39858
2007-07-14 20:05:18 +00:00
Chris Lattner
4481b428db
A significant refactoring of the type size stuff to also
...
compute type alignment. This info is needed for struct layout.
llvm-svn: 39850
2007-07-14 01:29:45 +00:00
Chris Lattner
9d3b0e0001
Implement trivial integer initializers, like 'int X = 4;' for global
...
vars. Approach suggested by Keith.
llvm-svn: 39849
2007-07-14 00:23:28 +00:00
Chris Lattner
6ee31f5df8
In "int X,Y;", compile both X and Y.
...
llvm-svn: 39848
2007-07-14 00:16:50 +00:00
Chris Lattner
027f21dd72
add a fixme
...
llvm-svn: 39847
2007-07-14 00:01:01 +00:00
Gabor Greif
d4606aa36e
implement _Complex * == and !=
...
llvm-svn: 39841
2007-07-13 23:33:18 +00:00
Chris Lattner
983a8bbbb2
Move getSize() out of type, into ASTContext, where it has target info, and
...
where ASTContext can manage caches for struct layout, etc.
llvm-svn: 39835
2007-07-13 22:13:22 +00:00
Chris Lattner
388cf760e2
implement codegen support for implicit casts.
...
llvm-svn: 39831
2007-07-13 20:25:53 +00:00
Chris Lattner
a5ba0cb772
silence a bogus gcc warning.
...
llvm-svn: 39824
2007-07-13 20:07:11 +00:00
Chris Lattner
6e9d9b350e
"Codegen for Character Literals and Conditional Operator
...
Both in one patch, and the test case that Chris didn't commit last
time is in there too...
I'll split the patch up if somebody wants it split."
Patch by Keith Bauer.
llvm-svn: 39796
2007-07-13 05:18:11 +00:00
Chris Lattner
d14bfa94a6
implement support for basic codegen of global variables with no initializers.
...
llvm-svn: 39795
2007-07-13 05:13:43 +00:00
Chris Lattner
fc7634f2ab
"Someone typed "PtrToInt" where they meant "IntToPtr".
...
I've added a tests/CodeGen directory, and a test for this case that
used to fail and now passes."
Patch by Keith Bauer
llvm-svn: 39794
2007-07-13 03:25:53 +00:00
Chris Lattner
d2b88ab313
Implement codegen for + and - with pointers. Patch contributed by
...
Keith Bauer.
llvm-svn: 39793
2007-07-13 03:05:23 +00:00
Chris Lattner
bd4de5df77
Fix "no newline at end of file" warnings. Patch contributed by
...
Benoit Boissinot!
llvm-svn: 39780
2007-07-12 15:43:07 +00:00
Chris Lattner
07eb733ef8
Evaluate the initializer for automatic variables.
...
llvm-svn: 39771
2007-07-12 00:39:48 +00:00
Chris Lattner
dcca487cfa
implement codegen support for pre/post inc/dec.
...
llvm-svn: 39765
2007-07-11 23:43:46 +00:00
Chris Lattner
c14236b8ae
implement codegen support for the "default argument promotions" (C99 6.5.2.2p6).
...
Not having this prevented promoting float arguments to double when passed
into printf, for example.
llvm-svn: 39727
2007-07-10 22:18:37 +00:00
Chris Lattner
a779b3df28
implement codegen support for rvalue-only vector subscripts, such as:
...
float4 test(void);
float test2() {
return test()[1];
}
llvm-svn: 39725
2007-07-10 21:58:36 +00:00
Chris Lattner
08c4b9ffec
Add support for codegen'ing vector subscripts, at least when they are lvalues.
...
llvm-svn: 39724
2007-07-10 21:17:59 +00:00
Chris Lattner
50d4abd24c
Add support for vector formal arguments.
...
llvm-svn: 39721
2007-07-10 00:28:12 +00:00
Chris Lattner
6eea886b9e
implement support for llvm codegen of vectors. That was much easier than
...
I expected :)
llvm-svn: 39720
2007-07-10 00:23:39 +00:00
Chris Lattner
2ada32ed7d
implement codegen support for FP literals
...
llvm-svn: 39718
2007-07-09 23:03:16 +00:00
Chris Lattner
47c247e7bf
add codegen support for <<= and >>=.
...
llvm-svn: 39713
2007-06-29 17:26:27 +00:00
Chris Lattner
b25a94383a
Implement the rest of the compound assignment operators, except shifts.
...
llvm-svn: 39712
2007-06-29 17:03:06 +00:00
Chris Lattner
cd215f00ee
refactor some code, implement -=
...
llvm-svn: 39711
2007-06-29 16:52:55 +00:00
Chris Lattner
9369a563b4
Rename ArithAssignBinaryOperator -> CompoundAssignOperator, implement
...
codegen support for +=.
llvm-svn: 39710
2007-06-29 16:31:29 +00:00
Chris Lattner
69e70e506a
fix codegen of void return functions
...
llvm-svn: 39694
2007-06-27 18:10:00 +00:00
Chris Lattner
c8c3dadaa0
fix codegen of void-returning functions
...
llvm-svn: 39693
2007-06-27 18:08:49 +00:00
Chris Lattner
54fb19efaa
implement support for struct and complex returns.
...
llvm-svn: 39674
2007-06-22 22:02:34 +00:00
Chris Lattner
e9a6453ded
add some infrastructure for codegen'ing complex numbers. implement addition
...
of complex. We now produce optimal code for:
void test(_Complex float *Y) {
*Y = *Y + *Y;
}
$ clang -emit-llvm cg.c | llvm-as | opt -std-compile-opts | llc -march=x86-64
...
_test:
movss (%rdi), %xmm0
addss %xmm0, %xmm0
movss 4(%rdi), %xmm1
movss %xmm0, (%rdi)
addss %xmm1, %xmm1
movss %xmm1, 4(%rdi)
ret
llvm-svn: 39673
2007-06-22 21:44:33 +00:00
Chris Lattner
c6395936ae
Split complex types out from being members of BuiltinType to being their own
...
types.
llvm-svn: 39672
2007-06-22 20:56:16 +00:00
Chris Lattner
f033c147c9
remove location tracking for target info
...
llvm-svn: 39671
2007-06-22 19:05:19 +00:00
Chris Lattner
0fb8465981
Don't forget to set this
...
llvm-svn: 39670
2007-06-22 18:57:44 +00:00
Chris Lattner
09153c0a8c
Build enough support for aggregates to be able to compile this:
...
void test(int A, _Complex float Y) {
_Complex float X;
X = X;
}
llvm-svn: 39669
2007-06-22 18:48:09 +00:00
Chris Lattner
3e3a1e9cda
implement lowering of complex types
...
llvm-svn: 39668
2007-06-22 18:15:26 +00:00
Chris Lattner
f39b03d98b
fix naming of aggregate arguments.
...
llvm-svn: 39667
2007-06-22 18:15:16 +00:00
Chris Lattner
1fde0b345b
implement codegen of the relational operations
...
One major FIXME though.
llvm-svn: 39666
2007-06-20 18:30:55 +00:00
Chris Lattner
273c63d450
Implement the equality operators for simple types
...
llvm-svn: 39665
2007-06-20 18:02:30 +00:00
Chris Lattner
e1e93a5e5d
assert, don't crash, on int[]
...
llvm-svn: 39664
2007-06-20 17:12:11 +00:00
Chris Lattner
b6984c4854
Hook up global function and variable handling. We can now compile:
...
int X, bar(int,int,int);
short Y;
double foo() {
return bar(X, Y, 3);
}
into:
@X = external global i32 ; <i32*> [#uses=1]
@Y = external global i16 ; <i16*> [#uses=1]
define double @foo() {
entry:
%tmp = load i32* @X ; <i32> [#uses=1]
%tmp1 = load i16* @Y ; <i16> [#uses=1]
%promote = sext i16 %tmp1 to i32 ; <i32> [#uses=1]
%call = tail call i32 @bar( i32 %tmp, i32 %promote, i32 3 ) ; <i32> [#uses=1]
%conv = sitofp i32 %call to double ; <double> [#uses=1]
ret double %conv
}
declare i32 @bar(i32, i32, i32)
llvm-svn: 39663
2007-06-20 04:44:43 +00:00
Chris Lattner
2ccb73bc8b
Refactor CodeGenTypes out to CodeGenModule so it can be used for functions
...
and globals.
llvm-svn: 39661
2007-06-16 00:16:26 +00:00
Chris Lattner
2052bc8107
Split type analysis out to its own file, now the integer constant expr evaluation
...
is ready.
llvm-svn: 39660
2007-06-16 00:12:05 +00:00
Chris Lattner
23b7eb677d
Finally bite the bullet and make the major change: split the clang namespace
...
out of the llvm namespace. This makes the clang namespace be a sibling of
llvm instead of being a child.
The good thing about this is that it makes many things unambiguous. The
bad things is that many things in the llvm namespace (notably data structures
like smallvector) now require an llvm:: qualifier. IMO, libsystem and libsupport
should be split out of llvm into their own namespace in the future, which will fix
this issue.
llvm-svn: 39659
2007-06-15 23:05:46 +00:00
Chris Lattner
2b228c95aa
implement codegen of calls. We can now compile:
...
double foo( int (*FP)(int, int, int)) {
return FP(1, 2, 3);
}
to:
define double @foo(i32 (i32, i32, i32)* %FP) {
entry:
%call = tail call i32 %FP( i32 1, i32 2, i32 3 )
%conv = sitofp i32 %call to double
ret double %conv
}
llvm-svn: 39658
2007-06-15 21:34:29 +00:00
Chris Lattner
d760e468aa
Don't generate code for prototypes
...
llvm-svn: 39656
2007-06-15 21:16:23 +00:00
Chris Lattner
b48238188e
Fix a nasty bug which caused infinite recursion
...
llvm-svn: 39655
2007-06-15 21:04:38 +00:00
Chris Lattner
cf98efa73b
Implement implicit conversions in return stmts.
...
llvm-svn: 39653
2007-06-13 20:50:31 +00:00
Chris Lattner
53621a535d
Implement support for formal arguments. We can now compile this:
...
int test(int X, short Y, float Z) {
return (int)(X*Y+Z);
}
to:
define i32 @test(i32 %X, i16 %Y, float %Z) {
entry:
%promote = sext i16 %Y to i32 ; <i32> [#uses=1]
%mul = mul i32 %promote, %X ; <i32> [#uses=1]
%promote3 = sitofp i32 %mul to float ; <float> [#uses=1]
%add = add float %promote3, %Z ; <float> [#uses=1]
%conv = fptosi float %add to i32 ; <i32> [#uses=1]
ret i32 %conv
}
with:
$ clang -emit-llvm t.c | llvm-as | opt -std-compile-opts | llvm-dis
llvm-svn: 39652
2007-06-13 20:44:40 +00:00
Chris Lattner
f99b3f5ec2
Emit codegen of enum literals.
...
llvm-svn: 39646
2007-06-11 03:52:52 +00:00
Chris Lattner
45bb914249
Convert argument types over, which works for trivial scalars.
...
llvm-svn: 39625
2007-06-09 02:28:57 +00:00
Chris Lattner
1ad38f8fee
codegen all declarators in a declstmt, allowing us to successfully codegen
...
stuff like:
void test() {
int *X, Y, *Z[14];
X[Y] = 4;
}
llvm-svn: 39624
2007-06-09 01:20:56 +00:00
Chris Lattner
d9d2fb1420
Implement array subscripts for non-vla types.
...
llvm-svn: 39622
2007-06-08 23:31:14 +00:00
Chris Lattner
4347e369b4
implement codegen of string literals.
...
llvm-svn: 39597
2007-06-06 04:54:52 +00:00
Chris Lattner
83b484b3be
implement the real int/fp conversions
...
llvm-svn: 39596
2007-06-06 04:39:08 +00:00
Chris Lattner
cf106ab42a
implement support for casts to/from pointers.
...
llvm-svn: 39595
2007-06-06 04:05:39 +00:00
Chris Lattner
8394d795c3
implement codegen of a bunch more loop constructs and most expressions
...
llvm-svn: 39593
2007-06-05 20:53:16 +00:00
Chris Lattner
946aa31f02
implement codegen of while stmts and lvalue evaluation of paren exprs :)
...
llvm-svn: 39582
2007-06-05 03:59:43 +00:00
Chris Lattner
b16f455e8c
Type::isSignedInteger() and isUnsignedInteger() did not properly account for
...
'char', which varies based on the target.
Instead of spreading target knowledge throughout the compiler, bifurcate char
into Char_S and Char_U, and have ASTContext create the right one based on the
target, when it starts up.
llvm-svn: 39577
2007-06-03 07:25:34 +00:00
Chris Lattner
cf25024828
Implement EmitUsualArithmeticConversions, so we can add shorts to floats and
...
ints to long long etc. For int to longlong, we now get:
%tmp = load i64* %F ; <i64> [#uses=1]
%tmp1 = load i32* %D ; <i32> [#uses=1]
%promote = sext i32 %tmp1 to i64 ; <i64> [#uses=1]
%tmp2 = add i64 %tmp, %promote ; <i64> [#uses=0]
llvm-svn: 39576
2007-06-03 02:02:44 +00:00
Chris Lattner
c18f9d1aed
Change EmitUsualArithmeticConversions to use EmitExprWithUsualUnaryConversions.
...
This allows us to compile:
register short X;
{
int Y;
return 1+X+Y;
into:
%tmp = load i16* %X ; <i16> [#uses=1]
%promote = sext i16 %tmp to i32 ; <i32> [#uses=1]
%tmp1 = add i32 1, %promote ; <i32> [#uses=1]
%tmp2 = load i32* %Y ; <i32> [#uses=1]
%tmp3 = add i32 %tmp1, %tmp2 ; <i32> [#uses=1]
ret i32 %tmp3
Look at the amazing sign extension, so much happier than an assertion failure. :)
llvm-svn: 39565
2007-06-02 22:51:30 +00:00
Chris Lattner
6db1fb845a
implement a first hack at codegen'ing the usual unary conversions.
...
This allows us to compile:
int func() {
int A[10];
if (!A) {
to:
define i32 @func() {
entry:
%A = alloca [10 x i32] ; <[10 x i32]*> [#uses=1]
%arraydecay = getelementptr [10 x i32]* %A, i32 0, i32 0 ; <i32*> [#uses=1]
%tobool = icmp ne i32* %arraydecay, null ; <i1> [#uses=1]
%lnot = xor i1 %tobool, true ; <i1> [#uses=1]
br i1 %lnot, label %ifthen, label %ifend
-Chris
llvm-svn: 39564
2007-06-02 22:49:07 +00:00
Chris Lattner
2b4e21ac3f
Implement translation of pointer, reference and simple array types. We now
...
compile:
void foo() {
int A[10];
int *P;
into:
entry:
%A = alloca [10 x i32] ; <[10 x i32]*> [#uses=0]
%P = alloca i32* ; <i32**> [#uses=0]
llvm-svn: 39561
2007-06-02 19:52:24 +00:00