Skip to content

Commit

Permalink
OpVariable in OpSpecConstantOp. (KhronosGroup#186)
Browse files Browse the repository at this point in the history
* Fixed problem with OpSpecConstantOp.
In one of last change of spirv spec was added following change:
"Public SPIRV-Headers issues KhronosGroup#12 and KhronosGroup#13 and Khronos SPIR-V issue KhronosGroup#65: Allow OpVariable as an initializer for another OpVariable instruction or the Base of an OpSpecConstantOp with an AccessChain opcode."
In this way, OpVariable can be initialize before OpSpecConstantOp. To do this, it's necessary add OpSpecConstantOp in one container with OpVariable in TopologicalSort. After this change, OpSpecConstantOp and OpVariable instructions will be add to spirv file in the right order.

* Renamed InstructionVec to ConstAndVarVec and fixed indentation
  • Loading branch information
echuraev authored and yxsamliu committed Sep 29, 2016
1 parent 4ddea0c commit 6826048
Showing 1 changed file with 6 additions and 7 deletions.
13 changes: 6 additions & 7 deletions libSPIRV/SPIRVModule.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -1225,15 +1225,15 @@ class TopologicalSort {
typedef std::vector<SPIRVType *> SPIRVTypeVec;
typedef std::vector<SPIRVValue *> SPIRVConstantVector;
typedef std::vector<SPIRVVariable *> SPIRVVariableVec;
typedef std::vector<SPIRVEntry *> SPIRVConstAndVarVec;
typedef std::vector<SPIRVTypeForwardPointer *> SPIRVForwardPointerVec;
typedef std::function<bool(SPIRVEntry*, SPIRVEntry*)> IdComp;
typedef std::map<SPIRVEntry*, DFSState, IdComp> EntryStateMapTy;

SPIRVTypeVec TypeIntVec;
SPIRVConstantVector ConstIntVec;
SPIRVTypeVec TypeVec;
SPIRVConstantVector ConstVec;
SPIRVVariableVec VariableVec;
SPIRVConstAndVarVec ConstAndVarVec;
const SPIRVForwardPointerVec& ForwardPointerVec;
EntryStateMapTy EntryStateMap;

Expand Down Expand Up @@ -1269,11 +1269,11 @@ class TopologicalSort {
if (C->getType()->isTypeInt())
ConstIntVec.push_back(C);
else
ConstVec.push_back(C);
ConstAndVarVec.push_back(E);
} else if (isTypeOpCode(OC))
TypeVec.push_back(static_cast<SPIRVType*>(E));
else if (E->isVariable())
VariableVec.push_back(static_cast<SPIRVVariable*>(E));
else
ConstAndVarVec.push_back(E);
}
public:
TopologicalSort(const SPIRVTypeVec &_TypeVec,
Expand Down Expand Up @@ -1303,8 +1303,7 @@ operator<< (spv_ostream &O, const TopologicalSort &S) {
O << S.TypeIntVec
<< S.ConstIntVec
<< S.TypeVec
<< S.ConstVec
<< S.VariableVec;
<< S.ConstAndVarVec;
return O;
}

Expand Down

0 comments on commit 6826048

Please sign in to comment.