From 7f096f23e3fa850c4caf1be6fba732f25f5df450 Mon Sep 17 00:00:00 2001 From: Andrey Guskov Date: Wed, 22 Apr 2015 15:13:56 +0300 Subject: [PATCH] Multitaget function return types fixed --- module.cpp | 3 +-- module.h | 2 ++ type.cpp | 28 +++++++++++++++------------- 3 files changed, 18 insertions(+), 15 deletions(-) diff --git a/module.cpp b/module.cpp index 95be7352..706ec447 100644 --- a/module.cpp +++ b/module.cpp @@ -756,8 +756,7 @@ Module::AddGlobalVariable(const std::string &name, const Type *type, Expr *initE This functions returns true and issues an error if are any illegal types are found and returns false otherwise. */ -static bool -lRecursiveCheckValidParamType(const Type *t, bool vectorOk) { +bool lRecursiveCheckValidParamType(const Type *t, bool vectorOk) { const StructType *st = CastType(t); if (st != NULL) { for (int i = 0; i < st->GetElementCount(); ++i) diff --git a/module.h b/module.h index ad5f5a2e..f2d11451 100644 --- a/module.h +++ b/module.h @@ -55,6 +55,8 @@ namespace llvm struct DispatchHeaderInfo; +bool lRecursiveCheckValidParamType(const Type *t, bool vectorOk); + class Module { public: /** The name of the source file being compiled should be passed as the diff --git a/type.cpp b/type.cpp index 0f765b2a..a1b6d669 100644 --- a/type.cpp +++ b/type.cpp @@ -1847,24 +1847,26 @@ static std::map lStructTypeMap; different memory layouts... */ static std::string -lMangleStructName(const std::string &name, Variability variability) { +lMangleStructName(const std::string &name, const Type *type, + Variability variability) { char buf[32]; std::string n; - // Encode vector width - sprintf(buf, "v%d", g->target->getVectorWidth()); - n += buf; - + // Encode vector width if required + if (!lRecursiveCheckValidParamType(type, false)) { + sprintf(buf, "v%d_", g->target->getVectorWidth()); + n += buf; + } // Variability switch (variability.type) { case Variability::Uniform: - n += "_uniform_"; + n += "uniform_"; break; case Variability::Varying: - n += "_varying_"; + n += "varying_"; break; case Variability::SOA: - sprintf(buf, "_soa%d_", variability.soaWidth); + sprintf(buf, "soa%d_", variability.soaWidth); n += buf; break; default: @@ -1905,7 +1907,7 @@ StructType::StructType(const std::string &n, const llvm::SmallVectorisOpaque() == false) return; @@ -1952,7 +1954,7 @@ StructType::GetCStructName() const { // compatibility... if (variability == Variability::Varying) { - return lMangleStructName(name, variability); + return lMangleStructName(name, this, variability); } else { return GetStructName(); @@ -2187,7 +2189,7 @@ StructType::GetCDeclaration(const std::string &n) const { llvm::Type * StructType::LLVMType(llvm::LLVMContext *ctx) const { Assert(variability != Variability::Unbound); - std::string mname = lMangleStructName(name, variability); + std::string mname = lMangleStructName(name, this, variability); if (lStructTypeMap.find(mname) == lStructTypeMap.end()) { Assert(m->errorCount > 0); return NULL; @@ -2341,7 +2343,7 @@ UndefinedStructType::UndefinedStructType(const std::string &n, Assert(name != ""); if (variability != Variability::Unbound) { // Create a new opaque LLVM struct type for this struct name - std::string mname = lMangleStructName(name, variability); + std::string mname = lMangleStructName(name, this, variability); if (lStructTypeMap.find(mname) == lStructTypeMap.end()) lStructTypeMap[mname] = llvm::StructType::create(*g->ctx, mname); } @@ -2476,7 +2478,7 @@ UndefinedStructType::GetCDeclaration(const std::string &n) const { llvm::Type * UndefinedStructType::LLVMType(llvm::LLVMContext *ctx) const { Assert(variability != Variability::Unbound); - std::string mname = lMangleStructName(name, variability); + std::string mname = lMangleStructName(name, this, variability); if (lStructTypeMap.find(mname) == lStructTypeMap.end()) { Assert(m->errorCount > 0); return NULL;