using TransformFunction =
std::function<Expected<std::unique_ptr<Module>>(std::unique_ptr<Module>)>;
- IRTransformLayer2(ExecutionSession &ES,
- IRLayer &BaseLayer,
- TransformFunction Transform);
+ IRTransformLayer2(ExecutionSession &ES, IRLayer &BaseLayer,
+ TransformFunction Transform = identityTransform);
+
+ void setTransform(TransformFunction Transform) {
+ this->Transform = std::move(Transform);
+ }
void emit(MaterializationResponsibility R, VModuleKey K,
std::unique_ptr<Module> M) override;
+ static std::unique_ptr<Module> identityTransform(std::unique_ptr<Module> M) {
+ return M;
+ }
+
private:
IRLayer &BaseLayer;
TransformFunction Transform;