initial support for exported varying
This commit is contained in:
26
module.cpp
26
module.cpp
@@ -567,9 +567,7 @@ Module::AddGlobalVariable(const std::string &name, const Type *type, Expr *initE
|
|||||||
|
|
||||||
/** Given an arbitrary type, see if it or any of the leaf types contained
|
/** Given an arbitrary type, see if it or any of the leaf types contained
|
||||||
in it has a type that's illegal to have exported to C/C++
|
in it has a type that's illegal to have exported to C/C++
|
||||||
code--specifically, that it has a varying value in memory, or a pointer
|
code.
|
||||||
to SOA data (which has a different representation than a regular
|
|
||||||
pointer.
|
|
||||||
|
|
||||||
(Note that it's fine for the original struct or a contained struct to
|
(Note that it's fine for the original struct or a contained struct to
|
||||||
be varying, so long as all of its members have bound 'uniform'
|
be varying, so long as all of its members have bound 'uniform'
|
||||||
@@ -601,15 +599,10 @@ lRecursiveCheckValidParamType(const Type *t, bool vectorOk) {
|
|||||||
|
|
||||||
const PointerType *pt = CastType<PointerType>(t);
|
const PointerType *pt = CastType<PointerType>(t);
|
||||||
if (pt != NULL) {
|
if (pt != NULL) {
|
||||||
if (pt->IsSlice() || pt->IsVaryingType())
|
|
||||||
return false;
|
|
||||||
return lRecursiveCheckValidParamType(pt->GetBaseType(), true);
|
return lRecursiveCheckValidParamType(pt->GetBaseType(), true);
|
||||||
}
|
}
|
||||||
|
|
||||||
if (t->IsVaryingType())
|
return true;
|
||||||
return false;
|
|
||||||
else
|
|
||||||
return true;
|
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
@@ -622,17 +615,14 @@ static void
|
|||||||
lCheckExportedParameterTypes(const Type *type, const std::string &name,
|
lCheckExportedParameterTypes(const Type *type, const std::string &name,
|
||||||
SourcePos pos) {
|
SourcePos pos) {
|
||||||
if (lRecursiveCheckValidParamType(type, false) == false) {
|
if (lRecursiveCheckValidParamType(type, false) == false) {
|
||||||
if (CastType<PointerType>(type))
|
if (CastType<StructType>(type->GetBaseType()))
|
||||||
Error(pos, "Varying pointer type parameter \"%s\" is illegal "
|
Error(pos, "Struct parameter \"%s\" with vector typed "
|
||||||
"in an exported function.", name.c_str());
|
|
||||||
else if (CastType<StructType>(type->GetBaseType()))
|
|
||||||
Error(pos, "Struct parameter \"%s\" with varying or vector typed "
|
|
||||||
"member(s) is illegal in an exported function.", name.c_str());
|
"member(s) is illegal in an exported function.", name.c_str());
|
||||||
else if (CastType<VectorType>(type))
|
else if (CastType<VectorType>(type))
|
||||||
Error(pos, "Vector-typed parameter \"%s\" is illegal in an exported "
|
Error(pos, "Vector-typed parameter \"%s\" is illegal in an exported "
|
||||||
"function.", name.c_str());
|
"function.", name.c_str());
|
||||||
else
|
else
|
||||||
Error(pos, "Varying parameter \"%s\" is illegal in an exported function.",
|
Error(pos, "\"%s\" is illegal in an exported function.",
|
||||||
name.c_str());
|
name.c_str());
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
@@ -830,9 +820,11 @@ Module::AddFunctionDeclaration(const std::string &name,
|
|||||||
const SourcePos &argPos = functionType->GetParameterSourcePos(i);
|
const SourcePos &argPos = functionType->GetParameterSourcePos(i);
|
||||||
|
|
||||||
// If the function is exported, make sure that the parameter
|
// If the function is exported, make sure that the parameter
|
||||||
// doesn't have any varying stuff going on in it.
|
// doesn't have any funky stuff going on in it.
|
||||||
if (functionType->isExported)
|
// JCB nomosoa - Varying is now a-ok.
|
||||||
|
if (functionType->isExported) {
|
||||||
lCheckExportedParameterTypes(argType, argName, argPos);
|
lCheckExportedParameterTypes(argType, argName, argPos);
|
||||||
|
}
|
||||||
|
|
||||||
// ISPC assumes that no pointers alias. (It should be possible to
|
// ISPC assumes that no pointers alias. (It should be possible to
|
||||||
// specify when this is not the case, but this should be the
|
// specify when this is not the case, but this should be the
|
||||||
|
|||||||
12
type.cpp
12
type.cpp
@@ -429,8 +429,7 @@ AtomicType::Mangle() const {
|
|||||||
std::string
|
std::string
|
||||||
AtomicType::GetCDeclaration(const std::string &name) const {
|
AtomicType::GetCDeclaration(const std::string &name) const {
|
||||||
std::string ret;
|
std::string ret;
|
||||||
if (variability != Variability::Uniform &&
|
if (variability == Variability::Unbound) {
|
||||||
variability != Variability::SOA) {
|
|
||||||
Assert(m->errorCount > 0);
|
Assert(m->errorCount > 0);
|
||||||
return ret;
|
return ret;
|
||||||
}
|
}
|
||||||
@@ -457,9 +456,14 @@ AtomicType::GetCDeclaration(const std::string &name) const {
|
|||||||
ret += name;
|
ret += name;
|
||||||
}
|
}
|
||||||
|
|
||||||
if (variability == Variability::SOA) {
|
if (variability == Variability::Varying ||
|
||||||
|
variability == Variability::SOA) {
|
||||||
char buf[32];
|
char buf[32];
|
||||||
sprintf(buf, "[%d]", variability.soaWidth);
|
// get program count
|
||||||
|
int vWidth = (variability == Variability::Varying) ?
|
||||||
|
g->target->getNativeVectorWidth() :
|
||||||
|
variability.soaWidth;
|
||||||
|
sprintf(buf, "[%d]", vWidth);
|
||||||
ret += buf;
|
ret += buf;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|||||||
Reference in New Issue
Block a user