This commit introduces ConstantFoldingPass and revises backend
implementation to use this ConstantFoldingPass pass.
Signed-off-by: Jonghyun Park <jh1302.park@samsung.com>
pipeline.append(make_unique<IndirectCopyEliminationPass>());
pipeline.append(make_unique<IdenticalObjectReductionPass>());
pipeline.append(make_unique<DuplicatedObjectReductionPass>());
+ pipeline.append(make_unique<ConstantFoldingPass>());
// Apply transforms in the pipeline
for (uint32_t n = 0; n < pipeline.size(); ++n)
// that share the same bag as their underlying bag
assert(!has_inout_bag(code(sess)->module()));
- fold_constants(code(sess));
-
// Eliminate dead object
//
// NOTE Dead Object Elimination (DOE) is performed before Copy lowering
#define __CONSTANT_FOLDING_H__
#include "Code.h"
+#include "Pass.h"
namespace enco
{
*/
void fold_constants(enco::Code *);
+struct ConstantFoldingPass final : public Pass
+{
+ PASS_CTOR(ConstantFoldingPass)
+ {
+ // DO NOTHING
+ }
+
+ void run(const SessionID &sess) const override { fold_constants(code(sess)); }
+};
+
} // namespace enco
#endif // __CONSTANT_FOLDING_H__