Intel SPMD Program Compiler  1.9.1
stmt.h
Go to the documentation of this file.
1 /*
2  Copyright (c) 2010-2013, Intel Corporation
3  All rights reserved.
4 
5  Redistribution and use in source and binary forms, with or without
6  modification, are permitted provided that the following conditions are
7  met:
8 
9  * Redistributions of source code must retain the above copyright
10  notice, this list of conditions and the following disclaimer.
11 
12  * Redistributions in binary form must reproduce the above copyright
13  notice, this list of conditions and the following disclaimer in the
14  documentation and/or other materials provided with the distribution.
15 
16  * Neither the name of Intel Corporation nor the names of its
17  contributors may be used to endorse or promote products derived from
18  this software without specific prior written permission.
19 
20 
21  THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS "AS
22  IS" AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED
23  TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A
24  PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT OWNER
25  OR CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL,
26  EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO,
27  PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR
28  PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF
29  LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING
30  NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF THIS
31  SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
32 */
33 
34 /** @file stmt.h
35  @brief File with declarations for classes related to statements in the language
36 */
37 
38 #ifndef ISPC_STMT_H
39 #define ISPC_STMT_H 1
40 
41 #include "ispc.h"
42 #include "ast.h"
43 
44 /** @brief Interface class for statements in the ispc language.
45 
46  This abstract base-class encapsulates methods that AST nodes for
47  statements in the language must implement.
48  */
49 class Stmt : public ASTNode {
50 public:
51  Stmt(SourcePos p, unsigned scid) : ASTNode(p, scid) { }
52 
53  static inline bool classof(Stmt const*) { return true; }
54  static inline bool classof(ASTNode const* N) {
55  return N->getValueID() > MaxExprID;
56  }
57 
58  /** Emit LLVM IR for the statement, using the FunctionEmitContext to create the
59  necessary instructions.
60  */
61  virtual void EmitCode(FunctionEmitContext *ctx) const = 0;
62 
63  /** Print a representation of the statement (and any children AST
64  nodes) to standard output. This method is used for debuggins. */
65  virtual void Print(int indent) const = 0;
66 
67  // Redeclare these methods with Stmt * return values, rather than
68  // ASTNode *s, as in the original ASTNode declarations of them. We'll
69  // also provide a default implementation of Optimize(), since most
70  // Stmts don't have anything to do here.
71  virtual Stmt *Optimize();
72  virtual Stmt *TypeCheck() = 0;
73 };
74 
75 
76 /** @brief Statement representing a single expression */
77 class ExprStmt : public Stmt {
78 public:
80 
81  static inline bool classof(ExprStmt const*) { return true; }
82  static inline bool classof(ASTNode const* N) {
83  return N->getValueID() == ExprStmtID;
84  }
85 
86  void EmitCode(FunctionEmitContext *ctx) const;
87  void Print(int indent) const;
88 
89  Stmt *TypeCheck();
90  int EstimateCost() const;
91 
93 };
94 
95 
97  VariableDeclaration(Symbol *s = NULL, Expr *i = NULL) {
98  sym = s; init = i;
99  }
102 };
103 
104 /** @brief Statement representing a single declaration (which in turn may declare
105  a number of variables. */
106 class DeclStmt : public Stmt {
107 public:
108  DeclStmt(const std::vector<VariableDeclaration> &v, SourcePos pos);
109 
110  static inline bool classof(DeclStmt const*) { return true; }
111  static inline bool classof(ASTNode const* N) {
112  return N->getValueID() == DeclStmtID;
113  }
114 
115  void EmitCode(FunctionEmitContext *ctx) const;
116  void Print(int indent) const;
117 
118  Stmt *Optimize();
119  Stmt *TypeCheck();
120  int EstimateCost() const;
121 
122  std::vector<VariableDeclaration> vars;
123 };
124 
125 
126 /** @brief Statement representing a single if statement, possibly with an
127  else clause. */
128 class IfStmt : public Stmt {
129 public:
130  IfStmt(Expr *testExpr, Stmt *trueStmts, Stmt *falseStmts,
131  bool doAllCheck, SourcePos pos);
132 
133  static inline bool classof(IfStmt const*) { return true; }
134  static inline bool classof(ASTNode const* N) {
135  return N->getValueID() == IfStmtID;
136  }
137 
138  void EmitCode(FunctionEmitContext *ctx) const;
139  void Print(int indent) const;
140 
141  Stmt *TypeCheck();
142  int EstimateCost() const;
143 
144  // @todo these are only public for lHasVaryingBreakOrContinue(); would
145  // be nice to clean that up...
146  /** Expression giving the 'if' test. */
148  /** Statements to run if the 'if' test returns a true value */
150  /** Statements to run if the 'if' test returns a false value */
152 
153 private:
154  /** This value records if this was a 'coherent' if statement in the
155  source and thus, if the emitted code should check to see if all
156  active program instances want to follow just one of the 'true' or
157  'false' blocks. */
158  const bool doAllCheck;
159 
160  void emitMaskedTrueAndFalse(FunctionEmitContext *ctx, llvm::Value *oldMask,
161  llvm::Value *test) const;
162  void emitVaryingIf(FunctionEmitContext *ctx, llvm::Value *test) const;
164  llvm::Value *test, llvm::BasicBlock *bDone) const;
165  void emitMaskMixed(FunctionEmitContext *ctx, llvm::Value *oldMask,
166  llvm::Value *test, llvm::BasicBlock *bDone) const;
167 };
168 
169 
170 /** @brief Statement implementation representing a 'do' statement in the
171  program.
172  */
173 class DoStmt : public Stmt {
174 public:
176  SourcePos pos);
177 
178  static inline bool classof(DoStmt const*) { return true; }
179  static inline bool classof(ASTNode const* N) {
180  return N->getValueID() == DoStmtID;
181  }
182 
183  void EmitCode(FunctionEmitContext *ctx) const;
184  void Print(int indent) const;
185 
186  Stmt *TypeCheck();
187  int EstimateCost() const;
188 
191  const bool doCoherentCheck;
192 };
193 
194 
195 /** @brief Statement implementation for 'for' loops (as well as for 'while'
196  loops).
197  */
198 class ForStmt : public Stmt {
199 public:
200  ForStmt(Stmt *initializer, Expr *testExpr, Stmt *stepStatements,
201  Stmt *bodyStatements, bool doCoherentCheck, SourcePos pos);
202 
203  static inline bool classof(ForStmt const*) { return true; }
204  static inline bool classof(ASTNode const* N) {
205  return N->getValueID() == ForStmtID;
206  }
207 
208  void EmitCode(FunctionEmitContext *ctx) const;
209  void Print(int indent) const;
210 
211  Stmt *TypeCheck();
212  int EstimateCost() const;
213 
214  /** 'for' statment initializer; may be NULL, indicating no intitializer */
216  /** expression that returns a value indicating whether the loop should
217  continue for the next iteration */
219  /** Statements to run at the end of the loop for the loop step, before
220  the test expression is evaluated. */
222  /** Loop body statements */
224  const bool doCoherentCheck;
225 };
226 
227 
228 /** @brief Statement implementation for a break statement in the
229  program. */
230 class BreakStmt : public Stmt {
231 public:
233 
234  static inline bool classof(BreakStmt const*) { return true; }
235  static inline bool classof(ASTNode const* N) {
236  return N->getValueID() == BreakStmtID;
237  }
238 
239  void EmitCode(FunctionEmitContext *ctx) const;
240  void Print(int indent) const;
241 
242  Stmt *TypeCheck();
243  int EstimateCost() const;
244 };
245 
246 
247 /** @brief Statement implementation for a continue statement in the
248  program. */
249 class ContinueStmt : public Stmt {
250 public:
252 
253  static inline bool classof(ContinueStmt const*) { return true; }
254  static inline bool classof(ASTNode const* N) {
255  return N->getValueID() == ContinueStmtID;
256  }
257 
258  void EmitCode(FunctionEmitContext *ctx) const;
259  void Print(int indent) const;
260 
261  Stmt *TypeCheck();
262  int EstimateCost() const;
263 };
264 
265 
266 /** @brief Statement implementation for parallel 'foreach' loops.
267  */
268 class ForeachStmt : public Stmt {
269 public:
270  ForeachStmt(const std::vector<Symbol *> &loopVars,
271  const std::vector<Expr *> &startExprs,
272  const std::vector<Expr *> &endExprs,
273  Stmt *bodyStatements, bool tiled, SourcePos pos);
274 
275  static inline bool classof(ForeachStmt const*) { return true; }
276  static inline bool classof(ASTNode const* N) {
277  return N->getValueID() == ForeachStmtID;
278  }
279 
280  void EmitCode(FunctionEmitContext *ctx) const;
281  void Print(int indent) const;
282 
283  Stmt *TypeCheck();
284  int EstimateCost() const;
285 
286  std::vector<Symbol *> dimVariables;
287  std::vector<Expr *> startExprs;
288  std::vector<Expr *> endExprs;
289  bool isTiled;
291 };
292 
293 
294 /** Iteration over each executing program instance.
295  */
296 class ForeachActiveStmt : public Stmt {
297 public:
299 
300  static inline bool classof(ForeachActiveStmt const*) { return true; }
301  static inline bool classof(ASTNode const* N) {
302  return N->getValueID() == ForeachActiveStmtID;
303  }
304 
305  void EmitCode(FunctionEmitContext *ctx) const;
306  void Print(int indent) const;
307 
308  Stmt *TypeCheck();
309  int EstimateCost() const;
310 
313 };
314 
315 
316 /** Parallel iteration over each unique value in the given (varying)
317  expression.
318  */
319 class ForeachUniqueStmt : public Stmt {
320 public:
321  ForeachUniqueStmt(const char *iterName, Expr *expr, Stmt *stmts,
322  SourcePos pos);
323 
324  static inline bool classof(ForeachUniqueStmt const*) { return true; }
325  static inline bool classof(ASTNode const* N) {
326  return N->getValueID() == ForeachUniqueStmtID;
327  }
328 
329  void EmitCode(FunctionEmitContext *ctx) const;
330  void Print(int indent) const;
331 
332  Stmt *TypeCheck();
333  int EstimateCost() const;
334 
338 };
339 
340 
341 /**
342  */
343 class UnmaskedStmt : public Stmt {
344 public:
345  UnmaskedStmt(Stmt *stmt, SourcePos pos);
346 
347  static inline bool classof(UnmaskedStmt const*) { return true; }
348  static inline bool classof(ASTNode const* N) {
349  return N->getValueID() == UnmaskedStmtID;
350  }
351 
352  void EmitCode(FunctionEmitContext *ctx) const;
353  void Print(int indent) const;
354 
355  Stmt *TypeCheck();
356  int EstimateCost() const;
357 
359 };
360 
361 
362 
363 /** @brief Statement implementation for a 'return' statement in the
364  program. */
365 class ReturnStmt : public Stmt {
366 public:
367  ReturnStmt(Expr *e, SourcePos p);
368 
369  static inline bool classof(ReturnStmt const*) { return true; }
370  static inline bool classof(ASTNode const* N) {
371  return N->getValueID() == ReturnStmtID;
372  }
373 
374  void EmitCode(FunctionEmitContext *ctx) const;
375  void Print(int indent) const;
376 
377  Stmt *TypeCheck();
378  int EstimateCost() const;
379 
381 };
382 
383 
384 /** Statement corresponding to a "case" label in the program. In addition
385  to the value associated with the "case", this statement also stores the
386  statements following it. */
387 class CaseStmt : public Stmt {
388 public:
389  CaseStmt(int value, Stmt *stmt, SourcePos pos);
390 
391  static inline bool classof(CaseStmt const*) { return true; }
392  static inline bool classof(ASTNode const* N) {
393  return N->getValueID() == CaseStmtID;
394  }
395 
396  void EmitCode(FunctionEmitContext *ctx) const;
397  void Print(int indent) const;
398 
399  Stmt *TypeCheck();
400  int EstimateCost() const;
401 
402  /** Integer value after the "case" statement */
403  const int value;
405 };
406 
407 
408 /** Statement for a "default" label (as would be found inside a "switch"
409  statement). */
410 class DefaultStmt : public Stmt {
411 public:
412  DefaultStmt(Stmt *stmt, SourcePos pos);
413 
414  static inline bool classof(DefaultStmt const*) { return true; }
415  static inline bool classof(ASTNode const* N) {
416  return N->getValueID() == DefaultStmtID;
417  }
418 
419  void EmitCode(FunctionEmitContext *ctx) const;
420  void Print(int indent) const;
421 
422  Stmt *TypeCheck();
423  int EstimateCost() const;
424 
426 };
427 
428 
429 /** A "switch" statement in the program. */
430 class SwitchStmt : public Stmt {
431 public:
433 
434  static inline bool classof(SwitchStmt const*) { return true; }
435  static inline bool classof(ASTNode const* N) {
436  return N->getValueID() == SwitchStmtID;
437  }
438 
439  void EmitCode(FunctionEmitContext *ctx) const;
440  void Print(int indent) const;
441 
442  Stmt *TypeCheck();
443  int EstimateCost() const;
444 
445  /** Expression that is used to determine which label to jump to. */
447  /** Statement block after the "switch" expression. */
449 };
450 
451 
452 /** A "goto" in an ispc program. */
453 class GotoStmt : public Stmt {
454 public:
455  GotoStmt(const char *label, SourcePos gotoPos, SourcePos idPos);
456 
457  static inline bool classof(GotoStmt const*) { return true; }
458  static inline bool classof(ASTNode const* N) {
459  return N->getValueID() == GotoStmtID;
460  }
461 
462  void EmitCode(FunctionEmitContext *ctx) const;
463  void Print(int indent) const;
464 
465  Stmt *Optimize();
466  Stmt *TypeCheck();
467  int EstimateCost() const;
468 
469  /** Name of the label to jump to when the goto is executed. */
470  std::string label;
472 };
473 
474 
475 /** Statement corresponding to a label (as would be used as a goto target)
476  in the program. */
477 class LabeledStmt : public Stmt {
478 public:
479  LabeledStmt(const char *label, Stmt *stmt, SourcePos p);
480 
481  static inline bool classof(LabeledStmt const*) { return true; }
482  static inline bool classof(ASTNode const* N) {
483  return N->getValueID() == LabeledStmtID;
484  }
485 
486  void EmitCode(FunctionEmitContext *ctx) const;
487  void Print(int indent) const;
488 
489  Stmt *Optimize();
490  Stmt *TypeCheck();
491  int EstimateCost() const;
492 
493  /** Name of the label. */
494  std::string name;
495  /** Statements following the label. */
497 };
498 
499 
500 /** @brief Representation of a list of statements in the program.
501  */
502 class StmtList : public Stmt {
503 public:
505 
506  static inline bool classof(StmtList const*) { return true; }
507  static inline bool classof(ASTNode const* N) {
508  return N->getValueID() == StmtListID;
509  }
510 
511  void EmitCode(FunctionEmitContext *ctx) const;
512  void Print(int indent) const;
513 
514  Stmt *TypeCheck();
515  int EstimateCost() const;
516 
517  void Add(Stmt *s) { if (s) stmts.push_back(s); }
518 
519  std::vector<Stmt *> stmts;
520 };
521 
522 
523 /** @brief Representation of a print() statement in the program.
524 
525  It's currently necessary to have a special statement type for print()
526  since strings aren't supported as first-class types in the language,
527  but we need to be able to pass a formatting string as the first
528  argument to print(). We also need this to be a variable argument
529  function, which also isn't supported. Representing print() as a
530  statement lets us work around both of those ugly little issues...
531  */
532 class PrintStmt : public Stmt {
533 public:
534  PrintStmt(const std::string &f, Expr *v, SourcePos p);
535 
536  static inline bool classof(PrintStmt const*) { return true; }
537  static inline bool classof(ASTNode const* N) {
538  return N->getValueID() == PrintStmtID;
539  }
540 
541  void EmitCode(FunctionEmitContext *ctx) const;
542  void Print(int indent) const;
543 
544  Stmt *TypeCheck();
545  int EstimateCost() const;
546 
547  /** Format string for the print() statement. */
548  const std::string format;
549  /** This holds the arguments passed to the print() statement. If more
550  than one was provided, this will be an ExprList. */
552 };
553 
554 
555 /** @brief Representation of an assert statement in the program.
556 
557  Like print() above, since we don't have strings as first-class types in
558  the language, we need to do some gymnastics to support it. Like
559  assert() in C, assert() checks the given condition and prints an error
560  and calls abort if the condition fails. For varying conditions, the
561  assert triggers if it's true for any of the program instances.
562 */
563 class AssertStmt : public Stmt {
564 public:
565  AssertStmt(const std::string &msg, Expr *e, SourcePos p);
566 
567  static inline bool classof(AssertStmt const*) { return true; }
568  static inline bool classof(ASTNode const* N) {
569  return N->getValueID() == AssertStmtID;
570  }
571 
572  void EmitCode(FunctionEmitContext *ctx) const;
573  void Print(int indent) const;
574 
575  Stmt *TypeCheck();
576  int EstimateCost() const;
577 
578  /** Message to print if the assertion fails. */
579  const std::string message;
580  /** The expression to be evaluated (that is asserted to be true). */
582 };
583 
584 
585 /** Representation of a delete statement in the program.
586 */
587 class DeleteStmt : public Stmt {
588 public:
589  DeleteStmt(Expr *e, SourcePos p);
590 
591  static inline bool classof(DeleteStmt const*) { return true; }
592  static inline bool classof(ASTNode const* N) {
593  return N->getValueID() == DeleteStmtID;
594  }
595 
596  void EmitCode(FunctionEmitContext *ctx) const;
597  void Print(int indent) const;
598 
599  Stmt *TypeCheck();
600  int EstimateCost() const;
601 
602  /** Expression that gives the pointer value to be deleted. */
604 };
605 
606 extern Stmt *CreateForeachActiveStmt(Symbol *iterSym, Stmt *stmts,
607  SourcePos pos);
608 
609 #endif // ISPC_STMT_H
int EstimateCost() const
Definition: stmt.cpp:1168
void EmitCode(FunctionEmitContext *ctx) const
Definition: stmt.cpp:3097
static bool classof(ASTNode const *N)
Definition: stmt.h:482
ForeachStmt(const std::vector< Symbol * > &loopVars, const std::vector< Expr * > &startExprs, const std::vector< Expr * > &endExprs, Stmt *bodyStatements, bool tiled, SourcePos pos)
Definition: stmt.cpp:1465
static bool classof(LabeledStmt const *)
Definition: stmt.h:481
Expr * expr
Definition: stmt.h:581
static bool classof(ASTNode const *N)
Definition: stmt.h:111
Stmt * bodyStmts
Definition: stmt.h:190
void Print(int indent) const
Definition: stmt.cpp:107
ForStmt(Stmt *initializer, Expr *testExpr, Stmt *stepStatements, Stmt *bodyStatements, bool doCoherentCheck, SourcePos pos)
Definition: stmt.cpp:1195
std::vector< VariableDeclaration > vars
Definition: stmt.h:122
static bool classof(ASTNode const *N)
Definition: stmt.h:276
int EstimateCost() const
Definition: stmt.cpp:672
void Print(int indent) const
Definition: stmt.cpp:3139
Stmt(SourcePos p, unsigned scid)
Definition: stmt.h:51
Stmt * stmts
Definition: stmt.h:404
const bool doCoherentCheck
Definition: stmt.h:224
static bool classof(ASTNode const *N)
Definition: stmt.h:348
static bool classof(ForeachStmt const *)
Definition: stmt.h:275
Stmt * trueStmts
Definition: stmt.h:149
int EstimateCost() const
Definition: stmt.cpp:517
Expr * expr
Definition: stmt.h:380
std::vector< Expr * > endExprs
Definition: stmt.h:288
static bool classof(ASTNode const *N)
Definition: stmt.h:179
void emitMaskAllOn(FunctionEmitContext *ctx, llvm::Value *test, llvm::BasicBlock *bDone) const
Definition: stmt.cpp:802
static bool classof(ASTNode const *N)
Definition: stmt.h:392
Representation of a print() statement in the program.
Definition: stmt.h:532
void emitVaryingIf(FunctionEmitContext *ctx, llvm::Value *test) const
Definition: stmt.cpp:723
void EmitCode(FunctionEmitContext *ctx) const
Definition: stmt.cpp:570
static bool classof(AssertStmt const *)
Definition: stmt.h:567
int EstimateCost() const
Definition: stmt.cpp:3157
Stmt * TypeCheck()
Definition: stmt.cpp:3064
Interface class for statements in the ispc language.
Definition: stmt.h:49
Statement representing a single declaration (which in turn may declare a number of variables...
Definition: stmt.h:106
Stmt * TypeCheck()
Definition: stmt.cpp:2136
static bool classof(ASTNode const *N)
Definition: stmt.h:54
virtual void EmitCode(FunctionEmitContext *ctx) const =0
void EmitCode(FunctionEmitContext *ctx) const
Definition: stmt.cpp:3173
void Print(int indent) const
Definition: stmt.cpp:2375
BreakStmt(SourcePos pos)
Definition: stmt.cpp:1389
static bool classof(ContinueStmt const *)
Definition: stmt.h:253
const std::string message
Definition: stmt.h:579
Statement representing a single expression.
Definition: stmt.h:77
const std::string format
Definition: stmt.h:548
static bool classof(ForStmt const *)
Definition: stmt.h:203
int EstimateCost() const
Definition: stmt.cpp:2657
void Print(int indent) const
Definition: stmt.cpp:3527
Stmt * CreateForeachActiveStmt(Symbol *iterSym, Stmt *stmts, SourcePos pos)
Definition: stmt.h:453
static bool classof(ASTNode const *N)
Definition: stmt.h:415
void EmitCode(FunctionEmitContext *ctx) const
Definition: stmt.cpp:2858
static bool classof(ASTNode const *N)
Definition: stmt.h:435
int EstimateCost() const
Definition: stmt.cpp:3641
static bool classof(ASTNode const *N)
Definition: stmt.h:507
static bool classof(ExprStmt const *)
Definition: stmt.h:81
int EstimateCost() const
Definition: stmt.cpp:2950
Stmt * Optimize()
Definition: stmt.cpp:3200
Statement implementation for 'for' loops (as well as for 'while' loops).
Definition: stmt.h:198
IfStmt(Expr *testExpr, Stmt *trueStmts, Stmt *falseStmts, bool doAllCheck, SourcePos pos)
Definition: stmt.cpp:525
Stmt * TypeCheck()
Definition: stmt.cpp:2400
static bool classof(ASTNode const *N)
Definition: stmt.h:537
void EmitCode(FunctionEmitContext *ctx) const
Definition: stmt.cpp:3563
int EstimateCost() const
Definition: stmt.cpp:3248
Stmt * TypeCheck()
Definition: stmt.cpp:1136
Stmt * TypeCheck()
Definition: stmt.cpp:1405
static bool classof(ASTNode const *N)
Definition: stmt.h:134
Stmt * TypeCheck()
Definition: stmt.cpp:2748
Representation of an assert statement in the program.
Definition: stmt.h:563
CaseStmt(int value, Stmt *stmt, SourcePos pos)
Definition: stmt.cpp:2686
static bool classof(ForeachUniqueStmt const *)
Definition: stmt.h:324
void EmitCode(FunctionEmitContext *ctx) const
Definition: stmt.cpp:2239
Stmt * TypeCheck()
Definition: stmt.cpp:3463
Statement implementation representing a 'do' statement in the program.
Definition: stmt.h:173
int EstimateCost() const
Definition: stmt.cpp:2754
static bool classof(ASTNode const *N)
Definition: stmt.h:568
void EmitCode(FunctionEmitContext *ctx) const
Definition: stmt.cpp:1395
void Print(int indent) const
Definition: stmt.cpp:3192
StmtList(SourcePos p)
Definition: stmt.h:504
Symbol * sym
Definition: stmt.h:100
ReturnStmt(Expr *e, SourcePos p)
Definition: stmt.cpp:3022
const int value
Definition: stmt.h:403
int EstimateCost() const
Definition: stmt.cpp:120
static bool classof(StmtList const *)
Definition: stmt.h:506
static bool classof(Stmt const *)
Definition: stmt.h:53
Symbol * sym
Definition: stmt.h:335
static bool classof(UnmaskedStmt const *)
Definition: stmt.h:347
Expr * test
Definition: stmt.h:147
static bool classof(ASTNode const *N)
Definition: stmt.h:592
int EstimateCost() const
Definition: stmt.cpp:2409
void Print(int indent) const
Definition: stmt.cpp:1363
Stmt * stmts
Definition: stmt.h:448
static bool classof(GotoStmt const *)
Definition: stmt.h:457
ContinueStmt(SourcePos pos)
Definition: stmt.cpp:1427
void Print(int indent) const
Definition: stmt.cpp:2905
Statement implementation for a break statement in the program.
Definition: stmt.h:230
Stmt * stmts
Definition: stmt.h:425
Expr * expr
Definition: stmt.h:446
ExprStmt(Expr *expr, SourcePos pos)
Definition: stmt.cpp:84
LabeledStmt(const char *label, Stmt *stmt, SourcePos p)
Definition: stmt.cpp:3165
Statement implementation for a 'return' statement in the program.
Definition: stmt.h:365
static bool classof(SwitchStmt const *)
Definition: stmt.h:434
Abstract base class for nodes in the abstract syntax tree (AST).
Definition: ast.h:50
void Print(int indent) const
Definition: stmt.cpp:3457
Stmt * TypeCheck()
Definition: stmt.cpp:2710
Stmt * TypeCheck()
Definition: stmt.cpp:3242
static bool classof(BreakStmt const *)
Definition: stmt.h:234
static bool classof(DefaultStmt const *)
Definition: stmt.h:414
ForeachUniqueStmt(const char *iterName, Expr *expr, Stmt *stmts, SourcePos pos)
Definition: stmt.cpp:2417
virtual Stmt * TypeCheck()=0
Stmt * stmts
Definition: stmt.h:337
ForeachActiveStmt(Symbol *iterSym, Stmt *stmts, SourcePos pos)
Definition: stmt.cpp:2231
Stmt * TypeCheck()
Definition: stmt.cpp:101
Stmt * Optimize()
Definition: stmt.cpp:3145
DeclStmt(const std::vector< VariableDeclaration > &v, SourcePos pos)
Definition: stmt.cpp:128
Stmt * step
Definition: stmt.h:221
Stmt * TypeCheck()
Definition: stmt.cpp:3206
Stmt * TypeCheck()
Definition: stmt.cpp:3625
Statement implementation for a continue statement in the program.
Definition: stmt.h:249
Stmt * TypeCheck()
Definition: stmt.cpp:2917
bool isTiled
Definition: stmt.h:289
void Print(int indent) const
Definition: stmt.cpp:2993
void EmitCode(FunctionEmitContext *ctx) const
Definition: stmt.cpp:3231
AssertStmt(const std::string &msg, Expr *e, SourcePos p)
Definition: stmt.cpp:3477
void EmitCode(FunctionEmitContext *ctx) const
Definition: stmt.cpp:2969
Stmt * TypeCheck()
Definition: stmt.cpp:1443
void EmitCode(FunctionEmitContext *ctx) const
Definition: stmt.cpp:3028
void Print(int indent) const
Definition: stmt.cpp:3254
static bool classof(ASTNode const *N)
Definition: stmt.h:254
VariableDeclaration(Symbol *s=NULL, Expr *i=NULL)
Definition: stmt.h:97
static bool classof(CaseStmt const *)
Definition: stmt.h:391
void Print(int indent) const
Definition: stmt.cpp:1178
Representation of a range of positions in a source file.
Definition: ispc.h:134
Stmt * stmts
Definition: stmt.h:312
DoStmt(Expr *testExpr, Stmt *bodyStmts, bool doCoherentCheck, SourcePos pos)
Definition: stmt.cpp:1019
Stmt * TypeCheck()
Definition: stmt.cpp:3151
void EmitCode(FunctionEmitContext *ctx) const
Definition: stmt.cpp:3483
void EmitCode(FunctionEmitContext *ctx) const
Definition: stmt.cpp:2693
Stmt * stmts
Definition: stmt.h:223
GotoStmt(const char *label, SourcePos gotoPos, SourcePos idPos)
Definition: stmt.cpp:3089
virtual void Print(int indent) const =0
static bool classof(ASTNode const *N)
Definition: stmt.h:325
SourcePos pos
Definition: ast.h:77
static bool classof(ASTNode const *N)
Definition: stmt.h:82
void Print(int indent) const
Definition: stmt.cpp:3619
Stmt * TypeCheck()
Definition: stmt.cpp:1333
const bool doCoherentCheck
Definition: stmt.h:191
void EmitCode(FunctionEmitContext *ctx) const
Definition: stmt.cpp:2731
Expr * values
Definition: stmt.h:551
Expr * testExpr
Definition: stmt.h:189
unsigned getValueID() const
Definition: ast.h:134
SwitchStmt(Expr *expr, Stmt *stmts, SourcePos pos)
Definition: stmt.cpp:2762
int EstimateCost() const
Definition: stmt.cpp:1411
void EmitCode(FunctionEmitContext *ctx) const
Definition: stmt.cpp:1025
void emitMaskedTrueAndFalse(FunctionEmitContext *ctx, llvm::Value *oldMask, llvm::Value *test) const
Definition: stmt.cpp:703
void Print(int indent) const
Definition: stmt.cpp:2601
Stmt * falseStmts
Definition: stmt.h:151
static bool classof(ReturnStmt const *)
Definition: stmt.h:369
Stmt * TypeCheck()
Definition: stmt.cpp:2633
static bool classof(ASTNode const *N)
Definition: stmt.h:370
Expr * test
Definition: stmt.h:218
Stmt * init
Definition: stmt.h:215
Stmt * stmts
Definition: stmt.h:290
Definition: stmt.h:387
static bool classof(ASTNode const *N)
Definition: stmt.h:204
std::vector< Expr * > startExprs
Definition: stmt.h:287
static bool classof(DoStmt const *)
Definition: stmt.h:178
int EstimateCost() const
Definition: stmt.cpp:3222
void Print(int indent) const
Definition: stmt.cpp:2739
Symbol * sym
Definition: stmt.h:311
SourcePos identifierPos
Definition: stmt.h:471
Representation of a program symbol.
Definition: sym.h:63
Stmt * stmt
Definition: stmt.h:496
int EstimateCost() const
Definition: stmt.cpp:2179
Stmt * TypeCheck()
Definition: stmt.cpp:3008
std::vector< Stmt * > stmts
Definition: stmt.h:519
int EstimateCost() const
Definition: stmt.cpp:1449
Expr * expr
Definition: stmt.h:92
Statement implementation for parallel 'foreach' loops.
Definition: stmt.h:268
Stmt * stmts
Definition: stmt.h:358
Stmt * Optimize()
Definition: stmt.cpp:436
DefaultStmt(Stmt *stmt, SourcePos pos)
Definition: stmt.cpp:2724
void EmitCode(FunctionEmitContext *ctx) const
Definition: stmt.cpp:2427
static bool classof(DeclStmt const *)
Definition: stmt.h:110
Statement representing a single if statement, possibly with an else clause.
Definition: stmt.h:128
Expr is the abstract base class that defines the interface that all expression types must implement...
Definition: expr.h:48
Expr * expr
Definition: stmt.h:603
virtual Stmt * Optimize()
Definition: stmt.cpp:76
void Print(int indent) const
Definition: stmt.cpp:2185
std::vector< Symbol * > dimVariables
Definition: stmt.h:286
int EstimateCost() const
Definition: stmt.cpp:3469
void EmitCode(FunctionEmitContext *ctx) const
Definition: stmt.cpp:1433
Representation of a list of statements in the program.
Definition: stmt.h:502
static bool classof(DeleteStmt const *)
Definition: stmt.h:591
UnmaskedStmt(Stmt *stmt, SourcePos pos)
Definition: stmt.cpp:2962
int EstimateCost() const
Definition: stmt.cpp:3014
void EmitCode(FunctionEmitContext *ctx) const
Definition: stmt.cpp:3370
std::string name
Definition: stmt.h:494
void Print(int indent) const
Definition: stmt.cpp:682
void EmitCode(FunctionEmitContext *ctx) const
Definition: stmt.cpp:1202
Stmt * TypeCheck()
Definition: stmt.cpp:466
Expr * expr
Definition: stmt.h:336
static bool classof(ASTNode const *N)
Definition: stmt.h:235
std::string label
Definition: stmt.h:470
void Print(int indent) const
Definition: stmt.cpp:499
static bool classof(PrintStmt const *)
Definition: stmt.h:536
PrintStmt(const std::string &f, Expr *v, SourcePos p)
Definition: stmt.cpp:3267
static bool classof(ASTNode const *N)
Definition: stmt.h:301
static bool classof(ASTNode const *N)
Definition: stmt.h:458
int EstimateCost() const
Definition: stmt.cpp:3070
static bool classof(ForeachActiveStmt const *)
Definition: stmt.h:300
Main ispc.header file. Defines Target, Globals and Opt classes.
void Print(int indent) const
Definition: stmt.cpp:1455
int EstimateCost() const
Definition: stmt.cpp:3548
static bool classof(IfStmt const *)
Definition: stmt.h:133
Stmt * TypeCheck()
Definition: stmt.cpp:653
DeleteStmt(Expr *e, SourcePos p)
Definition: stmt.cpp:3556
void emitMaskMixed(FunctionEmitContext *ctx, llvm::Value *oldMask, llvm::Value *test, llvm::BasicBlock *bDone) const
Definition: stmt.cpp:872
void Print(int indent) const
Definition: stmt.cpp:3076
void Print(int indent) const
Definition: stmt.cpp:2701
const bool doAllCheck
Definition: stmt.h:158
void EmitCode(FunctionEmitContext *ctx) const
Definition: stmt.cpp:90
void Print(int indent) const
Definition: stmt.cpp:1417
int EstimateCost() const
Definition: stmt.cpp:1353
Stmt * TypeCheck()
Definition: stmt.cpp:3533
void Add(Stmt *s)
Definition: stmt.h:517
int EstimateCost() const
Definition: stmt.cpp:2716
void EmitCode(FunctionEmitContext *ctx) const
Definition: stmt.cpp:209
void EmitCode(FunctionEmitContext *ctx) const
Definition: stmt.cpp:1666