Mercurial > projects > ldc
comparison gen/abi.h @ 989:420ef073448d
Forgot new files that were supposed to be in last commit.
author | Tomas Lindquist Olsen <tomas.l.olsen@gmail.com> |
---|---|
date | Thu, 26 Feb 2009 14:13:27 +0100 |
parents | |
children | e8c6dbcd33d1 |
comparison
equal
deleted
inserted
replaced
988:2667e3a145be | 989:420ef073448d |
---|---|
1 #ifndef __LDC_GEN_ABI_H__ | |
2 #define __LDC_GEN_ABI_H__ | |
3 | |
4 #include <vector> | |
5 | |
6 struct Type; | |
7 namespace llvm | |
8 { | |
9 class Type; | |
10 class Value; | |
11 } | |
12 | |
13 // return rewrite rule | |
14 struct ABIRetRewrite | |
15 { | |
16 // get original value from rewritten one | |
17 virtual LLValue* get(LLValue* v) = 0; | |
18 | |
19 // rewrite original value | |
20 virtual LLValue* put(LLValue* v) = 0; | |
21 | |
22 // returns target type of this rewrite | |
23 virtual const LLType* type(const LLType* t) = 0; | |
24 | |
25 // test if rewrite applies | |
26 virtual bool test(TypeFunction* tf) = 0; | |
27 }; | |
28 | |
29 | |
30 // interface called by codegen | |
31 struct TargetABI | |
32 { | |
33 static TargetABI* getTarget(); | |
34 | |
35 TargetABI(); | |
36 | |
37 const llvm::Type* getRetType(TypeFunction* tf, const llvm::Type* t); | |
38 llvm::Value* getRet(TypeFunction* tf, llvm::Value* v); | |
39 llvm::Value* putRet(TypeFunction* tf, llvm::Value* v); | |
40 | |
41 virtual bool returnInArg(Type* t) = 0; | |
42 virtual bool passByRef(Type* t) = 0; | |
43 | |
44 protected: | |
45 std::vector<ABIRetRewrite*> retOps; | |
46 ABIRetRewrite* findRetRewrite(TypeFunction* tf); | |
47 }; | |
48 | |
49 #endif |