This is part of the Backend refactoring in #1227.
The goal is to have the Backend sub-classes represent the hardware abstraction layer. The instances hold no mutable state, and all actions are performed through const virtual functions.
Proposed interface:
class Backend {
virtual bool transformPreLowering(Function *F, CompilationMode mode) const;
virtual bool transformPostLowering(Function *F, CompilationMode mode) const;
virtual bool isOpSupported(Kinded::Kind opKind, ElemKind elementTy) const;
virtual bool shouldLower(const Node *N) const;
virtual bool shouldShareBuffers() const;
/// Compile an IR function, consuming it in the process.
/// Returns a new object representing the compiled function.
virtual unique_ptr<CompiledFunction> compileFunction(unique_ptr<IRFunction>) const;
}
class CompiledFunction {
virtual void execute() =0;
}
Refactoring steps:
transformPreLowering and friends to be const.CompiledFunction sub-class per backend which holds the result of compiling a function.Backend sub-classes into a locally defined class that only exists during compileFunction().IRFunction pointer from backend instances and the createBackend() function.At this stage, the CompiledFunction sub-classes will still reference the original module, and their execute method can modify variables in the module.
I believe this is done; Backend is now a pure stateless abstraction layer.
Most helpful comment
I believe this is done; Backend is now a pure stateless abstraction layer.