mirror of
https://github.com/ldc-developers/ldc.git
synced 2025-05-13 14:36:18 +03:00
Refactoring: Introduce ArgTypesRewrite
This commit is contained in:
parent
d603010159
commit
e9164f1f1a
4 changed files with 73 additions and 79 deletions
35
gen/abi.cpp
35
gen/abi.cpp
|
@ -12,6 +12,7 @@
|
|||
#include "dmd/expression.h"
|
||||
#include "dmd/id.h"
|
||||
#include "dmd/identifier.h"
|
||||
#include "dmd/target.h"
|
||||
#include "gen/abi-aarch64.h"
|
||||
#include "gen/abi-arm.h"
|
||||
#include "gen/abi-generic.h"
|
||||
|
@ -67,6 +68,40 @@ bool TargetABI::isHFVA(Type *t, int maxNumElements, LLType **hfvaType) {
|
|||
return false;
|
||||
}
|
||||
|
||||
//////////////////////////////////////////////////////////////////////////////
|
||||
|
||||
TypeTuple *TargetABI::getArgTypes(Type *t) {
|
||||
// try to reuse cached argTypes of StructDeclarations
|
||||
if (auto ts = t->toBasetype()->isTypeStruct()) {
|
||||
auto sd = ts->sym;
|
||||
if (sd->sizeok == SIZEOKdone)
|
||||
return sd->argTypes;
|
||||
}
|
||||
|
||||
return target.toArgTypes(t);
|
||||
}
|
||||
|
||||
LLType *TargetABI::getRewrittenArgType(Type *t, TypeTuple *argTypes) {
|
||||
if (!argTypes || argTypes->arguments->empty() ||
|
||||
(argTypes->arguments->length == 1 &&
|
||||
argTypes->arguments->front()->type == t)) {
|
||||
return nullptr; // don't rewrite
|
||||
}
|
||||
|
||||
auto &args = *argTypes->arguments;
|
||||
assert(args.length <= 2);
|
||||
return args.length == 1
|
||||
? DtoType(args[0]->type)
|
||||
: LLStructType::get(gIR->context(), {DtoType(args[0]->type),
|
||||
DtoType(args[1]->type)});
|
||||
}
|
||||
|
||||
LLType *TargetABI::getRewrittenArgType(Type *t) {
|
||||
return getRewrittenArgType(t, getArgTypes(t));
|
||||
}
|
||||
|
||||
//////////////////////////////////////////////////////////////////////////////
|
||||
|
||||
bool TargetABI::isAggregate(Type *t) {
|
||||
TY ty = t->toBasetype()->ty;
|
||||
// FIXME: dynamic arrays can currently not be rewritten as they are used
|
||||
|
|
Loading…
Add table
Add a link
Reference in a new issue