Plan for Building a Backend in Cranelift
- Create a Folder for the Backend
- Place the new backend directory under
/cranelift/codegen/src/isa
, where each backend resides.
- Place the new backend directory under
- Define Backend and Implement Required Traits
- Ensure the backend implements these essential traits:
TargetIsa
: Specifies the target architecture’s interface.LowerBackend
: Manages instruction lowering for the architecture.
- Ensure the backend implements these essential traits:
- Add Core ISLE Files to the Backend Folder
inst.isle
: Define ISA-specific instructions, encodings and registers for the target architecture using ISLE (Instruction Selection or Lowering Expressions).lower.isle
: Specify instruction selection and CLIF (Cranelift Intermediate Representation) to MachInst (Machine Instructions) lowering rules.
- Implement an ABI for the Target Architecture
- Place the ABI implementation in the appropriate folder within the backend directory.
- Add ISA-Specific Settings
- Define any required ISA-specific settings in
cranelift-codegen-meta
, located at:/cranelift/codegen/meta/src/isa/<arch>
- Define any required ISA-specific settings in
- Include Filetests for Basic Functionality
- Add initial filetests to verify the backend’s basic functionality in:
/cranelift/filetests/filetests/isa/<arch>
- Add initial filetests to verify the backend’s basic functionality in: