annotate tests/mini/asm1_1.d @ 1499:df11cdec45a2

Another shot at fixing the issues with (constant) struct literals and their addresses. See DMD2682, #218, #324. The idea is to separate the notion of const from 'this variable can always be replaced with its initializer' in the frontend. To do that, I introduced Declaration::isSameAsInitializer, which is overridden in VarDeclaration to return false for constants that have a struct literal initializer. So {{{ const S s = S(5); void foo() { auto ps = &s; } // is no longer replaced by void foo() { auto ps = &(S(5)); } }}} To make taking the address of a struct constant with a struct-initializer outside of function scope possible, I made sure that AddrExp::optimize doesn't try to run the argument's optimization with WANTinterpret - that'd again replace the constant with a struct literal temporary.
author Christian Kamm <kamm incasoftware de>
date Sun, 14 Jun 2009 19:49:58 +0200
parents 08f87d8cd101
children
Ignore whitespace changes - Everywhere: Within whitespace: At end of lines:
rev   line source
341
1bb99290e03a [svn r362] Started merging the old 'test' dir as well as the newer 'tangotests' dir into 'tests/mini' and 'tests/minicomplex'.
lindquist
parents: 220
diff changeset
1 module tangotests.asm1_1;
220
ccc2e6898a78 [svn r236] added initial codegen of inline asm, pretty buggy and incomplete still. see the tangotests/asm1.d test for a sample of what does
lindquist
parents:
diff changeset
2
ccc2e6898a78 [svn r236] added initial codegen of inline asm, pretty buggy and incomplete still. see the tangotests/asm1.d test for a sample of what does
lindquist
parents:
diff changeset
3 extern(C) int printf(char*, ...);
ccc2e6898a78 [svn r236] added initial codegen of inline asm, pretty buggy and incomplete still. see the tangotests/asm1.d test for a sample of what does
lindquist
parents:
diff changeset
4
ccc2e6898a78 [svn r236] added initial codegen of inline asm, pretty buggy and incomplete still. see the tangotests/asm1.d test for a sample of what does
lindquist
parents:
diff changeset
5 int main()
ccc2e6898a78 [svn r236] added initial codegen of inline asm, pretty buggy and incomplete still. see the tangotests/asm1.d test for a sample of what does
lindquist
parents:
diff changeset
6 {
ccc2e6898a78 [svn r236] added initial codegen of inline asm, pretty buggy and incomplete still. see the tangotests/asm1.d test for a sample of what does
lindquist
parents:
diff changeset
7 int i = 12;
ccc2e6898a78 [svn r236] added initial codegen of inline asm, pretty buggy and incomplete still. see the tangotests/asm1.d test for a sample of what does
lindquist
parents:
diff changeset
8 int* ip = &i;
ccc2e6898a78 [svn r236] added initial codegen of inline asm, pretty buggy and incomplete still. see the tangotests/asm1.d test for a sample of what does
lindquist
parents:
diff changeset
9 printf("%d\n", i);
1034
12b423e17860 Adjust mini tests to use D_InlineAsm
Christian Kamm <kamm incasoftware de>
parents: 741
diff changeset
10 version (D_InlineAsm_X86)
220
ccc2e6898a78 [svn r236] added initial codegen of inline asm, pretty buggy and incomplete still. see the tangotests/asm1.d test for a sample of what does
lindquist
parents:
diff changeset
11 {
1215
08f87d8cd101 Fix some unittests for 64-bit asm. They were operating on int variables as if
Frits van Bommel <fvbommel wxs.nl>
parents: 1034
diff changeset
12 asm
08f87d8cd101 Fix some unittests for 64-bit asm. They were operating on int variables as if
Frits van Bommel <fvbommel wxs.nl>
parents: 1034
diff changeset
13 {
08f87d8cd101 Fix some unittests for 64-bit asm. They were operating on int variables as if
Frits van Bommel <fvbommel wxs.nl>
parents: 1034
diff changeset
14 mov ECX, ip;
08f87d8cd101 Fix some unittests for 64-bit asm. They were operating on int variables as if
Frits van Bommel <fvbommel wxs.nl>
parents: 1034
diff changeset
15 mov EAX, [ECX];
08f87d8cd101 Fix some unittests for 64-bit asm. They were operating on int variables as if
Frits van Bommel <fvbommel wxs.nl>
parents: 1034
diff changeset
16 add EAX, 8;
08f87d8cd101 Fix some unittests for 64-bit asm. They were operating on int variables as if
Frits van Bommel <fvbommel wxs.nl>
parents: 1034
diff changeset
17 mul EAX, EAX;
08f87d8cd101 Fix some unittests for 64-bit asm. They were operating on int variables as if
Frits van Bommel <fvbommel wxs.nl>
parents: 1034
diff changeset
18 mov [ECX], EAX;
08f87d8cd101 Fix some unittests for 64-bit asm. They were operating on int variables as if
Frits van Bommel <fvbommel wxs.nl>
parents: 1034
diff changeset
19 }
741
4ac97ec7c18e Applied easy part from wilsonk's x86-64 patch in #107
Christian Kamm <kamm incasoftware de>
parents: 341
diff changeset
20 }
1034
12b423e17860 Adjust mini tests to use D_InlineAsm
Christian Kamm <kamm incasoftware de>
parents: 741
diff changeset
21 else version (D_InlineAsm_X86_64)
741
4ac97ec7c18e Applied easy part from wilsonk's x86-64 patch in #107
Christian Kamm <kamm incasoftware de>
parents: 341
diff changeset
22 {
1215
08f87d8cd101 Fix some unittests for 64-bit asm. They were operating on int variables as if
Frits van Bommel <fvbommel wxs.nl>
parents: 1034
diff changeset
23 asm
08f87d8cd101 Fix some unittests for 64-bit asm. They were operating on int variables as if
Frits van Bommel <fvbommel wxs.nl>
parents: 1034
diff changeset
24 {
08f87d8cd101 Fix some unittests for 64-bit asm. They were operating on int variables as if
Frits van Bommel <fvbommel wxs.nl>
parents: 1034
diff changeset
25 movq RCX, ip;
08f87d8cd101 Fix some unittests for 64-bit asm. They were operating on int variables as if
Frits van Bommel <fvbommel wxs.nl>
parents: 1034
diff changeset
26 mov EAX, [RCX];
08f87d8cd101 Fix some unittests for 64-bit asm. They were operating on int variables as if
Frits van Bommel <fvbommel wxs.nl>
parents: 1034
diff changeset
27 add EAX, 8;
08f87d8cd101 Fix some unittests for 64-bit asm. They were operating on int variables as if
Frits van Bommel <fvbommel wxs.nl>
parents: 1034
diff changeset
28 imul EAX, EAX;
08f87d8cd101 Fix some unittests for 64-bit asm. They were operating on int variables as if
Frits van Bommel <fvbommel wxs.nl>
parents: 1034
diff changeset
29 mov [RCX], EAX;
08f87d8cd101 Fix some unittests for 64-bit asm. They were operating on int variables as if
Frits van Bommel <fvbommel wxs.nl>
parents: 1034
diff changeset
30 }
220
ccc2e6898a78 [svn r236] added initial codegen of inline asm, pretty buggy and incomplete still. see the tangotests/asm1.d test for a sample of what does
lindquist
parents:
diff changeset
31 }
ccc2e6898a78 [svn r236] added initial codegen of inline asm, pretty buggy and incomplete still. see the tangotests/asm1.d test for a sample of what does
lindquist
parents:
diff changeset
32 printf("%d\n", i);
ccc2e6898a78 [svn r236] added initial codegen of inline asm, pretty buggy and incomplete still. see the tangotests/asm1.d test for a sample of what does
lindquist
parents:
diff changeset
33 assert(i == 400);
ccc2e6898a78 [svn r236] added initial codegen of inline asm, pretty buggy and incomplete still. see the tangotests/asm1.d test for a sample of what does
lindquist
parents:
diff changeset
34 return 0;
ccc2e6898a78 [svn r236] added initial codegen of inline asm, pretty buggy and incomplete still. see the tangotests/asm1.d test for a sample of what does
lindquist
parents:
diff changeset
35 }