Merge pull request #54 from mknejp/master

SPIR-V: Return undefined values from implicit returns instead of dummy
This commit is contained in:
John Kessenich
2015-08-11 14:25:20 -06:00
4 changed files with 77 additions and 74 deletions

View File

@@ -791,9 +791,7 @@ void Builder::leaveFunction(bool main)
if (function.getReturnType() == makeVoidType())
makeReturn(true);
else {
Id retStorage = createVariable(StorageClassFunction, function.getReturnType(), "dummyReturn");
Id retValue = createLoad(retStorage);
makeReturn(true, retValue);
makeReturn(true, createUndefined(function.getReturnType()));
}
}
}
@@ -844,6 +842,14 @@ Id Builder::createVariable(StorageClass storageClass, Id type, const char* name)
return inst->getResultId();
}
// Comments in header
Id Builder::createUndefined(Id type)
{
Instruction* inst = new Instruction(getUniqueId(), type, OpUndef);
buildPoint->addInstruction(inst);
return inst->getResultId();
}
// Comments in header
void Builder::createStore(Id rValue, Id lValue)
{

View File

@@ -218,6 +218,9 @@ public:
// Create a global or function local or IO variable.
Id createVariable(StorageClass, Id type, const char* name = 0);
// Create an imtermediate with an undefined value.
Id createUndefined(Id type);
// Store into an Id and return the l-value
void createStore(Id rValue, Id lValue);