Merge pull request #1063 from ncos/ispc-classof
Removing RTTI from ispc - it causes problem when linking with clang libraries, which are no-rtti.
This commit is contained in:
2
Makefile
2
Makefile
@@ -169,7 +169,7 @@ CXXFLAGS=$(OPT) $(LLVM_CXXFLAGS) -I. -Iobjs/ -I$(CLANG_INCLUDE) \
|
||||
|
||||
# if( !($(LLVM_VERSION) == LLVM_3_2 || $(LLVM_VERSION) == LLVM_3_3 || $(LLVM_VERSION) == LLVM_3_4))
|
||||
ifeq (,$(filter $(LLVM_VERSION), LLVM_3_2 LLVM_3_3 LLVM_3_4))
|
||||
CXXFLAGS+=-std=c++11 -Wno-c99-extensions -Wno-deprecated-register
|
||||
CXXFLAGS+=-std=c++11 -Wno-c99-extensions -Wno-deprecated-register -fno-rtti
|
||||
endif
|
||||
ifneq ($(ARM_ENABLED), 0)
|
||||
CXXFLAGS+=-DISPC_ARM_ENABLED
|
||||
|
||||
118
ast.cpp
118
ast.cpp
@@ -85,7 +85,7 @@ WalkAST(ASTNode *node, ASTPreCallBackFunc preFunc, ASTPostCallBackFunc postFunc,
|
||||
|
||||
////////////////////////////////////////////////////////////////////////////
|
||||
// Handle Statements
|
||||
if (dynamic_cast<Stmt *>(node) != NULL) {
|
||||
if (llvm::dyn_cast<Stmt>(node) != NULL) {
|
||||
ExprStmt *es;
|
||||
DeclStmt *ds;
|
||||
IfStmt *is;
|
||||
@@ -105,33 +105,33 @@ WalkAST(ASTNode *node, ASTPreCallBackFunc preFunc, ASTPostCallBackFunc postFunc,
|
||||
DeleteStmt *dels;
|
||||
UnmaskedStmt *ums;
|
||||
|
||||
if ((es = dynamic_cast<ExprStmt *>(node)) != NULL)
|
||||
if ((es = llvm::dyn_cast<ExprStmt>(node)) != NULL)
|
||||
es->expr = (Expr *)WalkAST(es->expr, preFunc, postFunc, data);
|
||||
else if ((ds = dynamic_cast<DeclStmt *>(node)) != NULL) {
|
||||
else if ((ds = llvm::dyn_cast<DeclStmt>(node)) != NULL) {
|
||||
for (unsigned int i = 0; i < ds->vars.size(); ++i)
|
||||
ds->vars[i].init = (Expr *)WalkAST(ds->vars[i].init, preFunc,
|
||||
postFunc, data);
|
||||
}
|
||||
else if ((is = dynamic_cast<IfStmt *>(node)) != NULL) {
|
||||
else if ((is = llvm::dyn_cast<IfStmt>(node)) != NULL) {
|
||||
is->test = (Expr *)WalkAST(is->test, preFunc, postFunc, data);
|
||||
is->trueStmts = (Stmt *)WalkAST(is->trueStmts, preFunc,
|
||||
postFunc, data);
|
||||
is->falseStmts = (Stmt *)WalkAST(is->falseStmts, preFunc,
|
||||
postFunc, data);
|
||||
}
|
||||
else if ((dos = dynamic_cast<DoStmt *>(node)) != NULL) {
|
||||
else if ((dos = llvm::dyn_cast<DoStmt>(node)) != NULL) {
|
||||
dos->testExpr = (Expr *)WalkAST(dos->testExpr, preFunc,
|
||||
postFunc, data);
|
||||
dos->bodyStmts = (Stmt *)WalkAST(dos->bodyStmts, preFunc,
|
||||
postFunc, data);
|
||||
}
|
||||
else if ((fs = dynamic_cast<ForStmt *>(node)) != NULL) {
|
||||
else if ((fs = llvm::dyn_cast<ForStmt>(node)) != NULL) {
|
||||
fs->init = (Stmt *)WalkAST(fs->init, preFunc, postFunc, data);
|
||||
fs->test = (Expr *)WalkAST(fs->test, preFunc, postFunc, data);
|
||||
fs->step = (Stmt *)WalkAST(fs->step, preFunc, postFunc, data);
|
||||
fs->stmts = (Stmt *)WalkAST(fs->stmts, preFunc, postFunc, data);
|
||||
}
|
||||
else if ((fes = dynamic_cast<ForeachStmt *>(node)) != NULL) {
|
||||
else if ((fes = llvm::dyn_cast<ForeachStmt>(node)) != NULL) {
|
||||
for (unsigned int i = 0; i < fes->startExprs.size(); ++i)
|
||||
fes->startExprs[i] = (Expr *)WalkAST(fes->startExprs[i], preFunc,
|
||||
postFunc, data);
|
||||
@@ -140,42 +140,42 @@ WalkAST(ASTNode *node, ASTPreCallBackFunc preFunc, ASTPostCallBackFunc postFunc,
|
||||
postFunc, data);
|
||||
fes->stmts = (Stmt *)WalkAST(fes->stmts, preFunc, postFunc, data);
|
||||
}
|
||||
else if ((fas = dynamic_cast<ForeachActiveStmt *>(node)) != NULL) {
|
||||
else if ((fas = llvm::dyn_cast<ForeachActiveStmt>(node)) != NULL) {
|
||||
fas->stmts = (Stmt *)WalkAST(fas->stmts, preFunc, postFunc, data);
|
||||
}
|
||||
else if ((fus = dynamic_cast<ForeachUniqueStmt *>(node)) != NULL) {
|
||||
else if ((fus = llvm::dyn_cast<ForeachUniqueStmt>(node)) != NULL) {
|
||||
fus->expr = (Expr *)WalkAST(fus->expr, preFunc, postFunc, data);
|
||||
fus->stmts = (Stmt *)WalkAST(fus->stmts, preFunc, postFunc, data);
|
||||
}
|
||||
else if ((cs = dynamic_cast<CaseStmt *>(node)) != NULL)
|
||||
else if ((cs = llvm::dyn_cast<CaseStmt>(node)) != NULL)
|
||||
cs->stmts = (Stmt *)WalkAST(cs->stmts, preFunc, postFunc, data);
|
||||
else if ((defs = dynamic_cast<DefaultStmt *>(node)) != NULL)
|
||||
else if ((defs = llvm::dyn_cast<DefaultStmt>(node)) != NULL)
|
||||
defs->stmts = (Stmt *)WalkAST(defs->stmts, preFunc, postFunc, data);
|
||||
else if ((ss = dynamic_cast<SwitchStmt *>(node)) != NULL) {
|
||||
else if ((ss = llvm::dyn_cast<SwitchStmt>(node)) != NULL) {
|
||||
ss->expr = (Expr *)WalkAST(ss->expr, preFunc, postFunc, data);
|
||||
ss->stmts = (Stmt *)WalkAST(ss->stmts, preFunc, postFunc, data);
|
||||
}
|
||||
else if (dynamic_cast<BreakStmt *>(node) != NULL ||
|
||||
dynamic_cast<ContinueStmt *>(node) != NULL ||
|
||||
dynamic_cast<GotoStmt *>(node) != NULL) {
|
||||
else if (llvm::dyn_cast<BreakStmt>(node) != NULL ||
|
||||
llvm::dyn_cast<ContinueStmt>(node) != NULL ||
|
||||
llvm::dyn_cast<GotoStmt>(node) != NULL) {
|
||||
// nothing
|
||||
}
|
||||
else if ((ls = dynamic_cast<LabeledStmt *>(node)) != NULL)
|
||||
else if ((ls = llvm::dyn_cast<LabeledStmt>(node)) != NULL)
|
||||
ls->stmt = (Stmt *)WalkAST(ls->stmt, preFunc, postFunc, data);
|
||||
else if ((rs = dynamic_cast<ReturnStmt *>(node)) != NULL)
|
||||
else if ((rs = llvm::dyn_cast<ReturnStmt>(node)) != NULL)
|
||||
rs->expr = (Expr *)WalkAST(rs->expr, preFunc, postFunc, data);
|
||||
else if ((sl = dynamic_cast<StmtList *>(node)) != NULL) {
|
||||
else if ((sl = llvm::dyn_cast<StmtList>(node)) != NULL) {
|
||||
std::vector<Stmt *> &sls = sl->stmts;
|
||||
for (unsigned int i = 0; i < sls.size(); ++i)
|
||||
sls[i] = (Stmt *)WalkAST(sls[i], preFunc, postFunc, data);
|
||||
}
|
||||
else if ((ps = dynamic_cast<PrintStmt *>(node)) != NULL)
|
||||
else if ((ps = llvm::dyn_cast<PrintStmt>(node)) != NULL)
|
||||
ps->values = (Expr *)WalkAST(ps->values, preFunc, postFunc, data);
|
||||
else if ((as = dynamic_cast<AssertStmt *>(node)) != NULL)
|
||||
else if ((as = llvm::dyn_cast<AssertStmt>(node)) != NULL)
|
||||
as->expr = (Expr *)WalkAST(as->expr, preFunc, postFunc, data);
|
||||
else if ((dels = dynamic_cast<DeleteStmt *>(node)) != NULL)
|
||||
else if ((dels = llvm::dyn_cast<DeleteStmt>(node)) != NULL)
|
||||
dels->expr = (Expr *)WalkAST(dels->expr, preFunc, postFunc, data);
|
||||
else if ((ums = dynamic_cast<UnmaskedStmt *>(node)) != NULL)
|
||||
else if ((ums = llvm::dyn_cast<UnmaskedStmt>(node)) != NULL)
|
||||
ums->stmts = (Stmt *)WalkAST(ums->stmts, preFunc, postFunc, data);
|
||||
else
|
||||
FATAL("Unhandled statement type in WalkAST()");
|
||||
@@ -183,7 +183,7 @@ WalkAST(ASTNode *node, ASTPreCallBackFunc preFunc, ASTPostCallBackFunc postFunc,
|
||||
else {
|
||||
///////////////////////////////////////////////////////////////////////////
|
||||
// Handle expressions
|
||||
Assert(dynamic_cast<Expr *>(node) != NULL);
|
||||
Assert(llvm::dyn_cast<Expr>(node) != NULL);
|
||||
UnaryExpr *ue;
|
||||
BinaryExpr *be;
|
||||
AssignExpr *ae;
|
||||
@@ -200,64 +200,64 @@ WalkAST(ASTNode *node, ASTPreCallBackFunc preFunc, ASTPostCallBackFunc postFunc,
|
||||
AddressOfExpr *aoe;
|
||||
NewExpr *newe;
|
||||
|
||||
if ((ue = dynamic_cast<UnaryExpr *>(node)) != NULL)
|
||||
if ((ue = llvm::dyn_cast<UnaryExpr>(node)) != NULL)
|
||||
ue->expr = (Expr *)WalkAST(ue->expr, preFunc, postFunc, data);
|
||||
else if ((be = dynamic_cast<BinaryExpr *>(node)) != NULL) {
|
||||
else if ((be = llvm::dyn_cast<BinaryExpr>(node)) != NULL) {
|
||||
be->arg0 = (Expr *)WalkAST(be->arg0, preFunc, postFunc, data);
|
||||
be->arg1 = (Expr *)WalkAST(be->arg1, preFunc, postFunc, data);
|
||||
}
|
||||
else if ((ae = dynamic_cast<AssignExpr *>(node)) != NULL) {
|
||||
else if ((ae = llvm::dyn_cast<AssignExpr>(node)) != NULL) {
|
||||
ae->lvalue = (Expr *)WalkAST(ae->lvalue, preFunc, postFunc, data);
|
||||
ae->rvalue = (Expr *)WalkAST(ae->rvalue, preFunc, postFunc, data);
|
||||
}
|
||||
else if ((se = dynamic_cast<SelectExpr *>(node)) != NULL) {
|
||||
else if ((se = llvm::dyn_cast<SelectExpr>(node)) != NULL) {
|
||||
se->test = (Expr *)WalkAST(se->test, preFunc, postFunc, data);
|
||||
se->expr1 = (Expr *)WalkAST(se->expr1, preFunc, postFunc, data);
|
||||
se->expr2 = (Expr *)WalkAST(se->expr2, preFunc, postFunc, data);
|
||||
}
|
||||
else if ((el = dynamic_cast<ExprList *>(node)) != NULL) {
|
||||
else if ((el = llvm::dyn_cast<ExprList>(node)) != NULL) {
|
||||
for (unsigned int i = 0; i < el->exprs.size(); ++i)
|
||||
el->exprs[i] = (Expr *)WalkAST(el->exprs[i], preFunc,
|
||||
postFunc, data);
|
||||
}
|
||||
else if ((fce = dynamic_cast<FunctionCallExpr *>(node)) != NULL) {
|
||||
else if ((fce = llvm::dyn_cast<FunctionCallExpr>(node)) != NULL) {
|
||||
fce->func = (Expr *)WalkAST(fce->func, preFunc, postFunc, data);
|
||||
fce->args = (ExprList *)WalkAST(fce->args, preFunc, postFunc, data);
|
||||
for (int k = 0; k < 3; k++)
|
||||
fce->launchCountExpr[0] = (Expr *)WalkAST(fce->launchCountExpr[0], preFunc,
|
||||
postFunc, data);
|
||||
}
|
||||
else if ((ie = dynamic_cast<IndexExpr *>(node)) != NULL) {
|
||||
else if ((ie = llvm::dyn_cast<IndexExpr>(node)) != NULL) {
|
||||
ie->baseExpr = (Expr *)WalkAST(ie->baseExpr, preFunc, postFunc, data);
|
||||
ie->index = (Expr *)WalkAST(ie->index, preFunc, postFunc, data);
|
||||
}
|
||||
else if ((me = dynamic_cast<MemberExpr *>(node)) != NULL)
|
||||
else if ((me = llvm::dyn_cast<MemberExpr>(node)) != NULL)
|
||||
me->expr = (Expr *)WalkAST(me->expr, preFunc, postFunc, data);
|
||||
else if ((tce = dynamic_cast<TypeCastExpr *>(node)) != NULL)
|
||||
else if ((tce = llvm::dyn_cast<TypeCastExpr>(node)) != NULL)
|
||||
tce->expr = (Expr *)WalkAST(tce->expr, preFunc, postFunc, data);
|
||||
else if ((re = dynamic_cast<ReferenceExpr *>(node)) != NULL)
|
||||
else if ((re = llvm::dyn_cast<ReferenceExpr>(node)) != NULL)
|
||||
re->expr = (Expr *)WalkAST(re->expr, preFunc, postFunc, data);
|
||||
else if ((ptrderef = dynamic_cast<PtrDerefExpr *>(node)) != NULL)
|
||||
else if ((ptrderef = llvm::dyn_cast<PtrDerefExpr>(node)) != NULL)
|
||||
ptrderef->expr = (Expr *)WalkAST(ptrderef->expr, preFunc, postFunc,
|
||||
data);
|
||||
else if ((refderef = dynamic_cast<RefDerefExpr *>(node)) != NULL)
|
||||
else if ((refderef = llvm::dyn_cast<RefDerefExpr>(node)) != NULL)
|
||||
refderef->expr = (Expr *)WalkAST(refderef->expr, preFunc, postFunc,
|
||||
data);
|
||||
else if ((soe = dynamic_cast<SizeOfExpr *>(node)) != NULL)
|
||||
else if ((soe = llvm::dyn_cast<SizeOfExpr>(node)) != NULL)
|
||||
soe->expr = (Expr *)WalkAST(soe->expr, preFunc, postFunc, data);
|
||||
else if ((aoe = dynamic_cast<AddressOfExpr *>(node)) != NULL)
|
||||
else if ((aoe = llvm::dyn_cast<AddressOfExpr>(node)) != NULL)
|
||||
aoe->expr = (Expr *)WalkAST(aoe->expr, preFunc, postFunc, data);
|
||||
else if ((newe = dynamic_cast<NewExpr *>(node)) != NULL) {
|
||||
else if ((newe = llvm::dyn_cast<NewExpr>(node)) != NULL) {
|
||||
newe->countExpr = (Expr *)WalkAST(newe->countExpr, preFunc,
|
||||
postFunc, data);
|
||||
newe->initExpr = (Expr *)WalkAST(newe->initExpr, preFunc,
|
||||
postFunc, data);
|
||||
}
|
||||
else if (dynamic_cast<SymbolExpr *>(node) != NULL ||
|
||||
dynamic_cast<ConstExpr *>(node) != NULL ||
|
||||
dynamic_cast<FunctionSymbolExpr *>(node) != NULL ||
|
||||
dynamic_cast<SyncExpr *>(node) != NULL ||
|
||||
dynamic_cast<NullPointerExpr *>(node) != NULL) {
|
||||
else if (llvm::dyn_cast<SymbolExpr>(node) != NULL ||
|
||||
llvm::dyn_cast<ConstExpr>(node) != NULL ||
|
||||
llvm::dyn_cast<FunctionSymbolExpr>(node) != NULL ||
|
||||
llvm::dyn_cast<SyncExpr>(node) != NULL ||
|
||||
llvm::dyn_cast<NullPointerExpr>(node) != NULL) {
|
||||
// nothing to do
|
||||
}
|
||||
else
|
||||
@@ -331,7 +331,7 @@ struct CostData {
|
||||
static bool
|
||||
lCostCallbackPre(ASTNode *node, void *d) {
|
||||
CostData *data = (CostData *)d;
|
||||
if (dynamic_cast<ForeachStmt *>(node) != NULL)
|
||||
if (llvm::dyn_cast<ForeachStmt>(node) != NULL)
|
||||
++data->foreachDepth;
|
||||
if (data->foreachDepth == 0)
|
||||
data->cost += node->EstimateCost();
|
||||
@@ -342,7 +342,7 @@ lCostCallbackPre(ASTNode *node, void *d) {
|
||||
static ASTNode *
|
||||
lCostCallbackPost(ASTNode *node, void *d) {
|
||||
CostData *data = (CostData *)d;
|
||||
if (dynamic_cast<ForeachStmt *>(node) != NULL)
|
||||
if (llvm::dyn_cast<ForeachStmt>(node) != NULL)
|
||||
--data->foreachDepth;
|
||||
return node;
|
||||
}
|
||||
@@ -364,7 +364,7 @@ lCheckAllOffSafety(ASTNode *node, void *data) {
|
||||
bool *okPtr = (bool *)data;
|
||||
|
||||
FunctionCallExpr *fce;
|
||||
if ((fce = dynamic_cast<FunctionCallExpr *>(node)) != NULL) {
|
||||
if ((fce = llvm::dyn_cast<FunctionCallExpr>(node)) != NULL) {
|
||||
if (fce->func == NULL)
|
||||
return false;
|
||||
|
||||
@@ -381,7 +381,7 @@ lCheckAllOffSafety(ASTNode *node, void *data) {
|
||||
}
|
||||
}
|
||||
|
||||
if (dynamic_cast<AssertStmt *>(node) != NULL) {
|
||||
if (llvm::dyn_cast<AssertStmt>(node) != NULL) {
|
||||
// While it's fine to run the assert for varying tests, it's not
|
||||
// desirable to check an assert on a uniform variable if all of the
|
||||
// lanes are off.
|
||||
@@ -389,13 +389,13 @@ lCheckAllOffSafety(ASTNode *node, void *data) {
|
||||
return false;
|
||||
}
|
||||
|
||||
if (dynamic_cast<PrintStmt *>(node) != NULL) {
|
||||
if (llvm::dyn_cast<PrintStmt>(node) != NULL) {
|
||||
*okPtr = false;
|
||||
return false;
|
||||
}
|
||||
|
||||
if (dynamic_cast<NewExpr *>(node) != NULL ||
|
||||
dynamic_cast<DeleteStmt *>(node) != NULL) {
|
||||
if (llvm::dyn_cast<NewExpr>(node) != NULL ||
|
||||
llvm::dyn_cast<DeleteStmt>(node) != NULL) {
|
||||
// We definitely don't want to run the uniform variants of these if
|
||||
// the mask is all off. It's also worth skipping the overhead of
|
||||
// executing the varying versions of them in the all-off mask case.
|
||||
@@ -403,10 +403,10 @@ lCheckAllOffSafety(ASTNode *node, void *data) {
|
||||
return false;
|
||||
}
|
||||
|
||||
if (dynamic_cast<ForeachStmt *>(node) != NULL ||
|
||||
dynamic_cast<ForeachActiveStmt *>(node) != NULL ||
|
||||
dynamic_cast<ForeachUniqueStmt *>(node) != NULL ||
|
||||
dynamic_cast<UnmaskedStmt *>(node) != NULL) {
|
||||
if (llvm::dyn_cast<ForeachStmt>(node) != NULL ||
|
||||
llvm::dyn_cast<ForeachActiveStmt>(node) != NULL ||
|
||||
llvm::dyn_cast<ForeachUniqueStmt>(node) != NULL ||
|
||||
llvm::dyn_cast<UnmaskedStmt>(node) != NULL) {
|
||||
// The various foreach statements also shouldn't be run with an
|
||||
// all-off mask. Since they can re-establish an 'all on' mask,
|
||||
// this would be pretty unintuitive. (More generally, it's
|
||||
@@ -421,14 +421,14 @@ lCheckAllOffSafety(ASTNode *node, void *data) {
|
||||
}
|
||||
|
||||
IndexExpr *ie;
|
||||
if ((ie = dynamic_cast<IndexExpr *>(node)) != NULL && ie->baseExpr != NULL) {
|
||||
if ((ie = llvm::dyn_cast<IndexExpr>(node)) != NULL && ie->baseExpr != NULL) {
|
||||
const Type *type = ie->baseExpr->GetType();
|
||||
if (type == NULL)
|
||||
return true;
|
||||
if (CastType<ReferenceType>(type) != NULL)
|
||||
type = type->GetReferenceTarget();
|
||||
|
||||
ConstExpr *ce = dynamic_cast<ConstExpr *>(ie->index);
|
||||
ConstExpr *ce = llvm::dyn_cast<ConstExpr>(ie->index);
|
||||
if (ce == NULL) {
|
||||
// indexing with a variable... -> not safe
|
||||
*okPtr = false;
|
||||
@@ -466,13 +466,13 @@ lCheckAllOffSafety(ASTNode *node, void *data) {
|
||||
}
|
||||
|
||||
MemberExpr *me;
|
||||
if ((me = dynamic_cast<MemberExpr *>(node)) != NULL &&
|
||||
if ((me = llvm::dyn_cast<MemberExpr>(node)) != NULL &&
|
||||
me->dereferenceExpr) {
|
||||
*okPtr = false;
|
||||
return false;
|
||||
}
|
||||
|
||||
if (dynamic_cast<PtrDerefExpr *>(node) != NULL) {
|
||||
if (llvm::dyn_cast<PtrDerefExpr>(node) != NULL) {
|
||||
*okPtr = false;
|
||||
return false;
|
||||
}
|
||||
@@ -482,7 +482,7 @@ lCheckAllOffSafety(ASTNode *node, void *data) {
|
||||
assign to a uniform.
|
||||
*/
|
||||
AssignExpr *ae;
|
||||
if ((ae = dynamic_cast<AssignExpr *>(node)) != NULL) {
|
||||
if ((ae = llvm::dyn_cast<AssignExpr>(node)) != NULL) {
|
||||
if (ae->GetType()) {
|
||||
if (ae->GetType()->IsUniformType()) {
|
||||
*okPtr = false;
|
||||
|
||||
69
ast.h
69
ast.h
@@ -48,8 +48,9 @@
|
||||
(Expr) and statements (Stmt) inherit from this class.
|
||||
*/
|
||||
class ASTNode {
|
||||
const unsigned char SubclassID; // Subclass identifier (for isa/dyn_cast)
|
||||
public:
|
||||
ASTNode(SourcePos p) : pos(p) { }
|
||||
ASTNode(SourcePos p, unsigned scid) : SubclassID(scid), pos(p) { }
|
||||
virtual ~ASTNode();
|
||||
|
||||
/** The Optimize() method should perform any appropriate early-stage
|
||||
@@ -74,12 +75,72 @@ public:
|
||||
/** All AST nodes must track the file position where they are
|
||||
defined. */
|
||||
SourcePos pos;
|
||||
|
||||
/** An enumeration for keeping track of the concrete subclass of Value
|
||||
that is actually instantiated.*/
|
||||
enum ASTNodeTy {
|
||||
/* For classes inherited from Expr */
|
||||
AddressOfExprID,
|
||||
AssignExprID,
|
||||
BinaryExprID,
|
||||
ConstExprID,
|
||||
DerefExprID,
|
||||
PtrDerefExprID,
|
||||
RefDerefExprID,
|
||||
ExprListID,
|
||||
FunctionCallExprID,
|
||||
FunctionSymbolExprID,
|
||||
IndexExprID,
|
||||
StructMemberExprID,
|
||||
VectorMemberExprID,
|
||||
NewExprID,
|
||||
NullPointerExprID,
|
||||
ReferenceExprID,
|
||||
SelectExprID,
|
||||
SizeOfExprID,
|
||||
SymbolExprID,
|
||||
SyncExprID,
|
||||
TypeCastExprID,
|
||||
UnaryExprID,
|
||||
/* This is a convenience separator to shorten classof implementations */
|
||||
MaxExprID,
|
||||
/* For classes inherited from Stmt */
|
||||
AssertStmtID,
|
||||
BreakStmtID,
|
||||
CaseStmtID,
|
||||
ContinueStmtID,
|
||||
DeclStmtID,
|
||||
DefaultStmtID,
|
||||
DeleteStmtID,
|
||||
DoStmtID,
|
||||
ExprStmtID,
|
||||
ForeachActiveStmtID,
|
||||
ForeachStmtID,
|
||||
ForeachUniqueStmtID,
|
||||
ForStmtID,
|
||||
GotoStmtID,
|
||||
IfStmtID,
|
||||
LabeledStmtID,
|
||||
PrintStmtID,
|
||||
ReturnStmtID,
|
||||
StmtListID,
|
||||
SwitchStmtID,
|
||||
UnmaskedStmtID
|
||||
};
|
||||
|
||||
/** Return an ID for the concrete type of this object. This is used to
|
||||
implement the classof checks. This should not be used for any
|
||||
other purpose, as the values may change as ISPC evolves */
|
||||
unsigned getValueID() const {
|
||||
return SubclassID;
|
||||
}
|
||||
|
||||
static inline bool classof(ASTNode const*) { return true; }
|
||||
};
|
||||
|
||||
|
||||
/** Simple representation of the abstract syntax trees for all of the
|
||||
functions declared in a compilation unit.
|
||||
*/
|
||||
|
||||
|
||||
class AST {
|
||||
public:
|
||||
/** Add the AST for a function described by the given declaration
|
||||
|
||||
2
ctx.cpp
2
ctx.cpp
@@ -1241,7 +1241,7 @@ FunctionEmitContext::EnableGatherScatterWarnings() {
|
||||
|
||||
bool
|
||||
FunctionEmitContext::initLabelBBlocks(ASTNode *node, void *data) {
|
||||
LabeledStmt *ls = dynamic_cast<LabeledStmt *>(node);
|
||||
LabeledStmt *ls = llvm::dyn_cast<LabeledStmt>(node);
|
||||
if (ls == NULL)
|
||||
return true;
|
||||
|
||||
|
||||
4
decl.cpp
4
decl.cpp
@@ -519,9 +519,9 @@ Declarator::InitFromType(const Type *baseType, DeclSpecs *ds) {
|
||||
decl->initExpr = TypeCheck(decl->initExpr);
|
||||
decl->initExpr = Optimize(decl->initExpr);
|
||||
if (decl->initExpr != NULL) {
|
||||
init = dynamic_cast<ConstExpr *>(decl->initExpr);
|
||||
init = llvm::dyn_cast<ConstExpr>(decl->initExpr);
|
||||
if (init == NULL)
|
||||
init = dynamic_cast<NullPointerExpr *>(decl->initExpr);
|
||||
init = llvm::dyn_cast<NullPointerExpr>(decl->initExpr);
|
||||
if (init == NULL)
|
||||
Error(decl->initExpr->pos, "Default value for parameter "
|
||||
"\"%s\" must be a compile-time constant.",
|
||||
|
||||
159
expr.cpp
159
expr.cpp
@@ -178,7 +178,7 @@ lIsAllIntZeros(Expr *expr) {
|
||||
if (type == NULL || type->IsIntType() == false)
|
||||
return false;
|
||||
|
||||
ConstExpr *ce = dynamic_cast<ConstExpr *>(expr);
|
||||
ConstExpr *ce = llvm::dyn_cast<ConstExpr>(expr);
|
||||
if (ce == NULL)
|
||||
return false;
|
||||
|
||||
@@ -355,7 +355,7 @@ lDoTypeConv(const Type *fromType, const Type *toType, Expr **expr,
|
||||
}
|
||||
else if (PointerType::IsVoidPointer(fromPointerType) &&
|
||||
expr != NULL &&
|
||||
dynamic_cast<NullPointerExpr *>(*expr) != NULL) {
|
||||
llvm::dyn_cast<NullPointerExpr>(*expr) != NULL) {
|
||||
// and a NULL convert to any other pointer type
|
||||
goto typecast_ok;
|
||||
}
|
||||
@@ -617,7 +617,7 @@ PossiblyResolveFunctionOverloads(Expr *expr, const Type *type) {
|
||||
const FunctionType *funcType = NULL;
|
||||
if (CastType<PointerType>(type) != NULL &&
|
||||
(funcType = CastType<FunctionType>(type->GetBaseType())) &&
|
||||
(fse = dynamic_cast<FunctionSymbolExpr *>(expr)) != NULL) {
|
||||
(fse = llvm::dyn_cast<FunctionSymbolExpr>(expr)) != NULL) {
|
||||
// We're initializing a function pointer with a function symbol,
|
||||
// which in turn may represent an overloaded function. So we need
|
||||
// to try to resolve the overload based on the type of the symbol
|
||||
@@ -684,7 +684,7 @@ InitSymbol(llvm::Value *ptr, const Type *symType, Expr *initExpr,
|
||||
// If the initializer is a straight up expression that isn't an
|
||||
// ExprList, then we'll see if we can type convert it to the type of
|
||||
// the variable.
|
||||
if (dynamic_cast<ExprList *>(initExpr) == NULL) {
|
||||
if (llvm::dyn_cast<ExprList>(initExpr) == NULL) {
|
||||
if (PossiblyResolveFunctionOverloads(initExpr, symType) == false)
|
||||
return;
|
||||
initExpr = TypeConvertExpr(initExpr, symType, "initializer");
|
||||
@@ -703,7 +703,7 @@ InitSymbol(llvm::Value *ptr, const Type *symType, Expr *initExpr,
|
||||
// expressions if they have a single element (except for SOA types,
|
||||
// which are handled below).
|
||||
if (symType->IsSOAType() == false && Type::IsBasicType(symType)) {
|
||||
ExprList *elist = dynamic_cast<ExprList *>(initExpr);
|
||||
ExprList *elist = llvm::dyn_cast<ExprList>(initExpr);
|
||||
if (elist != NULL) {
|
||||
if (elist->exprs.size() == 1)
|
||||
InitSymbol(ptr, symType, elist->exprs[0], ctx, pos);
|
||||
@@ -755,7 +755,7 @@ InitSymbol(llvm::Value *ptr, const Type *symType, Expr *initExpr,
|
||||
// an initializer list may be provided (float foo[3] = { 1,2,3 }),
|
||||
// in which case the elements are initialized with the
|
||||
// corresponding values.
|
||||
ExprList *exprList = dynamic_cast<ExprList *>(initExpr);
|
||||
ExprList *exprList = llvm::dyn_cast<ExprList>(initExpr);
|
||||
if (exprList != NULL) {
|
||||
// The { ... } case; make sure we have the no more expressions
|
||||
// in the ExprList as we have struct members
|
||||
@@ -1108,11 +1108,10 @@ lEmitNegate(Expr *arg, SourcePos pos, FunctionEmitContext *ctx) {
|
||||
|
||||
|
||||
UnaryExpr::UnaryExpr(Op o, Expr *e, SourcePos p)
|
||||
: Expr(p), op(o) {
|
||||
: Expr(p, UnaryExprID), op(o) {
|
||||
expr = e;
|
||||
}
|
||||
|
||||
|
||||
llvm::Value *
|
||||
UnaryExpr::GetValue(FunctionEmitContext *ctx) const {
|
||||
if (expr == NULL)
|
||||
@@ -1184,7 +1183,7 @@ lOptimizeBitNot(ConstExpr *constExpr, const Type *type, SourcePos pos) {
|
||||
|
||||
Expr *
|
||||
UnaryExpr::Optimize() {
|
||||
ConstExpr *constExpr = dynamic_cast<ConstExpr *>(expr);
|
||||
ConstExpr *constExpr = llvm::dyn_cast<ConstExpr>(expr);
|
||||
// If the operand isn't a constant, then we can't do any optimization
|
||||
// here...
|
||||
if (constExpr == NULL)
|
||||
@@ -1359,7 +1358,7 @@ UnaryExpr::TypeCheck() {
|
||||
|
||||
int
|
||||
UnaryExpr::EstimateCost() const {
|
||||
if (dynamic_cast<ConstExpr *>(expr) != NULL)
|
||||
if (llvm::dyn_cast<ConstExpr>(expr) != NULL)
|
||||
return 0;
|
||||
|
||||
return COST_SIMPLE_ARITH_LOGIC_OP;
|
||||
@@ -1666,7 +1665,7 @@ lEmitBinaryCmp(BinaryExpr::Op op, llvm::Value *e0Val, llvm::Value *e1Val,
|
||||
|
||||
|
||||
BinaryExpr::BinaryExpr(Op o, Expr *a, Expr *b, SourcePos p)
|
||||
: Expr(p), op(o) {
|
||||
: Expr(p, BinaryExprID), op(o) {
|
||||
arg0 = a;
|
||||
arg1 = b;
|
||||
}
|
||||
@@ -1990,7 +1989,7 @@ lIsDifficultShiftAmount(Expr *expr) {
|
||||
if (expr->GetType()->IsVaryingType() == false)
|
||||
return false;
|
||||
|
||||
ConstExpr *ce = dynamic_cast<ConstExpr *>(expr);
|
||||
ConstExpr *ce = llvm::dyn_cast<ConstExpr>(expr);
|
||||
if (ce) {
|
||||
// If the shift is by a constant amount, *and* it's the same amount
|
||||
// in all vector lanes, we're in good shape.
|
||||
@@ -2002,7 +2001,7 @@ lIsDifficultShiftAmount(Expr *expr) {
|
||||
return false;
|
||||
}
|
||||
|
||||
TypeCastExpr *tce = dynamic_cast<TypeCastExpr *>(expr);
|
||||
TypeCastExpr *tce = llvm::dyn_cast<TypeCastExpr>(expr);
|
||||
if (tce && tce->expr) {
|
||||
// Finally, if the shift amount is given by a uniform value that's
|
||||
// been smeared out into a varying, we have the same shift for all
|
||||
@@ -2330,7 +2329,7 @@ lCanImproveVectorDivide(Expr *arg0, Expr *arg1, int *divisor) {
|
||||
|
||||
// The divisor must be the same compile-time constant value for all of
|
||||
// the vector lanes.
|
||||
ConstExpr *ce = dynamic_cast<ConstExpr *>(arg1);
|
||||
ConstExpr *ce = llvm::dyn_cast<ConstExpr>(arg1);
|
||||
if (!ce)
|
||||
return false;
|
||||
int64_t div[ISPC_MAX_NVEC];
|
||||
@@ -2357,8 +2356,8 @@ BinaryExpr::Optimize() {
|
||||
if (arg0 == NULL || arg1 == NULL)
|
||||
return NULL;
|
||||
|
||||
ConstExpr *constArg0 = dynamic_cast<ConstExpr *>(arg0);
|
||||
ConstExpr *constArg1 = dynamic_cast<ConstExpr *>(arg1);
|
||||
ConstExpr *constArg0 = llvm::dyn_cast<ConstExpr>(arg0);
|
||||
ConstExpr *constArg1 = llvm::dyn_cast<ConstExpr>(arg1);
|
||||
|
||||
if (g->opt.fastMath) {
|
||||
// optimizations related to division by floats..
|
||||
@@ -2823,8 +2822,8 @@ BinaryExpr::GetLValueType() const {
|
||||
|
||||
int
|
||||
BinaryExpr::EstimateCost() const {
|
||||
if (dynamic_cast<ConstExpr *>(arg0) != NULL &&
|
||||
dynamic_cast<ConstExpr *>(arg1) != NULL)
|
||||
if (llvm::dyn_cast<ConstExpr>(arg0) != NULL &&
|
||||
llvm::dyn_cast<ConstExpr>(arg1) != NULL)
|
||||
return 0;
|
||||
|
||||
return (op == Div || op == Mod) ? COST_COMPLEX_ARITH_OP :
|
||||
@@ -2945,7 +2944,7 @@ lEmitOpAssign(AssignExpr::Op op, Expr *arg0, Expr *arg1, const Type *type,
|
||||
|
||||
|
||||
AssignExpr::AssignExpr(AssignExpr::Op o, Expr *a, Expr *b, SourcePos p)
|
||||
: Expr(p), op(o) {
|
||||
: Expr(p, AssignExprID), op(o) {
|
||||
lvalue = a;
|
||||
rvalue = b;
|
||||
}
|
||||
@@ -3170,7 +3169,7 @@ AssignExpr::Print() const {
|
||||
// SelectExpr
|
||||
|
||||
SelectExpr::SelectExpr(Expr *t, Expr *e1, Expr *e2, SourcePos p)
|
||||
: Expr(p) {
|
||||
: Expr(p, SelectExprID) {
|
||||
test = t;
|
||||
expr1 = e1;
|
||||
expr2 = e2;
|
||||
@@ -3404,7 +3403,7 @@ SelectExpr::Optimize() {
|
||||
if (test == NULL || expr1 == NULL || expr2 == NULL)
|
||||
return NULL;
|
||||
|
||||
ConstExpr *constTest = dynamic_cast<ConstExpr *>(test);
|
||||
ConstExpr *constTest = llvm::dyn_cast<ConstExpr>(test);
|
||||
if (constTest == NULL)
|
||||
return this;
|
||||
|
||||
@@ -3431,8 +3430,8 @@ SelectExpr::Optimize() {
|
||||
// Last chance: see if the two expressions are constants; if so,
|
||||
// then we can do an element-wise selection based on the constant
|
||||
// condition..
|
||||
ConstExpr *constExpr1 = dynamic_cast<ConstExpr *>(expr1);
|
||||
ConstExpr *constExpr2 = dynamic_cast<ConstExpr *>(expr2);
|
||||
ConstExpr *constExpr1 = llvm::dyn_cast<ConstExpr>(expr1);
|
||||
ConstExpr *constExpr2 = llvm::dyn_cast<ConstExpr>(expr2);
|
||||
if (constExpr1 == NULL || constExpr2 == NULL)
|
||||
return this;
|
||||
|
||||
@@ -3555,7 +3554,7 @@ SelectExpr::Print() const {
|
||||
|
||||
FunctionCallExpr::FunctionCallExpr(Expr *f, ExprList *a, SourcePos p,
|
||||
bool il, Expr *lce[3])
|
||||
: Expr(p), isLaunch(il) {
|
||||
: Expr(p, FunctionCallExprID), isLaunch(il) {
|
||||
func = f;
|
||||
args = a;
|
||||
if (lce != NULL)
|
||||
@@ -3728,8 +3727,8 @@ bool FullResolveOverloads(Expr * func, ExprList * args,
|
||||
if (t == NULL)
|
||||
return false;
|
||||
argTypes->push_back(t);
|
||||
argCouldBeNULL->push_back(lIsAllIntZeros(expr) || dynamic_cast<NullPointerExpr *>(expr));
|
||||
argIsConstant->push_back(dynamic_cast<ConstExpr *>(expr) || dynamic_cast<NullPointerExpr *>(expr));
|
||||
argCouldBeNULL->push_back(lIsAllIntZeros(expr) || llvm::dyn_cast<NullPointerExpr>(expr));
|
||||
argIsConstant->push_back(llvm::dyn_cast<ConstExpr>(expr) || llvm::dyn_cast<NullPointerExpr>(expr));
|
||||
}
|
||||
return true;
|
||||
}
|
||||
@@ -3740,7 +3739,7 @@ FunctionCallExpr::GetType() const {
|
||||
std::vector<const Type *> argTypes;
|
||||
std::vector<bool> argCouldBeNULL, argIsConstant;
|
||||
if (FullResolveOverloads(func, args, &argTypes, &argCouldBeNULL, &argIsConstant) == true) {
|
||||
FunctionSymbolExpr *fse = dynamic_cast<FunctionSymbolExpr *>(func);
|
||||
FunctionSymbolExpr *fse = llvm::dyn_cast<FunctionSymbolExpr>(func);
|
||||
if (fse != NULL) {
|
||||
fse->ResolveOverloads(args->pos, argTypes, &argCouldBeNULL, &argIsConstant);
|
||||
}
|
||||
@@ -3785,7 +3784,7 @@ FunctionCallExpr::TypeCheck() {
|
||||
return NULL;
|
||||
}
|
||||
|
||||
FunctionSymbolExpr *fse = dynamic_cast<FunctionSymbolExpr *>(func);
|
||||
FunctionSymbolExpr *fse = llvm::dyn_cast<FunctionSymbolExpr>(func);
|
||||
if (fse != NULL) {
|
||||
// Regular function call
|
||||
if (fse->ResolveOverloads(args->pos, argTypes, &argCouldBeNULL,
|
||||
@@ -4012,7 +4011,7 @@ ExprList::GetConstant(const Type *type) const {
|
||||
const Type *elementType = collectionType->GetElementType(i);
|
||||
|
||||
Expr *expr = exprs[i];
|
||||
if (dynamic_cast<ExprList *>(expr) == NULL) {
|
||||
if (llvm::dyn_cast<ExprList>(expr) == NULL) {
|
||||
// If there's a simple type conversion from the type of this
|
||||
// expression to the type we need, then let the regular type
|
||||
// conversion machinery handle it.
|
||||
@@ -4121,7 +4120,7 @@ ExprList::Print() const {
|
||||
// IndexExpr
|
||||
|
||||
IndexExpr::IndexExpr(Expr *a, Expr *i, SourcePos p)
|
||||
: Expr(p) {
|
||||
: Expr(p, IndexExprID) {
|
||||
baseExpr = a;
|
||||
index = i;
|
||||
type = lvalueType = NULL;
|
||||
@@ -4294,8 +4293,8 @@ IndexExpr::GetValue(FunctionEmitContext *ctx) const {
|
||||
}
|
||||
else {
|
||||
Symbol *baseSym = GetBaseSymbol();
|
||||
if (dynamic_cast<FunctionCallExpr *>(baseExpr) == NULL &&
|
||||
dynamic_cast<BinaryExpr *>(baseExpr) == NULL) {
|
||||
if (llvm::dyn_cast<FunctionCallExpr>(baseExpr) == NULL &&
|
||||
llvm::dyn_cast<BinaryExpr>(baseExpr) == NULL) {
|
||||
// Don't check if we're doing a function call or pointer arith
|
||||
AssertPos(pos, baseSym != NULL);
|
||||
}
|
||||
@@ -4404,7 +4403,7 @@ lCheckIndicesVersusBounds(const Type *baseExprType, Expr *index) {
|
||||
if (soaWidth > 0)
|
||||
nElements *= soaWidth;
|
||||
|
||||
ConstExpr *ce = dynamic_cast<ConstExpr *>(index);
|
||||
ConstExpr *ce = llvm::dyn_cast<ConstExpr>(index);
|
||||
if (ce == NULL)
|
||||
return;
|
||||
|
||||
@@ -4725,6 +4724,11 @@ public:
|
||||
StructMemberExpr(Expr *e, const char *id, SourcePos p,
|
||||
SourcePos idpos, bool derefLValue);
|
||||
|
||||
static inline bool classof(StructMemberExpr const*) { return true; }
|
||||
static inline bool classof(ASTNode const* N) {
|
||||
return N->getValueID() == StructMemberExprID;
|
||||
}
|
||||
|
||||
const Type *GetType() const;
|
||||
const Type *GetLValueType() const;
|
||||
int getElementNumber() const;
|
||||
@@ -4737,7 +4741,7 @@ private:
|
||||
|
||||
StructMemberExpr::StructMemberExpr(Expr *e, const char *id, SourcePos p,
|
||||
SourcePos idpos, bool derefLValue)
|
||||
: MemberExpr(e, id, p, idpos, derefLValue) {
|
||||
: MemberExpr(e, id, p, idpos, derefLValue, StructMemberExprID) {
|
||||
}
|
||||
|
||||
|
||||
@@ -4892,6 +4896,11 @@ public:
|
||||
VectorMemberExpr(Expr *e, const char *id, SourcePos p,
|
||||
SourcePos idpos, bool derefLValue);
|
||||
|
||||
static inline bool classof(VectorMemberExpr const*) { return true; }
|
||||
static inline bool classof(ASTNode const* N) {
|
||||
return N->getValueID() == VectorMemberExprID;
|
||||
}
|
||||
|
||||
llvm::Value *GetValue(FunctionEmitContext* ctx) const;
|
||||
llvm::Value *GetLValue(FunctionEmitContext* ctx) const;
|
||||
const Type *GetType() const;
|
||||
@@ -4908,7 +4917,7 @@ private:
|
||||
|
||||
VectorMemberExpr::VectorMemberExpr(Expr *e, const char *id, SourcePos p,
|
||||
SourcePos idpos, bool derefLValue)
|
||||
: MemberExpr(e, id, p, idpos, derefLValue) {
|
||||
: MemberExpr(e, id, p, idpos, derefLValue, VectorMemberExprID) {
|
||||
const Type *exprType = e->GetType();
|
||||
exprVectorType = CastType<VectorType>(exprType);
|
||||
if (exprVectorType == NULL) {
|
||||
@@ -5166,8 +5175,8 @@ MemberExpr::create(Expr *e, const char *id, SourcePos p, SourcePos idpos,
|
||||
|
||||
|
||||
MemberExpr::MemberExpr(Expr *e, const char *id, SourcePos p, SourcePos idpos,
|
||||
bool derefLValue)
|
||||
: Expr(p), identifierPos(idpos) {
|
||||
bool derefLValue, unsigned scid)
|
||||
: Expr(p, scid), identifierPos(idpos) {
|
||||
expr = e;
|
||||
identifier = id;
|
||||
dereferenceExpr = derefLValue;
|
||||
@@ -5340,7 +5349,7 @@ MemberExpr::getCandidateNearMatches() const {
|
||||
// ConstExpr
|
||||
|
||||
ConstExpr::ConstExpr(const Type *t, int8_t i, SourcePos p)
|
||||
: Expr(p) {
|
||||
: Expr(p, ConstExprID) {
|
||||
type = t;
|
||||
type = type->GetAsConstType();
|
||||
AssertPos(pos, Type::Equal(type, AtomicType::UniformInt8->GetAsConstType()));
|
||||
@@ -5349,7 +5358,7 @@ ConstExpr::ConstExpr(const Type *t, int8_t i, SourcePos p)
|
||||
|
||||
|
||||
ConstExpr::ConstExpr(const Type *t, int8_t *i, SourcePos p)
|
||||
: Expr(p) {
|
||||
: Expr(p, ConstExprID) {
|
||||
type = t;
|
||||
type = type->GetAsConstType();
|
||||
AssertPos(pos, Type::Equal(type, AtomicType::UniformInt8->GetAsConstType()) ||
|
||||
@@ -5360,7 +5369,7 @@ ConstExpr::ConstExpr(const Type *t, int8_t *i, SourcePos p)
|
||||
|
||||
|
||||
ConstExpr::ConstExpr(const Type *t, uint8_t u, SourcePos p)
|
||||
: Expr(p) {
|
||||
: Expr(p, ConstExprID) {
|
||||
type = t;
|
||||
type = type->GetAsConstType();
|
||||
AssertPos(pos, Type::Equal(type, AtomicType::UniformUInt8->GetAsConstType()));
|
||||
@@ -5369,7 +5378,7 @@ ConstExpr::ConstExpr(const Type *t, uint8_t u, SourcePos p)
|
||||
|
||||
|
||||
ConstExpr::ConstExpr(const Type *t, uint8_t *u, SourcePos p)
|
||||
: Expr(p) {
|
||||
: Expr(p, ConstExprID) {
|
||||
type = t;
|
||||
type = type->GetAsConstType();
|
||||
AssertPos(pos, Type::Equal(type, AtomicType::UniformUInt8->GetAsConstType()) ||
|
||||
@@ -5380,7 +5389,7 @@ ConstExpr::ConstExpr(const Type *t, uint8_t *u, SourcePos p)
|
||||
|
||||
|
||||
ConstExpr::ConstExpr(const Type *t, int16_t i, SourcePos p)
|
||||
: Expr(p) {
|
||||
: Expr(p, ConstExprID) {
|
||||
type = t;
|
||||
type = type->GetAsConstType();
|
||||
AssertPos(pos, Type::Equal(type, AtomicType::UniformInt16->GetAsConstType()));
|
||||
@@ -5389,7 +5398,7 @@ ConstExpr::ConstExpr(const Type *t, int16_t i, SourcePos p)
|
||||
|
||||
|
||||
ConstExpr::ConstExpr(const Type *t, int16_t *i, SourcePos p)
|
||||
: Expr(p) {
|
||||
: Expr(p, ConstExprID) {
|
||||
type = t;
|
||||
type = type->GetAsConstType();
|
||||
AssertPos(pos, Type::Equal(type, AtomicType::UniformInt16->GetAsConstType()) ||
|
||||
@@ -5400,7 +5409,7 @@ ConstExpr::ConstExpr(const Type *t, int16_t *i, SourcePos p)
|
||||
|
||||
|
||||
ConstExpr::ConstExpr(const Type *t, uint16_t u, SourcePos p)
|
||||
: Expr(p) {
|
||||
: Expr(p, ConstExprID) {
|
||||
type = t;
|
||||
type = type->GetAsConstType();
|
||||
AssertPos(pos, Type::Equal(type, AtomicType::UniformUInt16->GetAsConstType()));
|
||||
@@ -5409,7 +5418,7 @@ ConstExpr::ConstExpr(const Type *t, uint16_t u, SourcePos p)
|
||||
|
||||
|
||||
ConstExpr::ConstExpr(const Type *t, uint16_t *u, SourcePos p)
|
||||
: Expr(p) {
|
||||
: Expr(p, ConstExprID) {
|
||||
type = t;
|
||||
type = type->GetAsConstType();
|
||||
AssertPos(pos, Type::Equal(type, AtomicType::UniformUInt16->GetAsConstType()) ||
|
||||
@@ -5420,7 +5429,7 @@ ConstExpr::ConstExpr(const Type *t, uint16_t *u, SourcePos p)
|
||||
|
||||
|
||||
ConstExpr::ConstExpr(const Type *t, int32_t i, SourcePos p)
|
||||
: Expr(p) {
|
||||
: Expr(p, ConstExprID) {
|
||||
type = t;
|
||||
type = type->GetAsConstType();
|
||||
AssertPos(pos, Type::Equal(type, AtomicType::UniformInt32->GetAsConstType()));
|
||||
@@ -5429,7 +5438,7 @@ ConstExpr::ConstExpr(const Type *t, int32_t i, SourcePos p)
|
||||
|
||||
|
||||
ConstExpr::ConstExpr(const Type *t, int32_t *i, SourcePos p)
|
||||
: Expr(p) {
|
||||
: Expr(p, ConstExprID) {
|
||||
type = t;
|
||||
type = type->GetAsConstType();
|
||||
AssertPos(pos, Type::Equal(type, AtomicType::UniformInt32->GetAsConstType()) ||
|
||||
@@ -5440,7 +5449,7 @@ ConstExpr::ConstExpr(const Type *t, int32_t *i, SourcePos p)
|
||||
|
||||
|
||||
ConstExpr::ConstExpr(const Type *t, uint32_t u, SourcePos p)
|
||||
: Expr(p) {
|
||||
: Expr(p, ConstExprID) {
|
||||
type = t;
|
||||
type = type->GetAsConstType();
|
||||
AssertPos(pos, Type::Equal(type, AtomicType::UniformUInt32->GetAsConstType()) ||
|
||||
@@ -5451,7 +5460,7 @@ ConstExpr::ConstExpr(const Type *t, uint32_t u, SourcePos p)
|
||||
|
||||
|
||||
ConstExpr::ConstExpr(const Type *t, uint32_t *u, SourcePos p)
|
||||
: Expr(p) {
|
||||
: Expr(p, ConstExprID) {
|
||||
type = t;
|
||||
type = type->GetAsConstType();
|
||||
AssertPos(pos, Type::Equal(type, AtomicType::UniformUInt32->GetAsConstType()) ||
|
||||
@@ -5463,7 +5472,7 @@ ConstExpr::ConstExpr(const Type *t, uint32_t *u, SourcePos p)
|
||||
|
||||
|
||||
ConstExpr::ConstExpr(const Type *t, float f, SourcePos p)
|
||||
: Expr(p) {
|
||||
: Expr(p, ConstExprID) {
|
||||
type = t;
|
||||
type = type->GetAsConstType();
|
||||
AssertPos(pos, Type::Equal(type, AtomicType::UniformFloat->GetAsConstType()));
|
||||
@@ -5472,7 +5481,7 @@ ConstExpr::ConstExpr(const Type *t, float f, SourcePos p)
|
||||
|
||||
|
||||
ConstExpr::ConstExpr(const Type *t, float *f, SourcePos p)
|
||||
: Expr(p) {
|
||||
: Expr(p, ConstExprID) {
|
||||
type = t;
|
||||
type = type->GetAsConstType();
|
||||
AssertPos(pos, Type::Equal(type, AtomicType::UniformFloat->GetAsConstType()) ||
|
||||
@@ -5483,7 +5492,7 @@ ConstExpr::ConstExpr(const Type *t, float *f, SourcePos p)
|
||||
|
||||
|
||||
ConstExpr::ConstExpr(const Type *t, int64_t i, SourcePos p)
|
||||
: Expr(p) {
|
||||
: Expr(p, ConstExprID) {
|
||||
type = t;
|
||||
type = type->GetAsConstType();
|
||||
AssertPos(pos, Type::Equal(type, AtomicType::UniformInt64->GetAsConstType()));
|
||||
@@ -5492,7 +5501,7 @@ ConstExpr::ConstExpr(const Type *t, int64_t i, SourcePos p)
|
||||
|
||||
|
||||
ConstExpr::ConstExpr(const Type *t, int64_t *i, SourcePos p)
|
||||
: Expr(p) {
|
||||
: Expr(p, ConstExprID) {
|
||||
type = t;
|
||||
type = type->GetAsConstType();
|
||||
AssertPos(pos, Type::Equal(type, AtomicType::UniformInt64->GetAsConstType()) ||
|
||||
@@ -5503,7 +5512,7 @@ ConstExpr::ConstExpr(const Type *t, int64_t *i, SourcePos p)
|
||||
|
||||
|
||||
ConstExpr::ConstExpr(const Type *t, uint64_t u, SourcePos p)
|
||||
: Expr(p) {
|
||||
: Expr(p, ConstExprID) {
|
||||
type = t;
|
||||
type = type->GetAsConstType();
|
||||
AssertPos(pos, Type::Equal(type, AtomicType::UniformUInt64->GetAsConstType()));
|
||||
@@ -5512,7 +5521,7 @@ ConstExpr::ConstExpr(const Type *t, uint64_t u, SourcePos p)
|
||||
|
||||
|
||||
ConstExpr::ConstExpr(const Type *t, uint64_t *u, SourcePos p)
|
||||
: Expr(p) {
|
||||
: Expr(p, ConstExprID) {
|
||||
type = t;
|
||||
type = type->GetAsConstType();
|
||||
AssertPos(pos, Type::Equal(type, AtomicType::UniformUInt64->GetAsConstType()) ||
|
||||
@@ -5523,7 +5532,7 @@ ConstExpr::ConstExpr(const Type *t, uint64_t *u, SourcePos p)
|
||||
|
||||
|
||||
ConstExpr::ConstExpr(const Type *t, double f, SourcePos p)
|
||||
: Expr(p) {
|
||||
: Expr(p, ConstExprID) {
|
||||
type = t;
|
||||
type = type->GetAsConstType();
|
||||
AssertPos(pos, Type::Equal(type, AtomicType::UniformDouble->GetAsConstType()));
|
||||
@@ -5532,7 +5541,7 @@ ConstExpr::ConstExpr(const Type *t, double f, SourcePos p)
|
||||
|
||||
|
||||
ConstExpr::ConstExpr(const Type *t, double *f, SourcePos p)
|
||||
: Expr(p) {
|
||||
: Expr(p, ConstExprID) {
|
||||
type = t;
|
||||
type = type->GetAsConstType();
|
||||
AssertPos(pos, Type::Equal(type, AtomicType::UniformDouble->GetAsConstType()) ||
|
||||
@@ -5543,7 +5552,7 @@ ConstExpr::ConstExpr(const Type *t, double *f, SourcePos p)
|
||||
|
||||
|
||||
ConstExpr::ConstExpr(const Type *t, bool b, SourcePos p)
|
||||
: Expr(p) {
|
||||
: Expr(p, ConstExprID) {
|
||||
type = t;
|
||||
type = type->GetAsConstType();
|
||||
AssertPos(pos, Type::Equal(type, AtomicType::UniformBool->GetAsConstType()));
|
||||
@@ -5552,7 +5561,7 @@ ConstExpr::ConstExpr(const Type *t, bool b, SourcePos p)
|
||||
|
||||
|
||||
ConstExpr::ConstExpr(const Type *t, bool *b, SourcePos p)
|
||||
: Expr(p) {
|
||||
: Expr(p, ConstExprID) {
|
||||
type = t;
|
||||
type = type->GetAsConstType();
|
||||
AssertPos(pos, Type::Equal(type, AtomicType::UniformBool->GetAsConstType()) ||
|
||||
@@ -5563,7 +5572,7 @@ ConstExpr::ConstExpr(const Type *t, bool *b, SourcePos p)
|
||||
|
||||
|
||||
ConstExpr::ConstExpr(ConstExpr *old, double *v)
|
||||
: Expr(old->pos) {
|
||||
: Expr(old->pos, ConstExprID) {
|
||||
type = old->type;
|
||||
|
||||
AtomicType::BasicType basicType = getBasicType();
|
||||
@@ -5617,7 +5626,7 @@ ConstExpr::ConstExpr(ConstExpr *old, double *v)
|
||||
|
||||
|
||||
ConstExpr::ConstExpr(ConstExpr *old, SourcePos p)
|
||||
: Expr(p) {
|
||||
: Expr(p, ConstExprID) {
|
||||
type = old->type;
|
||||
|
||||
AtomicType::BasicType basicType = getBasicType();
|
||||
@@ -6223,7 +6232,7 @@ ConstExpr::Print() const {
|
||||
// TypeCastExpr
|
||||
|
||||
TypeCastExpr::TypeCastExpr(const Type *t, Expr *e, SourcePos p)
|
||||
: Expr(p) {
|
||||
: Expr(p, TypeCastExprID) {
|
||||
type = t;
|
||||
expr = e;
|
||||
}
|
||||
@@ -7229,7 +7238,7 @@ TypeCastExpr::TypeCheck() {
|
||||
|
||||
Expr *
|
||||
TypeCastExpr::Optimize() {
|
||||
ConstExpr *constExpr = dynamic_cast<ConstExpr *>(expr);
|
||||
ConstExpr *constExpr = llvm::dyn_cast<ConstExpr>(expr);
|
||||
if (constExpr == NULL)
|
||||
// We can't do anything if this isn't a const expr
|
||||
return this;
|
||||
@@ -7315,7 +7324,7 @@ TypeCastExpr::Optimize() {
|
||||
|
||||
int
|
||||
TypeCastExpr::EstimateCost() const {
|
||||
if (dynamic_cast<ConstExpr *>(expr) != NULL)
|
||||
if (llvm::dyn_cast<ConstExpr>(expr) != NULL)
|
||||
return 0;
|
||||
|
||||
// FIXME: return COST_TYPECAST_COMPLEX when appropriate
|
||||
@@ -7392,7 +7401,7 @@ TypeCastExpr::GetConstant(const Type *constType) const {
|
||||
// ReferenceExpr
|
||||
|
||||
ReferenceExpr::ReferenceExpr(Expr *e, SourcePos p)
|
||||
: Expr(p) {
|
||||
: Expr(p, ReferenceExprID) {
|
||||
expr = e;
|
||||
}
|
||||
|
||||
@@ -7500,8 +7509,8 @@ ReferenceExpr::Print() const {
|
||||
///////////////////////////////////////////////////////////////////////////
|
||||
// DerefExpr
|
||||
|
||||
DerefExpr::DerefExpr(Expr *e, SourcePos p)
|
||||
: Expr(p) {
|
||||
DerefExpr::DerefExpr(Expr *e, SourcePos p, unsigned scid)
|
||||
: Expr(p, scid) {
|
||||
expr = e;
|
||||
}
|
||||
|
||||
@@ -7563,7 +7572,7 @@ DerefExpr::Optimize() {
|
||||
// PtrDerefExpr
|
||||
|
||||
PtrDerefExpr::PtrDerefExpr(Expr *e, SourcePos p)
|
||||
: DerefExpr(e, p) {
|
||||
: DerefExpr(e, p, PtrDerefExprID) {
|
||||
}
|
||||
|
||||
|
||||
@@ -7641,7 +7650,7 @@ PtrDerefExpr::Print() const {
|
||||
// RefDerefExpr
|
||||
|
||||
RefDerefExpr::RefDerefExpr(Expr *e, SourcePos p)
|
||||
: DerefExpr(e, p) {
|
||||
: DerefExpr(e, p, RefDerefExprID) {
|
||||
}
|
||||
|
||||
|
||||
@@ -7700,7 +7709,7 @@ RefDerefExpr::Print() const {
|
||||
// AddressOfExpr
|
||||
|
||||
AddressOfExpr::AddressOfExpr(Expr *e, SourcePos p)
|
||||
: Expr(p), expr(e) {
|
||||
: Expr(p, AddressOfExprID), expr(e) {
|
||||
}
|
||||
|
||||
|
||||
@@ -7832,12 +7841,12 @@ AddressOfExpr::GetConstant(const Type *type) const {
|
||||
// SizeOfExpr
|
||||
|
||||
SizeOfExpr::SizeOfExpr(Expr *e, SourcePos p)
|
||||
: Expr(p), expr(e), type(NULL) {
|
||||
: Expr(p, SizeOfExprID), expr(e), type(NULL) {
|
||||
}
|
||||
|
||||
|
||||
SizeOfExpr::SizeOfExpr(const Type *t, SourcePos p)
|
||||
: Expr(p), expr(NULL), type(t) {
|
||||
: Expr(p, SizeOfExprID), expr(NULL), type(t) {
|
||||
type = type->ResolveUnboundVariability(Variability::Varying);
|
||||
}
|
||||
|
||||
@@ -7914,7 +7923,7 @@ SizeOfExpr::EstimateCost() const {
|
||||
// SymbolExpr
|
||||
|
||||
SymbolExpr::SymbolExpr(Symbol *s, SourcePos p)
|
||||
: Expr(p) {
|
||||
: Expr(p, SymbolExprID) {
|
||||
symbol = s;
|
||||
}
|
||||
|
||||
@@ -8008,7 +8017,7 @@ SymbolExpr::Print() const {
|
||||
FunctionSymbolExpr::FunctionSymbolExpr(const char *n,
|
||||
const std::vector<Symbol *> &candidates,
|
||||
SourcePos p)
|
||||
: Expr(p) {
|
||||
: Expr(p, FunctionSymbolExprID) {
|
||||
name = n;
|
||||
candidateFunctions = candidates;
|
||||
matchingFunc = (candidates.size() == 1) ? candidates[0] : NULL;
|
||||
@@ -8555,7 +8564,7 @@ NullPointerExpr::EstimateCost() const {
|
||||
|
||||
NewExpr::NewExpr(int typeQual, const Type *t, Expr *init, Expr *count,
|
||||
SourcePos tqPos, SourcePos p)
|
||||
: Expr(p) {
|
||||
: Expr(p, NewExprID) {
|
||||
allocType = t;
|
||||
|
||||
initExpr = init;
|
||||
|
||||
129
expr.h
129
expr.h
@@ -47,7 +47,12 @@
|
||||
*/
|
||||
class Expr : public ASTNode {
|
||||
public:
|
||||
Expr(SourcePos p) : ASTNode(p) { }
|
||||
Expr(SourcePos p, unsigned scid) : ASTNode(p, scid) { }
|
||||
|
||||
static inline bool classof(Expr const*) { return true; }
|
||||
static inline bool classof(ASTNode const* N) {
|
||||
return N->getValueID() < MaxExprID;
|
||||
}
|
||||
|
||||
/** This is the main method for Expr implementations to implement. It
|
||||
should call methods in the FunctionEmitContext to emit LLVM IR
|
||||
@@ -111,6 +116,11 @@ public:
|
||||
|
||||
UnaryExpr(Op op, Expr *expr, SourcePos pos);
|
||||
|
||||
static inline bool classof(UnaryExpr const*) { return true; }
|
||||
static inline bool classof(ASTNode const* N) {
|
||||
return N->getValueID() == UnaryExprID;
|
||||
}
|
||||
|
||||
llvm::Value *GetValue(FunctionEmitContext *ctx) const;
|
||||
const Type *GetType() const;
|
||||
void Print() const;
|
||||
@@ -153,6 +163,11 @@ public:
|
||||
|
||||
BinaryExpr(Op o, Expr *a, Expr *b, SourcePos p);
|
||||
|
||||
static inline bool classof(BinaryExpr const*) { return true; }
|
||||
static inline bool classof(ASTNode const* N) {
|
||||
return N->getValueID() == BinaryExprID;
|
||||
}
|
||||
|
||||
llvm::Value *GetValue(FunctionEmitContext *ctx) const;
|
||||
const Type *GetType() const;
|
||||
const Type *GetLValueType() const;
|
||||
@@ -186,6 +201,11 @@ public:
|
||||
|
||||
AssignExpr(Op o, Expr *a, Expr *b, SourcePos p);
|
||||
|
||||
static inline bool classof(AssignExpr const*) { return true; }
|
||||
static inline bool classof(ASTNode const* N) {
|
||||
return N->getValueID() == AssignExprID;
|
||||
}
|
||||
|
||||
llvm::Value *GetValue(FunctionEmitContext *ctx) const;
|
||||
const Type *GetType() const;
|
||||
void Print() const;
|
||||
@@ -207,6 +227,11 @@ class SelectExpr : public Expr {
|
||||
public:
|
||||
SelectExpr(Expr *test, Expr *a, Expr *b, SourcePos p);
|
||||
|
||||
static inline bool classof(SelectExpr const*) { return true; }
|
||||
static inline bool classof(ASTNode const* N) {
|
||||
return N->getValueID() == SelectExprID;
|
||||
}
|
||||
|
||||
llvm::Value *GetValue(FunctionEmitContext *ctx) const;
|
||||
const Type *GetType() const;
|
||||
void Print() const;
|
||||
@@ -218,7 +243,6 @@ public:
|
||||
Expr *test, *expr1, *expr2;
|
||||
};
|
||||
|
||||
|
||||
/** @brief A list of expressions.
|
||||
|
||||
These are mostly used for representing curly-brace delimited
|
||||
@@ -227,8 +251,13 @@ public:
|
||||
*/
|
||||
class ExprList : public Expr {
|
||||
public:
|
||||
ExprList(SourcePos p) : Expr(p) { }
|
||||
ExprList(Expr *e, SourcePos p) : Expr(p) { exprs.push_back(e); }
|
||||
ExprList(SourcePos p) : Expr(p, ExprListID) { }
|
||||
ExprList(Expr *e, SourcePos p) : Expr(p, ExprListID) { exprs.push_back(e); }
|
||||
|
||||
static inline bool classof(ExprList const*) { return true; }
|
||||
static inline bool classof(ASTNode const* N) {
|
||||
return N->getValueID() == ExprListID;
|
||||
}
|
||||
|
||||
llvm::Value *GetValue(FunctionEmitContext *ctx) const;
|
||||
const Type *GetType() const;
|
||||
@@ -250,6 +279,11 @@ public:
|
||||
bool isLaunch = false,
|
||||
Expr *launchCountExpr[3] = NULL);
|
||||
|
||||
static inline bool classof(FunctionCallExpr const*) { return true; }
|
||||
static inline bool classof(ASTNode const* N) {
|
||||
return N->getValueID() == FunctionCallExprID;
|
||||
}
|
||||
|
||||
llvm::Value *GetValue(FunctionEmitContext *ctx) const;
|
||||
llvm::Value *GetLValue(FunctionEmitContext *ctx) const;
|
||||
const Type *GetType() const;
|
||||
@@ -276,6 +310,11 @@ class IndexExpr : public Expr {
|
||||
public:
|
||||
IndexExpr(Expr *baseExpr, Expr *index, SourcePos p);
|
||||
|
||||
static inline bool classof(IndexExpr const*) { return true; }
|
||||
static inline bool classof(ASTNode const* N) {
|
||||
return N->getValueID() == IndexExprID;
|
||||
}
|
||||
|
||||
llvm::Value *GetValue(FunctionEmitContext *ctx) const;
|
||||
llvm::Value *GetLValue(FunctionEmitContext *ctx) const;
|
||||
const Type *GetType() const;
|
||||
@@ -304,6 +343,13 @@ public:
|
||||
static MemberExpr *create(Expr *expr, const char *identifier,
|
||||
SourcePos pos, SourcePos identifierPos,
|
||||
bool derefLvalue);
|
||||
|
||||
static inline bool classof(MemberExpr const*) { return true; }
|
||||
static inline bool classof(ASTNode const* N) {
|
||||
return ((N->getValueID() == StructMemberExprID) ||
|
||||
(N->getValueID() == VectorMemberExprID));
|
||||
}
|
||||
|
||||
llvm::Value *GetValue(FunctionEmitContext *ctx) const;
|
||||
llvm::Value *GetLValue(FunctionEmitContext *ctx) const;
|
||||
const Type *GetType() const;
|
||||
@@ -322,7 +368,7 @@ public:
|
||||
const SourcePos identifierPos;
|
||||
|
||||
MemberExpr(Expr *expr, const char *identifier, SourcePos pos,
|
||||
SourcePos identifierPos, bool derefLValue);
|
||||
SourcePos identifierPos, bool derefLValue, unsigned scid);
|
||||
|
||||
/** Indicates whether the expression should be dereferenced before the
|
||||
member is found. (i.e. this is true if the MemberExpr was a '->'
|
||||
@@ -402,6 +448,11 @@ public:
|
||||
but at the given position. */
|
||||
ConstExpr(ConstExpr *old, SourcePos pos);
|
||||
|
||||
static inline bool classof(ConstExpr const*) { return true; }
|
||||
static inline bool classof(ASTNode const* N) {
|
||||
return N->getValueID() == ConstExprID;
|
||||
}
|
||||
|
||||
llvm::Value *GetValue(FunctionEmitContext *ctx) const;
|
||||
const Type *GetType() const;
|
||||
void Print() const;
|
||||
@@ -459,6 +510,11 @@ class TypeCastExpr : public Expr {
|
||||
public:
|
||||
TypeCastExpr(const Type *t, Expr *e, SourcePos p);
|
||||
|
||||
static inline bool classof(TypeCastExpr const*) { return true; }
|
||||
static inline bool classof(ASTNode const* N) {
|
||||
return N->getValueID() == TypeCastExprID;
|
||||
}
|
||||
|
||||
llvm::Value *GetValue(FunctionEmitContext *ctx) const;
|
||||
llvm::Value *GetLValue(FunctionEmitContext *ctx) const;
|
||||
const Type *GetType() const;
|
||||
@@ -481,6 +537,11 @@ class ReferenceExpr : public Expr {
|
||||
public:
|
||||
ReferenceExpr(Expr *e, SourcePos p);
|
||||
|
||||
static inline bool classof(ReferenceExpr const*) { return true; }
|
||||
static inline bool classof(ASTNode const* N) {
|
||||
return N->getValueID() == ReferenceExprID;
|
||||
}
|
||||
|
||||
llvm::Value *GetValue(FunctionEmitContext *ctx) const;
|
||||
const Type *GetType() const;
|
||||
const Type *GetLValueType() const;
|
||||
@@ -498,7 +559,14 @@ public:
|
||||
PtrDerefExpr and RefDerefExpr. */
|
||||
class DerefExpr : public Expr {
|
||||
public:
|
||||
DerefExpr(Expr *e, SourcePos p);
|
||||
DerefExpr(Expr *e, SourcePos p, unsigned scid = DerefExprID);
|
||||
|
||||
static inline bool classof(DerefExpr const*) { return true; }
|
||||
static inline bool classof(ASTNode const* N) {
|
||||
return ((N->getValueID() == DerefExprID) ||
|
||||
(N->getValueID() == PtrDerefExprID) ||
|
||||
(N->getValueID() == RefDerefExprID));
|
||||
}
|
||||
|
||||
llvm::Value *GetValue(FunctionEmitContext *ctx) const;
|
||||
llvm::Value *GetLValue(FunctionEmitContext *ctx) const;
|
||||
@@ -516,6 +584,11 @@ class PtrDerefExpr : public DerefExpr {
|
||||
public:
|
||||
PtrDerefExpr(Expr *e, SourcePos p);
|
||||
|
||||
static inline bool classof(PtrDerefExpr const*) { return true; }
|
||||
static inline bool classof(ASTNode const* N) {
|
||||
return N->getValueID() == PtrDerefExprID;
|
||||
}
|
||||
|
||||
const Type *GetType() const;
|
||||
void Print() const;
|
||||
Expr *TypeCheck();
|
||||
@@ -529,6 +602,11 @@ class RefDerefExpr : public DerefExpr {
|
||||
public:
|
||||
RefDerefExpr(Expr *e, SourcePos p);
|
||||
|
||||
static inline bool classof(RefDerefExpr const*) { return true; }
|
||||
static inline bool classof(ASTNode const* N) {
|
||||
return N->getValueID() == RefDerefExprID;
|
||||
}
|
||||
|
||||
const Type *GetType() const;
|
||||
void Print() const;
|
||||
Expr *TypeCheck();
|
||||
@@ -541,6 +619,11 @@ class AddressOfExpr : public Expr {
|
||||
public:
|
||||
AddressOfExpr(Expr *e, SourcePos p);
|
||||
|
||||
static inline bool classof(AddressOfExpr const*) { return true; }
|
||||
static inline bool classof(ASTNode const* N) {
|
||||
return N->getValueID() == AddressOfExprID;
|
||||
}
|
||||
|
||||
llvm::Value *GetValue(FunctionEmitContext *ctx) const;
|
||||
const Type *GetType() const;
|
||||
const Type *GetLValueType() const;
|
||||
@@ -562,6 +645,11 @@ public:
|
||||
SizeOfExpr(Expr *e, SourcePos p);
|
||||
SizeOfExpr(const Type *t, SourcePos p);
|
||||
|
||||
static inline bool classof(SizeOfExpr const*) { return true; }
|
||||
static inline bool classof(ASTNode const* N) {
|
||||
return N->getValueID() == SizeOfExprID;
|
||||
}
|
||||
|
||||
llvm::Value *GetValue(FunctionEmitContext *ctx) const;
|
||||
const Type *GetType() const;
|
||||
void Print() const;
|
||||
@@ -581,6 +669,11 @@ class SymbolExpr : public Expr {
|
||||
public:
|
||||
SymbolExpr(Symbol *s, SourcePos p);
|
||||
|
||||
static inline bool classof(SymbolExpr const*) { return true; }
|
||||
static inline bool classof(ASTNode const* N) {
|
||||
return N->getValueID() == SymbolExprID;
|
||||
}
|
||||
|
||||
llvm::Value *GetValue(FunctionEmitContext *ctx) const;
|
||||
llvm::Value *GetLValue(FunctionEmitContext *ctx) const;
|
||||
const Type *GetType() const;
|
||||
@@ -604,6 +697,11 @@ public:
|
||||
FunctionSymbolExpr(const char *name, const std::vector<Symbol *> &candFuncs,
|
||||
SourcePos pos);
|
||||
|
||||
static inline bool classof(FunctionSymbolExpr const*) { return true; }
|
||||
static inline bool classof(ASTNode const* N) {
|
||||
return N->getValueID() == FunctionSymbolExprID;
|
||||
}
|
||||
|
||||
llvm::Value *GetValue(FunctionEmitContext *ctx) const;
|
||||
const Type *GetType() const;
|
||||
Symbol *GetBaseSymbol() const;
|
||||
@@ -658,7 +756,12 @@ private:
|
||||
proceeding). */
|
||||
class SyncExpr : public Expr {
|
||||
public:
|
||||
SyncExpr(SourcePos p) : Expr(p) { }
|
||||
SyncExpr(SourcePos p) : Expr(p, SyncExprID) { }
|
||||
|
||||
static inline bool classof(SyncExpr const*) { return true; }
|
||||
static inline bool classof(ASTNode const* N) {
|
||||
return N->getValueID() == SyncExprID;
|
||||
}
|
||||
|
||||
llvm::Value *GetValue(FunctionEmitContext *ctx) const;
|
||||
const Type *GetType() const;
|
||||
@@ -672,7 +775,12 @@ public:
|
||||
/** @brief An expression that represents a NULL pointer. */
|
||||
class NullPointerExpr : public Expr {
|
||||
public:
|
||||
NullPointerExpr(SourcePos p) : Expr(p) { }
|
||||
NullPointerExpr(SourcePos p) : Expr(p, NullPointerExprID) { }
|
||||
|
||||
static inline bool classof(NullPointerExpr const*) { return true; }
|
||||
static inline bool classof(ASTNode const* N) {
|
||||
return N->getValueID() == NullPointerExprID;
|
||||
}
|
||||
|
||||
llvm::Value *GetValue(FunctionEmitContext *ctx) const;
|
||||
const Type *GetType() const;
|
||||
@@ -692,6 +800,11 @@ public:
|
||||
NewExpr(int typeQual, const Type *type, Expr *initializer, Expr *count,
|
||||
SourcePos tqPos, SourcePos p);
|
||||
|
||||
static inline bool classof(NewExpr const*) { return true; }
|
||||
static inline bool classof(ASTNode const* N) {
|
||||
return N->getValueID() == NewExprID;
|
||||
}
|
||||
|
||||
llvm::Value *GetValue(FunctionEmitContext *ctx) const;
|
||||
const Type *GetType() const;
|
||||
Expr *TypeCheck();
|
||||
|
||||
2
func.cpp
2
func.cpp
@@ -499,7 +499,7 @@ Function::GenerateIR() {
|
||||
// non-StmtList statment...
|
||||
SourcePos firstStmtPos = sym->pos;
|
||||
if (code) {
|
||||
StmtList *sl = dynamic_cast<StmtList *>(code);
|
||||
StmtList *sl = llvm::dyn_cast<StmtList>(code);
|
||||
if (sl && sl->stmts.size() > 0 && sl->stmts[0] != NULL)
|
||||
firstStmtPos = sl->stmts[0]->pos;
|
||||
else
|
||||
|
||||
12
module.cpp
12
module.cpp
@@ -608,7 +608,7 @@ Module::AddGlobalVariable(const std::string &name, const Type *type, Expr *initE
|
||||
// the same type as the global. (But not if it's an
|
||||
// ExprList; they don't have types per se / can't type
|
||||
// convert themselves anyway.)
|
||||
if (dynamic_cast<ExprList *>(initExpr) == NULL)
|
||||
if (llvm::dyn_cast<ExprList>(initExpr) == NULL)
|
||||
initExpr = TypeConvertExpr(initExpr, type, "initializer");
|
||||
|
||||
if (initExpr != NULL) {
|
||||
@@ -620,11 +620,11 @@ Module::AddGlobalVariable(const std::string &name, const Type *type, Expr *initE
|
||||
if (llvmInitializer != NULL) {
|
||||
if (type->IsConstType())
|
||||
// Try to get a ConstExpr associated with
|
||||
// the symbol. This dynamic_cast can
|
||||
// the symbol. This llvm::dyn_cast can
|
||||
// validly fail, for example for types like
|
||||
// StructTypes where a ConstExpr can't
|
||||
// represent their values.
|
||||
constValue = dynamic_cast<ConstExpr *>(initExpr);
|
||||
constValue = llvm::dyn_cast<ConstExpr>(initExpr);
|
||||
}
|
||||
else
|
||||
Error(initExpr->pos, "Initializer for global variable \"%s\" "
|
||||
@@ -1909,8 +1909,7 @@ std::string emitOffloadParamStruct(const std::string ¶mStructName,
|
||||
if (!orgParamType->IsConstType()) {
|
||||
Error(sym->pos,"When emitting offload-stubs, \"export\"ed functions cannot have non-const reference-type parameters.\n");
|
||||
}
|
||||
const ReferenceType *refType
|
||||
= dynamic_cast<const ReferenceType*>(orgParamType);
|
||||
const ReferenceType *refType = static_cast<const ReferenceType *>(orgParamType);
|
||||
paramType = refType->GetReferenceTarget()->GetAsNonConstType();
|
||||
} else {
|
||||
paramType = orgParamType->GetAsNonConstType();
|
||||
@@ -2028,8 +2027,7 @@ Module::writeDevStub(const char *fn)
|
||||
if (!orgParamType->IsConstType()) {
|
||||
Error(sym->pos,"When emitting offload-stubs, \"export\"ed functions cannot have non-const reference-type parameters.\n");
|
||||
}
|
||||
const ReferenceType *refType
|
||||
= dynamic_cast<const ReferenceType*>(orgParamType);
|
||||
const ReferenceType *refType = static_cast<const ReferenceType *>(orgParamType);
|
||||
paramType = refType->GetReferenceTarget()->GetAsNonConstType();
|
||||
} else {
|
||||
paramType = orgParamType->GetAsNonConstType();
|
||||
|
||||
4
parse.yy
4
parse.yy
@@ -480,7 +480,7 @@ argument_expression_list
|
||||
: assignment_expression { $$ = new ExprList($1, @1); }
|
||||
| argument_expression_list ',' assignment_expression
|
||||
{
|
||||
ExprList *argList = dynamic_cast<ExprList *>($1);
|
||||
ExprList *argList = llvm::dyn_cast<ExprList>($1);
|
||||
if (argList == NULL) {
|
||||
AssertPos(@1, m->errorCount > 0);
|
||||
argList = new ExprList(@3);
|
||||
@@ -2422,7 +2422,7 @@ lFinalizeEnumeratorSymbols(std::vector<Symbol *> &enums,
|
||||
Expr *castExpr = new TypeCastExpr(enumType, enums[i]->constValue,
|
||||
enums[i]->pos);
|
||||
castExpr = Optimize(castExpr);
|
||||
enums[i]->constValue = dynamic_cast<ConstExpr *>(castExpr);
|
||||
enums[i]->constValue = llvm::dyn_cast<ConstExpr>(castExpr);
|
||||
AssertPos(enums[i]->pos, enums[i]->constValue != NULL);
|
||||
}
|
||||
else {
|
||||
|
||||
90
stmt.cpp
90
stmt.cpp
@@ -82,7 +82,7 @@ Stmt::Optimize() {
|
||||
// ExprStmt
|
||||
|
||||
ExprStmt::ExprStmt(Expr *e, SourcePos p)
|
||||
: Stmt(p) {
|
||||
: Stmt(p, ExprStmtID) {
|
||||
expr = e;
|
||||
}
|
||||
|
||||
@@ -126,7 +126,7 @@ ExprStmt::EstimateCost() const {
|
||||
// DeclStmt
|
||||
|
||||
DeclStmt::DeclStmt(const std::vector<VariableDeclaration> &v, SourcePos p)
|
||||
: Stmt(p), vars(v) {
|
||||
: Stmt(p, DeclStmtID), vars(v) {
|
||||
}
|
||||
|
||||
|
||||
@@ -295,7 +295,7 @@ DeclStmt::EmitCode(FunctionEmitContext *ctx) const {
|
||||
// FIXME: we only need this for function pointers; it was
|
||||
// already done for atomic types and enums in
|
||||
// DeclStmt::TypeCheck()...
|
||||
if (dynamic_cast<ExprList *>(initExpr) == NULL) {
|
||||
if (llvm::dyn_cast<ExprList>(initExpr) == NULL) {
|
||||
initExpr = TypeConvertExpr(initExpr, sym->type,
|
||||
"initializer");
|
||||
// FIXME: and this is only needed to re-establish
|
||||
@@ -436,7 +436,7 @@ Stmt *
|
||||
DeclStmt::Optimize() {
|
||||
for (unsigned int i = 0; i < vars.size(); ++i) {
|
||||
Expr *init = vars[i].init;
|
||||
if (init != NULL && dynamic_cast<ExprList *>(init) == NULL) {
|
||||
if (init != NULL && llvm::dyn_cast<ExprList>(init) == NULL) {
|
||||
// If the variable is const-qualified, after we've optimized
|
||||
// the initializer expression, see if we have a ConstExpr. If
|
||||
// so, save it in Symbol::constValue where it can be used in
|
||||
@@ -455,7 +455,7 @@ DeclStmt::Optimize() {
|
||||
Symbol *sym = vars[i].sym;
|
||||
if (sym->type && sym->type->IsConstType() &&
|
||||
Type::Equal(init->GetType(), sym->type))
|
||||
sym->constValue = dynamic_cast<ConstExpr *>(init);
|
||||
sym->constValue = llvm::dyn_cast<ConstExpr>(init);
|
||||
}
|
||||
}
|
||||
return this;
|
||||
@@ -483,7 +483,7 @@ DeclStmt::TypeCheck() {
|
||||
// If it's an expr list with an atomic type, we'll later issue
|
||||
// an error. Need to leave vars[i].init as is in that case so
|
||||
// it is in fact caught later, though.
|
||||
if (dynamic_cast<ExprList *>(vars[i].init) == NULL) {
|
||||
if (llvm::dyn_cast<ExprList>(vars[i].init) == NULL) {
|
||||
vars[i].init = TypeConvertExpr(vars[i].init, type,
|
||||
"initializer");
|
||||
if (vars[i].init == NULL)
|
||||
@@ -523,7 +523,7 @@ DeclStmt::EstimateCost() const {
|
||||
// IfStmt
|
||||
|
||||
IfStmt::IfStmt(Expr *t, Stmt *ts, Stmt *fs, bool checkCoherence, SourcePos p)
|
||||
: Stmt(p), test(t), trueStmts(ts), falseStmts(fs),
|
||||
: Stmt(p, IfStmtID), test(t), trueStmts(ts), falseStmts(fs),
|
||||
doAllCheck(checkCoherence &&
|
||||
!g->opt.disableCoherentControlFlow) {
|
||||
}
|
||||
@@ -534,11 +534,11 @@ lEmitIfStatements(FunctionEmitContext *ctx, Stmt *stmts, const char *trueOrFalse
|
||||
if (!stmts)
|
||||
return;
|
||||
|
||||
if (dynamic_cast<StmtList *>(stmts) == NULL)
|
||||
if (llvm::dyn_cast<StmtList>(stmts) == NULL)
|
||||
ctx->StartScope();
|
||||
ctx->AddInstrumentationPoint(trueOrFalse);
|
||||
stmts->EmitCode(ctx);
|
||||
if (dynamic_cast<const StmtList *>(stmts) == NULL)
|
||||
if (llvm::dyn_cast<const StmtList>(stmts) == NULL)
|
||||
ctx->EndScope();
|
||||
}
|
||||
|
||||
@@ -549,18 +549,18 @@ lEmitIfStatements(FunctionEmitContext *ctx, Stmt *stmts, const char *trueOrFalse
|
||||
static bool
|
||||
lCanApplyBreakOptimization(Stmt *trueStmts, Stmt *falseStmts) {
|
||||
if (falseStmts != NULL) {
|
||||
if (StmtList *sl = dynamic_cast<StmtList *>(falseStmts)) {
|
||||
if (StmtList *sl = llvm::dyn_cast<StmtList>(falseStmts)) {
|
||||
return (sl->stmts.size() == 0);
|
||||
}
|
||||
else
|
||||
return false;
|
||||
}
|
||||
|
||||
if (dynamic_cast<BreakStmt *>(trueStmts))
|
||||
if (llvm::dyn_cast<BreakStmt>(trueStmts))
|
||||
return true;
|
||||
else if (StmtList *sl = dynamic_cast<StmtList *>(trueStmts))
|
||||
else if (StmtList *sl = llvm::dyn_cast<StmtList>(trueStmts))
|
||||
return (sl->stmts.size() == 1 &&
|
||||
dynamic_cast<BreakStmt *>(sl->stmts[0]) != NULL);
|
||||
llvm::dyn_cast<BreakStmt>(sl->stmts[0]) != NULL);
|
||||
else
|
||||
return false;
|
||||
}
|
||||
@@ -949,7 +949,7 @@ struct VaryingBCCheckInfo {
|
||||
static bool
|
||||
lIsVaryingFor(ASTNode *node) {
|
||||
IfStmt *ifStmt;
|
||||
if ((ifStmt = dynamic_cast<IfStmt *>(node)) != NULL &&
|
||||
if ((ifStmt = llvm::dyn_cast<IfStmt>(node)) != NULL &&
|
||||
ifStmt->test != NULL) {
|
||||
const Type *type = ifStmt->test->GetType();
|
||||
return (type != NULL && type->IsVaryingType());
|
||||
@@ -967,8 +967,8 @@ lVaryingBCPreFunc(ASTNode *node, void *d) {
|
||||
|
||||
// We found a break or continue statement; if we're under varying
|
||||
// control flow, then bingo.
|
||||
if ((dynamic_cast<BreakStmt *>(node) != NULL ||
|
||||
dynamic_cast<ContinueStmt *>(node) != NULL) &&
|
||||
if ((llvm::dyn_cast<BreakStmt>(node) != NULL ||
|
||||
llvm::dyn_cast<ContinueStmt>(node) != NULL) &&
|
||||
info->varyingControlFlowDepth > 0) {
|
||||
info->foundVaryingBreakOrContinue = true;
|
||||
return false;
|
||||
@@ -979,9 +979,9 @@ lVaryingBCPreFunc(ASTNode *node, void *d) {
|
||||
if (lIsVaryingFor(node))
|
||||
++info->varyingControlFlowDepth;
|
||||
|
||||
if (dynamic_cast<ForStmt *>(node) != NULL ||
|
||||
dynamic_cast<DoStmt *>(node) != NULL ||
|
||||
dynamic_cast<ForeachStmt *>(node) != NULL)
|
||||
if (llvm::dyn_cast<ForStmt>(node) != NULL ||
|
||||
llvm::dyn_cast<DoStmt>(node) != NULL ||
|
||||
llvm::dyn_cast<ForeachStmt>(node) != NULL)
|
||||
// Don't recurse into these guys, since we don't care about varying
|
||||
// breaks or continues within them...
|
||||
return false;
|
||||
@@ -1017,7 +1017,7 @@ lHasVaryingBreakOrContinue(Stmt *stmt) {
|
||||
|
||||
|
||||
DoStmt::DoStmt(Expr *t, Stmt *s, bool cc, SourcePos p)
|
||||
: Stmt(p), testExpr(t), bodyStmts(s),
|
||||
: Stmt(p, DoStmtID), testExpr(t), bodyStmts(s),
|
||||
doCoherentCheck(cc && !g->opt.disableCoherentControlFlow) {
|
||||
}
|
||||
|
||||
@@ -1052,7 +1052,7 @@ void DoStmt::EmitCode(FunctionEmitContext *ctx) const {
|
||||
// scope around the statements in the list. So if the body is just a
|
||||
// single statement (and thus not a statement list), we need a new
|
||||
// scope, but we don't want two scopes in the StmtList case.
|
||||
if (!dynamic_cast<StmtList *>(bodyStmts))
|
||||
if (!llvm::dyn_cast<StmtList>(bodyStmts))
|
||||
ctx->StartScope();
|
||||
|
||||
ctx->AddInstrumentationPoint("do loop body");
|
||||
@@ -1094,7 +1094,7 @@ void DoStmt::EmitCode(FunctionEmitContext *ctx) const {
|
||||
ctx->BranchInst(btest);
|
||||
}
|
||||
// End the scope we started above, if needed.
|
||||
if (!dynamic_cast<StmtList *>(bodyStmts))
|
||||
if (!llvm::dyn_cast<StmtList>(bodyStmts))
|
||||
ctx->EndScope();
|
||||
|
||||
// Now emit code for the loop test.
|
||||
@@ -1193,7 +1193,7 @@ DoStmt::Print(int indent) const {
|
||||
// ForStmt
|
||||
|
||||
ForStmt::ForStmt(Stmt *i, Expr *t, Stmt *s, Stmt *st, bool cc, SourcePos p)
|
||||
: Stmt(p), init(i), test(t), step(s), stmts(st),
|
||||
: Stmt(p, ForStmtID), init(i), test(t), step(s), stmts(st),
|
||||
doCoherentCheck(cc && !g->opt.disableCoherentControlFlow) {
|
||||
}
|
||||
|
||||
@@ -1219,7 +1219,7 @@ ForStmt::EmitCode(FunctionEmitContext *ctx) const {
|
||||
// it and then jump into the loop test code. (Also start a new scope
|
||||
// since the initiailizer may be a declaration statement).
|
||||
if (init) {
|
||||
AssertPos(pos, dynamic_cast<StmtList *>(init) == NULL);
|
||||
AssertPos(pos, llvm::dyn_cast<StmtList>(init) == NULL);
|
||||
ctx->StartScope();
|
||||
init->EmitCode(ctx);
|
||||
}
|
||||
@@ -1261,7 +1261,7 @@ ForStmt::EmitCode(FunctionEmitContext *ctx) const {
|
||||
ctx->SetCurrentBasicBlock(bloop);
|
||||
ctx->SetBlockEntryMask(ctx->GetFullMask());
|
||||
ctx->AddInstrumentationPoint("for loop body");
|
||||
if (!dynamic_cast<StmtList *>(stmts))
|
||||
if (!llvm::dyn_cast<StmtList>(stmts))
|
||||
ctx->StartScope();
|
||||
|
||||
if (doCoherentCheck && !uniformTest) {
|
||||
@@ -1306,7 +1306,7 @@ ForStmt::EmitCode(FunctionEmitContext *ctx) const {
|
||||
if (ctx->GetCurrentBasicBlock())
|
||||
ctx->BranchInst(bstep);
|
||||
}
|
||||
if (!dynamic_cast<StmtList *>(stmts))
|
||||
if (!llvm::dyn_cast<StmtList>(stmts))
|
||||
ctx->EndScope();
|
||||
|
||||
// Emit code for the loop step. First, restore the lane mask of any
|
||||
@@ -1387,7 +1387,7 @@ ForStmt::Print(int indent) const {
|
||||
// BreakStmt
|
||||
|
||||
BreakStmt::BreakStmt(SourcePos p)
|
||||
: Stmt(p) {
|
||||
: Stmt(p, BreakStmtID) {
|
||||
}
|
||||
|
||||
|
||||
@@ -1425,7 +1425,7 @@ BreakStmt::Print(int indent) const {
|
||||
// ContinueStmt
|
||||
|
||||
ContinueStmt::ContinueStmt(SourcePos p)
|
||||
: Stmt(p) {
|
||||
: Stmt(p, ContinueStmtID) {
|
||||
}
|
||||
|
||||
|
||||
@@ -1466,7 +1466,7 @@ ForeachStmt::ForeachStmt(const std::vector<Symbol *> &lvs,
|
||||
const std::vector<Expr *> &se,
|
||||
const std::vector<Expr *> &ee,
|
||||
Stmt *s, bool t, SourcePos pos)
|
||||
: Stmt(pos), dimVariables(lvs), startExprs(se), endExprs(ee), isTiled(t),
|
||||
: Stmt(pos, ForeachStmtID), dimVariables(lvs), startExprs(se), endExprs(ee), isTiled(t),
|
||||
stmts(s) {
|
||||
}
|
||||
|
||||
@@ -2223,7 +2223,7 @@ ForeachStmt::Print(int indent) const {
|
||||
// ForeachActiveStmt
|
||||
|
||||
ForeachActiveStmt::ForeachActiveStmt(Symbol *s, Stmt *st, SourcePos pos)
|
||||
: Stmt(pos) {
|
||||
: Stmt(pos, ForeachActiveStmtID) {
|
||||
sym = s;
|
||||
stmts = st;
|
||||
}
|
||||
@@ -2410,7 +2410,7 @@ ForeachActiveStmt::EstimateCost() const {
|
||||
|
||||
ForeachUniqueStmt::ForeachUniqueStmt(const char *iterName, Expr *e,
|
||||
Stmt *s, SourcePos pos)
|
||||
: Stmt(pos) {
|
||||
: Stmt(pos, ForeachUniqueStmtID) {
|
||||
sym = m->symbolTable->LookupVariable(iterName);
|
||||
expr = e;
|
||||
stmts = s;
|
||||
@@ -2678,7 +2678,7 @@ lCheckMask(Stmt *stmts) {
|
||||
|
||||
|
||||
CaseStmt::CaseStmt(int v, Stmt *s, SourcePos pos)
|
||||
: Stmt(pos), value(v) {
|
||||
: Stmt(pos, CaseStmtID), value(v) {
|
||||
stmts = s;
|
||||
}
|
||||
|
||||
@@ -2716,7 +2716,7 @@ CaseStmt::EstimateCost() const {
|
||||
// DefaultStmt
|
||||
|
||||
DefaultStmt::DefaultStmt(Stmt *s, SourcePos pos)
|
||||
: Stmt(pos) {
|
||||
: Stmt(pos, DefaultStmtID) {
|
||||
stmts = s;
|
||||
}
|
||||
|
||||
@@ -2754,7 +2754,7 @@ DefaultStmt::EstimateCost() const {
|
||||
// SwitchStmt
|
||||
|
||||
SwitchStmt::SwitchStmt(Expr *e, Stmt *s, SourcePos pos)
|
||||
: Stmt(pos) {
|
||||
: Stmt(pos, SwitchStmtID) {
|
||||
expr = e;
|
||||
stmts = s;
|
||||
}
|
||||
@@ -2794,13 +2794,13 @@ struct SwitchVisitInfo {
|
||||
|
||||
static bool
|
||||
lSwitchASTPreVisit(ASTNode *node, void *d) {
|
||||
if (dynamic_cast<SwitchStmt *>(node) != NULL)
|
||||
if (llvm::dyn_cast<SwitchStmt>(node) != NULL)
|
||||
// don't continue recursively into a nested switch--we only want
|
||||
// our own case and default statements!
|
||||
return false;
|
||||
|
||||
CaseStmt *cs = dynamic_cast<CaseStmt *>(node);
|
||||
DefaultStmt *ds = dynamic_cast<DefaultStmt *>(node);
|
||||
CaseStmt *cs = llvm::dyn_cast<CaseStmt>(node);
|
||||
DefaultStmt *ds = llvm::dyn_cast<DefaultStmt>(node);
|
||||
|
||||
SwitchVisitInfo *svi = (SwitchVisitInfo *)d;
|
||||
llvm::BasicBlock *bb = NULL;
|
||||
@@ -2954,7 +2954,7 @@ SwitchStmt::EstimateCost() const {
|
||||
// UnmaskedStmt
|
||||
|
||||
UnmaskedStmt::UnmaskedStmt(Stmt *s, SourcePos pos)
|
||||
: Stmt(pos) {
|
||||
: Stmt(pos, UnmaskedStmtID) {
|
||||
stmts = s;
|
||||
}
|
||||
|
||||
@@ -3008,7 +3008,7 @@ UnmaskedStmt::EstimateCost() const {
|
||||
// ReturnStmt
|
||||
|
||||
ReturnStmt::ReturnStmt(Expr *e, SourcePos p)
|
||||
: Stmt(p), expr(e) {
|
||||
: Stmt(p, ReturnStmtID), expr(e) {
|
||||
}
|
||||
|
||||
|
||||
@@ -3075,7 +3075,7 @@ ReturnStmt::Print(int indent) const {
|
||||
// GotoStmt
|
||||
|
||||
GotoStmt::GotoStmt(const char *l, SourcePos gotoPos, SourcePos ip)
|
||||
: Stmt(gotoPos) {
|
||||
: Stmt(gotoPos, GotoStmtID) {
|
||||
label = l;
|
||||
identifierPos = ip;
|
||||
}
|
||||
@@ -3151,7 +3151,7 @@ GotoStmt::EstimateCost() const {
|
||||
// LabeledStmt
|
||||
|
||||
LabeledStmt::LabeledStmt(const char *n, Stmt *s, SourcePos p)
|
||||
: Stmt(p) {
|
||||
: Stmt(p, LabeledStmtID) {
|
||||
name = n;
|
||||
stmt = s;
|
||||
}
|
||||
@@ -3253,7 +3253,7 @@ StmtList::Print(int indent) const {
|
||||
// PrintStmt
|
||||
|
||||
PrintStmt::PrintStmt(const std::string &f, Expr *v, SourcePos p)
|
||||
: Stmt(p), format(f), values(v) {
|
||||
: Stmt(p, PrintStmtID), format(f), values(v) {
|
||||
}
|
||||
|
||||
/* Because the pointers to values that are passed to __do_print() are all
|
||||
@@ -3383,7 +3383,7 @@ PrintStmt::EmitCode(FunctionEmitContext *ctx) const {
|
||||
// Get the values passed to the print() statement evaluated and
|
||||
// stored in memory so that we set up the array of pointers to them
|
||||
// for the 5th __do_print() argument
|
||||
ExprList *elist = dynamic_cast<ExprList *>(values);
|
||||
ExprList *elist = llvm::dyn_cast<ExprList>(values);
|
||||
int nArgs = elist ? elist->exprs.size() : 1;
|
||||
|
||||
// Allocate space for the array of pointers to values to be printed
|
||||
@@ -3463,7 +3463,7 @@ PrintStmt::EstimateCost() const {
|
||||
// AssertStmt
|
||||
|
||||
AssertStmt::AssertStmt(const std::string &msg, Expr *e, SourcePos p)
|
||||
: Stmt(p), message(msg), expr(e) {
|
||||
: Stmt(p, AssertStmtID), message(msg), expr(e) {
|
||||
}
|
||||
|
||||
|
||||
@@ -3542,7 +3542,7 @@ AssertStmt::EstimateCost() const {
|
||||
// DeleteStmt
|
||||
|
||||
DeleteStmt::DeleteStmt(Expr *e, SourcePos p)
|
||||
: Stmt(p) {
|
||||
: Stmt(p, DeleteStmtID) {
|
||||
expr = e;
|
||||
}
|
||||
|
||||
|
||||
114
stmt.h
114
stmt.h
@@ -48,7 +48,12 @@
|
||||
*/
|
||||
class Stmt : public ASTNode {
|
||||
public:
|
||||
Stmt(SourcePos p) : ASTNode(p) { }
|
||||
Stmt(SourcePos p, unsigned scid) : ASTNode(p, scid) { }
|
||||
|
||||
static inline bool classof(Stmt const*) { return true; }
|
||||
static inline bool classof(ASTNode const* N) {
|
||||
return N->getValueID() > MaxExprID;
|
||||
}
|
||||
|
||||
/** Emit LLVM IR for the statement, using the FunctionEmitContext to create the
|
||||
necessary instructions.
|
||||
@@ -73,6 +78,11 @@ class ExprStmt : public Stmt {
|
||||
public:
|
||||
ExprStmt(Expr *expr, SourcePos pos);
|
||||
|
||||
static inline bool classof(ExprStmt const*) { return true; }
|
||||
static inline bool classof(ASTNode const* N) {
|
||||
return N->getValueID() == ExprStmtID;
|
||||
}
|
||||
|
||||
void EmitCode(FunctionEmitContext *ctx) const;
|
||||
void Print(int indent) const;
|
||||
|
||||
@@ -97,6 +107,11 @@ class DeclStmt : public Stmt {
|
||||
public:
|
||||
DeclStmt(const std::vector<VariableDeclaration> &v, SourcePos pos);
|
||||
|
||||
static inline bool classof(DeclStmt const*) { return true; }
|
||||
static inline bool classof(ASTNode const* N) {
|
||||
return N->getValueID() == DeclStmtID;
|
||||
}
|
||||
|
||||
void EmitCode(FunctionEmitContext *ctx) const;
|
||||
void Print(int indent) const;
|
||||
|
||||
@@ -115,6 +130,11 @@ public:
|
||||
IfStmt(Expr *testExpr, Stmt *trueStmts, Stmt *falseStmts,
|
||||
bool doAllCheck, SourcePos pos);
|
||||
|
||||
static inline bool classof(IfStmt const*) { return true; }
|
||||
static inline bool classof(ASTNode const* N) {
|
||||
return N->getValueID() == IfStmtID;
|
||||
}
|
||||
|
||||
void EmitCode(FunctionEmitContext *ctx) const;
|
||||
void Print(int indent) const;
|
||||
|
||||
@@ -155,6 +175,11 @@ public:
|
||||
DoStmt(Expr *testExpr, Stmt *bodyStmts, bool doCoherentCheck,
|
||||
SourcePos pos);
|
||||
|
||||
static inline bool classof(DoStmt const*) { return true; }
|
||||
static inline bool classof(ASTNode const* N) {
|
||||
return N->getValueID() == DoStmtID;
|
||||
}
|
||||
|
||||
void EmitCode(FunctionEmitContext *ctx) const;
|
||||
void Print(int indent) const;
|
||||
|
||||
@@ -175,6 +200,11 @@ public:
|
||||
ForStmt(Stmt *initializer, Expr *testExpr, Stmt *stepStatements,
|
||||
Stmt *bodyStatements, bool doCoherentCheck, SourcePos pos);
|
||||
|
||||
static inline bool classof(ForStmt const*) { return true; }
|
||||
static inline bool classof(ASTNode const* N) {
|
||||
return N->getValueID() == ForStmtID;
|
||||
}
|
||||
|
||||
void EmitCode(FunctionEmitContext *ctx) const;
|
||||
void Print(int indent) const;
|
||||
|
||||
@@ -201,6 +231,11 @@ class BreakStmt : public Stmt {
|
||||
public:
|
||||
BreakStmt(SourcePos pos);
|
||||
|
||||
static inline bool classof(BreakStmt const*) { return true; }
|
||||
static inline bool classof(ASTNode const* N) {
|
||||
return N->getValueID() == BreakStmtID;
|
||||
}
|
||||
|
||||
void EmitCode(FunctionEmitContext *ctx) const;
|
||||
void Print(int indent) const;
|
||||
|
||||
@@ -215,6 +250,11 @@ class ContinueStmt : public Stmt {
|
||||
public:
|
||||
ContinueStmt(SourcePos pos);
|
||||
|
||||
static inline bool classof(ContinueStmt const*) { return true; }
|
||||
static inline bool classof(ASTNode const* N) {
|
||||
return N->getValueID() == ContinueStmtID;
|
||||
}
|
||||
|
||||
void EmitCode(FunctionEmitContext *ctx) const;
|
||||
void Print(int indent) const;
|
||||
|
||||
@@ -232,6 +272,11 @@ public:
|
||||
const std::vector<Expr *> &endExprs,
|
||||
Stmt *bodyStatements, bool tiled, SourcePos pos);
|
||||
|
||||
static inline bool classof(ForeachStmt const*) { return true; }
|
||||
static inline bool classof(ASTNode const* N) {
|
||||
return N->getValueID() == ForeachStmtID;
|
||||
}
|
||||
|
||||
void EmitCode(FunctionEmitContext *ctx) const;
|
||||
void Print(int indent) const;
|
||||
|
||||
@@ -252,6 +297,11 @@ class ForeachActiveStmt : public Stmt {
|
||||
public:
|
||||
ForeachActiveStmt(Symbol *iterSym, Stmt *stmts, SourcePos pos);
|
||||
|
||||
static inline bool classof(ForeachActiveStmt const*) { return true; }
|
||||
static inline bool classof(ASTNode const* N) {
|
||||
return N->getValueID() == ForeachActiveStmtID;
|
||||
}
|
||||
|
||||
void EmitCode(FunctionEmitContext *ctx) const;
|
||||
void Print(int indent) const;
|
||||
|
||||
@@ -271,6 +321,11 @@ public:
|
||||
ForeachUniqueStmt(const char *iterName, Expr *expr, Stmt *stmts,
|
||||
SourcePos pos);
|
||||
|
||||
static inline bool classof(ForeachUniqueStmt const*) { return true; }
|
||||
static inline bool classof(ASTNode const* N) {
|
||||
return N->getValueID() == ForeachUniqueStmtID;
|
||||
}
|
||||
|
||||
void EmitCode(FunctionEmitContext *ctx) const;
|
||||
void Print(int indent) const;
|
||||
|
||||
@@ -289,6 +344,11 @@ class UnmaskedStmt : public Stmt {
|
||||
public:
|
||||
UnmaskedStmt(Stmt *stmt, SourcePos pos);
|
||||
|
||||
static inline bool classof(UnmaskedStmt const*) { return true; }
|
||||
static inline bool classof(ASTNode const* N) {
|
||||
return N->getValueID() == UnmaskedStmtID;
|
||||
}
|
||||
|
||||
void EmitCode(FunctionEmitContext *ctx) const;
|
||||
void Print(int indent) const;
|
||||
|
||||
@@ -306,6 +366,11 @@ class ReturnStmt : public Stmt {
|
||||
public:
|
||||
ReturnStmt(Expr *e, SourcePos p);
|
||||
|
||||
static inline bool classof(ReturnStmt const*) { return true; }
|
||||
static inline bool classof(ASTNode const* N) {
|
||||
return N->getValueID() == ReturnStmtID;
|
||||
}
|
||||
|
||||
void EmitCode(FunctionEmitContext *ctx) const;
|
||||
void Print(int indent) const;
|
||||
|
||||
@@ -323,6 +388,11 @@ class CaseStmt : public Stmt {
|
||||
public:
|
||||
CaseStmt(int value, Stmt *stmt, SourcePos pos);
|
||||
|
||||
static inline bool classof(CaseStmt const*) { return true; }
|
||||
static inline bool classof(ASTNode const* N) {
|
||||
return N->getValueID() == CaseStmtID;
|
||||
}
|
||||
|
||||
void EmitCode(FunctionEmitContext *ctx) const;
|
||||
void Print(int indent) const;
|
||||
|
||||
@@ -341,6 +411,11 @@ class DefaultStmt : public Stmt {
|
||||
public:
|
||||
DefaultStmt(Stmt *stmt, SourcePos pos);
|
||||
|
||||
static inline bool classof(DefaultStmt const*) { return true; }
|
||||
static inline bool classof(ASTNode const* N) {
|
||||
return N->getValueID() == DefaultStmtID;
|
||||
}
|
||||
|
||||
void EmitCode(FunctionEmitContext *ctx) const;
|
||||
void Print(int indent) const;
|
||||
|
||||
@@ -356,6 +431,11 @@ class SwitchStmt : public Stmt {
|
||||
public:
|
||||
SwitchStmt(Expr *expr, Stmt *stmts, SourcePos pos);
|
||||
|
||||
static inline bool classof(SwitchStmt const*) { return true; }
|
||||
static inline bool classof(ASTNode const* N) {
|
||||
return N->getValueID() == SwitchStmtID;
|
||||
}
|
||||
|
||||
void EmitCode(FunctionEmitContext *ctx) const;
|
||||
void Print(int indent) const;
|
||||
|
||||
@@ -374,6 +454,11 @@ class GotoStmt : public Stmt {
|
||||
public:
|
||||
GotoStmt(const char *label, SourcePos gotoPos, SourcePos idPos);
|
||||
|
||||
static inline bool classof(GotoStmt const*) { return true; }
|
||||
static inline bool classof(ASTNode const* N) {
|
||||
return N->getValueID() == GotoStmtID;
|
||||
}
|
||||
|
||||
void EmitCode(FunctionEmitContext *ctx) const;
|
||||
void Print(int indent) const;
|
||||
|
||||
@@ -393,6 +478,11 @@ class LabeledStmt : public Stmt {
|
||||
public:
|
||||
LabeledStmt(const char *label, Stmt *stmt, SourcePos p);
|
||||
|
||||
static inline bool classof(LabeledStmt const*) { return true; }
|
||||
static inline bool classof(ASTNode const* N) {
|
||||
return N->getValueID() == LabeledStmtID;
|
||||
}
|
||||
|
||||
void EmitCode(FunctionEmitContext *ctx) const;
|
||||
void Print(int indent) const;
|
||||
|
||||
@@ -411,7 +501,12 @@ public:
|
||||
*/
|
||||
class StmtList : public Stmt {
|
||||
public:
|
||||
StmtList(SourcePos p) : Stmt(p) { }
|
||||
StmtList(SourcePos p) : Stmt(p, StmtListID) { }
|
||||
|
||||
static inline bool classof(StmtList const*) { return true; }
|
||||
static inline bool classof(ASTNode const* N) {
|
||||
return N->getValueID() == StmtListID;
|
||||
}
|
||||
|
||||
void EmitCode(FunctionEmitContext *ctx) const;
|
||||
void Print(int indent) const;
|
||||
@@ -438,6 +533,11 @@ class PrintStmt : public Stmt {
|
||||
public:
|
||||
PrintStmt(const std::string &f, Expr *v, SourcePos p);
|
||||
|
||||
static inline bool classof(PrintStmt const*) { return true; }
|
||||
static inline bool classof(ASTNode const* N) {
|
||||
return N->getValueID() == PrintStmtID;
|
||||
}
|
||||
|
||||
void EmitCode(FunctionEmitContext *ctx) const;
|
||||
void Print(int indent) const;
|
||||
|
||||
@@ -464,6 +564,11 @@ class AssertStmt : public Stmt {
|
||||
public:
|
||||
AssertStmt(const std::string &msg, Expr *e, SourcePos p);
|
||||
|
||||
static inline bool classof(AssertStmt const*) { return true; }
|
||||
static inline bool classof(ASTNode const* N) {
|
||||
return N->getValueID() == AssertStmtID;
|
||||
}
|
||||
|
||||
void EmitCode(FunctionEmitContext *ctx) const;
|
||||
void Print(int indent) const;
|
||||
|
||||
@@ -483,6 +588,11 @@ class DeleteStmt : public Stmt {
|
||||
public:
|
||||
DeleteStmt(Expr *e, SourcePos p);
|
||||
|
||||
static inline bool classof(DeleteStmt const*) { return true; }
|
||||
static inline bool classof(ASTNode const* N) {
|
||||
return N->getValueID() == DeleteStmtID;
|
||||
}
|
||||
|
||||
void EmitCode(FunctionEmitContext *ctx) const;
|
||||
void Print(int indent) const;
|
||||
|
||||
|
||||
6
type.cpp
6
type.cpp
@@ -1603,7 +1603,7 @@ ArrayType::SizeUnsizedArrays(const Type *type, Expr *initExpr) {
|
||||
if (at == NULL)
|
||||
return type;
|
||||
|
||||
ExprList *exprList = dynamic_cast<ExprList *>(initExpr);
|
||||
ExprList *exprList = llvm::dyn_cast_or_null<ExprList>(initExpr);
|
||||
if (exprList == NULL || exprList->exprs.size() == 0)
|
||||
return type;
|
||||
|
||||
@@ -1618,7 +1618,7 @@ ArrayType::SizeUnsizedArrays(const Type *type, Expr *initExpr) {
|
||||
// now. Otherwise we'll use the first one to size the next dimension
|
||||
// (after checking below that it has the same length as all of the
|
||||
// other ones.
|
||||
ExprList *nextList = dynamic_cast<ExprList *>(exprList->exprs[0]);
|
||||
ExprList *nextList = llvm::dyn_cast_or_null<ExprList>(exprList->exprs[0]);
|
||||
if (nextList == NULL)
|
||||
return type;
|
||||
|
||||
@@ -1638,7 +1638,7 @@ ArrayType::SizeUnsizedArrays(const Type *type, Expr *initExpr) {
|
||||
continue;
|
||||
}
|
||||
|
||||
ExprList *el = dynamic_cast<ExprList *>(exprList->exprs[i]);
|
||||
ExprList *el = llvm::dyn_cast_or_null<ExprList>(exprList->exprs[i]);
|
||||
if (el == NULL || el->exprs.size() != nextSize) {
|
||||
Error(Union(exprList->exprs[0]->pos, exprList->exprs[i]->pos),
|
||||
"Inconsistent initializer expression list lengths "
|
||||
|
||||
Reference in New Issue
Block a user