Legalization in GlobalISel
In GlobalISel, all the legalization decisions and the implementation of the custom legalization are described with your target-specific instance of the LegalizerInfo
class.
Your job is to implement that class and to connect it to your Subtarget
class for the Legalizer
pass to automatically find it. The connection in your Subtarget
class simply consists of overriding the getLegalizerInfo
method:
class H2BLBSubtarget : public H2BLBGenSubtargetInfo {
...
std::unique_ptr<LegalizerInfo> Legalizer;
public:
H2BLBSubtarget::H2BLBSubtarget(/*...*/ {
Legalizer.reset(new H2BLBLegalizerInfo(*this));
}
const LegalizerInfo *getLegalizerInfo() const override {
return Legalizer.get();
}`
In this snippet, we create an H2BLBLegalizerInfo
instance, our implementation of the LegalizerInfo
class, in the constructor of our Subtarget
class and we provide it in the overridden getter.
Focusing on the implementation of your LegalizerInfo...