Mercurial > projects > ldc
comparison gen/abi.h @ 1024:9167d492cbc2
Abstracted more (most) ABI details out of the normal codegen.
author | Tomas Lindquist Olsen <tomas.l.olsen@gmail.com> |
---|---|
date | Tue, 03 Mar 2009 02:51:21 +0100 |
parents | e8c6dbcd33d1 |
children | 45af482e3832 |
comparison
equal
deleted
inserted
replaced
1023:ca191c141cec | 1024:9167d492cbc2 |
---|---|
2 #define __LDC_GEN_ABI_H__ | 2 #define __LDC_GEN_ABI_H__ |
3 | 3 |
4 #include <vector> | 4 #include <vector> |
5 | 5 |
6 struct Type; | 6 struct Type; |
7 struct IrFuncTyArg; | |
7 namespace llvm | 8 namespace llvm |
8 { | 9 { |
9 class Type; | 10 class Type; |
10 class Value; | 11 class Value; |
11 } | 12 } |
12 | 13 |
13 // return rewrite rule | 14 // return rewrite rule |
14 struct ABIRetRewrite | 15 struct ABIRewrite |
15 { | 16 { |
16 // get original value from rewritten one | 17 // get original value from rewritten one |
17 virtual LLValue* get(LLValue* v) = 0; | 18 virtual LLValue* get(Type* dty, LLValue* v) = 0; |
18 | 19 |
19 // rewrite original value | 20 // rewrite original value |
20 virtual LLValue* put(LLValue* v) = 0; | 21 virtual LLValue* put(Type* dty, LLValue* v) = 0; |
21 | 22 |
22 // returns target type of this rewrite | 23 // returns target type of this rewrite |
23 virtual const LLType* type(const LLType* t) = 0; | 24 virtual const LLType* type(Type* dty, const LLType* t) = 0; |
24 | |
25 // test if rewrite applies | |
26 virtual bool test(TypeFunction* tf) = 0; | |
27 }; | 25 }; |
28 | |
29 | 26 |
30 // interface called by codegen | 27 // interface called by codegen |
31 struct TargetABI | 28 struct TargetABI |
32 { | 29 { |
33 static TargetABI* getTarget(); | 30 static TargetABI* getTarget(); |
34 | 31 |
35 TargetABI(); | 32 virtual bool returnInArg(TypeFunction* tf) = 0; |
33 virtual bool passByVal(Type* t) = 0; | |
36 | 34 |
37 const llvm::Type* getRetType(TypeFunction* tf, const llvm::Type* t); | 35 virtual void rewriteFunctionType(TypeFunction* t) = 0; |
38 llvm::Value* getRet(TypeFunction* tf, llvm::Value* v); | |
39 llvm::Value* putRet(TypeFunction* tf, llvm::Value* v); | |
40 | |
41 virtual bool returnInArg(TypeFunction* t) = 0; | |
42 | |
43 protected: | |
44 std::vector<ABIRetRewrite*> retOps; | |
45 ABIRetRewrite* findRetRewrite(TypeFunction* tf); | |
46 }; | 36 }; |
47 | 37 |
48 #endif | 38 #endif |