[WIP] Remove cases for ForeachStmt and SymbolExpr

This commit is contained in:
2017-05-11 01:19:50 -04:00
parent 2e28640860
commit f65b3e6300
5 changed files with 26 additions and 6 deletions

View File

@@ -128,6 +128,9 @@ Expr::ReplacePolyType(const PolyType *polyType, const Type *replacement) {
case ConstExprID:
copy = (Expr*)new ConstExpr(*(ConstExpr*)this);
break;
case SymbolExprID:
copy = (Expr*)new SymbolExpr(*(SymbolExpr*)this);
break;
case PtrDerefExprID:
copy = (Expr*)new PtrDerefExpr(*(PtrDerefExpr*)this);
break;
@@ -8138,6 +8141,7 @@ SymbolExpr::Optimize() {
return this;
}
/*
Expr *
SymbolExpr::ReplacePolyType(const PolyType *from, const Type *to) {
if (!symbol)
@@ -8145,7 +8149,7 @@ SymbolExpr::ReplacePolyType(const PolyType *from, const Type *to) {
SymbolExpr *copy = new SymbolExpr(this);
copy->symbol = new Symbol(*symbol);
//copy->symbol = new Symbol(*symbol);
if (Type::EqualForReplacement(symbol->type->GetBaseType(), from)) {
copy->symbol->type = PolyType::ReplaceType(symbol->type, to);
@@ -8153,6 +8157,7 @@ SymbolExpr::ReplacePolyType(const PolyType *from, const Type *to) {
return copy;
}
*/
int

2
expr.h
View File

@@ -691,7 +691,7 @@ public:
Symbol *GetBaseSymbol() const;
Expr *TypeCheck();
Expr *Optimize();
Expr *ReplacePolyType(const PolyType *from, const Type *to);
//Expr *ReplacePolyType(const PolyType *from, const Type *to);
void Print() const;
int EstimateCost() const;

View File

@@ -127,6 +127,7 @@ Function::Function(Symbol *s, Stmt *c) {
const FunctionType *type = CastType<FunctionType>(sym->type);
Assert(type != NULL);
printf("Function %s symbol types: ", sym->name.c_str());
for (int i = 0; i < type->GetNumParameters(); ++i) {
const char *paramName = type->GetParameterName(i).c_str();
Symbol *sym = m->symbolTable->LookupVariable(paramName);
@@ -135,9 +136,14 @@ Function::Function(Symbol *s, Stmt *c) {
args.push_back(sym);
const Type *t = type->GetParameterType(i);
printf(" %s: %s==%s, ", sym->name.c_str(),
t->GetString().c_str(),
sym->type->GetString().c_str());
if (sym != NULL && CastType<ReferenceType>(t) == NULL)
sym->parentFunction = this;
}
printf("\n");
if (type->isTask
#ifdef ISPC_NVPTX_ENABLED

View File

@@ -105,6 +105,9 @@ Stmt::ReplacePolyType(const PolyType *polyType, const Type *replacement) {
case ExprStmtID:
copy = (Stmt*)new ExprStmt(*(ExprStmt*)this);
break;
case ForeachStmtID:
copy = (Stmt*)new ForeachStmt(*(ForeachStmt*)this);
break;
case ForeachActiveStmtID:
copy = (Stmt*)new ForeachActiveStmt(*(ForeachActiveStmt*)this);
break;
@@ -1557,6 +1560,7 @@ ForeachStmt::ForeachStmt(const std::vector<Symbol *> &lvs,
stmts(s) {
}
/*
ForeachStmt::ForeachStmt(ForeachStmt *base)
: Stmt(base->pos, ForeachStmtID) {
dimVariables = base->dimVariables;
@@ -1565,6 +1569,7 @@ ForeachStmt::ForeachStmt(ForeachStmt *base)
isTiled = base->isTiled;
stmts = base->stmts;
}
*/
/* Given a uniform counter value in the memory location pointed to by
@@ -1809,8 +1814,10 @@ ForeachStmt::EmitCode(FunctionEmitContext *ctx) const {
// Start and end value for this loop dimension
llvm::Value *sv = startExprs[i]->GetValue(ctx);
llvm::Value *ev = endExprs[i]->GetValue(ctx);
if (sv == NULL || ev == NULL)
if (sv == NULL || ev == NULL) {
fprintf(stderr, "ev is NULL again :(\n");
return;
}
startVals.push_back(sv);
endVals.push_back(ev);
@@ -2270,6 +2277,7 @@ ForeachStmt::TypeCheck() {
return anyErrors ? NULL : this;
}
/*
Stmt *
ForeachStmt::ReplacePolyType(const PolyType *from, const Type *to) {
if (!stmts)
@@ -2280,12 +2288,13 @@ ForeachStmt::ReplacePolyType(const PolyType *from, const Type *to) {
for (size_t i=0; i<dimVariables.size(); i++) {
const Type *t = copy->dimVariables[i]->type;
if (Type::EqualForReplacement(t->GetBaseType(), from)) {
t = PolyType::ReplaceType(t, to);
copy->dimVariables[i]->type = PolyType::ReplaceType(t, to);
}
}
return copy;
}
*/
int

4
stmt.h
View File

@@ -285,7 +285,7 @@ public:
void Print(int indent) const;
Stmt *TypeCheck();
Stmt *ReplacePolyType(const PolyType *from, const Type *to);
//Stmt *ReplacePolyType(const PolyType *from, const Type *to);
int EstimateCost() const;
std::vector<Symbol *> dimVariables;
@@ -294,7 +294,7 @@ public:
bool isTiled;
Stmt *stmts;
private:
ForeachStmt(ForeachStmt *base);
//ForeachStmt(ForeachStmt *base);
};