51
module.cpp
51
module.cpp
@@ -544,27 +544,37 @@ Module::AddGlobalVariable(const std::string &name, const Type *type, Expr *initE
|
|||||||
types are found and returns false otherwise.
|
types are found and returns false otherwise.
|
||||||
*/
|
*/
|
||||||
static bool
|
static bool
|
||||||
lRecursiveCheckValidParamType(const Type *t) {
|
lRecursiveCheckValidParamType(const Type *t, bool vectorOk) {
|
||||||
const StructType *st = CastType<StructType>(t);
|
const StructType *st = CastType<StructType>(t);
|
||||||
if (st != NULL) {
|
if (st != NULL) {
|
||||||
for (int i = 0; i < st->GetElementCount(); ++i)
|
for (int i = 0; i < st->GetElementCount(); ++i)
|
||||||
if (lRecursiveCheckValidParamType(st->GetElementType(i)))
|
if (!lRecursiveCheckValidParamType(st->GetElementType(i),
|
||||||
return true;
|
vectorOk))
|
||||||
return false;
|
return false;
|
||||||
|
return true;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
// Vector types are also not supported, pending ispc properly
|
||||||
|
// supporting the platform ABI. (Pointers to vector types are ok,
|
||||||
|
// though.) (https://github.com/ispc/ispc/issues/363)...
|
||||||
|
if (vectorOk == false && CastType<VectorType>(t) != NULL)
|
||||||
|
return false;
|
||||||
|
|
||||||
const SequentialType *seqt = CastType<SequentialType>(t);
|
const SequentialType *seqt = CastType<SequentialType>(t);
|
||||||
if (seqt != NULL)
|
if (seqt != NULL)
|
||||||
return lRecursiveCheckValidParamType(seqt->GetElementType());
|
return lRecursiveCheckValidParamType(seqt->GetElementType(), vectorOk);
|
||||||
|
|
||||||
const PointerType *pt = CastType<PointerType>(t);
|
const PointerType *pt = CastType<PointerType>(t);
|
||||||
if (pt != NULL) {
|
if (pt != NULL) {
|
||||||
if (pt->IsSlice() || pt->IsVaryingType())
|
if (pt->IsSlice() || pt->IsVaryingType())
|
||||||
return true;
|
return false;
|
||||||
return lRecursiveCheckValidParamType(pt->GetBaseType());
|
return lRecursiveCheckValidParamType(pt->GetBaseType(), true);
|
||||||
}
|
}
|
||||||
|
|
||||||
return t->IsVaryingType();
|
if (t->IsVaryingType())
|
||||||
|
return false;
|
||||||
|
else
|
||||||
|
return true;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
@@ -574,15 +584,18 @@ lRecursiveCheckValidParamType(const Type *t) {
|
|||||||
varying parameters is illegal.
|
varying parameters is illegal.
|
||||||
*/
|
*/
|
||||||
static void
|
static void
|
||||||
lCheckForVaryingParameter(const Type *type, const std::string &name,
|
lCheckExportedParameterTypes(const Type *type, const std::string &name,
|
||||||
SourcePos pos) {
|
SourcePos pos) {
|
||||||
if (lRecursiveCheckValidParamType(type)) {
|
if (lRecursiveCheckValidParamType(type, false) == false) {
|
||||||
if (CastType<PointerType>(type))
|
if (CastType<PointerType>(type))
|
||||||
Error(pos, "Varying pointer type parameter \"%s\" is illegal "
|
Error(pos, "Varying pointer type parameter \"%s\" is illegal "
|
||||||
"in an exported function.", name.c_str());
|
"in an exported function.", name.c_str());
|
||||||
else if (CastType<StructType>(type->GetBaseType()))
|
else if (CastType<StructType>(type->GetBaseType()))
|
||||||
Error(pos, "Struct parameter \"%s\" with varying member(s) is illegal "
|
Error(pos, "Struct parameter \"%s\" with varying or vector typed "
|
||||||
"in an exported function.", name.c_str());
|
"member(s) is illegal in an exported function.", name.c_str());
|
||||||
|
else if (CastType<VectorType>(type))
|
||||||
|
Error(pos, "Vector-typed parameter \"%s\" is illegal in an exported "
|
||||||
|
"function.", name.c_str());
|
||||||
else
|
else
|
||||||
Error(pos, "Varying parameter \"%s\" is illegal in an exported function.",
|
Error(pos, "Varying parameter \"%s\" is illegal in an exported function.",
|
||||||
name.c_str());
|
name.c_str());
|
||||||
@@ -747,12 +760,12 @@ Module::AddFunctionDeclaration(const std::string &name,
|
|||||||
// This also applies transitively to members I think?
|
// This also applies transitively to members I think?
|
||||||
function->setDoesNotAlias(1, true);
|
function->setDoesNotAlias(1, true);
|
||||||
|
|
||||||
// Make sure that the return type isn't 'varying' if the function is
|
// Make sure that the return type isn't 'varying' or vector typed if
|
||||||
// 'export'ed.
|
// the function is 'export'ed.
|
||||||
if (functionType->isExported &&
|
if (functionType->isExported &&
|
||||||
lRecursiveCheckValidParamType(functionType->GetReturnType()))
|
lRecursiveCheckValidParamType(functionType->GetReturnType(), false) == false)
|
||||||
Error(pos, "Illegal to return a \"varying\" type from exported "
|
Error(pos, "Illegal to return a \"varying\" or vector type from "
|
||||||
"function \"%s\"", name.c_str());
|
"exported function \"%s\"", name.c_str());
|
||||||
|
|
||||||
if (functionType->isTask &&
|
if (functionType->isTask &&
|
||||||
Type::Equal(functionType->GetReturnType(), AtomicType::Void) == false)
|
Type::Equal(functionType->GetReturnType(), AtomicType::Void) == false)
|
||||||
@@ -774,7 +787,7 @@ Module::AddFunctionDeclaration(const std::string &name,
|
|||||||
// 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 varying stuff going on in it.
|
||||||
if (functionType->isExported)
|
if (functionType->isExported)
|
||||||
lCheckForVaryingParameter(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
|
||||||
|
|||||||
@@ -1,4 +1,4 @@
|
|||||||
// dsgsdhg
|
// Vector-typed parameter "x" is illegal
|
||||||
|
|
||||||
export void foo(uniform float<3> x) {
|
export void foo(uniform float<3> x) {
|
||||||
}
|
}
|
||||||
|
|||||||
Reference in New Issue
Block a user