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

2
expr.h
View File

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

View File

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

View File

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

4
stmt.h
View File

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