2017-10-20 05:37:38 +08:00
|
|
|
//===-- RISCVISelLowering.h - RISCV DAG Lowering Interface ------*- C++ -*-===//
|
|
|
|
//
|
2019-01-19 16:50:56 +08:00
|
|
|
// 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
|
2017-10-20 05:37:38 +08:00
|
|
|
//
|
|
|
|
//===----------------------------------------------------------------------===//
|
|
|
|
//
|
|
|
|
// This file defines the interfaces that RISCV uses to lower LLVM code into a
|
|
|
|
// selection DAG.
|
|
|
|
//
|
|
|
|
//===----------------------------------------------------------------------===//
|
|
|
|
|
|
|
|
#ifndef LLVM_LIB_TARGET_RISCV_RISCVISELLOWERING_H
|
|
|
|
#define LLVM_LIB_TARGET_RISCV_RISCVISELLOWERING_H
|
|
|
|
|
|
|
|
#include "RISCV.h"
|
2021-05-14 00:34:41 +08:00
|
|
|
#include "llvm/CodeGen/CallingConvLower.h"
|
2017-10-20 05:37:38 +08:00
|
|
|
#include "llvm/CodeGen/SelectionDAG.h"
|
2017-11-17 09:07:10 +08:00
|
|
|
#include "llvm/CodeGen/TargetLowering.h"
|
2017-10-20 05:37:38 +08:00
|
|
|
|
|
|
|
namespace llvm {
|
|
|
|
class RISCVSubtarget;
|
2021-02-18 20:48:14 +08:00
|
|
|
struct RISCVRegisterInfo;
|
2017-10-20 05:37:38 +08:00
|
|
|
namespace RISCVISD {
|
|
|
|
enum NodeType : unsigned {
|
|
|
|
FIRST_NUMBER = ISD::BUILTIN_OP_END,
|
2017-11-08 21:41:21 +08:00
|
|
|
RET_FLAG,
|
[RISCV] Add support for _interrupt attribute
- Save/restore only registers that are used.
This includes Callee saved registers and Caller saved registers
(arguments and temporaries) for integer and FP registers.
- If there is a call in the interrupt handler, save/restore all
Caller saved registers (arguments and temporaries) and all FP registers.
- Emit special return instructions depending on "interrupt"
attribute type.
Based on initial patch by Zhaoshi Zheng.
Reviewers: asb
Reviewed By: asb
Subscribers: rkruppe, the_o, MartinMosbeck, brucehoult, rbar, johnrusso, simoncook, sabuasal, niosHD, kito-cheng, shiva0217, zzheng, edward-jones, mgrang, rogfer01, llvm-commits
Differential Revision: https://reviews.llvm.org/D48411
llvm-svn: 338047
2018-07-27 01:49:43 +08:00
|
|
|
URET_FLAG,
|
|
|
|
SRET_FLAG,
|
|
|
|
MRET_FLAG,
|
2017-11-21 15:51:32 +08:00
|
|
|
CALL,
|
[RISCV] Optimize select_cc after fp compare expansion
Some FP compares expand to a sequence ending with (xor X, 1) to invert the result. If
the consumer is a select_cc we can likely get rid of this xor by fixing
up the select_cc condition.
This patch combines (select_cc (xor X, 1), 0, setne, trueV, falseV) -
(select_cc X, 0, seteq, trueV, falseV) if we can prove X is 0/1.
Reviewed By: lenary
Differential Revision: https://reviews.llvm.org/D94546
2021-01-15 05:41:35 +08:00
|
|
|
/// Select with condition operator - This selects between a true value and
|
|
|
|
/// a false value (ops #3 and #4) based on the boolean result of comparing
|
|
|
|
/// the lhs and rhs (ops #0 and #1) of a conditional expression with the
|
|
|
|
/// condition code in op #2, a XLenVT constant from the ISD::CondCode enum.
|
|
|
|
/// The lhs and rhs are XLenVT integers. The true and false values can be
|
|
|
|
/// integer or floating point.
|
2018-04-12 13:34:25 +08:00
|
|
|
SELECT_CC,
|
2021-03-16 02:44:59 +08:00
|
|
|
BR_CC,
|
2018-04-12 13:34:25 +08:00
|
|
|
BuildPairF64,
|
2018-05-24 06:44:08 +08:00
|
|
|
SplitF64,
|
2019-01-25 13:04:00 +08:00
|
|
|
TAIL,
|
2021-04-02 00:41:36 +08:00
|
|
|
// Multiply high for signedxunsigned.
|
|
|
|
MULHSU,
|
2019-01-25 13:04:00 +08:00
|
|
|
// RV64I shifts, directly matching the semantics of the named RISC-V
|
|
|
|
// instructions.
|
|
|
|
SLLW,
|
|
|
|
SRAW,
|
2019-01-25 13:11:34 +08:00
|
|
|
SRLW,
|
|
|
|
// 32-bit operations from RV64M that can't be simply matched with a pattern
|
2021-01-26 01:35:14 +08:00
|
|
|
// at instruction selection time. These have undefined behavior for division
|
|
|
|
// by 0 or overflow (divw) like their target independent counterparts.
|
2019-01-25 13:11:34 +08:00
|
|
|
DIVW,
|
|
|
|
DIVUW,
|
2019-02-01 06:48:38 +08:00
|
|
|
REMUW,
|
2020-11-21 02:11:34 +08:00
|
|
|
// RV64IB rotates, directly matching the semantics of the named RISC-V
|
|
|
|
// instructions.
|
|
|
|
ROLW,
|
|
|
|
RORW,
|
2021-04-01 00:27:22 +08:00
|
|
|
// RV64IZbb bit counting instructions directly matching the semantics of the
|
|
|
|
// named RISC-V instructions.
|
|
|
|
CLZW,
|
|
|
|
CTZW,
|
2021-02-01 09:37:44 +08:00
|
|
|
// RV64IB/RV32IB funnel shifts, with the semantics of the named RISC-V
|
|
|
|
// instructions, but the same operand order as fshl/fshr intrinsics.
|
|
|
|
FSR,
|
|
|
|
FSL,
|
2020-11-26 01:43:16 +08:00
|
|
|
// RV64IB funnel shifts, with the semantics of the named RISC-V instructions,
|
|
|
|
// but the same operand order as fshl/fshr intrinsics.
|
|
|
|
FSRW,
|
|
|
|
FSLW,
|
2020-07-03 22:57:59 +08:00
|
|
|
// FPR<->GPR transfer operations when the FPR is smaller than XLEN, needed as
|
|
|
|
// XLEN is the only legal integer width.
|
|
|
|
//
|
2020-12-04 02:29:10 +08:00
|
|
|
// FMV_H_X matches the semantics of the FMV.H.X.
|
|
|
|
// FMV_X_ANYEXTH is similar to FMV.X.H but has an any-extended result.
|
2020-07-03 22:57:59 +08:00
|
|
|
// FMV_W_X_RV64 matches the semantics of the FMV.W.X.
|
2019-02-01 06:48:38 +08:00
|
|
|
// FMV_X_ANYEXTW_RV64 is similar to FMV.X.W but has an any-extended result.
|
2020-07-03 22:57:59 +08:00
|
|
|
//
|
2019-02-01 06:48:38 +08:00
|
|
|
// This is a more convenient semantic for producing dagcombines that remove
|
|
|
|
// unnecessary GPR->FPR->GPR moves.
|
2020-12-04 02:29:10 +08:00
|
|
|
FMV_H_X,
|
|
|
|
FMV_X_ANYEXTH,
|
2019-02-01 06:48:38 +08:00
|
|
|
FMV_W_X_RV64,
|
[RISCV] Support @llvm.readcyclecounter() Intrinsic
On RISC-V, the `cycle` CSR holds a 64-bit count of the number of clock
cycles executed by the core, from an arbitrary point in the past. This
matches the intended semantics of `@llvm.readcyclecounter()`, which we
currently leave to the default lowering (to the constant 0).
With this patch, we will now correctly lower this intrinsic to the
intended semantics, using the user-space instruction `rdcycle`. On
64-bit targets, we can directly lower to this instruction.
On 32-bit targets, we need to do more, as `rdcycle` only returns the low
32-bits of the `cycle` CSR. In this case, we perform a custom lowering,
based on the PowerPC lowering, using `rdcycleh` to obtain the high
32-bits of the `cycle` CSR. This custom lowering inserts a new basic
block which detects overflow in the high 32-bits of the `cycle` CSR
during reading (because multiple instructions are required to read). The
emitted assembly matches the suggested assembly in the RISC-V
specification.
Differential Revision: https://reviews.llvm.org/D64125
llvm-svn: 365201
2019-07-05 20:35:21 +08:00
|
|
|
FMV_X_ANYEXTW_RV64,
|
|
|
|
// READ_CYCLE_WIDE - A read of the 64-bit cycle CSR on a 32-bit target
|
|
|
|
// (returns (Lo, Hi)). It takes a chain operand.
|
2020-11-11 21:41:55 +08:00
|
|
|
READ_CYCLE_WIDE,
|
|
|
|
// Generalized Reverse and Generalized Or-Combine - directly matching the
|
|
|
|
// semantics of the named RISC-V instructions. Lowered as custom nodes as
|
|
|
|
// TableGen chokes when faced with commutative permutations in deeply-nested
|
2021-04-13 22:54:24 +08:00
|
|
|
// DAGs. Each node takes an input operand and a control operand and outputs a
|
|
|
|
// bit-manipulated version of input. All operands are i32 or XLenVT.
|
|
|
|
GREV,
|
|
|
|
GREVW,
|
|
|
|
GORC,
|
|
|
|
GORCW,
|
2021-04-13 14:27:44 +08:00
|
|
|
SHFL,
|
2021-04-23 07:19:15 +08:00
|
|
|
SHFLW,
|
|
|
|
UNSHFL,
|
|
|
|
UNSHFLW,
|
2021-04-26 09:49:40 +08:00
|
|
|
// Bit Compress/Decompress implement the generic bit extract and bit deposit
|
|
|
|
// functions. This operation is also referred to as bit gather/scatter, bit
|
|
|
|
// pack/unpack, parallel extract/deposit, compress/expand, or right
|
|
|
|
// compress/right expand.
|
|
|
|
BCOMPRESS,
|
|
|
|
BCOMPRESSW,
|
|
|
|
BDECOMPRESS,
|
|
|
|
BDECOMPRESSW,
|
2020-12-19 01:50:23 +08:00
|
|
|
// Vector Extension
|
2021-02-09 02:59:38 +08:00
|
|
|
// VMV_V_X_VL matches the semantics of vmv.v.x but includes an extra operand
|
|
|
|
// for the VL value to be used for the operation.
|
|
|
|
VMV_V_X_VL,
|
|
|
|
// VFMV_V_F_VL matches the semantics of vfmv.v.f but includes an extra operand
|
|
|
|
// for the VL value to be used for the operation.
|
|
|
|
VFMV_V_F_VL,
|
2021-01-31 00:53:32 +08:00
|
|
|
// VMV_X_S matches the semantics of vmv.x.s. The result is always XLenVT sign
|
|
|
|
// extended from the vector element size.
|
2020-12-19 01:50:23 +08:00
|
|
|
VMV_X_S,
|
2021-04-06 03:54:49 +08:00
|
|
|
// VMV_S_X_VL matches the semantics of vmv.s.x. It carries a VL operand.
|
|
|
|
VMV_S_X_VL,
|
|
|
|
// VFMV_S_F_VL matches the semantics of vfmv.s.f. It carries a VL operand.
|
|
|
|
VFMV_S_F_VL,
|
2020-12-15 21:05:32 +08:00
|
|
|
// Splats an i64 scalar to a vector type (with element type i64) where the
|
|
|
|
// scalar is a sign-extended i32.
|
|
|
|
SPLAT_VECTOR_I64,
|
2021-05-27 01:23:30 +08:00
|
|
|
// Splats an 64-bit value that has been split into two i32 parts. This is
|
|
|
|
// expanded late to two scalar stores and a stride 0 vector load.
|
|
|
|
SPLAT_VECTOR_SPLIT_I64_VL,
|
2021-01-14 09:14:45 +08:00
|
|
|
// Read VLENB CSR
|
|
|
|
READ_VLENB,
|
2021-02-23 00:51:24 +08:00
|
|
|
// Truncates a RVV integer vector by one power-of-two. Carries both an extra
|
|
|
|
// mask and VL operand.
|
|
|
|
TRUNCATE_VECTOR_VL,
|
2021-01-12 01:42:05 +08:00
|
|
|
// Matches the semantics of vslideup/vslidedown. The first operand is the
|
2021-02-11 23:01:40 +08:00
|
|
|
// pass-thru operand, the second is the source vector, the third is the
|
|
|
|
// XLenVT index (either constant or non-constant), the fourth is the mask
|
|
|
|
// and the fifth the VL.
|
|
|
|
VSLIDEUP_VL,
|
|
|
|
VSLIDEDOWN_VL,
|
2021-04-08 01:14:59 +08:00
|
|
|
// Matches the semantics of vslide1up/slide1down. The first operand is the
|
|
|
|
// source vector, the second is the XLenVT scalar value. The third and fourth
|
2021-03-08 23:20:37 +08:00
|
|
|
// operands are the mask and VL operands.
|
|
|
|
VSLIDE1UP_VL,
|
2021-04-08 01:14:59 +08:00
|
|
|
VSLIDE1DOWN_VL,
|
2021-02-09 20:09:10 +08:00
|
|
|
// Matches the semantics of the vid.v instruction, with a mask and VL
|
|
|
|
// operand.
|
|
|
|
VID_VL,
|
2021-01-22 22:54:00 +08:00
|
|
|
// Matches the semantics of the vfcnvt.rod function (Convert double-width
|
|
|
|
// float to single-width float, rounding towards odd). Takes a double-width
|
2021-02-23 23:25:26 +08:00
|
|
|
// float vector and produces a single-width float vector. Also has a mask and
|
|
|
|
// VL operand.
|
|
|
|
VFNCVT_ROD_VL,
|
2021-01-28 23:31:27 +08:00
|
|
|
// These nodes match the semantics of the corresponding RVV vector reduction
|
|
|
|
// instructions. They produce a vector result which is the reduction
|
|
|
|
// performed over the first vector operand plus the first element of the
|
|
|
|
// second vector operand. The first operand is an unconstrained vector type,
|
|
|
|
// and the result and second operand's types are expected to be the
|
|
|
|
// corresponding full-width LMUL=1 type for the first operand:
|
|
|
|
// nxv8i8 = vecreduce_add nxv32i8, nxv8i8
|
|
|
|
// nxv2i32 = vecreduce_add nxv8i32, nxv2i32
|
|
|
|
// The different in types does introduce extra vsetvli instructions but
|
|
|
|
// similarly it reduces the number of registers consumed per reduction.
|
2021-03-10 01:33:00 +08:00
|
|
|
// Also has a mask and VL operand.
|
|
|
|
VECREDUCE_ADD_VL,
|
|
|
|
VECREDUCE_UMAX_VL,
|
|
|
|
VECREDUCE_SMAX_VL,
|
|
|
|
VECREDUCE_UMIN_VL,
|
|
|
|
VECREDUCE_SMIN_VL,
|
|
|
|
VECREDUCE_AND_VL,
|
|
|
|
VECREDUCE_OR_VL,
|
|
|
|
VECREDUCE_XOR_VL,
|
|
|
|
VECREDUCE_FADD_VL,
|
|
|
|
VECREDUCE_SEQ_FADD_VL,
|
2021-04-29 18:35:33 +08:00
|
|
|
VECREDUCE_FMIN_VL,
|
|
|
|
VECREDUCE_FMAX_VL,
|
2021-02-09 02:32:32 +08:00
|
|
|
|
2021-02-13 01:20:54 +08:00
|
|
|
// Vector binary and unary ops with a mask as a third operand, and VL as a
|
|
|
|
// fourth operand.
|
2021-02-09 02:32:32 +08:00
|
|
|
// FIXME: Can we replace these with ISD::VP_*?
|
|
|
|
ADD_VL,
|
|
|
|
AND_VL,
|
|
|
|
MUL_VL,
|
|
|
|
OR_VL,
|
|
|
|
SDIV_VL,
|
|
|
|
SHL_VL,
|
|
|
|
SREM_VL,
|
|
|
|
SRA_VL,
|
|
|
|
SRL_VL,
|
|
|
|
SUB_VL,
|
|
|
|
UDIV_VL,
|
|
|
|
UREM_VL,
|
|
|
|
XOR_VL,
|
|
|
|
FADD_VL,
|
|
|
|
FSUB_VL,
|
|
|
|
FMUL_VL,
|
|
|
|
FDIV_VL,
|
|
|
|
FNEG_VL,
|
2021-02-13 07:33:21 +08:00
|
|
|
FABS_VL,
|
2021-02-13 07:10:18 +08:00
|
|
|
FSQRT_VL,
|
2021-02-09 02:45:45 +08:00
|
|
|
FMA_VL,
|
2021-03-12 01:41:39 +08:00
|
|
|
FCOPYSIGN_VL,
|
2021-02-11 20:45:38 +08:00
|
|
|
SMIN_VL,
|
|
|
|
SMAX_VL,
|
|
|
|
UMIN_VL,
|
|
|
|
UMAX_VL,
|
2021-04-22 16:55:27 +08:00
|
|
|
FMINNUM_VL,
|
|
|
|
FMAXNUM_VL,
|
2021-02-19 01:09:33 +08:00
|
|
|
MULHS_VL,
|
|
|
|
MULHU_VL,
|
2021-02-24 18:18:28 +08:00
|
|
|
FP_TO_SINT_VL,
|
|
|
|
FP_TO_UINT_VL,
|
|
|
|
SINT_TO_FP_VL,
|
|
|
|
UINT_TO_FP_VL,
|
2021-02-23 23:25:26 +08:00
|
|
|
FP_ROUND_VL,
|
|
|
|
FP_EXTEND_VL,
|
2021-02-09 02:32:32 +08:00
|
|
|
|
2021-07-07 00:55:57 +08:00
|
|
|
// Widening instructions
|
|
|
|
VWMUL_VL,
|
|
|
|
VWMULU_VL,
|
|
|
|
|
2021-02-13 01:20:54 +08:00
|
|
|
// Vector compare producing a mask. Fourth operand is input mask. Fifth
|
|
|
|
// operand is VL.
|
|
|
|
SETCC_VL,
|
|
|
|
|
2021-02-16 00:38:25 +08:00
|
|
|
// Vector select with an additional VL operand. This operation is unmasked.
|
|
|
|
VSELECT_VL,
|
|
|
|
|
2021-02-16 04:42:33 +08:00
|
|
|
// Mask binary operators.
|
|
|
|
VMAND_VL,
|
|
|
|
VMOR_VL,
|
|
|
|
VMXOR_VL,
|
|
|
|
|
2021-02-09 02:32:32 +08:00
|
|
|
// Set mask vector to all zeros or ones.
|
|
|
|
VMCLR_VL,
|
|
|
|
VMSET_VL,
|
|
|
|
|
2021-03-10 01:43:08 +08:00
|
|
|
// Matches the semantics of vrgather.vx and vrgather.vv with an extra operand
|
|
|
|
// for VL.
|
2021-02-11 01:40:28 +08:00
|
|
|
VRGATHER_VX_VL,
|
2021-03-10 01:43:08 +08:00
|
|
|
VRGATHER_VV_VL,
|
|
|
|
VRGATHEREI16_VV_VL,
|
2021-02-11 01:40:28 +08:00
|
|
|
|
2021-02-17 17:08:24 +08:00
|
|
|
// Vector sign/zero extend with additional mask & VL operands.
|
|
|
|
VSEXT_VL,
|
|
|
|
VZEXT_VL,
|
2021-07-07 00:55:57 +08:00
|
|
|
|
2021-04-07 17:03:22 +08:00
|
|
|
// vpopc.m with additional mask and VL operands.
|
|
|
|
VPOPC_VL,
|
2021-02-17 17:08:24 +08:00
|
|
|
|
2021-03-18 23:07:27 +08:00
|
|
|
// Reads value of CSR.
|
|
|
|
// The first operand is a chain pointer. The second specifies address of the
|
|
|
|
// required CSR. Two results are produced, the read value and the new chain
|
|
|
|
// pointer.
|
|
|
|
READ_CSR,
|
|
|
|
// Write value to CSR.
|
|
|
|
// The first operand is a chain pointer, the second specifies address of the
|
|
|
|
// required CSR and the third is the value to write. The result is the new
|
|
|
|
// chain pointer.
|
|
|
|
WRITE_CSR,
|
|
|
|
// Read and write value of CSR.
|
|
|
|
// The first operand is a chain pointer, the second specifies address of the
|
|
|
|
// required CSR and the third is the value to write. Two results are produced,
|
|
|
|
// the value read before the modification and the new chain pointer.
|
|
|
|
SWAP_CSR,
|
|
|
|
|
2021-02-09 02:32:32 +08:00
|
|
|
// Memory opcodes start here.
|
|
|
|
VLE_VL = ISD::FIRST_TARGET_MEMORY_OPCODE,
|
|
|
|
VSE_VL,
|
|
|
|
|
|
|
|
// WARNING: Do not add anything in the end unless you want the node to
|
|
|
|
// have memop! In fact, starting from FIRST_TARGET_MEMORY_OPCODE all
|
|
|
|
// opcodes will be thought as target memory ops!
|
2017-10-20 05:37:38 +08:00
|
|
|
};
|
2020-11-11 21:41:55 +08:00
|
|
|
} // namespace RISCVISD
|
2017-10-20 05:37:38 +08:00
|
|
|
|
|
|
|
class RISCVTargetLowering : public TargetLowering {
|
|
|
|
const RISCVSubtarget &Subtarget;
|
|
|
|
|
|
|
|
public:
|
|
|
|
explicit RISCVTargetLowering(const TargetMachine &TM,
|
|
|
|
const RISCVSubtarget &STI);
|
|
|
|
|
2020-12-11 15:16:08 +08:00
|
|
|
const RISCVSubtarget &getSubtarget() const { return Subtarget; }
|
|
|
|
|
2018-09-19 18:54:22 +08:00
|
|
|
bool getTgtMemIntrinsic(IntrinsicInfo &Info, const CallInst &I,
|
|
|
|
MachineFunction &MF,
|
|
|
|
unsigned Intrinsic) const override;
|
2018-04-26 20:13:48 +08:00
|
|
|
bool isLegalAddressingMode(const DataLayout &DL, const AddrMode &AM, Type *Ty,
|
|
|
|
unsigned AS,
|
|
|
|
Instruction *I = nullptr) const override;
|
2018-04-26 21:15:17 +08:00
|
|
|
bool isLegalICmpImmediate(int64_t Imm) const override;
|
2018-04-26 21:00:37 +08:00
|
|
|
bool isLegalAddImmediate(int64_t Imm) const override;
|
2018-04-26 21:37:00 +08:00
|
|
|
bool isTruncateFree(Type *SrcTy, Type *DstTy) const override;
|
|
|
|
bool isTruncateFree(EVT SrcVT, EVT DstVT) const override;
|
2018-04-26 22:04:18 +08:00
|
|
|
bool isZExtFree(SDValue Val, EVT VT2) const override;
|
2018-11-30 17:56:54 +08:00
|
|
|
bool isSExtCheaperThanZExt(EVT SrcVT, EVT DstVT) const override;
|
2020-11-10 02:05:51 +08:00
|
|
|
bool isCheapToSpeculateCttz() const override;
|
|
|
|
bool isCheapToSpeculateCtlz() const override;
|
2020-03-20 17:22:48 +08:00
|
|
|
bool isFPImmLegal(const APFloat &Imm, EVT VT,
|
|
|
|
bool ForCodeSize) const override;
|
[RISCV] Support Bit-Preserving FP in F/D Extensions
Summary:
This allows some integer bitwise operations to instead be performed by
hardware fp instructions. This is correct because the RISC-V spec
requires the F and D extensions to use the IEEE-754 standard
representation, and fp register loads and stores to be bit-preserving.
This is tested against the soft-float ABI, but with hardware float
extensions enabled, so that the tests also ensure the optimisation also
fires in this case.
Reviewers: asb, luismarques
Reviewed By: asb
Subscribers: hiraditya, rbar, johnrusso, simoncook, apazos, sabuasal, niosHD, kito-cheng, shiva0217, jrtc27, zzheng, edward-jones, rogfer01, MartinMosbeck, brucehoult, the_o, rkruppe, PkmX, jocewei, psnobl, benna, Jim, llvm-commits
Tags: #llvm
Differential Revision: https://reviews.llvm.org/D62900
llvm-svn: 362790
2019-06-07 20:20:14 +08:00
|
|
|
|
2021-04-02 02:47:11 +08:00
|
|
|
bool softPromoteHalfType() const override { return true; }
|
|
|
|
|
|
|
|
/// Return the register type for a given MVT, ensuring vectors are treated
|
|
|
|
/// as a series of gpr sized integers.
|
|
|
|
MVT getRegisterTypeForCallingConv(LLVMContext &Context, CallingConv::ID CC,
|
|
|
|
EVT VT) const override;
|
|
|
|
|
|
|
|
/// Return the number of registers for a given MVT, ensuring vectors are
|
|
|
|
/// treated as a series of gpr sized integers.
|
|
|
|
unsigned getNumRegistersForCallingConv(LLVMContext &Context,
|
|
|
|
CallingConv::ID CC,
|
|
|
|
EVT VT) const override;
|
|
|
|
|
2021-03-12 08:21:42 +08:00
|
|
|
/// Return true if the given shuffle mask can be codegen'd directly, or if it
|
|
|
|
/// should be stack expanded.
|
|
|
|
bool isShuffleMaskLegal(ArrayRef<int> M, EVT VT) const override;
|
|
|
|
|
[RISCV] Support Bit-Preserving FP in F/D Extensions
Summary:
This allows some integer bitwise operations to instead be performed by
hardware fp instructions. This is correct because the RISC-V spec
requires the F and D extensions to use the IEEE-754 standard
representation, and fp register loads and stores to be bit-preserving.
This is tested against the soft-float ABI, but with hardware float
extensions enabled, so that the tests also ensure the optimisation also
fires in this case.
Reviewers: asb, luismarques
Reviewed By: asb
Subscribers: hiraditya, rbar, johnrusso, simoncook, apazos, sabuasal, niosHD, kito-cheng, shiva0217, jrtc27, zzheng, edward-jones, rogfer01, MartinMosbeck, brucehoult, the_o, rkruppe, PkmX, jocewei, psnobl, benna, Jim, llvm-commits
Tags: #llvm
Differential Revision: https://reviews.llvm.org/D62900
llvm-svn: 362790
2019-06-07 20:20:14 +08:00
|
|
|
bool hasBitPreservingFPLogic(EVT VT) const override;
|
2021-03-01 23:31:56 +08:00
|
|
|
bool
|
|
|
|
shouldExpandBuildVectorWithShuffles(EVT VT,
|
|
|
|
unsigned DefinedValues) const override;
|
2018-04-26 20:13:48 +08:00
|
|
|
|
2017-10-20 05:37:38 +08:00
|
|
|
// Provide custom lowering hooks for some operations.
|
|
|
|
SDValue LowerOperation(SDValue Op, SelectionDAG &DAG) const override;
|
2019-01-25 13:04:00 +08:00
|
|
|
void ReplaceNodeResults(SDNode *N, SmallVectorImpl<SDValue> &Results,
|
|
|
|
SelectionDAG &DAG) const override;
|
2017-10-20 05:37:38 +08:00
|
|
|
|
2018-10-04 07:30:16 +08:00
|
|
|
SDValue PerformDAGCombine(SDNode *N, DAGCombinerInfo &DCI) const override;
|
|
|
|
|
2021-01-16 02:54:26 +08:00
|
|
|
bool targetShrinkDemandedConstant(SDValue Op, const APInt &DemandedBits,
|
|
|
|
const APInt &DemandedElts,
|
|
|
|
TargetLoweringOpt &TLO) const override;
|
|
|
|
|
2021-01-14 09:14:45 +08:00
|
|
|
void computeKnownBitsForTargetNode(const SDValue Op,
|
|
|
|
KnownBits &Known,
|
|
|
|
const APInt &DemandedElts,
|
|
|
|
const SelectionDAG &DAG,
|
|
|
|
unsigned Depth) const override;
|
2019-01-25 13:04:00 +08:00
|
|
|
unsigned ComputeNumSignBitsForTargetNode(SDValue Op,
|
|
|
|
const APInt &DemandedElts,
|
|
|
|
const SelectionDAG &DAG,
|
|
|
|
unsigned Depth) const override;
|
|
|
|
|
2017-10-20 05:37:38 +08:00
|
|
|
// This method returns the name of a target specific DAG node.
|
|
|
|
const char *getTargetNodeName(unsigned Opcode) const override;
|
2018-01-11 04:05:09 +08:00
|
|
|
|
[RISCV] Support 'f' Inline Assembly Constraint
Summary:
This adds the 'f' inline assembly constraint, as supported by GCC. An
'f'-constrained operand is passed in a floating point register. Exactly
which kind of floating-point register (32-bit or 64-bit) is decided
based on the operand type and the available standard extensions (-f and
-d, respectively).
This patch adds support in both the clang frontend, and LLVM itself.
Reviewers: asb, lewis-revill
Reviewed By: asb
Subscribers: hiraditya, rbar, johnrusso, simoncook, apazos, sabuasal, niosHD, kito-cheng, shiva0217, jrtc27, MaskRay, zzheng, edward-jones, rogfer01, MartinMosbeck, brucehoult, the_o, rkruppe, PkmX, jocewei, psnobl, benna, Jim, s.egerton, cfe-commits, llvm-commits
Tags: #clang, #llvm
Differential Revision: https://reviews.llvm.org/D65500
llvm-svn: 367403
2019-07-31 17:45:55 +08:00
|
|
|
ConstraintType getConstraintType(StringRef Constraint) const override;
|
2019-08-16 18:28:34 +08:00
|
|
|
|
|
|
|
unsigned getInlineAsmMemConstraint(StringRef ConstraintCode) const override;
|
|
|
|
|
2018-01-11 04:05:09 +08:00
|
|
|
std::pair<unsigned, const TargetRegisterClass *>
|
|
|
|
getRegForInlineAsmConstraint(const TargetRegisterInfo *TRI,
|
|
|
|
StringRef Constraint, MVT VT) const override;
|
2017-10-20 05:37:38 +08:00
|
|
|
|
2019-06-11 20:42:13 +08:00
|
|
|
void LowerAsmOperandForConstraint(SDValue Op, std::string &Constraint,
|
|
|
|
std::vector<SDValue> &Ops,
|
|
|
|
SelectionDAG &DAG) const override;
|
|
|
|
|
2017-11-21 15:51:32 +08:00
|
|
|
MachineBasicBlock *
|
|
|
|
EmitInstrWithCustomInserter(MachineInstr &MI,
|
|
|
|
MachineBasicBlock *BB) const override;
|
2018-02-02 10:43:18 +08:00
|
|
|
|
|
|
|
EVT getSetCCResultType(const DataLayout &DL, LLVMContext &Context,
|
|
|
|
EVT VT) const override;
|
2017-11-21 15:51:32 +08:00
|
|
|
|
2019-03-22 18:39:22 +08:00
|
|
|
bool convertSetCCLogicToBitwiseLogic(EVT VT) const override {
|
|
|
|
return VT.isScalarInteger();
|
|
|
|
}
|
2020-05-02 22:05:12 +08:00
|
|
|
bool convertSelectOfConstantsToMath(EVT VT) const override { return true; }
|
2019-03-22 18:39:22 +08:00
|
|
|
|
2018-06-13 20:04:51 +08:00
|
|
|
bool shouldInsertFencesForAtomic(const Instruction *I) const override {
|
|
|
|
return isa<LoadInst>(I) || isa<StoreInst>(I);
|
|
|
|
}
|
2021-06-06 04:56:19 +08:00
|
|
|
Instruction *emitLeadingFence(IRBuilderBase &Builder, Instruction *Inst,
|
2018-06-13 20:04:51 +08:00
|
|
|
AtomicOrdering Ord) const override;
|
2021-06-06 04:56:19 +08:00
|
|
|
Instruction *emitTrailingFence(IRBuilderBase &Builder, Instruction *Inst,
|
2018-06-13 20:04:51 +08:00
|
|
|
AtomicOrdering Ord) const override;
|
|
|
|
|
2020-11-26 07:07:34 +08:00
|
|
|
bool isFMAFasterThanFMulAndFAdd(const MachineFunction &MF,
|
|
|
|
EVT VT) const override;
|
|
|
|
|
2019-03-12 05:41:22 +08:00
|
|
|
ISD::NodeType getExtendForAtomicOps() const override {
|
[LegalizeTypes][RISCV] Correctly sign-extend comparison for ATOMIC_CMP_XCHG
Summary:
Currently, the comparison argument used for ATOMIC_CMP_XCHG is legalised
with GetPromotedInteger, which leaves the upper bits of the value
undefind. Since this is used for comparing in an LR/SC loop with a
full-width comparison, we must sign extend it. We introduce a new
getExtendForAtomicCmpSwapArg to complement getExtendForAtomicOps, since
many targets have compare-and-swap instructions (or pseudos) that
correctly handle an any-extend input, and the existing function
determines the extension of the result, whereas we are concerned with
the input.
This is related to https://reviews.llvm.org/D58829, which solved the
issue for ATOMIC_CMP_SWAP_WITH_SUCCESS, but not the simpler
ATOMIC_CMP_SWAP.
Reviewers: asb, lenary, efriedma
Reviewed By: asb
Subscribers: arichardson, hiraditya, rbar, johnrusso, simoncook, sabuasal, niosHD, kito-cheng, shiva0217, MaskRay, zzheng, edward-jones, rogfer01, MartinMosbeck, brucehoult, the_o, rkruppe, jfb, PkmX, jocewei, psnobl, benna, Jim, s.egerton, pzheng, sameer.abuasal, apazos, luismarques, evandro, llvm-commits
Tags: #llvm
Differential Revision: https://reviews.llvm.org/D74453
2020-04-01 22:50:47 +08:00
|
|
|
return ISD::SIGN_EXTEND;
|
|
|
|
}
|
|
|
|
|
|
|
|
ISD::NodeType getExtendForAtomicCmpSwapArg() const override {
|
2019-03-12 05:41:22 +08:00
|
|
|
return ISD::SIGN_EXTEND;
|
|
|
|
}
|
|
|
|
|
2019-04-16 22:38:32 +08:00
|
|
|
bool shouldExpandShift(SelectionDAG &DAG, SDNode *N) const override {
|
|
|
|
if (DAG.getMachineFunction().getFunction().hasMinSize())
|
|
|
|
return false;
|
|
|
|
return true;
|
|
|
|
}
|
[RISCV] Prevent re-ordering some adds after shifts
Summary:
DAGCombine will normally turn a `(shl (add x, c1), c2)` into `(add (shl x, c2), c1 << c2)`, where `c1` and `c2` are constants. This can be prevented by a callback in TargetLowering.
On RISC-V, materialising the constant `c1 << c2` can be more expensive than materialising `c1`, because materialising the former may take more instructions, and may use a register, where materialising the latter would not.
This patch implements the hook in RISCVTargetLowering to prevent this transform, in the cases where:
- `c1` fits into the immediate field in an `addi` instruction.
- `c1` takes fewer instructions to materialise than `c1 << c2`.
In future, DAGCombine could do the check to see whether `c1` fits into an add immediate, which might simplify more targets hooks than just RISC-V.
Reviewers: asb, luismarques, efriedma
Reviewed By: asb
Subscribers: xbolva00, lebedev.ri, craig.topper, lewis-revill, Jim, hiraditya, rbar, johnrusso, simoncook, apazos, sabuasal, niosHD, kito-cheng, shiva0217, jrtc27, zzheng, edward-jones, rogfer01, MartinMosbeck, brucehoult, the_o, rkruppe, PkmX, jocewei, psnobl, benna, llvm-commits
Tags: #llvm
Differential Revision: https://reviews.llvm.org/D62857
llvm-svn: 363736
2019-06-19 04:38:08 +08:00
|
|
|
bool isDesirableToCommuteWithShift(const SDNode *N,
|
|
|
|
CombineLevel Level) const override;
|
2019-04-16 22:38:32 +08:00
|
|
|
|
2019-07-08 17:16:47 +08:00
|
|
|
/// If a physical register, this returns the register that receives the
|
|
|
|
/// exception address on entry to an EH pad.
|
2020-04-08 22:29:30 +08:00
|
|
|
Register
|
2019-07-08 17:16:47 +08:00
|
|
|
getExceptionPointerRegister(const Constant *PersonalityFn) const override;
|
|
|
|
|
|
|
|
/// If a physical register, this returns the register that receives the
|
|
|
|
/// exception typeid on entry to a landing pad.
|
2020-04-08 22:29:30 +08:00
|
|
|
Register
|
2019-07-08 17:16:47 +08:00
|
|
|
getExceptionSelectorRegister(const Constant *PersonalityFn) const override;
|
|
|
|
|
2019-08-29 07:40:37 +08:00
|
|
|
bool shouldExtendTypeInLibCall(EVT Type) const override;
|
2021-01-26 01:16:45 +08:00
|
|
|
bool shouldSignExtendTypeInLibCall(EVT Type, bool IsSigned) const override;
|
2019-08-29 07:40:37 +08:00
|
|
|
|
2019-11-04 19:21:51 +08:00
|
|
|
/// Returns the register with the specified architectural or ABI name. This
|
|
|
|
/// method is necessary to lower the llvm.read_register.* and
|
|
|
|
/// llvm.write_register.* intrinsics. Allocatable registers must be reserved
|
|
|
|
/// with the clang -ffixed-xX flag for access to be allowed.
|
2019-12-28 22:18:56 +08:00
|
|
|
Register getRegisterByName(const char *RegName, LLT VT,
|
2019-11-04 19:21:51 +08:00
|
|
|
const MachineFunction &MF) const override;
|
|
|
|
|
2017-10-20 05:37:38 +08:00
|
|
|
// Lower incoming arguments, copy physregs into vregs
|
|
|
|
SDValue LowerFormalArguments(SDValue Chain, CallingConv::ID CallConv,
|
|
|
|
bool IsVarArg,
|
|
|
|
const SmallVectorImpl<ISD::InputArg> &Ins,
|
|
|
|
const SDLoc &DL, SelectionDAG &DAG,
|
|
|
|
SmallVectorImpl<SDValue> &InVals) const override;
|
2020-05-12 18:49:17 +08:00
|
|
|
bool CanLowerReturn(CallingConv::ID CallConv, MachineFunction &MF,
|
|
|
|
bool IsVarArg,
|
|
|
|
const SmallVectorImpl<ISD::OutputArg> &Outs,
|
|
|
|
LLVMContext &Context) const override;
|
2017-10-20 05:37:38 +08:00
|
|
|
SDValue LowerReturn(SDValue Chain, CallingConv::ID CallConv, bool IsVarArg,
|
|
|
|
const SmallVectorImpl<ISD::OutputArg> &Outs,
|
|
|
|
const SmallVectorImpl<SDValue> &OutVals, const SDLoc &DL,
|
|
|
|
SelectionDAG &DAG) const override;
|
2017-11-08 21:41:21 +08:00
|
|
|
SDValue LowerCall(TargetLowering::CallLoweringInfo &CLI,
|
|
|
|
SmallVectorImpl<SDValue> &InVals) const override;
|
2020-06-10 16:16:09 +08:00
|
|
|
|
2017-10-20 05:37:38 +08:00
|
|
|
bool shouldConvertConstantLoadToIntImm(const APInt &Imm,
|
|
|
|
Type *Ty) const override {
|
|
|
|
return true;
|
|
|
|
}
|
2020-02-18 23:53:26 +08:00
|
|
|
bool mayBeEmittedAsTailCall(const CallInst *CI) const override;
|
2020-06-10 16:16:09 +08:00
|
|
|
bool shouldConsiderGEPOffsetSplit() const override { return true; }
|
|
|
|
|
2020-07-08 09:48:46 +08:00
|
|
|
bool decomposeMulByConstant(LLVMContext &Context, EVT VT,
|
|
|
|
SDValue C) const override;
|
|
|
|
|
2020-06-10 16:16:09 +08:00
|
|
|
TargetLowering::AtomicExpansionKind
|
|
|
|
shouldExpandAtomicRMWInIR(AtomicRMWInst *AI) const override;
|
2021-06-06 04:56:19 +08:00
|
|
|
Value *emitMaskedAtomicRMWIntrinsic(IRBuilderBase &Builder, AtomicRMWInst *AI,
|
2020-06-10 16:16:09 +08:00
|
|
|
Value *AlignedAddr, Value *Incr,
|
|
|
|
Value *Mask, Value *ShiftAmt,
|
|
|
|
AtomicOrdering Ord) const override;
|
|
|
|
TargetLowering::AtomicExpansionKind
|
|
|
|
shouldExpandAtomicCmpXchgInIR(AtomicCmpXchgInst *CI) const override;
|
2021-06-06 04:56:19 +08:00
|
|
|
Value *emitMaskedAtomicCmpXchgIntrinsic(IRBuilderBase &Builder,
|
2020-06-10 16:16:09 +08:00
|
|
|
AtomicCmpXchgInst *CI,
|
|
|
|
Value *AlignedAddr, Value *CmpVal,
|
|
|
|
Value *NewVal, Value *Mask,
|
|
|
|
AtomicOrdering Ord) const override;
|
|
|
|
|
2021-01-27 15:00:46 +08:00
|
|
|
/// Returns true if the target allows unaligned memory accesses of the
|
|
|
|
/// specified type.
|
|
|
|
bool allowsMisalignedMemoryAccesses(
|
|
|
|
EVT VT, unsigned AddrSpace = 0, Align Alignment = Align(1),
|
|
|
|
MachineMemOperand::Flags Flags = MachineMemOperand::MONone,
|
|
|
|
bool *Fast = nullptr) const override;
|
|
|
|
|
2021-03-09 08:53:02 +08:00
|
|
|
bool splitValueIntoRegisterParts(SelectionDAG &DAG, const SDLoc &DL,
|
|
|
|
SDValue Val, SDValue *Parts,
|
|
|
|
unsigned NumParts, MVT PartVT,
|
|
|
|
Optional<CallingConv::ID> CC) const override;
|
|
|
|
|
|
|
|
SDValue
|
|
|
|
joinRegisterPartsIntoValue(SelectionDAG &DAG, const SDLoc &DL,
|
|
|
|
const SDValue *Parts, unsigned NumParts,
|
|
|
|
MVT PartVT, EVT ValueVT,
|
|
|
|
Optional<CallingConv::ID> CC) const override;
|
|
|
|
|
2021-05-12 01:17:26 +08:00
|
|
|
static RISCVII::VLMUL getLMUL(MVT VT);
|
|
|
|
static unsigned getRegClassIDForLMUL(RISCVII::VLMUL LMul);
|
2021-02-18 20:48:14 +08:00
|
|
|
static unsigned getSubregIndexByMVT(MVT VT, unsigned Index);
|
|
|
|
static unsigned getRegClassIDForVecVT(MVT VT);
|
|
|
|
static std::pair<unsigned, unsigned>
|
|
|
|
decomposeSubvectorInsertExtractToSubRegs(MVT VecVT, MVT SubVecVT,
|
|
|
|
unsigned InsertExtractIdx,
|
|
|
|
const RISCVRegisterInfo *TRI);
|
2021-03-04 17:55:14 +08:00
|
|
|
MVT getContainerForFixedLengthVector(MVT VT) const;
|
2021-02-18 20:48:14 +08:00
|
|
|
|
2021-02-04 17:56:01 +08:00
|
|
|
bool shouldRemoveExtendFromGSIndex(EVT VT) const override;
|
|
|
|
|
2020-06-10 16:16:09 +08:00
|
|
|
private:
|
2021-05-14 00:34:41 +08:00
|
|
|
/// RISCVCCAssignFn - This target-specific function extends the default
|
|
|
|
/// CCValAssign with additional information used to lower RISC-V calling
|
|
|
|
/// conventions.
|
|
|
|
typedef bool RISCVCCAssignFn(const DataLayout &DL, RISCVABI::ABI,
|
|
|
|
unsigned ValNo, MVT ValVT, MVT LocVT,
|
|
|
|
CCValAssign::LocInfo LocInfo,
|
|
|
|
ISD::ArgFlagsTy ArgFlags, CCState &State,
|
|
|
|
bool IsFixed, bool IsRet, Type *OrigTy,
|
|
|
|
const RISCVTargetLowering &TLI,
|
|
|
|
Optional<unsigned> FirstMaskArgument);
|
|
|
|
|
2020-06-10 16:16:09 +08:00
|
|
|
void analyzeInputArgs(MachineFunction &MF, CCState &CCInfo,
|
2021-05-14 00:34:41 +08:00
|
|
|
const SmallVectorImpl<ISD::InputArg> &Ins, bool IsRet,
|
|
|
|
RISCVCCAssignFn Fn) const;
|
2020-06-10 16:16:09 +08:00
|
|
|
void analyzeOutputArgs(MachineFunction &MF, CCState &CCInfo,
|
|
|
|
const SmallVectorImpl<ISD::OutputArg> &Outs,
|
2021-05-14 00:34:41 +08:00
|
|
|
bool IsRet, CallLoweringInfo *CLI,
|
|
|
|
RISCVCCAssignFn Fn) const;
|
2019-04-01 22:42:56 +08:00
|
|
|
|
|
|
|
template <class NodeTy>
|
2019-06-11 20:57:47 +08:00
|
|
|
SDValue getAddr(NodeTy *N, SelectionDAG &DAG, bool IsLocal = true) const;
|
2019-04-01 22:42:56 +08:00
|
|
|
|
2019-06-19 16:40:59 +08:00
|
|
|
SDValue getStaticTLSAddr(GlobalAddressSDNode *N, SelectionDAG &DAG,
|
|
|
|
bool UseGOT) const;
|
|
|
|
SDValue getDynamicTLSAddr(GlobalAddressSDNode *N, SelectionDAG &DAG) const;
|
|
|
|
|
2017-11-08 21:24:21 +08:00
|
|
|
SDValue lowerGlobalAddress(SDValue Op, SelectionDAG &DAG) const;
|
[RISCV] Support and tests for a variety of additional LLVM IR constructs
Previous patches primarily ensured that codegen was possible for the standard
RISC-V instructions. However, there are a number of IR inputs that wouldn't be
appropriately lowered. This patch both adds test cases and supports lowering
for a number of these cases:
* Improved sext/zext/trunc support
* Support for setcc variants that don't map directly to RISC-V instructions
* Lowering mul, and hence support for external symbols
* addc, adde, subc, sube
* mulhs, srem, mulhu, urem, udiv, sdiv
* {srl,sra,shl}_parts
* brind
* br_jt
* bswap, ctlz, cttz, ctpop
* rotl, rotr
* BlockAddress operands
Differential Revision: https://reviews.llvm.org/D29938
llvm-svn: 318737
2017-11-21 16:11:03 +08:00
|
|
|
SDValue lowerBlockAddress(SDValue Op, SelectionDAG &DAG) const;
|
2018-03-20 21:26:12 +08:00
|
|
|
SDValue lowerConstantPool(SDValue Op, SelectionDAG &DAG) const;
|
2020-11-25 22:01:19 +08:00
|
|
|
SDValue lowerJumpTable(SDValue Op, SelectionDAG &DAG) const;
|
2019-06-19 16:40:59 +08:00
|
|
|
SDValue lowerGlobalTLSAddress(SDValue Op, SelectionDAG &DAG) const;
|
2017-11-21 15:51:32 +08:00
|
|
|
SDValue lowerSELECT(SDValue Op, SelectionDAG &DAG) const;
|
2021-03-16 02:44:59 +08:00
|
|
|
SDValue lowerBRCOND(SDValue Op, SelectionDAG &DAG) const;
|
2018-01-11 03:41:03 +08:00
|
|
|
SDValue lowerVASTART(SDValue Op, SelectionDAG &DAG) const;
|
2018-10-04 13:27:50 +08:00
|
|
|
SDValue lowerFRAMEADDR(SDValue Op, SelectionDAG &DAG) const;
|
|
|
|
SDValue lowerRETURNADDR(SDValue Op, SelectionDAG &DAG) const;
|
2019-04-16 22:38:32 +08:00
|
|
|
SDValue lowerShiftLeftParts(SDValue Op, SelectionDAG &DAG) const;
|
|
|
|
SDValue lowerShiftRightParts(SDValue Op, SelectionDAG &DAG, bool IsSRA) const;
|
2021-03-11 01:46:16 +08:00
|
|
|
SDValue lowerSPLAT_VECTOR_PARTS(SDValue Op, SelectionDAG &DAG) const;
|
2021-04-28 23:11:57 +08:00
|
|
|
SDValue lowerVectorMaskSplat(SDValue Op, SelectionDAG &DAG) const;
|
2021-01-13 20:27:05 +08:00
|
|
|
SDValue lowerVectorMaskExt(SDValue Op, SelectionDAG &DAG,
|
|
|
|
int64_t ExtTrueVal) const;
|
|
|
|
SDValue lowerVectorMaskTrunc(SDValue Op, SelectionDAG &DAG) const;
|
2021-01-12 01:42:05 +08:00
|
|
|
SDValue lowerINSERT_VECTOR_ELT(SDValue Op, SelectionDAG &DAG) const;
|
|
|
|
SDValue lowerEXTRACT_VECTOR_ELT(SDValue Op, SelectionDAG &DAG) const;
|
2020-03-28 08:27:00 +08:00
|
|
|
SDValue LowerINTRINSIC_WO_CHAIN(SDValue Op, SelectionDAG &DAG) const;
|
2020-12-17 13:45:52 +08:00
|
|
|
SDValue LowerINTRINSIC_W_CHAIN(SDValue Op, SelectionDAG &DAG) const;
|
2021-01-28 23:31:27 +08:00
|
|
|
SDValue lowerVECREDUCE(SDValue Op, SelectionDAG &DAG) const;
|
2021-04-07 17:03:22 +08:00
|
|
|
SDValue lowerVectorMaskVECREDUCE(SDValue Op, SelectionDAG &DAG) const;
|
2021-02-02 22:34:51 +08:00
|
|
|
SDValue lowerFPVECREDUCE(SDValue Op, SelectionDAG &DAG) const;
|
2021-02-19 00:48:49 +08:00
|
|
|
SDValue lowerINSERT_SUBVECTOR(SDValue Op, SelectionDAG &DAG) const;
|
2021-02-18 20:48:14 +08:00
|
|
|
SDValue lowerEXTRACT_SUBVECTOR(SDValue Op, SelectionDAG &DAG) const;
|
2021-03-30 21:49:25 +08:00
|
|
|
SDValue lowerSTEP_VECTOR(SDValue Op, SelectionDAG &DAG) const;
|
2021-03-10 01:43:08 +08:00
|
|
|
SDValue lowerVECTOR_REVERSE(SDValue Op, SelectionDAG &DAG) const;
|
2021-03-10 00:51:01 +08:00
|
|
|
SDValue lowerABS(SDValue Op, SelectionDAG &DAG) const;
|
2021-03-20 01:39:33 +08:00
|
|
|
SDValue lowerMLOAD(SDValue Op, SelectionDAG &DAG) const;
|
|
|
|
SDValue lowerMSTORE(SDValue Op, SelectionDAG &DAG) const;
|
2021-03-12 01:41:39 +08:00
|
|
|
SDValue lowerFixedLengthVectorFCOPYSIGNToRVV(SDValue Op,
|
|
|
|
SelectionDAG &DAG) const;
|
2021-03-23 00:54:17 +08:00
|
|
|
SDValue lowerMGATHER(SDValue Op, SelectionDAG &DAG) const;
|
|
|
|
SDValue lowerMSCATTER(SDValue Op, SelectionDAG &DAG) const;
|
2021-02-09 02:32:32 +08:00
|
|
|
SDValue lowerFixedLengthVectorLoadToRVV(SDValue Op, SelectionDAG &DAG) const;
|
|
|
|
SDValue lowerFixedLengthVectorStoreToRVV(SDValue Op, SelectionDAG &DAG) const;
|
2021-02-13 01:20:54 +08:00
|
|
|
SDValue lowerFixedLengthVectorSetccToRVV(SDValue Op, SelectionDAG &DAG) const;
|
2021-02-17 01:26:22 +08:00
|
|
|
SDValue lowerFixedLengthVectorLogicOpToRVV(SDValue Op, SelectionDAG &DAG,
|
|
|
|
unsigned MaskOpc,
|
|
|
|
unsigned VecOpc) const;
|
2021-06-29 14:09:58 +08:00
|
|
|
SDValue lowerFixedLengthVectorShiftToRVV(SDValue Op, SelectionDAG &DAG) const;
|
2021-02-16 00:38:25 +08:00
|
|
|
SDValue lowerFixedLengthVectorSelectToRVV(SDValue Op,
|
|
|
|
SelectionDAG &DAG) const;
|
2021-02-17 01:26:22 +08:00
|
|
|
SDValue lowerToScalableOp(SDValue Op, SelectionDAG &DAG, unsigned NewOpc,
|
|
|
|
bool HasMask = true) const;
|
2021-04-29 23:58:56 +08:00
|
|
|
SDValue lowerVPOp(SDValue Op, SelectionDAG &DAG, unsigned RISCVISDOpc) const;
|
2021-02-17 17:08:24 +08:00
|
|
|
SDValue lowerFixedLengthVectorExtendToRVV(SDValue Op, SelectionDAG &DAG,
|
|
|
|
unsigned ExtendOpc) const;
|
2020-11-05 14:59:52 +08:00
|
|
|
SDValue lowerGET_ROUNDING(SDValue Op, SelectionDAG &DAG) const;
|
2020-11-11 00:51:34 +08:00
|
|
|
SDValue lowerSET_ROUNDING(SDValue Op, SelectionDAG &DAG) const;
|
2018-05-24 06:44:08 +08:00
|
|
|
|
2021-06-09 22:17:21 +08:00
|
|
|
SDValue expandUnalignedRVVLoad(SDValue Op, SelectionDAG &DAG) const;
|
|
|
|
SDValue expandUnalignedRVVStore(SDValue Op, SelectionDAG &DAG) const;
|
|
|
|
|
2019-02-21 22:31:41 +08:00
|
|
|
bool isEligibleForTailCallOptimization(
|
|
|
|
CCState &CCInfo, CallLoweringInfo &CLI, MachineFunction &MF,
|
|
|
|
const SmallVector<CCValAssign, 16> &ArgLocs) const;
|
2018-09-19 18:54:22 +08:00
|
|
|
|
2019-10-23 04:25:01 +08:00
|
|
|
/// Generate error diagnostics if any register used by CC has been marked
|
|
|
|
/// reserved.
|
|
|
|
void validateCCReservedRegs(
|
|
|
|
const SmallVectorImpl<std::pair<llvm::Register, llvm::SDValue>> &Regs,
|
|
|
|
MachineFunction &MF) const;
|
2021-02-09 02:32:32 +08:00
|
|
|
|
|
|
|
bool useRVVForFixedLengthVectorVT(MVT VT) const;
|
2021-05-21 20:00:19 +08:00
|
|
|
|
2021-05-24 22:24:54 +08:00
|
|
|
MVT getVPExplicitVectorLengthTy() const override;
|
|
|
|
|
2021-05-21 20:00:19 +08:00
|
|
|
/// RVV code generation for fixed length vectors does not lower all
|
|
|
|
/// BUILD_VECTORs. This makes BUILD_VECTOR legalisation a source of stores to
|
|
|
|
/// merge. However, merging them creates a BUILD_VECTOR that is just as
|
|
|
|
/// illegal as the original, thus leading to an infinite legalisation loop.
|
|
|
|
/// NOTE: Once BUILD_VECTOR can be custom lowered for all legal vector types,
|
|
|
|
/// this override can be removed.
|
|
|
|
bool mergeStoresAfterLegalization(EVT VT) const override;
|
2017-10-20 05:37:38 +08:00
|
|
|
};
|
2020-12-11 15:16:08 +08:00
|
|
|
|
2021-01-27 15:00:46 +08:00
|
|
|
namespace RISCV {
|
|
|
|
// We use 64 bits as the known part in the scalable vector types.
|
|
|
|
static constexpr unsigned RVVBitsPerBlock = 64;
|
2021-02-11 03:20:07 +08:00
|
|
|
} // namespace RISCV
|
2021-01-27 15:00:46 +08:00
|
|
|
|
2020-12-11 15:16:08 +08:00
|
|
|
namespace RISCVVIntrinsicsTable {
|
|
|
|
|
|
|
|
struct RISCVVIntrinsicInfo {
|
2021-01-28 04:22:36 +08:00
|
|
|
unsigned IntrinsicID;
|
2021-03-11 01:37:25 +08:00
|
|
|
uint8_t SplatOperand;
|
2020-12-11 15:16:08 +08:00
|
|
|
};
|
|
|
|
|
|
|
|
using namespace RISCV;
|
|
|
|
|
|
|
|
#define GET_RISCVVIntrinsicsTable_DECL
|
|
|
|
#include "RISCVGenSearchableTables.inc"
|
|
|
|
|
|
|
|
} // end namespace RISCVVIntrinsicsTable
|
[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
|
|
|
|
2021-02-18 03:37:06 +08:00
|
|
|
} // end namespace llvm
|
2017-10-20 05:37:38 +08:00
|
|
|
|
|
|
|
#endif
|