mirror of
https://github.com/ldc-developers/ldc.git
synced 2025-05-07 03:16:05 +03:00
Get rid of more superfluous casts with DMD arrays.
There are still a few more left.
This commit is contained in:
parent
b8aed4538a
commit
e4aa92deb3
6 changed files with 41 additions and 49 deletions
|
@ -509,7 +509,7 @@ void AsmBlockStatement_toIR(AsmBlockStatement *stmt, IRState* p)
|
|||
// do asm statements
|
||||
for (unsigned i=0; i < stmt->statements->dim; i++)
|
||||
{
|
||||
Statement* s = static_cast<Statement*>(stmt->statements->data[i]);
|
||||
Statement* s = (*stmt->statements)[i];
|
||||
if (s) {
|
||||
Statement_toIR(s, p);
|
||||
}
|
||||
|
@ -780,7 +780,7 @@ Statement *AsmBlockStatement::syntaxCopy()
|
|||
a->setDim(statements->dim);
|
||||
for (size_t i = 0; i < statements->dim; i++)
|
||||
{
|
||||
Statement *s = static_cast<Statement *>(statements->data[i]);
|
||||
Statement *s = (*statements)[i];
|
||||
if (s)
|
||||
s = s->syntaxCopy();
|
||||
a->data[i] = s;
|
||||
|
@ -811,7 +811,7 @@ AsmBlockStatement* CompoundStatement::endsWithAsm()
|
|||
if (statements && statements->dim)
|
||||
{
|
||||
unsigned last = statements->dim - 1;
|
||||
Statement* s = static_cast<Statement*>(statements->data[last]);
|
||||
Statement* s = (*statements)[last];
|
||||
if (s) return s->endsWithAsm();
|
||||
}
|
||||
return NULL;
|
||||
|
|
|
@ -562,7 +562,7 @@ static void codegenModule(Module* m)
|
|||
|
||||
// process module members
|
||||
for (unsigned k=0; k < m->members->dim; k++) {
|
||||
Dsymbol* dsym = static_cast<Dsymbol*>(m->members->data[k]);
|
||||
Dsymbol* dsym = (*m->members)[k];
|
||||
assert(dsym);
|
||||
Declaration_codegen(dsym);
|
||||
}
|
||||
|
@ -755,11 +755,7 @@ void Module::genmoduleinfo()
|
|||
//printf("members->dim = %d\n", members->dim);
|
||||
for (size_t i = 0; i < members->dim; i++)
|
||||
{
|
||||
Dsymbol *member;
|
||||
|
||||
member = static_cast<Dsymbol *>(members->data[i]);
|
||||
//printf("\tmember '%s'\n", member->toChars());
|
||||
member->addLocalClass(&aclasses);
|
||||
(*members)[i]->addLocalClass(&aclasses);
|
||||
}
|
||||
// fill inits
|
||||
std::vector<LLConstant*> classInits;
|
||||
|
|
|
@ -433,7 +433,7 @@ DValue * DtoInlineAsmExpr(Loc& loc, FuncDeclaration * fd, Expressions * argument
|
|||
assert(arguments->dim >= 2 && "invalid __asm call");
|
||||
|
||||
// get code param
|
||||
Expression* e = static_cast<Expression*>(arguments->data[0]);
|
||||
Expression* e = (*arguments)[0];
|
||||
IF_LOG Logger::println("code exp: %s", e->toChars());
|
||||
StringExp* se = static_cast<StringExp*>(e);
|
||||
if (e->op != TOKstring || se->sz != 1)
|
||||
|
@ -444,7 +444,7 @@ DValue * DtoInlineAsmExpr(Loc& loc, FuncDeclaration * fd, Expressions * argument
|
|||
std::string code(static_cast<char*>(se->string), se->len);
|
||||
|
||||
// get constraints param
|
||||
e = static_cast<Expression*>(arguments->data[1]);
|
||||
e = (*arguments)[1];
|
||||
IF_LOG Logger::println("constraint exp: %s", e->toChars());
|
||||
se = static_cast<StringExp*>(e);
|
||||
if (e->op != TOKstring || se->sz != 1)
|
||||
|
@ -464,8 +464,7 @@ DValue * DtoInlineAsmExpr(Loc& loc, FuncDeclaration * fd, Expressions * argument
|
|||
|
||||
for (size_t i = 2; i < n; i++)
|
||||
{
|
||||
e = static_cast<Expression*>(arguments->data[i]);
|
||||
args.push_back(toElem(e)->getRVal());
|
||||
args.push_back(toElem((*arguments)[i])->getRVal());
|
||||
argtypes.push_back(args.back()->getType());
|
||||
}
|
||||
|
||||
|
|
|
@ -227,7 +227,7 @@ void DtoBuildDVarArgList(std::vector<LLValue*>& args,
|
|||
// build struct with argument types (non variadic args)
|
||||
for (size_t i=begin; i<n_arguments; i++)
|
||||
{
|
||||
Expression* argexp = static_cast<Expression*>(arguments->data[i]);
|
||||
Expression* argexp = (*arguments)[i];
|
||||
assert(argexp->type->ty != Ttuple);
|
||||
vtypes.push_back(DtoType(argexp->type));
|
||||
size_t sz = getTypePaddedSize(vtypes.back());
|
||||
|
@ -263,7 +263,7 @@ void DtoBuildDVarArgList(std::vector<LLValue*>& args,
|
|||
// store arguments in the struct
|
||||
for (size_t i=begin,k=0; i<n_arguments; i++,k++)
|
||||
{
|
||||
Expression* argexp = static_cast<Expression*>(arguments->data[i]);
|
||||
Expression* argexp = (*arguments)[i];
|
||||
LLValue* argdst = DtoGEPi(mem,0,k);
|
||||
argdst = DtoBitCast(argdst, getPtrToType(i1ToI8(DtoType(argexp->type))));
|
||||
DtoVariadicArgument(argexp, argdst);
|
||||
|
@ -281,8 +281,7 @@ void DtoBuildDVarArgList(std::vector<LLValue*>& args,
|
|||
vtypeinfos.reserve(n_arguments);
|
||||
for (size_t i=begin; i<n_arguments; i++)
|
||||
{
|
||||
Expression* argexp = static_cast<Expression*>(arguments->data[i]);
|
||||
vtypeinfos.push_back(DtoTypeInfoOf(argexp->type));
|
||||
vtypeinfos.push_back(DtoTypeInfoOf((*arguments)[i]->type));
|
||||
}
|
||||
|
||||
// apply initializer
|
||||
|
@ -315,7 +314,7 @@ void DtoBuildDVarArgList(std::vector<LLValue*>& args,
|
|||
for (int i=0; i<begin; i++)
|
||||
{
|
||||
Parameter* fnarg = Parameter::getNth(tf->parameters, i);
|
||||
DValue* argval = DtoArgument(fnarg, static_cast<Expression*>(arguments->data[i]));
|
||||
DValue* argval = DtoArgument(fnarg, (*arguments)[i]);
|
||||
args.push_back(fixArgument(argval, irFty, callableTy->getParamType(argidx++), i));
|
||||
|
||||
if (HAS_ATTRIBUTES(irFty.args[i]->attrs))
|
||||
|
@ -497,8 +496,7 @@ DValue* DtoCallFunction(Loc& loc, Type* resulttype, DValue* fnval, Expressions*
|
|||
{
|
||||
for (size_t i=0; i<n_arguments; i++)
|
||||
{
|
||||
Expression* exp = static_cast<Expression*>(arguments->data[i]);
|
||||
DValue* expelem = toElem(exp);
|
||||
DValue* expelem = toElem((*arguments)[i]);
|
||||
// cast to va_list*
|
||||
LLValue* val = DtoBitCast(expelem->getLVal(), getVoidPtrType());
|
||||
++argiter;
|
||||
|
@ -539,14 +537,14 @@ DValue* DtoCallFunction(Loc& loc, Type* resulttype, DValue* fnval, Expressions*
|
|||
for (int i=n-1; i>=0; --i) {
|
||||
Parameter* fnarg = Parameter::getNth(tf->parameters, i);
|
||||
assert(fnarg);
|
||||
DValue* argval = DtoArgument(fnarg, static_cast<Expression*>(arguments->data[i]));
|
||||
DValue* argval = DtoArgument(fnarg, (*arguments)[i]);
|
||||
argvals.insert(argvals.begin(), argval);
|
||||
}
|
||||
} else {
|
||||
for (size_t i=0; i<n; ++i) {
|
||||
Parameter* fnarg = Parameter::getNth(tf->parameters, i);
|
||||
assert(fnarg);
|
||||
DValue* argval = DtoArgument(fnarg, static_cast<Expression*>(arguments->data[i]));
|
||||
DValue* argval = DtoArgument(fnarg, (*arguments)[i]);
|
||||
argvals.push_back(argval);
|
||||
}
|
||||
}
|
||||
|
@ -599,7 +597,7 @@ DValue* DtoCallFunction(Loc& loc, Type* resulttype, DValue* fnval, Expressions*
|
|||
for (size_t i=n; i<n_arguments; i++)
|
||||
{
|
||||
Parameter* fnarg = Parameter::getNth(tf->parameters, i);
|
||||
DValue* argval = DtoArgument(fnarg, static_cast<Expression*>(arguments->data[i]));
|
||||
DValue* argval = DtoArgument(fnarg, (*arguments)[i]);
|
||||
LLValue* arg = argval->getRVal();
|
||||
|
||||
// FIXME: do we need any param attrs here ?
|
||||
|
|
49
gen/toir.cpp
49
gen/toir.cpp
|
@ -832,7 +832,7 @@ public:
|
|||
{
|
||||
if (fndecl->linkage == LINKc && strcmp(fndecl->ident->string, "printf") == 0)
|
||||
{
|
||||
warnInvalidPrintfCall(e->loc, static_cast<Expression*>(e->arguments->data[0]), e->arguments->dim);
|
||||
warnInvalidPrintfCall(e->loc, (*e->arguments)[0], e->arguments->dim);
|
||||
}
|
||||
}
|
||||
|
||||
|
@ -889,7 +889,7 @@ public:
|
|||
e->error("va_arg instruction expects 1 arguments");
|
||||
fatal();
|
||||
}
|
||||
result = DtoVaArg(e->loc, e->type, static_cast<Expression*>(e->arguments->data[0]));
|
||||
result = DtoVaArg(e->loc, e->type, (*e->arguments)[0]);
|
||||
}
|
||||
// C alloca
|
||||
else if (fndecl->llvmInternal == LLVMalloca) {
|
||||
|
@ -897,7 +897,7 @@ public:
|
|||
e->error("alloca expects 1 arguments");
|
||||
fatal();
|
||||
}
|
||||
Expression* exp = static_cast<Expression*>(e->arguments->data[0]);
|
||||
Expression* exp = (*e->arguments)[0];
|
||||
DValue* expv = toElem(exp);
|
||||
if (expv->getType()->toBasetype()->ty != Tint32)
|
||||
expv = DtoCast(e->loc, expv, Type::tint32);
|
||||
|
@ -909,7 +909,7 @@ public:
|
|||
e->error("fence instruction expects 1 arguments");
|
||||
fatal();
|
||||
}
|
||||
gIR->ir->CreateFence(llvm::AtomicOrdering(static_cast<Expression*>(e->arguments->data[0])->toInteger()));
|
||||
gIR->ir->CreateFence(llvm::AtomicOrdering((*e->arguments)[0]->toInteger()));
|
||||
return;
|
||||
}
|
||||
// atomic store instruction
|
||||
|
@ -918,9 +918,9 @@ public:
|
|||
e->error("atomic store instruction expects 3 arguments");
|
||||
fatal();
|
||||
}
|
||||
Expression* exp1 = static_cast<Expression*>(e->arguments->data[0]);
|
||||
Expression* exp2 = static_cast<Expression*>(e->arguments->data[1]);
|
||||
int atomicOrdering = static_cast<Expression*>(e->arguments->data[2])->toInteger();
|
||||
Expression* exp1 = (*e->arguments)[0];
|
||||
Expression* exp2 = (*e->arguments)[1];
|
||||
int atomicOrdering = (*e->arguments)[2]->toInteger();
|
||||
LLValue* val = toElem(exp1)->getRVal();
|
||||
LLValue* ptr = toElem(exp2)->getRVal();
|
||||
|
||||
|
@ -941,8 +941,8 @@ public:
|
|||
fatal();
|
||||
}
|
||||
|
||||
Expression* exp = static_cast<Expression*>(e->arguments->data[0]);
|
||||
int atomicOrdering = static_cast<Expression*>(e->arguments->data[1])->toInteger();
|
||||
Expression* exp = (*e->arguments)[0];
|
||||
int atomicOrdering = (*e->arguments)[1]->toInteger();
|
||||
|
||||
LLValue* ptr = toElem(exp)->getRVal();
|
||||
Type* retType = exp->type->nextOf();
|
||||
|
@ -963,10 +963,10 @@ public:
|
|||
e->error("cmpxchg instruction expects 4 arguments");
|
||||
fatal();
|
||||
}
|
||||
Expression* exp1 = static_cast<Expression*>(e->arguments->data[0]);
|
||||
Expression* exp2 = static_cast<Expression*>(e->arguments->data[1]);
|
||||
Expression* exp3 = static_cast<Expression*>(e->arguments->data[2]);
|
||||
int atomicOrdering = static_cast<Expression*>(e->arguments->data[3])->toInteger();
|
||||
Expression* exp1 = (*e->arguments)[0];
|
||||
Expression* exp2 = (*e->arguments)[1];
|
||||
Expression* exp3 = (*e->arguments)[2];
|
||||
int atomicOrdering = (*e->arguments)[3]->toInteger();
|
||||
LLValue* ptr = toElem(exp1)->getRVal();
|
||||
LLValue* cmp = toElem(exp2)->getRVal();
|
||||
LLValue* val = toElem(exp3)->getRVal();
|
||||
|
@ -1011,9 +1011,9 @@ public:
|
|||
break;
|
||||
}
|
||||
|
||||
Expression* exp1 = static_cast<Expression*>(e->arguments->data[0]);
|
||||
Expression* exp2 = static_cast<Expression*>(e->arguments->data[1]);
|
||||
int atomicOrdering = static_cast<Expression*>(e->arguments->data[2])->toInteger();
|
||||
Expression* exp1 = (*e->arguments)[0];
|
||||
Expression* exp2 = (*e->arguments)[1];
|
||||
int atomicOrdering = (*e->arguments)[2]->toInteger();
|
||||
LLValue* ptr = toElem(exp1)->getRVal();
|
||||
LLValue* val = toElem(exp2)->getRVal();
|
||||
LLValue* ret = gIR->ir->CreateAtomicRMW(llvm::AtomicRMWInst::BinOp(op), ptr, val,
|
||||
|
@ -1031,8 +1031,8 @@ public:
|
|||
fatal();
|
||||
}
|
||||
|
||||
Expression* exp1 = static_cast<Expression*>(e->arguments->data[0]);
|
||||
Expression* exp2 = static_cast<Expression*>(e->arguments->data[1]);
|
||||
Expression* exp1 = (*e->arguments)[0];
|
||||
Expression* exp2 = (*e->arguments)[1];
|
||||
LLValue* ptr = toElem(exp1)->getRVal();
|
||||
LLValue* bitnum = toElem(exp2)->getRVal();
|
||||
|
||||
|
@ -1839,7 +1839,7 @@ public:
|
|||
assert(e->arguments->dim >= 1);
|
||||
if (e->arguments->dim == 1)
|
||||
{
|
||||
DValue* sz = toElem(static_cast<Expression*>(e->arguments->data[0]));
|
||||
DValue* sz = toElem((*e->arguments)[0]);
|
||||
// allocate & init
|
||||
result = DtoNewDynArray(e->loc, e->newtype, sz, true);
|
||||
}
|
||||
|
@ -1849,7 +1849,7 @@ public:
|
|||
std::vector<DValue*> dims;
|
||||
dims.reserve(ndims);
|
||||
for (size_t i=0; i<ndims; ++i)
|
||||
dims.push_back(toElem(static_cast<Expression*>(e->arguments->data[i])));
|
||||
dims.push_back(toElem((*e->arguments)[i]));
|
||||
result = DtoNewMulDimDynArray(e->loc, e->newtype, &dims[0], ndims, true);
|
||||
}
|
||||
}
|
||||
|
@ -2873,8 +2873,8 @@ public:
|
|||
const size_t n = e->keys->dim;
|
||||
for (size_t i = 0; i<n; ++i)
|
||||
{
|
||||
Expression* ekey = static_cast<Expression*>(e->keys->data[i]);
|
||||
Expression* eval = static_cast<Expression*>(e->values->data[i]);
|
||||
Expression* ekey = (*e->keys)[i];
|
||||
Expression* eval = (*e->values)[i];
|
||||
|
||||
IF_LOG Logger::println("(%zu) aa[%s] = %s", i, ekey->toChars(), eval->toChars());
|
||||
|
||||
|
@ -2960,13 +2960,12 @@ public:
|
|||
types.reserve(e->exps->dim);
|
||||
for (size_t i = 0; i < e->exps->dim; i++)
|
||||
{
|
||||
Expression *el = static_cast<Expression *>(e->exps->data[i]);
|
||||
types.push_back(i1ToI8(voidToI8(DtoType(el->type))));
|
||||
types.push_back(i1ToI8(voidToI8(DtoType((*e->exps)[i]->type))));
|
||||
}
|
||||
LLValue *val = DtoRawAlloca(LLStructType::get(gIR->context(), types),0, "tuple");
|
||||
for (size_t i = 0; i < e->exps->dim; i++)
|
||||
{
|
||||
Expression *el = static_cast<Expression *>(e->exps->data[i]);
|
||||
Expression *el = (*e->exps)[i];
|
||||
DValue* ep = toElem(el);
|
||||
LLValue *gep = DtoGEPi(val,0,i);
|
||||
if (el->type->ty == Tstruct)
|
||||
|
|
|
@ -253,7 +253,7 @@ LLType* DtoStructTypeFromArguments(Arguments* arguments)
|
|||
std::vector<LLType*> types;
|
||||
for (size_t i = 0; i < arguments->dim; i++)
|
||||
{
|
||||
Argument *arg = static_cast<Argument *>(arguments->data[i]);
|
||||
Argument *arg = (*arguments)[i];
|
||||
assert(arg && arg->type);
|
||||
|
||||
types.push_back(DtoType(arg->type));
|
||||
|
|
Loading…
Add table
Add a link
Reference in a new issue