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-01-05 20:16:50 +01: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;
|
|
|
|
|
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
|
|
|
|
[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
|
|
|
void selectVLSEG(SDNode *Node, unsigned IntNo);
|
|
|
|
void selectVLSEGMask(SDNode *Node, unsigned IntNo);
|
2021-01-14 10:07:18 +01:00
|
|
|
void selectVSSEG(SDNode *Node, unsigned IntNo);
|
|
|
|
void selectVSSEGMask(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
|