Mercurial > projects > ldc
comparison gen/llvmhelpers.h @ 1141:f99a3b393c03
Reorganize EnclosingHandlers to require less changes to the frontend and allow us to
implement the synchronized storage class for functions.
author | Christian Kamm <kamm incasoftware de> |
---|---|
date | Tue, 24 Mar 2009 21:18:18 +0100 |
parents | 7ce8355fbcc6 |
children | dbe4af57b240 |
comparison
equal
deleted
inserted
replaced
1137:45d73f0a9b43 | 1141:f99a3b393c03 |
---|---|
1 #ifndef LDC_GEN_LLVMHELPERS_H | 1 #ifndef LDC_GEN_LLVMHELPERS_H |
2 #define LDC_GEN_LLVMHELPERS_H | 2 #define LDC_GEN_LLVMHELPERS_H |
3 | 3 |
4 #include "gen/llvm.h" | 4 #include "gen/llvm.h" |
5 #include "statement.h" | 5 #include "statement.h" |
6 | |
7 // this is used for tracking try-finally, synchronized and volatile scopes | |
8 struct EnclosingHandler | |
9 { | |
10 virtual void emitCode(IRState* p) = 0; | |
11 }; | |
12 struct EnclosingTryFinally : EnclosingHandler | |
13 { | |
14 TryFinallyStatement* tf; | |
15 void emitCode(IRState* p); | |
16 EnclosingTryFinally(TryFinallyStatement* _tf) : tf(_tf) {} | |
17 }; | |
18 struct EnclosingVolatile : EnclosingHandler | |
19 { | |
20 VolatileStatement* v; | |
21 void emitCode(IRState* p); | |
22 EnclosingVolatile(VolatileStatement* _tf) : v(_tf) {} | |
23 }; | |
24 struct EnclosingSynchro : EnclosingHandler | |
25 { | |
26 SynchronizedStatement* s; | |
27 void emitCode(IRState* p); | |
28 EnclosingSynchro(SynchronizedStatement* _tf) : s(_tf) {} | |
29 }; | |
30 | |
6 | 31 |
7 // dynamic memory helpers | 32 // dynamic memory helpers |
8 LLValue* DtoNew(Type* newtype); | 33 LLValue* DtoNew(Type* newtype); |
9 void DtoDeleteMemory(LLValue* ptr); | 34 void DtoDeleteMemory(LLValue* ptr); |
10 void DtoDeleteClass(LLValue* inst); | 35 void DtoDeleteClass(LLValue* inst); |
14 // emit an alloca | 39 // emit an alloca |
15 llvm::AllocaInst* DtoAlloca(const LLType* lltype, const std::string& name = ""); | 40 llvm::AllocaInst* DtoAlloca(const LLType* lltype, const std::string& name = ""); |
16 llvm::AllocaInst* DtoAlloca(const LLType* lltype, LLValue* arraysize, const std::string& name = ""); | 41 llvm::AllocaInst* DtoAlloca(const LLType* lltype, LLValue* arraysize, const std::string& name = ""); |
17 | 42 |
18 // assertion generator | 43 // assertion generator |
19 void DtoAssert(Module* M, Loc* loc, DValue* msg); | 44 void DtoAssert(Module* M, Loc loc, DValue* msg); |
20 | 45 |
21 // return the LabelStatement from the current function with the given identifier or NULL if not found | 46 // return the LabelStatement from the current function with the given identifier or NULL if not found |
22 LabelStatement* DtoLabelStatement(Identifier* ident); | 47 LabelStatement* DtoLabelStatement(Identifier* ident); |
23 // emit goto | 48 // emit goto |
24 void DtoGoto(Loc* loc, Identifier* target, EnclosingHandler* enclosingtryfinally, TryFinallyStatement* sourcetf); | 49 void DtoGoto(Loc loc, Identifier* target); |
25 | 50 |
26 // generates IR for finally blocks between the 'start' and 'end' statements | 51 // Generates IR for enclosing handlers between the current state and |
27 // will begin with the finally block belonging to 'start' and does not include | 52 // the scope created by the 'target' statement. |
28 // the finally block of 'end' | 53 void DtoEnclosingHandlers(Loc loc, Statement* target); |
29 void DtoEnclosingHandlers(EnclosingHandler* start, EnclosingHandler* end); | |
30 | 54 |
31 // enters a critical section | 55 // enters a critical section |
32 void DtoEnterCritical(LLValue* g); | 56 void DtoEnterCritical(LLValue* g); |
33 // leaves a critical section | 57 // leaves a critical section |
34 void DtoLeaveCritical(LLValue* g); | 58 void DtoLeaveCritical(LLValue* g); |