-
Notifications
You must be signed in to change notification settings - Fork 447
/
Copy pathexpression.def
653 lines (595 loc) · 23.5 KB
/
expression.def
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
141
142
143
144
145
146
147
148
149
150
151
152
153
154
155
156
157
158
159
160
161
162
163
164
165
166
167
168
169
170
171
172
173
174
175
176
177
178
179
180
181
182
183
184
185
186
187
188
189
190
191
192
193
194
195
196
197
198
199
200
201
202
203
204
205
206
207
208
209
210
211
212
213
214
215
216
217
218
219
220
221
222
223
224
225
226
227
228
229
230
231
232
233
234
235
236
237
238
239
240
241
242
243
244
245
246
247
248
249
250
251
252
253
254
255
256
257
258
259
260
261
262
263
264
265
266
267
268
269
270
271
272
273
274
275
276
277
278
279
280
281
282
283
284
285
286
287
288
289
290
291
292
293
294
295
296
297
298
299
300
301
302
303
304
305
306
307
308
309
310
311
312
313
314
315
316
317
318
319
320
321
322
323
324
325
326
327
328
329
330
331
332
333
334
335
336
337
338
339
340
341
342
343
344
345
346
347
348
349
350
351
352
353
354
355
356
357
358
359
360
361
362
363
364
365
366
367
368
369
370
371
372
373
374
375
376
377
378
379
380
381
382
383
384
385
386
387
388
389
390
391
392
393
394
395
396
397
398
399
400
401
402
403
404
405
406
407
408
409
410
411
412
413
414
415
416
417
418
419
420
421
422
423
424
425
426
427
428
429
430
431
432
433
434
435
436
437
438
439
440
441
442
443
444
445
446
447
448
449
450
451
452
453
454
455
456
457
458
459
460
461
462
463
464
465
466
467
468
469
470
471
472
473
474
475
476
477
478
479
480
481
482
483
484
485
486
487
488
489
490
491
492
493
494
495
496
497
498
499
500
501
502
503
504
505
506
507
508
509
510
511
512
513
514
515
516
517
518
519
520
521
522
523
524
525
526
527
528
529
530
531
532
533
534
535
536
537
538
539
540
541
542
543
544
545
546
547
548
549
550
551
552
553
554
555
556
557
558
559
560
561
562
563
564
565
566
567
568
569
570
571
572
573
574
575
576
577
578
579
580
581
582
583
584
585
586
587
588
589
590
591
592
593
594
595
596
597
598
599
600
601
602
603
604
605
606
607
608
609
610
611
612
613
614
615
616
617
618
619
620
621
622
623
624
625
626
627
628
629
630
631
632
633
634
635
636
637
638
639
640
641
642
643
644
645
646
647
648
649
650
651
652
653
/* -*-C++-*- */
/* This file contains the IR classes for all expressions.
The base classes are in base.def */
/** \addtogroup irdefs
* @{
*/
abstract Operation_Unary : Operation {
Expression expr;
inline Operation_Unary {
if (!srcInfo && expr) srcInfo = expr->srcInfo;
if (type->is<Type::Unknown>() && expr) type = expr->type; }
precedence = DBPrint::Prec_Prefix;
toString{ return getStringOp() + expr->toString(); }
}
class Neg : Operation_Unary {
stringOp = "-";
}
class UPlus : Operation_Unary {
stringOp = "+";
}
class Cmpl : Operation_Unary {
stringOp = "~";
}
class LNot : Operation_Unary {
stringOp = "!";
LNot {
// This sets the type only when no type is explicitly provided in the constructor.
// If a type is provided in the constructor this assignment has no effect
// because the type member is shadowed by the type parameter.
type = Type::Boolean::get();
}
}
abstract Operation_Binary : Operation {
Expression left;
Expression right;
inline Operation_Binary {
if (!srcInfo && left && right) srcInfo = left->srcInfo + right->srcInfo;
if (type->is<Type::Unknown>() && left && right && left->type == right->type)
type = left->type; }
toString {
// FIXME: Do not use debug printing to render user-side strings
std::stringstream tmp;
tmp << DBPrint::Prec_Low;
dbprint(tmp);
return tmp.str();
}
}
abstract Operation_Ternary : Operation {
Expression e0;
Expression e1;
Expression e2;
inline Operation_Ternary { if (!srcInfo && e0 && e2) srcInfo = e0->srcInfo + e2->srcInfo; }
}
abstract Operation_Relation : Operation_Binary {
inline Operation_Relation {
// This sets the type only when no type is explicitly provided in the constructor.
// If a type is provided in the constructor this assignment has no effect
// because the type member is shadowed by the type parameter.
type = Type::Boolean::get();
}
}
class Mul : Operation_Binary {
stringOp = "*";
precedence = DBPrint::Prec_Mul;
}
class Div : Operation_Binary {
stringOp = "/";
precedence = DBPrint::Prec_Div;
}
class Mod : Operation_Binary {
stringOp = "%";
precedence = DBPrint::Prec_Mod;
}
class Add : Operation_Binary {
stringOp = "+";
precedence = DBPrint::Prec_Add;
}
class Sub : Operation_Binary {
stringOp = "-";
precedence = DBPrint::Prec_Sub;
}
class AddSat : Operation_Binary {
stringOp = "|+|";
precedence = DBPrint::Prec_AddSat;
}
class SubSat : Operation_Binary {
stringOp = "|-|";
precedence = DBPrint::Prec_SubSat;
}
class Shl : Operation_Binary {
stringOp = "<<";
precedence = DBPrint::Prec_Shl;
inline Shl { if (type->is<Type::Unknown>() && left) type = left->type; }
}
class Shr : Operation_Binary {
stringOp = ">>";
precedence = DBPrint::Prec_Shr;
inline Shr { if (type->is<Type::Unknown>() && left) type = left->type; }
}
class Equ : Operation_Relation {
stringOp = "==";
precedence = DBPrint::Prec_Equ;
}
class Neq : Operation_Relation {
stringOp = "!=";
precedence = DBPrint::Prec_Neq;
}
class Lss : Operation_Relation {
stringOp = "<";
precedence = DBPrint::Prec_Lss;
}
class Leq : Operation_Relation {
stringOp = "<=";
precedence = DBPrint::Prec_Leq;
}
class Grt : Operation_Relation {
stringOp = ">";
precedence = DBPrint::Prec_Grt;
}
class Geq : Operation_Relation {
stringOp = ">=";
precedence = DBPrint::Prec_Geq;
}
class BAnd : Operation_Binary {
stringOp = "&";
precedence = DBPrint::Prec_BAnd;
}
class BOr : Operation_Binary {
stringOp = "|";
precedence = DBPrint::Prec_BOr;
}
class BXor : Operation_Binary {
stringOp = "^";
precedence = DBPrint::Prec_BXor;
}
class LAnd : Operation_Binary {
stringOp = "&&";
precedence = DBPrint::Prec_LAnd;
inline LAnd {
// This sets the type only when no type is explicitly provided in the constructor.
// If a type is provided in the constructor this assignment has no effect
// because the type member is shadowed by the type parameter.
type = Type::Boolean::get();
}
}
class LOr : Operation_Binary {
stringOp = "||";
precedence = DBPrint::Prec_LOr;
inline LOr {
// This sets the type only when no type is explicitly provided in the constructor.
// If a type is provided in the constructor this assignment has no effect
// because the type member is shadowed by the type parameter.
type = Type::Boolean::get();
}}
/// Represents the ... default initializer expression
class Dots : Expression {
dbprint { out << "..."; }
toString { return "..."_cs; }
}
/// Represents the ... default initializer expression
/// when used in a StructExpression.
class NamedDots : NamedExpression {
inline NamedDots() : NamedExpression("...", new Dots()) {}
inline NamedDots(Util::SourceInfo srcInfo, Dots dots) : NamedExpression(srcInfo, "..."_cs, dots) { CHECK_NULL(dots); }
inline NamedDots(Util::SourceInfo srcInfo) : NamedExpression(srcInfo, "...", new Dots()) {}
dbprint { out << "..."; }
toString { return "..."_cs; }
}
abstract Literal : Expression, CompileTimeValue {}
/// This is an integer literal on arbitrary-precision.
class Constant : Literal {
big_int value;
optional unsigned base; /// base used when reading/writing
#noconstructor
/// if noWarning is true, no warning is emitted
void handleOverflow(bool noWarning);
// We need to enumerate all the integer types because we need proper 64-bit handling on
// 32-bit systems (which ain't long!) and mpz_import is too big a hammer because and it loses
// the signess of the value.
inline Constant(int v, unsigned base = 10) :
Literal(Type_InfInt::get()), value(v), base(base) {}
inline Constant(unsigned v, unsigned base = 10) :
Literal(Type_InfInt::get()), value(v), base(base) {}
#emit
#if __WORDSIZE == 64
Constant(intmax_t v, unsigned base = 10) :
Literal(Type_InfInt::get()), value(v), base(base) {}
#else
Constant(long v, unsigned base = 10) :
Literal(Type_InfInt::get()), value(v), base(base) {}
Constant(unsigned long v, unsigned base = 10) :
Literal(Type_InfInt::get()), value(v), base(base) {}
Constant(intmax_t v, unsigned base = 10) :
Literal(Type_InfInt::get()), value(v), base(base) {}
#endif
#end
inline Constant(uint64_t v, unsigned base = 10) :
Literal(Type_InfInt::get()), value(v), base(base) {}
inline Constant(big_int v, unsigned base = 10) :
Literal(Type_InfInt::get()), value(v), base(base) {}
inline Constant(Util::SourceInfo si, big_int v, unsigned base = 10) :
Literal(si, Type_InfInt::get()), value(v), base(base) {}
inline Constant(const Type *t, big_int v, unsigned base = 10, bool noWarning = false) :
Literal(t), value(v), base(base) { CHECK_NULL(t); handleOverflow(noWarning); }
inline Constant(Util::SourceInfo si, const Type *t, big_int v,
unsigned base = 10, bool noWarning = false) :
Literal(si, t), value(v), base(base) { CHECK_NULL(t); handleOverflow(noWarning); }
#emit
static Constant GetMask(unsigned width);
#end
/// @return a constant. Any constant returned here is interned. Base is always 10.
static const Constant *get(const Type *t, big_int v, Util::SourceInfo si = {});
inline bool fitsInt() const { return value >= INT_MIN && value <= INT_MAX; }
inline bool fitsLong() const { return value >= LONG_MIN && value <= LONG_MAX; }
inline bool fitsUint() const { return value >= 0 && value <= UINT_MAX; }
inline bool fitsUint64() const { return value >= 0 && value <= UINT64_MAX; }
inline bool fitsInt64() const { return value >= INT64_MIN && value <= INT64_MAX; }
inline long asLong() const {
if (!fitsLong())
::P4::error(ErrorType::ERR_OVERLIMIT, "%1$x: Value too large for long", this);
return static_cast<long>(value); }
inline int asInt() const {
if (!fitsInt())
::P4::error(ErrorType::ERR_OVERLIMIT, "%1$x: Value too large for int", this);
return static_cast<int>(value); }
inline unsigned asUnsigned() const {
if (!fitsUint())
::P4::error(ErrorType::ERR_OVERLIMIT, "%1$x: Value too large for unsigned int", this);
return static_cast<unsigned>(value);
}
inline uint64_t asUint64() const {
if (!fitsUint64())
::P4::error(ErrorType::ERR_OVERLIMIT, "%1$x: Value too large for uint64", this);
return static_cast<uint64_t>(value);
}
inline int64_t asInt64() const {
if (!fitsInt64())
::P4::error(ErrorType::ERR_OVERLIMIT, "%1$x: Value too large for int64", this);
return static_cast<int64_t>(value);
}
// The following operators are only used in special circumstances.
// They do not look at the type when operating. There are separate
// implementations of these computations when doing proper constant folding.
#emit
Constant operator<<(const unsigned &shift) const;
Constant operator>>(const unsigned &shift) const;
Constant operator&(const Constant &c) const;
Constant operator|(const Constant &c) const;
Constant operator^(const Constant &c) const;
Constant operator-(const Constant &c) const;
Constant operator-() const;
#end
toString {
unsigned width;
bool sign;
if (const IR::Type_Bits* tb = type->to<IR::Type_Bits>()) {
width = tb->size;
sign = tb->isSigned;
} else {
width = 0;
sign = false;
}
return Util::toString(value, width, sign, base);
}
visit_children { v.visit(type, "type"); }
}
class BoolLiteral : Literal {
bool value;
toString{ return value ? "true"_cs : "false"_cs; }
/// @return a bool literal. Both booleans are interned.
static const BoolLiteral *get(bool value, const Util::SourceInfo &si = {});
}
class StringLiteral : Literal {
cstring value;
validate{ if (value.isNull()) BUG("null StringLiteral"); }
toString{ return absl::StrCat("\"", value.escapeJson(), "\""); }
inline StringLiteral(ID v) : Literal(v.srcInfo), value(v.name) {}
#emit
operator IR::ID() const { return IR::ID(srcInfo, value); }
#end
/// @returns a string literal. The value is cached.
static const StringLiteral *get(cstring value, const Type *t = Type_String::get(), const Util::SourceInfo &si = {});
}
class PathExpression : Expression {
Path path;
inline PathExpression { if (!srcInfo && path) srcInfo = path->srcInfo; }
inline PathExpression(Type t, IR::ID id) : Expression(id.srcInfo, t), path(new IR::Path(id)) {}
inline PathExpression(IR::ID id) : Expression(id.srcInfo), path(new IR::Path(id)) {}
toString{ return path->toString(); }
}
// enum X { a }
// X.a
// The 'X' portion is a TypeNameExpression
class TypeNameExpression : Expression {
Type typeName;
inline TypeNameExpression { if (!srcInfo && typeName) srcInfo = typeName->srcInfo; }
inline TypeNameExpression(ID id) : Expression(id.srcInfo),
typeName(new IR::Type_Name(new IR::Path(id))) {}
dbprint{ out << typeName; }
toString { return typeName->toString(); }
validate { BUG_CHECK(typeName->is<Type_Name>() || typeName->is<Type_Specialized>(),
"%1% unexpected type in TypeNameExpression", typeName); }
}
abstract AbstractSlice : Operation_Ternary {
virtual unsigned getH() const = 0;
virtual unsigned getL() const = 0;
}
class Slice : AbstractSlice {
precedence = DBPrint::Prec_Postfix;
stringOp = "[:]";
toString{ return absl::StrCat(e0, "[", e1, ":", e2, "]"); }
// After type checking e1 and e2 will be constants
unsigned getH() const override { return e1->checkedTo<IR::Constant>()->asUnsigned(); }
unsigned getL() const override { return e2->checkedTo<IR::Constant>()->asUnsigned(); }
inline Slice(Expression a, int hi, int lo)
: AbstractSlice(IR::Type::Bits::get(hi-lo+1), a, new Constant(hi), new Constant(lo)) {}
inline Slice(Util::SourceInfo si, Expression a, int hi, int lo)
: AbstractSlice(si, IR::Type::Bits::get(hi-lo+1), a, new Constant(hi), new Constant(lo)) {}
inline Slice {
if (type->is<Type::Unknown>() && e1 && e1->is<Constant>() && e2 && e2->is<Constant>())
type = IR::Type::Bits::get(getH() - getL() + 1); }
// make a slice, folding slices on slices and slices on constants automatically
static Expression make(Expression a, unsigned hi, unsigned lo);
}
class PlusSlice : AbstractSlice {
precedence = DBPrint::Prec_Postfix;
stringOp = "[+:]";
toString{ return absl::StrCat(e0, "[", e1, "+:", e2, "]"); }
unsigned getH() const override {
BUG_CHECK(e1->is<IR::Constant>(), "non-const PlusSlice not handled");
return e1->to<IR::Constant>()->asUnsigned() + e2->checkedTo<IR::Constant>()->asUnsigned() - 1; }
unsigned getL() const override {
BUG_CHECK(e1->is<IR::Constant>(), "non-const PlusSlice not handled");
return e1->to<IR::Constant>()->asUnsigned(); }
inline PlusSlice(Expression a, Expression lo, int width)
: AbstractSlice(IR::Type::Bits::get(width), a, lo, new Constant(width)) {}
inline PlusSlice {
if (type->is<Type::Unknown>() && e2 && e2->is<Constant>())
type = IR::Type::Bits::get(e2->to<IR::Constant>()->asUnsigned()); }
}
class Member : Operation_Unary {
precedence = DBPrint::Prec_Postfix;
ID member;
virtual int offset_bits() const;
int lsb() const;
int msb() const;
stringOp = ".";
toString{ return absl::StrCat(expr, ".", member); }
}
class Concat : Operation_Binary {
stringOp = "++";
precedence = DBPrint::Prec_Add;
inline Concat {
if (left && right) {
auto lt = left->type->to<IR::Type::Bits>();
auto rt = right->type->to<IR::Type::Bits>();
if (lt && rt)
type = IR::Type::Bits::get(lt->size + rt->size, lt->isSigned); } }
}
class ArrayIndex : Operation_Binary {
stringOp = "[]";
precedence = DBPrint::Prec_Postfix;
inline ArrayIndex {
if (auto st = left ? left->type->to<IR::Type_Stack>() : nullptr)
type = st->elementType; }
toString{ return absl::StrCat(left, "[", right, "]"); }
}
class Range : Operation_Binary {
stringOp = "..";
precedence = DBPrint::Prec_Low;
inline Range { if (left && type == left->type && !left->type->is<Type::Unknown>())
type = new Type_Set(left->type); }
}
class Mask : Operation_Binary {
stringOp = "&&&";
precedence = DBPrint::Prec_Low;
inline Mask { if (left && type == left->type && !left->type->is<Type::Unknown>())
type = new Type_Set(left->type); }
}
class Mux : Operation_Ternary {
stringOp = "?:";
precedence = DBPrint::Prec_Low;
visit_children {
v.visit(e0, "e0");
SplitFlowVisit<Expression>(v, e1, e2).run_visit(); }
inline Mux { if (type->is<Type::Unknown>() && e1 && e2 && e1->type == e2->type) type = e1->type; }
}
class DefaultExpression : Expression {}
// Two different This should not be equal.
// That's why we use a hidden id field to distinguish them.
class This : Expression {
long id = nextId++;
toString { return "this"_cs; }
private:
static long nextId;
}
class Cast : Operation_Unary {
Type destType = type;
/// These will generally always be the same, except when a cast to a type argument of
/// a generic occurs. Then at some point, the 'destType' will be specialized to a concrete
/// type, and 'type' will only be updated later when type inferencing occurs
precedence = DBPrint::Prec_Prefix;
stringOp = "(cast)";
toString{ return absl::StrCat("(", destType, ")", expr); }
validate{ BUG_CHECK(!destType->is<Type_Unknown>(), "%1%: Cannot cast to unknown type", this); }
}
class SelectCase {
Expression keyset;
PathExpression state;
dbprint { out << keyset << ": " << state; }
}
class SelectExpression : Expression {
ListExpression select;
inline Vector<SelectCase> selectCases;
visit_children {
v.visit(select, "select");
SplitFlowVisitVector<SelectCase>(v, selectCases).run_visit(); }
}
class MethodCallExpression : Expression {
Expression method;
optional Vector<Type> typeArguments = new Vector<Type>;
optional Vector<Argument> arguments = new Vector<Argument>;
toString {
return
absl::StrCat(method, "(",
absl::StrJoin(*arguments, ", ",
[](std::string *out, const Argument *arg) {
absl::StrAppend(out, arg);
}),
")");
}
validate{ typeArguments->check_null(); arguments->check_null(); }
inline MethodCallExpression(Util::SourceInfo si, IR::ID m, std::initializer_list<Argument> a)
: Expression(si), method(new PathExpression(m)), arguments(new Vector<Argument>(a)) {}
inline MethodCallExpression(Util::SourceInfo si, Expression m,
const std::initializer_list<Argument> &a)
: Expression(si), method(m), arguments(new Vector<Argument>(a)) {}
MethodCallExpression(Expression m, const std::initializer_list<const Expression *> &a)
: method(m), arguments(nullptr) {
auto arguments = new Vector<Argument>;
for (auto arg : a) arguments->push_back(new Argument(arg));
this->arguments = arguments; }
}
class ConstructorCallExpression : Expression {
Type constructedType = type; // Either a Type_Name or a Specialized_Type
Vector<Argument> arguments;
toString{ return constructedType->toString(); }
validate{ BUG_CHECK(constructedType->is<Type_Name>() ||
constructedType->is<Type_Specialized>(),
"%1%: unexpected type", constructedType);
arguments->check_null(); }
}
class BaseListExpression : Expression {
inline Vector<Expression> components;
validate { components.check_null(); }
inline size_t size() const { return components.size(); }
inline void push_back(Expression e) { components.push_back(e); }
inline bool containsDots() const {
if (components.empty())
return false;
size_t size = components.size();
return components.at(size - 1)->is<IR::Dots>();
}
toString {
return components.empty() ? "{}" :
absl::StrCat("{ ",
absl::StrJoin(components, ", ",
[](std::string *out, const Expression *comp) {
absl::StrAppend(out, comp);
}),
" }");
}
#nodbprint
}
/// Represents a list of expressions separated by commas
class ListExpression : BaseListExpression {
inline ListExpression {
validate();
if (type->is<Type::Unknown>()) {
Vector<Type> tuple;
for (auto e : components)
tuple.push_back(e->type);
type = new Type_List(tuple); } }
}
/// Represents P4 list expression, not to be confused with
/// ListExpression from above.
class P4ListExpression : BaseListExpression {
Type elementType;
inline P4ListExpression {
validate();
if (type->is<Type::Unknown>()) {
type = new Type_P4List(elementType); } }
}
/// An expression that evaluates to a struct.
class StructExpression : Expression {
/// The struct or header type that is being intialized.
/// May only be known after type checking; so it can be nullptr.
NullOK Type structType;
inline IndexedVector<NamedExpression> components;
validate {
components.check_null(); components.validate();
BUG_CHECK(structType == nullptr || structType->is<IR::Type_Name>() ||
structType->is<IR::Type_Specialized>(),
"%1%: unexpected struct type", this);
}
inline size_t size() const { return components.size(); }
inline NamedExpression getField(cstring name) const {
return components.getDeclaration<NamedExpression>(name); }
inline bool containsDots() const {
if (components.empty())
return false;
size_t size = components.size();
return components.at(size - 1)->is<IR::NamedDots>();
}
toString {
return components.empty() ? "{}" :
absl::StrCat("{ ",
absl::StrJoin(components, ", ",
[](std::string *out, const NamedExpression *comp) {
absl::StrAppend(out, comp, " = ", comp->expression);
}),
" }");
}
}
/// Can be an invalid header or header_union
class Invalid : Expression {
}
/// An expression that evaluates to an invalid header with the specified type.
class InvalidHeader : Expression {
Type headerType;
}
/// An expression that evaluates to an invalid header union with the specified type.
class InvalidHeaderUnion : Expression {
Type headerUnionType;
}
/// An expression that evaluates to a header stack
class HeaderStackExpression : BaseListExpression {
/// May only be known after type checking; so it can be nullptr.
NullOK Type headerStackType;
validate {
components.check_null();
}
}
/// A ListExpression where all the components are compile-time values.
/// This is used by the evaluator pass.
class ListCompileTimeValue : CompileTimeValue {
inline Vector<Node> components;
validate {
for (auto v : components)
BUG_CHECK(v->is<CompileTimeValue>(), "%1%: not a compile-time value", v); }
#nodbprint
}
/// A P4ListExpression where all the components are compile-time values.
/// This is used by the evaluator pass.
class P4ListCompileTimeValue : CompileTimeValue {
inline Vector<Node> components;
validate {
for (auto v : components)
BUG_CHECK(v->is<CompileTimeValue>(), "%1%: not a compile-time value", v); }
#nodbprint
}
/// A StructExpression where all the components are compile-time values.
/// This is used by the evaluator pass.
class StructCompileTimeValue : CompileTimeValue {
inline Vector<Node> components;
validate {
for (auto v : components)
BUG_CHECK(v->is<CompileTimeValue>(), "%1%: not a compile-time value", v); }
#nodbprint
}
/// Experimental: an extern methond/function call with constant arguments to be
/// evaluated at compile time
class CompileTimeMethodCall : MethodCallExpression, CompileTimeValue {
inline CompileTimeMethodCall(MethodCallExpression e) : MethodCallExpression(*e) {}
validate {
for (auto v : *arguments)
BUG_CHECK(v->is<CompileTimeValue>(), "%1%: not a compile-time value", v); }
#nodbprint
}
/// Signifies that a particular expression is a symbolic variable with a label.
/// These variables are intended to be consumed by SMT/SAT solvers.
class SymbolicVariable : Expression {
#noconstructor
/// The label of the symbolic variable.
cstring label;
/// A symbolic variable always has a type and no source info.
inline SymbolicVariable(Type type, cstring label) : Expression(type), label(label) {}
/// Implements comparisons so that SymbolicVariables can be used as map keys.
inline bool operator<(const SymbolicVariable &other) const {
return label < other.label;
}
toString { return absl::StrCat("|", label, "(", type, ")|"); }
dbprint { out << "|" + label +"(" << type << ")|"; }
}
/** @} *//* end group irdefs */