SPV: Partially address #2293: correct "const in" precision matching.

Track whether formal parameters declare reduced precision and match
that with arguments, and if they differ, make a copy to promote the
precision.
This commit is contained in:
John Kessenich
2020-06-26 08:37:06 -06:00
parent fbb9dc2cf1
commit 4df10335e6
6 changed files with 94 additions and 2 deletions

View File

@@ -55,6 +55,7 @@
#include <iostream>
#include <memory>
#include <vector>
#include <set>
namespace spv {
@@ -355,6 +356,10 @@ public:
void setImplicitThis() { implicitThis = true; }
bool hasImplicitThis() const { return implicitThis; }
void addReducedPrecisionParam(int p) { reducedPrecisionParams.insert(p); }
bool isReducedPrecisionParam(int p) const
{ return reducedPrecisionParams.find(p) != reducedPrecisionParams.end(); }
void dump(std::vector<unsigned int>& out) const
{
// OpFunction
@@ -379,6 +384,7 @@ protected:
std::vector<Instruction*> parameterInstructions;
std::vector<Block*> blocks;
bool implicitThis; // true if this is a member function expecting to be passed a 'this' as the first argument
std::set<int> reducedPrecisionParams; // list of parameter indexes that need a relaxed precision arg
};
//