Mercurial > projects > ldc
comparison gen/functions.cpp @ 585:fbb1a366cfbc
Complex number should now follow the D ABI on x86. They're also treated as first class values now. Big change.
author | Tomas Lindquist Olsen <tomas.l.olsen@gmail.com> |
---|---|
date | Tue, 09 Sep 2008 16:49:47 -0700 |
parents | 406aee3416bb |
children | 26fce59fe80a |
comparison
equal
deleted
inserted
replaced
584:c7d7e2282ba3 | 585:fbb1a366cfbc |
---|---|
120 assert(argT); | 120 assert(argT); |
121 | 121 |
122 bool refOrOut = ((arg->storageClass & STCref) || (arg->storageClass & STCout)); | 122 bool refOrOut = ((arg->storageClass & STCref) || (arg->storageClass & STCout)); |
123 | 123 |
124 const LLType* at = DtoType(argT); | 124 const LLType* at = DtoType(argT); |
125 if (isaStruct(at)) { | 125 |
126 // FIXME: using the llvm type for these is a bad idea... aggregates are first class now and we're starting to use it ... | |
127 | |
128 if (argT->iscomplex()) { | |
129 goto Lbadstuff; | |
130 } | |
131 else if (isaStruct(at)) { | |
126 Logger::println("struct param"); | 132 Logger::println("struct param"); |
127 paramvec.push_back(getPtrToType(at)); | 133 paramvec.push_back(getPtrToType(at)); |
128 if (!refOrOut) | 134 if (!refOrOut) |
129 arg->llvmAttrs |= llvm::ParamAttr::ByVal; | 135 arg->llvmAttrs |= llvm::ParamAttr::ByVal; |
130 } | 136 } |
138 Logger::println("opaque param"); | 144 Logger::println("opaque param"); |
139 assert(argT->ty == Tstruct || argT->ty == Tclass); | 145 assert(argT->ty == Tstruct || argT->ty == Tclass); |
140 paramvec.push_back(getPtrToType(at)); | 146 paramvec.push_back(getPtrToType(at)); |
141 } | 147 } |
142 else { | 148 else { |
149 Lbadstuff: | |
143 if (refOrOut) { | 150 if (refOrOut) { |
144 Logger::println("by ref param"); | 151 Logger::println("by ref param"); |
145 at = getPtrToType(at); | 152 at = getPtrToType(at); |
146 } | 153 } |
147 else { | 154 else { |
864 arg = new DImValue(argexp->type, arg->getLVal()); | 871 arg = new DImValue(argexp->type, arg->getLVal()); |
865 else | 872 else |
866 arg = new DImValue(argexp->type, arg->getRVal()); | 873 arg = new DImValue(argexp->type, arg->getRVal()); |
867 } | 874 } |
868 // byval arg, but expr has no storage yet | 875 // byval arg, but expr has no storage yet |
869 else if (DtoIsPassedByRef(argexp->type) && (arg->isSlice() || arg->isComplex() || arg->isNull())) | 876 else if (DtoIsPassedByRef(argexp->type) && (arg->isSlice() || arg->isNull())) |
870 { | 877 { |
871 LLValue* alloc = DtoAlloca(DtoType(argexp->type), ".tmp_arg"); | 878 LLValue* alloc = DtoAlloca(DtoType(argexp->type), ".tmp_arg"); |
872 DVarValue* vv = new DVarValue(argexp->type, alloc, true); | 879 DVarValue* vv = new DVarValue(argexp->type, alloc); |
873 DtoAssign(argexp->loc, vv, arg); | 880 DtoAssign(argexp->loc, vv, arg); |
874 arg = vv; | 881 arg = vv; |
875 } | 882 } |
876 | 883 |
877 return arg; | 884 return arg; |
881 | 888 |
882 void DtoVariadicArgument(Expression* argexp, LLValue* dst) | 889 void DtoVariadicArgument(Expression* argexp, LLValue* dst) |
883 { | 890 { |
884 Logger::println("DtoVariadicArgument"); | 891 Logger::println("DtoVariadicArgument"); |
885 LOG_SCOPE; | 892 LOG_SCOPE; |
886 DVarValue vv(argexp->type, dst, true); | 893 DVarValue vv(argexp->type, dst); |
887 DtoAssign(argexp->loc, &vv, argexp->toElem(gIR)); | 894 DtoAssign(argexp->loc, &vv, argexp->toElem(gIR)); |
888 } | 895 } |
889 | 896 |
890 ////////////////////////////////////////////////////////////////////////////////////////// | 897 ////////////////////////////////////////////////////////////////////////////////////////// |
891 | 898 |