2020-03-31 14:28:24 +08:00
|
|
|
//===---- RISCVISelDAGToDAG.h - A dag to dag inst selector for RISCV ------===//
|
|
|
|
//
|
|
|
|
// Part of the LLVM Project, under the Apache License v2.0 with LLVM Exceptions.
|
|
|
|
// See https://llvm.org/LICENSE.txt for license information.
|
|
|
|
// SPDX-License-Identifier: Apache-2.0 WITH LLVM-exception
|
|
|
|
//
|
|
|
|
//===----------------------------------------------------------------------===//
|
|
|
|
//
|
|
|
|
// This file defines an instruction selector for the RISCV target.
|
|
|
|
//
|
|
|
|
//===----------------------------------------------------------------------===//
|
|
|
|
|
|
|
|
#ifndef LLVM_LIB_TARGET_RISCV_RISCVISELDAGTODAG_H
|
|
|
|
#define LLVM_LIB_TARGET_RISCV_RISCVISELDAGTODAG_H
|
|
|
|
|
|
|
|
#include "RISCV.h"
|
|
|
|
#include "RISCVTargetMachine.h"
|
|
|
|
#include "llvm/CodeGen/SelectionDAGISel.h"
|
|
|
|
|
|
|
|
// RISCV-specific code to select RISCV machine instructions for
|
|
|
|
// SelectionDAG operations.
|
|
|
|
namespace llvm {
|
|
|
|
class RISCVDAGToDAGISel : public SelectionDAGISel {
|
|
|
|
const RISCVSubtarget *Subtarget = nullptr;
|
|
|
|
|
|
|
|
public:
|
|
|
|
explicit RISCVDAGToDAGISel(RISCVTargetMachine &TargetMachine)
|
|
|
|
: SelectionDAGISel(TargetMachine) {}
|
|
|
|
|
|
|
|
StringRef getPassName() const override {
|
|
|
|
return "RISCV DAG->DAG Pattern Instruction Selection";
|
|
|
|
}
|
|
|
|
|
|
|
|
bool runOnMachineFunction(MachineFunction &MF) override {
|
|
|
|
Subtarget = &MF.getSubtarget<RISCVSubtarget>();
|
|
|
|
return SelectionDAGISel::runOnMachineFunction(MF);
|
|
|
|
}
|
|
|
|
|
|
|
|
void PostprocessISelDAG() override;
|
|
|
|
|
|
|
|
void Select(SDNode *Node) override;
|
|
|
|
|
|
|
|
bool SelectInlineAsmMemoryOperand(const SDValue &Op, unsigned ConstraintID,
|
|
|
|
std::vector<SDValue> &OutOps) override;
|
|
|
|
|
|
|
|
bool SelectAddrFI(SDValue Addr, SDValue &Base);
|
2021-02-03 02:05:33 +08:00
|
|
|
bool SelectRVVBaseAddr(SDValue Addr, SDValue &Base);
|
2020-03-31 14:28:24 +08:00
|
|
|
|
2021-01-28 12:36:21 +08:00
|
|
|
bool isUnneededShiftMask(SDNode *N, unsigned Width) const;
|
|
|
|
|
2021-01-06 03:16:50 +08:00
|
|
|
bool MatchSRLIW(SDNode *N) const;
|
|
|
|
bool MatchSLOI(SDNode *N) const;
|
|
|
|
bool MatchSROI(SDNode *N) const;
|
|
|
|
bool MatchSROIW(SDNode *N) const;
|
|
|
|
bool MatchSLLIUW(SDNode *N) const;
|
|
|
|
|
2021-02-02 15:53:54 +08:00
|
|
|
bool selectVLOp(SDValue N, SDValue &VL);
|
|
|
|
|
2020-12-15 21:05:32 +08:00
|
|
|
bool selectVSplat(SDValue N, SDValue &SplatVal);
|
|
|
|
bool selectVSplatSimm5(SDValue N, SDValue &SplatVal);
|
|
|
|
bool selectVSplatUimm5(SDValue N, SDValue &SplatVal);
|
2020-07-15 18:50:03 +08:00
|
|
|
|
2021-01-15 19:29:51 +08:00
|
|
|
void selectVLSEG(SDNode *Node, unsigned IntNo, bool IsStrided);
|
|
|
|
void selectVLSEGMask(SDNode *Node, unsigned IntNo, bool IsStrided);
|
2021-01-24 13:37:38 +08:00
|
|
|
void selectVLSEGFF(SDNode *Node);
|
|
|
|
void selectVLSEGFFMask(SDNode *Node);
|
2021-01-18 10:02:40 +08:00
|
|
|
void selectVLXSEG(SDNode *Node, unsigned IntNo);
|
|
|
|
void selectVLXSEGMask(SDNode *Node, unsigned IntNo);
|
2021-01-16 21:40:41 +08:00
|
|
|
void selectVSSEG(SDNode *Node, unsigned IntNo, bool IsStrided);
|
|
|
|
void selectVSSEGMask(SDNode *Node, unsigned IntNo, bool IsStrided);
|
2021-01-19 10:47:44 +08:00
|
|
|
void selectVSXSEG(SDNode *Node, unsigned IntNo);
|
|
|
|
void selectVSXSEGMask(SDNode *Node, unsigned IntNo);
|
[RISCV] Implement vlseg intrinsics.
For Zvlsseg, we need continuous vector registers for the values. We need
to define new register classes for the different combinations of (number
of fields and LMUL). For example,
when the number of fields(NF) = 3, LMUL = 2, the values will be assigned
to (V0M2, V2M2, V4M2), (V2M2, V4M2, V6M2), (V4M2, V6M2, V8M2), ...
We define the vlseg intrinsics with multiple outputs. There is no way to
describe the codegen patterns with multiple outputs in the tablegen
files. We do the codegen in RISCVISelDAGToDAG and use EXTRACT_SUBREG to
extract the values of output.
The multiple scalable vector values will be put into a struct. This
patch is depended on the support for scalable vector struct.
Differential Revision: https://reviews.llvm.org/D94229
2020-12-31 17:14:15 +08:00
|
|
|
|
2020-03-31 14:28:24 +08:00
|
|
|
// Include the pieces autogenerated from the target description.
|
|
|
|
#include "RISCVGenDAGISel.inc"
|
|
|
|
|
|
|
|
private:
|
|
|
|
void doPeepholeLoadStoreADDI();
|
|
|
|
};
|
|
|
|
}
|
|
|
|
|
|
|
|
#endif
|