comparison ir/irfunction.cpp @ 1050:32ead42679d1

Fix a bug in the X86 ABI. The size of a struct is different from the size of a pointer to that struct...
author Frits van Bommel <fvbommel wxs.nl>
date Fri, 06 Mar 2009 21:15:13 +0100
parents 45af482e3832
children dc608dc33081
comparison
equal deleted inserted replaced
1049:afe271b0e271 1050:32ead42679d1
1 1
2 #include "gen/llvm.h" 2 #include "gen/llvm.h"
3 #include "gen/tollvm.h" 3 #include "gen/tollvm.h"
4 #include "gen/abi.h" 4 #include "gen/abi.h"
5 #include "gen/dvalue.h" 5 #include "gen/dvalue.h"
6 #include "gen/logger.h"
6 #include "ir/irfunction.h" 7 #include "ir/irfunction.h"
7 8
8 #include <sstream> 9 #include <sstream>
9 10
10 ////////////////////////////////////////////////////////////////////////////// 11 //////////////////////////////////////////////////////////////////////////////
25 ////////////////////////////////////////////////////////////////////////////// 26 //////////////////////////////////////////////////////////////////////////////
26 27
27 llvm::Value* IrFuncTy::putRet(Type* dty, DValue* val) 28 llvm::Value* IrFuncTy::putRet(Type* dty, DValue* val)
28 { 29 {
29 assert(!arg_sret); 30 assert(!arg_sret);
30 if (ret->rewrite) 31 if (ret->rewrite) {
32 Logger::println("Rewrite: putRet");
33 LOG_SCOPE
31 return ret->rewrite->put(dty, val); 34 return ret->rewrite->put(dty, val);
35 }
32 return val->getRVal(); 36 return val->getRVal();
33 } 37 }
34 38
35 llvm::Value* IrFuncTy::getRet(Type* dty, DValue* val) 39 llvm::Value* IrFuncTy::getRet(Type* dty, DValue* val)
36 { 40 {
37 assert(!arg_sret); 41 assert(!arg_sret);
38 if (ret->rewrite) 42 if (ret->rewrite) {
43 Logger::println("Rewrite: getRet");
44 LOG_SCOPE
39 return ret->rewrite->get(dty, val); 45 return ret->rewrite->get(dty, val);
46 }
40 return val->getRVal(); 47 return val->getRVal();
41 } 48 }
42 49
43 llvm::Value* IrFuncTy::putParam(Type* dty, int idx, DValue* val) 50 llvm::Value* IrFuncTy::putParam(Type* dty, int idx, DValue* val)
44 { 51 {
45 assert(idx >= 0 && idx < args.size() && "invalid putParam"); 52 assert(idx >= 0 && idx < args.size() && "invalid putParam");
46 if (args[idx]->rewrite) 53 if (args[idx]->rewrite) {
54 Logger::println("Rewrite: putParam");
55 LOG_SCOPE
47 return args[idx]->rewrite->put(dty, val); 56 return args[idx]->rewrite->put(dty, val);
57 }
48 return val->getRVal(); 58 return val->getRVal();
49 } 59 }
50 60
51 llvm::Value* IrFuncTy::getParam(Type* dty, int idx, DValue* val) 61 llvm::Value* IrFuncTy::getParam(Type* dty, int idx, DValue* val)
52 { 62 {
53 assert(idx >= 0 && idx < args.size() && "invalid getParam"); 63 assert(idx >= 0 && idx < args.size() && "invalid getParam");
54 if (args[idx]->rewrite) 64 if (args[idx]->rewrite) {
65 Logger::println("Rewrite: getParam (get)");
66 LOG_SCOPE
55 return args[idx]->rewrite->get(dty, val); 67 return args[idx]->rewrite->get(dty, val);
68 }
56 return val->getRVal(); 69 return val->getRVal();
57 } 70 }
58 71
59 void IrFuncTy::getParam(Type* dty, int idx, DValue* val, llvm::Value* lval) 72 void IrFuncTy::getParam(Type* dty, int idx, DValue* val, llvm::Value* lval)
60 { 73 {
61 assert(idx >= 0 && idx < args.size() && "invalid getParam"); 74 assert(idx >= 0 && idx < args.size() && "invalid getParam");
62 75
63 if (args[idx]->rewrite) 76 if (args[idx]->rewrite)
64 { 77 {
78 Logger::println("Rewrite: getParam (getL)");
79 LOG_SCOPE
65 args[idx]->rewrite->getL(dty, val, lval); 80 args[idx]->rewrite->getL(dty, val, lval);
66 return; 81 return;
67 } 82 }
68 83
69 DtoStore(val->getRVal(), lval); 84 DtoStore(val->getRVal(), lval);