Supporting a subtarget
A target may have a subtarget—typically, a variant with instructions—way of handling operands, among others. This subtarget feature can be supported in the LLVM backend. A subtarget may contain some additional instructions, registers, scheduling models, and so on. ARM has subtargets such as NEON and THUMB, while x86 has subtarget features such as SSE, AVX, and so on. The instruction set differs for the subtarget feature, for example, NEON for ARM and SSE/AVX for subtarget features that support vector instructions. SSE and AVX also support the vector instruction set, but their instructions differ from each other.
How to do it…
This recipe will demonstrate how to add a support subtarget feature in the backend. A new class that will inherit the TargetSubtargetInfo
class has to be defined:
Create a new file called
TOYSubtarget.h
:$ vi TOYSubtarget.h
Include the following files:
#include "TOY.h" #include "TOYFrameLowering.h" #include "TOYISelLowering.h" #include "TOYInstrInfo...