FreeTensor
Loading...
Searching...
No Matches
expr.h
Go to the documentation of this file.
1#ifndef FREE_TENSOR_EXPR_H
2#define FREE_TENSOR_EXPR_H
3
4#include <string>
5#include <vector>
6
7#include <ast.h>
8#include <type/data_type.h>
9
10namespace freetensor {
11
17class AnyExprNode : public ExprNode {
18 public:
19 void compHash() override;
20 void inferDType() override { ASSERT(false); }
21 std::vector<Expr> children() const override { return {}; }
23};
25inline Expr
26makeAnyExpr(std::source_location loc = std::source_location::current()) {
28 a->setDebugBlame(loc);
29 return a;
30}
31
32class VarNode : public ExprNode {
33 public:
34 std::string name_;
35 void compHash() override;
36 void inferDType() override;
37 std::vector<Expr> children() const override { return {}; }
39};
41inline Expr
42makeVar(const std::string &name,
43 std::source_location loc = std::source_location::current()) {
44 ASSERT(!name.empty());
45 Var v = Var::make();
46 v->name_ = name;
47 v->setDebugBlame(loc);
48 return v;
49}
50
51class LoadNode : public ExprNode {
52 public:
53 std::string var_;
56 void compHash() override;
57 void inferDType() override;
58 std::vector<Expr> children() const override { return indices_; }
60};
62template <class Tindices>
63Expr makeLoad(const std::string &var, Tindices &&indices, DataType loadType,
64 std::source_location loc = std::source_location::current()) {
65 ASSERT(!var.empty());
66 Load l = Load::make();
67 l->var_ = var;
68 l->indices_ = std::forward<Tindices>(indices);
69 l->loadType_ = loadType;
70 l->setDebugBlame(loc);
71 return l;
72}
73inline Expr
74makeLoad(const std::string &var, const std::vector<Expr> &indices,
75 DataType loadType,
76 std::source_location loc = std::source_location::current()) {
77 ASSERT(!var.empty());
78 Load l = Load::make();
79 l->var_ = var;
80 l->indices_ = indices;
81 l->loadType_ = loadType;
82 l->setDebugBlame(loc);
83 return l;
84}
85
86class ConstNode : public ExprNode {
87 public:
88 bool isConst() const override { return true; }
89 std::vector<Expr> children() const override { return {}; }
90};
92
93class IntConstNode : public ConstNode {
94 public:
95 int64_t val_;
96 void compHash() override;
97 void inferDType() override;
99};
101inline Expr
102makeIntConst(int64_t val,
103 std::source_location loc = std::source_location::current()) {
105 c->val_ = val;
106 c->setDebugBlame(loc);
107 return c;
108}
109
110class FloatConstNode : public ConstNode {
111 public:
112 double val_;
113 void compHash() override;
114 void inferDType() override;
116};
118inline Expr
119makeFloatConst(double val,
120 std::source_location loc = std::source_location::current()) {
122 c->val_ = val;
123 c->setDebugBlame(loc);
124 return c;
125}
126
127class BoolConstNode : public ConstNode {
128 public:
129 bool val_;
130 void compHash() override;
131 void inferDType() override;
133};
135inline Expr
137 std::source_location loc = std::source_location::current()) {
139 b->val_ = val;
140 b->setDebugBlame(loc);
141 return b;
142}
143
144class BinaryExprNode : public ExprNode {
145 public:
147
148 bool isBinary() const override { return true; }
149 std::vector<Expr> children() const override { return {lhs_, rhs_}; }
150 virtual bool isCommutative() const = 0;
151};
153
155 public:
156 void compHash() override;
157 bool isCommutative() const override { return true; }
158};
160
162 public:
163 void compHash() override;
164 bool isCommutative() const override { return false; }
165};
167
169 void inferDType() override;
171};
173template <class T, class U>
175 std::source_location loc = std::source_location::current()) {
176 Add a = Add::make();
177 a->lhs_ = std::forward<T>(lhs), a->rhs_ = std::forward<U>(rhs);
178 a->setDebugBlame(loc);
179 return a;
180}
181
183 void inferDType() override;
185};
187template <class T, class U>
189 std::source_location loc = std::source_location::current()) {
190 Sub a = Sub::make();
191 a->lhs_ = std::forward<T>(lhs), a->rhs_ = std::forward<U>(rhs);
192 a->setDebugBlame(loc);
193 return a;
194}
195
197 void inferDType() override;
199};
201template <class T, class U>
203 std::source_location loc = std::source_location::current()) {
204 Mul a = Mul::make();
205 a->lhs_ = std::forward<T>(lhs), a->rhs_ = std::forward<U>(rhs);
206 a->setDebugBlame(loc);
207 return a;
208}
209
214 void inferDType() override;
216};
218template <class T, class U>
220 std::source_location loc = std::source_location::current()) {
222 a->lhs_ = std::forward<T>(lhs), a->rhs_ = std::forward<U>(rhs);
223 a->setDebugBlame(loc);
224 return a;
225}
226
234 void inferDType() override;
236};
238template <class T, class U>
240 std::source_location loc = std::source_location::current()) {
242 a->lhs_ = std::forward<T>(lhs), a->rhs_ = std::forward<U>(rhs);
243 a->setDebugBlame(loc);
244 return a;
245}
246
254 void inferDType() override;
256};
258template <class T, class U>
260 std::source_location loc = std::source_location::current()) {
262 a->lhs_ = std::forward<T>(lhs), a->rhs_ = std::forward<U>(rhs);
263 a->setDebugBlame(loc);
264 return a;
265}
266
274 void inferDType() override;
276};
278template <class T, class U>
280 T &&lhs, U &&rhs,
281 std::source_location loc = std::source_location::current()) {
283 a->lhs_ = std::forward<T>(lhs), a->rhs_ = std::forward<U>(rhs);
284 a->setDebugBlame(loc);
285 return a;
286}
287
298 void inferDType() override;
300};
302template <class T, class U>
304 std::source_location loc = std::source_location::current()) {
305 Mod a = Mod::make();
306 a->lhs_ = std::forward<T>(lhs), a->rhs_ = std::forward<U>(rhs);
307 a->setDebugBlame(loc);
308 return a;
309}
310
321 void inferDType() override;
323};
325template <class T, class U>
327 std::source_location loc = std::source_location::current()) {
329 a->lhs_ = std::forward<T>(lhs), a->rhs_ = std::forward<U>(rhs);
330 a->setDebugBlame(loc);
331 return a;
332}
333
335 void inferDType() override;
337};
339template <class T, class U>
341 std::source_location loc = std::source_location::current()) {
342 Min m = Min::make();
343 m->lhs_ = std::forward<T>(lhs), m->rhs_ = std::forward<U>(rhs);
344 m->setDebugBlame(loc);
345 return m;
346}
347
349 void inferDType() override;
351};
353template <class T, class U>
355 std::source_location loc = std::source_location::current()) {
356 Max m = Max::make();
357 m->lhs_ = std::forward<T>(lhs), m->rhs_ = std::forward<U>(rhs);
358 m->setDebugBlame(loc);
359 return m;
360}
361
363 void inferDType() override;
365};
367template <class T, class U>
369 std::source_location loc = std::source_location::current()) {
370 LT a = LT::make();
371 a->lhs_ = std::forward<T>(lhs), a->rhs_ = std::forward<U>(rhs);
372 a->setDebugBlame(loc);
373 return a;
374}
375
377 void inferDType() override;
379};
381template <class T, class U>
383 std::source_location loc = std::source_location::current()) {
384 LE a = LE::make();
385 a->lhs_ = std::forward<T>(lhs), a->rhs_ = std::forward<U>(rhs);
386 a->setDebugBlame(loc);
387 return a;
388}
389
391 void inferDType() override;
393};
395template <class T, class U>
397 std::source_location loc = std::source_location::current()) {
398 GT a = GT::make();
399 a->lhs_ = std::forward<T>(lhs), a->rhs_ = std::forward<U>(rhs);
400 a->setDebugBlame(loc);
401 return a;
402}
403
405 void inferDType() override;
407};
409template <class T, class U>
411 std::source_location loc = std::source_location::current()) {
412 GE a = GE::make();
413 a->lhs_ = std::forward<T>(lhs), a->rhs_ = std::forward<U>(rhs);
414 a->setDebugBlame(loc);
415 return a;
416}
417
419 void inferDType() override;
421};
423template <class T, class U>
425 std::source_location loc = std::source_location::current()) {
426 EQ a = EQ::make();
427 a->lhs_ = std::forward<T>(lhs), a->rhs_ = std::forward<U>(rhs);
428 a->setDebugBlame(loc);
429 return a;
430}
431
433 void inferDType() override;
435};
437template <class T, class U>
439 std::source_location loc = std::source_location::current()) {
440 NE a = NE::make();
441 a->lhs_ = std::forward<T>(lhs), a->rhs_ = std::forward<U>(rhs);
442 a->setDebugBlame(loc);
443 return a;
444}
445
447 void inferDType() override;
449};
451template <class T, class U>
453 std::source_location loc = std::source_location::current()) {
454 LAnd l = LAnd::make();
455 l->lhs_ = std::forward<T>(lhs), l->rhs_ = std::forward<U>(rhs);
456 l->setDebugBlame(loc);
457 return l;
458}
459
461 void inferDType() override;
463};
465template <class T, class U>
467 std::source_location loc = std::source_location::current()) {
468 LOr l = LOr::make();
469 l->lhs_ = std::forward<T>(lhs), l->rhs_ = std::forward<U>(rhs);
470 l->setDebugBlame(loc);
471 return l;
472}
473
474class UnaryExprNode : public ExprNode {
475 public:
477
478 void compHash() override;
479 bool isUnary() const override { return true; }
480 std::vector<Expr> children() const override { return {expr_}; }
481};
483
484class LNotNode : public UnaryExprNode {
485 void inferDType() override;
487};
489template <class T>
490Expr makeLNot(T &&expr,
491 std::source_location loc = std::source_location::current()) {
492 LNot n = LNot::make();
493 n->expr_ = std::forward<T>(expr);
494 n->setDebugBlame(loc);
495 return n;
496}
497
498class SqrtNode : public UnaryExprNode {
499 void inferDType() override;
501};
503template <class T>
504Expr makeSqrt(T &&expr,
505 std::source_location loc = std::source_location::current()) {
506 Sqrt s = Sqrt::make();
507 s->expr_ = std::forward<T>(expr);
508 s->setDebugBlame(loc);
509 return s;
510}
511
512class ExpNode : public UnaryExprNode {
513 void inferDType() override;
515};
517template <class T>
518Expr makeExp(T &&expr,
519 std::source_location loc = std::source_location::current()) {
520 Exp e = Exp::make();
521 e->expr_ = std::forward<T>(expr);
522 e->setDebugBlame(loc);
523 return e;
524}
525
526class LnNode : public UnaryExprNode {
527 void inferDType() override;
529};
531template <class T>
532Expr makeLn(T &&expr,
533 std::source_location loc = std::source_location::current()) {
534 Ln e = Ln::make();
535 e->expr_ = std::forward<T>(expr);
536 e->setDebugBlame(loc);
537 return e;
538}
539
540class SquareNode : public UnaryExprNode {
541 void inferDType() override;
543};
545template <class T>
547 std::source_location loc = std::source_location::current()) {
548 Square e = Square::make();
549 e->expr_ = std::forward<T>(expr);
550 e->setDebugBlame(loc);
551 return e;
552}
553
555 void inferDType() override;
557};
559template <class T>
561 std::source_location loc = std::source_location::current()) {
563 e->expr_ = std::forward<T>(expr);
564 e->setDebugBlame(loc);
565 return e;
566}
567
568class SinNode : public UnaryExprNode {
569 void inferDType() override;
571};
573template <class T>
574Expr makeSin(T &&expr,
575 std::source_location loc = std::source_location::current()) {
576 Sin e = Sin::make();
577 e->expr_ = std::forward<T>(expr);
578 e->setDebugBlame(loc);
579 return e;
580}
581
582class CosNode : public UnaryExprNode {
583 void inferDType() override;
585};
587template <class T>
588Expr makeCos(T &&expr,
589 std::source_location loc = std::source_location::current()) {
590 Cos e = Cos::make();
591 e->expr_ = std::forward<T>(expr);
592 e->setDebugBlame(loc);
593 return e;
594}
595
596class TanNode : public UnaryExprNode {
597 void inferDType() override;
599};
601template <class T>
602Expr makeTan(T &&expr,
603 std::source_location loc = std::source_location::current()) {
604 Tan e = Tan::make();
605 e->expr_ = std::forward<T>(expr);
606 e->setDebugBlame(loc);
607 return e;
608}
609
610class TanhNode : public UnaryExprNode {
611 void inferDType() override;
613};
615template <class T>
616Expr makeTanh(T &&expr,
617 std::source_location loc = std::source_location::current()) {
618 Tanh e = Tanh::make();
619 e->expr_ = std::forward<T>(expr);
620 e->setDebugBlame(loc);
621 return e;
622}
623
624class AbsNode : public UnaryExprNode {
625 void inferDType() override;
627};
629template <class T>
630Expr makeAbs(T &&expr,
631 std::source_location loc = std::source_location::current()) {
632 Abs e = Abs::make();
633 e->expr_ = std::forward<T>(expr);
634 e->setDebugBlame(loc);
635 return e;
636}
637
638class FloorNode : public UnaryExprNode {
639 void inferDType() override;
641};
643template <class T>
645 std::source_location loc = std::source_location::current()) {
646 Floor e = Floor::make();
647 e->expr_ = std::forward<T>(expr);
648 e->setDebugBlame(loc);
649 return e;
650}
651
652class CeilNode : public UnaryExprNode {
653 void inferDType() override;
655};
657template <class T>
658Expr makeCeil(T &&expr,
659 std::source_location loc = std::source_location::current()) {
660 Ceil e = Ceil::make();
661 e->expr_ = std::forward<T>(expr);
662 e->setDebugBlame(loc);
663 return e;
664}
665
680 void inferDType() override;
682};
684template <class T>
686 std::source_location loc = std::source_location::current()) {
688 e->expr_ = std::forward<T>(expr);
689 e->setDebugBlame(loc);
690 return e;
691}
692
693class IfExprNode : public ExprNode {
694 public:
698 void compHash() override;
699 void inferDType() override;
700 std::vector<Expr> children() const override {
701 return {cond_, thenCase_, elseCase_};
702 }
704};
706template <class T, class U, class V>
707Expr makeIfExpr(T &&cond, U &&thenCase, V &&elseCase,
708 std::source_location loc = std::source_location::current()) {
709 IfExpr e = IfExpr::make();
710 e->cond_ = std::forward<T>(cond);
711 e->thenCase_ = std::forward<U>(thenCase);
712 e->elseCase_ = std::forward<V>(elseCase);
713 e->setDebugBlame(loc);
714 return e;
715}
716
717class CastNode : public ExprNode {
718 public:
721 void compHash() override;
722 void inferDType() override;
723 std::vector<Expr> children() const override { return {expr_}; }
725};
727template <class T>
728Expr makeCast(T &&expr, DataType destType,
729 std::source_location loc = std::source_location::current()) {
730 Cast e = Cast::make();
731 e->expr_ = std::forward<T>(expr);
732 e->destType_ = destType;
733 e->setDebugBlame(loc);
734 return e;
735}
736
740class IntrinsicNode : public ExprNode {
741 public:
742 std::string
749 void compHash() override;
750 void inferDType() override;
751 std::vector<Expr> children() const override { return {params_}; }
753};
755template <class T>
756Expr makeIntrinsic(const std::string &format, T &&params, DataType retType,
757 bool hasSideEffect,
758 std::source_location loc = std::source_location::current()) {
760 i->format_ = format;
761 i->params_ = std::forward<T>(params);
762 i->retType_ = retType;
763 i->hasSideEffect_ = hasSideEffect;
764 i->setDebugBlame(loc);
765 return i;
766}
767inline Expr
768makeIntrinsic(const std::string &format, std::initializer_list<Expr> params,
769 DataType retType, bool hasSideEffect,
770 std::source_location loc = std::source_location::current()) {
772 i->format_ = format;
773 i->params_ = params;
774 i->retType_ = retType;
775 i->hasSideEffect_ = hasSideEffect;
776 i->setDebugBlame(loc);
777 return i;
778}
779
781 public:
782 std::string tapeName_;
785 void compHash() override;
786 void inferDType() override;
787 std::vector<Expr> children() const override { return indices_; }
789};
791template <class Tindices>
792inline Expr
793makeLoadAtVersion(const std::string &tapeName, Tindices &&indices,
794 const DataType loadType,
795 std::source_location loc = std::source_location::current()) {
797 l->tapeName_ = tapeName;
798 l->indices_ = std::forward<Tindices>(indices);
799 l->loadType_ = loadType;
800 l->setDebugBlame(loc);
801 return l;
802}
803inline Expr
804makeLoadAtVersion(const std::string &tapeName, const std::vector<Expr> &indices,
805 const DataType loadType,
806 std::source_location loc = std::source_location::current()) {
808 l->tapeName_ = tapeName;
809 l->indices_ = indices;
810 l->loadType_ = loadType;
811 l->setDebugBlame(loc);
812 return l;
813}
814
815template <class T, class U>
816Expr makeBinary(ASTNodeType nodeType, T &&lhs, U &&rhs,
817 std::source_location loc = std::source_location::current()) {
818 switch (nodeType) {
819 case ASTNodeType::Add:
820 return makeAdd(std::forward<T>(lhs), std::forward<U>(rhs), loc);
821 case ASTNodeType::Sub:
822 return makeSub(std::forward<T>(lhs), std::forward<U>(rhs), loc);
823 case ASTNodeType::Mul:
824 return makeMul(std::forward<T>(lhs), std::forward<U>(rhs), loc);
826 return makeRealDiv(std::forward<T>(lhs), std::forward<U>(rhs), loc);
828 return makeFloorDiv(std::forward<T>(lhs), std::forward<U>(rhs), loc);
830 return makeCeilDiv(std::forward<T>(lhs), std::forward<U>(rhs), loc);
832 return makeRoundTowards0Div(std::forward<T>(lhs), std::forward<U>(rhs),
833 loc);
834 case ASTNodeType::Mod:
835 return makeMod(std::forward<T>(lhs), std::forward<U>(rhs), loc);
837 return makeRemainder(std::forward<T>(lhs), std::forward<U>(rhs), loc);
838 case ASTNodeType::Min:
839 return makeMin(std::forward<T>(lhs), std::forward<U>(rhs), loc);
840 case ASTNodeType::Max:
841 return makeMax(std::forward<T>(lhs), std::forward<U>(rhs), loc);
842 case ASTNodeType::LT:
843 return makeLT(std::forward<T>(lhs), std::forward<U>(rhs), loc);
844 case ASTNodeType::LE:
845 return makeLE(std::forward<T>(lhs), std::forward<U>(rhs), loc);
846 case ASTNodeType::GT:
847 return makeGT(std::forward<T>(lhs), std::forward<U>(rhs), loc);
848 case ASTNodeType::GE:
849 return makeGE(std::forward<T>(lhs), std::forward<U>(rhs), loc);
850 case ASTNodeType::EQ:
851 return makeEQ(std::forward<T>(lhs), std::forward<U>(rhs), loc);
852 case ASTNodeType::NE:
853 return makeNE(std::forward<T>(lhs), std::forward<U>(rhs), loc);
855 return makeLAnd(std::forward<T>(lhs), std::forward<U>(rhs), loc);
856 case ASTNodeType::LOr:
857 return makeLOr(std::forward<T>(lhs), std::forward<U>(rhs), loc);
858 default:
859 ASSERT(false);
860 }
861}
862
863template <class T>
864Expr makeUnary(ASTNodeType nodeType, T &&expr,
865 std::source_location loc = std::source_location::current()) {
866 switch (nodeType) {
868 return makeLNot(std::forward<T>(expr), loc);
870 return makeSqrt(std::forward<T>(expr), loc);
871 case ASTNodeType::Exp:
872 return makeExp(std::forward<T>(expr), loc);
873 case ASTNodeType::Ln:
874 return makeLn(std::forward<T>(expr), loc);
876 return makeSquare(std::forward<T>(expr), loc);
878 return makeSigmoid(std::forward<T>(expr), loc);
879 case ASTNodeType::Sin:
880 return makeSin(std::forward<T>(expr), loc);
881 case ASTNodeType::Cos:
882 return makeCos(std::forward<T>(expr), loc);
883 case ASTNodeType::Tan:
884 return makeTan(std::forward<T>(expr), loc);
886 return makeTanh(std::forward<T>(expr), loc);
887 case ASTNodeType::Abs:
888 return makeAbs(std::forward<T>(expr), loc);
890 return makeFloor(std::forward<T>(expr), loc);
892 return makeCeil(std::forward<T>(expr), loc);
894 return makeUnbound(std::forward<T>(expr), loc);
895 default:
896 ASSERT(false);
897 }
898}
899
900} // namespace freetensor
901
902#endif // FREE_TENSOR_EXPR_H
#define DEFINE_NODE_TRAIT(name)
Definition: ast.h:106
Definition: expr.h:624
Definition: expr.h:168
Definition: expr.h:17
void inferDType() override
Definition: expr.h:20
void compHash() override
Definition: expr.cc:12
std::vector< Expr > children() const override
Definition: expr.h:21
Definition: expr.h:144
std::vector< Expr > children() const override
Definition: expr.h:149
virtual bool isCommutative() const =0
SubTree< ExprNode > lhs_
Definition: expr.h:146
SubTree< ExprNode > rhs_
Definition: expr.h:146
bool isBinary() const override
Definition: expr.h:148
Definition: expr.h:127
void inferDType() override
Definition: expr.cc:27
bool val_
Definition: expr.h:129
void compHash() override
Definition: expr.cc:17
Definition: expr.h:717
void compHash() override
Definition: expr.cc:19
SubTree< ExprNode > expr_
Definition: expr.h:719
std::vector< Expr > children() const override
Definition: expr.h:723
void inferDType() override
Definition: expr.cc:64
DataType destType_
Definition: expr.h:720
Definition: expr.h:253
Definition: expr.h:652
void compHash() override
Definition: expr.cc:7
bool isCommutative() const override
Definition: expr.h:157
Definition: expr.h:86
bool isConst() const override
Definition: expr.h:88
std::vector< Expr > children() const override
Definition: expr.h:89
Definition: expr.h:582
Definition: data_type.h:106
Definition: expr.h:418
Definition: expr.h:512
Definition: ast.h:157
Definition: expr.h:110
void inferDType() override
Definition: expr.cc:26
void compHash() override
Definition: expr.cc:16
double val_
Definition: expr.h:112
Definition: expr.h:233
Definition: expr.h:638
Definition: expr.h:404
Definition: expr.h:390
Definition: expr.h:693
std::vector< Expr > children() const override
Definition: expr.h:700
SubTree< ExprNode > thenCase_
Definition: expr.h:696
SubTree< ExprNode > cond_
Definition: expr.h:695
void inferDType() override
Definition: expr.cc:63
SubTree< ExprNode > elseCase_
Definition: expr.h:697
void compHash() override
Definition: expr.cc:18
Definition: expr.h:93
int64_t val_
Definition: expr.h:95
void compHash() override
Definition: expr.cc:15
void inferDType() override
Definition: expr.cc:25
Definition: expr.h:740
std::vector< Expr > children() const override
Definition: expr.h:751
std::string format_
Definition: expr.h:743
void inferDType() override
Definition: expr.cc:65
void compHash() override
Definition: expr.cc:20
SubTreeList< ExprNode > params_
Definition: expr.h:746
DataType retType_
Definition: expr.h:747
bool hasSideEffect_
Definition: expr.h:748
Definition: expr.h:446
Definition: expr.h:376
Definition: expr.h:484
Definition: expr.h:460
Definition: expr.h:362
Definition: expr.h:526
Definition: expr.h:780
void inferDType() override
Definition: expr.cc:66
std::string tapeName_
Definition: expr.h:782
SubTreeList< ExprNode > indices_
Definition: expr.h:783
DEFINE_NODE_TRAIT(LoadAtVersion)
void compHash() override
Definition: expr.cc:21
DataType loadType_
Definition: expr.h:784
std::vector< Expr > children() const override
Definition: expr.h:787
Definition: expr.h:51
void compHash() override
Definition: expr.cc:14
std::string var_
Definition: expr.h:53
SubTreeList< ExprNode > indices_
Definition: expr.h:54
void inferDType() override
Definition: expr.cc:24
std::vector< Expr > children() const override
Definition: expr.h:58
DataType loadType_
Definition: expr.h:55
Definition: expr.h:348
Definition: expr.h:334
Definition: expr.h:297
Definition: expr.h:196
Definition: expr.h:432
bool isCommutative() const override
Definition: expr.h:164
void compHash() override
Definition: expr.cc:8
Definition: expr.h:213
Definition: ref.h:24
static Ref make()
Definition: ref.h:105
Definition: expr.h:320
Definition: expr.h:273
Definition: expr.h:554
Definition: expr.h:568
Definition: expr.h:498
Definition: expr.h:540
Definition: expr.h:182
Definition: sub_tree.h:305
Definition: sub_tree.h:134
Definition: expr.h:596
Definition: expr.h:610
Definition: expr.h:474
std::vector< Expr > children() const override
Definition: expr.h:480
SubTree< ExprNode > expr_
Definition: expr.h:476
bool isUnary() const override
Definition: expr.h:479
void compHash() override
Definition: expr.cc:11
Definition: expr.h:679
Definition: expr.h:32
std::string name_
Definition: expr.h:34
void inferDType() override
Definition: expr.cc:23
std::vector< Expr > children() const override
Definition: expr.h:37
void compHash() override
Definition: expr.cc:13
#define ASSERT(expr)
Definition: except.h:152
int n
Definition: metadata.cc:15
Definition: allocator.h:9
Expr makeCeil(T &&expr, std::source_location loc=std::source_location::current())
Definition: expr.h:658
Ref< TanNode > Tan
Definition: expr.h:600
Expr makeLoad(const std::string &var, Tindices &&indices, DataType loadType, std::source_location loc=std::source_location::current())
Definition: expr.h:63
Expr makeRemainder(T &&lhs, U &&rhs, std::source_location loc=std::source_location::current())
Definition: expr.h:326
Ref< RemainderNode > Remainder
Definition: expr.h:324
Ref< BoolConstNode > BoolConst
Definition: expr.h:134
Ref< RoundTowards0DivNode > RoundTowards0Div
Definition: expr.h:277
Ref< VarNode > Var
Definition: expr.h:40
auto && lhs
Definition: const_fold.cc:70
Ref< CeilDivNode > CeilDiv
Definition: expr.h:257
Expr makeSigmoid(T &&expr, std::source_location loc=std::source_location::current())
Definition: expr.h:560
Expr makeUnary(ASTNodeType nodeType, T &&expr, std::source_location loc=std::source_location::current())
Definition: expr.h:864
Ref< MaxNode > Max
Definition: expr.h:352
Expr makeLT(T &&lhs, U &&rhs, std::source_location loc=std::source_location::current())
Definition: expr.h:368
Ref< ConstNode > Const
Definition: expr.h:91
Ref< LAndNode > LAnd
Definition: expr.h:450
Expr makeMin(T &&lhs, U &&rhs, std::source_location loc=std::source_location::current())
Definition: expr.h:340
Expr makeIntrinsic(const std::string &format, T &&params, DataType retType, bool hasSideEffect, std::source_location loc=std::source_location::current())
Definition: expr.h:756
PBSet params(T &&set)
Definition: presburger.h:1065
Expr makeSin(T &&expr, std::source_location loc=std::source_location::current())
Definition: expr.h:574
Expr makeLoadAtVersion(const std::string &tapeName, Tindices &&indices, const DataType loadType, std::source_location loc=std::source_location::current())
Definition: expr.h:793
Expr makeUnbound(T &&expr, std::source_location loc=std::source_location::current())
Definition: expr.h:685
Expr makeMul(T &&lhs, U &&rhs, std::source_location loc=std::source_location::current())
Definition: expr.h:202
Ref< LoadNode > Load
Definition: expr.h:61
Expr makeGT(T &&lhs, U &&rhs, std::source_location loc=std::source_location::current())
Definition: expr.h:396
Expr makeFloorDiv(T &&lhs, U &&rhs, std::source_location loc=std::source_location::current())
Definition: expr.h:239
Expr makeAdd(T &&lhs, U &&rhs, std::source_location loc=std::source_location::current())
Definition: expr.h:174
Expr makeCeilDiv(T &&lhs, U &&rhs, std::source_location loc=std::source_location::current())
Definition: expr.h:259
Ref< BinaryExprNode > BinaryExpr
Definition: expr.h:152
Expr makeIfExpr(T &&cond, U &&thenCase, V &&elseCase, std::source_location loc=std::source_location::current())
Definition: expr.h:707
Ref< SubNode > Sub
Definition: expr.h:186
Ref< IfExprNode > IfExpr
Definition: expr.h:705
Ref< SquareNode > Square
Definition: expr.h:544
Ref< SigmoidNode > Sigmoid
Definition: expr.h:558
Ref< CastNode > Cast
Definition: expr.h:726
Ref< RealDivNode > RealDiv
Definition: expr.h:217
Expr makeMod(T &&lhs, U &&rhs, std::source_location loc=std::source_location::current())
Definition: expr.h:303
Ref< CeilNode > Ceil
Definition: expr.h:656
Expr makeBinary(ASTNodeType nodeType, T &&lhs, U &&rhs, std::source_location loc=std::source_location::current())
Definition: expr.h:816
Expr makeLE(T &&lhs, U &&rhs, std::source_location loc=std::source_location::current())
Definition: expr.h:382
Ref< LNotNode > LNot
Definition: expr.h:488
Ref< FloorNode > Floor
Definition: expr.h:642
Ref< GENode > GE
Definition: expr.h:408
Ref< GTNode > GT
Definition: expr.h:394
Ref< FloorDivNode > FloorDiv
Definition: expr.h:237
Expr makeAbs(T &&expr, std::source_location loc=std::source_location::current())
Definition: expr.h:630
Ref< UnaryExprNode > UnaryExpr
Definition: expr.h:482
Ref< TanhNode > Tanh
Definition: expr.h:614
Expr makeCos(T &&expr, std::source_location loc=std::source_location::current())
Definition: expr.h:588
Ref< MulNode > Mul
Definition: expr.h:200
Expr makeLn(T &&expr, std::source_location loc=std::source_location::current())
Definition: expr.h:532
Ref< LTNode > LT
Definition: expr.h:366
Expr makeTanh(T &&expr, std::source_location loc=std::source_location::current())
Definition: expr.h:616
Ref< NENode > NE
Definition: expr.h:436
Expr makeNE(T &&lhs, U &&rhs, std::source_location loc=std::source_location::current())
Definition: expr.h:438
Ref< LoadAtVersionNode > LoadAtVersion
Definition: expr.h:790
Ref< IntrinsicNode > Intrinsic
Definition: expr.h:754
Expr makeEQ(T &&lhs, U &&rhs, std::source_location loc=std::source_location::current())
Definition: expr.h:424
Expr makeLOr(T &&lhs, U &&rhs, std::source_location loc=std::source_location::current())
Definition: expr.h:466
Expr makeSquare(T &&expr, std::source_location loc=std::source_location::current())
Definition: expr.h:546
Ref< MinNode > Min
Definition: expr.h:338
Expr makeLAnd(T &&lhs, U &&rhs, std::source_location loc=std::source_location::current())
Definition: expr.h:452
Expr makeRealDiv(T &&lhs, U &&rhs, std::source_location loc=std::source_location::current())
Definition: expr.h:219
Ref< IntConstNode > IntConst
Definition: expr.h:100
Ref< AnyExprNode > AnyExpr
Definition: expr.h:24
Ref< AbsNode > Abs
Definition: expr.h:628
Expr makeCast(T &&expr, DataType destType, std::source_location loc=std::source_location::current())
Definition: expr.h:728
Ref< EQNode > EQ
Definition: expr.h:422
Expr makeAnyExpr(std::source_location loc=std::source_location::current())
Definition: expr.h:26
Expr makeTan(T &&expr, std::source_location loc=std::source_location::current())
Definition: expr.h:602
Expr makeSub(T &&lhs, U &&rhs, std::source_location loc=std::source_location::current())
Definition: expr.h:188
Expr makeExp(T &&expr, std::source_location loc=std::source_location::current())
Definition: expr.h:518
auto auto && rhs
Definition: const_fold.cc:70
Expr makeGE(T &&lhs, U &&rhs, std::source_location loc=std::source_location::current())
Definition: expr.h:410
Ref< SqrtNode > Sqrt
Definition: expr.h:502
Ref< NonCommutativeBinaryExprNode > NonCommutativeBinaryExpr
Definition: expr.h:166
Expr makeSqrt(T &&expr, std::source_location loc=std::source_location::current())
Definition: expr.h:504
Ref< AddNode > Add
Definition: expr.h:172
Expr makeFloor(T &&expr, std::source_location loc=std::source_location::current())
Definition: expr.h:644
Expr makeVar(const std::string &name, std::source_location loc=std::source_location::current())
Definition: expr.h:42
Ref< ExprNode > Expr
Definition: ast.h:184
Expr makeBoolConst(bool val, std::source_location loc=std::source_location::current())
Definition: expr.h:136
Ref< UnboundNode > Unbound
Definition: expr.h:683
Expr makeIntConst(int64_t val, std::source_location loc=std::source_location::current())
Definition: expr.h:102
Expr makeLNot(T &&expr, std::source_location loc=std::source_location::current())
Definition: expr.h:490
Ref< ModNode > Mod
Definition: expr.h:301
Expr makeFloatConst(double val, std::source_location loc=std::source_location::current())
Definition: expr.h:119
Ref< LOrNode > LOr
Definition: expr.h:464
Ref< CosNode > Cos
Definition: expr.h:586
Ref< SinNode > Sin
Definition: expr.h:572
Expr makeRoundTowards0Div(T &&lhs, U &&rhs, std::source_location loc=std::source_location::current())
Definition: expr.h:279
Ref< LENode > LE
Definition: expr.h:380
Ref< CommutativeBinaryExprNode > CommutativeBinaryExpr
Definition: expr.h:159
Ref< FloatConstNode > FloatConst
Definition: expr.h:117
Ref< ExpNode > Exp
Definition: expr.h:516
ASTNodeType
Definition: ast.h:20
Ref< LnNode > Ln
Definition: expr.h:530
Expr makeMax(T &&lhs, U &&rhs, std::source_location loc=std::source_location::current())
Definition: expr.h:354
Definition: sub_tree.h:20