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-13 09:42:25 +01:00
|
|
|
bool SelectBaseAddr(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-02-22 23:36:44 +01:00
|
|
|
bool selectSExti32(SDValue N, SDValue &Val);
|
2021-02-25 00:55:19 +01:00
|
|
|
bool selectZExti32(SDValue N, SDValue &Val);
|
2021-02-22 23:36:44 +01:00
|
|
|
|
2021-01-05 20:16:50 +01:00
|
|
|
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-02-19 04:00:48 +01:00
|
|
|
void selectVLSEG(SDNode *Node, bool IsMasked, bool IsStrided);
|
2021-02-17 07:58:14 +01:00
|
|
|
void selectVLSEGFF(SDNode *Node, bool IsMasked);
|
2021-02-19 04:00:48 +01:00
|
|
|
void selectVLXSEG(SDNode *Node, bool IsMasked, bool IsOrdered);
|
|
|
|
void selectVSSEG(SDNode *Node, bool IsMasked, bool IsStrided);
|
|
|
|
void selectVSXSEG(SDNode *Node, bool IsMasked, bool IsOrdered);
|
[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();
|
|
|
|
};
|
2021-02-19 04:00:48 +01:00
|
|
|
|
|
|
|
namespace RISCV {
|
|
|
|
struct VLSEGPseudo {
|
|
|
|
uint8_t NF;
|
|
|
|
uint8_t Masked;
|
|
|
|
uint8_t Strided;
|
|
|
|
uint8_t FF;
|
|
|
|
uint8_t SEW;
|
|
|
|
uint8_t LMUL;
|
|
|
|
uint16_t Pseudo;
|
|
|
|
};
|
|
|
|
|
|
|
|
struct VLXSEGPseudo {
|
|
|
|
uint8_t NF;
|
|
|
|
uint8_t Masked;
|
|
|
|
uint8_t Ordered;
|
|
|
|
uint8_t SEW;
|
|
|
|
uint8_t LMUL;
|
|
|
|
uint8_t IndexLMUL;
|
|
|
|
uint16_t Pseudo;
|
|
|
|
};
|
|
|
|
|
|
|
|
struct VSSEGPseudo {
|
|
|
|
uint8_t NF;
|
|
|
|
uint8_t Masked;
|
|
|
|
uint8_t Strided;
|
|
|
|
uint8_t SEW;
|
|
|
|
uint8_t LMUL;
|
|
|
|
uint16_t Pseudo;
|
|
|
|
};
|
|
|
|
|
|
|
|
struct VSXSEGPseudo {
|
|
|
|
uint8_t NF;
|
|
|
|
uint8_t Masked;
|
|
|
|
uint8_t Ordered;
|
|
|
|
uint8_t SEW;
|
|
|
|
uint8_t LMUL;
|
|
|
|
uint8_t IndexLMUL;
|
|
|
|
uint16_t Pseudo;
|
|
|
|
};
|
|
|
|
|
2021-02-22 18:39:56 +01:00
|
|
|
struct VLEPseudo {
|
|
|
|
uint8_t Masked;
|
|
|
|
uint8_t Strided;
|
|
|
|
uint8_t FF;
|
|
|
|
uint8_t SEW;
|
|
|
|
uint8_t LMUL;
|
|
|
|
uint16_t Pseudo;
|
|
|
|
};
|
|
|
|
|
|
|
|
struct VSEPseudo {
|
|
|
|
uint8_t Masked;
|
|
|
|
uint8_t Strided;
|
|
|
|
uint8_t SEW;
|
|
|
|
uint8_t LMUL;
|
|
|
|
uint16_t Pseudo;
|
|
|
|
};
|
|
|
|
|
2021-02-19 19:08:43 +01:00
|
|
|
struct VLX_VSXPseudo {
|
|
|
|
uint8_t Masked;
|
|
|
|
uint8_t Ordered;
|
|
|
|
uint8_t SEW;
|
|
|
|
uint8_t LMUL;
|
|
|
|
uint8_t IndexLMUL;
|
|
|
|
uint16_t Pseudo;
|
|
|
|
};
|
|
|
|
|
2021-02-19 04:00:48 +01:00
|
|
|
#define GET_RISCVVSSEGTable_DECL
|
|
|
|
#define GET_RISCVVLSEGTable_DECL
|
|
|
|
#define GET_RISCVVLXSEGTable_DECL
|
|
|
|
#define GET_RISCVVSXSEGTable_DECL
|
2021-02-22 18:39:56 +01:00
|
|
|
#define GET_RISCVVLETable_DECL
|
|
|
|
#define GET_RISCVVSETable_DECL
|
2021-02-19 19:08:43 +01:00
|
|
|
#define GET_RISCVVLXTable_DECL
|
|
|
|
#define GET_RISCVVSXTable_DECL
|
2021-02-19 04:00:48 +01:00
|
|
|
#include "RISCVGenSearchableTables.inc"
|
|
|
|
} // namespace RISCV
|
|
|
|
|
|
|
|
} // namespace llvm
|
2020-03-31 08:28:24 +02:00
|
|
|
|
|
|
|
#endif
|