Intel SPMD Program Compiler  1.9.1
expr.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 expr.h
35  @brief Expr abstract base class and expression implementations
36 */
37 
38 #ifndef ISPC_EXPR_H
39 #define ISPC_EXPR_H 1
40 
41 #include "ispc.h"
42 #include "ast.h"
43 #include "type.h"
44 
45 /** @brief Expr is the abstract base class that defines the interface that
46  all expression types must implement.
47  */
48 class Expr : public ASTNode {
49 public:
50  Expr(SourcePos p, unsigned scid) : ASTNode(p, scid) { }
51 
52  static inline bool classof(Expr const*) { return true; }
53  static inline bool classof(ASTNode const* N) {
54  return N->getValueID() < MaxExprID;
55  }
56 
57  /** This is the main method for Expr implementations to implement. It
58  should call methods in the FunctionEmitContext to emit LLVM IR
59  instructions to the current basic block in order to generate an
60  llvm::Value that represents the expression's value. */
61  virtual llvm::Value *GetValue(FunctionEmitContext *ctx) const = 0;
62 
63  /** For expressions that can provide an lvalue (e.g. array indexing),
64  this function should emit IR that computes the expression's lvalue
65  and returns the corresponding llvm::Value. Expressions that can't
66  provide an lvalue should leave this unimplemented; the default
67  implementation returns NULL. */
68  virtual llvm::Value *GetLValue(FunctionEmitContext *ctx) const;
69 
70  /** Returns the Type of the expression. */
71  virtual const Type *GetType() const = 0;
72 
73  /** Returns the type of the value returned by GetLValueType(); this
74  should be a pointer type of some sort (uniform or varying). */
75  virtual const Type *GetLValueType() const;
76 
77  /** For expressions that have values based on a symbol (e.g. regular
78  symbol references, array indexing, etc.), this returns a pointer to
79  that symbol. */
80  virtual Symbol *GetBaseSymbol() const;
81 
82  /** If this is a constant expression that can be converted to a
83  constant of the given type, this method should return the
84  corresponding llvm::Constant value. Otherwise it should return
85  NULL. */
86  virtual llvm::Constant *GetConstant(const Type *type) const;
87 
88  /** This method should perform early optimizations of the expression
89  (constant folding, etc.) and return a pointer to the resulting
90  expression. If an error is encountered during optimization, NULL
91  should be returned. */
92  virtual Expr *Optimize() = 0;
93 
94  /** This method should perform type checking of the expression and
95  return a pointer to the resulting expression. If an error is
96  encountered, NULL should be returned. */
97  virtual Expr *TypeCheck() = 0;
98 
99  /** Prints the expression to standard output (used for debugging). */
100  virtual void Print() const = 0;
101 };
102 
103 
104 /** @brief Unary expression */
105 class UnaryExpr : public Expr {
106 public:
107  enum Op {
108  PreInc, ///< Pre-increment
109  PreDec, ///< Pre-decrement
110  PostInc, ///< Post-increment
111  PostDec, ///< Post-decrement
112  Negate, ///< Negation
113  LogicalNot, ///< Logical not
114  BitNot, ///< Bit not
115  };
116 
118 
119  static inline bool classof(UnaryExpr const*) { return true; }
120  static inline bool classof(ASTNode const* N) {
121  return N->getValueID() == UnaryExprID;
122  }
123 
124  llvm::Value *GetValue(FunctionEmitContext *ctx) const;
125  const Type *GetType() const;
126  void Print() const;
127  Expr *Optimize();
128  Expr *TypeCheck();
129  int EstimateCost() const;
130 
131  const Op op;
133 };
134 
135 
136 /** @brief Binary expression */
137 class BinaryExpr : public Expr {
138 public:
139  enum Op {
140  Add, ///< Addition
141  Sub, ///< Subtraction
142  Mul, ///< Multiplication
143  Div, ///< Division
144  Mod, ///< Modulus
145  Shl, ///< Shift left
146  Shr, ///< Shift right
147 
148  Lt, ///< Less than
149  Gt, ///< Greater than
150  Le, ///< Less than or equal
151  Ge, ///< Greater than or equal
152  Equal, ///< Equal
153  NotEqual, ///< Not equal
154 
155  BitAnd, ///< Bitwise AND
156  BitXor, ///< Bitwise XOR
157  BitOr, ///< Bitwise OR
158  LogicalAnd, ///< Logical AND
159  LogicalOr, ///< Logical OR
160 
161  Comma, ///< Comma operator
162  };
163 
164  BinaryExpr(Op o, Expr *a, Expr *b, SourcePos p);
165 
166  static inline bool classof(BinaryExpr const*) { return true; }
167  static inline bool classof(ASTNode const* N) {
168  return N->getValueID() == BinaryExprID;
169  }
170 
171  llvm::Value *GetValue(FunctionEmitContext *ctx) const;
172  const Type *GetType() const;
173  const Type *GetLValueType() const;
174  void Print() const;
175 
176  Expr *Optimize();
177  Expr *TypeCheck();
178  int EstimateCost() const;
179 
180  const Op op;
182 };
183 
184 
185 /** @brief Assignment expression */
186 class AssignExpr : public Expr {
187 public:
188  enum Op {
189  Assign, ///< Regular assignment
190  MulAssign, ///< *= assignment
191  DivAssign, ///< /= assignment
192  ModAssign, ///< %= assignment
193  AddAssign, ///< += assignment
194  SubAssign, ///< -= assignment
195  ShlAssign, ///< <<= assignment
196  ShrAssign, ///< >>= assignment
197  AndAssign, ///< &= assignment
198  XorAssign, ///< ^= assignment
199  OrAssign, ///< |= assignment
200  };
201 
202  AssignExpr(Op o, Expr *a, Expr *b, SourcePos p);
203 
204  static inline bool classof(AssignExpr const*) { return true; }
205  static inline bool classof(ASTNode const* N) {
206  return N->getValueID() == AssignExprID;
207  }
208 
209  llvm::Value *GetValue(FunctionEmitContext *ctx) const;
210  const Type *GetType() const;
211  void Print() const;
212 
213  Expr *Optimize();
214  Expr *TypeCheck();
215  int EstimateCost() const;
216 
217  const Op op;
219 };
220 
221 
222 /** @brief Selection expression, corresponding to "test ? a : b".
223 
224  Returns the value of "a" or "b", depending on the value of "test".
225 */
226 class SelectExpr : public Expr {
227 public:
228  SelectExpr(Expr *test, Expr *a, Expr *b, SourcePos p);
229 
230  static inline bool classof(SelectExpr const*) { return true; }
231  static inline bool classof(ASTNode const* N) {
232  return N->getValueID() == SelectExprID;
233  }
234 
235  llvm::Value *GetValue(FunctionEmitContext *ctx) const;
236  const Type *GetType() const;
237  void Print() const;
238 
239  Expr *Optimize();
240  Expr *TypeCheck();
241  int EstimateCost() const;
242 
244 };
245 
246 /** @brief A list of expressions.
247 
248  These are mostly used for representing curly-brace delimited
249  initializers for initializers for complex types and for representing
250  the arguments passed to a function call.
251  */
252 class ExprList : public Expr {
253 public:
255  ExprList(Expr *e, SourcePos p) : Expr(p, ExprListID) { exprs.push_back(e); }
256 
257  static inline bool classof(ExprList const*) { return true; }
258  static inline bool classof(ASTNode const* N) {
259  return N->getValueID() == ExprListID;
260  }
261 
262  llvm::Value *GetValue(FunctionEmitContext *ctx) const;
263  const Type *GetType() const;
264  void Print() const;
265  llvm::Constant *GetConstant(const Type *type) const;
266  ExprList *Optimize();
267  ExprList *TypeCheck();
268  int EstimateCost() const;
269 
270  std::vector<Expr *> exprs;
271 };
272 
273 
274 /** @brief Expression representing a function call.
275  */
276 class FunctionCallExpr : public Expr {
277 public:
279  bool isLaunch = false,
280  Expr *launchCountExpr[3] = NULL);
281 
282  static inline bool classof(FunctionCallExpr const*) { return true; }
283  static inline bool classof(ASTNode const* N) {
284  return N->getValueID() == FunctionCallExprID;
285  }
286 
287  llvm::Value *GetValue(FunctionEmitContext *ctx) const;
288  llvm::Value *GetLValue(FunctionEmitContext *ctx) const;
289  const Type *GetType() const;
290  const Type *GetLValueType() const;
291  void Print() const;
292 
293  Expr *Optimize();
294  Expr *TypeCheck();
295  int EstimateCost() const;
296 
299  bool isLaunch;
301 };
302 
303 
304 /** @brief Expression representing indexing into something with an integer
305  offset.
306 
307  This is used for both array indexing and indexing into VectorTypes.
308 */
309 class IndexExpr : public Expr {
310 public:
312 
313  static inline bool classof(IndexExpr const*) { return true; }
314  static inline bool classof(ASTNode const* N) {
315  return N->getValueID() == IndexExprID;
316  }
317 
318  llvm::Value *GetValue(FunctionEmitContext *ctx) const;
319  llvm::Value *GetLValue(FunctionEmitContext *ctx) const;
320  const Type *GetType() const;
321  const Type *GetLValueType() const;
322  Symbol *GetBaseSymbol() const;
323  void Print() const;
324 
325  Expr *Optimize();
326  Expr *TypeCheck();
327  int EstimateCost() const;
328 
330 
331 private:
332  mutable const Type *type;
333  mutable const PointerType *lvalueType;
334 };
335 
336 
337 /** @brief Expression representing member selection ("foo.bar").
338  *
339  * This will also be overloaded to deal with swizzles.
340  */
341 class MemberExpr : public Expr {
342 public:
343  static MemberExpr *create(Expr *expr, const char *identifier,
345  bool derefLvalue);
346 
347  static inline bool classof(MemberExpr const*) { return true; }
348  static inline bool classof(ASTNode const* N) {
349  return ((N->getValueID() == StructMemberExprID) ||
350  (N->getValueID() == VectorMemberExprID));
351  }
352 
353  llvm::Value *GetValue(FunctionEmitContext *ctx) const;
354  llvm::Value *GetLValue(FunctionEmitContext *ctx) const;
355  const Type *GetType() const;
356  Symbol *GetBaseSymbol() const;
357  void Print() const;
358  Expr *Optimize();
359  Expr *TypeCheck();
360  int EstimateCost() const;
361 
362  virtual int getElementNumber() const = 0;
363  virtual const Type *getElementType() const = 0;
364  std::string getCandidateNearMatches() const;
365 
367  std::string identifier;
369 
370  MemberExpr(Expr *expr, const char *identifier, SourcePos pos,
371  SourcePos identifierPos, bool derefLValue, unsigned scid);
372 
373  /** Indicates whether the expression should be dereferenced before the
374  member is found. (i.e. this is true if the MemberExpr was a '->'
375  operator, and is false if it was a '.' operator. */
377 
378 protected:
379  mutable const Type *type, *lvalueType;
380 };
381 
382 
383 /** @brief Expression representing a compile-time constant value.
384 
385  This class can currently represent compile-time constants of anything
386  that is an AtomicType or an EnumType; for anything more complex, we
387  don't currently have a representation of a compile-time constant that
388  can be further reasoned about.
389  */
390 class ConstExpr : public Expr {
391 public:
392  /** Create a ConstExpr from a uniform int8 value */
393  ConstExpr(const Type *t, int8_t i, SourcePos p);
394  /** Create a ConstExpr from a varying int8 value */
395  ConstExpr(const Type *t, int8_t *i, SourcePos p);
396  /** Create a ConstExpr from a uniform uint8 value */
397  ConstExpr(const Type *t, uint8_t u, SourcePos p);
398  /** Create a ConstExpr from a varying uint8 value */
399  ConstExpr(const Type *t, uint8_t *u, SourcePos p);
400 
401  /** Create a ConstExpr from a uniform int16 value */
402  ConstExpr(const Type *t, int16_t i, SourcePos p);
403  /** Create a ConstExpr from a varying int16 value */
404  ConstExpr(const Type *t, int16_t *i, SourcePos p);
405  /** Create a ConstExpr from a uniform uint16 value */
406  ConstExpr(const Type *t, uint16_t u, SourcePos p);
407  /** Create a ConstExpr from a varying uint16 value */
408  ConstExpr(const Type *t, uint16_t *u, SourcePos p);
409 
410  /** Create a ConstExpr from a uniform int32 value */
411  ConstExpr(const Type *t, int32_t i, SourcePos p);
412  /** Create a ConstExpr from a varying int32 value */
413  ConstExpr(const Type *t, int32_t *i, SourcePos p);
414  /** Create a ConstExpr from a uniform uint32 value */
415  ConstExpr(const Type *t, uint32_t u, SourcePos p);
416  /** Create a ConstExpr from a varying uint32 value */
417  ConstExpr(const Type *t, uint32_t *u, SourcePos p);
418 
419  /** Create a ConstExpr from a uniform float value */
420  ConstExpr(const Type *t, float f, SourcePos p);
421  /** Create a ConstExpr from a varying float value */
422  ConstExpr(const Type *t, float *f, SourcePos p);
423 
424  /** Create a ConstExpr from a uniform double value */
425  ConstExpr(const Type *t, double d, SourcePos p);
426  /** Create a ConstExpr from a varying double value */
427  ConstExpr(const Type *t, double *d, SourcePos p);
428 
429  /** Create a ConstExpr from a uniform int64 value */
430  ConstExpr(const Type *t, int64_t i, SourcePos p);
431  /** Create a ConstExpr from a varying int64 value */
432  ConstExpr(const Type *t, int64_t *i, SourcePos p);
433  /** Create a ConstExpr from a uniform uint64 value */
434  ConstExpr(const Type *t, uint64_t i, SourcePos p);
435  /** Create a ConstExpr from a varying uint64 value */
436  ConstExpr(const Type *t, uint64_t *i, SourcePos p);
437 
438  /** Create a ConstExpr from a uniform bool value */
439  ConstExpr(const Type *t, bool b, SourcePos p);
440  /** Create a ConstExpr from a varying bool value */
441  ConstExpr(const Type *t, bool *b, SourcePos p);
442 
443  /** Create a ConstExpr of the same type as the given old ConstExpr,
444  with values given by the "vales" parameter. */
445  ConstExpr(ConstExpr *old, double *values);
446 
447  /** Create ConstExpr with the same type and values as the given one,
448  but at the given position. */
450 
451  static inline bool classof(ConstExpr const*) { return true; }
452  static inline bool classof(ASTNode const* N) {
453  return N->getValueID() == ConstExprID;
454  }
455 
456  llvm::Value *GetValue(FunctionEmitContext *ctx) const;
457  const Type *GetType() const;
458  void Print() const;
459  llvm::Constant *GetConstant(const Type *type) const;
460 
461  Expr *TypeCheck();
462  Expr *Optimize();
463  int EstimateCost() const;
464 
465  /** Return the ConstExpr's values as the given pointer type, doing type
466  conversion from the actual type if needed. If forceVarying is
467  true, then type convert to 'varying' so as to always return a
468  number of values equal to the target vector width into the given
469  pointer. */
470  int GetValues(bool *, bool forceVarying = false) const;
471  int GetValues(int8_t *, bool forceVarying = false) const;
472  int GetValues(uint8_t *, bool forceVarying = false) const;
473  int GetValues(int16_t *, bool forceVarying = false) const;
474  int GetValues(uint16_t *, bool forceVarying = false) const;
475  int GetValues(int32_t *, bool forceVarying = false) const;
476  int GetValues(uint32_t *, bool forceVarying = false) const;
477  int GetValues(float *, bool forceVarying = false) const;
478  int GetValues(int64_t *, bool forceVarying = false) const;
479  int GetValues(uint64_t *, bool forceVarying = false) const;
480  int GetValues(double *, bool forceVarying = false) const;
481 
482  /** Return the number of values in the ConstExpr; should be either 1,
483  if it has uniform type, or the target's vector width if it's
484  varying. */
485  int Count() const;
486 
487 private:
489 
490  const Type *type;
491  union {
503  };
504 };
505 
506 
507 /** @brief Expression representing a type cast of the given expression to a
508  probably-different type. */
509 class TypeCastExpr : public Expr {
510 public:
511  TypeCastExpr(const Type *t, Expr *e, SourcePos p);
512 
513  static inline bool classof(TypeCastExpr const*) { return true; }
514  static inline bool classof(ASTNode const* N) {
515  return N->getValueID() == TypeCastExprID;
516  }
517 
518  llvm::Value *GetValue(FunctionEmitContext *ctx) const;
519  llvm::Value *GetLValue(FunctionEmitContext *ctx) const;
520  const Type *GetType() const;
521  const Type *GetLValueType() const;
522  void Print() const;
523  Expr *TypeCheck();
524  Expr *Optimize();
525  int EstimateCost() const;
526  Symbol *GetBaseSymbol() const;
527  llvm::Constant *GetConstant(const Type *type) const;
528 
529  const Type *type;
531 };
532 
533 
534 /** @brief Expression that represents taking a reference of a (non-reference)
535  variable. */
536 class ReferenceExpr : public Expr {
537 public:
539 
540  static inline bool classof(ReferenceExpr const*) { return true; }
541  static inline bool classof(ASTNode const* N) {
542  return N->getValueID() == ReferenceExprID;
543  }
544 
545  llvm::Value *GetValue(FunctionEmitContext *ctx) const;
546  const Type *GetType() const;
547  const Type *GetLValueType() const;
548  Symbol *GetBaseSymbol() const;
549  void Print() const;
550  Expr *TypeCheck();
551  Expr *Optimize();
552  int EstimateCost() const;
553 
555 };
556 
557 
558 /** @brief Common base class that provides shared functionality for
559  PtrDerefExpr and RefDerefExpr. */
560 class DerefExpr : public Expr {
561 public:
562  DerefExpr(Expr *e, SourcePos p, unsigned scid = DerefExprID);
563 
564  static inline bool classof(DerefExpr const*) { return true; }
565  static inline bool classof(ASTNode const* N) {
566  return ((N->getValueID() == DerefExprID) ||
567  (N->getValueID() == PtrDerefExprID) ||
568  (N->getValueID() == RefDerefExprID));
569  }
570 
571  llvm::Value *GetValue(FunctionEmitContext *ctx) const;
572  llvm::Value *GetLValue(FunctionEmitContext *ctx) const;
573  const Type *GetLValueType() const;
574  Symbol *GetBaseSymbol() const;
575  Expr *Optimize();
576 
578 };
579 
580 
581 /** @brief Expression that represents dereferencing a pointer to get its
582  value. */
583 class PtrDerefExpr : public DerefExpr {
584 public:
585  PtrDerefExpr(Expr *e, SourcePos p);
586 
587  static inline bool classof(PtrDerefExpr const*) { return true; }
588  static inline bool classof(ASTNode const* N) {
589  return N->getValueID() == PtrDerefExprID;
590  }
591 
592  const Type *GetType() const;
593  void Print() const;
594  Expr *TypeCheck();
595  int EstimateCost() const;
596 };
597 
598 
599 /** @brief Expression that represents dereferencing a reference to get its
600  value. */
601 class RefDerefExpr : public DerefExpr {
602 public:
603  RefDerefExpr(Expr *e, SourcePos p);
604 
605  static inline bool classof(RefDerefExpr const*) { return true; }
606  static inline bool classof(ASTNode const* N) {
607  return N->getValueID() == RefDerefExprID;
608  }
609 
610  const Type *GetType() const;
611  void Print() const;
612  Expr *TypeCheck();
613  int EstimateCost() const;
614 };
615 
616 
617 /** Expression that represents taking the address of an expression. */
618 class AddressOfExpr : public Expr {
619 public:
621 
622  static inline bool classof(AddressOfExpr const*) { return true; }
623  static inline bool classof(ASTNode const* N) {
624  return N->getValueID() == AddressOfExprID;
625  }
626 
627  llvm::Value *GetValue(FunctionEmitContext *ctx) const;
628  const Type *GetType() const;
629  const Type *GetLValueType() const;
630  Symbol *GetBaseSymbol() const;
631  void Print() const;
632  Expr *TypeCheck();
633  Expr *Optimize();
634  int EstimateCost() const;
635  llvm::Constant *GetConstant(const Type *type) const;
636 
638 };
639 
640 
641 /** Expression that returns the size of the given expression or type in
642  bytes. */
643 class SizeOfExpr : public Expr {
644 public:
645  SizeOfExpr(Expr *e, SourcePos p);
646  SizeOfExpr(const Type *t, SourcePos p);
647 
648  static inline bool classof(SizeOfExpr const*) { return true; }
649  static inline bool classof(ASTNode const* N) {
650  return N->getValueID() == SizeOfExprID;
651  }
652 
653  llvm::Value *GetValue(FunctionEmitContext *ctx) const;
654  const Type *GetType() const;
655  void Print() const;
656  Expr *TypeCheck();
657  Expr *Optimize();
658  int EstimateCost() const;
659 
660  /* One of expr or type should be non-NULL (but not both of them). The
661  SizeOfExpr returns the size of whichever one of them isn't NULL. */
663  const Type *type;
664 };
665 
666 
667 /** @brief Expression representing a symbol reference in the program */
668 class SymbolExpr : public Expr {
669 public:
670  SymbolExpr(Symbol *s, SourcePos p);
671 
672  static inline bool classof(SymbolExpr const*) { return true; }
673  static inline bool classof(ASTNode const* N) {
674  return N->getValueID() == SymbolExprID;
675  }
676 
677  llvm::Value *GetValue(FunctionEmitContext *ctx) const;
678  llvm::Value *GetLValue(FunctionEmitContext *ctx) const;
679  const Type *GetType() const;
680  const Type *GetLValueType() const;
681  Symbol *GetBaseSymbol() const;
682  Expr *TypeCheck();
683  Expr *Optimize();
684  void Print() const;
685  int EstimateCost() const;
686 
687 private:
689 };
690 
691 
692 /** @brief Expression representing a function symbol in the program (generally
693  used for a function call).
694  */
695 class FunctionSymbolExpr : public Expr {
696 public:
697  FunctionSymbolExpr(const char *name, const std::vector<Symbol *> &candFuncs,
698  SourcePos pos);
699 
700  static inline bool classof(FunctionSymbolExpr const*) { return true; }
701  static inline bool classof(ASTNode const* N) {
702  return N->getValueID() == FunctionSymbolExprID;
703  }
704 
705  llvm::Value *GetValue(FunctionEmitContext *ctx) const;
706  const Type *GetType() const;
707  Symbol *GetBaseSymbol() const;
708  Expr *TypeCheck();
709  Expr *Optimize();
710  void Print() const;
711  int EstimateCost() const;
712  llvm::Constant *GetConstant(const Type *type) const;
713 
714  /** Given the types of the function arguments, in the presence of
715  function overloading, this method resolves which actual function
716  the arguments match best. If the argCouldBeNULL parameter is
717  non-NULL, each element indicates whether the corresponding argument
718  is the number zero, indicating that it could be a NULL pointer, and
719  if argIsConstant is non-NULL, each element indicates whether the
720  corresponding argument is a compile-time constant value. Both of
721  these parameters may be NULL (for cases where overload resolution
722  is being done just given type information without the parameter
723  argument expressions being available. This function returns true
724  on success.
725  */
726  bool ResolveOverloads(SourcePos argPos,
727  const std::vector<const Type *> &argTypes,
728  const std::vector<bool> *argCouldBeNULL = NULL,
729  const std::vector<bool> *argIsConstant = NULL);
731 
732 private:
733  std::vector<Symbol *> getCandidateFunctions(int argCount) const;
734  static int computeOverloadCost(const FunctionType *ftype,
735  const std::vector<const Type *> &argTypes,
736  const std::vector<bool> *argCouldBeNULL,
737  const std::vector<bool> *argIsConstant,
738  int * cost);
739 
740  /** Name of the function that is being called. */
741  std::string name;
742 
743  /** All of the functions with the name given in the function call;
744  there may be more then one, in which case we need to resolve which
745  overload is the best match. */
746  std::vector<Symbol *> candidateFunctions;
747 
748  /** The actual matching function found after overload resolution. */
750 
752 };
753 
754 
755 /** @brief A sync statement in the program (waits for all launched tasks before
756  proceeding). */
757 class SyncExpr : public Expr {
758 public:
760 
761  static inline bool classof(SyncExpr const*) { return true; }
762  static inline bool classof(ASTNode const* N) {
763  return N->getValueID() == SyncExprID;
764  }
765 
766  llvm::Value *GetValue(FunctionEmitContext *ctx) const;
767  const Type *GetType() const;
768  Expr *TypeCheck();
769  Expr *Optimize();
770  void Print() const;
771  int EstimateCost() const;
772 };
773 
774 
775 /** @brief An expression that represents a NULL pointer. */
776 class NullPointerExpr : public Expr {
777 public:
779 
780  static inline bool classof(NullPointerExpr const*) { return true; }
781  static inline bool classof(ASTNode const* N) {
782  return N->getValueID() == NullPointerExprID;
783  }
784 
785  llvm::Value *GetValue(FunctionEmitContext *ctx) const;
786  const Type *GetType() const;
787  Expr *TypeCheck();
788  Expr *Optimize();
789  llvm::Constant *GetConstant(const Type *type) const;
790  void Print() const;
791  int EstimateCost() const;
792 };
793 
794 
795 /** An expression representing a "new" expression, used for dynamically
796  allocating memory.
797 */
798 class NewExpr : public Expr {
799 public:
800  NewExpr(int typeQual, const Type *type, Expr *initializer, Expr *count,
801  SourcePos tqPos, SourcePos p);
802 
803  static inline bool classof(NewExpr const*) { return true; }
804  static inline bool classof(ASTNode const* N) {
805  return N->getValueID() == NewExprID;
806  }
807 
808  llvm::Value *GetValue(FunctionEmitContext *ctx) const;
809  const Type *GetType() const;
810  Expr *TypeCheck();
811  Expr *Optimize();
812  void Print() const;
813  int EstimateCost() const;
814 
815  /** Type of object to allocate storage for. */
816  const Type *allocType;
817  /** Expression giving the number of elements to allocate, when the
818  "new Foo[expr]" form is used. This may be NULL, in which case a
819  single element of the given type will be allocated. */
821  /** Optional initializer expression used to initialize the allocated
822  memory. */
824  /** Indicates whether this is a "varying new" or "uniform new"
825  (i.e. whether a separate allocation is performed per program
826  instance, or whether a single allocation is performed for the
827  entire gang of program instances.) */
828  bool isVarying;
829 };
830 
831 
832 /** This function indicates whether it's legal to convert from fromType to
833  toType. If the optional errorMsgBase and source position parameters
834  are provided, then an error message is issued if the type conversion
835  isn't possible.
836  */
837 bool CanConvertTypes(const Type *fromType, const Type *toType,
838  const char *errorMsgBase = NULL,
839  SourcePos pos = SourcePos());
840 
841 /** This function attempts to convert the given expression to the given
842  type, returning a pointer to a new expression that is the result. If
843  the required type conversion is illegal, it returns NULL and prints an
844  error message using the provided string to indicate the context for
845  which type conversion was being applied (e.g. "function call
846  parameter").
847  */
848 Expr *TypeConvertExpr(Expr *expr, const Type *toType, const char *errorMsgBase);
849 
851 
852 /** Utility routine that emits code to initialize a symbol given an
853  initializer expression.
854 
855  @param lvalue Memory location of storage for the symbol's data
856  @param symName Name of symbol (used in error messages)
857  @param symType Type of variable being initialized
858  @param initExpr Expression for the initializer
859  @param ctx FunctionEmitContext to use for generating instructions
860  @param pos Source file position of the variable being initialized
861 */
862 void
863 InitSymbol(llvm::Value *lvalue, const Type *symType, Expr *initExpr,
864  FunctionEmitContext *ctx, SourcePos pos);
865 
866 bool PossiblyResolveFunctionOverloads(Expr *expr, const Type *type);
867 
868 #endif // ISPC_EXPR_H
const Type * GetType() const
Definition: expr.cpp:2072
static bool classof(RefDerefExpr const *)
Definition: expr.h:605
static bool classof(DerefExpr const *)
Definition: expr.h:564
static bool classof(SelectExpr const *)
Definition: expr.h:230
Symbol * GetMatchingFunction()
Definition: expr.cpp:8464
const Type * GetLValueType() const
Definition: expr.cpp:7760
llvm::Value * GetValue(FunctionEmitContext *ctx) const
Definition: expr.cpp:2017
Common base class that provides shared functionality for PtrDerefExpr and RefDerefExpr.
Definition: expr.h:560
const Type * type
Definition: expr.h:663
static bool classof(ASTNode const *N)
Definition: expr.h:53
Expr * Optimize()
Definition: expr.cpp:8064
const Type * type
Definition: expr.h:332
const Type * GetLValueType() const
Definition: expr.cpp:7958
static bool classof(BinaryExpr const *)
Definition: expr.h:166
Symbol * GetBaseSymbol() const
Definition: expr.cpp:7970
Expr * countExpr
Definition: expr.h:820
const Type * GetType() const
Definition: expr.cpp:7875
|= assignment
Definition: expr.h:199
llvm::Value * GetValue(FunctionEmitContext *ctx) const
Definition: expr.cpp:4243
Expr * TypeCheck()
Definition: expr.cpp:7791
void Print() const
Definition: expr.cpp:8493
const Type * GetLValueType() const
Definition: expr.cpp:7468
const Type * type
Definition: expr.h:379
Expr * Optimize()
Definition: expr.cpp:5294
FunctionSymbolExpr(const char *name, const std::vector< Symbol * > &candFuncs, SourcePos pos)
Definition: expr.cpp:8022
virtual Symbol * GetBaseSymbol() const
Definition: expr.cpp:109
llvm::Constant * GetConstant(const Type *type) const
Definition: expr.cpp:7384
static bool classof(AssignExpr const *)
Definition: expr.h:204
const Type * GetType() const
Definition: expr.cpp:7663
DerefExpr(Expr *e, SourcePos p, unsigned scid=DerefExprID)
Definition: expr.cpp:7517
const Type * GetType() const
Definition: expr.cpp:4310
int8_t int8Val[ISPC_MAX_NVEC]
Definition: expr.h:492
llvm::Value * GetValue(FunctionEmitContext *ctx) const
Definition: expr.cpp:3591
static bool classof(NullPointerExpr const *)
Definition: expr.h:780
Division.
Definition: expr.h:143
const Type * GetType() const
Definition: expr.cpp:3959
llvm::Value * GetValue(FunctionEmitContext *ctx) const
Definition: expr.cpp:2954
const Type * GetType() const
Definition: expr.cpp:8521
Expr * TypeCheck()
Definition: expr.cpp:7895
llvm::Value * GetValue(FunctionEmitContext *ctx) const
Definition: expr.cpp:7860
/= assignment
Definition: expr.h:191
static bool classof(ASTNode const *N)
Definition: expr.h:205
Bitwise OR.
Definition: expr.h:157
llvm::Constant * GetConstant(const Type *type) const
Definition: expr.cpp:8539
virtual void Print() const =0
const Type * GetType() const
Definition: expr.cpp:7455
void Print() const
Definition: expr.cpp:3934
static bool classof(ASTNode const *N)
Definition: expr.h:541
Expression that represents taking a reference of a (non-reference) variable.
Definition: expr.h:536
Expr * TypeCheck()
Definition: expr.cpp:7163
Expr * Optimize()
Definition: expr.cpp:2355
An expression that represents a NULL pointer.
Definition: expr.h:776
virtual llvm::Value * GetLValue(FunctionEmitContext *ctx) const
Definition: expr.cpp:87
Expr(SourcePos p, unsigned scid)
Definition: expr.h:50
int EstimateCost() const
Definition: expr.cpp:8001
Expr * Optimize()
Definition: expr.cpp:7569
Logical AND.
Definition: expr.h:158
const Type * GetType() const
Definition: expr.cpp:3362
static bool classof(FunctionSymbolExpr const *)
Definition: expr.h:700
int16_t int16Val[ISPC_MAX_NVEC]
Definition: expr.h:494
void Print() const
Definition: expr.cpp:5310
llvm::Constant * GetConstant(const Type *type) const
Definition: expr.cpp:3978
static bool classof(SyncExpr const *)
Definition: expr.h:761
NullPointerExpr(SourcePos p)
Definition: expr.h:778
const Type * GetType() const
Definition: expr.cpp:8034
const Type * GetLValueType() const
Definition: expr.cpp:7140
Expr * baseExpr
Definition: expr.h:329
const Type * GetType() const
Definition: expr.cpp:7737
Expression representing a compile-time constant value.
Definition: expr.h:390
SymbolExpr(Symbol *s, SourcePos p)
Definition: expr.cpp:7930
TypeCastExpr(const Type *t, Expr *e, SourcePos p)
Definition: expr.cpp:6234
static bool classof(ReferenceExpr const *)
Definition: expr.h:540
const PointerType * lvalueType
Definition: expr.h:333
Greater than.
Definition: expr.h:149
Expr * TypeCheck()
Definition: expr.cpp:8737
Expr * expr
Definition: expr.h:366
Symbol * GetBaseSymbol() const
Definition: expr.cpp:4358
BinaryExpr(Op o, Expr *a, Expr *b, SourcePos p)
Definition: expr.cpp:1667
static bool classof(UnaryExpr const *)
Definition: expr.h:119
void Print() const
Definition: expr.cpp:1369
llvm::Value * GetLValue(FunctionEmitContext *ctx) const
Definition: expr.cpp:3706
std::string name
Definition: expr.h:741
Expr * TypeCheck()
Definition: expr.cpp:2508
int EstimateCost() const
Definition: expr.cpp:3910
virtual Expr * Optimize()=0
bool triedToResolve
Definition: expr.h:751
int EstimateCost() const
Definition: expr.cpp:1360
int EstimateCost() const
Definition: expr.cpp:7497
Less than.
Definition: expr.h:148
Symbol * symbol
Definition: expr.h:688
Negation.
Definition: expr.h:112
int EstimateCost() const
Definition: expr.cpp:4102
void Print() const
Definition: expr.cpp:4677
llvm::Value * GetValue(FunctionEmitContext *ctx) const
Definition: expr.cpp:8479
static bool classof(ASTNode const *N)
Definition: expr.h:623
static bool classof(ExprList const *)
Definition: expr.h:257
ReferenceExpr(Expr *e, SourcePos p)
Definition: expr.cpp:7408
virtual llvm::Constant * GetConstant(const Type *type) const
Definition: expr.cpp:102
const Op op
Definition: expr.h:131
PtrDerefExpr(Expr *e, SourcePos p)
Definition: expr.cpp:7579
Comma operator.
Definition: expr.h:161
static bool classof(ASTNode const *N)
Definition: expr.h:314
bool CanConvertTypes(const Type *fromType, const Type *toType, const char *errorMsgBase=NULL, SourcePos pos=SourcePos())
Definition: expr.cpp:587
void Print() const
Definition: expr.cpp:4108
Expr * MakeBinaryExpr(BinaryExpr::Op o, Expr *a, Expr *b, SourcePos p)
Definition: expr.cpp:1722
Symbol * matchingFunc
Definition: expr.h:749
void Print() const
Definition: expr.cpp:7341
void Print() const
Definition: expr.cpp:3537
void Print() const
Definition: expr.cpp:2835
const Type * GetType() const
Definition: expr.cpp:7119
SelectExpr(Expr *test, Expr *a, Expr *b, SourcePos p)
Definition: expr.cpp:3171
bool ResolveOverloads(SourcePos argPos, const std::vector< const Type * > &argTypes, const std::vector< bool > *argCouldBeNULL=NULL, const std::vector< bool > *argIsConstant=NULL)
Definition: expr.cpp:8353
A list of expressions.
Definition: expr.h:252
Expr * Optimize()
Definition: expr.cpp:7988
llvm::Value * GetValue(FunctionEmitContext *ctx) const
Definition: expr.cpp:3227
const Type * GetLValueType() const
Definition: expr.cpp:7555
Type implementation for pointers to other types.
Definition: type.h:446
Expr * expr
Definition: expr.h:530
Expr * Optimize()
Definition: expr.cpp:7245
ExprList * args
Definition: expr.h:298
llvm::Value * GetValue(FunctionEmitContext *ctx) const
Definition: expr.cpp:1116
static bool classof(ASTNode const *N)
Definition: expr.h:804
Expr * arg0
Definition: expr.h:181
static bool classof(ASTNode const *N)
Definition: expr.h:514
AssignExpr(Op o, Expr *a, Expr *b, SourcePos p)
Definition: expr.cpp:2946
static bool classof(ASTNode const *N)
Definition: expr.h:781
FunctionCallExpr(Expr *func, ExprList *args, SourcePos p, bool isLaunch=false, Expr *launchCountExpr[3]=NULL)
Definition: expr.cpp:3555
bool boolVal[ISPC_MAX_NVEC]
Definition: expr.h:498
void Print() const
Definition: expr.cpp:8799
llvm::Value * GetValue(FunctionEmitContext *ctx) const
Definition: expr.cpp:8046
Pre-increment.
Definition: expr.h:108
Expr * expr
Definition: expr.h:577
llvm::Value * GetValue(FunctionEmitContext *ctx) const
Definition: expr.cpp:5188
static bool classof(SymbolExpr const *)
Definition: expr.h:672
llvm::Value * GetValue(FunctionEmitContext *ctx) const
Definition: expr.cpp:8602
Modulus.
Definition: expr.h:144
int EstimateCost() const
Definition: expr.cpp:8562
const Type * GetType() const
Definition: expr.cpp:3738
int EstimateCost() const
Definition: expr.cpp:7693
Expr * test
Definition: expr.h:243
llvm::Value * GetLValue(FunctionEmitContext *ctx) const
Definition: expr.cpp:5255
std::string identifier
Definition: expr.h:367
void Print() const
Definition: expr.cpp:8076
void Print() const
Definition: expr.cpp:7702
void Print() const
Definition: expr.cpp:7643
Expr * expr
Definition: expr.h:132
llvm::Constant * GetConstant(const Type *type) const
Definition: expr.cpp:7824
static bool classof(MemberExpr const *)
Definition: expr.h:347
static bool classof(ASTNode const *N)
Definition: expr.h:348
llvm::Value * GetValue(FunctionEmitContext *ctx) const
Definition: expr.cpp:3952
const Type * GetType() const
Definition: expr.cpp:3021
uint8_t uint8Val[ISPC_MAX_NVEC]
Definition: expr.h:493
RefDerefExpr(Expr *e, SourcePos p)
Definition: expr.cpp:7657
llvm::Value * GetValue(FunctionEmitContext *ctx) const
Definition: expr.cpp:7937
Binary expression.
Definition: expr.h:137
static bool classof(SizeOfExpr const *)
Definition: expr.h:648
const Type * lvalueType
Definition: expr.h:379
bool isVarying
Definition: expr.h:828
Definition: expr.h:798
void Print() const
Definition: expr.cpp:7779
static bool classof(NewExpr const *)
Definition: expr.h:803
Expr * TypeCheck()
Definition: expr.cpp:8058
void Print() const
Definition: expr.cpp:8009
Expression representing a type cast of the given expression to a probably-different type...
Definition: expr.h:509
static bool classof(Expr const *)
Definition: expr.h:52
uint32_t uint32Val[ISPC_MAX_NVEC]
Definition: expr.h:497
Expr * TypeCheck()
Definition: expr.cpp:7676
Expr * Optimize()
Definition: expr.cpp:7812
Multiplication.
Definition: expr.h:142
Shift left.
Definition: expr.h:145
Abstract base class for nodes in the abstract syntax tree (AST).
Definition: ast.h:50
llvm::Value * GetValue(FunctionEmitContext *ctx) const
Definition: expr.cpp:6808
static bool classof(TypeCastExpr const *)
Definition: expr.h:513
SizeOfExpr(Expr *e, SourcePos p)
Definition: expr.cpp:7848
Expr * func
Definition: expr.h:297
int EstimateCost() const
Definition: expr.cpp:4658
llvm::Value * GetLValue(FunctionEmitContext *ctx) const
Definition: expr.cpp:4439
Expr * Optimize()
Definition: expr.cpp:8506
float floatVal[ISPC_MAX_NVEC]
Definition: expr.h:499
llvm::Value * GetLValue(FunctionEmitContext *ctx) const
Definition: expr.cpp:7547
int EstimateCost() const
Definition: expr.cpp:6177
void Print() const
Definition: expr.cpp:7882
int EstimateCost() const
Definition: expr.cpp:7331
static bool classof(ASTNode const *N)
Definition: expr.h:283
int GetValues(bool *, bool forceVarying=false) const
Definition: expr.cpp:5876
Expr * arg1
Definition: expr.h:181
const Type * GetType() const
Definition: expr.cpp:8727
Expr * TypeCheck()
Definition: expr.cpp:6171
Expr * expr
Definition: expr.h:637
static bool classof(ASTNode const *N)
Definition: expr.h:673
Symbol * GetBaseSymbol() const
Definition: expr.cpp:7563
llvm::Constant * GetConstant(const Type *type) const
Definition: expr.cpp:6029
Expr * Optimize()
Definition: expr.cpp:6165
llvm::Value * GetLValue(FunctionEmitContext *ctx) const
Definition: expr.cpp:7108
static bool classof(ASTNode const *N)
Definition: expr.h:701
virtual const Type * GetLValueType() const
Definition: expr.cpp:94
llvm::Value * GetValue(FunctionEmitContext *ctx) const
Definition: expr.cpp:5694
Expr * TypeCheck()
Definition: expr.cpp:3058
Expr * Optimize()
Definition: expr.cpp:7481
Expr * TypeCheck()
Definition: expr.cpp:3482
const Type * GetType() const
Definition: expr.cpp:7585
const Op op
Definition: expr.h:217
%= assignment
Definition: expr.h:192
Expr * TypeCheck()
Definition: expr.cpp:5288
Expr * expr
Definition: expr.h:554
Expr * Optimize()
Definition: expr.cpp:8533
A sync statement in the program (waits for all launched tasks before proceeding). ...
Definition: expr.h:757
Expr * index
Definition: expr.h:329
AddressOfExpr(Expr *e, SourcePos p)
Definition: expr.cpp:7716
virtual llvm::Value * GetValue(FunctionEmitContext *ctx) const =0
Logical not.
Definition: expr.h:113
Expr * lvalue
Definition: expr.h:218
llvm::Value * GetValue(FunctionEmitContext *ctx) const
Definition: expr.cpp:7722
static bool classof(ASTNode const *N)
Definition: expr.h:167
Representation of a range of positions in a source file.
Definition: ispc.h:134
Expression representing a function symbol in the program (generally used for a function call)...
Definition: expr.h:695
uint64_t uint64Val[ISPC_MAX_NVEC]
Definition: expr.h:502
Expr * Optimize()
Definition: expr.cpp:1185
const Type * GetType() const
Definition: expr.cpp:1146
Post-decrement.
Definition: expr.h:111
SyncExpr(SourcePos p)
Definition: expr.h:759
void Print() const
Definition: expr.cpp:8555
Expr * TypeCheck()
Definition: expr.cpp:3776
ExprList * TypeCheck()
Definition: expr.cpp:3972
+= assignment
Definition: expr.h:193
const Type * GetType() const
Definition: expr.cpp:5688
Symbol * GetBaseSymbol() const
Definition: expr.cpp:7350
static bool classof(PtrDerefExpr const *)
Definition: expr.h:587
Expr * TypeCheck()
Definition: expr.cpp:7982
const Op op
Definition: expr.h:180
std::vector< Symbol * > candidateFunctions
Definition: expr.h:746
Post-increment.
Definition: expr.h:110
const Type * GetLValueType() const
Definition: expr.cpp:4512
SourcePos pos
Definition: ast.h:77
Expr * Optimize()
Definition: expr.cpp:8793
std::vector< Symbol * > getCandidateFunctions(int argCount) const
Definition: expr.cpp:8181
Not equal.
Definition: expr.h:153
int64_t int64Val[ISPC_MAX_NVEC]
Definition: expr.h:501
llvm::Value * GetValue(FunctionEmitContext *ctx) const
Definition: expr.cpp:7524
const Type * GetType() const
Definition: expr.cpp:8473
const Type * type
Definition: expr.h:490
UnaryExpr(Op op, Expr *expr, SourcePos pos)
Definition: expr.cpp:1110
void InitSymbol(llvm::Value *lvalue, const Type *symType, Expr *initExpr, FunctionEmitContext *ctx, SourcePos pos)
Definition: expr.cpp:648
Bitwise XOR.
Definition: expr.h:156
const Type * GetType() const
Definition: expr.cpp:5237
Expr * TypeCheck()
Definition: expr.cpp:8527
Symbol * GetBaseSymbol() const
Definition: expr.cpp:8052
unsigned getValueID() const
Definition: ast.h:134
Expr * Optimize()
Definition: expr.cpp:3013
void Print() const
Definition: expr.cpp:7503
Bit not.
Definition: expr.h:114
Expr * launchCountExpr[3]
Definition: expr.h:300
int EstimateCost() const
Definition: expr.cpp:8487
#define ISPC_MAX_NVEC
Definition: ispc.h:68
static bool classof(ConstExpr const *)
Definition: expr.h:451
int EstimateCost() const
Definition: expr.cpp:7923
virtual int getElementNumber() const =0
Definition: expr.cpp:5249
int EstimateCost() const
Definition: expr.cpp:3531
static bool classof(ASTNode const *N)
Definition: expr.h:231
int EstimateCost() const
Definition: expr.cpp:7626
const Type * allocType
Definition: expr.h:816
Expression representing member selection ("foo.bar").
Definition: expr.h:341
Pre-decrement.
Definition: expr.h:109
std::vector< Expr * > exprs
Definition: expr.h:270
virtual const Type * GetType() const =0
int EstimateCost() const
Definition: expr.cpp:7818
Symbol * GetBaseSymbol() const
Definition: expr.cpp:7449
Symbol * GetBaseSymbol() const
Definition: expr.cpp:5243
static int computeOverloadCost(const FunctionType *ftype, const std::vector< const Type * > &argTypes, const std::vector< bool > *argCouldBeNULL, const std::vector< bool > *argIsConstant, int *cost)
Definition: expr.cpp:8225
Expr * TypeCheck()
Definition: expr.cpp:7601
BasicType
Definition: type.h:328
llvm::Value * GetLValue(FunctionEmitContext *ctx) const
Definition: expr.cpp:7949
int Count() const
Definition: expr.cpp:6023
>>= assignment
Definition: expr.h:196
Unary expression.
Definition: expr.h:105
static bool classof(ASTNode const *N)
Definition: expr.h:258
static bool classof(IndexExpr const *)
Definition: expr.h:313
Expr * rvalue
Definition: expr.h:218
static bool classof(ASTNode const *N)
Definition: expr.h:588
Expression representing indexing into something with an integer offset.
Definition: expr.h:309
static MemberExpr * create(Expr *expr, const char *identifier, SourcePos pos, SourcePos identifierPos, bool derefLvalue)
Definition: expr.cpp:5107
Type representing a function (return type + argument types)
Definition: type.h:883
Representation of a program symbol.
Definition: sym.h:63
<<= assignment
Definition: expr.h:195
bool isLaunch
Definition: expr.h:299
Symbol * GetBaseSymbol() const
Definition: expr.cpp:7773
void Print() const
Definition: expr.cpp:3155
Expr * expr2
Definition: expr.h:243
AtomicType::BasicType getBasicType() const
Definition: expr.cpp:5676
Interface class that defines the type abstraction.
Definition: type.h:101
Expression that represents dereferencing a pointer to get its value.
Definition: expr.h:583
Expr * Optimize()
Definition: expr.cpp:3402
Regular assignment.
Definition: expr.h:189
Expr * Optimize()
Definition: expr.cpp:4577
Addition.
Definition: expr.h:140
static bool classof(FunctionCallExpr const *)
Definition: expr.h:282
Less than or equal.
Definition: expr.h:150
&= assignment
Definition: expr.h:197
Expr * TypeConvertExpr(Expr *expr, const Type *toType, const char *errorMsgBase)
Definition: expr.cpp:595
Expr * TypeCheck()
Definition: expr.cpp:1286
static bool classof(ASTNode const *N)
Definition: expr.h:606
llvm::Constant * GetConstant(const Type *type) const
Definition: expr.cpp:8087
ExprList * Optimize()
Definition: expr.cpp:3966
Expr * Optimize()
Definition: expr.cpp:3768
std::string getCandidateNearMatches() const
Definition: expr.cpp:5326
Expr is the abstract base class that defines the interface that all expression types must implement...
Definition: expr.h:48
int EstimateCost() const
Definition: expr.cpp:8805
double doubleVal[ISPC_MAX_NVEC]
Definition: expr.h:500
Assignment expression.
Definition: expr.h:186
MemberExpr(Expr *expr, const char *identifier, SourcePos pos, SourcePos identifierPos, bool derefLValue, unsigned scid)
Definition: expr.cpp:5177
Expr * TypeCheck()
Definition: expr.cpp:8500
-= assignment
Definition: expr.h:194
Expr * expr
Definition: expr.h:662
Subtraction.
Definition: expr.h:141
ConstExpr(const Type *t, int8_t i, SourcePos p)
Definition: expr.cpp:5351
static bool classof(AddressOfExpr const *)
Definition: expr.h:622
Expression that represents dereferencing a reference to get its value.
Definition: expr.h:601
IndexExpr(Expr *baseExpr, Expr *index, SourcePos p)
Definition: expr.cpp:4122
const Type * type
Definition: expr.h:529
const Type * GetLValueType() const
Definition: expr.cpp:2812
Shift right.
Definition: expr.h:146
int EstimateCost() const
Definition: expr.cpp:2824
int EstimateCost() const
Definition: expr.cpp:5300
Greater than or equal.
Definition: expr.h:151
bool PossiblyResolveFunctionOverloads(Expr *expr, const Type *type)
Definition: expr.cpp:615
*= assignment
Definition: expr.h:190
llvm::Value * GetValue(FunctionEmitContext *ctx) const
Definition: expr.cpp:7415
Equal.
Definition: expr.h:152
int32_t int32Val[ISPC_MAX_NVEC]
Definition: expr.h:496
const Type * GetType() const
Definition: expr.cpp:7976
void Print() const
Definition: expr.cpp:6183
const Type * GetLValueType() const
Definition: expr.cpp:3753
int EstimateCost() const
Definition: expr.cpp:3144
Expression representing a symbol reference in the program.
Definition: expr.h:668
int EstimateCost() const
Definition: expr.cpp:8070
bool dereferenceExpr
Definition: expr.h:376
Selection expression, corresponding to "test ? a : b".
Definition: expr.h:226
llvm::Value * GetValue(FunctionEmitContext *ctx) const
Definition: expr.cpp:8515
static bool classof(ASTNode const *N)
Definition: expr.h:565
static bool classof(ASTNode const *N)
Definition: expr.h:649
static bool classof(ASTNode const *N)
Definition: expr.h:452
Main ispc.header file. Defines Target, Globals and Opt classes.
uint16_t uint16Val[ISPC_MAX_NVEC]
Definition: expr.h:495
Expr * TypeCheck()
Definition: expr.cpp:7489
static bool classof(ASTNode const *N)
Definition: expr.h:120
Expr * expr1
Definition: expr.h:243
ExprList(Expr *e, SourcePos p)
Definition: expr.h:255
virtual Expr * TypeCheck()=0
Expr * Optimize()
Definition: expr.cpp:7917
const SourcePos identifierPos
Definition: expr.h:368
^= assignment
Definition: expr.h:198
ExprList(SourcePos p)
Definition: expr.h:254
Expr * initExpr
Definition: expr.h:823
Expr * TypeCheck()
Definition: expr.cpp:4585
Logical OR.
Definition: expr.h:159
static bool classof(ASTNode const *N)
Definition: expr.h:762
Expression representing a function call.
Definition: expr.h:276
virtual const Type * getElementType() const =0
File with declarations for classes related to type representation.
Bitwise AND.
Definition: expr.h:155
NewExpr(int typeQual, const Type *type, Expr *initializer, Expr *count, SourcePos tqPos, SourcePos p)
Definition: expr.cpp:8570