summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorPierre Moreau <dev@pmoreau.org>2018-04-17 21:11:51 +0200
committerAlexey Sotkin <alexey.sotkin@intel.com>2018-04-24 12:21:49 +0300
commitb5346d8645a6a111eb07d26b53f3345636faef9c (patch)
treeef58ed808989e610102a9e5f5f6101a5e4375af3
parenta8d032140fe6deac00c37c6d069e4dee9f0bba3c (diff)
Rename all variables and functions to match LLVM guidelines
The project version was also changed as the entrypoints to the library have been modified. Command used: /usr/share/clang/run-clang-tidy.py -header-filter "(./include/SPIRV.h|./lib/SPIRV/Mangler/FunctionDescriptor.h|./lib/SPIRV/Mangler/ManglingUtils.h|./lib/SPIRV/Mangler/NameMangleAPI.h|./lib/SPIRV/Mangler/ParameterType.h|./lib/SPIRV/Mangler/Refcount.h|./lib/SPIRV/libSPIRV/libSPIRV.h|./lib/SPIRV/libSPIRV/SPIRVBasicBlock.h|./lib/SPIRV/libSPIRV/SPIRVDebug.h|./lib/SPIRV/libSPIRV/SPIRVDecorate.h|./lib/SPIRV/libSPIRV/SPIRVEntry.h|./lib/SPIRV/libSPIRV/SPIRVEnum.h|./lib/SPIRV/libSPIRV/SPIRVError.h|./lib/SPIRV/libSPIRV/SPIRVErrorEnum.h|./lib/SPIRV/libSPIRV/SPIRVExtInst.h|./lib/SPIRV/libSPIRV/SPIRVFunction.h|./lib/SPIRV/libSPIRV/SPIRVInstruction.h|./lib/SPIRV/libSPIRV/SPIRVIsValidEnum.h|./lib/SPIRV/libSPIRV/SPIRVModule.h|./lib/SPIRV/libSPIRV/SPIRVNameMapEnum.h|./lib/SPIRV/libSPIRV/SPIRVOpCode.h|./lib/SPIRV/libSPIRV/SPIRVOpCodeEnum.h|./lib/SPIRV/libSPIRV/SPIRVStream.h|./lib/SPIRV/libSPIRV/SPIRVType.h|./lib/SPIRV/libSPIRV/SPIRVUtil.h|./lib/SPIRV/libSPIRV/SPIRVValue.h|./lib/SPIRV/runtime/OpenCL/inc/spirv.h|./lib/SPIRV/runtime/OpenCL/inc/spirv_convert.h|./lib/SPIRV/OCLUtil.h|./lib/SPIRV/OCLTypeToSPIRV.h|./lib/SPIRV/SPIRVInternal.h|./lib/SPIRV/SPIRVMDBuilder.h|./lib/SPIRV/SPIRVMDWalker.h|./lib/SPIRV/SPIRVWriterPass.h)" -checks="-*,readability-identifier-naming" `find . -iname "*.cpp"` Manual edits: * lib/SPIRV/Mangler/FunctionDescriptor.cpp * lib/SPIRV/libSPIRV/SPIRVEntry.h * lib/SPIRV/libSPIRV/SPIRVDecorate.h * lib/SPIRV/libSPIRV/SPIRVValue.h * lib/SPIRV/libSPIRV/SPIRVStream.h * lib/SPIRV/libSPIRV/SPIRVInstruction.h * lib/SPIRV/Mangler/ParameterType.cpp * lib/SPIRV/Mangler/Mangler.cpp * lib/SPIRV/OCL20ToSPIRV.cpp * lib/SPIRV/Mangler/ParameterType.h * lib/SPIRV/SPIRVLowerOCLBlocks.cpp * lib/SPIRV/SPIRVUtil.cpp * lib/SPIRV/Mangler/Refcount.h
-rw-r--r--CMakeLists.txt2
-rw-r--r--include/SPIRV.h16
-rw-r--r--lib/SPIRV/Mangler/FunctionDescriptor.cpp80
-rw-r--r--lib/SPIRV/Mangler/FunctionDescriptor.h10
-rw-r--r--lib/SPIRV/Mangler/Mangler.cpp200
-rw-r--r--lib/SPIRV/Mangler/ManglingUtils.cpp74
-rw-r--r--lib/SPIRV/Mangler/ManglingUtils.h16
-rw-r--r--lib/SPIRV/Mangler/NameMangleAPI.h2
-rw-r--r--lib/SPIRV/Mangler/ParameterType.cpp200
-rw-r--r--lib/SPIRV/Mangler/ParameterType.h60
-rw-r--r--lib/SPIRV/Mangler/Refcount.h20
-rw-r--r--lib/SPIRV/OCL20ToSPIRV.cpp30
-rw-r--r--lib/SPIRV/OCLUtil.cpp62
-rw-r--r--lib/SPIRV/OCLUtil.h8
-rw-r--r--lib/SPIRV/SPIRVInternal.h54
-rw-r--r--lib/SPIRV/SPIRVLowerOCLBlocks.cpp42
-rw-r--r--lib/SPIRV/SPIRVReader.cpp114
-rw-r--r--lib/SPIRV/SPIRVToOCL20.cpp180
-rw-r--r--lib/SPIRV/SPIRVUtil.cpp180
-rw-r--r--lib/SPIRV/SPIRVWriter.cpp28
-rw-r--r--lib/SPIRV/SPIRVWriterPass.cpp10
-rw-r--r--lib/SPIRV/libSPIRV/SPIRVBasicBlock.cpp4
-rw-r--r--lib/SPIRV/libSPIRV/SPIRVDecorate.cpp6
-rw-r--r--lib/SPIRV/libSPIRV/SPIRVDecorate.h2
-rw-r--r--lib/SPIRV/libSPIRV/SPIRVEntry.cpp20
-rw-r--r--lib/SPIRV/libSPIRV/SPIRVEntry.h24
-rw-r--r--lib/SPIRV/libSPIRV/SPIRVEnum.h4
-rw-r--r--lib/SPIRV/libSPIRV/SPIRVFunction.h10
-rw-r--r--lib/SPIRV/libSPIRV/SPIRVInstruction.h84
-rw-r--r--lib/SPIRV/libSPIRV/SPIRVModule.cpp56
-rw-r--r--lib/SPIRV/libSPIRV/SPIRVModule.h4
-rw-r--r--lib/SPIRV/libSPIRV/SPIRVStream.cpp2
-rw-r--r--lib/SPIRV/libSPIRV/SPIRVStream.h12
-rw-r--r--lib/SPIRV/libSPIRV/SPIRVType.h8
-rw-r--r--lib/SPIRV/libSPIRV/SPIRVUtil.h18
-rw-r--r--lib/SPIRV/libSPIRV/SPIRVValue.h8
-rw-r--r--tools/llvm-spirv/llvm-spirv.cpp20
37 files changed, 834 insertions, 836 deletions
diff --git a/CMakeLists.txt b/CMakeLists.txt
index 141f8b2..84d7197 100644
--- a/CMakeLists.txt
+++ b/CMakeLists.txt
@@ -1,6 +1,6 @@
cmake_minimum_required(VERSION 3.3)
-set(LLVM_SPIRV_VERSION 0.1.0.0)
+set(LLVM_SPIRV_VERSION 0.2.0.0)
# check if we build inside llvm or not
if(CMAKE_SOURCE_DIR STREQUAL CMAKE_CURRENT_SOURCE_DIR)
diff --git a/include/SPIRV.h b/include/SPIRV.h
index 29c79f0..f8f695f 100644
--- a/include/SPIRV.h
+++ b/include/SPIRV.h
@@ -68,24 +68,24 @@ namespace SPIRV {
class SPIRVModule;
/// \brief Check if a string contains SPIR-V binary.
-bool IsSPIRVBinary(std::string &Img);
+bool isSpirvBinary(std::string &Img);
#ifdef _SPIRV_SUPPORT_TEXT_FMT
/// \brief Convert SPIR-V between binary and internal textual formats.
/// This function is not thread safe and should not be used in multi-thread
/// applications unless guarded by a critical section.
/// \returns true if succeeds.
-bool ConvertSPIRV(std::istream &IS, llvm::raw_ostream &OS, std::string &ErrMsg,
+bool convertSpirv(std::istream &IS, llvm::raw_ostream &OS, std::string &ErrMsg,
bool FromText, bool ToText);
/// \brief Convert SPIR-V between binary and internel text formats.
/// This function is not thread safe and should not be used in multi-thread
/// applications unless guarded by a critical section.
-bool ConvertSPIRV(std::string &Input, std::string &Out, std::string &ErrMsg,
+bool convertSpirv(std::string &Input, std::string &Out, std::string &ErrMsg,
bool ToText);
/// \brief Check if a string contains SPIR-V in internal text format.
-bool IsSPIRVText(std::string &Img);
+bool isSpirvText(std::string &Img);
#endif
} // End namespace SPIRV
@@ -94,19 +94,19 @@ namespace llvm {
/// \brief Translate LLVM module to SPIRV and write to ostream.
/// \returns true if succeeds.
-bool WriteSPIRV(llvm::Module *M, llvm::raw_ostream &OS, std::string &ErrMsg);
+bool writeSpirv(llvm::Module *M, llvm::raw_ostream &OS, std::string &ErrMsg);
/// \brief Load SPIRV from istream and translate to LLVM module.
/// \returns true if succeeds.
-bool ReadSPIRV(llvm::LLVMContext &C, std::istream &IS, llvm::Module *&M,
+bool readSpirv(llvm::LLVMContext &C, std::istream &IS, llvm::Module *&M,
std::string &ErrMsg);
/// \brief Regularize LLVM module by removing entities not representable by
/// SPIRV.
-bool RegularizeLLVMForSPIRV(llvm::Module *M, std::string &ErrMsg);
+bool regularizeLlvmForSpirv(llvm::Module *M, std::string &ErrMsg);
/// \brief Mangle OpenCL builtin function function name.
-void MangleOpenCLBuiltin(const std::string &UnmangledName,
+void mangleOpenClBuiltin(const std::string &UnmangledName,
ArrayRef<Type *> ArgTypes, std::string &MangledName);
/// Create a pass for translating LLVM to SPIR-V.
diff --git a/lib/SPIRV/Mangler/FunctionDescriptor.cpp b/lib/SPIRV/Mangler/FunctionDescriptor.cpp
index 03d3d6c..d158036 100644
--- a/lib/SPIRV/Mangler/FunctionDescriptor.cpp
+++ b/lib/SPIRV/Mangler/FunctionDescriptor.cpp
@@ -21,32 +21,32 @@ std::string FunctionDescriptor::nullString() {
}
std::string FunctionDescriptor::toString() const {
- std::stringstream stream;
+ std::stringstream Stream;
if (isNull()) {
return FunctionDescriptor::nullString();
}
- stream << name << "(";
- size_t paramCount = parameters.size();
- if (paramCount > 0) {
- for (size_t i = 0; i < paramCount - 1; ++i)
- stream << parameters[i]->toString() << ", ";
- stream << parameters[paramCount - 1]->toString();
+ Stream << Name << "(";
+ size_t ParamCount = Parameters.size();
+ if (ParamCount > 0) {
+ for (size_t I = 0; I < ParamCount - 1; ++I)
+ Stream << Parameters[I]->toString() << ", ";
+ Stream << Parameters[ParamCount - 1]->toString();
}
- stream << ")";
- return stream.str();
+ Stream << ")";
+ return Stream.str();
}
-static bool equal(const TypeVector &l, const TypeVector &r) {
- if (&l == &r)
+static bool equal(const TypeVector &L, const TypeVector &R) {
+ if (&L == &R)
return true;
- if (l.size() != r.size())
+ if (L.size() != R.size())
return false;
- TypeVector::const_iterator itl = l.begin(), itr = r.begin(), endl = l.end();
- while (itl != endl) {
- if (!(*itl)->equals(*itr))
+ TypeVector::const_iterator Itl = L.begin(), Itr = R.begin(), Endl = L.end();
+ while (Itl != Endl) {
+ if (!(*Itl)->equals(*Itr))
return false;
- ++itl;
- ++itr;
+ ++Itl;
+ ++Itr;
}
return true;
}
@@ -55,41 +55,41 @@ static bool equal(const TypeVector &l, const TypeVector &r) {
// FunctionDescriptor
//
-bool FunctionDescriptor::operator==(const FunctionDescriptor &that) const {
- if (this == &that)
+bool FunctionDescriptor::operator==(const FunctionDescriptor &That) const {
+ if (this == &That)
return true;
- if (name != that.name)
+ if (Name != That.Name)
return false;
- return equal(parameters, that.parameters);
+ return equal(Parameters, That.Parameters);
}
-bool FunctionDescriptor::operator<(const FunctionDescriptor &that) const {
- int strCmp = name.compare(that.name);
- if (strCmp)
- return (strCmp < 0);
- size_t len = parameters.size(), thatLen = that.parameters.size();
- if (len != thatLen)
- return len < thatLen;
- TypeVector::const_iterator it = parameters.begin(), e = parameters.end(),
- thatit = that.parameters.begin();
- while (it != e) {
- int cmp = (*it)->toString().compare((*thatit)->toString());
- if (cmp)
- return (cmp < 0);
- ++thatit;
- ++it;
+bool FunctionDescriptor::operator<(const FunctionDescriptor &That) const {
+ int StrCmp = Name.compare(That.Name);
+ if (StrCmp)
+ return (StrCmp < 0);
+ size_t Len = Parameters.size(), ThatLen = That.Parameters.size();
+ if (Len != ThatLen)
+ return Len < ThatLen;
+ TypeVector::const_iterator It = Parameters.begin(), E = Parameters.end(),
+ Thatit = That.Parameters.begin();
+ while (It != E) {
+ int Cmp = (*It)->toString().compare((*Thatit)->toString());
+ if (Cmp)
+ return (Cmp < 0);
+ ++Thatit;
+ ++It;
}
return false;
}
bool FunctionDescriptor::isNull() const {
- return (name.empty() && parameters.empty());
+ return (Name.empty() && Parameters.empty());
}
FunctionDescriptor FunctionDescriptor::null() {
- FunctionDescriptor fd;
- fd.name = "";
- return fd;
+ FunctionDescriptor Fd;
+ Fd.Name = "";
+ return Fd;
}
} // namespace SPIR
diff --git a/lib/SPIRV/Mangler/FunctionDescriptor.h b/lib/SPIRV/Mangler/FunctionDescriptor.h
index a34999e..b8fda85 100644
--- a/lib/SPIRV/Mangler/FunctionDescriptor.h
+++ b/lib/SPIRV/Mangler/FunctionDescriptor.h
@@ -28,9 +28,9 @@ struct FunctionDescriptor {
std::string toString() const;
/// The name of the function (stripped).
- std::string name;
+ std::string Name;
/// Parameter list of the function.
- TypeVector parameters;
+ TypeVector Parameters;
bool operator==(const FunctionDescriptor &) const;
@@ -46,9 +46,9 @@ struct FunctionDescriptor {
};
template <typename T>
-std::ostream &operator<<(T &o, const SPIR::FunctionDescriptor &fd) {
- o << fd.toString();
- return o;
+std::ostream &operator<<(T &O, const SPIR::FunctionDescriptor &Fd) {
+ O << Fd.toString();
+ return O;
}
} // namespace SPIR
diff --git a/lib/SPIRV/Mangler/Mangler.cpp b/lib/SPIRV/Mangler/Mangler.cpp
index 4eed0af..82896db 100644
--- a/lib/SPIRV/Mangler/Mangler.cpp
+++ b/lib/SPIRV/Mangler/Mangler.cpp
@@ -29,8 +29,8 @@ namespace SPIR {
class MangleVisitor : public TypeVisitor {
public:
- MangleVisitor(SPIRversion ver, std::stringstream &s)
- : TypeVisitor(ver), Stream(s), seqId(0) {}
+ MangleVisitor(SPIRversion Ver, std::stringstream &S)
+ : TypeVisitor(Ver), Stream(S), SeqId(0) {}
//
// mangle substitution methods
@@ -39,39 +39,39 @@ public:
if (SeqID == 1)
Stream << '0';
else if (SeqID > 1) {
- std::string bstr;
- std::string charset = "0123456789ABCDEFGHIJKLMNOPQRSTUVWXYZ";
+ std::string Bstr;
+ std::string Charset = "0123456789ABCDEFGHIJKLMNOPQRSTUVWXYZ";
SeqID--;
- bstr.reserve(7);
+ Bstr.reserve(7);
for (; SeqID != 0; SeqID /= 36)
- bstr += charset.substr(SeqID % 36, 1);
- std::reverse(bstr.begin(), bstr.end());
- Stream << bstr;
+ Bstr += Charset.substr(SeqID % 36, 1);
+ std::reverse(Bstr.begin(), Bstr.end());
+ Stream << Bstr;
}
Stream << '_';
}
- bool mangleSubstitution(const ParamType *type, std::string typeStr) {
- size_t fpos;
- std::stringstream thistypeStr;
- thistypeStr << typeStr;
- if ((fpos = Stream.str().find(typeStr)) != std::string::npos) {
- const char *nType;
- if (const PointerType *p = SPIR::dyn_cast<PointerType>(type)) {
- if ((nType =
- mangledPrimitiveStringfromName(p->getPointee()->toString())))
- thistypeStr << nType;
+ bool mangleSubstitution(const ParamType *Type, std::string TypeStr) {
+ size_t Fpos;
+ std::stringstream ThistypeStr;
+ ThistypeStr << TypeStr;
+ if ((Fpos = Stream.str().find(TypeStr)) != std::string::npos) {
+ const char *NType;
+ if (const PointerType *P = SPIR::dynCast<PointerType>(Type)) {
+ if ((NType =
+ mangledPrimitiveStringfromName(P->getPointee()->toString())))
+ ThistypeStr << NType;
}
#if defined(ENABLE_MANGLER_VECTOR_SUBSTITUTION)
- else if (const VectorType *pVec = SPIR::dyn_cast<VectorType>(type)) {
- if ((nType = mangledPrimitiveStringfromName(
- pVec->getScalarType()->toString())))
- thistypeStr << nType;
+ else if (const VectorType *PVec = SPIR::dynCast<VectorType>(Type)) {
+ if ((NType = mangledPrimitiveStringfromName(
+ PVec->getScalarType()->toString())))
+ ThistypeStr << NType;
}
#endif
std::map<std::string, unsigned>::iterator I =
- substitutions.find(thistypeStr.str());
- if (I == substitutions.end())
+ Substitutions.find(ThistypeStr.str());
+ if (I == Substitutions.end())
return false;
unsigned SeqID = I->second;
@@ -85,141 +85,141 @@ public:
//
// Visit methods
//
- MangleError visit(const PrimitiveType *t) override {
- MangleError me = MANGLE_SUCCESS;
+ MangleError visit(const PrimitiveType *T) override {
+ MangleError Me = MANGLE_SUCCESS;
#if defined(SPIRV_SPIR20_MANGLING_REQUIREMENTS)
Stream << mangledPrimitiveString(t->getPrimitive());
#else
- std::string mangledPrimitive =
- std::string(mangledPrimitiveString(t->getPrimitive()));
+ std::string MangledPrimitive =
+ std::string(mangledPrimitiveString(T->getPrimitive()));
// out of all enums it makes sense to substitute only
// memory_scope/memory_order since only they appear several times in the
// builtin declaration.
- if (mangledPrimitive == "12memory_scope" ||
- mangledPrimitive == "12memory_order") {
- if (!mangleSubstitution(t, mangledPrimitiveString(t->getPrimitive()))) {
- size_t index = Stream.str().size();
- Stream << mangledPrimitiveString(t->getPrimitive());
- substitutions[Stream.str().substr(index)] = seqId++;
+ if (MangledPrimitive == "12memory_scope" ||
+ MangledPrimitive == "12memory_order") {
+ if (!mangleSubstitution(T, mangledPrimitiveString(T->getPrimitive()))) {
+ size_t Index = Stream.str().size();
+ Stream << mangledPrimitiveString(T->getPrimitive());
+ Substitutions[Stream.str().substr(Index)] = SeqId++;
}
} else {
- Stream << mangledPrimitive;
+ Stream << MangledPrimitive;
}
#endif
- return me;
+ return Me;
}
- MangleError visit(const PointerType *p) override {
- size_t fpos = Stream.str().size();
- std::string qualStr;
- MangleError me = MANGLE_SUCCESS;
- for (unsigned int i = ATTR_QUALIFIER_FIRST; i <= ATTR_QUALIFIER_LAST; i++) {
- TypeAttributeEnum qualifier = (TypeAttributeEnum)i;
- if (p->hasQualifier(qualifier)) {
- qualStr += getMangledAttribute(qualifier);
+ MangleError visit(const PointerType *P) override {
+ size_t Fpos = Stream.str().size();
+ std::string QualStr;
+ MangleError Me = MANGLE_SUCCESS;
+ for (unsigned int I = ATTR_QUALIFIER_FIRST; I <= ATTR_QUALIFIER_LAST; I++) {
+ TypeAttributeEnum Qualifier = (TypeAttributeEnum)I;
+ if (P->hasQualifier(Qualifier)) {
+ QualStr += getMangledAttribute(Qualifier);
}
}
- qualStr += getMangledAttribute((p->getAddressSpace()));
- if (!mangleSubstitution(p, "P" + qualStr)) {
+ QualStr += getMangledAttribute((P->getAddressSpace()));
+ if (!mangleSubstitution(P, "P" + QualStr)) {
// A pointee type is substituted when it is a user type, a vector type
// (but see a comment in the beginning of this file), a pointer type,
// or a primitive type with qualifiers (addr. space and/or CV qualifiers).
// So, stream "P", type qualifiers
- Stream << "P" << qualStr;
+ Stream << "P" << QualStr;
// and the pointee type itself.
- me = p->getPointee()->accept(this);
+ Me = P->getPointee()->accept(this);
// The type qualifiers plus a pointee type is a substitutable entity
- if (qualStr.length() > 0)
- substitutions[Stream.str().substr(fpos + 1)] = seqId++;
+ if (QualStr.length() > 0)
+ Substitutions[Stream.str().substr(Fpos + 1)] = SeqId++;
// The complete pointer type is substitutable as well
- substitutions[Stream.str().substr(fpos)] = seqId++;
+ Substitutions[Stream.str().substr(Fpos)] = SeqId++;
}
- return me;
+ return Me;
}
- MangleError visit(const VectorType *v) override {
- size_t index = Stream.str().size();
- std::stringstream typeStr;
- typeStr << "Dv" << v->getLength() << "_";
- MangleError me = MANGLE_SUCCESS;
+ MangleError visit(const VectorType *V) override {
+ size_t Index = Stream.str().size();
+ std::stringstream TypeStr;
+ TypeStr << "Dv" << V->getLength() << "_";
+ MangleError Me = MANGLE_SUCCESS;
#if defined(ENABLE_MANGLER_VECTOR_SUBSTITUTION)
- if (!mangleSubstitution(v, typeStr.str()))
+ if (!mangleSubstitution(V, TypeStr.str()))
#endif
{
- Stream << typeStr.str();
- me = v->getScalarType()->accept(this);
- substitutions[Stream.str().substr(index)] = seqId++;
+ Stream << TypeStr.str();
+ Me = V->getScalarType()->accept(this);
+ Substitutions[Stream.str().substr(Index)] = SeqId++;
}
- return me;
+ return Me;
}
- MangleError visit(const AtomicType *p) override {
- MangleError me = MANGLE_SUCCESS;
- size_t index = Stream.str().size();
- const char *typeStr = "U7_Atomic";
- if (!mangleSubstitution(p, typeStr)) {
- Stream << typeStr;
- me = p->getBaseType()->accept(this);
- substitutions[Stream.str().substr(index)] = seqId++;
+ MangleError visit(const AtomicType *P) override {
+ MangleError Me = MANGLE_SUCCESS;
+ size_t Index = Stream.str().size();
+ const char *TypeStr = "U7_Atomic";
+ if (!mangleSubstitution(P, TypeStr)) {
+ Stream << TypeStr;
+ Me = P->getBaseType()->accept(this);
+ Substitutions[Stream.str().substr(Index)] = SeqId++;
}
- return me;
+ return Me;
}
- MangleError visit(const BlockType *p) override {
+ MangleError visit(const BlockType *P) override {
Stream << "U"
<< "13block_pointerFv";
- if (p->getNumOfParams() == 0)
+ if (P->getNumOfParams() == 0)
Stream << "v";
else
- for (unsigned int i = 0; i < p->getNumOfParams(); ++i) {
- MangleError err = p->getParam(i)->accept(this);
- if (err != MANGLE_SUCCESS) {
- return err;
+ for (unsigned int I = 0; I < P->getNumOfParams(); ++I) {
+ MangleError Err = P->getParam(I)->accept(this);
+ if (Err != MANGLE_SUCCESS) {
+ return Err;
}
}
Stream << "E";
return MANGLE_SUCCESS;
}
- MangleError visit(const UserDefinedType *pTy) override {
- std::string name = pTy->toString();
- Stream << name.size() << name;
+ MangleError visit(const UserDefinedType *PTy) override {
+ std::string Name = PTy->toString();
+ Stream << Name.size() << Name;
return MANGLE_SUCCESS;
}
private:
// Holds the mangled string representing the prototype of the function.
std::stringstream &Stream;
- unsigned seqId;
- std::map<std::string, unsigned> substitutions;
+ unsigned SeqId;
+ std::map<std::string, unsigned> Substitutions;
};
//
// NameMangler
//
-NameMangler::NameMangler(SPIRversion version) : Spir_version(version) {}
+NameMangler::NameMangler(SPIRversion Version) : SpirVersion(Version) {}
-MangleError NameMangler::mangle(const FunctionDescriptor &fd,
- std::string &mangledName) {
- if (fd.isNull()) {
- mangledName.assign(FunctionDescriptor::nullString());
+MangleError NameMangler::mangle(const FunctionDescriptor &Fd,
+ std::string &MangledName) {
+ if (Fd.isNull()) {
+ MangledName.assign(FunctionDescriptor::nullString());
return MANGLE_NULL_FUNC_DESCRIPTOR;
}
- std::stringstream ret;
- ret << "_Z" << fd.name.length() << fd.name;
- MangleVisitor visitor(Spir_version, ret);
- for (unsigned int i = 0; i < fd.parameters.size(); ++i) {
- MangleError err = fd.parameters[i]->accept(&visitor);
- if (err == MANGLE_TYPE_NOT_SUPPORTED) {
- mangledName.assign("Type ");
- mangledName.append(fd.parameters[i]->toString());
- mangledName.append(" is not supported in ");
- std::string ver = getSPIRVersionAsString(Spir_version);
- mangledName.append(ver);
- return err;
+ std::stringstream Ret;
+ Ret << "_Z" << Fd.Name.length() << Fd.Name;
+ MangleVisitor Visitor(SpirVersion, Ret);
+ for (unsigned int I = 0; I < Fd.Parameters.size(); ++I) {
+ MangleError Err = Fd.Parameters[I]->accept(&Visitor);
+ if (Err == MANGLE_TYPE_NOT_SUPPORTED) {
+ MangledName.assign("Type ");
+ MangledName.append(Fd.Parameters[I]->toString());
+ MangledName.append(" is not supported in ");
+ std::string Ver = getSPIRVersionAsString(SpirVersion);
+ MangledName.append(Ver);
+ return Err;
}
}
- mangledName.assign(ret.str());
+ MangledName.assign(Ret.str());
return MANGLE_SUCCESS;
}
diff --git a/lib/SPIRV/Mangler/ManglingUtils.cpp b/lib/SPIRV/Mangler/ManglingUtils.cpp
index 5237ef2..3f6d160 100644
--- a/lib/SPIRV/Mangler/ManglingUtils.cpp
+++ b/lib/SPIRV/Mangler/ManglingUtils.cpp
@@ -54,7 +54,7 @@ static const char *PrimitiveNames[PRIMITIVE_NUM] = {
"memory_order",
"memory_scope"};
-const char *mangledTypes[PRIMITIVE_NUM] = {
+const char *MangledTypes[PRIMITIVE_NUM] = {
"b", // BOOL
"h", // UCHAR
"c", // CHAR
@@ -99,17 +99,17 @@ const char *mangledTypes[PRIMITIVE_NUM] = {
#endif
};
-const char *readableAttribute[ATTR_NUM] = {
+const char *ReadableAttribute[ATTR_NUM] = {
"restrict", "volatile", "const", "__private",
"__global", "__constant", "__local", "__generic",
};
-const char *mangledAttribute[ATTR_NUM] = {
+const char *MangledAttribute[ATTR_NUM] = {
"r", "V", "K", "", "U3AS1", "U3AS2", "U3AS3", "U3AS4",
};
// SPIR supported version - stated version is oldest supported version.
-static const SPIRversion primitiveSupportedVersions[PRIMITIVE_NUM] = {
+static const SPIRversion PrimitiveSupportedVersions[PRIMITIVE_NUM] = {
SPIR12, // BOOL
SPIR12, // UCHAR
SPIR12, // CHAR
@@ -145,36 +145,36 @@ static const SPIRversion primitiveSupportedVersions[PRIMITIVE_NUM] = {
SPIR12 // PRIMITIVE_SAMPLER_T
};
-const char *mangledPrimitiveString(TypePrimitiveEnum t) {
- return mangledTypes[t];
+const char *mangledPrimitiveString(TypePrimitiveEnum T) {
+ return MangledTypes[T];
}
-const char *readablePrimitiveString(TypePrimitiveEnum t) {
- return PrimitiveNames[t];
+const char *readablePrimitiveString(TypePrimitiveEnum T) {
+ return PrimitiveNames[T];
}
-const char *getMangledAttribute(TypeAttributeEnum attribute) {
- return mangledAttribute[attribute];
+const char *getMangledAttribute(TypeAttributeEnum Attribute) {
+ return MangledAttribute[Attribute];
}
-const char *getReadableAttribute(TypeAttributeEnum attribute) {
- return readableAttribute[attribute];
+const char *getReadableAttribute(TypeAttributeEnum Attribute) {
+ return ReadableAttribute[Attribute];
}
-SPIRversion getSupportedVersion(TypePrimitiveEnum t) {
- return primitiveSupportedVersions[t];
+SPIRversion getSupportedVersion(TypePrimitiveEnum T) {
+ return PrimitiveSupportedVersions[T];
}
-const char *mangledPrimitiveStringfromName(std::string type) {
- for (size_t i = 0; i < (sizeof(PrimitiveNames) / sizeof(PrimitiveNames[0]));
- i++)
- if (type == PrimitiveNames[i])
- return mangledTypes[i];
+const char *mangledPrimitiveStringfromName(std::string Type) {
+ for (size_t I = 0; I < (sizeof(PrimitiveNames) / sizeof(PrimitiveNames[0]));
+ I++)
+ if (Type == PrimitiveNames[I])
+ return MangledTypes[I];
return NULL;
}
-const char *getSPIRVersionAsString(SPIRversion version) {
- switch (version) {
+const char *getSPIRVersionAsString(SPIRversion Version) {
+ switch (Version) {
case SPIR12:
return "SPIR 1.2";
case SPIR20:
@@ -185,22 +185,22 @@ const char *getSPIRVersionAsString(SPIRversion version) {
}
}
-bool isPipeBuiltin(std::string unmangledName) {
- return unmangledName == "write_pipe" || unmangledName == "read_pipe" ||
- unmangledName == "reserve_write_pipe" ||
- unmangledName == "reserve_read_pipe" ||
- unmangledName == "commit_write_pipe" ||
- unmangledName == "commit_read_pipe" ||
- unmangledName == "work_group_reserve_write_pipe" ||
- unmangledName == "work_group_reserve_read_pipe" ||
- unmangledName == "work_group_commit_write_pipe" ||
- unmangledName == "work_group_commit_read_pipe" ||
- unmangledName == "get_pipe_num_packets" ||
- unmangledName == "get_pipe_max_packets" ||
- unmangledName == "sub_group_reserve_write_pipe" ||
- unmangledName == "sub_group_reserve_read_pipe" ||
- unmangledName == "sub_group_commit_write_pipe" ||
- unmangledName == "sub_group_commit_read_pipe";
+bool isPipeBuiltin(std::string UnmangledName) {
+ return UnmangledName == "write_pipe" || UnmangledName == "read_pipe" ||
+ UnmangledName == "reserve_write_pipe" ||
+ UnmangledName == "reserve_read_pipe" ||
+ UnmangledName == "commit_write_pipe" ||
+ UnmangledName == "commit_read_pipe" ||
+ UnmangledName == "work_group_reserve_write_pipe" ||
+ UnmangledName == "work_group_reserve_read_pipe" ||
+ UnmangledName == "work_group_commit_write_pipe" ||
+ UnmangledName == "work_group_commit_read_pipe" ||
+ UnmangledName == "get_pipe_num_packets" ||
+ UnmangledName == "get_pipe_max_packets" ||
+ UnmangledName == "sub_group_reserve_write_pipe" ||
+ UnmangledName == "sub_group_reserve_read_pipe" ||
+ UnmangledName == "sub_group_commit_write_pipe" ||
+ UnmangledName == "sub_group_commit_read_pipe";
}
} // namespace SPIR
diff --git a/lib/SPIRV/Mangler/ManglingUtils.h b/lib/SPIRV/Mangler/ManglingUtils.h
index 6a6b0e8..a79f67e 100644
--- a/lib/SPIRV/Mangler/ManglingUtils.h
+++ b/lib/SPIRV/Mangler/ManglingUtils.h
@@ -17,18 +17,18 @@
namespace SPIR {
-const char *mangledPrimitiveString(TypePrimitiveEnum primitive);
-const char *readablePrimitiveString(TypePrimitiveEnum primitive);
+const char *mangledPrimitiveString(TypePrimitiveEnum Primitive);
+const char *readablePrimitiveString(TypePrimitiveEnum Primitive);
-const char *getMangledAttribute(TypeAttributeEnum attribute);
-const char *getReadableAttribute(TypeAttributeEnum attribute);
+const char *getMangledAttribute(TypeAttributeEnum Attribute);
+const char *getReadableAttribute(TypeAttributeEnum Attribute);
-SPIRversion getSupportedVersion(TypePrimitiveEnum t);
-const char *getSPIRVersionAsString(SPIRversion version);
+SPIRversion getSupportedVersion(TypePrimitiveEnum T);
+const char *getSPIRVersionAsString(SPIRversion Version);
-const char *mangledPrimitiveStringfromName(std::string type);
+const char *mangledPrimitiveStringfromName(std::string Type);
-bool isPipeBuiltin(std::string unmangledName);
+bool isPipeBuiltin(std::string UnmangledName);
} // namespace SPIR
#endif // SPIRV_MANGLER_MANGLINGUTILS_H
diff --git a/lib/SPIRV/Mangler/NameMangleAPI.h b/lib/SPIRV/Mangler/NameMangleAPI.h
index c80ec69..ded0f8a 100644
--- a/lib/SPIRV/Mangler/NameMangleAPI.h
+++ b/lib/SPIRV/Mangler/NameMangleAPI.h
@@ -34,7 +34,7 @@ struct NameMangler {
MangleError mangle(const FunctionDescriptor &, std::string &);
private:
- SPIRversion Spir_version;
+ SPIRversion SpirVersion;
};
} // namespace SPIR
diff --git a/lib/SPIRV/Mangler/ParameterType.cpp b/lib/SPIRV/Mangler/ParameterType.cpp
index 7435d88..c95fab8 100644
--- a/lib/SPIRV/Mangler/ParameterType.cpp
+++ b/lib/SPIRV/Mangler/ParameterType.cpp
@@ -20,148 +20,146 @@ namespace SPIR {
// Primitive Type
//
-PrimitiveType::PrimitiveType(TypePrimitiveEnum primitive)
- : ParamType(TYPE_ID_PRIMITIVE), Primitive(primitive) {}
+PrimitiveType::PrimitiveType(TypePrimitiveEnum Primitive)
+ : ParamType(TYPE_ID_PRIMITIVE), Primitive(Primitive) {}
-MangleError PrimitiveType::accept(TypeVisitor *visitor) const {
+MangleError PrimitiveType::accept(TypeVisitor *Visitor) const {
if (getSupportedVersion(this->getPrimitive()) >= SPIR20 &&
- visitor->spirVer < SPIR20) {
+ Visitor->SpirVer < SPIR20) {
return MANGLE_TYPE_NOT_SUPPORTED;
}
- return visitor->visit(this);
+ return Visitor->visit(this);
}
std::string PrimitiveType::toString() const {
assert((Primitive >= PRIMITIVE_FIRST && Primitive <= PRIMITIVE_LAST) &&
"illegal primitive");
- std::stringstream myName;
- myName << readablePrimitiveString(Primitive);
- return myName.str();
+ std::stringstream MyName;
+ MyName << readablePrimitiveString(Primitive);
+ return MyName.str();
}
-bool PrimitiveType::equals(const ParamType *type) const {
- const PrimitiveType *p = SPIR::dyn_cast<PrimitiveType>(type);
- return p && (Primitive == p->Primitive);
+bool PrimitiveType::equals(const ParamType *Type) const {
+ const PrimitiveType *P = SPIR::dynCast<PrimitiveType>(Type);
+ return P && (Primitive == P->Primitive);
}
//
// Pointer Type
//
-PointerType::PointerType(const RefParamType type)
- : ParamType(TYPE_ID_POINTER), PType(type) {
- for (unsigned int i = ATTR_QUALIFIER_FIRST; i <= ATTR_QUALIFIER_LAST; i++) {
- setQualifier((TypeAttributeEnum)i, false);
+PointerType::PointerType(const RefParamType Type)
+ : ParamType(TYPE_ID_POINTER), PType(Type) {
+ for (unsigned int I = ATTR_QUALIFIER_FIRST; I <= ATTR_QUALIFIER_LAST; I++) {
+ setQualifier((TypeAttributeEnum)I, false);
}
- Address_space = ATTR_PRIVATE;
+ AddressSpace = ATTR_PRIVATE;
}
-MangleError PointerType::accept(TypeVisitor *visitor) const {
- return visitor->visit(this);
+MangleError PointerType::accept(TypeVisitor *Visitor) const {
+ return Visitor->visit(this);
}
-void PointerType::setAddressSpace(TypeAttributeEnum attr) {
- if (attr < ATTR_ADDR_SPACE_FIRST || attr > ATTR_ADDR_SPACE_LAST) {
+void PointerType::setAddressSpace(TypeAttributeEnum Attr) {
+ if (Attr < ATTR_ADDR_SPACE_FIRST || Attr > ATTR_ADDR_SPACE_LAST) {
return;
}
- Address_space = attr;
+ AddressSpace = Attr;
}
-TypeAttributeEnum PointerType::getAddressSpace() const {
- return Address_space;
-}
+TypeAttributeEnum PointerType::getAddressSpace() const { return AddressSpace; }
-void PointerType::setQualifier(TypeAttributeEnum qual, bool enabled) {
- if (qual < ATTR_QUALIFIER_FIRST || qual > ATTR_QUALIFIER_LAST) {
+void PointerType::setQualifier(TypeAttributeEnum Qual, bool Enabled) {
+ if (Qual < ATTR_QUALIFIER_FIRST || Qual > ATTR_QUALIFIER_LAST) {
return;
}
- Qualifiers[qual - ATTR_QUALIFIER_FIRST] = enabled;
+ Qualifiers[Qual - ATTR_QUALIFIER_FIRST] = Enabled;
}
-bool PointerType::hasQualifier(TypeAttributeEnum qual) const {
- if (qual < ATTR_QUALIFIER_FIRST || qual > ATTR_QUALIFIER_LAST) {
+bool PointerType::hasQualifier(TypeAttributeEnum Qual) const {
+ if (Qual < ATTR_QUALIFIER_FIRST || Qual > ATTR_QUALIFIER_LAST) {
return false;
}
- return Qualifiers[qual - ATTR_QUALIFIER_FIRST];
+ return Qualifiers[Qual - ATTR_QUALIFIER_FIRST];
}
std::string PointerType::toString() const {
- std::stringstream myName;
- for (unsigned int i = ATTR_QUALIFIER_FIRST; i <= ATTR_QUALIFIER_LAST; i++) {
- TypeAttributeEnum qual = (TypeAttributeEnum)i;
- if (hasQualifier(qual)) {
- myName << getReadableAttribute(qual) << " ";
+ std::stringstream MyName;
+ for (unsigned int I = ATTR_QUALIFIER_FIRST; I <= ATTR_QUALIFIER_LAST; I++) {
+ TypeAttributeEnum Qual = (TypeAttributeEnum)I;
+ if (hasQualifier(Qual)) {
+ MyName << getReadableAttribute(Qual) << " ";
}
}
- myName << getReadableAttribute(TypeAttributeEnum(Address_space)) << " ";
- myName << getPointee()->toString() << " *";
- return myName.str();
+ MyName << getReadableAttribute(TypeAttributeEnum(AddressSpace)) << " ";
+ MyName << getPointee()->toString() << " *";
+ return MyName.str();
}
-bool PointerType::equals(const ParamType *type) const {
- const PointerType *p = SPIR::dyn_cast<PointerType>(type);
- if (!p) {
+bool PointerType::equals(const ParamType *Type) const {
+ const PointerType *P = SPIR::dynCast<PointerType>(Type);
+ if (!P) {
return false;
}
- if (getAddressSpace() != p->getAddressSpace()) {
+ if (getAddressSpace() != P->getAddressSpace()) {
return false;
}
- for (unsigned int i = ATTR_QUALIFIER_FIRST; i <= ATTR_QUALIFIER_LAST; i++) {
- TypeAttributeEnum qual = (TypeAttributeEnum)i;
- if (hasQualifier(qual) != p->hasQualifier(qual)) {
+ for (unsigned int I = ATTR_QUALIFIER_FIRST; I <= ATTR_QUALIFIER_LAST; I++) {
+ TypeAttributeEnum Qual = (TypeAttributeEnum)I;
+ if (hasQualifier(Qual) != P->hasQualifier(Qual)) {
return false;
}
}
- return (*getPointee()).equals(&*(p->getPointee()));
+ return (*getPointee()).equals(&*(P->getPointee()));
}
//
// Vector Type
//
-VectorType::VectorType(const RefParamType type, int len)
- : ParamType(TYPE_ID_VECTOR), PType(type), Len(len) {}
+VectorType::VectorType(const RefParamType Type, int Len)
+ : ParamType(TYPE_ID_VECTOR), PType(Type), Len(Len) {}
-MangleError VectorType::accept(TypeVisitor *visitor) const {
- return visitor->visit(this);
+MangleError VectorType::accept(TypeVisitor *Visitor) const {
+ return Visitor->visit(this);
}
std::string VectorType::toString() const {
- std::stringstream myName;
- myName << getScalarType()->toString();
- myName << Len;
- return myName.str();
+ std::stringstream MyName;
+ MyName << getScalarType()->toString();
+ MyName << Len;
+ return MyName.str();
}
-bool VectorType::equals(const ParamType *type) const {
- const VectorType *pVec = SPIR::dyn_cast<VectorType>(type);
- return pVec && (Len == pVec->Len) &&
- (*getScalarType()).equals(&*(pVec->getScalarType()));
+bool VectorType::equals(const ParamType *Type) const {
+ const VectorType *PVec = SPIR::dynCast<VectorType>(Type);
+ return PVec && (Len == PVec->Len) &&
+ (*getScalarType()).equals(&*(PVec->getScalarType()));
}
//
// Atomic Type
//
-AtomicType::AtomicType(const RefParamType type)
- : ParamType(TYPE_ID_ATOMIC), PType(type) {}
+AtomicType::AtomicType(const RefParamType Type)
+ : ParamType(TYPE_ID_ATOMIC), PType(Type) {}
-MangleError AtomicType::accept(TypeVisitor *visitor) const {
- if (visitor->spirVer < SPIR20) {
+MangleError AtomicType::accept(TypeVisitor *Visitor) const {
+ if (Visitor->SpirVer < SPIR20) {
return MANGLE_TYPE_NOT_SUPPORTED;
}
- return visitor->visit(this);
+ return Visitor->visit(this);
}
std::string AtomicType::toString() const {
- std::stringstream myName;
- myName << "atomic_" << getBaseType()->toString();
- return myName.str();
+ std::stringstream MyName;
+ MyName << "atomic_" << getBaseType()->toString();
+ return MyName.str();
}
-bool AtomicType::equals(const ParamType *type) const {
- const AtomicType *a = dyn_cast<AtomicType>(type);
- return (a && (*getBaseType()).equals(&*(a->getBaseType())));
+bool AtomicType::equals(const ParamType *Type) const {
+ const AtomicType *A = dynCast<AtomicType>(Type);
+ return (A && (*getBaseType()).equals(&*(A->getBaseType())));
}
//
@@ -170,32 +168,32 @@ bool AtomicType::equals(const ParamType *type) const {
BlockType::BlockType() : ParamType(TYPE_ID_BLOCK) {}
-MangleError BlockType::accept(TypeVisitor *visitor) const {
- if (visitor->spirVer < SPIR20) {
+MangleError BlockType::accept(TypeVisitor *Visitor) const {
+ if (Visitor->SpirVer < SPIR20) {
return MANGLE_TYPE_NOT_SUPPORTED;
}
- return visitor->visit(this);
+ return Visitor->visit(this);
}
std::string BlockType::toString() const {
- std::stringstream myName;
- myName << "void (";
- for (unsigned int i = 0; i < getNumOfParams(); ++i) {
- if (i > 0)
- myName << ", ";
- myName << Params[i]->toString();
+ std::stringstream MyName;
+ MyName << "void (";
+ for (unsigned int I = 0; I < getNumOfParams(); ++I) {
+ if (I > 0)
+ MyName << ", ";
+ MyName << Params[I]->toString();
}
- myName << ")*";
- return myName.str();
+ MyName << ")*";
+ return MyName.str();
}
-bool BlockType::equals(const ParamType *type) const {
- const BlockType *pBlock = dyn_cast<BlockType>(type);
- if (!pBlock || getNumOfParams() != pBlock->getNumOfParams()) {
+bool BlockType::equals(const ParamType *Type) const {
+ const BlockType *PBlock = dynCast<BlockType>(Type);
+ if (!PBlock || getNumOfParams() != PBlock->getNumOfParams()) {
return false;
}
- for (unsigned int i = 0; i < getNumOfParams(); ++i) {
- if (!getParam(i)->equals(&*pBlock->getParam(i))) {
+ for (unsigned int I = 0; I < getNumOfParams(); ++I) {
+ if (!getParam(I)->equals(&*PBlock->getParam(I))) {
return false;
}
}
@@ -205,32 +203,32 @@ bool BlockType::equals(const ParamType *type) const {
//
// User Defined Type
//
-UserDefinedType::UserDefinedType(const std::string &name)
- : ParamType(TYPE_ID_STRUCTURE), Name(name) {}
+UserDefinedType::UserDefinedType(const std::string &Name)
+ : ParamType(TYPE_ID_STRUCTURE), Name(Name) {}
-MangleError UserDefinedType::accept(TypeVisitor *visitor) const {
- return visitor->visit(this);
+MangleError UserDefinedType::accept(TypeVisitor *Visitor) const {
+ return Visitor->visit(this);
}
std::string UserDefinedType::toString() const {
- std::stringstream myName;
- myName << Name;
- return myName.str();
+ std::stringstream MyName;
+ MyName << Name;
+ return MyName.str();
}
-bool UserDefinedType::equals(const ParamType *pType) const {
- const UserDefinedType *pTy = SPIR::dyn_cast<UserDefinedType>(pType);
- return pTy && (Name == pTy->Name);
+bool UserDefinedType::equals(const ParamType *PType) const {
+ const UserDefinedType *PTy = SPIR::dynCast<UserDefinedType>(PType);
+ return PTy && (Name == PTy->Name);
}
//
// Static enums
//
-const TypeEnum PrimitiveType::enumTy = TYPE_ID_PRIMITIVE;
-const TypeEnum PointerType::enumTy = TYPE_ID_POINTER;
-const TypeEnum VectorType::enumTy = TYPE_ID_VECTOR;
-const TypeEnum AtomicType::enumTy = TYPE_ID_ATOMIC;
-const TypeEnum BlockType::enumTy = TYPE_ID_BLOCK;
-const TypeEnum UserDefinedType::enumTy = TYPE_ID_STRUCTURE;
+const TypeEnum PrimitiveType::EnumTy = TYPE_ID_PRIMITIVE;
+const TypeEnum PointerType::EnumTy = TYPE_ID_POINTER;
+const TypeEnum VectorType::EnumTy = TYPE_ID_VECTOR;
+const TypeEnum AtomicType::EnumTy = TYPE_ID_ATOMIC;
+const TypeEnum BlockType::EnumTy = TYPE_ID_BLOCK;
+const TypeEnum UserDefinedType::EnumTy = TYPE_ID_STRUCTURE;
} // namespace SPIR
diff --git a/lib/SPIRV/Mangler/ParameterType.h b/lib/SPIRV/Mangler/ParameterType.h
index b3ed4a1..38b50e6 100644
--- a/lib/SPIRV/Mangler/ParameterType.h
+++ b/lib/SPIRV/Mangler/ParameterType.h
@@ -114,7 +114,7 @@ struct TypeVisitor;
struct ParamType {
/// @brief Constructor.
/// @param TypeEnum type id.
- ParamType(TypeEnum typeId) : TypeId(typeId){};
+ ParamType(TypeEnum TypeId) : TypeId(TypeId){};
/// @brief Destructor.
virtual ~ParamType(){};
@@ -154,7 +154,7 @@ protected:
struct PrimitiveType : public ParamType {
/// An enumeration to identify the type id of this class.
- const static TypeEnum enumTy;
+ const static TypeEnum EnumTy;
/// @brief Constructor.
/// @param TypePrimitiveEnum primitive id.
@@ -191,11 +191,11 @@ protected:
struct PointerType : public ParamType {
/// An enumeration to identify the type id of this class.
- const static TypeEnum enumTy;
+ const static TypeEnum EnumTy;
/// @brief Constructor.
/// @param RefParamType the type of pointee (that the pointer points at).
- PointerType(const RefParamType type);
+ PointerType(const RefParamType Type);
/// Implementation of Abstract Methods ///
@@ -223,7 +223,7 @@ struct PointerType : public ParamType {
/// @brief Sets the address space attribute - default is __private
/// @param TypeAttributeEnum address space attribute id.
- void setAddressSpace(TypeAttributeEnum attr);
+ void setAddressSpace(TypeAttributeEnum Attr);
/// @brief Returns the pointer's address space.
/// @return pointer's address space.
@@ -233,12 +233,12 @@ struct PointerType : public ParamType {
/// @param TypeAttributeEnum qual - qualifier to add/remove.
/// @param bool enabled - true if qualifier should exist false otherwise.
/// default is set to false.
- void setQualifier(TypeAttributeEnum qual, bool enabled);
+ void setQualifier(TypeAttributeEnum Qual, bool Enabled);
/// @brief Checks if the pointer has a certain qualifier.
/// @param TypeAttributeEnum qual - qualifier to check.
/// @return true if the qualifier exists and false otherwise.
- bool hasQualifier(TypeAttributeEnum qual) const;
+ bool hasQualifier(TypeAttributeEnum Qual) const;
private:
/// The type this pointer is pointing at.
@@ -246,17 +246,17 @@ private:
/// Array of the pointer's enabled type qualifiers.
bool Qualifiers[ATTR_QUALIFIER_LAST - ATTR_QUALIFIER_FIRST + 1];
/// Pointer's address space.
- TypeAttributeEnum Address_space;
+ TypeAttributeEnum AddressSpace;
};
struct VectorType : public ParamType {
/// An enumeration to identify the type id of this class.
- const static TypeEnum enumTy;
+ const static TypeEnum EnumTy;
/// @brief Constructor.
/// @param RefParamType the type of each scalar element in the vector.
/// @param int the length of the vector.
- VectorType(const RefParamType type, int len);
+ VectorType(const RefParamType Type, int Len);
/// Implementation of Abstract Methods ///
@@ -295,11 +295,11 @@ private:
struct AtomicType : public ParamType {
/// an enumeration to identify the type id of this class
- const static TypeEnum enumTy;
+ const static TypeEnum EnumTy;
/// @brief Constructor
/// @param RefParamType the type refernced as atomic.
- AtomicType(const RefParamType type);
+ AtomicType(const RefParamType Type);
/// Implementation of Abstract Methods ///
@@ -331,7 +331,7 @@ private:
struct BlockType : public ParamType {
/// an enumeration to identify the type id of this class
- const static TypeEnum enumTy;
+ const static TypeEnum EnumTy;
///@brief Constructor
BlockType();
@@ -362,19 +362,19 @@ struct BlockType : public ParamType {
///@brief returns the type of parameter "index" of the block.
// @param index the sequential number of the queried parameter
///@return parameter type
- const RefParamType &getParam(unsigned int index) const {
- assert(Params.size() > index && "index is OOB");
- return Params[index];
+ const RefParamType &getParam(unsigned int Index) const {
+ assert(Params.size() > Index && "index is OOB");
+ return Params[Index];
}
///@brief set the type of parameter "index" of the block.
// @param index the sequential number of the queried parameter
// @param type the parameter type
- void setParam(unsigned int index, RefParamType type) {
- if (index < getNumOfParams()) {
- Params[index] = type;
- } else if (index == getNumOfParams()) {
- Params.push_back(type);
+ void setParam(unsigned int Index, RefParamType Type) {
+ if (Index < getNumOfParams()) {
+ Params[Index] = Type;
+ } else if (Index == getNumOfParams()) {
+ Params.push_back(Type);
} else {
assert(false && "index is OOB");
}
@@ -387,7 +387,7 @@ protected:
struct UserDefinedType : public ParamType {
/// An enumeration to identify the type id of this class.
- const static TypeEnum enumTy;
+ const static TypeEnum EnumTy;
/// @brief Constructor.
UserDefinedType(const std::string &);
@@ -418,8 +418,8 @@ protected:
/// @brief Can be overridden so an object of static type Type* will
/// dispatch the correct visit method according to its dynamic type.
struct TypeVisitor {
- SPIRversion spirVer;
- TypeVisitor(SPIRversion ver) : spirVer(ver) {}
+ SPIRversion SpirVer;
+ TypeVisitor(SPIRversion Ver) : SpirVer(Ver) {}
virtual ~TypeVisitor() {}
virtual MangleError visit(const PrimitiveType *) = 0;
virtual MangleError visit(const VectorType *) = 0;
@@ -433,9 +433,9 @@ struct TypeVisitor {
/// @param ParamType given param type.
/// @return required casting type if given param type is an instance if
// that type, NULL otherwise.
-template <typename T> T *dyn_cast(ParamType *pType) {
- assert(pType && "dyn_cast does not support casting of NULL");
- return (T::enumTy == pType->getTypeId()) ? (T *)pType : NULL;
+template <typename T> T *dynCast(ParamType *PType) {
+ assert(PType && "dyn_cast does not support casting of NULL");
+ return (T::EnumTy == PType->getTypeId()) ? (T *)PType : NULL;
}
/// @brief Template dynamic cast function for ParamType derived classes
@@ -443,9 +443,9 @@ template <typename T> T *dyn_cast(ParamType *pType) {
/// @param ParamType given param type.
/// @return required casting type if given param type is an instance if
// that type, NULL otherwise.
-template <typename T> const T *dyn_cast(const ParamType *pType) {
- assert(pType && "dyn_cast does not support casting of NULL");
- return (T::enumTy == pType->getTypeId()) ? (const T *)pType : NULL;
+template <typename T> const T *dynCast(const ParamType *PType) {
+ assert(PType && "dyn_cast does not support casting of NULL");
+ return (T::EnumTy == PType->getTypeId()) ? (const T *)PType : NULL;
}
} // namespace SPIR
diff --git a/lib/SPIRV/Mangler/Refcount.h b/lib/SPIRV/Mangler/Refcount.h
index 43a9393..56e01d6 100644
--- a/lib/SPIRV/Mangler/Refcount.h
+++ b/lib/SPIRV/Mangler/Refcount.h
@@ -21,29 +21,29 @@ template <typename T> class RefCount {
public:
RefCount() : Count(0), Ptr(0) {}
- RefCount(T *ptr) : Ptr(ptr) { Count = new int(1); }
+ RefCount(T *Ptr) : Ptr(Ptr) { Count = new int(1); }
- RefCount(const RefCount<T> &other) { cpy(other); }
+ RefCount(const RefCount<T> &Other) { cpy(Other); }
~RefCount() {
if (Count)
dispose();
}
- RefCount &operator=(const RefCount<T> &other) {
- if (this == &other)
+ RefCount &operator=(const RefCount<T> &Other) {
+ if (this == &Other)
return *this;
if (Count)
dispose();
- cpy(other);
+ cpy(Other);
return *this;
}
- void init(T *ptr) {
+ void init(T *Ptr) {
assert(!Ptr && "overrunning non NULL pointer");
assert(!Count && "overrunning non NULL pointer");
Count = new int(1);
- Ptr = ptr;
+ this->Ptr = Ptr;
}
bool isNull() const { return (!Ptr); }
@@ -74,9 +74,9 @@ private:
assert(*Count && "zero ref counter");
}
- void cpy(const RefCount<T> &other) {
- Count = other.Count;
- Ptr = other.Ptr;
+ void cpy(const RefCount<T> &Other) {
+ Count = Other.Count;
+ Ptr = Other.Ptr;
if (Count)
++*Count;
}
diff --git a/lib/SPIRV/OCL20ToSPIRV.cpp b/lib/SPIRV/OCL20ToSPIRV.cpp
index 469ef3b..050f68c 100644
--- a/lib/SPIRV/OCL20ToSPIRV.cpp
+++ b/lib/SPIRV/OCL20ToSPIRV.cpp
@@ -526,8 +526,8 @@ void OCL20ToSPIRV::visitCallInst(CallInst &CI) {
void OCL20ToSPIRV::visitCallNDRange(CallInst *CI,
const std::string &DemangledName) {
assert(DemangledName.find(kOCLBuiltinName::NDRangePrefix) == 0);
- std::string lenStr = DemangledName.substr(8, 1);
- auto Len = atoi(lenStr.c_str());
+ std::string LenStr = DemangledName.substr(8, 1);
+ auto Len = atoi(LenStr.c_str());
assert(Len >= 1 && Len <= 3);
// SPIR-V ndrange structure requires 3 members in the following order:
// global work offset
@@ -566,7 +566,7 @@ void OCL20ToSPIRV::visitCallNDRange(CallInst *CI,
// Translate ndrange_ND into differently named SPIR-V decorated
// functions because they have array arugments of different dimension
// which mangled the same way.
- return getSPIRVFuncName(OpBuildNDRange, "_" + lenStr + "D");
+ return getSPIRVFuncName(OpBuildNDRange, "_" + LenStr + "D");
},
&Attrs);
}
@@ -803,10 +803,10 @@ void OCL20ToSPIRV::transAtomicBuiltin(CallInst *CI, OCLBuiltinTransInfo &Info) {
// For atomic_compare_exchange the swap above puts Comparator/Expected
// argument just where it should be, so don't move the last argument
// then.
- int offset =
+ int Offset =
Info.UniqName.find("atomic_compare_exchange") == 0 ? 1 : 0;
std::rotate(Args.begin() + 2, Args.begin() + OrderIdx,
- Args.end() - offset);
+ Args.end() - Offset);
}
return getSPIRVFuncName(OCLSPIRVBuiltinMap::map(Info.UniqName));
},
@@ -903,7 +903,7 @@ void OCL20ToSPIRV::visitCallGroupBuiltin(CallInst *CI, StringRef MangledName,
if (DemangledName != kOCLBuiltinName::WaitGroupEvent) {
StringRef GroupOp = DemangledName;
GroupOp = GroupOp.drop_front(strlen(kSPIRVName::GroupPrefix));
- SPIRSPIRVGroupOperationMap::foreach_conditional(
+ SPIRSPIRVGroupOperationMap::foreachConditional(
[&](const std::string &S, SPIRVGroupOperationKind G) {
if (!GroupOp.startswith(S))
return true; // continue
@@ -987,7 +987,7 @@ void OCL20ToSPIRV::transBuiltin(CallInst *CI, OCLBuiltinTransInfo &Info) {
[=](CallInst *NewCI) -> Instruction * {
if (NewCI->getType()->isIntegerTy() && CI->getType()->isIntegerTy())
return CastInst::CreateIntegerCast(NewCI, CI->getType(),
- Info.isRetSigned, "", CI);
+ Info.IsRetSigned, "", CI);
else
return CastInst::CreatePointerBitCastOrAddrSpaceCast(
NewCI, CI->getType(), "", CI);
@@ -1028,7 +1028,7 @@ void OCL20ToSPIRV::visitCallReadImageWithSampler(
CallInst *CI, StringRef MangledName, const std::string &DemangledName) {
assert(MangledName.find(kMangledName::Sampler) != StringRef::npos);
AttributeList Attrs = CI->getCalledFunction()->getAttributes();
- bool isRetScalar = !CI->getType()->isVectorTy();
+ bool IsRetScalar = !CI->getType()->isVectorTy();
mutateCallInstSPIRV(
M, CI,
[=](CallInst *, std::vector<Value *> &Args, Type *&Ret) {
@@ -1063,14 +1063,14 @@ void OCL20ToSPIRV::visitCallReadImageWithSampler(
}
// SPIR-V intruction always returns 4-element vector
- if (isRetScalar)
+ if (IsRetScalar)
Ret = VectorType::get(Ret, 4);
return getSPIRVFuncName(OpImageSampleExplicitLod,
std::string(kSPIRVPostfix::ExtDivider) +
getPostfixForReturnType(Ret));
},
[&](CallInst *CI) -> Instruction * {
- if (isRetScalar)
+ if (IsRetScalar)
return ExtractElementInst::Create(CI, getSizet(M, 0), "",
CI->getNextNode());
return CI;
@@ -1122,9 +1122,9 @@ void OCL20ToSPIRV::visitCallGetImageSize(CallInst *CI, StringRef MangledName,
} else if (Desc.Dim == Dim2D && Desc.Arrayed) {
Constant *Index[] = {getInt32(M, 0), getInt32(M, 1)};
- Constant *mask = ConstantVector::get(Index);
+ Constant *Mask = ConstantVector::get(Index);
return new ShuffleVectorInst(NCI, UndefValue::get(NCI->getType()),
- mask, NCI->getName(), CI);
+ Mask, NCI->getName(), CI);
}
return NCI;
}
@@ -1501,9 +1501,9 @@ void OCL20ToSPIRV::visitSubgroupBlockWriteINTEL(
Info.UniqName = getSPIRVFuncName(spv::OpSubgroupImageBlockWriteINTEL);
else
Info.UniqName = getSPIRVFuncName(spv::OpSubgroupBlockWriteINTEL);
- unsigned numArgs = CI->getNumArgOperands();
- if (numArgs && CI->getArgOperand(numArgs - 1)->getType()->isVectorTy()) {
- switch (CI->getArgOperand(numArgs - 1)->getType()->getVectorNumElements()) {
+ unsigned NumArgs = CI->getNumArgOperands();
+ if (NumArgs && CI->getArgOperand(NumArgs - 1)->getType()->isVectorTy()) {
+ switch (CI->getArgOperand(NumArgs - 1)->getType()->getVectorNumElements()) {
case 2:
Info.Postfix = "_v2";
break;
diff --git a/lib/SPIRV/OCLUtil.cpp b/lib/SPIRV/OCLUtil.cpp
index f2dd4e3..cd0b84c 100644
--- a/lib/SPIRV/OCLUtil.cpp
+++ b/lib/SPIRV/OCLUtil.cpp
@@ -117,15 +117,15 @@ BarrierLiterals getBarrierLiterals(CallInst *CI) {
"call must a builtin (work_group_barrier or sub_group_barrier)");
}
- OCLScopeKind scope = OCLMS_work_group;
+ OCLScopeKind Scope = OCLMS_work_group;
if (DemangledName == kOCLBuiltinName::SubGroupBarrier) {
- scope = OCLMS_sub_group;
+ Scope = OCLMS_sub_group;
}
return std::make_tuple(getArgAsInt(CI, 0),
N == 1 ? OCLMS_work_group
: static_cast<OCLScopeKind>(getArgAsInt(CI, 1)),
- scope);
+ Scope);
}
unsigned getExtOp(StringRef OrigName, const std::string &GivenDemangledName) {
@@ -137,7 +137,7 @@ unsigned getExtOp(StringRef OrigName, const std::string &GivenDemangledName) {
bool Found = OCLExtOpMap::rfind(DemangledName, &EOC);
if (!Found) {
std::string Prefix;
- switch (LastFuncParamType(OrigName)) {
+ switch (lastFuncParamType(OrigName)) {
case ParamType::UNSIGNED:
Prefix = "u_";
break;
@@ -166,7 +166,7 @@ std::unique_ptr<SPIRVEntry> getSPIRVInst(const OCLBuiltinTransInfo &Info) {
Entry = SPIRVEntry::create(OC);
else if ((ExtOp = getExtOp(Info.MangledName, Info.UniqName)) != ~0U)
Entry = static_cast<SPIRVEntry *>(
- SPIRVEntry::create_unique(SPIRVEIS_OpenCL, ExtOp).get());
+ SPIRVEntry::createUnique(SPIRVEIS_OpenCL, ExtOp).get());
return std::unique_ptr<SPIRVEntry>(Entry);
}
@@ -199,13 +199,13 @@ unsigned getOCLVersion(Module *M, bool AllowMulti) {
// If the module was linked with another module, there may be multiple
// operands.
- auto getVer = [=](unsigned I) {
+ auto GetVer = [=](unsigned I) {
auto MD = NamedMD->getOperand(I);
return std::make_pair(getMDOperandAsInt(MD, 0), getMDOperandAsInt(MD, 1));
};
- auto Ver = getVer(0);
+ auto Ver = GetVer(0);
for (unsigned I = 1, E = NamedMD->getNumOperands(); I != E; ++I)
- if (Ver != getVer(I))
+ if (Ver != GetVer(I))
report_fatal_error("OCL version mismatch");
return encodeOCLVer(Ver.first, Ver.second, 0);
@@ -227,8 +227,8 @@ unsigned encodeVecTypeHint(Type *Ty) {
return 5;
if (Ty->isDoubleTy())
return 6;
- if (IntegerType *intTy = dyn_cast<IntegerType>(Ty)) {
- switch (intTy->getIntegerBitWidth()) {
+ if (IntegerType *IntTy = dyn_cast<IntegerType>(Ty)) {
+ switch (IntTy->getIntegerBitWidth()) {
case 8:
return 0;
case 16:
@@ -249,9 +249,9 @@ unsigned encodeVecTypeHint(Type *Ty) {
llvm_unreachable("invalid type");
}
-Type *decodeVecTypeHint(LLVMContext &C, unsigned code) {
- unsigned VecWidth = code >> 16;
- unsigned Scalar = code & 0xFFFF;
+Type *decodeVecTypeHint(LLVMContext &C, unsigned Code) {
+ unsigned VecWidth = Code >> 16;
+ unsigned Scalar = Code & 0xFFFF;
Type *ST = nullptr;
switch (Scalar) {
case 0:
@@ -303,8 +303,8 @@ SPIRAddressSpace getOCLOpaqueTypeAddrSpace(Op OpCode) {
}
}
-static SPIR::TypeAttributeEnum mapAddrSpaceEnums(SPIRAddressSpace addrspace) {
- switch (addrspace) {
+static SPIR::TypeAttributeEnum mapAddrSpaceEnums(SPIRAddressSpace Addrspace) {
+ switch (Addrspace) {
case SPIRAS_Private:
return SPIR::ATTR_PRIVATE;
case SPIRAS_Global:
@@ -321,8 +321,8 @@ static SPIR::TypeAttributeEnum mapAddrSpaceEnums(SPIRAddressSpace addrspace) {
}
SPIR::TypeAttributeEnum
-getOCLOpaqueTypeAddrSpace(SPIR::TypePrimitiveEnum prim) {
- switch (prim) {
+getOCLOpaqueTypeAddrSpace(SPIR::TypePrimitiveEnum Prim) {
+ switch (Prim) {
case SPIR::PRIMITIVE_QUEUE_T:
return mapAddrSpaceEnums(SPIRV_QUEUE_T_ADDR_SPACE);
case SPIR::PRIMITIVE_EVENT_T:
@@ -352,15 +352,15 @@ getOCLOpaqueTypeAddrSpace(SPIR::TypePrimitiveEnum prim) {
}
// Fetch type of invoke function passed to device execution built-ins
-static FunctionType *getBlockInvokeTy(Function *F, unsigned blockIdx) {
- auto params = F->getFunctionType()->params();
- PointerType *funcPtr = cast<PointerType>(params[blockIdx]);
- return cast<FunctionType>(funcPtr->getElementType());
+static FunctionType *getBlockInvokeTy(Function *F, unsigned BlockIdx) {
+ auto Params = F->getFunctionType()->params();
+ PointerType *FuncPtr = cast<PointerType>(Params[BlockIdx]);
+ return cast<FunctionType>(FuncPtr->getElementType());
}
class OCLBuiltinFuncMangleInfo : public SPIRV::BuiltinFuncMangleInfo {
public:
- OCLBuiltinFuncMangleInfo(Function *f) : F(f) {}
+ OCLBuiltinFuncMangleInfo(Function *F) : F(F) {}
void init(const std::string &UniqName) override {
UnmangledName = UniqName;
size_t Pos = std::string::npos;
@@ -377,10 +377,10 @@ public:
UnmangledName ==
"get_kernel_preferred_work_group_size_multiple") {
assert(F && "lack of necessary information");
- const size_t blockArgIdx = 0;
- FunctionType *InvokeTy = getBlockInvokeTy(F, blockArgIdx);
+ const size_t BlockArgIdx = 0;
+ FunctionType *InvokeTy = getBlockInvokeTy(F, BlockArgIdx);
if (InvokeTy->getNumParams() > 1)
- setLocalArgBlock(blockArgIdx);
+ setLocalArgBlock(BlockArgIdx);
} else if (UnmangledName == "enqueue_kernel") {
assert(F && "lack of necessary information");
setEnumArg(1, SPIR::PRIMITIVE_KERNEL_ENQUEUE_FLAGS_T);
@@ -388,12 +388,12 @@ public:
setArgAttr(4, SPIR::ATTR_CONST);
// If there are arguments other then block context then these are pointers
// to local memory so this built-in must be mangled accordingly.
- const size_t blockArgIdx = 6;
- FunctionType *InvokeTy = getBlockInvokeTy(F, blockArgIdx);
+ const size_t BlockArgIdx = 6;
+ FunctionType *InvokeTy = getBlockInvokeTy(F, BlockArgIdx);
if (InvokeTy->getNumParams() > 1) {
- setLocalArgBlock(blockArgIdx);
- addUnsignedArg(blockArgIdx + 1);
- setVarArg(blockArgIdx + 2);
+ setLocalArgBlock(BlockArgIdx);
+ addUnsignedArg(BlockArgIdx + 1);
+ setVarArg(BlockArgIdx + 2);
}
} else if (UnmangledName.find("get_") == 0 || UnmangledName == "nan" ||
UnmangledName == "mem_fence" ||
@@ -607,7 +607,7 @@ bool isSpecialTypeInitializer(Instruction *Inst) {
} // namespace OCLUtil
-void llvm::MangleOpenCLBuiltin(const std::string &UniqName,
+void llvm::mangleOpenClBuiltin(const std::string &UniqName,
ArrayRef<Type *> ArgTypes,
std::string &MangledName) {
OCLUtil::OCLBuiltinFuncMangleInfo BtnInfo(nullptr);
diff --git a/lib/SPIRV/OCLUtil.h b/lib/SPIRV/OCLUtil.h
index 33d0db3..4ac4b5a 100644
--- a/lib/SPIRV/OCLUtil.h
+++ b/lib/SPIRV/OCLUtil.h
@@ -120,9 +120,9 @@ struct OCLBuiltinTransInfo {
/// Postprocessor of operands
std::function<void(std::vector<Value *> &)> PostProc;
Type *RetTy; // Return type of the translated function
- bool isRetSigned; // When RetTy is int, determines if extensions
+ bool IsRetSigned; // When RetTy is int, determines if extensions
// on it should be a sext or zet.
- OCLBuiltinTransInfo() : RetTy(nullptr), isRetSigned(false) {
+ OCLBuiltinTransInfo() : RetTy(nullptr), IsRetSigned(false) {
PostProc = [](std::vector<Value *> &) {};
}
};
@@ -310,10 +310,10 @@ void decodeMDNode(MDNode *N, unsigned &X, unsigned &Y, unsigned &Z);
unsigned transVecTypeHint(MDNode *Node);
/// Decode SPIR-V encoding of vector type hint execution mode.
-Type *decodeVecTypeHint(LLVMContext &C, unsigned code);
+Type *decodeVecTypeHint(LLVMContext &C, unsigned Code);
SPIRAddressSpace getOCLOpaqueTypeAddrSpace(Op OpCode);
-SPIR::TypeAttributeEnum getOCLOpaqueTypeAddrSpace(SPIR::TypePrimitiveEnum prim);
+SPIR::TypeAttributeEnum getOCLOpaqueTypeAddrSpace(SPIR::TypePrimitiveEnum Prim);
inline unsigned mapOCLMemSemanticToSPIRV(unsigned MemFenceFlag,
OCLMemOrderKind Order) {
diff --git a/lib/SPIRV/SPIRVInternal.h b/lib/SPIRV/SPIRVInternal.h
index 9e75e84..1f2ebe7 100644
--- a/lib/SPIRV/SPIRVInternal.h
+++ b/lib/SPIRV/SPIRVInternal.h
@@ -62,7 +62,7 @@ namespace SPIRV {
/// The LLVM/SPIR-V translator version used to fill the lower 16 bits of the
/// generator's magic number in the generated SPIR-V module.
/// This number should be bumped up whenever the generated SPIR-V changes.
-const static unsigned short kTranslatorVer = 14;
+const static unsigned short KTranslatorVer = 14;
#define SPCV_TARGET_LLVM_IMAGE_TYPE_ENCODE_ACCESS_QUAL 0
// Workaround for SPIR 2 producer bug about kernel function calling convention.
@@ -485,19 +485,19 @@ template <class T> std::vector<Type *> getTypes(T V) {
/// Move elements of std::vector from [begin, end) to target.
template <typename T>
-void move(std::vector<T> &V, size_t begin, size_t end, size_t target) {
- assert(begin < end && end <= V.size() && target <= V.size() &&
- !(begin < target && target < end));
- if (begin <= target && target <= end)
+void move(std::vector<T> &V, size_t Begin, size_t End, size_t Target) {
+ assert(Begin < End && End <= V.size() && Target <= V.size() &&
+ !(Begin < Target && Target < End));
+ if (Begin <= Target && Target <= End)
return;
- auto B = V.begin() + begin, E = V.begin() + end;
- if (target > V.size())
- target = V.size();
- if (target > end)
- target -= (end - begin);
+ auto B = V.begin() + Begin, E = V.begin() + End;
+ if (Target > V.size())
+ Target = V.size();
+ if (Target > End)
+ Target -= (End - Begin);
std::vector<T> Segment(B, E);
V.erase(B, E);
- V.insert(V.begin() + target, Segment.begin(), Segment.end());
+ V.insert(V.begin() + Target, Segment.begin(), Segment.end());
}
/// Find position of first pointer type value in a vector.
@@ -531,7 +531,7 @@ Function *getOrCreateFunction(Module *M, Type *RetTy, ArrayRef<Type *> ArgTypes,
StringRef Name,
BuiltinFuncMangleInfo *Mangle = nullptr,
AttributeList *Attrs = nullptr,
- bool takeName = true);
+ bool TakeName = true);
/// Get function call arguments.
/// \param Start Starting index.
@@ -582,7 +582,7 @@ bool isDecoratedSPIRVFunc(const Function *F, std::string *UndecName = nullptr);
/// Get a canonical function name for a SPIR-V op code.
std::string getSPIRVFuncName(Op OC, StringRef PostFix = "");
-std::string getSPIRVFuncName(Op OC, const Type *pRetTy, bool IsSigned = false);
+std::string getSPIRVFuncName(Op OC, const Type *PRetTy, bool IsSigned = false);
/// Get a canonical function name for a SPIR-V extended instruction
std::string getSPIRVExtFuncName(SPIRVExtInstSetKind Set, unsigned ExtOp,
@@ -608,7 +608,7 @@ bool getSPIRVBuiltin(const std::string &Name, spv::BuiltIn &Builtin);
/// \returns true if Name is the name of the OpenCL built-in function,
/// false for other functions
bool oclIsBuiltin(const StringRef &Name, std::string *DemangledName = nullptr,
- bool isCPP = false);
+ bool IsCpp = false);
/// Check if a function type is void(void).
bool isVoidFuncTy(FunctionType *FT);
@@ -630,7 +630,7 @@ CallInst *mutateCallInst(
Module *M, CallInst *CI,
std::function<std::string(CallInst *, std::vector<Value *> &)> ArgMutate,
BuiltinFuncMangleInfo *Mangle = nullptr, AttributeList *Attrs = nullptr,
- bool takeName = false);
+ bool TakeName = false);
/// Mutates function call instruction by changing the arguments and return
/// value.
@@ -643,7 +643,7 @@ Instruction *mutateCallInst(
ArgMutate,
std::function<Instruction *(CallInst *)> RetMutate,
BuiltinFuncMangleInfo *Mangle = nullptr, AttributeList *Attrs = nullptr,
- bool takeName = false);
+ bool TakeName = false);
/// Mutate call instruction to call SPIR-V builtin function.
CallInst *mutateCallInstSPIRV(
@@ -714,25 +714,25 @@ Type *getVoidFuncType(Module *M);
Type *getVoidFuncPtrType(Module *M, unsigned AddrSpace = 0);
/// Get a 64 bit integer constant.
-ConstantInt *getInt64(Module *M, int64_t value);
+ConstantInt *getInt64(Module *M, int64_t Value);
/// Get a 32 bit integer constant.
-ConstantInt *getInt32(Module *M, int value);
+ConstantInt *getInt32(Module *M, int Value);
/// Get a 32 bit unsigned integer constant.
-ConstantInt *getUInt32(Module *M, unsigned value);
+ConstantInt *getUInt32(Module *M, unsigned Value);
/// Get a 16 bit unsigned integer constant.
-ConstantInt *getUInt16(Module *M, unsigned short value);
+ConstantInt *getUInt16(Module *M, unsigned short Value);
// Get a 32 bit floating point constant.
-Constant *getFloat32(Module *M, float value);
+Constant *getFloat32(Module *M, float Value);
/// Get a 32 bit integer constant vector.
-std::vector<Value *> getInt32(Module *M, const std::vector<int> &value);
+std::vector<Value *> getInt32(Module *M, const std::vector<int> &Value);
/// Get a size_t type constant.
-ConstantInt *getSizet(Module *M, uint64_t value);
+ConstantInt *getSizet(Module *M, uint64_t Value);
/// Get metadata operand as int.
int getMDOperandAsInt(MDNode *N, unsigned I);
@@ -772,10 +772,10 @@ std::string getPostfix(Decoration Dec, unsigned Value = 0);
/// Get postfix _R{ReturnType} for return type
/// The returned postfix does not includ "_" at the beginning
std::string getPostfixForReturnType(CallInst *CI, bool IsSigned = false);
-std::string getPostfixForReturnType(const Type *pRetTy, bool IsSigned = false);
+std::string getPostfixForReturnType(const Type *PRetTy, bool IsSigned = false);
Constant *getScalarOrVectorConstantInt(Type *T, uint64_t V,
- bool isSigned = false);
+ bool IsSigned = false);
/// Get a constant int or a constant int array.
/// \param T is the type of the constant. It should be an integer type or
@@ -783,7 +783,7 @@ Constant *getScalarOrVectorConstantInt(Type *T, uint64_t V,
/// \param Len is the length of the array.
/// \param V is the value to fill the array.
Value *getScalarOrArrayConstantInt(Instruction *P, Type *T, unsigned Len,
- uint64_t V, bool isSigned = false);
+ uint64_t V, bool IsSigned = false);
/// Get the array from GEP.
/// \param V is a GEP whose pointer operand is a pointer to an array of size
@@ -853,7 +853,7 @@ bool isValidVectorSize(unsigned I);
enum class ParamType { FLOAT = 0, SIGNED = 1, UNSIGNED = 2, UNKNOWN = 3 };
-ParamType LastFuncParamType(const std::string &MangledName);
+ParamType lastFuncParamType(const std::string &MangledName);
// Check if the last function parameter is signed
bool isLastFuncParamSigned(const std::string &MangledName);
diff --git a/lib/SPIRV/SPIRVLowerOCLBlocks.cpp b/lib/SPIRV/SPIRVLowerOCLBlocks.cpp
index fa9fb43..5748801 100644
--- a/lib/SPIRV/SPIRVLowerOCLBlocks.cpp
+++ b/lib/SPIRV/SPIRVLowerOCLBlocks.cpp
@@ -109,8 +109,8 @@ public:
lowerBlockBind();
lowerGetBlockInvoke();
lowerGetBlockContext();
- EraseUselessGlobalVars();
- EliminateDeadArgs();
+ eraseUselessGlobalVars();
+ eliminateDeadArgs();
erase(M->getFunction(SPIR_INTRINSIC_GET_BLOCK_INVOKE));
erase(M->getFunction(SPIR_INTRINSIC_GET_BLOCK_CONTEXT));
erase(M->getFunction(SPIR_INTRINSIC_BLOCK_BIND));
@@ -141,7 +141,7 @@ private:
}
bool eraseUselessFunctions() {
- bool changed = false;
+ bool Changed = false;
for (auto I = M->begin(), E = M->end(); I != E;) {
Function *F = &(*I++);
if (!GlobalValue::isInternalLinkage(F->getLinkage()) &&
@@ -154,7 +154,7 @@ private:
if (auto CE = dyn_cast<ConstantExpr>(U)) {
if (CE->use_empty()) {
CE->dropAllReferences();
- changed = true;
+ Changed = true;
}
}
}
@@ -171,9 +171,9 @@ private:
}
erase(F);
- changed = true;
+ Changed = true;
}
- return changed;
+ return Changed;
}
void lowerGetBlockInvoke() {
@@ -198,7 +198,7 @@ private:
/// Lower calls of spir_block_bind.
/// Return true if the Module is changed.
bool lowerBlockBind(Function *BlockBindFunc) {
- bool changed = false;
+ bool Changed = false;
for (auto I = BlockBindFunc->user_begin(), E = BlockBindFunc->user_end();
I != E;) {
DEBUG(dbgs() << "[lowerBlockBind] " << **I << '\n');
@@ -217,7 +217,7 @@ private:
SPIRVDBG(dbgs() << " Block user: " << *BlkUser << '\n');
if (auto Ret = dyn_cast<ReturnInst>(BlkUser)) {
bool Inlined = false;
- changed |= lowerReturnBlock(Ret, CallBlkBind, Inlined);
+ Changed |= lowerReturnBlock(Ret, CallBlkBind, Inlined);
if (Inlined)
return true;
} else if (auto CI = dyn_cast<CallInst>(BlkUser)) {
@@ -226,23 +226,23 @@ private:
std::string DemangledName;
if (Name == SPIR_INTRINSIC_GET_BLOCK_INVOKE) {
assert(CI->getArgOperand(0) == CallBlkBind);
- changed |= lowerGetBlockInvoke(CI, cast<Function>(InvF));
+ Changed |= lowerGetBlockInvoke(CI, cast<Function>(InvF));
} else if (Name == SPIR_INTRINSIC_GET_BLOCK_CONTEXT) {
assert(CI->getArgOperand(0) == CallBlkBind);
// Handle context_ptr = spir_get_block_context(block)
lowerGetBlockContext(CI, Ctx);
- changed = true;
+ Changed = true;
} else if (oclIsBuiltin(Name, &DemangledName)) {
lowerBlockBuiltin(CI, InvF, Ctx, CtxLen, CtxAlign, DemangledName);
- changed = true;
+ Changed = true;
} else
llvm_unreachable("Invalid block user");
}
}
erase(CallBlkBind);
}
- changed |= eraseUselessFunctions();
- return changed;
+ Changed |= eraseUselessFunctions();
+ return Changed;
}
void lowerGetBlockContext(CallInst *CallGetBlkCtx, Value *Ctx = nullptr) {
@@ -257,7 +257,7 @@ private:
bool lowerGetBlockInvoke(CallInst *CallGetBlkInvoke,
Function *InvokeF = nullptr) {
- bool changed = false;
+ bool Changed = false;
for (auto UI = CallGetBlkInvoke->user_begin(),
UE = CallGetBlkInvoke->user_end();
UI != UE;) {
@@ -279,10 +279,10 @@ private:
CI->replaceUsesOfWith(F, InvokeF);
DEBUG(dbgs() << " => " << *CI << "\n\n");
erase(Cast);
- changed = true;
+ Changed = true;
}
erase(CallGetBlkInvoke);
- return changed;
+ return Changed;
}
void lowerBlockBuiltin(CallInst *CI, Function *InvF, Value *Ctx,
@@ -326,14 +326,14 @@ private:
/// Returns true of module is changed.
bool lowerReturnBlock(ReturnInst *Ret, Value *CallBlkBind, bool &Inlined) {
auto F = Ret->getParent()->getParent();
- auto changed = false;
+ auto Changed = false;
for (auto UI = F->user_begin(), UE = F->user_end(); UI != UE;) {
auto U = *UI++;
dumpUsers(U);
auto Inst = dyn_cast<Instruction>(U);
if (Inst && Inst->use_empty()) {
erase(Inst);
- changed = true;
+ Changed = true;
continue;
}
auto CI = dyn_cast<CallInst>(U);
@@ -351,14 +351,14 @@ private:
InlineFunction(CI, IFI);
Inlined = true;
}
- return changed || Inlined;
+ return Changed || Inlined;
}
/// Looking for a global variables initialized by opencl.block*. If found,
/// check
/// its users. If users are trivially dead, erase them. If the global variable
/// has no users left after that, erase it too.
- void EraseUselessGlobalVars() {
+ void eraseUselessGlobalVars() {
std::vector<GlobalVariable *> GlobalVarsToDelete;
for (GlobalVariable &G : M->globals()) {
if (!G.hasInitializer())
@@ -424,7 +424,7 @@ private:
/// Then adjust all users/callers of the function with new arguments
/// Implementation of this function is based on
/// the dead argument elimination pass.
- void EliminateDeadArgs() {
+ void eliminateDeadArgs() {
std::vector<Function *> FunctionsToDelete;
for (Function &F : M->functions()) {
if (F.arg_size() < 1)
diff --git a/lib/SPIRV/SPIRVReader.cpp b/lib/SPIRV/SPIRVReader.cpp
index b9cf2c1..0337523 100644
--- a/lib/SPIRV/SPIRVReader.cpp
+++ b/lib/SPIRV/SPIRVReader.cpp
@@ -103,7 +103,7 @@ cl::opt<bool> SPIRVGenImgTypeAccQualPostfix(
" in OpenCL image type names"));
// Prefix for placeholder global variable name.
-const char *kPlaceholderPrefix = "placeholder.";
+const char *KPlaceholderPrefix = "placeholder.";
// Save the translated LLVM before validation for debugging purpose.
static bool DbgSaveTmpLLVM = false;
@@ -422,7 +422,7 @@ private:
auto LD = dyn_cast<LoadInst>(Loc->second);
auto Placeholder = dyn_cast<GlobalVariable>(LD->getPointerOperand());
assert(LD && Placeholder &&
- Placeholder->getName().startswith(kPlaceholderPrefix) &&
+ Placeholder->getName().startswith(KPlaceholderPrefix) &&
"A value is translated twice");
// Replaces placeholders for PHI nodes
LD->replaceAllUsesWith(V);
@@ -586,7 +586,7 @@ bool SPIRVToLLVM::transOCLBuiltinFromVariable(GlobalVariable *GV,
std::vector<Type *> ArgTy;
if (IsVec)
ArgTy.push_back(Type::getInt32Ty(*Context));
- MangleOpenCLBuiltin(FuncName, ArgTy, MangledName);
+ mangleOpenClBuiltin(FuncName, ArgTy, MangledName);
Function *Func = M->getFunction(MangledName);
if (!Func) {
FunctionType *FT = FunctionType::get(ReturnTy, ArgTy, false);
@@ -1043,13 +1043,13 @@ bool SPIRVToLLVM::postProcessOCL() {
std::string DemangledName;
SPIRVWord SrcLangVer = 0;
BM->getSourceLanguage(&SrcLangVer);
- bool isCPP = SrcLangVer == kOCLVer::CL21;
+ bool IsCpp = SrcLangVer == kOCLVer::CL21;
for (auto I = M->begin(), E = M->end(); I != E;) {
auto F = I++;
if (F->hasName() && F->isDeclaration()) {
DEBUG(dbgs() << "[postProcessOCL sret] " << *F << '\n');
if (F->getReturnType()->isStructTy() &&
- oclIsBuiltin(F->getName(), &DemangledName, isCPP)) {
+ oclIsBuiltin(F->getName(), &DemangledName, IsCpp)) {
if (!postProcessOCLBuiltinReturnStruct(&(*F)))
return false;
}
@@ -1060,7 +1060,7 @@ bool SPIRVToLLVM::postProcessOCL() {
if (F->hasName() && F->isDeclaration()) {
DEBUG(dbgs() << "[postProcessOCL array arg] " << *F << '\n');
if (hasArrayArg(&(*F)) &&
- oclIsBuiltin(F->getName(), &DemangledName, isCPP))
+ oclIsBuiltin(F->getName(), &DemangledName, IsCpp))
if (!postProcessOCLBuiltinWithArrayArguments(&(*F), DemangledName))
return false;
}
@@ -1079,12 +1079,12 @@ bool SPIRVToLLVM::postProcessOCLBuiltinReturnStruct(Function *F) {
getFunctionTypeParameterTypes(F->getFunctionType(), ArgTys);
ArgTys.insert(ArgTys.begin(),
PointerType::get(F->getReturnType(), SPIRAS_Private));
- auto newF =
+ auto NewF =
getOrCreateFunction(M, Type::getVoidTy(*Context), ArgTys, Name);
- newF->setCallingConv(F->getCallingConv());
+ NewF->setCallingConv(F->getCallingConv());
auto Args = getArguments(CI);
Args.insert(Args.begin(), ST->getPointerOperand());
- auto NewCI = CallInst::Create(newF, Args, CI->getName(), CI);
+ auto NewCI = CallInst::Create(NewF, Args, CI->getName(), CI);
NewCI->setCallingConv(CI->getCallingConv());
ST->eraseFromParent();
CI->eraseFromParent();
@@ -1127,11 +1127,11 @@ Instruction *SPIRVToLLVM::postProcessOCLReadImage(SPIRVInstruction *BI,
const std::string &FuncName) {
AttributeList Attrs = CI->getCalledFunction()->getAttributes();
StringRef ImageTypeName;
- bool isDepthImage = false;
+ bool IsDepthImage = false;
if (isOCLImageType(
(cast<CallInst>(CI->getOperand(0)))->getArgOperand(0)->getType(),
&ImageTypeName))
- isDepthImage = ImageTypeName.endswith("depth_t");
+ IsDepthImage = ImageTypeName.endswith("depth_t");
return mutateCallInstOCL(
M, CI,
[=](CallInst *, std::vector<Value *> &Args, llvm::Type *&RetTy) {
@@ -1160,12 +1160,12 @@ Instruction *SPIRVToLLVM::postProcessOCLReadImage(SPIRVInstruction *BI,
Type *T = CI->getType();
if (auto VT = dyn_cast<VectorType>(T))
T = VT->getElementType();
- RetTy = isDepthImage ? T : CI->getType();
+ RetTy = IsDepthImage ? T : CI->getType();
return std::string(kOCLBuiltinName::SampledReadImage) +
(T->isFloatingPointTy() ? 'f' : 'i');
},
[=](CallInst *NewCI) -> Instruction * {
- if (isDepthImage)
+ if (IsDepthImage)
return InsertElementInst::Create(
UndefValue::get(VectorType::get(NewCI->getType(), 4)), NewCI,
getSizet(M, 0), "", NewCI->getParent());
@@ -1242,19 +1242,19 @@ SPIRVToLLVM::expandOCLBuiltinWithScalarArg(CallInst *CI,
return mutateCallInstOCL(
M, CI,
[=](CallInst *, std::vector<Value *> &Args) {
- unsigned vecSize =
+ unsigned VecSize =
CI->getOperand(1)->getType()->getVectorNumElements();
Value *NewVec = nullptr;
if (auto CA = dyn_cast<Constant>(Args[0]))
- NewVec = ConstantVector::getSplat(vecSize, CA);
+ NewVec = ConstantVector::getSplat(VecSize, CA);
else {
NewVec = ConstantVector::getSplat(
- vecSize, Constant::getNullValue(Args[0]->getType()));
+ VecSize, Constant::getNullValue(Args[0]->getType()));
NewVec = InsertElementInst::Create(NewVec, Args[0], getInt32(M, 0),
"", CI);
NewVec = new ShuffleVectorInst(
NewVec, NewVec,
- ConstantVector::getSplat(vecSize, getInt32(M, 0)), "", CI);
+ ConstantVector::getSplat(VecSize, getInt32(M, 0)), "", CI);
}
NewVec->takeName(Args[0]);
Args[0] = NewVec;
@@ -1396,14 +1396,14 @@ Value *SPIRVToLLVM::transValueWithoutDecoration(SPIRVValue *BV, Function *F,
// if we try to initialize constant TypeStruct, add bitcasts
// if src and dst types are both pointers but to different types
if (Members == Constants) {
- for (unsigned i = 0; i < Members; ++i) {
- if (CV[i]->getType() == BCCTy->getElementType(i))
+ for (unsigned I = 0; I < Members; ++I) {
+ if (CV[I]->getType() == BCCTy->getElementType(I))
continue;
- if (!CV[i]->getType()->isPointerTy() ||
- !BCCTy->getElementType(i)->isPointerTy())
+ if (!CV[I]->getType()->isPointerTy() ||
+ !BCCTy->getElementType(I)->isPointerTy())
continue;
- CV[i] = ConstantExpr::getBitCast(CV[i], BCCTy->getElementType(i));
+ CV[I] = ConstantExpr::getBitCast(CV[I], BCCTy->getElementType(I));
}
}
@@ -1506,7 +1506,7 @@ Value *SPIRVToLLVM::transValueWithoutDecoration(SPIRVValue *BV, Function *F,
if (CreatePlaceHolder) {
auto GV = new GlobalVariable(
*M, transType(BV->getType()), false, GlobalValue::PrivateLinkage,
- nullptr, std::string(kPlaceholderPrefix) + BV->getName(), 0,
+ nullptr, std::string(KPlaceholderPrefix) + BV->getName(), 0,
GlobalVariable::NotThreadLocal, 0);
auto LD = new LoadInst(GV, BV->getName(), BB);
PlaceholderMap[BV] = LD;
@@ -1615,7 +1615,7 @@ Value *SPIRVToLLVM::transValueWithoutDecoration(SPIRVValue *BV, Function *F,
llvm::Value *Dst = transValue(BC->getTarget(), F, BB);
unsigned Align = BC->getAlignment();
llvm::Value *Size = transValue(BC->getSize(), F, BB);
- bool isVolatile = BC->SPIRVMemoryAccess::isVolatile();
+ bool IsVolatile = BC->SPIRVMemoryAccess::isVolatile();
IRBuilder<> Builder(BB);
// If we copy from zero-initialized array, we can optimize it to llvm.memset
@@ -1631,14 +1631,14 @@ Value *SPIRVToLLVM::transValueWithoutDecoration(SPIRVValue *BV, Function *F,
Type *SrcTy = transType(AT->getArrayElementType());
assert(SrcTy->isIntegerTy(8));
llvm::Value *Src = ConstantInt::get(SrcTy, 0);
- CI = Builder.CreateMemSet(Dst, Src, Size, Align, isVolatile);
+ CI = Builder.CreateMemSet(Dst, Src, Size, Align, IsVolatile);
}
}
}
}
if (!CI) {
llvm::Value *Src = transValue(BC->getSource(), F, BB);
- CI = Builder.CreateMemCpy(Dst, Align, Src, Align, Size, isVolatile);
+ CI = Builder.CreateMemCpy(Dst, Align, Src, Align, Size, IsVolatile);
}
if (isFuncNoUnwind())
CI->getFunction()->addFnAttr(Attribute::NoUnwind);
@@ -1688,8 +1688,8 @@ Value *SPIRVToLLVM::transValueWithoutDecoration(SPIRVValue *BV, Function *F,
auto Scalar = transValue(VTS->getScalar(), F, BB);
auto Vector = transValue(VTS->getVector(), F, BB);
assert(Vector->getType()->isVectorTy() && "Invalid type");
- unsigned vecSize = Vector->getType()->getVectorNumElements();
- auto NewVec = Builder.CreateVectorSplat(vecSize, Scalar, Scalar->getName());
+ unsigned VecSize = Vector->getType()->getVectorNumElements();
+ auto NewVec = Builder.CreateVectorSplat(VecSize, Scalar, Scalar->getName());
NewVec->takeName(Scalar);
auto Scale = Builder.CreateFMul(Vector, NewVec, "scale");
return mapValue(BV, Scale);
@@ -1855,7 +1855,7 @@ Value *SPIRVToLLVM::transValueWithoutDecoration(SPIRVValue *BV, Function *F,
std::vector<Type *> ArgTypes;
ArgTypes.push_back(FRem->getType());
ArgTypes.push_back(Divisor->getType());
- MangleOpenCLBuiltin(UnmangledName, ArgTypes, MangledName);
+ mangleOpenClBuiltin(UnmangledName, ArgTypes, MangledName);
auto FT = FunctionType::get(transType(BV->getType()), ArgTypes, false);
auto Func =
@@ -2169,22 +2169,22 @@ Value *SPIRVToLLVM::transEnqueuedBlock(SPIRVValue *SInvoke,
auto BlockAlloca = Builder.CreateAlloca(BlockTy, nullptr, "block");
BlockAlloca->setAlignment(DL.getPrefTypeAlignment(BlockTy));
- auto getIndices = [Int32Ty](int a, int b) -> SmallVector<Value *, 2> {
- return {ConstantInt::get(Int32Ty, a), ConstantInt::get(Int32Ty, b)};
+ auto GetIndices = [Int32Ty](int A, int B) -> SmallVector<Value *, 2> {
+ return {ConstantInt::get(Int32Ty, A), ConstantInt::get(Int32Ty, B)};
};
// 1. isa, flags and reserved fields isn't used in current implementation
// Fill them the same way as clang does
- auto IsaGEP = Builder.CreateGEP(BlockAlloca, getIndices(0, 0));
+ auto IsaGEP = Builder.CreateGEP(BlockAlloca, GetIndices(0, 0));
Builder.CreateStore(ConstantPointerNull::get(Int8PtrTy), IsaGEP);
- auto FlagsGEP = Builder.CreateGEP(BlockAlloca, getIndices(0, 1));
+ auto FlagsGEP = Builder.CreateGEP(BlockAlloca, GetIndices(0, 1));
Builder.CreateStore(ConstantInt::get(Int32Ty, 1342177280), FlagsGEP);
- auto ReservedGEP = Builder.CreateGEP(BlockAlloca, getIndices(0, 2));
+ auto ReservedGEP = Builder.CreateGEP(BlockAlloca, GetIndices(0, 2));
Builder.CreateStore(ConstantInt::get(Int32Ty, 0), ReservedGEP);
// 2. Store pointer to block invoke to the structure
auto InvokeCast = Builder.CreateBitCast(LInvoke, Int8PtrTy, "invoke");
- auto InvokeGEP = Builder.CreateGEP(BlockAlloca, getIndices(0, 3));
+ auto InvokeGEP = Builder.CreateGEP(BlockAlloca, GetIndices(0, 3));
Builder.CreateStore(InvokeCast, InvokeGEP);
// 3. Create and store a pointer to the block descriptor global value
@@ -2200,13 +2200,13 @@ Value *SPIRVToLLVM::transEnqueuedBlock(SPIRVValue *SInvoke,
new GlobalVariable(*M, BlockDescTy, true, GlobalValue::InternalLinkage,
BlockDesc, "__block_descriptor_spirv");
auto BlockDescGEP =
- Builder.CreateGEP(BlockAlloca, getIndices(0, 4), "block.descriptor");
+ Builder.CreateGEP(BlockAlloca, GetIndices(0, 4), "block.descriptor");
Builder.CreateStore(BlockDescGV, BlockDescGEP);
// 4. Copy captured data to the structure
if (LCaptSize->getZExtValue() > 0) {
auto CapturedGEP =
- Builder.CreateGEP(BlockAlloca, getIndices(0, 5), "block.captured");
+ Builder.CreateGEP(BlockAlloca, GetIndices(0, 5), "block.captured");
auto CapturedGEPCast = Builder.CreateBitCast(CapturedGEP, Int8PtrTy);
// We can't make any guesses about type of captured data, so
@@ -2230,9 +2230,9 @@ Instruction *SPIRVToLLVM::transEnqueueKernelBI(SPIRVInstruction *BI,
// Find or create enqueue kernel BI declaration
auto Ops = BI->getOperands();
- bool hasVaargs = Ops.size() > 10;
+ bool HasVaargs = Ops.size() > 10;
- std::string FName = hasVaargs ? "__enqueue_kernel_events_vaargs"
+ std::string FName = HasVaargs ? "__enqueue_kernel_events_vaargs"
: "__enqueue_kernel_basic_events";
Function *F = M->getFunction(FName);
if (!F) {
@@ -2249,10 +2249,10 @@ Instruction *SPIRVToLLVM::transEnqueueKernelBI(SPIRVInstruction *BI,
EventTy, // events
Type::getInt8PtrTy(*Context, SPIRAS_Generic) // block
};
- if (hasVaargs)
+ if (HasVaargs)
Tys.push_back(IntTy); // Number of variadics if any
- FunctionType *FT = FunctionType::get(IntTy, Tys, hasVaargs);
+ FunctionType *FT = FunctionType::get(IntTy, Tys, HasVaargs);
F = Function::Create(FT, GlobalValue::ExternalLinkage, FName, M);
if (isFuncNoUnwind())
F->addFnAttr(Attribute::NoUnwind);
@@ -2269,11 +2269,11 @@ Instruction *SPIRVToLLVM::transEnqueueKernelBI(SPIRVInstruction *BI,
transEnqueuedBlock(Ops[6], Ops[7], Ops[8], Ops[9], F, BB) // block
};
- if (hasVaargs) {
+ if (HasVaargs) {
Args.push_back(
ConstantInt::get(IntTy, Ops.size() - 10)); // Number of vaargs
- for (unsigned i = 10; i < Ops.size(); ++i)
- Args.push_back(transValue(Ops[i], F, BB, false));
+ for (unsigned I = 10; I < Ops.size(); ++I)
+ Args.push_back(transValue(Ops[I], F, BB, false));
}
auto Call = CallInst::Create(F, Args, "", BB);
setName(Call, BI);
@@ -2321,7 +2321,7 @@ Instruction *SPIRVToLLVM::transBuiltinFromInst(const std::string &FuncName,
}
}
if (!HasFuncPtrArg)
- MangleOpenCLBuiltin(FuncName, ArgTys, MangledName);
+ mangleOpenClBuiltin(FuncName, ArgTys, MangledName);
else
MangledName = decorateSPIRVFunction(FuncName);
Function *Func = M->getFunction(MangledName);
@@ -2745,9 +2745,9 @@ Instruction *SPIRVToLLVM::transOCLBuiltinFromExtInst(SPIRVExtInst *BC,
} else if (UnmangledName.find("read_image") == 0) {
auto ModifiedArgTypes = ArgTypes;
ModifiedArgTypes[1] = getOrCreateOpaquePtrType(M, "opencl.sampler_t");
- MangleOpenCLBuiltin(UnmangledName, ModifiedArgTypes, MangledName);
+ mangleOpenClBuiltin(UnmangledName, ModifiedArgTypes, MangledName);
} else {
- MangleOpenCLBuiltin(UnmangledName, ArgTypes, MangledName);
+ mangleOpenClBuiltin(UnmangledName, ArgTypes, MangledName);
}
SPIRVDBG(spvdbgs() << "[transOCLBuiltinFromExtInst] ModifiedUnmangledName: "
<< UnmangledName << " MangledName: " << MangledName
@@ -2808,7 +2808,7 @@ CallInst *SPIRVToLLVM::transOCLBarrier(BasicBlock *BB, SPIRVWord ExecScope,
std::string MangledName;
- MangleOpenCLBuiltin(FuncName, ArgTy, MangledName);
+ mangleOpenClBuiltin(FuncName, ArgTy, MangledName);
Function *Func = M->getFunction(MangledName);
if (!Func) {
FunctionType *FT = FunctionType::get(VoidTy, ArgTy, false);
@@ -2855,7 +2855,7 @@ CallInst *SPIRVToLLVM::transOCLMemFence(BasicBlock *BB, SPIRVWord MemSema,
std::string MangledName;
- MangleOpenCLBuiltin(FuncName, ArgTy, MangledName);
+ mangleOpenClBuiltin(FuncName, ArgTy, MangledName);
Function *Func = M->getFunction(MangledName);
if (!Func) {
FunctionType *FT = FunctionType::get(VoidTy, ArgTy, false);
@@ -2872,8 +2872,8 @@ Instruction *SPIRVToLLVM::transOCLBarrierFence(SPIRVInstruction *MB,
BasicBlock *BB) {
assert(BB && "Invalid BB");
std::string FuncName;
- auto getIntVal = [](SPIRVValue *value) {
- return static_cast<SPIRVConstant *>(value)->getZExtIntValue();
+ auto GetIntVal = [](SPIRVValue *Value) {
+ return static_cast<SPIRVConstant *>(Value)->getZExtIntValue();
};
CallInst *Call = nullptr;
@@ -2881,16 +2881,16 @@ Instruction *SPIRVToLLVM::transOCLBarrierFence(SPIRVInstruction *MB,
if (MB->getOpCode() == OpMemoryBarrier) {
auto MemB = static_cast<SPIRVMemoryBarrier *>(MB);
- SPIRVWord MemScope = getIntVal(MemB->getOpValue(0));
- SPIRVWord MemSema = getIntVal(MemB->getOpValue(1));
+ SPIRVWord MemScope = GetIntVal(MemB->getOpValue(0));
+ SPIRVWord MemSema = GetIntVal(MemB->getOpValue(1));
Call = transOCLMemFence(BB, MemSema, MemScope);
} else if (MB->getOpCode() == OpControlBarrier) {
auto CtlB = static_cast<SPIRVControlBarrier *>(MB);
- SPIRVWord ExecScope = getIntVal(CtlB->getExecScope());
- SPIRVWord MemSema = getIntVal(CtlB->getMemSemantic());
- SPIRVWord MemScope = getIntVal(CtlB->getMemScope());
+ SPIRVWord ExecScope = GetIntVal(CtlB->getExecScope());
+ SPIRVWord MemSema = GetIntVal(CtlB->getMemSemantic());
+ SPIRVWord MemScope = GetIntVal(CtlB->getMemScope());
Call = transOCLBarrier(BB, ExecScope, MemSema, MemScope);
} else {
@@ -3075,7 +3075,7 @@ Instruction *SPIRVToLLVM::transOCLRelational(SPIRVInstruction *I,
}
} // namespace SPIRV
-bool llvm::ReadSPIRV(LLVMContext &C, std::istream &IS, Module *&M,
+bool llvm::readSpirv(LLVMContext &C, std::istream &IS, Module *&M,
std::string &ErrMsg) {
M = new Module("", C);
std::unique_ptr<SPIRVModule> BM(SPIRVModule::createSPIRVModule());
diff --git a/lib/SPIRV/SPIRVToOCL20.cpp b/lib/SPIRV/SPIRVToOCL20.cpp
index f61b88f..4ca9c2b 100644
--- a/lib/SPIRV/SPIRVToOCL20.cpp
+++ b/lib/SPIRV/SPIRVToOCL20.cpp
@@ -198,11 +198,11 @@ void SPIRVToOCL20::visitCallSPIRVMemoryBarrier(CallInst *CI) {
AttributeList Attrs = CI->getCalledFunction()->getAttributes();
mutateCallInstOCL(M, CI,
[=](CallInst *, std::vector<Value *> &Args) {
- auto getArg = [=](unsigned I) {
+ auto GetArg = [=](unsigned I) {
return cast<ConstantInt>(Args[I])->getZExtValue();
};
- auto MScope = static_cast<Scope>(getArg(0));
- auto Sema = mapSPIRVMemSemanticToOCL(getArg(1));
+ auto MScope = static_cast<Scope>(GetArg(0));
+ auto Sema = mapSPIRVMemSemanticToOCL(GetArg(1));
Args.resize(3);
Args[0] = getInt32(M, Sema.first);
Args[1] = getInt32(M, Sema.second);
@@ -213,128 +213,128 @@ void SPIRVToOCL20::visitCallSPIRVMemoryBarrier(CallInst *CI) {
}
void SPIRVToOCL20::visitCallSPRIVImageQuerySize(CallInst *CI) {
- Function *func = CI->getCalledFunction();
+ Function *Func = CI->getCalledFunction();
// Get image type
- Type *argTy = func->getFunctionType()->getParamType(0);
- assert(argTy->isPointerTy() &&
+ Type *ArgTy = Func->getFunctionType()->getParamType(0);
+ assert(ArgTy->isPointerTy() &&
"argument must be a pointer to opaque structure");
- StructType *imgTy = cast<StructType>(argTy->getPointerElementType());
- assert(imgTy->isOpaque() && "image type must be an opaque structure");
- StringRef imgTyName = imgTy->getName();
- assert(imgTyName.startswith("opencl.image") && "not an OCL image type");
-
- unsigned imgDim = 0;
- bool imgArray = false;
-
- if (imgTyName.startswith("opencl.image1d")) {
- imgDim = 1;
- } else if (imgTyName.startswith("opencl.image2d")) {
- imgDim = 2;
- } else if (imgTyName.startswith("opencl.image3d")) {
- imgDim = 3;
+ StructType *ImgTy = cast<StructType>(ArgTy->getPointerElementType());
+ assert(ImgTy->isOpaque() && "image type must be an opaque structure");
+ StringRef ImgTyName = ImgTy->getName();
+ assert(ImgTyName.startswith("opencl.image") && "not an OCL image type");
+
+ unsigned ImgDim = 0;
+ bool ImgArray = false;
+
+ if (ImgTyName.startswith("opencl.image1d")) {
+ ImgDim = 1;
+ } else if (ImgTyName.startswith("opencl.image2d")) {
+ ImgDim = 2;
+ } else if (ImgTyName.startswith("opencl.image3d")) {
+ ImgDim = 3;
}
- assert(imgDim != 0 && "unexpected image dimensionality");
+ assert(ImgDim != 0 && "unexpected image dimensionality");
- if (imgTyName.count("_array_") != 0) {
- imgArray = true;
+ if (ImgTyName.count("_array_") != 0) {
+ ImgArray = true;
}
- AttributeList attributes = CI->getCalledFunction()->getAttributes();
- BuiltinFuncMangleInfo mangle;
- Type *int32Ty = Type::getInt32Ty(*Ctx);
- Instruction *getImageSize = nullptr;
+ AttributeList Attributes = CI->getCalledFunction()->getAttributes();
+ BuiltinFuncMangleInfo Mangle;
+ Type *Int32Ty = Type::getInt32Ty(*Ctx);
+ Instruction *GetImageSize = nullptr;
- if (imgDim == 1) {
+ if (ImgDim == 1) {
// OpImageQuerySize from non-arrayed 1d image is always translated
// into get_image_width returning scalar argument
- getImageSize = addCallInst(M, kOCLBuiltinName::GetImageWidth, int32Ty,
- CI->getArgOperand(0), &attributes, CI, &mangle,
+ GetImageSize = addCallInst(M, kOCLBuiltinName::GetImageWidth, Int32Ty,
+ CI->getArgOperand(0), &Attributes, CI, &Mangle,
CI->getName(), false);
// The width of integer type returning by OpImageQuerySize[Lod] may
// differ from i32
- if (CI->getType()->getScalarType() != int32Ty) {
- getImageSize = CastInst::CreateIntegerCast(getImageSize,
+ if (CI->getType()->getScalarType() != Int32Ty) {
+ GetImageSize = CastInst::CreateIntegerCast(GetImageSize,
CI->getType()->getScalarType(),
false, CI->getName(), CI);
}
} else {
- assert((imgDim == 2 || imgDim == 3) && "invalid image type");
+ assert((ImgDim == 2 || ImgDim == 3) && "invalid image type");
assert(CI->getType()->isVectorTy() &&
"this code can handle vector result type only");
// get_image_dim returns int2 and int4 for 2d and 3d images respecitvely.
- const unsigned imgDimRetEls = imgDim == 2 ? 2 : 4;
- VectorType *retTy = VectorType::get(int32Ty, imgDimRetEls);
- getImageSize = addCallInst(M, kOCLBuiltinName::GetImageDim, retTy,
- CI->getArgOperand(0), &attributes, CI, &mangle,
+ const unsigned ImgDimRetEls = ImgDim == 2 ? 2 : 4;
+ VectorType *RetTy = VectorType::get(Int32Ty, ImgDimRetEls);
+ GetImageSize = addCallInst(M, kOCLBuiltinName::GetImageDim, RetTy,
+ CI->getArgOperand(0), &Attributes, CI, &Mangle,
CI->getName(), false);
// The width of integer type returning by OpImageQuerySize[Lod] may
// differ from i32
- if (CI->getType()->getScalarType() != int32Ty) {
- getImageSize = CastInst::CreateIntegerCast(
- getImageSize,
+ if (CI->getType()->getScalarType() != Int32Ty) {
+ GetImageSize = CastInst::CreateIntegerCast(
+ GetImageSize,
VectorType::get(CI->getType()->getScalarType(),
- getImageSize->getType()->getVectorNumElements()),
+ GetImageSize->getType()->getVectorNumElements()),
false, CI->getName(), CI);
}
}
- if (imgArray || imgDim == 3) {
+ if (ImgArray || ImgDim == 3) {
assert(
CI->getType()->isVectorTy() &&
"OpImageQuerySize[Lod] must return vector for arrayed and 3d images");
- const unsigned imgQuerySizeRetEls = CI->getType()->getVectorNumElements();
+ const unsigned ImgQuerySizeRetEls = CI->getType()->getVectorNumElements();
- if (imgDim == 1) {
+ if (ImgDim == 1) {
// get_image_width returns scalar result while OpImageQuerySize
// for image1d_array_t returns <2 x i32> vector.
- assert(imgQuerySizeRetEls == 2 &&
+ assert(ImgQuerySizeRetEls == 2 &&
"OpImageQuerySize[Lod] must return <2 x iN> vector type");
- getImageSize = InsertElementInst::Create(
- UndefValue::get(CI->getType()), getImageSize,
- ConstantInt::get(int32Ty, 0), CI->getName(), CI);
+ GetImageSize = InsertElementInst::Create(
+ UndefValue::get(CI->getType()), GetImageSize,
+ ConstantInt::get(Int32Ty, 0), CI->getName(), CI);
} else {
// get_image_dim and OpImageQuerySize returns different vector
// types for arrayed and 3d images.
- SmallVector<Constant *, 4> maskEls;
- for (unsigned idx = 0; idx < imgQuerySizeRetEls; ++idx)
- maskEls.push_back(ConstantInt::get(int32Ty, idx));
- Constant *mask = ConstantVector::get(maskEls);
+ SmallVector<Constant *, 4> MaskEls;
+ for (unsigned Idx = 0; Idx < ImgQuerySizeRetEls; ++Idx)
+ MaskEls.push_back(ConstantInt::get(Int32Ty, Idx));
+ Constant *Mask = ConstantVector::get(MaskEls);
- getImageSize = new ShuffleVectorInst(
- getImageSize, UndefValue::get(getImageSize->getType()), mask,
+ GetImageSize = new ShuffleVectorInst(
+ GetImageSize, UndefValue::get(GetImageSize->getType()), Mask,
CI->getName(), CI);
}
}
- if (imgArray) {
- assert((imgDim == 1 || imgDim == 2) && "invalid image array type");
+ if (ImgArray) {
+ assert((ImgDim == 1 || ImgDim == 2) && "invalid image array type");
// Insert get_image_array_size to the last position of the resulting vector.
- Type *sizeTy =
+ Type *SizeTy =
Type::getIntNTy(*Ctx, M->getDataLayout().getPointerSizeInBits(0));
- Instruction *getImageArraySize = addCallInst(
- M, kOCLBuiltinName::GetImageArraySize, sizeTy, CI->getArgOperand(0),
- &attributes, CI, &mangle, CI->getName(), false);
+ Instruction *GetImageArraySize = addCallInst(
+ M, kOCLBuiltinName::GetImageArraySize, SizeTy, CI->getArgOperand(0),
+ &Attributes, CI, &Mangle, CI->getName(), false);
// The width of integer type returning by OpImageQuerySize[Lod] may
// differ from size_t which is returned by get_image_array_size
- if (getImageArraySize->getType() != CI->getType()->getScalarType()) {
- getImageArraySize = CastInst::CreateIntegerCast(
- getImageArraySize, CI->getType()->getScalarType(), false,
+ if (GetImageArraySize->getType() != CI->getType()->getScalarType()) {
+ GetImageArraySize = CastInst::CreateIntegerCast(
+ GetImageArraySize, CI->getType()->getScalarType(), false,
CI->getName(), CI);
}
- getImageSize = InsertElementInst::Create(
- getImageSize, getImageArraySize,
- ConstantInt::get(int32Ty, CI->getType()->getVectorNumElements() - 1),
+ GetImageSize = InsertElementInst::Create(
+ GetImageSize, GetImageArraySize,
+ ConstantInt::get(Int32Ty, CI->getType()->getVectorNumElements() - 1),
CI->getName(), CI);
}
- assert(getImageSize && "must not be null");
- CI->replaceAllUsesWith(getImageSize);
+ assert(GetImageSize && "must not be null");
+ CI->replaceAllUsesWith(GetImageSize);
CI->eraseFromParent();
}
void SPIRVToOCL20::visitCallSPIRVAtomicBuiltin(CallInst *CI, Op OC) {
AttributeList Attrs = CI->getCalledFunction()->getAttributes();
- Instruction *pInsertBefore = CI;
+ Instruction *PInsertBefore = CI;
mutateCallInstOCL(
M, CI,
@@ -374,15 +374,15 @@ void SPIRVToOCL20::visitCallSPIRVAtomicBuiltin(CallInst *CI, Op OC) {
// OCL built-ins returns boolean value and stores a new/original
// value by pointer passed as 2nd argument (aka expected) while SPIR-V
// instructions returns this new/original value as a resulting value.
- AllocaInst *pExpected =
+ AllocaInst *PExpected =
new AllocaInst(CI->getType(), 0, "expected",
- &(*pInsertBefore->getParent()
+ &(*PInsertBefore->getParent()
->getParent()
->getEntryBlock()
.getFirstInsertionPt()));
- pExpected->setAlignment(CI->getType()->getScalarSizeInBits() / 8);
- new StoreInst(Args[1], pExpected, pInsertBefore);
- Args[1] = pExpected;
+ PExpected->setAlignment(CI->getType()->getScalarSizeInBits() / 8);
+ new StoreInst(Args[1], PExpected, PInsertBefore);
+ Args[1] = PExpected;
std::swap(Args[3], Args[4]);
std::swap(Args[2], Args[3]);
RetTy = Type::getInt1Ty(*Ctx);
@@ -397,9 +397,9 @@ void SPIRVToOCL20::visitCallSPIRVAtomicBuiltin(CallInst *CI, Op OC) {
// returning it has to be loaded from the memory where 'expected'
// value is stored. This memory must contain the needed value after a
// call to OCL built-in is completed.
- LoadInst *pOriginal =
- new LoadInst(CI->getArgOperand(1), "original", pInsertBefore);
- return pOriginal;
+ LoadInst *POriginal =
+ new LoadInst(CI->getArgOperand(1), "original", PInsertBefore);
+ return POriginal;
}
// For other built-ins the return values match.
return CI;
@@ -530,31 +530,31 @@ void SPIRVToOCL20::visitCastInst(CastInst &Cast) {
!isa<UIToFPInst>(Cast) && !isa<SIToFPInst>(Cast))
return;
- Type const *srcTy = Cast.getSrcTy();
- Type *dstVecTy = Cast.getDestTy();
+ Type const *SrcTy = Cast.getSrcTy();
+ Type *DstVecTy = Cast.getDestTy();
// Leave scalar casts as is. Skip boolean vector casts becase there
// are no suitable OCL built-ins.
- if (!dstVecTy->isVectorTy() || srcTy->getScalarSizeInBits() == 1 ||
- dstVecTy->getScalarSizeInBits() == 1)
+ if (!DstVecTy->isVectorTy() || SrcTy->getScalarSizeInBits() == 1 ||
+ DstVecTy->getScalarSizeInBits() == 1)
return;
// Assemble built-in name -> convert_gentypeN
- std::string castBuiltInName(kOCLBuiltinName::ConvertPrefix);
+ std::string CastBuiltInName(kOCLBuiltinName::ConvertPrefix);
// Check if this is 'floating point -> unsigned integer' cast
- castBuiltInName += mapLLVMTypeToOCLType(dstVecTy, !isa<FPToUIInst>(Cast));
+ CastBuiltInName += mapLLVMTypeToOCLType(DstVecTy, !isa<FPToUIInst>(Cast));
// Replace LLVM conversion instruction with call to conversion built-in
- BuiltinFuncMangleInfo mangle;
+ BuiltinFuncMangleInfo Mangle;
// It does matter if the source is unsigned integer or not. SExt is for
// signed source, ZExt and UIToFPInst are for unsigned source.
if (isa<ZExtInst>(Cast) || isa<UIToFPInst>(Cast))
- mangle.addUnsignedArg(0);
+ Mangle.addUnsignedArg(0);
- AttributeList attributes;
- CallInst *call =
- addCallInst(M, castBuiltInName, dstVecTy, Cast.getOperand(0), &attributes,
- &Cast, &mangle, Cast.getName(), false);
- Cast.replaceAllUsesWith(call);
+ AttributeList Attributes;
+ CallInst *Call =
+ addCallInst(M, CastBuiltInName, DstVecTy, Cast.getOperand(0), &Attributes,
+ &Cast, &Mangle, Cast.getName(), false);
+ Cast.replaceAllUsesWith(Call);
Cast.eraseFromParent();
}
diff --git a/lib/SPIRV/SPIRVUtil.cpp b/lib/SPIRV/SPIRVUtil.cpp
index 69459d4..1aaa41b 100644
--- a/lib/SPIRV/SPIRVUtil.cpp
+++ b/lib/SPIRV/SPIRVUtil.cpp
@@ -116,12 +116,12 @@ std::string mapLLVMTypeToOCLType(const Type *Ty, bool Signed) {
return "float";
if (Ty->isDoubleTy())
return "double";
- if (auto intTy = dyn_cast<IntegerType>(Ty)) {
+ if (auto IntTy = dyn_cast<IntegerType>(Ty)) {
std::string SignPrefix;
std::string Stem;
if (!Signed)
SignPrefix = "u";
- switch (intTy->getIntegerBitWidth()) {
+ switch (IntTy->getIntegerBitWidth()) {
case 8:
Stem = "char";
break;
@@ -140,12 +140,12 @@ std::string mapLLVMTypeToOCLType(const Type *Ty, bool Signed) {
}
return SignPrefix + Stem;
}
- if (auto vecTy = dyn_cast<VectorType>(Ty)) {
- Type *eleTy = vecTy->getElementType();
- unsigned size = vecTy->getVectorNumElements();
- std::stringstream ss;
- ss << mapLLVMTypeToOCLType(eleTy, Signed) << size;
- return ss.str();
+ if (auto VecTy = dyn_cast<VectorType>(Ty)) {
+ Type *EleTy = VecTy->getElementType();
+ unsigned Size = VecTy->getVectorNumElements();
+ std::stringstream Ss;
+ Ss << mapLLVMTypeToOCLType(EleTy, Signed) << Size;
+ return Ss.str();
}
return "invalid_type";
}
@@ -192,11 +192,11 @@ std::string mapSPIRVTypeToOCLType(SPIRVType *Ty, bool Signed) {
return SignPrefix + Stem;
}
if (Ty->isTypeVector()) {
- auto eleTy = Ty->getVectorComponentType();
- auto size = Ty->getVectorComponentCount();
- std::stringstream ss;
- ss << mapSPIRVTypeToOCLType(eleTy, Signed) << size;
- return ss.str();
+ auto EleTy = Ty->getVectorComponentType();
+ auto Size = Ty->getVectorComponentCount();
+ std::stringstream Ss;
+ Ss << mapSPIRVTypeToOCLType(EleTy, Signed) << Size;
+ return Ss.str();
}
llvm_unreachable("Invalid type");
return "unknown_type";
@@ -261,9 +261,9 @@ bool isOCLImageType(llvm::Type *Ty, StringRef *Name) {
return false;
}
-/// \param BaseTyName is the type name as in spirv.BaseTyName.Postfixes
+/// \param BaseTyName is the type Name as in spirv.BaseTyName.Postfixes
/// \param Postfix contains postfixes extracted from the SPIR-V image
-/// type name as spirv.BaseTyName.Postfixes.
+/// type Name as spirv.BaseTyName.Postfixes.
bool isSPIRVType(llvm::Type *Ty, StringRef BaseTyName, StringRef *Postfix) {
if (auto PT = dyn_cast<PointerType>(Ty))
if (auto ST = dyn_cast<StructType>(PT->getElementType()))
@@ -284,18 +284,18 @@ bool isSPIRVType(llvm::Type *Ty, StringRef BaseTyName, StringRef *Postfix) {
Function *getOrCreateFunction(Module *M, Type *RetTy, ArrayRef<Type *> ArgTypes,
StringRef Name, BuiltinFuncMangleInfo *Mangle,
- AttributeList *Attrs, bool takeName) {
+ AttributeList *Attrs, bool TakeName) {
std::string MangledName = Name;
- bool isVarArg = false;
+ bool IsVarArg = false;
if (Mangle) {
MangledName = mangleBuiltin(Name, ArgTypes, Mangle);
- isVarArg = 0 <= Mangle->getVarArg();
- if (isVarArg)
+ IsVarArg = 0 <= Mangle->getVarArg();
+ if (IsVarArg)
ArgTypes = ArgTypes.slice(0, Mangle->getVarArg());
}
- FunctionType *FT = FunctionType::get(RetTy, ArgTypes, isVarArg);
+ FunctionType *FT = FunctionType::get(RetTy, ArgTypes, IsVarArg);
Function *F = M->getFunction(MangledName);
- if (!takeName && F && F->getFunctionType() != FT && Mangle != nullptr) {
+ if (!TakeName && F && F->getFunctionType() != FT && Mangle != nullptr) {
std::string S;
raw_string_ostream SS(S);
SS << "Error: Attempt to redefine function: " << *F << " => " << *FT
@@ -305,12 +305,12 @@ Function *getOrCreateFunction(Module *M, Type *RetTy, ArrayRef<Type *> ArgTypes,
if (!F || F->getFunctionType() != FT) {
auto NewF =
Function::Create(FT, GlobalValue::ExternalLinkage, MangledName, M);
- if (F && takeName) {
+ if (F && TakeName) {
NewF->takeName(F);
- DEBUG(dbgs() << "[getOrCreateFunction] Warning: taking function name\n");
+ DEBUG(dbgs() << "[getOrCreateFunction] Warning: taking function Name\n");
}
if (NewF->getName() != MangledName) {
- DEBUG(dbgs() << "[getOrCreateFunction] Warning: function name changed\n");
+ DEBUG(dbgs() << "[getOrCreateFunction] Warning: function Name changed\n");
}
DEBUG(dbgs() << "[getOrCreateFunction] "; if (F) dbgs() << *F << " => ";
dbgs() << *NewF << '\n';);
@@ -374,9 +374,9 @@ std::string getSPIRVFuncName(Op OC, StringRef PostFix) {
return prefixSPIRVName(getName(OC) + PostFix.str());
}
-std::string getSPIRVFuncName(Op OC, const Type *pRetTy, bool IsSigned) {
+std::string getSPIRVFuncName(Op OC, const Type *PRetTy, bool IsSigned) {
return prefixSPIRVName(getName(OC) + kSPIRVPostfix::Divider +
- getPostfixForReturnType(pRetTy, false));
+ getPostfixForReturnType(PRetTy, false));
}
std::string getSPIRVExtFuncName(SPIRVExtInstSetKind Set, unsigned ExtOp,
@@ -430,9 +430,9 @@ std::string getPostfixForReturnType(CallInst *CI, bool IsSigned) {
return getPostfixForReturnType(CI->getType(), IsSigned);
}
-std::string getPostfixForReturnType(const Type *pRetTy, bool IsSigned) {
+std::string getPostfixForReturnType(const Type *PRetTy, bool IsSigned) {
return std::string(kSPIRVPostfix::Return) +
- mapLLVMTypeToOCLType(pRetTy, IsSigned);
+ mapLLVMTypeToOCLType(PRetTy, IsSigned);
}
Op getSPIRVFuncOC(const std::string &S, SmallVectorImpl<std::string> *Dec) {
@@ -455,12 +455,12 @@ bool getSPIRVBuiltin(const std::string &OrigName, spv::BuiltIn &B) {
SmallVector<StringRef, 2> Postfix;
StringRef R(OrigName);
R = dePrefixSPIRVName(R, Postfix);
- assert(Postfix.empty() && "Invalid SPIR-V builtin name");
+ assert(Postfix.empty() && "Invalid SPIR-V builtin Name");
return getByName(R.str(), B);
}
bool oclIsBuiltin(const StringRef &Name, std::string *DemangledName,
- bool isCPP) {
+ bool IsCpp) {
if (Name == "printf") {
if (DemangledName)
*DemangledName = Name;
@@ -473,7 +473,7 @@ bool oclIsBuiltin(const StringRef &Name, std::string *DemangledName,
// OpenCL C++ built-ins are declared in cl namespace.
// TODO: consider using 'St' abbriviation for cl namespace mangling.
// Similar to ::std:: in C++.
- if (isCPP) {
+ if (IsCpp) {
if (!Name.startswith("_ZN"))
return false;
// Skip CV and ref qualifiers.
@@ -496,7 +496,7 @@ bool oclIsBuiltin(const StringRef &Name, std::string *DemangledName,
return true;
}
-// Check if a mangled type name is unsigned
+// Check if a mangled type Name is unsigned
bool isMangledTypeUnsigned(char Mangled) {
return Mangled == 'h' /* uchar */
|| Mangled == 't' /* ushort */
@@ -504,7 +504,7 @@ bool isMangledTypeUnsigned(char Mangled) {
|| Mangled == 'm' /* ulong */;
}
-// Check if a mangled type name is signed
+// Check if a mangled type Name is signed
bool isMangledTypeSigned(char Mangled) {
return Mangled == 'c' /* char */
|| Mangled == 'a' /* signed char */
@@ -513,13 +513,13 @@ bool isMangledTypeSigned(char Mangled) {
|| Mangled == 'l' /* long */;
}
-// Check if a mangled type name is floating point (excludes half)
+// Check if a mangled type Name is floating point (excludes half)
bool isMangledTypeFP(char Mangled) {
return Mangled == 'f' /* float */
|| Mangled == 'd'; /* double */
}
-// Check if a mangled type name is half
+// Check if a mangled type Name is half
bool isMangledTypeHalf(std::string Mangled) {
return Mangled == "Dh"; /* half */
}
@@ -532,7 +532,7 @@ void eraseSubstitutionFromMangledName(std::string &MangledName) {
}
}
-ParamType LastFuncParamType(const std::string &MangledName) {
+ParamType lastFuncParamType(const std::string &MangledName) {
auto Copy = MangledName;
eraseSubstitutionFromMangledName(Copy);
char Mangled = Copy.back();
@@ -551,10 +551,10 @@ ParamType LastFuncParamType(const std::string &MangledName) {
// Check if the last argument is signed
bool isLastFuncParamSigned(const std::string &MangledName) {
- return LastFuncParamType(MangledName) == ParamType::SIGNED;
+ return lastFuncParamType(MangledName) == ParamType::SIGNED;
}
-// Check if a mangled function name contains unsigned atomic type
+// Check if a mangled function Name contains unsigned atomic type
bool containsUnsignedAtomicType(StringRef Name) {
auto Loc = Name.find(kMangledName::AtomicPrefixIncoming);
if (Loc == StringRef::npos)
@@ -680,7 +680,7 @@ CallInst *addCallInst(Module *M, StringRef FuncName, Type *RetTy,
auto F = getOrCreateFunction(M, RetTy, getTypes(Args), FuncName, Mangle,
Attrs, TakeFuncName);
- // Cannot assign a name to void typed values
+ // Cannot assign a Name to void typed values
auto CI = CallInst::Create(F, Args, RetTy->isVoidTy() ? "" : InstName, Pos);
CI->setCallingConv(F->getCallingConv());
return CI;
@@ -776,35 +776,35 @@ Type *getVoidFuncPtrType(Module *M, unsigned AddrSpace) {
return PointerType::get(getVoidFuncType(M), AddrSpace);
}
-ConstantInt *getInt64(Module *M, int64_t value) {
- return ConstantInt::get(Type::getInt64Ty(M->getContext()), value, true);
+ConstantInt *getInt64(Module *M, int64_t Value) {
+ return ConstantInt::get(Type::getInt64Ty(M->getContext()), Value, true);
}
-Constant *getFloat32(Module *M, float value) {
- return ConstantFP::get(Type::getFloatTy(M->getContext()), value);
+Constant *getFloat32(Module *M, float Value) {
+ return ConstantFP::get(Type::getFloatTy(M->getContext()), Value);
}
-ConstantInt *getInt32(Module *M, int value) {
- return ConstantInt::get(Type::getInt32Ty(M->getContext()), value, true);
+ConstantInt *getInt32(Module *M, int Value) {
+ return ConstantInt::get(Type::getInt32Ty(M->getContext()), Value, true);
}
-ConstantInt *getUInt32(Module *M, unsigned value) {
- return ConstantInt::get(Type::getInt32Ty(M->getContext()), value, false);
+ConstantInt *getUInt32(Module *M, unsigned Value) {
+ return ConstantInt::get(Type::getInt32Ty(M->getContext()), Value, false);
}
-ConstantInt *getUInt16(Module *M, unsigned short value) {
- return ConstantInt::get(Type::getInt16Ty(M->getContext()), value, false);
+ConstantInt *getUInt16(Module *M, unsigned short Value) {
+ return ConstantInt::get(Type::getInt16Ty(M->getContext()), Value, false);
}
-std::vector<Value *> getInt32(Module *M, const std::vector<int> &value) {
+std::vector<Value *> getInt32(Module *M, const std::vector<int> &Values) {
std::vector<Value *> V;
- for (auto &I : value)
+ for (auto &I : Values)
V.push_back(getInt32(M, I));
return V;
}
-ConstantInt *getSizet(Module *M, uint64_t value) {
- return ConstantInt::get(getSizetType(M), value, false);
+ConstantInt *getSizet(Module *M, uint64_t Value) {
+ return ConstantInt::get(getSizetType(M), Value, false);
}
///////////////////////////////////////////////////////////////////////////////
@@ -972,14 +972,14 @@ static SPIR::RefParamType transTypeDesc(Type *Ty,
if (Name.startswith(kSPIRVTypeName::PrefixAndDelim)) {
Name = Name.substr(sizeof(kSPIRVTypeName::PrefixAndDelim) - 1);
Tmp = Name.str();
- auto pos = Tmp.find(kSPIRVTypeName::Delimiter); // first dot
- while (pos != std::string::npos) {
- Tmp[pos] = '_';
- pos = Tmp.find(kSPIRVTypeName::Delimiter, pos);
+ auto Pos = Tmp.find(kSPIRVTypeName::Delimiter); // first dot
+ while (Pos != std::string::npos) {
+ Tmp[Pos] = '_';
+ Pos = Tmp.find(kSPIRVTypeName::Delimiter, Pos);
}
Name = Tmp = kSPIRVName::Prefix + Tmp;
}
- // ToDo: Create a better unique name for struct without name
+ // ToDo: Create a better unique Name for struct without Name
if (Name.empty()) {
std::ostringstream OS;
OS << reinterpret_cast<size_t>(Ty);
@@ -1004,7 +1004,7 @@ static SPIR::RefParamType transTypeDesc(Type *Ty,
if (DelimPos != StringRef::npos)
TyName = TyName.substr(0, DelimPos);
}
- DEBUG(dbgs() << " type name: " << TyName << '\n');
+ DEBUG(dbgs() << " type Name: " << TyName << '\n');
auto Prim = getOCLTypePrimitiveEnum(TyName);
if (StructTy->isOpaque()) {
@@ -1070,13 +1070,13 @@ Value *getScalarOrArray(Value *V, unsigned Size, Instruction *Pos) {
return new LoadInst(P, "", Pos);
}
-Constant *getScalarOrVectorConstantInt(Type *T, uint64_t V, bool isSigned) {
+Constant *getScalarOrVectorConstantInt(Type *T, uint64_t V, bool IsSigned) {
if (auto IT = dyn_cast<IntegerType>(T))
return ConstantInt::get(IT, V);
if (auto VT = dyn_cast<VectorType>(T)) {
std::vector<Constant *> EV(
VT->getVectorNumElements(),
- getScalarOrVectorConstantInt(VT->getVectorElementType(), V, isSigned));
+ getScalarOrVectorConstantInt(VT->getVectorElementType(), V, IsSigned));
return ConstantVector::get(EV);
}
llvm_unreachable("Invalid type");
@@ -1084,15 +1084,15 @@ Constant *getScalarOrVectorConstantInt(Type *T, uint64_t V, bool isSigned) {
}
Value *getScalarOrArrayConstantInt(Instruction *Pos, Type *T, unsigned Len,
- uint64_t V, bool isSigned) {
+ uint64_t V, bool IsSigned) {
if (auto IT = dyn_cast<IntegerType>(T)) {
assert(Len == 1 && "Invalid length");
- return ConstantInt::get(IT, V, isSigned);
+ return ConstantInt::get(IT, V, IsSigned);
}
if (auto PT = dyn_cast<PointerType>(T)) {
auto ET = PT->getPointerElementType();
auto AT = ArrayType::get(ET, Len);
- std::vector<Constant *> EV(Len, ConstantInt::get(ET, V, isSigned));
+ std::vector<Constant *> EV(Len, ConstantInt::get(ET, V, IsSigned));
auto CA = ConstantArray::get(AT, EV);
auto Alloca = new AllocaInst(AT, 0, "", Pos);
new StoreInst(CA, Alloca, Pos);
@@ -1106,7 +1106,7 @@ Value *getScalarOrArrayConstantInt(Instruction *Pos, Type *T, unsigned Len,
if (auto AT = dyn_cast<ArrayType>(T)) {
auto ET = AT->getArrayElementType();
assert(AT->getArrayNumElements() == Len);
- std::vector<Constant *> EV(Len, ConstantInt::get(ET, V, isSigned));
+ std::vector<Constant *> EV(Len, ConstantInt::get(ET, V, IsSigned));
auto Ret = ConstantArray::get(AT, EV);
DEBUG(dbgs() << "[getScalarOrArrayConstantInt] Array type: " << *AT
<< ", Return: " << *Ret << '\n');
@@ -1125,7 +1125,7 @@ void dumpUsers(Value *V, StringRef Prompt) {
}
std::string getSPIRVTypeName(StringRef BaseName, StringRef Postfixes) {
- assert(!BaseName.empty() && "Invalid SPIR-V type name");
+ assert(!BaseName.empty() && "Invalid SPIR-V type Name");
auto TN = std::string(kSPIRVTypeName::PrefixAndDelim) + BaseName.str();
if (Postfixes.empty())
return TN;
@@ -1241,11 +1241,11 @@ std::string mapOCLTypeNameToSPIRV(StringRef Name, StringRef Acc) {
}
bool eraseIfNoUse(Function *F) {
- bool changed = false;
+ bool Changed = false;
if (!F)
- return changed;
+ return Changed;
if (!GlobalValue::isInternalLinkage(F->getLinkage()) && !F->isDeclaration())
- return changed;
+ return Changed;
dumpUsers(F, "[eraseIfNoUse] ");
for (auto UI = F->user_begin(), UE = F->user_end(); UI != UE;) {
@@ -1253,16 +1253,16 @@ bool eraseIfNoUse(Function *F) {
if (auto CE = dyn_cast<ConstantExpr>(U)) {
if (CE->use_empty()) {
CE->dropAllReferences();
- changed = true;
+ Changed = true;
}
}
}
if (F->use_empty()) {
DEBUG(dbgs() << "Erase "; F->printAsOperand(dbgs()); dbgs() << '\n');
F->eraseFromParent();
- changed = true;
+ Changed = true;
}
- return changed;
+ return Changed;
}
void eraseIfNoUse(Value *V) {
@@ -1280,27 +1280,27 @@ void eraseIfNoUse(Value *V) {
}
bool eraseUselessFunctions(Module *M) {
- bool changed = false;
+ bool Changed = false;
for (auto I = M->begin(), E = M->end(); I != E;)
- changed |= eraseIfNoUse(&(*I++));
- return changed;
+ Changed |= eraseIfNoUse(&(*I++));
+ return Changed;
}
// The mangling algorithm follows OpenCL pipe built-ins clang 3.8 CodeGen rules.
-static SPIR::MangleError manglePipeBuiltin(const SPIR::FunctionDescriptor &fd,
- std::string &mangledName) {
- assert(SPIR::isPipeBuiltin(fd.name) &&
+static SPIR::MangleError manglePipeBuiltin(const SPIR::FunctionDescriptor &Fd,
+ std::string &MangledName) {
+ assert(SPIR::isPipeBuiltin(Fd.Name) &&
"Method is expected to be called only for pipe builtins!");
- if (fd.isNull()) {
- mangledName.assign(SPIR::FunctionDescriptor::nullString());
+ if (Fd.isNull()) {
+ MangledName.assign(SPIR::FunctionDescriptor::nullString());
return SPIR::MANGLE_NULL_FUNC_DESCRIPTOR;
}
- mangledName.assign("__" + fd.name);
- if (fd.name == "write_pipe" || fd.name == "read_pipe") {
+ MangledName.assign("__" + Fd.Name);
+ if (Fd.Name == "write_pipe" || Fd.Name == "read_pipe") {
// add "_2" or "_4" postfix reflecting the number of explicit args.
- mangledName.append("_");
+ MangledName.append("_");
// subtruct 2 in order to not count size and alignment of packet.
- mangledName.append(std::to_string(fd.parameters.size() - 2));
+ MangledName.append(std::to_string(Fd.Parameters.size() - 2));
}
return SPIR::MANGLE_SUCCESS;
}
@@ -1314,14 +1314,14 @@ std::string mangleBuiltin(const std::string &UniqName,
std::string MangledName;
DEBUG(dbgs() << "[mangle] " << UniqName << " => ");
SPIR::FunctionDescriptor FD;
- FD.name = BtnInfo->getUnmangledName();
+ FD.Name = BtnInfo->getUnmangledName();
bool BIVarArgNegative = BtnInfo->getVarArg() < 0;
if (ArgTypes.empty()) {
// Function signature cannot be ()(void, ...) so if there is an ellipsis
// it must be ()(...)
if (BIVarArgNegative) {
- FD.parameters.emplace_back(
+ FD.Parameters.emplace_back(
SPIR::RefParamType(new SPIR::PrimitiveType(SPIR::PRIMITIVE_VOID)));
}
} else {
@@ -1329,7 +1329,7 @@ std::string mangleBuiltin(const std::string &UniqName,
: (unsigned)BtnInfo->getVarArg();
I != E; ++I) {
auto T = ArgTypes[I];
- FD.parameters.emplace_back(
+ FD.Parameters.emplace_back(
transTypeDesc(T, BtnInfo->getTypeMangleInfo(I)));
}
}
@@ -1337,7 +1337,7 @@ std::string mangleBuiltin(const std::string &UniqName,
if (!BIVarArgNegative) {
assert((unsigned)BtnInfo->getVarArg() <= ArgTypes.size() &&
"invalid index of an ellipsis");
- FD.parameters.emplace_back(
+ FD.Parameters.emplace_back(
SPIR::RefParamType(new SPIR::PrimitiveType(SPIR::PRIMITIVE_VAR_ARG)));
}
@@ -1357,7 +1357,7 @@ std::string mangleBuiltin(const std::string &UniqName,
return MangledName;
}
-/// Check if access qualifier is encoded in the type name.
+/// Check if access qualifier is encoded in the type Name.
bool hasAccessQualifiedName(StringRef TyName) {
if (TyName.endswith("_ro_t") || TyName.endswith("_wo_t") ||
TyName.endswith("_rw_t"))
@@ -1365,7 +1365,7 @@ bool hasAccessQualifiedName(StringRef TyName) {
return false;
}
-/// Get access qualifier from the type name.
+/// Get access qualifier from the type Name.
StringRef getAccessQualifier(StringRef TyName) {
assert(hasAccessQualifiedName(TyName) &&
"Type is not qualified with access.");
diff --git a/lib/SPIRV/SPIRVWriter.cpp b/lib/SPIRV/SPIRVWriter.cpp
index f52db31..c0829b6 100644
--- a/lib/SPIRV/SPIRVWriter.cpp
+++ b/lib/SPIRV/SPIRVWriter.cpp
@@ -799,9 +799,9 @@ SPIRVValue *LLVMToSPIRV::transValue(Value *V, SPIRVBasicBlock *BB,
auto BV = transValueWithoutDecoration(V, BB, CreateForward);
if (!BV || !transDecoration(V, BV))
return nullptr;
- std::string name = V->getName();
- if (!name.empty()) // Don't erase the name, which BM might already have
- BM->setName(BV, name);
+ std::string Name = V->getName();
+ if (!Name.empty()) // Don't erase the name, which BM might already have
+ BM->setName(BV, Name);
return BV;
}
@@ -1092,8 +1092,8 @@ SPIRVValue *LLVMToSPIRV::transValueWithoutDecoration(Value *V,
if (GetElementPtrInst *GEP = dyn_cast<GetElementPtrInst>(V)) {
std::vector<SPIRVValue *> Indices;
- for (unsigned i = 0, e = GEP->getNumIndices(); i != e; ++i)
- Indices.push_back(transValue(GEP->getOperand(i + 1), BB));
+ for (unsigned I = 0, E = GEP->getNumIndices(); I != E; ++I)
+ Indices.push_back(transValue(GEP->getOperand(I + 1), BB));
return mapValue(
V, BM->addPtrAccessChainInst(transType(GEP->getType()),
transValue(GEP->getPointerOperand(), BB),
@@ -1235,7 +1235,7 @@ SPIRVValue *LLVMToSPIRV::transSpcvCast(CallInst *CI, SPIRVBasicBlock *BB) {
SPIRVValue *LLVMToSPIRV::transIntrinsicInst(IntrinsicInst *II,
SPIRVBasicBlock *BB) {
- auto getMemoryAccess = [](MemIntrinsic *MI) -> std::vector<SPIRVWord> {
+ auto GetMemoryAccess = [](MemIntrinsic *MI) -> std::vector<SPIRVWord> {
std::vector<SPIRVWord> MemoryAccess(1, MemoryAccessMaskNone);
if (SPIRVWord AlignVal = MI->getDestAlignment()) {
MemoryAccess[0] |= MemoryAccessAlignedMask;
@@ -1291,7 +1291,7 @@ SPIRVValue *LLVMToSPIRV::transIntrinsicInst(IntrinsicInst *II,
SPIRVValue *Source = BM->addUnaryInst(OpBitcast, SourceTy, Var, BB);
SPIRVValue *Target = transValue(MSI->getRawDest(), BB);
return BM->addCopyMemorySizedInst(Target, Source, CompositeTy->getLength(),
- getMemoryAccess(MSI), BB);
+ GetMemoryAccess(MSI), BB);
} break;
case Intrinsic::memcpy:
assert(cast<MemCpyInst>(II)->getSourceAlignment() ==
@@ -1300,7 +1300,7 @@ SPIRVValue *LLVMToSPIRV::transIntrinsicInst(IntrinsicInst *II,
return BM->addCopyMemorySizedInst(
transValue(II->getOperand(0), BB), transValue(II->getOperand(1), BB),
transValue(II->getOperand(2), BB),
- getMemoryAccess(cast<MemIntrinsic>(II)), BB);
+ GetMemoryAccess(cast<MemIntrinsic>(II)), BB);
case Intrinsic::lifetime_start:
return transLifetimeIntrinsicInst(OpLifetimeStart, II, BB);
case Intrinsic::lifetime_end:
@@ -1336,13 +1336,13 @@ SPIRVValue *LLVMToSPIRV::transCallInst(CallInst *CI, SPIRVBasicBlock *BB) {
BM->addExtInst(
transType(CI->getType()), ExtSetId, ExtOp,
transArguments(CI, BB,
- SPIRVEntry::create_unique(ExtSetKind, ExtOp).get()),
+ SPIRVEntry::createUnique(ExtSetKind, ExtOp).get()),
BB),
Dec);
return BM->addCallInst(
transFunctionDecl(CI->getCalledFunction()),
- transArguments(CI, BB, SPIRVEntry::create_unique(OpFunctionCall).get()),
+ transArguments(CI, BB, SPIRVEntry::createUnique(OpFunctionCall).get()),
BB);
}
@@ -1458,7 +1458,7 @@ void LLVMToSPIRV::transFunction(Function *I) {
}
bool LLVMToSPIRV::translate() {
- BM->setGeneratorVer(kTranslatorVer);
+ BM->setGeneratorVer(KTranslatorVer);
if (!transSourceLanguage())
return false;
@@ -1585,7 +1585,7 @@ bool LLVMToSPIRV::transExecutionMode() {
bool LLVMToSPIRV::transOCLKernelMetadata() {
NamedMDNode *KernelMDs = M->getNamedMetadata(SPIR_MD_KERNELS);
- std::vector<std::string> argAccessQual;
+ std::vector<std::string> ArgAccessQual;
if (!KernelMDs)
return true;
@@ -1802,7 +1802,7 @@ void addPassesForSPIRV(legacy::PassManager &PassMgr) {
PassMgr.add(createSPIRVLowerMemmove());
}
-bool llvm::WriteSPIRV(Module *M, llvm::raw_ostream &OS, std::string &ErrMsg) {
+bool llvm::writeSpirv(Module *M, llvm::raw_ostream &OS, std::string &ErrMsg) {
std::unique_ptr<SPIRVModule> BM(SPIRVModule::createSPIRVModule());
legacy::PassManager PassMgr;
addPassesForSPIRV(PassMgr);
@@ -1815,7 +1815,7 @@ bool llvm::WriteSPIRV(Module *M, llvm::raw_ostream &OS, std::string &ErrMsg) {
return true;
}
-bool llvm::RegularizeLLVMForSPIRV(Module *M, std::string &ErrMsg) {
+bool llvm::regularizeLlvmForSpirv(Module *M, std::string &ErrMsg) {
std::unique_ptr<SPIRVModule> BM(SPIRVModule::createSPIRVModule());
legacy::PassManager PassMgr;
addPassesForSPIRV(PassMgr);
diff --git a/lib/SPIRV/SPIRVWriterPass.cpp b/lib/SPIRV/SPIRVWriterPass.cpp
index 53ced30..ed029d2 100644
--- a/lib/SPIRV/SPIRVWriterPass.cpp
+++ b/lib/SPIRV/SPIRVWriterPass.cpp
@@ -20,8 +20,8 @@ using namespace llvm;
PreservedAnalyses SPIRVWriterPass::run(Module &M) {
// FIXME: at the moment LLVM/SPIR-V translation errors are ignored.
- std::string err;
- WriteSPIRV(&M, OS, err);
+ std::string Err;
+ writeSpirv(&M, OS, Err);
return PreservedAnalyses::all();
}
@@ -30,14 +30,14 @@ class WriteSPIRVPass : public ModulePass {
raw_ostream &OS; // raw_ostream to print on
public:
static char ID; // Pass identification, replacement for typeid
- explicit WriteSPIRVPass(raw_ostream &o) : ModulePass(ID), OS(o) {}
+ explicit WriteSPIRVPass(raw_ostream &O) : ModulePass(ID), OS(O) {}
StringRef getPassName() const override { return "SPIRV Writer"; }
bool runOnModule(Module &M) override {
// FIXME: at the moment LLVM/SPIR-V translation errors are ignored.
- std::string err;
- WriteSPIRV(&M, OS, err);
+ std::string Err;
+ writeSpirv(&M, OS, Err);
return false;
}
};
diff --git a/lib/SPIRV/libSPIRV/SPIRVBasicBlock.cpp b/lib/SPIRV/libSPIRV/SPIRVBasicBlock.cpp
index 5b597c5..f749337 100644
--- a/lib/SPIRV/libSPIRV/SPIRVBasicBlock.cpp
+++ b/lib/SPIRV/libSPIRV/SPIRVBasicBlock.cpp
@@ -69,8 +69,8 @@ SPIRVInstruction *SPIRVBasicBlock::addInstruction(SPIRVInstruction *I) {
void SPIRVBasicBlock::encodeChildren(spv_ostream &O) const {
O << SPIRVNL();
- for (size_t i = 0, e = InstVec.size(); i != e; ++i)
- O << *InstVec[i];
+ for (size_t I = 0, E = InstVec.size(); I != E; ++I)
+ O << *InstVec[I];
}
_SPIRV_IMP_ENCDEC1(SPIRVBasicBlock, Id)
diff --git a/lib/SPIRV/libSPIRV/SPIRVDecorate.cpp b/lib/SPIRV/libSPIRV/SPIRVDecorate.cpp
index 5b81bf8..35aeadc 100644
--- a/lib/SPIRV/libSPIRV/SPIRVDecorate.cpp
+++ b/lib/SPIRV/libSPIRV/SPIRVDecorate.cpp
@@ -77,9 +77,9 @@ SPIRVDecorateGeneric::SPIRVDecorateGeneric(Op OC)
Decoration SPIRVDecorateGeneric::getDecorateKind() const { return Dec; }
-SPIRVWord SPIRVDecorateGeneric::getLiteral(size_t i) const {
- assert(i <= Literals.size() && "Out of bounds");
- return Literals[i];
+SPIRVWord SPIRVDecorateGeneric::getLiteral(size_t I) const {
+ assert(I <= Literals.size() && "Out of bounds");
+ return Literals[I];
}
size_t SPIRVDecorateGeneric::getLiteralCount() const { return Literals.size(); }
diff --git a/lib/SPIRV/libSPIRV/SPIRVDecorate.h b/lib/SPIRV/libSPIRV/SPIRVDecorate.h
index 1e49993..02e0095 100644
--- a/lib/SPIRV/libSPIRV/SPIRVDecorate.h
+++ b/lib/SPIRV/libSPIRV/SPIRVDecorate.h
@@ -74,7 +74,7 @@ public:
SPIRVDecorationGroup *getOwner() const { return Owner; }
- void setOwner(SPIRVDecorationGroup *owner) { Owner = owner; }
+ void setOwner(SPIRVDecorationGroup *Owner) { this->Owner = Owner; }
SPIRVCapVec getRequiredCapability() const override {
return getCapability(Dec);
diff --git a/lib/SPIRV/libSPIRV/SPIRVEntry.cpp b/lib/SPIRV/libSPIRV/SPIRVEntry.cpp
index cf827b6..6678434 100644
--- a/lib/SPIRV/libSPIRV/SPIRVEntry.cpp
+++ b/lib/SPIRV/libSPIRV/SPIRVEntry.cpp
@@ -88,12 +88,12 @@ SPIRVEntry *SPIRVEntry::create(Op OpCode) {
return 0;
}
-std::unique_ptr<SPIRV::SPIRVEntry> SPIRVEntry::create_unique(Op OC) {
+std::unique_ptr<SPIRV::SPIRVEntry> SPIRVEntry::createUnique(Op OC) {
return std::unique_ptr<SPIRVEntry>(create(OC));
}
std::unique_ptr<SPIRV::SPIRVExtInst>
-SPIRVEntry::create_unique(SPIRVExtInstSetKind Set, unsigned ExtOp) {
+SPIRVEntry::createUnique(SPIRVExtInstSetKind Set, unsigned ExtOp) {
return std::unique_ptr<SPIRVExtInst>(new SPIRVExtInst(Set, ExtOp));
}
@@ -205,24 +205,24 @@ void SPIRVEntry::decode(std::istream &I) { assert(0 && "Not implemented"); }
std::vector<SPIRVValue *>
SPIRVEntry::getValues(const std::vector<SPIRVId> &IdVec) const {
std::vector<SPIRVValue *> ValueVec;
- for (auto i : IdVec)
- ValueVec.push_back(getValue(i));
+ for (auto I : IdVec)
+ ValueVec.push_back(getValue(I));
return ValueVec;
}
std::vector<SPIRVType *>
SPIRVEntry::getValueTypes(const std::vector<SPIRVId> &IdVec) const {
std::vector<SPIRVType *> TypeVec;
- for (auto i : IdVec)
- TypeVec.push_back(getValue(i)->getType());
+ for (auto I : IdVec)
+ TypeVec.push_back(getValue(I)->getType());
return TypeVec;
}
std::vector<SPIRVId>
SPIRVEntry::getIds(const std::vector<SPIRVValue *> ValueVec) const {
std::vector<SPIRVId> IdVec;
- for (auto i : ValueVec)
- IdVec.push_back(i->getId());
+ for (auto I : ValueVec)
+ IdVec.push_back(I->getId());
return IdVec;
}
@@ -339,8 +339,8 @@ bool SPIRVEntry::hasLinkageType() const {
}
void SPIRVEntry::encodeDecorate(spv_ostream &O) const {
- for (auto &i : Decorates)
- O << *i.second;
+ for (auto &I : Decorates)
+ O << *I.second;
}
SPIRVLinkageTypeKind SPIRVEntry::getLinkageType() const {
diff --git a/lib/SPIRV/libSPIRV/SPIRVEntry.h b/lib/SPIRV/libSPIRV/SPIRVEntry.h
index 3ff4b7d..9411fa5 100644
--- a/lib/SPIRV/libSPIRV/SPIRVEntry.h
+++ b/lib/SPIRV/libSPIRV/SPIRVEntry.h
@@ -341,11 +341,11 @@ public:
/// Create an empty SPIRV object by op code, e.g. OpTypeInt creates
/// SPIRVTypeInt.
static SPIRVEntry *create(Op);
- static std::unique_ptr<SPIRVEntry> create_unique(Op);
+ static std::unique_ptr<SPIRVEntry> createUnique(Op);
/// Create an empty extended instruction.
- static std::unique_ptr<SPIRVExtInst> create_unique(SPIRVExtInstSetKind Set,
- unsigned ExtOp);
+ static std::unique_ptr<SPIRVExtInst> createUnique(SPIRVExtInstSetKind Set,
+ unsigned ExtOp);
friend spv_ostream &operator<<(spv_ostream &O, const SPIRVEntry &E);
friend std::istream &operator>>(std::istream &I, SPIRVEntry &E);
@@ -547,7 +547,7 @@ public:
SPIRVWord getColumn() const { return Column; }
- void setColumn(const SPIRVWord column) { Column = column; }
+ void setColumn(const SPIRVWord Column) { this->Column = Column; }
SPIRVId getFileName() const { return FileName; }
@@ -555,11 +555,11 @@ public:
return get<SPIRVString>(FileName)->getStr();
}
- void setFileName(const SPIRVId fileName) { FileName = fileName; }
+ void setFileName(const SPIRVId FileName) { this->FileName = FileName; }
SPIRVWord getLine() const { return Line; }
- void setLine(const SPIRVWord line) { Line = line; }
+ void setLine(const SPIRVWord Line) { this->Line = Line; }
bool operator!=(const SPIRVLine &O) const {
return !equals(O.FileName, O.Line, O.Column);
@@ -582,18 +582,18 @@ class SPIRVExecutionMode : public SPIRVAnnotation<OpExecutionMode> {
public:
// Complete constructor for LocalSize, LocalSizeHint
SPIRVExecutionMode(SPIRVEntry *TheTarget, SPIRVExecutionModeKind TheExecMode,
- SPIRVWord x, SPIRVWord y, SPIRVWord z)
+ SPIRVWord X, SPIRVWord Y, SPIRVWord Z)
: SPIRVAnnotation(TheTarget, 6), ExecMode(TheExecMode) {
- WordLiterals.push_back(x);
- WordLiterals.push_back(y);
- WordLiterals.push_back(z);
+ WordLiterals.push_back(X);
+ WordLiterals.push_back(Y);
+ WordLiterals.push_back(Z);
updateModuleVersion();
}
// Complete constructor for VecTypeHint, SubgroupSize, SubgroupsPerWorkgroup
SPIRVExecutionMode(SPIRVEntry *TheTarget, SPIRVExecutionModeKind TheExecMode,
- SPIRVWord code)
+ SPIRVWord Code)
: SPIRVAnnotation(TheTarget, 4), ExecMode(TheExecMode) {
- WordLiterals.push_back(code);
+ WordLiterals.push_back(Code);
updateModuleVersion();
}
// Complete constructor for ContractionOff
diff --git a/lib/SPIRV/libSPIRV/SPIRVEnum.h b/lib/SPIRV/libSPIRV/SPIRVEnum.h
index 0572e54..8c902d1 100644
--- a/lib/SPIRV/libSPIRV/SPIRVEnum.h
+++ b/lib/SPIRV/libSPIRV/SPIRVEnum.h
@@ -59,7 +59,7 @@ inline SPIRVWord mkWord(unsigned WordCount, Op OpCode) {
return (WordCount << 16) | OpCode;
}
-const static unsigned kSPIRVMemOrderSemanticMask = 0x1F;
+const static unsigned KSpirvMemOrderSemanticMask = 0x1F;
enum SPIRVVersion : SPIRVWord {
SPIRV_1_0 = 0x00010000,
@@ -403,7 +403,7 @@ inline unsigned getImageDimension(SPIRVImageDimKind K) {
/// Extract memory order part of SPIR-V memory semantics.
inline unsigned extractSPIRVMemOrderSemantic(unsigned Sema) {
- return Sema & kSPIRVMemOrderSemanticMask;
+ return Sema & KSpirvMemOrderSemanticMask;
}
} // namespace SPIRV
diff --git a/lib/SPIRV/libSPIRV/SPIRVFunction.h b/lib/SPIRV/libSPIRV/SPIRVFunction.h
index 11c71df..d4af072 100644
--- a/lib/SPIRV/libSPIRV/SPIRVFunction.h
+++ b/lib/SPIRV/libSPIRV/SPIRVFunction.h
@@ -100,12 +100,12 @@ public:
SPIRVTypeFunction *getFunctionType() const { return FuncType; }
SPIRVWord getFuncCtlMask() const { return FCtrlMask; }
size_t getNumBasicBlock() const { return BBVec.size(); }
- SPIRVBasicBlock *getBasicBlock(size_t i) const { return BBVec[i]; }
+ SPIRVBasicBlock *getBasicBlock(size_t I) const { return BBVec[I]; }
size_t getNumArguments() const {
return getFunctionType()->getNumParameters();
}
- SPIRVId getArgumentId(size_t i) const { return Parameters[i]->getId(); }
- SPIRVFunctionParameter *getArgument(size_t i) const { return Parameters[i]; }
+ SPIRVId getArgumentId(size_t I) const { return Parameters[I]->getId(); }
+ SPIRVFunctionParameter *getArgument(size_t I) const { return Parameters[I]; }
void foreachArgument(std::function<void(SPIRVFunctionParameter *)> Func) {
for (size_t I = 0, E = getNumArguments(); I != E; ++I)
Func(getArgument(I));
@@ -145,8 +145,8 @@ private:
}
void addAllArguments(SPIRVId FirstArgId) {
- for (size_t i = 0, e = getFunctionType()->getNumParameters(); i != e; ++i)
- addArgument(i, FirstArgId + i);
+ for (size_t I = 0, E = getFunctionType()->getNumParameters(); I != E; ++I)
+ addArgument(I, FirstArgId + I);
}
void decodeBB(SPIRVDecoder &);
diff --git a/lib/SPIRV/libSPIRV/SPIRVInstruction.h b/lib/SPIRV/libSPIRV/SPIRVInstruction.h
index 7ee2c29..fc88551 100644
--- a/lib/SPIRV/libSPIRV/SPIRVInstruction.h
+++ b/lib/SPIRV/libSPIRV/SPIRVInstruction.h
@@ -381,12 +381,12 @@ class SPIRVMemoryAccess {
public:
SPIRVMemoryAccess(const std::vector<SPIRVWord> &TheMemoryAccess)
: TheMemoryAccessMask(0), Alignment(0) {
- MemoryAccessUpdate(TheMemoryAccess);
+ memoryAccessUpdate(TheMemoryAccess);
}
SPIRVMemoryAccess() : TheMemoryAccessMask(0), Alignment(0) {}
- void MemoryAccessUpdate(const std::vector<SPIRVWord> &MemoryAccess) {
+ void memoryAccessUpdate(const std::vector<SPIRVWord> &MemoryAccess) {
if (!MemoryAccess.size())
return;
assert((MemoryAccess.size() == 1 || MemoryAccess.size() == 2) &&
@@ -520,7 +520,7 @@ protected:
void decode(std::istream &I) override {
getDecoder(I) >> PtrId >> ValId >> MemoryAccess;
- MemoryAccessUpdate(MemoryAccess);
+ memoryAccessUpdate(MemoryAccess);
}
void validate() const override {
@@ -572,7 +572,7 @@ protected:
void decode(std::istream &I) override {
getDecoder(I) >> Type >> Id >> PtrId >> MemoryAccess;
- MemoryAccessUpdate(MemoryAccess);
+ memoryAccessUpdate(MemoryAccess);
}
void validate() const override {
@@ -592,40 +592,40 @@ protected:
void validate() const override {
SPIRVId Op1 = Ops[0];
SPIRVId Op2 = Ops[1];
- SPIRVType *op1Ty, *op2Ty;
+ SPIRVType *Op1Ty, *Op2Ty;
SPIRVInstruction::validate();
if (getValue(Op1)->isForward() || getValue(Op2)->isForward())
return;
if (getValueType(Op1)->isTypeVector()) {
- op1Ty = getValueType(Op1)->getVectorComponentType();
- op2Ty = getValueType(Op2)->getVectorComponentType();
+ Op1Ty = getValueType(Op1)->getVectorComponentType();
+ Op2Ty = getValueType(Op2)->getVectorComponentType();
assert(getValueType(Op1)->getVectorComponentCount() ==
getValueType(Op2)->getVectorComponentCount() &&
"Inconsistent Vector component width");
} else {
- op1Ty = getValueType(Op1);
- op2Ty = getValueType(Op2);
+ Op1Ty = getValueType(Op1);
+ Op2Ty = getValueType(Op2);
}
- (void)op1Ty;
- (void)op2Ty;
+ (void)Op1Ty;
+ (void)Op2Ty;
if (isBinaryOpCode(OpCode)) {
assert(getValueType(Op1) == getValueType(Op2) &&
"Invalid type for binary instruction");
- assert((op1Ty->isTypeInt() || op2Ty->isTypeFloat()) &&
+ assert((Op1Ty->isTypeInt() || Op2Ty->isTypeFloat()) &&
"Invalid type for Binary instruction");
- assert((op1Ty->getBitWidth() == op2Ty->getBitWidth()) &&
+ assert((Op1Ty->getBitWidth() == Op2Ty->getBitWidth()) &&
"Inconsistent BitWidth");
} else if (isShiftOpCode(OpCode)) {
- assert((op1Ty->isTypeInt() || op2Ty->isTypeInt()) &&
+ assert((Op1Ty->isTypeInt() || Op2Ty->isTypeInt()) &&
"Invalid type for shift instruction");
} else if (isLogicalOpCode(OpCode)) {
- assert((op1Ty->isTypeBool() || op2Ty->isTypeBool()) &&
+ assert((Op1Ty->isTypeBool() || Op2Ty->isTypeBool()) &&
"Invalid type for logical instruction");
} else if (isBitwiseOpCode(OpCode)) {
- assert((op1Ty->isTypeInt() || op2Ty->isTypeInt()) &&
+ assert((Op1Ty->isTypeInt() || Op2Ty->isTypeInt()) &&
"Invalid type for bitwise instruction");
- assert((op1Ty->getIntegerBitWidth() == op2Ty->getIntegerBitWidth()) &&
+ assert((Op1Ty->getIntegerBitWidth() == Op2Ty->getIntegerBitWidth()) &&
"Inconsistent BitWidth");
} else {
assert(0 && "Invalid op code!");
@@ -867,30 +867,30 @@ protected:
void validate() const override {
auto Op1 = Ops[0];
auto Op2 = Ops[1];
- SPIRVType *op1Ty, *op2Ty, *resTy;
+ SPIRVType *Op1Ty, *Op2Ty, *ResTy;
SPIRVInstruction::validate();
if (getValue(Op1)->isForward() || getValue(Op2)->isForward())
return;
- (void)op1Ty;
- (void)op2Ty;
- (void)resTy;
+ (void)Op1Ty;
+ (void)Op2Ty;
+ (void)ResTy;
if (getValueType(Op1)->isTypeVector()) {
- op1Ty = getValueType(Op1)->getVectorComponentType();
- op2Ty = getValueType(Op2)->getVectorComponentType();
- resTy = Type->getVectorComponentType();
+ Op1Ty = getValueType(Op1)->getVectorComponentType();
+ Op2Ty = getValueType(Op2)->getVectorComponentType();
+ ResTy = Type->getVectorComponentType();
assert(getValueType(Op1)->getVectorComponentCount() ==
getValueType(Op2)->getVectorComponentCount() &&
"Inconsistent Vector component width");
} else {
- op1Ty = getValueType(Op1);
- op2Ty = getValueType(Op2);
- resTy = Type;
+ Op1Ty = getValueType(Op1);
+ Op2Ty = getValueType(Op2);
+ ResTy = Type;
}
assert(isCmpOpCode(OpCode) && "Invalid op code for cmp inst");
- assert((resTy->isTypeBool() || resTy->isTypeInt()) &&
+ assert((ResTy->isTypeBool() || ResTy->isTypeInt()) &&
"Invalid type for compare instruction");
- assert(op1Ty == op2Ty && "Inconsistent types");
+ assert(Op1Ty == Op2Ty && "Inconsistent types");
}
};
@@ -953,11 +953,11 @@ protected:
getValue(Op2)->isForward())
return;
- SPIRVType *conTy = getValueType(Condition)->isTypeVector()
+ SPIRVType *ConTy = getValueType(Condition)->isTypeVector()
? getValueType(Condition)->getVectorComponentType()
: getValueType(Condition);
- (void)conTy;
- assert(conTy->isTypeBool() && "Invalid type");
+ (void)ConTy;
+ assert(ConTy->isTypeBool() && "Invalid type");
assert(getType() == getValueType(Op1) && getType() == getValueType(Op2) &&
"Inconsistent type");
}
@@ -1073,8 +1073,8 @@ public:
if (!Module->exist(Pairs[PairSize * I + getLiteralsCount()], &BB))
continue;
- for (size_t i = 0; i < getLiteralsCount(); ++i) {
- Literals.push_back(Pairs.at(PairSize * I + i));
+ for (size_t J = 0; J < getLiteralsCount(); ++J) {
+ Literals.push_back(Pairs.at(PairSize * I + J));
}
Func(Literals, static_cast<SPIRVBasicBlock *>(BB));
}
@@ -1203,18 +1203,18 @@ protected:
if (getValue(Op)->isForward())
return;
if (isGenericNegateOpCode(OpCode)) {
- SPIRVType *resTy =
+ SPIRVType *ResTy =
Type->isTypeVector() ? Type->getVectorComponentType() : Type;
- SPIRVType *opTy = Type->isTypeVector()
+ SPIRVType *OpTy = Type->isTypeVector()
? getValueType(Op)->getVectorComponentType()
: getValueType(Op);
- (void)resTy;
- (void)opTy;
+ (void)ResTy;
+ (void)OpTy;
assert(getType() == getValueType(Op) && "Inconsistent type");
- assert((resTy->isTypeInt() || resTy->isTypeFloat()) &&
+ assert((ResTy->isTypeInt() || ResTy->isTypeFloat()) &&
"Invalid type for Generic Negate instruction");
- assert((resTy->getBitWidth() == opTy->getBitWidth()) &&
+ assert((ResTy->getBitWidth() == OpTy->getBitWidth()) &&
"Invalid bitwidth for Generic Negate instruction");
assert((Type->isTypeVector()
? (Type->getVectorComponentCount() ==
@@ -1614,7 +1614,7 @@ protected:
void decode(std::istream &I) override {
getDecoder(I) >> Target >> Source >> MemoryAccess;
- MemoryAccessUpdate(MemoryAccess);
+ memoryAccessUpdate(MemoryAccess);
}
void validate() const override {
@@ -1670,7 +1670,7 @@ protected:
void decode(std::istream &I) override {
getDecoder(I) >> Target >> Source >> Size >> MemoryAccess;
- MemoryAccessUpdate(MemoryAccess);
+ memoryAccessUpdate(MemoryAccess);
}
void validate() const override { SPIRVInstruction::validate(); }
diff --git a/lib/SPIRV/libSPIRV/SPIRVModule.cpp b/lib/SPIRV/libSPIRV/SPIRVModule.cpp
index 0a24dbf..3be592c 100644
--- a/lib/SPIRV/libSPIRV/SPIRVModule.cpp
+++ b/lib/SPIRV/libSPIRV/SPIRVModule.cpp
@@ -608,12 +608,12 @@ bool SPIRVModuleImpl::exist(SPIRVId Id, SPIRVEntry **Entry) const {
// If Id is invalid, returns the next available id.
// Otherwise returns the given id and adjust the next available id by increment.
-SPIRVId SPIRVModuleImpl::getId(SPIRVId Id, unsigned increment) {
+SPIRVId SPIRVModuleImpl::getId(SPIRVId Id, unsigned Increment) {
if (!isValidId(Id))
Id = NextId;
else
NextId = std::max(Id, NextId);
- NextId += increment;
+ NextId += Increment;
return Id;
}
@@ -809,8 +809,8 @@ void SPIRVModuleImpl::createForwardPointers() {
auto ST = static_cast<SPIRVTypeStruct *>(T);
- for (unsigned i = 0; i < ST->getStructMemberCount(); ++i) {
- auto MemberTy = ST->getStructMemberType(i);
+ for (unsigned I = 0; I < ST->getStructMemberCount(); ++I) {
+ auto MemberTy = ST->getStructMemberType(I);
if (!MemberTy->isTypePointer())
continue;
auto Ptr = static_cast<SPIRVTypePointer *>(MemberTy);
@@ -1311,20 +1311,20 @@ class TopologicalSort {
}
public:
- TopologicalSort(const SPIRVTypeVec &_TypeVec,
- const SPIRVConstantVector &_ConstVec,
- const SPIRVVariableVec &_VariableVec,
- const SPIRVForwardPointerVec &_ForwardPointerVec)
- : ForwardPointerVec(_ForwardPointerVec),
- EntryStateMap([](SPIRVEntry *a, SPIRVEntry *b) -> bool {
- return a->getId() < b->getId();
+ TopologicalSort(const SPIRVTypeVec &TypeVec,
+ const SPIRVConstantVector &ConstVec,
+ const SPIRVVariableVec &VariableVec,
+ const SPIRVForwardPointerVec &ForwardPointerVec)
+ : ForwardPointerVec(ForwardPointerVec),
+ EntryStateMap([](SPIRVEntry *A, SPIRVEntry *B) -> bool {
+ return A->getId() < B->getId();
}) {
// Collect entries for sorting
- for (auto *T : _TypeVec)
+ for (auto *T : TypeVec)
EntryStateMap[T] = DFSState::Unvisited;
- for (auto *C : _ConstVec)
+ for (auto *C : ConstVec)
EntryStateMap[C] = DFSState::Unvisited;
- for (auto *V : _VariableVec)
+ for (auto *V : VariableVec)
EntryStateMap[V] = DFSState::Unvisited;
// Run topoligical sort
for (auto ES : EntryStateMap)
@@ -1513,32 +1513,32 @@ SPIRVType *SPIRVModuleImpl::getValueType(SPIRVId TheId) const {
std::vector<SPIRVValue *>
SPIRVModuleImpl::getValues(const std::vector<SPIRVId> &IdVec) const {
std::vector<SPIRVValue *> ValueVec;
- for (auto i : IdVec)
- ValueVec.push_back(getValue(i));
+ for (auto I : IdVec)
+ ValueVec.push_back(getValue(I));
return ValueVec;
}
std::vector<SPIRVType *>
SPIRVModuleImpl::getValueTypes(const std::vector<SPIRVId> &IdVec) const {
std::vector<SPIRVType *> TypeVec;
- for (auto i : IdVec)
- TypeVec.push_back(getValue(i)->getType());
+ for (auto I : IdVec)
+ TypeVec.push_back(getValue(I)->getType());
return TypeVec;
}
std::vector<SPIRVId>
SPIRVModuleImpl::getIds(const std::vector<SPIRVEntry *> &ValueVec) const {
std::vector<SPIRVId> IdVec;
- for (auto i : ValueVec)
- IdVec.push_back(i->getId());
+ for (auto I : ValueVec)
+ IdVec.push_back(I->getId());
return IdVec;
}
std::vector<SPIRVId>
SPIRVModuleImpl::getIds(const std::vector<SPIRVValue *> &ValueVec) const {
std::vector<SPIRVId> IdVec;
- for (auto i : ValueVec)
- IdVec.push_back(i->getId());
+ for (auto I : ValueVec)
+ IdVec.push_back(I->getId());
return IdVec;
}
@@ -1582,7 +1582,7 @@ unsigned SPIRVDbgInfo::getFunctionLineNo(SPIRVFunction *F) {
return 0;
}
-bool IsSPIRVBinary(const std::string &Img) {
+bool isSpirvBinary(const std::string &Img) {
if (Img.size() < sizeof(unsigned))
return false;
auto Magic = reinterpret_cast<const unsigned *>(Img.data());
@@ -1591,7 +1591,7 @@ bool IsSPIRVBinary(const std::string &Img) {
#ifdef _SPIRV_SUPPORT_TEXT_FMT
-bool ConvertSPIRV(std::istream &IS, spv_ostream &OS, std::string &ErrMsg,
+bool convertSpirv(std::istream &IS, spv_ostream &OS, std::string &ErrMsg,
bool FromText, bool ToText) {
auto SaveOpt = SPIRVUseTextFormat;
SPIRVUseTextFormat = FromText;
@@ -1611,7 +1611,7 @@ bool ConvertSPIRV(std::istream &IS, spv_ostream &OS, std::string &ErrMsg,
return true;
}
-bool IsSPIRVText(const std::string &Img) {
+bool isSpirvText(const std::string &Img) {
std::istringstream SS(Img);
unsigned Magic = 0;
SS >> Magic;
@@ -1620,9 +1620,9 @@ bool IsSPIRVText(const std::string &Img) {
return Magic == MagicNumber;
}
-bool ConvertSPIRV(std::string &Input, std::string &Out, std::string &ErrMsg,
+bool convertSpirv(std::string &Input, std::string &Out, std::string &ErrMsg,
bool ToText) {
- auto FromText = IsSPIRVText(Input);
+ auto FromText = isSpirvText(Input);
if (ToText == FromText) {
Out = Input;
return true;
@@ -1633,7 +1633,7 @@ bool ConvertSPIRV(std::string &Input, std::string &Out, std::string &ErrMsg,
#else
std::ostringstream OS;
#endif
- if (!ConvertSPIRV(IS, OS, ErrMsg, FromText, ToText))
+ if (!convertSpirv(IS, OS, ErrMsg, FromText, ToText))
return false;
Out = OS.str();
return true;
diff --git a/lib/SPIRV/libSPIRV/SPIRVModule.h b/lib/SPIRV/libSPIRV/SPIRVModule.h
index fbad3b8..3c212c4 100644
--- a/lib/SPIRV/libSPIRV/SPIRVModule.h
+++ b/lib/SPIRV/libSPIRV/SPIRVModule.h
@@ -171,8 +171,8 @@ public:
virtual SPIRVMemberName *addMemberName(SPIRVTypeStruct *ST,
SPIRVWord MemberNumber,
const std::string &Name) = 0;
- virtual void addUnknownStructField(SPIRVTypeStruct *, unsigned idx,
- SPIRVId id) = 0;
+ virtual void addUnknownStructField(SPIRVTypeStruct *, unsigned Idx,
+ SPIRVId Id) = 0;
virtual void addLine(SPIRVEntry *E, SPIRVId FileNameId, SPIRVWord Line,
SPIRVWord Column) = 0;
virtual const std::shared_ptr<const SPIRVLine> &getCurrentLine() const = 0;
diff --git a/lib/SPIRV/libSPIRV/SPIRVStream.cpp b/lib/SPIRV/libSPIRV/SPIRVStream.cpp
index 8d8ca4e..00efeae 100644
--- a/lib/SPIRV/libSPIRV/SPIRVStream.cpp
+++ b/lib/SPIRV/libSPIRV/SPIRVStream.cpp
@@ -106,7 +106,7 @@ template <class T> const SPIRVDecoder &decode(const SPIRVDecoder &I, T &V) {
return I;
}
#endif
- return DecodeBinary(I, V);
+ return decodeBinary(I, V);
}
template <class T> const SPIRVEncoder &encode(const SPIRVEncoder &O, T V) {
diff --git a/lib/SPIRV/libSPIRV/SPIRVStream.h b/lib/SPIRV/libSPIRV/SPIRVStream.h
index 9498f1c..5253aa5 100644
--- a/lib/SPIRV/libSPIRV/SPIRVStream.h
+++ b/lib/SPIRV/libSPIRV/SPIRVStream.h
@@ -95,7 +95,7 @@ class SPIRVNL {
};
template <typename T>
-const SPIRVDecoder &DecodeBinary(const SPIRVDecoder &I, T &V) {
+const SPIRVDecoder &decodeBinary(const SPIRVDecoder &I, T &V) {
uint32_t W;
I.IS.read(reinterpret_cast<char *>(&W), sizeof(W));
V = static_cast<T>(W);
@@ -114,7 +114,7 @@ const SPIRVDecoder &operator>>(const SPIRVDecoder &I, T &V) {
return I;
}
#endif
- return DecodeBinary(I, V);
+ return decodeBinary(I, V);
}
template <typename T>
@@ -135,8 +135,8 @@ const SPIRVDecoder &operator>>(const SPIRVDecoder &Decoder,
template <typename T>
const SPIRVDecoder &operator>>(const SPIRVDecoder &I, std::vector<T> &V) {
- for (size_t i = 0, e = V.size(); i != e; ++i)
- I >> V[i];
+ for (size_t J = 0, E = V.size(); J != E; ++J)
+ I >> V[J];
return I;
}
@@ -160,8 +160,8 @@ const SPIRVEncoder &operator<<(const SPIRVEncoder &O, T *P) {
template <typename T>
const SPIRVEncoder &operator<<(const SPIRVEncoder &O, const std::vector<T> &V) {
- for (size_t i = 0, e = V.size(); i != e; ++i)
- O << V[i];
+ for (size_t I = 0, E = V.size(); I != E; ++I)
+ O << V[I];
return O;
}
diff --git a/lib/SPIRV/libSPIRV/SPIRVType.h b/lib/SPIRV/libSPIRV/SPIRVType.h
index 2a9e4c7..18c35c9 100644
--- a/lib/SPIRV/libSPIRV/SPIRVType.h
+++ b/lib/SPIRV/libSPIRV/SPIRVType.h
@@ -186,8 +186,8 @@ public:
SPIRVCapVec CV;
if (isTypeFloat(16)) {
CV.push_back(CapabilityFloat16Buffer);
- auto extensions = getModule()->getExtension();
- if (std::any_of(extensions.begin(), extensions.end(),
+ auto Extensions = getModule()->getExtension();
+ if (std::any_of(Extensions.begin(), Extensions.end(),
[](const std::string &I) { return I == "cl_khr_fp16"; }))
CV.push_back(CapabilityFloat16);
} else if (isTypeFloat(64))
@@ -551,8 +551,8 @@ public:
const std::string &TheName)
: SPIRVType(M, 2 + TheMemberTypes.size(), OpTypeStruct, TheId) {
MemberTypeIdVec.resize(TheMemberTypes.size());
- for (auto &t : TheMemberTypes)
- MemberTypeIdVec.push_back(t->getId());
+ for (auto &T : TheMemberTypes)
+ MemberTypeIdVec.push_back(T->getId());
Name = TheName;
validate();
}
diff --git a/lib/SPIRV/libSPIRV/SPIRVUtil.h b/lib/SPIRV/libSPIRV/SPIRVUtil.h
index fc0bcdc..b324df7 100644
--- a/lib/SPIRV/libSPIRV/SPIRVUtil.h
+++ b/lib/SPIRV/libSPIRV/SPIRVUtil.h
@@ -127,7 +127,7 @@ public:
// For each key/value in the map executes function \p F.
// If \p F returns false break the iteration.
- static void foreach_conditional(std::function<bool(const Ty1 &, Ty2)> F) {
+ static void foreachConditional(std::function<bool(const Ty1 &, Ty2)> F) {
for (auto &I : getMap().Map) {
if (!F(I.first, I.second))
break;
@@ -270,10 +270,10 @@ template <typename K> bool getByName(const std::string &Name, K &Key) {
}
// Add a number as a string to a string
-template <class T> std::string concat(const std::string &s, const T &n) {
- std::stringstream ss;
- ss << s << n;
- return ss.str();
+template <class T> std::string concat(const std::string &S, const T &N) {
+ std::stringstream Ss;
+ Ss << S << N;
+ return Ss.str();
}
inline std::string concat(const std::string &S1, const std::string &S2,
@@ -286,12 +286,12 @@ inline std::string concat(const std::string &S1, const std::string &S2,
return S;
}
-inline std::string operator+(const std::string &s, int n) {
- return concat(s, n);
+inline std::string operator+(const std::string &S, int N) {
+ return concat(S, N);
}
-inline std::string operator+(const std::string &s, unsigned n) {
- return concat(s, n);
+inline std::string operator+(const std::string &S, unsigned N) {
+ return concat(S, N);
}
template <typename T> std::string getStr(const T &C, char Delim = ' ') {
diff --git a/lib/SPIRV/libSPIRV/SPIRVValue.h b/lib/SPIRV/libSPIRV/SPIRVValue.h
index eea5f21..f29f5ca 100644
--- a/lib/SPIRV/libSPIRV/SPIRVValue.h
+++ b/lib/SPIRV/libSPIRV/SPIRVValue.h
@@ -168,8 +168,8 @@ protected:
}
void encode(spv_ostream &O) const override {
getEncoder(O) << Type << Id;
- for (unsigned i = 0; i < NumWords; ++i)
- getEncoder(O) << Union.Words[i];
+ for (unsigned I = 0; I < NumWords; ++I)
+ getEncoder(O) << Union.Words[I];
}
void setWordCount(SPIRVWord WordCount) override {
SPIRVValue::setWordCount(WordCount);
@@ -177,8 +177,8 @@ protected:
}
void decode(std::istream &I) override {
getDecoder(I) >> Type >> Id;
- for (unsigned i = 0; i < NumWords; ++i)
- getDecoder(I) >> Union.Words[i];
+ for (unsigned J = 0; J < NumWords; ++J)
+ getDecoder(I) >> Union.Words[J];
}
unsigned NumWords;
diff --git a/tools/llvm-spirv/llvm-spirv.cpp b/tools/llvm-spirv/llvm-spirv.cpp
index 003b607..cbf2e45 100644
--- a/tools/llvm-spirv/llvm-spirv.cpp
+++ b/tools/llvm-spirv/llvm-spirv.cpp
@@ -137,11 +137,11 @@ static int convertLLVMToSPIRV() {
(SPIRV::SPIRVUseTextFormat ? kExt::SpirvText : kExt::SpirvBinary);
}
- llvm::StringRef outFile(OutputFile);
+ llvm::StringRef OutFile(OutputFile);
std::error_code EC;
std::string Err;
- llvm::raw_fd_ostream OFS(outFile, EC, llvm::sys::fs::F_None);
- if (!WriteSPIRV(M.get(), OFS, Err)) {
+ llvm::raw_fd_ostream OFS(OutFile, EC, llvm::sys::fs::F_None);
+ if (!writeSpirv(M.get(), OFS, Err)) {
errs() << "Fails to save LLVM as SPIRV: " << Err << '\n';
return -1;
}
@@ -154,7 +154,7 @@ static int convertSPIRVToLLVM() {
Module *M;
std::string Err;
- if (!ReadSPIRV(Context, IFS, M, Err)) {
+ if (!readSpirv(Context, IFS, M, Err)) {
errs() << "Fails to load SPIRV as LLVM Module: " << Err << '\n';
return -1;
}
@@ -206,7 +206,7 @@ static int convertSPIRV() {
auto Action = [&](llvm::raw_ostream &OFS) {
std::string Err;
- if (!SPIRV::ConvertSPIRV(IFS, OFS, Err, ToBinary, ToText)) {
+ if (!SPIRV::convertSpirv(IFS, OFS, Err, ToBinary, ToText)) {
errs() << "Fails to convert SPIR-V : " << Err << '\n';
return -1;
}
@@ -240,7 +240,7 @@ static int regularizeLLVM() {
}
std::string Err;
- if (!RegularizeLLVMForSPIRV(M.get(), Err)) {
+ if (!regularizeLlvmForSpirv(M.get(), Err)) {
errs() << "Fails to save LLVM as SPIRV: " << Err << '\n';
return -1;
}
@@ -257,12 +257,12 @@ static int regularizeLLVM() {
return 0;
}
-int main(int ac, char **av) {
+int main(int Ac, char **Av) {
EnablePrettyStackTrace();
- sys::PrintStackTraceOnErrorSignal(av[0]);
- PrettyStackTraceProgram X(ac, av);
+ sys::PrintStackTraceOnErrorSignal(Av[0]);
+ PrettyStackTraceProgram X(Ac, Av);
- cl::ParseCommandLineOptions(ac, av, "LLVM/SPIR-V translator");
+ cl::ParseCommandLineOptions(Ac, Av, "LLVM/SPIR-V translator");
#ifdef _SPIRV_SUPPORT_TEXT_FMT
if (ToText && (ToBinary || IsReverse || IsRegularization)) {