Mercurial > projects > ldc
annotate gen/irstate.h @ 1559:06d5cc873350
getTrue/getFalse were moved back to ConstantInt
Requires LLVM >= r77685
author | Benjamin Kramer <benny.kra@gmail.com> |
---|---|
date | Fri, 31 Jul 2009 19:11:07 +0200 |
parents | 61f12f4651b5 |
children | 8d086d552909 |
rev | line source |
---|---|
664
eef8ac26c66c
Some missed LLVMDC -> LDC.
Christian Kamm <kamm incasoftware de>
parents:
632
diff
changeset
|
1 #ifndef LDC_GEN_IRSTATE_H |
eef8ac26c66c
Some missed LLVMDC -> LDC.
Christian Kamm <kamm incasoftware de>
parents:
632
diff
changeset
|
2 #define LDC_GEN_IRSTATE_H |
1 | 3 |
4 #include <vector> | |
945
03d7c4aac654
SWITCHED TO LLVM 2.5 !
Tomas Lindquist Olsen <tomas.l.olsen@gmail.com>
parents:
920
diff
changeset
|
5 #include <deque> |
102
027b8d8b71ec
[svn r106] Turns out the last commit wasn't enough, now the D->LLVM process is even more split up.
lindquist
parents:
100
diff
changeset
|
6 #include <list> |
920
545f54041d91
Implemented proper support for naked asm using llvm module level asm. Still not 100% complete, but already 1000 times better that what we had before. Don's BignumX86 implementation from Tango (when turned into a standalone unittest) seems to fully work with no changes, and great performance :)
Tomas Lindquist Olsen <tomas.l.olsen@gmail.com>
parents:
797
diff
changeset
|
7 #include <sstream> |
1 | 8 |
9 #include "root.h" | |
113
27b9f749d9fe
[svn r117] Initial working implementation of interfaces.
lindquist
parents:
108
diff
changeset
|
10 #include "aggregate.h" |
1 | 11 |
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:
116
diff
changeset
|
12 #include "ir/irfunction.h" |
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:
116
diff
changeset
|
13 #include "ir/irstruct.h" |
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:
116
diff
changeset
|
14 #include "ir/irvar.h" |
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:
116
diff
changeset
|
15 |
1013
8c73ff5f69e0
Use llvm::CallSite instead of custom CallOrInvoke class.
Frits van Bommel <fvbommel wxs.nl>
parents:
988
diff
changeset
|
16 #include "llvm/Support/CallSite.h" |
8c73ff5f69e0
Use llvm::CallSite instead of custom CallOrInvoke class.
Frits van Bommel <fvbommel wxs.nl>
parents:
988
diff
changeset
|
17 |
988
2667e3a145be
- Fixed LLVM style CL args for D2.
Tomas Lindquist Olsen <tomas.l.olsen@gmail.com>
parents:
971
diff
changeset
|
18 namespace llvm { |
1535
61f12f4651b5
Don't use llvm::getGlobalContext() anymore
Benjamin Kramer <benny.kra@gmail.com>
parents:
1529
diff
changeset
|
19 class LLVMContext; |
988
2667e3a145be
- Fixed LLVM style CL args for D2.
Tomas Lindquist Olsen <tomas.l.olsen@gmail.com>
parents:
971
diff
changeset
|
20 class TargetMachine; |
2667e3a145be
- Fixed LLVM style CL args for D2.
Tomas Lindquist Olsen <tomas.l.olsen@gmail.com>
parents:
971
diff
changeset
|
21 } |
2667e3a145be
- Fixed LLVM style CL args for D2.
Tomas Lindquist Olsen <tomas.l.olsen@gmail.com>
parents:
971
diff
changeset
|
22 |
1 | 23 // global ir state for current module |
24 struct IRState; | |
988
2667e3a145be
- Fixed LLVM style CL args for D2.
Tomas Lindquist Olsen <tomas.l.olsen@gmail.com>
parents:
971
diff
changeset
|
25 struct TargetABI; |
2667e3a145be
- Fixed LLVM style CL args for D2.
Tomas Lindquist Olsen <tomas.l.olsen@gmail.com>
parents:
971
diff
changeset
|
26 |
1 | 27 extern IRState* gIR; |
988
2667e3a145be
- Fixed LLVM style CL args for D2.
Tomas Lindquist Olsen <tomas.l.olsen@gmail.com>
parents:
971
diff
changeset
|
28 extern llvm::TargetMachine* gTargetMachine; |
73 | 29 extern const llvm::TargetData* gTargetData; |
988
2667e3a145be
- Fixed LLVM style CL args for D2.
Tomas Lindquist Olsen <tomas.l.olsen@gmail.com>
parents:
971
diff
changeset
|
30 extern TargetABI* gABI; |
1 | 31 |
32 struct TypeFunction; | |
33 struct TypeStruct; | |
34 struct ClassDeclaration; | |
35 struct FuncDeclaration; | |
36 struct Module; | |
37 struct TypeStruct; | |
113
27b9f749d9fe
[svn r117] Initial working implementation of interfaces.
lindquist
parents:
108
diff
changeset
|
38 struct BaseClass; |
797
340acf1535d0
Removed KDevelop3 project files, CMake can generate them just fine!
Tomas Lindquist Olsen <tomas.l.olsen@gmail.com>
parents:
664
diff
changeset
|
39 struct AnonDeclaration; |
1 | 40 |
156
ccd07d9f2ce9
[svn r172] moving all IR state previously stored in Dsymbol into IrDsymbol and a Dsymbol->IrDsymbol map
ChristianK
parents:
155
diff
changeset
|
41 struct IrModule; |
ccd07d9f2ce9
[svn r172] moving all IR state previously stored in Dsymbol into IrDsymbol and a Dsymbol->IrDsymbol map
ChristianK
parents:
155
diff
changeset
|
42 |
1 | 43 // represents a scope |
44 struct IRScope | |
45 { | |
46 llvm::BasicBlock* begin; | |
47 llvm::BasicBlock* end; | |
493
017ca8645a1f
Make llvmdc work with llvm 2.4svn revision 54614. Breaks compatibility with llvm 2.3.
Christian Kamm <kamm incasoftware de>
parents:
477
diff
changeset
|
48 IRBuilder<> builder; |
1 | 49 |
50 IRScope(); | |
51 IRScope(llvm::BasicBlock* b, llvm::BasicBlock* e); | |
1529
ad7f2f1862d6
Adjust LDC to work with the LLVMContext LLVM changes.
Christian Kamm <kamm incasoftware de>
parents:
1508
diff
changeset
|
52 |
ad7f2f1862d6
Adjust LDC to work with the LLVMContext LLVM changes.
Christian Kamm <kamm incasoftware de>
parents:
1508
diff
changeset
|
53 const IRScope& operator=(const IRScope& rhs); |
1 | 54 }; |
55 | |
40 | 56 struct IRBuilderHelper |
57 { | |
58 IRState* state; | |
493
017ca8645a1f
Make llvmdc work with llvm 2.4svn revision 54614. Breaks compatibility with llvm 2.3.
Christian Kamm <kamm incasoftware de>
parents:
477
diff
changeset
|
59 IRBuilder<>* operator->(); |
40 | 60 }; |
61 | |
232
092468448d25
[svn r248] Fixed: labels in inline asm block now work for the normal case.
lindquist
parents:
213
diff
changeset
|
62 struct IRAsmStmt |
092468448d25
[svn r248] Fixed: labels in inline asm block now work for the normal case.
lindquist
parents:
213
diff
changeset
|
63 { |
477
253f234eb80c
Make sure to initialize isBranchToLabel to zero.
Christian Kamm <kamm incasoftware de>
parents:
447
diff
changeset
|
64 IRAsmStmt() |
253f234eb80c
Make sure to initialize isBranchToLabel to zero.
Christian Kamm <kamm incasoftware de>
parents:
447
diff
changeset
|
65 : isBranchToLabel(NULL) {} |
253f234eb80c
Make sure to initialize isBranchToLabel to zero.
Christian Kamm <kamm incasoftware de>
parents:
447
diff
changeset
|
66 |
232
092468448d25
[svn r248] Fixed: labels in inline asm block now work for the normal case.
lindquist
parents:
213
diff
changeset
|
67 std::string code; |
092468448d25
[svn r248] Fixed: labels in inline asm block now work for the normal case.
lindquist
parents:
213
diff
changeset
|
68 std::string out_c; |
092468448d25
[svn r248] Fixed: labels in inline asm block now work for the normal case.
lindquist
parents:
213
diff
changeset
|
69 std::string in_c; |
092468448d25
[svn r248] Fixed: labels in inline asm block now work for the normal case.
lindquist
parents:
213
diff
changeset
|
70 std::vector<LLValue*> out; |
092468448d25
[svn r248] Fixed: labels in inline asm block now work for the normal case.
lindquist
parents:
213
diff
changeset
|
71 std::vector<LLValue*> in; |
299
df8a7b8d5929
[svn r320] Begun work on branches out of asm blocks. Unfinished.
ChristianK
parents:
252
diff
changeset
|
72 |
302 | 73 // if this is nonzero, it contains the target label |
305
2b72433d5c8c
[svn r326] Fixed a bunch of issues with printf's that MinGW32 did not support.
lindquist
parents:
302
diff
changeset
|
74 Identifier* isBranchToLabel; |
232
092468448d25
[svn r248] Fixed: labels in inline asm block now work for the normal case.
lindquist
parents:
213
diff
changeset
|
75 }; |
092468448d25
[svn r248] Fixed: labels in inline asm block now work for the normal case.
lindquist
parents:
213
diff
changeset
|
76 |
233
76ee1bbe487e
[svn r249] Changed inline asm clobbers to a set instead of a list so we don't get duplicate clobbers.
lindquist
parents:
232
diff
changeset
|
77 struct IRAsmBlock |
76ee1bbe487e
[svn r249] Changed inline asm clobbers to a set instead of a list so we don't get duplicate clobbers.
lindquist
parents:
232
diff
changeset
|
78 { |
945
03d7c4aac654
SWITCHED TO LLVM 2.5 !
Tomas Lindquist Olsen <tomas.l.olsen@gmail.com>
parents:
920
diff
changeset
|
79 std::deque<IRAsmStmt*> s; |
233
76ee1bbe487e
[svn r249] Changed inline asm clobbers to a set instead of a list so we don't get duplicate clobbers.
lindquist
parents:
232
diff
changeset
|
80 std::set<std::string> clobs; |
971
985104c0f1db
Fix the problems exposed by the callingconv1.d test case.
Frits van Bommel <fvbommel wxs.nl>
parents:
959
diff
changeset
|
81 size_t outputcount; |
299
df8a7b8d5929
[svn r320] Begun work on branches out of asm blocks. Unfinished.
ChristianK
parents:
252
diff
changeset
|
82 |
df8a7b8d5929
[svn r320] Begun work on branches out of asm blocks. Unfinished.
ChristianK
parents:
252
diff
changeset
|
83 // stores the labels within the asm block |
df8a7b8d5929
[svn r320] Begun work on branches out of asm blocks. Unfinished.
ChristianK
parents:
252
diff
changeset
|
84 std::vector<Identifier*> internalLabels; |
945
03d7c4aac654
SWITCHED TO LLVM 2.5 !
Tomas Lindquist Olsen <tomas.l.olsen@gmail.com>
parents:
920
diff
changeset
|
85 |
03d7c4aac654
SWITCHED TO LLVM 2.5 !
Tomas Lindquist Olsen <tomas.l.olsen@gmail.com>
parents:
920
diff
changeset
|
86 AsmBlockStatement* asmBlock; |
03d7c4aac654
SWITCHED TO LLVM 2.5 !
Tomas Lindquist Olsen <tomas.l.olsen@gmail.com>
parents:
920
diff
changeset
|
87 const LLType* retty; |
03d7c4aac654
SWITCHED TO LLVM 2.5 !
Tomas Lindquist Olsen <tomas.l.olsen@gmail.com>
parents:
920
diff
changeset
|
88 unsigned retn; |
954
e048e36bc155
Added support for using a temporary to implement emulated ABI return from inline asm, could be easier to use, but I think this will do. It's so extremely target dependent in any case that doing a completely generic approach seems hard.
Tomas Lindquist Olsen <tomas.l.olsen@gmail.com>
parents:
946
diff
changeset
|
89 bool retemu; // emulate abi ret with a temporary |
959
7e669954db7d
Implement implicit return after inline asm on x86_64
Frits van Bommel <fvbommel wxs.nl>
parents:
954
diff
changeset
|
90 LLValue* (*retfixup)(IRBuilderHelper b, LLValue* orig); // Modifies retval |
945
03d7c4aac654
SWITCHED TO LLVM 2.5 !
Tomas Lindquist Olsen <tomas.l.olsen@gmail.com>
parents:
920
diff
changeset
|
91 |
959
7e669954db7d
Implement implicit return after inline asm on x86_64
Frits van Bommel <fvbommel wxs.nl>
parents:
954
diff
changeset
|
92 IRAsmBlock(AsmBlockStatement* b) |
971
985104c0f1db
Fix the problems exposed by the callingconv1.d test case.
Frits van Bommel <fvbommel wxs.nl>
parents:
959
diff
changeset
|
93 : asmBlock(b), retty(NULL), retn(0), retemu(false), retfixup(NULL), |
985104c0f1db
Fix the problems exposed by the callingconv1.d test case.
Frits van Bommel <fvbommel wxs.nl>
parents:
959
diff
changeset
|
94 outputcount(0) |
985104c0f1db
Fix the problems exposed by the callingconv1.d test case.
Frits van Bommel <fvbommel wxs.nl>
parents:
959
diff
changeset
|
95 {} |
233
76ee1bbe487e
[svn r249] Changed inline asm clobbers to a set instead of a list so we don't get duplicate clobbers.
lindquist
parents:
232
diff
changeset
|
96 }; |
76ee1bbe487e
[svn r249] Changed inline asm clobbers to a set instead of a list so we don't get duplicate clobbers.
lindquist
parents:
232
diff
changeset
|
97 |
1 | 98 // represents the module |
40 | 99 struct IRState |
1 | 100 { |
946
1714836f2c0b
Mostly rewrite debug info generation in terms of llvm/Analysis/DebugInfo.h.
Christian Kamm <kamm incasoftware de>
parents:
945
diff
changeset
|
101 IRState(llvm::Module* m); |
1 | 102 |
103 // module | |
104 Module* dmodule; | |
105 llvm::Module* module; | |
106 | |
161
3a891cfcd249
[svn r177] moved variable for interface info type from being local static to being within IRState
ChristianK
parents:
157
diff
changeset
|
107 // interface info type, used in DtoInterfaceInfoType |
309 | 108 const LLStructType* interfaceInfoType; |
109 const LLStructType* mutexType; | |
323
0d52412d5b1a
[svn r344] Fixed some very minor issues with the usage listing when calling llvmdc with no arguments.
lindquist
parents:
319
diff
changeset
|
110 const LLStructType* moduleRefType; |
161
3a891cfcd249
[svn r177] moved variable for interface info type from being local static to being within IRState
ChristianK
parents:
157
diff
changeset
|
111 |
1535
61f12f4651b5
Don't use llvm::getGlobalContext() anymore
Benjamin Kramer <benny.kra@gmail.com>
parents:
1529
diff
changeset
|
112 // helper to get the LLVMContext of the module |
61f12f4651b5
Don't use llvm::getGlobalContext() anymore
Benjamin Kramer <benny.kra@gmail.com>
parents:
1529
diff
changeset
|
113 llvm::LLVMContext& context() const { return module->getContext(); } |
61f12f4651b5
Don't use llvm::getGlobalContext() anymore
Benjamin Kramer <benny.kra@gmail.com>
parents:
1529
diff
changeset
|
114 |
1 | 115 // functions |
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:
116
diff
changeset
|
116 typedef std::vector<IrFunction*> FunctionVector; |
40 | 117 FunctionVector functions; |
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:
116
diff
changeset
|
118 IrFunction* func(); |
40 | 119 |
1 | 120 llvm::Function* topfunc(); |
121 TypeFunction* topfunctype(); | |
122 llvm::Instruction* topallocapoint(); | |
123 | |
124 // structs | |
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:
116
diff
changeset
|
125 typedef std::vector<IrStruct*> StructVector; |
1 | 126 StructVector structs; |
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:
116
diff
changeset
|
127 IrStruct* topstruct(); |
1 | 128 |
129 // D main function | |
130 bool emitMain; | |
131 llvm::Function* mainFunc; | |
132 | |
133 // basic block scopes | |
134 std::vector<IRScope> scopes; | |
135 IRScope& scope(); | |
108
288fe1029e1f
[svn r112] Fixed 'case 1,2,3:' style case statements.
lindquist
parents:
103
diff
changeset
|
136 llvm::BasicBlock* scopebb(); |
1 | 137 llvm::BasicBlock* scopeend(); |
138 bool scopereturned(); | |
139 | |
315
a9697749e898
[svn r336] Made sure calls within a landing pad area are invokes.
ChristianK
parents:
314
diff
changeset
|
140 // create a call or invoke, depending on the landing pad info |
a9697749e898
[svn r336] Made sure calls within a landing pad area are invokes.
ChristianK
parents:
314
diff
changeset
|
141 // the template function is defined further down in this file |
a9697749e898
[svn r336] Made sure calls within a landing pad area are invokes.
ChristianK
parents:
314
diff
changeset
|
142 template <typename InputIterator> |
1013
8c73ff5f69e0
Use llvm::CallSite instead of custom CallOrInvoke class.
Frits van Bommel <fvbommel wxs.nl>
parents:
988
diff
changeset
|
143 llvm::CallSite CreateCallOrInvoke(LLValue* Callee, InputIterator ArgBegin, InputIterator ArgEnd, const char* Name=""); |
8c73ff5f69e0
Use llvm::CallSite instead of custom CallOrInvoke class.
Frits van Bommel <fvbommel wxs.nl>
parents:
988
diff
changeset
|
144 llvm::CallSite CreateCallOrInvoke(LLValue* Callee, const char* Name=""); |
8c73ff5f69e0
Use llvm::CallSite instead of custom CallOrInvoke class.
Frits van Bommel <fvbommel wxs.nl>
parents:
988
diff
changeset
|
145 llvm::CallSite CreateCallOrInvoke(LLValue* Callee, LLValue* Arg1, const char* Name=""); |
8c73ff5f69e0
Use llvm::CallSite instead of custom CallOrInvoke class.
Frits van Bommel <fvbommel wxs.nl>
parents:
988
diff
changeset
|
146 llvm::CallSite CreateCallOrInvoke2(LLValue* Callee, LLValue* Arg1, LLValue* Arg2, const char* Name=""); |
8c73ff5f69e0
Use llvm::CallSite instead of custom CallOrInvoke class.
Frits van Bommel <fvbommel wxs.nl>
parents:
988
diff
changeset
|
147 llvm::CallSite CreateCallOrInvoke3(LLValue* Callee, LLValue* Arg1, LLValue* Arg2, LLValue* Arg3, const char* Name=""); |
8c73ff5f69e0
Use llvm::CallSite instead of custom CallOrInvoke class.
Frits van Bommel <fvbommel wxs.nl>
parents:
988
diff
changeset
|
148 llvm::CallSite CreateCallOrInvoke4(LLValue* Callee, LLValue* Arg1, LLValue* Arg2, LLValue* Arg3, LLValue* Arg4, const char* Name=""); |
315
a9697749e898
[svn r336] Made sure calls within a landing pad area are invokes.
ChristianK
parents:
314
diff
changeset
|
149 |
1 | 150 // this holds the array being indexed or sliced so $ will work |
151 // might be a better way but it works. problem is I only get a | |
152 // VarDeclaration for __dollar, but I can't see how to get the | |
153 // array pointer from this :( | |
86
fd32135dca3e
[svn r90] Major updates to the gen directory. Redesigned the 'elem' struct. Much more... !!!
lindquist
parents:
82
diff
changeset
|
154 std::vector<DValue*> arrays; |
15
37a4fdab33fc
[svn r19] * Added support for reassigning 'this' inside class constructors.
lindquist
parents:
6
diff
changeset
|
155 |
40 | 156 // builder helper |
157 IRBuilderHelper ir; | |
98
6789050b5ad1
[svn r102] Further delayed emission of function bodies to avoid problems with circular-forward-references.
lindquist
parents:
94
diff
changeset
|
158 |
946
1714836f2c0b
Mostly rewrite debug info generation in terms of llvm/Analysis/DebugInfo.h.
Christian Kamm <kamm incasoftware de>
parents:
945
diff
changeset
|
159 // debug info helper |
1714836f2c0b
Mostly rewrite debug info generation in terms of llvm/Analysis/DebugInfo.h.
Christian Kamm <kamm incasoftware de>
parents:
945
diff
changeset
|
160 llvm::DIFactory difactory; |
1714836f2c0b
Mostly rewrite debug info generation in terms of llvm/Analysis/DebugInfo.h.
Christian Kamm <kamm incasoftware de>
parents:
945
diff
changeset
|
161 |
116
fd7ad91fd713
[svn r120] ModuleInfo implementation is now almost complete.
lindquist
parents:
113
diff
changeset
|
162 // static ctors/dtors/unittests |
fd7ad91fd713
[svn r120] ModuleInfo implementation is now almost complete.
lindquist
parents:
113
diff
changeset
|
163 typedef std::vector<FuncDeclaration*> FuncDeclVector; |
fd7ad91fd713
[svn r120] ModuleInfo implementation is now almost complete.
lindquist
parents:
113
diff
changeset
|
164 FuncDeclVector ctors; |
fd7ad91fd713
[svn r120] ModuleInfo implementation is now almost complete.
lindquist
parents:
113
diff
changeset
|
165 FuncDeclVector dtors; |
fd7ad91fd713
[svn r120] ModuleInfo implementation is now almost complete.
lindquist
parents:
113
diff
changeset
|
166 FuncDeclVector unitTests; |
1478
4dca8ed9d8b7
Fix #318 by making a list of all seen template instances in a module for
Christian Kamm <kamm incasoftware de>
parents:
1412
diff
changeset
|
167 |
4dca8ed9d8b7
Fix #318 by making a list of all seen template instances in a module for
Christian Kamm <kamm incasoftware de>
parents:
1412
diff
changeset
|
168 // all template instances that had members emitted |
4dca8ed9d8b7
Fix #318 by making a list of all seen template instances in a module for
Christian Kamm <kamm incasoftware de>
parents:
1412
diff
changeset
|
169 // currently only filled for singleobj |
4dca8ed9d8b7
Fix #318 by making a list of all seen template instances in a module for
Christian Kamm <kamm incasoftware de>
parents:
1412
diff
changeset
|
170 // used to make sure the complete template instance gets emitted in the |
4dca8ed9d8b7
Fix #318 by making a list of all seen template instances in a module for
Christian Kamm <kamm incasoftware de>
parents:
1412
diff
changeset
|
171 // first file that touches a member, see #318 |
4dca8ed9d8b7
Fix #318 by making a list of all seen template instances in a module for
Christian Kamm <kamm incasoftware de>
parents:
1412
diff
changeset
|
172 typedef std::set<TemplateInstance*> TemplateInstanceSet; |
4dca8ed9d8b7
Fix #318 by making a list of all seen template instances in a module for
Christian Kamm <kamm incasoftware de>
parents:
1412
diff
changeset
|
173 TemplateInstanceSet seenTemplateInstances; |
232
092468448d25
[svn r248] Fixed: labels in inline asm block now work for the normal case.
lindquist
parents:
213
diff
changeset
|
174 |
092468448d25
[svn r248] Fixed: labels in inline asm block now work for the normal case.
lindquist
parents:
213
diff
changeset
|
175 // for inline asm |
233
76ee1bbe487e
[svn r249] Changed inline asm clobbers to a set instead of a list so we don't get duplicate clobbers.
lindquist
parents:
232
diff
changeset
|
176 IRAsmBlock* asmBlock; |
920
545f54041d91
Implemented proper support for naked asm using llvm module level asm. Still not 100% complete, but already 1000 times better that what we had before. Don's BignumX86 implementation from Tango (when turned into a standalone unittest) seems to fully work with no changes, and great performance :)
Tomas Lindquist Olsen <tomas.l.olsen@gmail.com>
parents:
797
diff
changeset
|
177 std::ostringstream nakedAsm; |
545f54041d91
Implemented proper support for naked asm using llvm module level asm. Still not 100% complete, but already 1000 times better that what we had before. Don's BignumX86 implementation from Tango (when turned into a standalone unittest) seems to fully work with no changes, and great performance :)
Tomas Lindquist Olsen <tomas.l.olsen@gmail.com>
parents:
797
diff
changeset
|
178 |
545f54041d91
Implemented proper support for naked asm using llvm module level asm. Still not 100% complete, but already 1000 times better that what we had before. Don's BignumX86 implementation from Tango (when turned into a standalone unittest) seems to fully work with no changes, and great performance :)
Tomas Lindquist Olsen <tomas.l.olsen@gmail.com>
parents:
797
diff
changeset
|
179 // 'used' array solely for keeping a reference to globals |
545f54041d91
Implemented proper support for naked asm using llvm module level asm. Still not 100% complete, but already 1000 times better that what we had before. Don's BignumX86 implementation from Tango (when turned into a standalone unittest) seems to fully work with no changes, and great performance :)
Tomas Lindquist Olsen <tomas.l.olsen@gmail.com>
parents:
797
diff
changeset
|
180 std::vector<LLConstant*> usedArray; |
250
fc9c1a0eabbd
[svn r267] Fixed debug info for global variables.
lindquist
parents:
233
diff
changeset
|
181 |
252 | 182 // dwarf dbg stuff |
183 LLGlobalVariable* dwarfCUs; | |
184 LLGlobalVariable* dwarfSPs; | |
185 LLGlobalVariable* dwarfGVs; | |
1 | 186 }; |
187 | |
315
a9697749e898
[svn r336] Made sure calls within a landing pad area are invokes.
ChristianK
parents:
314
diff
changeset
|
188 template <typename InputIterator> |
1013
8c73ff5f69e0
Use llvm::CallSite instead of custom CallOrInvoke class.
Frits van Bommel <fvbommel wxs.nl>
parents:
988
diff
changeset
|
189 llvm::CallSite IRState::CreateCallOrInvoke(LLValue* Callee, InputIterator ArgBegin, InputIterator ArgEnd, const char* Name) |
315
a9697749e898
[svn r336] Made sure calls within a landing pad area are invokes.
ChristianK
parents:
314
diff
changeset
|
190 { |
1508
e1e93343fc11
Move function codegen data from IrFunction to new FuncGen.
Christian Kamm <kamm incasoftware de>
parents:
1478
diff
changeset
|
191 llvm::BasicBlock* pad = func()->gen->landingPad; |
1412
3f5ea912149d
Fix #308 by giving finally code emitted by EnclosingTryFinally a different landing pad.
Christian Kamm <kamm incasoftware de>
parents:
1300
diff
changeset
|
192 if(pad) |
315
a9697749e898
[svn r336] Made sure calls within a landing pad area are invokes.
ChristianK
parents:
314
diff
changeset
|
193 { |
1300
329e45865d84
Add 'nounwind' attribute to the relevant runtime functions, and use it when
Frits van Bommel <fvbommel wxs.nl>
parents:
1277
diff
changeset
|
194 // intrinsics don't support invoking and 'nounwind' functions don't need it. |
447
f7259fa1349c
Fixed problem with invoking intrinsics, which llvm doesn't allow.
Tomas Lindquist Olsen <tomas.l.olsen@gmail.com>
parents:
334
diff
changeset
|
195 LLFunction* funcval = llvm::dyn_cast<LLFunction>(Callee); |
1300
329e45865d84
Add 'nounwind' attribute to the relevant runtime functions, and use it when
Frits van Bommel <fvbommel wxs.nl>
parents:
1277
diff
changeset
|
196 if (funcval && (funcval->isIntrinsic() || funcval->doesNotThrow())) |
447
f7259fa1349c
Fixed problem with invoking intrinsics, which llvm doesn't allow.
Tomas Lindquist Olsen <tomas.l.olsen@gmail.com>
parents:
334
diff
changeset
|
197 { |
1277
6bd5ce91b136
Add some attributes to runtime calls, to provide the standard LLVM optimization
Frits van Bommel <fvbommel wxs.nl>
parents:
1148
diff
changeset
|
198 llvm::CallInst* call = ir->CreateCall(Callee, ArgBegin, ArgEnd, Name); |
1300
329e45865d84
Add 'nounwind' attribute to the relevant runtime functions, and use it when
Frits van Bommel <fvbommel wxs.nl>
parents:
1277
diff
changeset
|
199 call->setAttributes(funcval->getAttributes()); |
1277
6bd5ce91b136
Add some attributes to runtime calls, to provide the standard LLVM optimization
Frits van Bommel <fvbommel wxs.nl>
parents:
1148
diff
changeset
|
200 return call; |
447
f7259fa1349c
Fixed problem with invoking intrinsics, which llvm doesn't allow.
Tomas Lindquist Olsen <tomas.l.olsen@gmail.com>
parents:
334
diff
changeset
|
201 } |
f7259fa1349c
Fixed problem with invoking intrinsics, which llvm doesn't allow.
Tomas Lindquist Olsen <tomas.l.olsen@gmail.com>
parents:
334
diff
changeset
|
202 |
315
a9697749e898
[svn r336] Made sure calls within a landing pad area are invokes.
ChristianK
parents:
314
diff
changeset
|
203 llvm::BasicBlock* postinvoke = llvm::BasicBlock::Create("postinvoke", topfunc(), scopeend()); |
319
e9c93739bc4c
[svn r340] Rework exception handling to work with nested tryfinally and trycatch.
ChristianK
parents:
315
diff
changeset
|
204 llvm::InvokeInst* invoke = ir->CreateInvoke(Callee, postinvoke, pad, ArgBegin, ArgEnd, Name); |
1277
6bd5ce91b136
Add some attributes to runtime calls, to provide the standard LLVM optimization
Frits van Bommel <fvbommel wxs.nl>
parents:
1148
diff
changeset
|
205 if (LLFunction* fn = llvm::dyn_cast<LLFunction>(Callee)) |
6bd5ce91b136
Add some attributes to runtime calls, to provide the standard LLVM optimization
Frits van Bommel <fvbommel wxs.nl>
parents:
1148
diff
changeset
|
206 invoke->setAttributes(fn->getAttributes()); |
315
a9697749e898
[svn r336] Made sure calls within a landing pad area are invokes.
ChristianK
parents:
314
diff
changeset
|
207 scope() = IRScope(postinvoke, scopeend()); |
1013
8c73ff5f69e0
Use llvm::CallSite instead of custom CallOrInvoke class.
Frits van Bommel <fvbommel wxs.nl>
parents:
988
diff
changeset
|
208 return invoke; |
315
a9697749e898
[svn r336] Made sure calls within a landing pad area are invokes.
ChristianK
parents:
314
diff
changeset
|
209 } |
319
e9c93739bc4c
[svn r340] Rework exception handling to work with nested tryfinally and trycatch.
ChristianK
parents:
315
diff
changeset
|
210 else |
1277
6bd5ce91b136
Add some attributes to runtime calls, to provide the standard LLVM optimization
Frits van Bommel <fvbommel wxs.nl>
parents:
1148
diff
changeset
|
211 { |
6bd5ce91b136
Add some attributes to runtime calls, to provide the standard LLVM optimization
Frits van Bommel <fvbommel wxs.nl>
parents:
1148
diff
changeset
|
212 llvm::CallInst* call = ir->CreateCall(Callee, ArgBegin, ArgEnd, Name); |
6bd5ce91b136
Add some attributes to runtime calls, to provide the standard LLVM optimization
Frits van Bommel <fvbommel wxs.nl>
parents:
1148
diff
changeset
|
213 if (LLFunction* fn = llvm::dyn_cast<LLFunction>(Callee)) |
6bd5ce91b136
Add some attributes to runtime calls, to provide the standard LLVM optimization
Frits van Bommel <fvbommel wxs.nl>
parents:
1148
diff
changeset
|
214 call->setAttributes(fn->getAttributes()); |
6bd5ce91b136
Add some attributes to runtime calls, to provide the standard LLVM optimization
Frits van Bommel <fvbommel wxs.nl>
parents:
1148
diff
changeset
|
215 return call; |
6bd5ce91b136
Add some attributes to runtime calls, to provide the standard LLVM optimization
Frits van Bommel <fvbommel wxs.nl>
parents:
1148
diff
changeset
|
216 } |
315
a9697749e898
[svn r336] Made sure calls within a landing pad area are invokes.
ChristianK
parents:
314
diff
changeset
|
217 } |
a9697749e898
[svn r336] Made sure calls within a landing pad area are invokes.
ChristianK
parents:
314
diff
changeset
|
218 |
664
eef8ac26c66c
Some missed LLVMDC -> LDC.
Christian Kamm <kamm incasoftware de>
parents:
632
diff
changeset
|
219 #endif // LDC_GEN_IRSTATE_H |