mirror of
https://github.com/ldc-developers/ldc.git
synced 2025-05-09 20:37:25 +03:00
Get rid of D type param in DtoConstSlice()
This commit is contained in:
parent
7fa7f35b2a
commit
4c74f64a9c
7 changed files with 14 additions and 31 deletions
|
@ -453,7 +453,7 @@ LLConstant *DtoConstArrayInitializer(ArrayInitializer *arrinit,
|
||||||
return gvar;
|
return gvar;
|
||||||
}
|
}
|
||||||
|
|
||||||
return DtoConstSlice(DtoConstSize_t(arrlen), gvar, arrty);
|
return DtoConstSlice(DtoConstSize_t(arrlen), gvar);
|
||||||
}
|
}
|
||||||
|
|
||||||
////////////////////////////////////////////////////////////////////////////////
|
////////////////////////////////////////////////////////////////////////////////
|
||||||
|
@ -618,11 +618,10 @@ void initializeArrayLiteral(IRState *p, ArrayLiteralExp *ale,
|
||||||
}
|
}
|
||||||
|
|
||||||
////////////////////////////////////////////////////////////////////////////////
|
////////////////////////////////////////////////////////////////////////////////
|
||||||
LLConstant *DtoConstSlice(LLConstant *dim, LLConstant *ptr, Type *type) {
|
LLConstant *DtoConstSlice(LLConstant *dim, LLConstant *ptr) {
|
||||||
LLConstant *values[2] = {dim, ptr};
|
LLConstant *values[2] = {dim, ptr};
|
||||||
LLStructType *lltype =
|
LLStructType *lltype =
|
||||||
type ? isaStruct(DtoType(type))
|
LLConstantStruct::getTypeForElements(gIR->context(), values);
|
||||||
: LLConstantStruct::getTypeForElements(gIR->context(), values);
|
|
||||||
return LLConstantStruct::get(lltype, values);
|
return LLConstantStruct::get(lltype, values);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
|
@ -35,8 +35,7 @@ llvm::ArrayType *DtoStaticArrayType(Type *sarrayTy);
|
||||||
LLConstant *DtoConstArrayInitializer(ArrayInitializer *si, Type *targetType,
|
LLConstant *DtoConstArrayInitializer(ArrayInitializer *si, Type *targetType,
|
||||||
const bool isCfile);
|
const bool isCfile);
|
||||||
|
|
||||||
LLConstant *DtoConstSlice(LLConstant *dim, LLConstant *ptr,
|
LLConstant *DtoConstSlice(LLConstant *dim, LLConstant *ptr);
|
||||||
Type *type = nullptr);
|
|
||||||
|
|
||||||
/// Returns the element at position idx of the literal (assumed to be in range).
|
/// Returns the element at position idx of the literal (assumed to be in range).
|
||||||
Expression *indexArrayLiteral(ArrayLiteralExp *ale, unsigned idx);
|
Expression *indexArrayLiteral(ArrayLiteralExp *ale, unsigned idx);
|
||||||
|
|
|
@ -234,11 +234,8 @@ void addCoverageAnalysis(Module *m) {
|
||||||
m->d_cover_valid = new llvm::GlobalVariable(
|
m->d_cover_valid = new llvm::GlobalVariable(
|
||||||
gIR->module, type, /*isConstant=*/true, LLGlobalValue::InternalLinkage,
|
gIR->module, type, /*isConstant=*/true, LLGlobalValue::InternalLinkage,
|
||||||
zeroinitializer, "_d_cover_valid");
|
zeroinitializer, "_d_cover_valid");
|
||||||
LLConstant *idxs[] = {DtoConstUint(0), DtoConstUint(0)};
|
d_cover_valid_slice = DtoConstSlice(
|
||||||
d_cover_valid_slice =
|
DtoConstSize_t(type->getArrayNumElements()), m->d_cover_valid);
|
||||||
DtoConstSlice(DtoConstSize_t(type->getArrayNumElements()),
|
|
||||||
llvm::ConstantExpr::getGetElementPtr(
|
|
||||||
type, m->d_cover_valid, idxs, true));
|
|
||||||
|
|
||||||
// Assert that initializer array elements have enough bits
|
// Assert that initializer array elements have enough bits
|
||||||
assert(sizeof(m->d_cover_valid_init[0]) * 8 >=
|
assert(sizeof(m->d_cover_valid_init[0]) * 8 >=
|
||||||
|
@ -269,9 +266,8 @@ void addCoverageAnalysis(Module *m) {
|
||||||
LLGlobalValue::InternalLinkage,
|
LLGlobalValue::InternalLinkage,
|
||||||
init, "_d_cover_data");
|
init, "_d_cover_data");
|
||||||
|
|
||||||
d_cover_data_slice = DtoConstSlice(DtoConstSize_t(m->numlines),
|
d_cover_data_slice =
|
||||||
DtoGEP(m->d_cover_data->getValueType(),
|
DtoConstSlice(DtoConstSize_t(m->numlines), m->d_cover_data);
|
||||||
m->d_cover_data, 0, 0));
|
|
||||||
}
|
}
|
||||||
|
|
||||||
// Create "static constructor" that calls _d_cover_register2(string filename,
|
// Create "static constructor" that calls _d_cover_register2(string filename,
|
||||||
|
|
|
@ -16,6 +16,7 @@
|
||||||
#include "dmd/target.h"
|
#include "dmd/target.h"
|
||||||
#include "dmd/template.h"
|
#include "dmd/template.h"
|
||||||
#include "gen/abi/abi.h"
|
#include "gen/abi/abi.h"
|
||||||
|
#include "gen/arrays.h"
|
||||||
#include "gen/classes.h"
|
#include "gen/classes.h"
|
||||||
#include "gen/dvalue.h"
|
#include "gen/dvalue.h"
|
||||||
#include "gen/funcgenstate.h"
|
#include "gen/funcgenstate.h"
|
||||||
|
@ -237,18 +238,7 @@ static LLValue *getTypeinfoArrayArgumentForDVarArg(Expressions *argexps,
|
||||||
LLConstant *tiinits = LLConstantArray::get(typeinfoarraytype, vtypeinfos);
|
LLConstant *tiinits = LLConstantArray::get(typeinfoarraytype, vtypeinfos);
|
||||||
typeinfomem->setInitializer(tiinits);
|
typeinfomem->setInitializer(tiinits);
|
||||||
|
|
||||||
// put data in d-array
|
return DtoConstSlice(DtoConstSize_t(numVariadicArgs), typeinfomem);
|
||||||
LLConstant *pinits[] = {
|
|
||||||
DtoConstSize_t(numVariadicArgs),
|
|
||||||
llvm::ConstantExpr::getBitCast(typeinfomem, getPtrToType(typeinfotype))};
|
|
||||||
LLType *tiarrty = DtoType(arrayOf(getTypeInfoType()));
|
|
||||||
tiinits = LLConstantStruct::get(isaStruct(tiarrty),
|
|
||||||
llvm::ArrayRef<LLConstant *>(pinits));
|
|
||||||
LLValue *typeinfoarrayparam = new llvm::GlobalVariable(
|
|
||||||
gIR->module, tiarrty, true, llvm::GlobalValue::InternalLinkage, tiinits,
|
|
||||||
"._arguments.array");
|
|
||||||
|
|
||||||
return DtoLoad(tiarrty, typeinfoarrayparam);
|
|
||||||
}
|
}
|
||||||
|
|
||||||
////////////////////////////////////////////////////////////////////////////////
|
////////////////////////////////////////////////////////////////////////////////
|
||||||
|
|
|
@ -180,8 +180,7 @@ public:
|
||||||
if (t->ty == TY::Tpointer) {
|
if (t->ty == TY::Tpointer) {
|
||||||
result = arrptr;
|
result = arrptr;
|
||||||
} else if (t->ty == TY::Tarray) {
|
} else if (t->ty == TY::Tarray) {
|
||||||
LLConstant *clen = LLConstantInt::get(DtoSize_t(), e->len, false);
|
result = DtoConstSlice(DtoConstSize_t(e->len), arrptr);
|
||||||
result = DtoConstSlice(clen, arrptr, e->type);
|
|
||||||
} else {
|
} else {
|
||||||
llvm_unreachable("Unknown type for StringExp.");
|
llvm_unreachable("Unknown type for StringExp.");
|
||||||
}
|
}
|
||||||
|
|
|
@ -442,8 +442,8 @@ public:
|
||||||
LLConstant *arrptr = DtoGEP(gvar->getValueType(), gvar, 0u, 0u);
|
LLConstant *arrptr = DtoGEP(gvar->getValueType(), gvar, 0u, 0u);
|
||||||
|
|
||||||
if (dtype->ty == TY::Tarray) {
|
if (dtype->ty == TY::Tarray) {
|
||||||
LLConstant *clen = LLConstantInt::get(DtoSize_t(), stringLength, false);
|
result = new DSliceValue(
|
||||||
result = new DSliceValue(e->type, DtoConstSlice(clen, arrptr, dtype));
|
e->type, DtoConstSlice(DtoConstSize_t(stringLength), arrptr));
|
||||||
} else if (dtype->ty == TY::Tsarray) {
|
} else if (dtype->ty == TY::Tsarray) {
|
||||||
// array length matches string length with or without null terminator
|
// array length matches string length with or without null terminator
|
||||||
result = new DLValue(e->type, gvar);
|
result = new DLValue(e->type, gvar);
|
||||||
|
|
|
@ -509,7 +509,7 @@ LLConstant *DtoConstCString(const char *str) {
|
||||||
LLConstant *DtoConstString(const char *str) {
|
LLConstant *DtoConstString(const char *str) {
|
||||||
LLConstant *cString = DtoConstCString(str);
|
LLConstant *cString = DtoConstCString(str);
|
||||||
LLConstant *length = DtoConstSize_t(str ? strlen(str) : 0);
|
LLConstant *length = DtoConstSize_t(str ? strlen(str) : 0);
|
||||||
return DtoConstSlice(length, cString, arrayOf(Type::tchar));
|
return DtoConstSlice(length, cString);
|
||||||
}
|
}
|
||||||
|
|
||||||
////////////////////////////////////////////////////////////////////////////////
|
////////////////////////////////////////////////////////////////////////////////
|
||||||
|
|
Loading…
Add table
Add a link
Reference in a new issue