Refactor code to hide direct IrFunction->func usage and add convenient functions (#1911)

This commit is contained in:
Ivan Butygin 2017-01-18 00:40:32 +03:00 committed by Johan Engelen
parent 09cef87178
commit a26bfc1223
17 changed files with 158 additions and 73 deletions

View file

@ -1383,7 +1383,7 @@ void callPostblit(Loc &loc, Expression *exp, LLValue *val) {
}
DtoResolveFunction(fd);
Expressions args;
DFuncValue dfn(fd, getIrFunc(fd)->func, val);
DFuncValue dfn(fd, DtoCallee(fd), val);
DtoCallFunction(loc, Type::basic[Tvoid], &dfn, &args);
}
}
@ -1588,9 +1588,9 @@ DValue *DtoSymbolAddress(Loc &loc, Type *type, Declaration *decl) {
// We need to codegen the function here, because literals are not added
// to the module member list.
DtoDefineFunction(flitdecl);
assert(getIrFunc(flitdecl)->func);
assert(DtoCallee(flitdecl));
return new DFuncValue(flitdecl, getIrFunc(flitdecl)->func);
return new DFuncValue(flitdecl, DtoCallee(flitdecl));
}
if (FuncDeclaration *fdecl = decl->isFuncDeclaration()) {
@ -1607,7 +1607,7 @@ DValue *DtoSymbolAddress(Loc &loc, Type *type, Declaration *decl) {
}
DtoResolveFunction(fdecl);
return new DFuncValue(fdecl, fdecl->llvmInternal != LLVMva_arg
? getIrFunc(fdecl)->func
? DtoCallee(fdecl)
: nullptr);
}
@ -1661,7 +1661,7 @@ llvm::Constant *DtoConstSymbolAddress(Loc &loc, Declaration *decl) {
// static function
if (FuncDeclaration *fd = decl->isFuncDeclaration()) {
DtoResolveFunction(fd);
return getIrFunc(fd)->func;
return DtoCallee(fd);
}
llvm_unreachable("Taking constant address not implemented.");