mirror of
https://github.com/exaloop/codon.git
synced 2025-06-03 15:03:52 +08:00
34 lines
845 B
C
34 lines
845 B
C
|
#pragma once
|
||
|
|
||
|
#include "sir/transform/pass.h"
|
||
|
|
||
|
namespace seq {
|
||
|
namespace ir {
|
||
|
namespace transform {
|
||
|
namespace folding {
|
||
|
|
||
|
/// Constant propagation pass.
|
||
|
class ConstPropPass : public OperatorPass {
|
||
|
private:
|
||
|
/// Key of the reaching definition analysis
|
||
|
std::string reachingDefKey;
|
||
|
/// Key of the global variables analysis
|
||
|
std::string globalVarsKey;
|
||
|
|
||
|
public:
|
||
|
static const std::string KEY;
|
||
|
|
||
|
/// Constructs a constant propagation pass.
|
||
|
/// @param reachingDefKey the reaching definition analysis' key
|
||
|
ConstPropPass(const std::string &reachingDefKey, const std::string &globalVarsKey)
|
||
|
: reachingDefKey(reachingDefKey), globalVarsKey(globalVarsKey) {}
|
||
|
|
||
|
std::string getKey() const override { return KEY; }
|
||
|
void handle(VarValue *v) override;
|
||
|
};
|
||
|
|
||
|
} // namespace folding
|
||
|
} // namespace transform
|
||
|
} // namespace ir
|
||
|
} // namespace seq
|