80 std::map<const IR::Declaration_Constant *, const IR::Expression *>
constants;
83 bool assignmentTarget;
86 const IR::Expression *
getConstant(
const IR::Expression *expr)
const;
89 const IR::Constant *
cast(
const IR::Constant *node,
unsigned base,
90 const IR::Type_Bits *type)
const;
94 std::function<big_int(big_int, big_int)> func,
bool saturating =
false);
114 Result setContains(
const IR::Expression *keySet,
const IR::Expression *constant)
const;
125 setName(
"DoConstantFolding");
126 assignmentTarget =
false;
131 explicit DoConstantFolding(
const TypeMap *
typeMap,
bool warnings =
true,
132 ConstantFoldingPolicy *policy =
nullptr)
135 DoConstantFolding() : DoConstantFolding(nullptr, nullptr) {}
137 const IR::Node *postorder(IR::Declaration_Constant *d)
override;
138 const IR::Node *postorder(IR::PathExpression *e)
override;
139 const IR::Node *postorder(IR::Cmpl *e)
override;
140 const IR::Node *postorder(IR::Neg *e)
override;
141 const IR::Node *postorder(IR::UPlus *e)
override;
142 const IR::Node *postorder(IR::LNot *e)
override;
143 const IR::Node *postorder(IR::LAnd *e)
override;
144 const IR::Node *postorder(IR::LOr *e)
override;
145 const IR::Node *postorder(IR::Slice *e)
override;
146 const IR::Node *postorder(IR::PlusSlice *e)
override;
147 const IR::Node *postorder(IR::Add *e)
override;
148 const IR::Node *postorder(IR::AddSat *e)
override;
149 const IR::Node *postorder(IR::Sub *e)
override;
150 const IR::Node *postorder(IR::SubSat *e)
override;
151 const IR::Node *postorder(IR::Mul *e)
override;
152 const IR::Node *postorder(IR::Div *e)
override;
153 const IR::Node *postorder(IR::Mod *e)
override;
154 const IR::Node *postorder(IR::BXor *e)
override;
155 const IR::Node *postorder(IR::BAnd *e)
override;
156 const IR::Node *postorder(IR::BOr *e)
override;
157 const IR::Node *postorder(IR::Equ *e)
override;
158 const IR::Node *postorder(IR::Neq *e)
override;
159 const IR::Node *postorder(IR::Lss *e)
override;
160 const IR::Node *postorder(IR::Grt *e)
override;
161 const IR::Node *postorder(IR::Leq *e)
override;
162 const IR::Node *postorder(IR::Geq *e)
override;
163 const IR::Node *postorder(IR::Shl *e)
override;
164 const IR::Node *postorder(IR::Shr *e)
override;
165 const IR::Node *postorder(IR::Concat *e)
override;
166 const IR::Node *postorder(IR::Member *e)
override;
167 const IR::Node *postorder(IR::Cast *e)
override;
168 const IR::Node *postorder(IR::Mux *e)
override;
169 const IR::Node *postorder(IR::Type_Bits *type)
override;
170 const IR::Node *postorder(IR::Type_Varbits *type)
override;
171 const IR::Node *postorder(IR::SelectExpression *e)
override;
172 const IR::Node *postorder(IR::IfStatement *statement)
override;
173 const IR::Node *preorder(IR::AssignmentStatement *statement)
override;
174 const IR::Node *preorder(IR::ArrayIndex *e)
override;
175 const IR::Node *preorder(IR::SwitchCase *c)
override;
176 const IR::BlockStatement *preorder(IR::BlockStatement *bs)
override {
177 if (bs->annotations->getSingle(
"disable_optimization"_cs)) prune();
const IR::Node * binary(const IR::Operation_Binary *op, std::function< big_int(big_int, big_int)> func, bool saturating=false)
Statically evaluate binary operation e implemented by func.
Definition constantFolding.cpp:501
const IR::Constant * cast(const IR::Constant *node, unsigned base, const IR::Type_Bits *type) const
Statically cast constant node to type represented in the specified base.
Definition constantFolding.cpp:342
Visitor mixin for looking up names in enclosing scopes from the Visitor::Context.
Definition resolveReferences.h:35