Revert "Multitaget function return types fixed"

This commit is contained in:
Dmitry Babokin
2015-04-22 17:38:05 +03:00
parent 8040154b2f
commit 0f1358b69f
3 changed files with 15 additions and 18 deletions

View File

@@ -756,7 +756,8 @@ Module::AddGlobalVariable(const std::string &name, const Type *type, Expr *initE
This functions returns true and issues an error if are any illegal This functions returns true and issues an error if are any illegal
types are found and returns false otherwise. types are found and returns false otherwise.
*/ */
bool lRecursiveCheckValidParamType(const Type *t, bool vectorOk) { static bool
lRecursiveCheckValidParamType(const Type *t, bool vectorOk) {
const StructType *st = CastType<StructType>(t); const StructType *st = CastType<StructType>(t);
if (st != NULL) { if (st != NULL) {
for (int i = 0; i < st->GetElementCount(); ++i) for (int i = 0; i < st->GetElementCount(); ++i)

View File

@@ -55,8 +55,6 @@ namespace llvm
struct DispatchHeaderInfo; struct DispatchHeaderInfo;
bool lRecursiveCheckValidParamType(const Type *t, bool vectorOk);
class Module { class Module {
public: public:
/** The name of the source file being compiled should be passed as the /** The name of the source file being compiled should be passed as the

View File

@@ -1847,26 +1847,24 @@ static std::map<std::string, llvm::StructType *> lStructTypeMap;
different memory layouts... different memory layouts...
*/ */
static std::string static std::string
lMangleStructName(const std::string &name, const Type *type, lMangleStructName(const std::string &name, Variability variability) {
Variability variability) {
char buf[32]; char buf[32];
std::string n; std::string n;
// Encode vector width if required // Encode vector width
if (!lRecursiveCheckValidParamType(type, false)) { sprintf(buf, "v%d", g->target->getVectorWidth());
sprintf(buf, "v%d_", g->target->getVectorWidth()); n += buf;
n += buf;
}
// Variability // Variability
switch (variability.type) { switch (variability.type) {
case Variability::Uniform: case Variability::Uniform:
n += "uniform_"; n += "_uniform_";
break; break;
case Variability::Varying: case Variability::Varying:
n += "varying_"; n += "_varying_";
break; break;
case Variability::SOA: case Variability::SOA:
sprintf(buf, "soa%d_", variability.soaWidth); sprintf(buf, "_soa%d_", variability.soaWidth);
n += buf; n += buf;
break; break;
default: default:
@@ -1907,7 +1905,7 @@ StructType::StructType(const std::string &n, const llvm::SmallVector<const Type
// If a non-opaque LLVM struct for this type has already been // If a non-opaque LLVM struct for this type has already been
// created, we're done. For an opaque struct type, we'll override // created, we're done. For an opaque struct type, we'll override
// the old definition now that we have a full definition. // the old definition now that we have a full definition.
std::string mname = lMangleStructName(name, this, variability); std::string mname = lMangleStructName(name, variability);
if (lStructTypeMap.find(mname) != lStructTypeMap.end() && if (lStructTypeMap.find(mname) != lStructTypeMap.end() &&
lStructTypeMap[mname]->isOpaque() == false) lStructTypeMap[mname]->isOpaque() == false)
return; return;
@@ -1954,7 +1952,7 @@ StructType::GetCStructName() const {
// compatibility... // compatibility...
if (variability == Variability::Varying) { if (variability == Variability::Varying) {
return lMangleStructName(name, this, variability); return lMangleStructName(name, variability);
} }
else { else {
return GetStructName(); return GetStructName();
@@ -2189,7 +2187,7 @@ StructType::GetCDeclaration(const std::string &n) const {
llvm::Type * llvm::Type *
StructType::LLVMType(llvm::LLVMContext *ctx) const { StructType::LLVMType(llvm::LLVMContext *ctx) const {
Assert(variability != Variability::Unbound); Assert(variability != Variability::Unbound);
std::string mname = lMangleStructName(name, this, variability); std::string mname = lMangleStructName(name, variability);
if (lStructTypeMap.find(mname) == lStructTypeMap.end()) { if (lStructTypeMap.find(mname) == lStructTypeMap.end()) {
Assert(m->errorCount > 0); Assert(m->errorCount > 0);
return NULL; return NULL;
@@ -2343,7 +2341,7 @@ UndefinedStructType::UndefinedStructType(const std::string &n,
Assert(name != ""); Assert(name != "");
if (variability != Variability::Unbound) { if (variability != Variability::Unbound) {
// Create a new opaque LLVM struct type for this struct name // Create a new opaque LLVM struct type for this struct name
std::string mname = lMangleStructName(name, this, variability); std::string mname = lMangleStructName(name, variability);
if (lStructTypeMap.find(mname) == lStructTypeMap.end()) if (lStructTypeMap.find(mname) == lStructTypeMap.end())
lStructTypeMap[mname] = llvm::StructType::create(*g->ctx, mname); lStructTypeMap[mname] = llvm::StructType::create(*g->ctx, mname);
} }
@@ -2478,7 +2476,7 @@ UndefinedStructType::GetCDeclaration(const std::string &n) const {
llvm::Type * llvm::Type *
UndefinedStructType::LLVMType(llvm::LLVMContext *ctx) const { UndefinedStructType::LLVMType(llvm::LLVMContext *ctx) const {
Assert(variability != Variability::Unbound); Assert(variability != Variability::Unbound);
std::string mname = lMangleStructName(name, this, variability); std::string mname = lMangleStructName(name, variability);
if (lStructTypeMap.find(mname) == lStructTypeMap.end()) { if (lStructTypeMap.find(mname) == lStructTypeMap.end()) {
Assert(m->errorCount > 0); Assert(m->errorCount > 0);
return NULL; return NULL;