annotate ir/irfunction.h @ 945:03d7c4aac654

SWITCHED TO LLVM 2.5 ! Applied patch from ticket #129 to compile against latest LLVM. Thanks Frits van Bommel. Fixed implicit return by asm block at the end of a function on x86-32. Other architectures will produce an error at the moment. Adding support for new targets is fairly simple. Fixed return calling convention for complex numbers, ST and ST(1) were switched around. Added some testcases. I've run a dstress test and there are no regressions. However, the runtime does not seem to compile with symbolic debug information. -O3 -release -inline works well and is what I used for the dstress run. Tango does not compile, a small workaround is needed in tango.io.digest.Digest.Digest.hexDigest. See ticket #206 .
author Tomas Lindquist Olsen <tomas.l.olsen@gmail.com>
date Sun, 08 Feb 2009 05:26:54 +0100
parents 2ebac4750adb
children 1714836f2c0b
Ignore whitespace changes - Everywhere: Within whitespace: At end of lines:
rev   line source
664
eef8ac26c66c Some missed LLVMDC -> LDC.
Christian Kamm <kamm incasoftware de>
parents: 584
diff changeset
1 #ifndef LDC_IR_IRFUNCTION_H
eef8ac26c66c Some missed LLVMDC -> LDC.
Christian Kamm <kamm incasoftware de>
parents: 584
diff changeset
2 #define LDC_IR_IRFUNCTION_H
136
0e28624814e8 [svn r140] did a lot of the work towards being able to pass multiple modules on the command line. not complete yet though
lindquist
parents:
diff changeset
3
0e28624814e8 [svn r140] did a lot of the work towards being able to pass multiple modules on the command line. not complete yet though
lindquist
parents:
diff changeset
4 #include "ir/ir.h"
319
e9c93739bc4c [svn r340] Rework exception handling to work with nested tryfinally and trycatch.
ChristianK
parents: 309
diff changeset
5 #include "ir/irlandingpad.h"
136
0e28624814e8 [svn r140] did a lot of the work towards being able to pass multiple modules on the command line. not complete yet though
lindquist
parents:
diff changeset
6
0e28624814e8 [svn r140] did a lot of the work towards being able to pass multiple modules on the command line. not complete yet though
lindquist
parents:
diff changeset
7 #include <vector>
355
d8357f7004ca [svn r376] Fix bug with finally blocks and labels. The labels would get emitted multiple times and conflict.
ChristianK
parents: 353
diff changeset
8 #include <stack>
d8357f7004ca [svn r376] Fix bug with finally blocks and labels. The labels would get emitted multiple times and conflict.
ChristianK
parents: 353
diff changeset
9 #include <map>
136
0e28624814e8 [svn r140] did a lot of the work towards being able to pass multiple modules on the command line. not complete yet though
lindquist
parents:
diff changeset
10
0e28624814e8 [svn r140] did a lot of the work towards being able to pass multiple modules on the command line. not complete yet though
lindquist
parents:
diff changeset
11 // represents a function
0e28624814e8 [svn r140] did a lot of the work towards being able to pass multiple modules on the command line. not complete yet though
lindquist
parents:
diff changeset
12 struct IrFunction : IrBase
0e28624814e8 [svn r140] did a lot of the work towards being able to pass multiple modules on the command line. not complete yet though
lindquist
parents:
diff changeset
13 {
0e28624814e8 [svn r140] did a lot of the work towards being able to pass multiple modules on the command line. not complete yet though
lindquist
parents:
diff changeset
14 llvm::Function* func;
0e28624814e8 [svn r140] did a lot of the work towards being able to pass multiple modules on the command line. not complete yet though
lindquist
parents:
diff changeset
15 llvm::Instruction* allocapoint;
0e28624814e8 [svn r140] did a lot of the work towards being able to pass multiple modules on the command line. not complete yet though
lindquist
parents:
diff changeset
16 FuncDeclaration* decl;
0e28624814e8 [svn r140] did a lot of the work towards being able to pass multiple modules on the command line. not complete yet though
lindquist
parents:
diff changeset
17 TypeFunction* type;
0e28624814e8 [svn r140] did a lot of the work towards being able to pass multiple modules on the command line. not complete yet though
lindquist
parents:
diff changeset
18
0e28624814e8 [svn r140] did a lot of the work towards being able to pass multiple modules on the command line. not complete yet though
lindquist
parents:
diff changeset
19 bool queued;
0e28624814e8 [svn r140] did a lot of the work towards being able to pass multiple modules on the command line. not complete yet though
lindquist
parents:
diff changeset
20 bool defined;
486
a34078905d01 Added pragma(llvmdc, "string") for misc per-module compiler configuration, currently "string" can only be "verbose" which forces -vv for module it appears in.
Tomas Lindquist Olsen <tomas.l.olsen@gmail.com>
parents: 355
diff changeset
21
a34078905d01 Added pragma(llvmdc, "string") for misc per-module compiler configuration, currently "string" can only be "verbose" which forces -vv for module it appears in.
Tomas Lindquist Olsen <tomas.l.olsen@gmail.com>
parents: 355
diff changeset
22 llvm::Value* retArg; // return in ptr arg
a34078905d01 Added pragma(llvmdc, "string") for misc per-module compiler configuration, currently "string" can only be "verbose" which forces -vv for module it appears in.
Tomas Lindquist Olsen <tomas.l.olsen@gmail.com>
parents: 355
diff changeset
23 llvm::Value* thisArg; // class/struct 'this' arg
a34078905d01 Added pragma(llvmdc, "string") for misc per-module compiler configuration, currently "string" can only be "verbose" which forces -vv for module it appears in.
Tomas Lindquist Olsen <tomas.l.olsen@gmail.com>
parents: 355
diff changeset
24 llvm::Value* nestArg; // nested function 'this' arg
a34078905d01 Added pragma(llvmdc, "string") for misc per-module compiler configuration, currently "string" can only be "verbose" which forces -vv for module it appears in.
Tomas Lindquist Olsen <tomas.l.olsen@gmail.com>
parents: 355
diff changeset
25
a34078905d01 Added pragma(llvmdc, "string") for misc per-module compiler configuration, currently "string" can only be "verbose" which forces -vv for module it appears in.
Tomas Lindquist Olsen <tomas.l.olsen@gmail.com>
parents: 355
diff changeset
26 llvm::Value* nestedVar; // nested var alloca
a34078905d01 Added pragma(llvmdc, "string") for misc per-module compiler configuration, currently "string" can only be "verbose" which forces -vv for module it appears in.
Tomas Lindquist Olsen <tomas.l.olsen@gmail.com>
parents: 355
diff changeset
27
136
0e28624814e8 [svn r140] did a lot of the work towards being able to pass multiple modules on the command line. not complete yet though
lindquist
parents:
diff changeset
28 llvm::Value* _arguments;
0e28624814e8 [svn r140] did a lot of the work towards being able to pass multiple modules on the command line. not complete yet though
lindquist
parents:
diff changeset
29 llvm::Value* _argptr;
486
a34078905d01 Added pragma(llvmdc, "string") for misc per-module compiler configuration, currently "string" can only be "verbose" which forces -vv for module it appears in.
Tomas Lindquist Olsen <tomas.l.olsen@gmail.com>
parents: 355
diff changeset
30
136
0e28624814e8 [svn r140] did a lot of the work towards being able to pass multiple modules on the command line. not complete yet though
lindquist
parents:
diff changeset
31 llvm::Constant* dwarfSubProg;
0e28624814e8 [svn r140] did a lot of the work towards being able to pass multiple modules on the command line. not complete yet though
lindquist
parents:
diff changeset
32
355
d8357f7004ca [svn r376] Fix bug with finally blocks and labels. The labels would get emitted multiple times and conflict.
ChristianK
parents: 353
diff changeset
33 // pushes a unique label scope of the given name
d8357f7004ca [svn r376] Fix bug with finally blocks and labels. The labels would get emitted multiple times and conflict.
ChristianK
parents: 353
diff changeset
34 void pushUniqueLabelScope(const char* name);
d8357f7004ca [svn r376] Fix bug with finally blocks and labels. The labels would get emitted multiple times and conflict.
ChristianK
parents: 353
diff changeset
35 // pops a label scope
d8357f7004ca [svn r376] Fix bug with finally blocks and labels. The labels would get emitted multiple times and conflict.
ChristianK
parents: 353
diff changeset
36 void popLabelScope();
d8357f7004ca [svn r376] Fix bug with finally blocks and labels. The labels would get emitted multiple times and conflict.
ChristianK
parents: 353
diff changeset
37
d8357f7004ca [svn r376] Fix bug with finally blocks and labels. The labels would get emitted multiple times and conflict.
ChristianK
parents: 353
diff changeset
38 // gets the string under which the label's BB
d8357f7004ca [svn r376] Fix bug with finally blocks and labels. The labels would get emitted multiple times and conflict.
ChristianK
parents: 353
diff changeset
39 // is stored in the labelToBB map.
d8357f7004ca [svn r376] Fix bug with finally blocks and labels. The labels would get emitted multiple times and conflict.
ChristianK
parents: 353
diff changeset
40 // essentially prefixes ident by the strings in labelScopes
d8357f7004ca [svn r376] Fix bug with finally blocks and labels. The labels would get emitted multiple times and conflict.
ChristianK
parents: 353
diff changeset
41 std::string getScopedLabelName(const char* ident);
d8357f7004ca [svn r376] Fix bug with finally blocks and labels. The labels would get emitted multiple times and conflict.
ChristianK
parents: 353
diff changeset
42
353
a7a26f538d6e [svn r374] Move label target basic block from AST to IRFunction. This is a first step to allowing labels to be emitted multiple times. (for instance within finally blocks)
ChristianK
parents: 319
diff changeset
43 // label to basic block lookup
a7a26f538d6e [svn r374] Move label target basic block from AST to IRFunction. This is a first step to allowing labels to be emitted multiple times. (for instance within finally blocks)
ChristianK
parents: 319
diff changeset
44 typedef std::map<std::string, llvm::BasicBlock*> LabelToBBMap;
a7a26f538d6e [svn r374] Move label target basic block from AST to IRFunction. This is a first step to allowing labels to be emitted multiple times. (for instance within finally blocks)
ChristianK
parents: 319
diff changeset
45 LabelToBBMap labelToBB;
a7a26f538d6e [svn r374] Move label target basic block from AST to IRFunction. This is a first step to allowing labels to be emitted multiple times. (for instance within finally blocks)
ChristianK
parents: 319
diff changeset
46
319
e9c93739bc4c [svn r340] Rework exception handling to work with nested tryfinally and trycatch.
ChristianK
parents: 309
diff changeset
47 // landing pads for try statements
e9c93739bc4c [svn r340] Rework exception handling to work with nested tryfinally and trycatch.
ChristianK
parents: 309
diff changeset
48 IRLandingPad landingPad;
e9c93739bc4c [svn r340] Rework exception handling to work with nested tryfinally and trycatch.
ChristianK
parents: 309
diff changeset
49
136
0e28624814e8 [svn r140] did a lot of the work towards being able to pass multiple modules on the command line. not complete yet though
lindquist
parents:
diff changeset
50 IrFunction(FuncDeclaration* fd);
355
d8357f7004ca [svn r376] Fix bug with finally blocks and labels. The labels would get emitted multiple times and conflict.
ChristianK
parents: 353
diff changeset
51
584
c7d7e2282ba3 Make sure functions containing inline asm are never inlined to avoid
Christian Kamm <kamm incasoftware de>
parents: 486
diff changeset
52 // annotations
c7d7e2282ba3 Make sure functions containing inline asm are never inlined to avoid
Christian Kamm <kamm incasoftware de>
parents: 486
diff changeset
53 void setNeverInline();
c7d7e2282ba3 Make sure functions containing inline asm are never inlined to avoid
Christian Kamm <kamm incasoftware de>
parents: 486
diff changeset
54 void setAlwaysInline();
c7d7e2282ba3 Make sure functions containing inline asm are never inlined to avoid
Christian Kamm <kamm incasoftware de>
parents: 486
diff changeset
55
355
d8357f7004ca [svn r376] Fix bug with finally blocks and labels. The labels would get emitted multiple times and conflict.
ChristianK
parents: 353
diff changeset
56 private:
d8357f7004ca [svn r376] Fix bug with finally blocks and labels. The labels would get emitted multiple times and conflict.
ChristianK
parents: 353
diff changeset
57 // prefix for labels and gotos
d8357f7004ca [svn r376] Fix bug with finally blocks and labels. The labels would get emitted multiple times and conflict.
ChristianK
parents: 353
diff changeset
58 // used for allowing labels to be emitted twice
d8357f7004ca [svn r376] Fix bug with finally blocks and labels. The labels would get emitted multiple times and conflict.
ChristianK
parents: 353
diff changeset
59 std::vector<std::string> labelScopes;
d8357f7004ca [svn r376] Fix bug with finally blocks and labels. The labels would get emitted multiple times and conflict.
ChristianK
parents: 353
diff changeset
60
d8357f7004ca [svn r376] Fix bug with finally blocks and labels. The labels would get emitted multiple times and conflict.
ChristianK
parents: 353
diff changeset
61 // next unique id stack
d8357f7004ca [svn r376] Fix bug with finally blocks and labels. The labels would get emitted multiple times and conflict.
ChristianK
parents: 353
diff changeset
62 std::stack<int> nextUnique;
136
0e28624814e8 [svn r140] did a lot of the work towards being able to pass multiple modules on the command line. not complete yet though
lindquist
parents:
diff changeset
63 };
0e28624814e8 [svn r140] did a lot of the work towards being able to pass multiple modules on the command line. not complete yet though
lindquist
parents:
diff changeset
64
0e28624814e8 [svn r140] did a lot of the work towards being able to pass multiple modules on the command line. not complete yet though
lindquist
parents:
diff changeset
65 #endif