1 //===---- RISCVISelDAGToDAG.h - A dag to dag inst selector for RISCV ------===//
3 // Part of the LLVM Project, under the Apache License v2.0 with LLVM Exceptions.
4 // See https://llvm.org/LICENSE.txt for license information.
5 // SPDX-License-Identifier: Apache-2.0 WITH LLVM-exception
7 //===----------------------------------------------------------------------===//
9 // This file defines an instruction selector for the RISCV target.
11 //===----------------------------------------------------------------------===//
13 #ifndef LLVM_LIB_TARGET_RISCV_RISCVISELDAGTODAG_H
14 #define LLVM_LIB_TARGET_RISCV_RISCVISELDAGTODAG_H
17 #include "RISCVTargetMachine.h"
18 #include "llvm/CodeGen/SelectionDAGISel.h"
20 // RISCV-specific code to select RISCV machine instructions for
21 // SelectionDAG operations.
23 class RISCVDAGToDAGISel : public SelectionDAGISel {
24 const RISCVSubtarget *Subtarget = nullptr;
27 explicit RISCVDAGToDAGISel(RISCVTargetMachine &TargetMachine)
28 : SelectionDAGISel(TargetMachine) {}
30 StringRef getPassName() const override {
31 return "RISCV DAG->DAG Pattern Instruction Selection";
34 bool runOnMachineFunction(MachineFunction &MF) override {
35 Subtarget = &MF.getSubtarget<RISCVSubtarget>();
36 return SelectionDAGISel::runOnMachineFunction(MF);
39 void PostprocessISelDAG() override;
41 void Select(SDNode *Node) override;
43 bool SelectInlineAsmMemoryOperand(const SDValue &Op, unsigned ConstraintID,
44 std::vector<SDValue> &OutOps) override;
46 bool SelectAddrFI(SDValue Addr, SDValue &Base);
48 bool SelectSLOI(SDValue N, SDValue &RS1, SDValue &Shamt);
49 bool SelectSROI(SDValue N, SDValue &RS1, SDValue &Shamt);
50 bool SelectRORI(SDValue N, SDValue &RS1, SDValue &Shamt);
51 bool SelectSLLIUW(SDValue N, SDValue &RS1, SDValue &Shamt);
52 bool SelectSLOIW(SDValue N, SDValue &RS1, SDValue &Shamt);
53 bool SelectSROIW(SDValue N, SDValue &RS1, SDValue &Shamt);
54 bool SelectRORIW(SDValue N, SDValue &RS1, SDValue &Shamt);
55 bool SelectFSRIW(SDValue N, SDValue &RS1, SDValue &RS2, SDValue &Shamt);
57 // Include the pieces autogenerated from the target description.
58 #include "RISCVGenDAGISel.inc"
61 void doPeepholeLoadStoreADDI();