2020-03-31 08:28:24 +02: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-02 19:05:33 +01:00
|
|
|
bool SelectRVVBaseAddr(SDValue Addr, SDValue &Base);
|
2020-03-31 08:28:24 +02:00
|
|
|
|
2021-02-12 23:01:28 +01:00
|
|
|
bool selectShiftMask(SDValue N, unsigned ShiftWidth, SDValue &ShAmt);
|
|
|
|
bool selectShiftMaskXLen(SDValue N, SDValue &ShAmt) {
|
|
|
|
return selectShiftMask(N, Subtarget->getXLen(), ShAmt);
|
|
|
|
}
|
|
|
|
bool selectShiftMask32(SDValue N, SDValue &ShAmt) {
|
|
|
|
return selectShiftMask(N, 32, ShAmt);
|
|
|
|
}
|
2021-01-28 05:36:21 +01:00
|
|
|
|
2021-01-05 20:16:50 +01:00
|
|
|
bool MatchSRLIW(SDNode *N) const;
|
|
|
|
bool MatchSLLIUW(SDNode *N) const;
|
|
|
|
|
2021-02-02 08:53:54 +01:00
|
|
|
bool selectVLOp(SDValue N, SDValue &VL);
|
|
|
|
|
2020-12-15 14:05:32 +01:00
|
|
|
bool selectVSplat(SDValue N, SDValue &SplatVal);
|
|
|
|
bool selectVSplatSimm5(SDValue N, SDValue &SplatVal);
|
|
|
|
bool selectVSplatUimm5(SDValue N, SDValue &SplatVal);
|
2020-07-15 12:50:03 +02:00
|
|
|
|
2021-02-12 18:09:22 +01:00
|
|
|
bool selectRVVSimm5(SDValue N, unsigned Width, SDValue &Imm);
|
|
|
|
template <unsigned Width> bool selectRVVSimm5(SDValue N, SDValue &Imm) {
|
|
|
|
return selectRVVSimm5(N, Width, Imm);
|
|
|
|
}
|
|
|
|
|
|
|
|
bool selectRVVUimm5(SDValue N, unsigned Width, SDValue &Imm);
|
|
|
|
template <unsigned Width> bool selectRVVUimm5(SDValue N, SDValue &Imm) {
|
|
|
|
return selectRVVUimm5(N, Width, Imm);
|
|
|
|
}
|
|
|
|
|
2021-01-15 12:29:51 +01:00
|
|
|
void selectVLSEG(SDNode *Node, unsigned IntNo, bool IsStrided);
|
|
|
|
void selectVLSEGMask(SDNode *Node, unsigned IntNo, bool IsStrided);
|
2021-01-24 06:37:38 +01:00
|
|
|
void selectVLSEGFF(SDNode *Node);
|
|
|
|
void selectVLSEGFFMask(SDNode *Node);
|
2021-01-18 03:02:40 +01:00
|
|
|
void selectVLXSEG(SDNode *Node, unsigned IntNo);
|
|
|
|
void selectVLXSEGMask(SDNode *Node, unsigned IntNo);
|
2021-01-16 14:40:41 +01:00
|
|
|
void selectVSSEG(SDNode *Node, unsigned IntNo, bool IsStrided);
|
|
|
|
void selectVSSEGMask(SDNode *Node, unsigned IntNo, bool IsStrided);
|
2021-01-19 03:47:44 +01: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 10:14:15 +01:00
|
|
|
|
2020-03-31 08:28:24 +02:00
|
|
|
// Include the pieces autogenerated from the target description.
|
|
|
|
#include "RISCVGenDAGISel.inc"
|
|
|
|
|
|
|
|
private:
|
|
|
|
void doPeepholeLoadStoreADDI();
|
|
|
|
};
|
|
|
|
}
|
|
|
|
|
|
|
|
#endif
|