Lines Matching refs:spv
44 namespace spv {
81 namespace spv {
88 spirvbin_t(int verbose = 0) : entryPoint(spv::NoResult), largestNewId(0), verbose(verbose), errorLatch(false)
94 void remap(std::vector<std::uint32_t>& spv, const std::vector<std::string>& whiteListStrings,
98 void remap(std::vector<std::uint32_t>& spv, std::uint32_t opts = DO_EVERYTHING);
114 typedef std::unordered_map<spv::Id, spv::Id> idmap_t;
115 typedef std::unordered_set<spv::Id> idset_t;
116 typedef std::unordered_map<spv::Id, int> blockmap_t;
121 typedef std::unordered_map<std::string, spv::Id> namemap_t;
126 typedef std::function<void(spv::Id&)> idfn_t;
127 typedef std::function<bool(spv::Op, unsigned start)> instfn_t;
130 static const spv::Id unmapped; // unchanged from default value
131 static const spv::Id unused; // unused ID
138 typedef std::map<spv::Id, typeentry_t> globaltypes_t;
142 typedef std::unordered_map<spv::Id, int> posmap_rev_t;
145 typedef std::unordered_map<spv::Id, unsigned> typesize_map_t;
150 bool isConstOp(spv::Op opCode) const;
151 bool isTypeOp(spv::Op opCode) const;
152 bool isStripOp(spv::Op opCode) const;
153 bool isFlowCtrl(spv::Op opCode) const;
154 range_t literalRange(spv::Op opCode) const;
155 range_t typeRange(spv::Op opCode) const;
156 range_t constRange(spv::Op opCode) const;
157 unsigned typeSizeInWords(spv::Id id) const;
158 unsigned idTypeSizeInWords(spv::Id id) const;
160 bool isStripOp(spv::Op opCode, unsigned start) const;
162 spv::Id& asId(unsigned word) { return spv[word]; }
163 const spv::Id& asId(unsigned word) const { return spv[word]; }
164 spv::Op asOpCode(unsigned word) const { return opOpCode(spv[word]); }
166 spv::Decoration asDecoration(unsigned word) const { return spv::Decoration(spv[word]); }
167 unsigned asWordCount(unsigned word) const { return opWordCount(spv[word]); }
168 spv::Id asTypeConstId(unsigned word) const { return asId(word + (isTypeOp(asOpCode(word)) ? 1 : 2)); }
169 unsigned idPos(spv::Id id) const;
171 static unsigned opWordCount(spirword_t data) { return data >> spv::WordCountShift; }
172 static spv::Op opOpCode(spirword_t data) { return spv::Op(data & spv::OpCodeMask); }
175 spirword_t magic() const { return spv[0]; } // return magic number
176 spirword_t bound() const { return spv[3]; } // return Id bound from header
177 spirword_t bound(spirword_t b) { return spv[3] = b; }
178 spirword_t genmagic() const { return spv[2]; } // generator magic
179 spirword_t genmagic(spirword_t m) { return spv[2] = m; }
180 spirword_t schemaNum() const { return spv[4]; } // schema number from header
183 spv::Id localId(spv::Id id) const { return idMapL[id]; }
186 inline spv::Id localId(spv::Id id, spv::Id newId);
187 void countIds(spv::Id id);
192 inline spv::Id nextUnusedId(spv::Id id);
198 bool isNewIdMapped(spv::Id newId) const { return isMapped(newId); }
199 bool isOldIdUnmapped(spv::Id oldId) const { return localId(oldId) == unmapped; }
200 bool isOldIdUnused(spv::Id oldId) const { return localId(oldId) == unused; }
201 bool isOldIdMapped(spv::Id oldId) const { return !isOldIdUnused(oldId) && !isOldIdUnmapped(oldId); }
202 bool isFunction(spv::Id oldId) const { return fnPos.find(oldId) != fnPos.end(); }
204 // bool matchType(const globaltypes_t& globalTypes, spv::Id lt, spv::Id gt) const;
205 // spv::Id findType(const globaltypes_t& globalTypes, spv::Id lt) const;
229 std::vector<spirword_t> spv; // SPIR words
241 bool isMapped(spv::Id id) const { return id < maxMappedId() && ((mapped[id/mBits] & (1LL<<(id%mBits))) != 0); }
242 void setMapped(spv::Id id) { resizeMapped(id); mapped[id/mBits] |= (1LL<<(id%mBits)); }
243 void resizeMapped(spv::Id id) { if (id >= maxMappedId()) mapped.resize(id/mBits+1, 0); }
252 std::unordered_map<spv::Id, range_t> fnPos;
255 std::unordered_map<spv::Id, int> fnCalls;
261 std::vector<spv::Id> idMapL; // ID {M}ap from {L}ocal to {G}lobal IDs
263 spv::Id entryPoint; // module entry point
264 spv::Id largestNewId; // biggest new ID we have mapped anything to