2012-02-18 20:03:15 +08:00
|
|
|
//===-- HexagonISelLowering.h - Hexagon DAG Lowering Interface --*- C++ -*-===//
|
2011-12-13 05:14:40 +08:00
|
|
|
//
|
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
|
2011-12-13 05:14:40 +08:00
|
|
|
//
|
|
|
|
//===----------------------------------------------------------------------===//
|
|
|
|
//
|
|
|
|
// This file defines the interfaces that Hexagon uses to lower LLVM code into a
|
|
|
|
// selection DAG.
|
|
|
|
//
|
|
|
|
//===----------------------------------------------------------------------===//
|
|
|
|
|
2014-08-14 00:26:38 +08:00
|
|
|
#ifndef LLVM_LIB_TARGET_HEXAGON_HEXAGONISELLOWERING_H
|
|
|
|
#define LLVM_LIB_TARGET_HEXAGON_HEXAGONISELLOWERING_H
|
2011-12-13 05:14:40 +08:00
|
|
|
|
2012-03-18 02:46:09 +08:00
|
|
|
#include "Hexagon.h"
|
2016-12-17 09:09:05 +08:00
|
|
|
#include "llvm/ADT/StringRef.h"
|
|
|
|
#include "llvm/CodeGen/ISDOpcodes.h"
|
|
|
|
#include "llvm/CodeGen/SelectionDAGNodes.h"
|
2017-11-17 09:07:10 +08:00
|
|
|
#include "llvm/CodeGen/TargetLowering.h"
|
2018-03-30 01:21:10 +08:00
|
|
|
#include "llvm/CodeGen/ValueTypes.h"
|
2013-01-02 19:36:10 +08:00
|
|
|
#include "llvm/IR/CallingConv.h"
|
2016-12-17 09:09:05 +08:00
|
|
|
#include "llvm/IR/InlineAsm.h"
|
2018-03-24 07:58:25 +08:00
|
|
|
#include "llvm/Support/MachineValueType.h"
|
2016-12-17 09:09:05 +08:00
|
|
|
#include <cstdint>
|
|
|
|
#include <utility>
|
2011-12-13 05:14:40 +08:00
|
|
|
|
|
|
|
namespace llvm {
|
2016-12-17 09:09:05 +08:00
|
|
|
|
|
|
|
namespace HexagonISD {
|
|
|
|
|
2015-05-08 05:33:59 +08:00
|
|
|
enum NodeType : unsigned {
|
2015-04-23 05:17:00 +08:00
|
|
|
OP_BEGIN = ISD::BUILTIN_OP_END,
|
2011-12-13 05:14:40 +08:00
|
|
|
|
2015-04-23 05:17:00 +08:00
|
|
|
CONST32 = OP_BEGIN,
|
2011-12-13 05:14:40 +08:00
|
|
|
CONST32_GP, // For marking data present in GP.
|
2018-06-01 22:00:32 +08:00
|
|
|
ADDC, // Add with carry: (X, Y, Cin) -> (X+Y, Cout).
|
|
|
|
SUBC, // Sub with carry: (X, Y, Cin) -> (X+~Y+Cin, Cout).
|
2015-04-23 00:43:53 +08:00
|
|
|
ALLOCA,
|
2011-12-13 05:14:40 +08:00
|
|
|
|
2015-12-19 04:19:30 +08:00
|
|
|
AT_GOT, // Index in GOT.
|
|
|
|
AT_PCREL, // Offset relative to PC.
|
2015-03-11 04:04:44 +08:00
|
|
|
|
2016-08-12 19:12:02 +08:00
|
|
|
CALL, // Function call.
|
|
|
|
CALLnr, // Function call that does not return.
|
2015-01-17 01:05:27 +08:00
|
|
|
CALLR,
|
|
|
|
|
2011-12-13 05:14:40 +08:00
|
|
|
RET_FLAG, // Return with a flag operand.
|
2015-03-20 00:33:08 +08:00
|
|
|
BARRIER, // Memory barrier.
|
|
|
|
JT, // Jump table.
|
|
|
|
CP, // Constant pool.
|
2015-04-23 05:17:00 +08:00
|
|
|
|
2014-12-06 02:24:06 +08:00
|
|
|
COMBINE,
|
2018-04-21 03:38:37 +08:00
|
|
|
VSPLAT, // Generic splat, selection depends on argument/return
|
|
|
|
// types.
|
2017-07-11 04:16:44 +08:00
|
|
|
VASL,
|
|
|
|
VASR,
|
|
|
|
VLSR,
|
2015-04-23 05:17:00 +08:00
|
|
|
|
2018-01-24 01:53:59 +08:00
|
|
|
TSTBIT,
|
2015-04-23 05:17:00 +08:00
|
|
|
INSERT,
|
|
|
|
EXTRACTU,
|
2017-12-07 00:40:37 +08:00
|
|
|
VEXTRACTW,
|
|
|
|
VINSERTW0,
|
|
|
|
VROR,
|
2013-05-02 05:37:34 +08:00
|
|
|
TC_RETURN,
|
2015-01-07 03:03:20 +08:00
|
|
|
EH_RETURN,
|
2015-04-23 05:17:00 +08:00
|
|
|
DCFETCH,
|
2017-02-23 06:28:47 +08:00
|
|
|
READCYCLE,
|
2019-08-17 00:16:27 +08:00
|
|
|
PTRUE,
|
|
|
|
PFALSE,
|
2018-01-24 01:53:59 +08:00
|
|
|
D2P, // Convert 8-byte value to 8-bit predicate register. [*]
|
|
|
|
P2D, // Convert 8-bit predicate register to 8-byte value. [*]
|
|
|
|
V2Q, // Convert HVX vector to a vector predicate reg. [*]
|
|
|
|
Q2V, // Convert vector predicate to an HVX vector. [*]
|
|
|
|
// [*] The equivalence is defined as "Q <=> (V != 0)",
|
|
|
|
// where the != operation compares bytes.
|
|
|
|
// Note: V != 0 is implemented as V >u 0.
|
2018-02-06 22:24:57 +08:00
|
|
|
QCAT,
|
2018-02-06 22:16:52 +08:00
|
|
|
QTRUE,
|
|
|
|
QFALSE,
|
2017-12-21 04:49:43 +08:00
|
|
|
VZERO,
|
2018-04-21 03:38:37 +08:00
|
|
|
VSPLATW, // HVX splat of a 32-bit word with an arbitrary result type.
|
2018-01-24 01:53:59 +08:00
|
|
|
TYPECAST, // No-op that's used to convert between different legal
|
|
|
|
// types in a register.
|
2018-03-08 01:27:18 +08:00
|
|
|
VALIGN, // Align two vectors (in Op0, Op1) to one that would have
|
|
|
|
// been loaded from address in Op2.
|
|
|
|
VALIGNADDR, // Align vector address: Op0 & -Op1, except when it is
|
2018-02-15 04:46:06 +08:00
|
|
|
// an address in a vector load, then it's a no-op.
|
2015-04-23 05:17:00 +08:00
|
|
|
OP_END
|
2011-12-13 05:14:40 +08:00
|
|
|
};
|
2016-12-17 09:09:05 +08:00
|
|
|
|
|
|
|
} // end namespace HexagonISD
|
2011-12-13 05:14:40 +08:00
|
|
|
|
2015-02-03 06:11:36 +08:00
|
|
|
class HexagonSubtarget;
|
|
|
|
|
2011-12-13 05:14:40 +08:00
|
|
|
class HexagonTargetLowering : public TargetLowering {
|
|
|
|
int VarArgsFrameOffset; // Frame offset to start of varargs area.
|
2016-12-17 09:09:05 +08:00
|
|
|
const HexagonTargetMachine &HTM;
|
|
|
|
const HexagonSubtarget &Subtarget;
|
2011-12-13 05:14:40 +08:00
|
|
|
|
2015-04-23 05:17:00 +08:00
|
|
|
bool CanReturnSmallStruct(const Function* CalleeFn, unsigned& RetSize)
|
|
|
|
const;
|
2015-03-20 00:33:08 +08:00
|
|
|
|
2011-12-13 05:14:40 +08:00
|
|
|
public:
|
2015-02-03 06:11:36 +08:00
|
|
|
explicit HexagonTargetLowering(const TargetMachine &TM,
|
2015-04-23 05:17:00 +08:00
|
|
|
const HexagonSubtarget &ST);
|
2011-12-13 05:14:40 +08:00
|
|
|
|
2017-12-07 00:40:37 +08:00
|
|
|
bool isHVXVectorType(MVT Ty) const;
|
|
|
|
|
2011-12-13 05:14:40 +08:00
|
|
|
/// IsEligibleForTailCallOptimization - Check whether the call is eligible
|
|
|
|
/// for tail call optimization. Targets which want to do tail call
|
|
|
|
/// optimization should implement this function.
|
2015-04-23 05:17:00 +08:00
|
|
|
bool IsEligibleForTailCallOptimization(SDValue Callee,
|
|
|
|
CallingConv::ID CalleeCC, bool isVarArg, bool isCalleeStructRet,
|
|
|
|
bool isCallerStructRet, const SmallVectorImpl<ISD::OutputArg> &Outs,
|
|
|
|
const SmallVectorImpl<SDValue> &OutVals,
|
|
|
|
const SmallVectorImpl<ISD::InputArg> &Ins, SelectionDAG& DAG) const;
|
2011-12-13 05:14:40 +08:00
|
|
|
|
2017-12-12 02:57:54 +08:00
|
|
|
bool getTgtMemIntrinsic(IntrinsicInfo &Info, const CallInst &I,
|
2017-12-15 06:34:10 +08:00
|
|
|
MachineFunction &MF,
|
2017-12-12 02:57:54 +08:00
|
|
|
unsigned Intrinsic) const override;
|
|
|
|
|
2014-04-29 15:58:16 +08:00
|
|
|
bool isTruncateFree(Type *Ty1, Type *Ty2) const override;
|
|
|
|
bool isTruncateFree(EVT VT1, EVT VT2) const override;
|
2011-12-13 05:14:40 +08:00
|
|
|
|
2018-03-13 02:18:23 +08:00
|
|
|
bool isCheapToSpeculateCttz() const override { return true; }
|
|
|
|
bool isCheapToSpeculateCtlz() const override { return true; }
|
|
|
|
bool isCtlzFast() const override { return true; }
|
|
|
|
|
[Codegen] (X & (C l>>/<< Y)) ==/!= 0 --> ((X <</l>> Y) & C) ==/!= 0 fold
Summary:
This was originally reported in D62818.
https://rise4fun.com/Alive/oPH
InstCombine does the opposite fold, in hope that `C l>>/<< Y` expression
will be hoisted out of a loop if `Y` is invariant and `X` is not.
But as it is seen from the diffs here, if it didn't get hoisted,
the produced assembly is almost universally worse.
Much like with my recent "hoist add/sub by/from const" patches,
we should get almost universal win if we hoist constant,
there is almost always an "and/test by imm" instruction,
but "shift of imm" not so much, so we may avoid having to
materialize the immediate, and thus need one less register.
And since we now shift not by constant, but by something else,
the live-range of that something else may reduce.
Special care needs to be applied not to disturb x86 `BT` / hexagon `tstbit`
instruction pattern. And to not get into endless combine loop.
Reviewers: RKSimon, efriedma, t.p.northover, craig.topper, spatel, arsenm
Reviewed By: spatel
Subscribers: hiraditya, MaskRay, wuzish, xbolva00, nikic, nemanjai, jvesely, wdng, nhaehnle, javed.absar, tpr, kristof.beyls, jsji, llvm-commits
Tags: #llvm
Differential Revision: https://reviews.llvm.org/D62871
llvm-svn: 366955
2019-07-25 06:57:22 +08:00
|
|
|
bool hasBitTest(SDValue X, SDValue Y) const override;
|
|
|
|
|
2014-04-29 15:58:16 +08:00
|
|
|
bool allowTruncateForTailCall(Type *Ty1, Type *Ty2) const override;
|
Refactor isInTailCallPosition handling
This change came about primarily because of two issues in the existing code.
Niether of:
define i64 @test1(i64 %val) {
%in = trunc i64 %val to i32
tail call i32 @ret32(i32 returned %in)
ret i64 %val
}
define i64 @test2(i64 %val) {
tail call i32 @ret32(i32 returned undef)
ret i32 42
}
should be tail calls, and the function sameNoopInput is responsible. The main
problem is that it is completely symmetric in the "tail call" and "ret" value,
but in reality different things are allowed on each side.
For these cases:
1. Any truncation should lead to a larger value being generated by "tail call"
than needed by "ret".
2. Undef should only be allowed as a source for ret, not as a result of the
call.
Along the way I noticed that a mismatch between what this function treats as a
valid truncation and what the backends see can lead to invalid calls as well
(see x86-32 test case).
This patch refactors the code so that instead of being based primarily on
values which it recurses into when necessary, it starts by inspecting the type
and considers each fundamental slot that the backend will see in turn. For
example, given a pathological function that returned {{}, {{}, i32, {}}, i32}
we would consider each "real" i32 in turn, and ask if it passes through
unchanged. This is much closer to what the backend sees as a result of
ComputeValueVTs.
Aside from the bug fixes, this eliminates the recursion that's going on and, I
believe, makes the bulk of the code significantly easier to understand. The
trade-off is the nasty iterators needed to find the real types inside a
returned value.
llvm-svn: 187787
2013-08-06 17:12:35 +08:00
|
|
|
|
2016-08-19 21:34:31 +08:00
|
|
|
/// Return true if an FMA operation is faster than a pair of mul and add
|
|
|
|
/// instructions. fmuladd intrinsics will be expanded to FMAs when this
|
|
|
|
/// method returns true (and FMAs are legal), otherwise fmuladd is
|
|
|
|
/// expanded to mul + add.
|
|
|
|
bool isFMAFasterThanFMulAndFAdd(EVT) const override;
|
|
|
|
|
2015-03-20 00:33:08 +08:00
|
|
|
// Should we expand the build vector with shuffles?
|
|
|
|
bool shouldExpandBuildVectorWithShuffles(EVT VT,
|
2015-04-23 05:17:00 +08:00
|
|
|
unsigned DefinedValues) const override;
|
2011-12-13 05:14:40 +08:00
|
|
|
|
2017-07-26 16:06:58 +08:00
|
|
|
bool isShuffleMaskLegal(ArrayRef<int> Mask, EVT VT) const override;
|
2018-11-06 07:26:13 +08:00
|
|
|
TargetLoweringBase::LegalizeTypeAction getPreferredVectorAction(MVT VT)
|
2017-12-19 02:21:01 +08:00
|
|
|
const override;
|
2016-09-14 05:16:07 +08:00
|
|
|
|
2015-03-20 00:33:08 +08:00
|
|
|
SDValue LowerOperation(SDValue Op, SelectionDAG &DAG) const override;
|
2018-08-09 01:00:09 +08:00
|
|
|
void LowerOperationWrapper(SDNode *N, SmallVectorImpl<SDValue> &Results,
|
|
|
|
SelectionDAG &DAG) const override;
|
2018-01-24 01:53:59 +08:00
|
|
|
void ReplaceNodeResults(SDNode *N, SmallVectorImpl<SDValue> &Results,
|
|
|
|
SelectionDAG &DAG) const override;
|
|
|
|
|
2014-04-29 15:58:16 +08:00
|
|
|
const char *getTargetNodeName(unsigned Opcode) const override;
|
2017-11-30 03:58:10 +08:00
|
|
|
|
|
|
|
SDValue LowerBUILD_VECTOR(SDValue Op, SelectionDAG &DAG) const;
|
2015-03-20 00:33:08 +08:00
|
|
|
SDValue LowerCONCAT_VECTORS(SDValue Op, SelectionDAG &DAG) const;
|
2017-11-30 03:58:10 +08:00
|
|
|
SDValue LowerEXTRACT_VECTOR_ELT(SDValue Op, SelectionDAG &DAG) const;
|
|
|
|
SDValue LowerEXTRACT_SUBVECTOR(SDValue Op, SelectionDAG &DAG) const;
|
|
|
|
SDValue LowerINSERT_VECTOR_ELT(SDValue Op, SelectionDAG &DAG) const;
|
2017-12-07 00:40:37 +08:00
|
|
|
SDValue LowerINSERT_SUBVECTOR(SDValue Op, SelectionDAG &DAG) const;
|
2016-07-30 00:44:27 +08:00
|
|
|
SDValue LowerVECTOR_SHUFFLE(SDValue Op, SelectionDAG &DAG) const;
|
|
|
|
SDValue LowerVECTOR_SHIFT(SDValue Op, SelectionDAG &DAG) const;
|
2018-06-12 20:49:36 +08:00
|
|
|
SDValue LowerROTL(SDValue Op, SelectionDAG &DAG) const;
|
2018-01-24 01:53:59 +08:00
|
|
|
SDValue LowerBITCAST(SDValue Op, SelectionDAG &DAG) const;
|
|
|
|
SDValue LowerANY_EXTEND(SDValue Op, SelectionDAG &DAG) const;
|
|
|
|
SDValue LowerSIGN_EXTEND(SDValue Op, SelectionDAG &DAG) const;
|
|
|
|
SDValue LowerZERO_EXTEND(SDValue Op, SelectionDAG &DAG) const;
|
2018-08-09 01:00:09 +08:00
|
|
|
SDValue LowerLoad(SDValue Op, SelectionDAG &DAG) const;
|
|
|
|
SDValue LowerStore(SDValue Op, SelectionDAG &DAG) const;
|
2018-03-08 01:27:18 +08:00
|
|
|
SDValue LowerUnalignedLoad(SDValue Op, SelectionDAG &DAG) const;
|
2019-07-01 23:50:09 +08:00
|
|
|
SDValue LowerUAddSubO(SDValue Op, SelectionDAG &DAG) const;
|
2018-06-01 22:00:32 +08:00
|
|
|
SDValue LowerAddSubCarry(SDValue Op, SelectionDAG &DAG) const;
|
2017-11-30 03:58:10 +08:00
|
|
|
|
2011-12-13 05:14:40 +08:00
|
|
|
SDValue LowerDYNAMIC_STACKALLOC(SDValue Op, SelectionDAG &DAG) const;
|
|
|
|
SDValue LowerINLINEASM(SDValue Op, SelectionDAG &DAG) const;
|
2016-02-18 21:58:38 +08:00
|
|
|
SDValue LowerPREFETCH(SDValue Op, SelectionDAG &DAG) const;
|
2017-02-23 06:28:47 +08:00
|
|
|
SDValue LowerREADCYCLECOUNTER(SDValue Op, SelectionDAG &DAG) const;
|
2011-12-13 05:14:40 +08:00
|
|
|
SDValue LowerEH_LABEL(SDValue Op, SelectionDAG &DAG) const;
|
2013-05-02 05:37:34 +08:00
|
|
|
SDValue LowerEH_RETURN(SDValue Op, SelectionDAG &DAG) const;
|
2016-06-12 23:39:02 +08:00
|
|
|
SDValue
|
|
|
|
LowerFormalArguments(SDValue Chain, CallingConv::ID CallConv, bool isVarArg,
|
|
|
|
const SmallVectorImpl<ISD::InputArg> &Ins,
|
|
|
|
const SDLoc &dl, SelectionDAG &DAG,
|
|
|
|
SmallVectorImpl<SDValue> &InVals) const override;
|
2011-12-13 05:14:40 +08:00
|
|
|
SDValue LowerGLOBALADDRESS(SDValue Op, SelectionDAG &DAG) const;
|
2013-03-08 03:10:28 +08:00
|
|
|
SDValue LowerBlockAddress(SDValue Op, SelectionDAG &DAG) const;
|
2016-02-18 23:42:57 +08:00
|
|
|
SDValue LowerGlobalTLSAddress(SDValue Op, SelectionDAG &DAG) const;
|
|
|
|
SDValue LowerToTLSGeneralDynamicModel(GlobalAddressSDNode *GA,
|
|
|
|
SelectionDAG &DAG) const;
|
|
|
|
SDValue LowerToTLSInitialExecModel(GlobalAddressSDNode *GA,
|
|
|
|
SelectionDAG &DAG) const;
|
|
|
|
SDValue LowerToTLSLocalExecModel(GlobalAddressSDNode *GA,
|
|
|
|
SelectionDAG &DAG) const;
|
|
|
|
SDValue GetDynamicTLSAddr(SelectionDAG &DAG, SDValue Chain,
|
2017-02-18 06:14:51 +08:00
|
|
|
GlobalAddressSDNode *GA, SDValue InFlag, EVT PtrVT,
|
2016-02-18 23:42:57 +08:00
|
|
|
unsigned ReturnReg, unsigned char OperandFlags) const;
|
2015-12-19 04:19:30 +08:00
|
|
|
SDValue LowerGLOBAL_OFFSET_TABLE(SDValue Op, SelectionDAG &DAG) const;
|
2011-12-13 05:14:40 +08:00
|
|
|
|
2012-05-26 00:35:28 +08:00
|
|
|
SDValue LowerCall(TargetLowering::CallLoweringInfo &CLI,
|
2015-04-23 05:17:00 +08:00
|
|
|
SmallVectorImpl<SDValue> &InVals) const override;
|
2011-12-13 05:14:40 +08:00
|
|
|
SDValue LowerCallResult(SDValue Chain, SDValue InFlag,
|
2016-06-12 23:39:02 +08:00
|
|
|
CallingConv::ID CallConv, bool isVarArg,
|
|
|
|
const SmallVectorImpl<ISD::InputArg> &Ins,
|
|
|
|
const SDLoc &dl, SelectionDAG &DAG,
|
|
|
|
SmallVectorImpl<SDValue> &InVals,
|
|
|
|
const SmallVectorImpl<SDValue> &OutVals,
|
|
|
|
SDValue Callee) const;
|
2011-12-13 05:14:40 +08:00
|
|
|
|
2015-03-20 00:33:08 +08:00
|
|
|
SDValue LowerSETCC(SDValue Op, SelectionDAG &DAG) const;
|
|
|
|
SDValue LowerVSELECT(SDValue Op, SelectionDAG &DAG) const;
|
2011-12-13 05:14:40 +08:00
|
|
|
SDValue LowerFRAMEADDR(SDValue Op, SelectionDAG &DAG) const;
|
|
|
|
SDValue LowerATOMIC_FENCE(SDValue Op, SelectionDAG& DAG) const;
|
|
|
|
SDValue LowerRETURNADDR(SDValue Op, SelectionDAG &DAG) const;
|
|
|
|
|
2017-04-13 23:05:51 +08:00
|
|
|
bool CanLowerReturn(CallingConv::ID CallConv,
|
|
|
|
MachineFunction &MF, bool isVarArg,
|
|
|
|
const SmallVectorImpl<ISD::OutputArg> &Outs,
|
|
|
|
LLVMContext &Context) const override;
|
|
|
|
|
2016-06-12 23:39:02 +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;
|
2011-12-13 05:14:40 +08:00
|
|
|
|
2019-08-16 00:13:17 +08:00
|
|
|
SDValue PerformDAGCombine(SDNode *N, DAGCombinerInfo &DCI) const override;
|
|
|
|
|
2017-04-19 05:16:46 +08:00
|
|
|
bool mayBeEmittedAsTailCall(const CallInst *CI) const override;
|
2011-12-13 05:14:40 +08:00
|
|
|
|
2019-10-01 09:44:39 +08:00
|
|
|
Register getRegisterByName(const char* RegName, EVT VT,
|
|
|
|
const MachineFunction &MF) const override;
|
2018-09-07 21:36:21 +08:00
|
|
|
|
2015-11-07 09:11:31 +08:00
|
|
|
/// If a physical register, this returns the register that receives the
|
|
|
|
/// exception address on entry to an EH pad.
|
|
|
|
unsigned
|
|
|
|
getExceptionPointerRegister(const Constant *PersonalityFn) const override {
|
|
|
|
return Hexagon::R0;
|
|
|
|
}
|
|
|
|
|
|
|
|
/// If a physical register, this returns the register that receives the
|
|
|
|
/// exception typeid on entry to a landing pad.
|
|
|
|
unsigned
|
|
|
|
getExceptionSelectorRegister(const Constant *PersonalityFn) const override {
|
|
|
|
return Hexagon::R1;
|
|
|
|
}
|
|
|
|
|
2015-04-23 05:17:00 +08:00
|
|
|
SDValue LowerVASTART(SDValue Op, SelectionDAG &DAG) const;
|
|
|
|
SDValue LowerConstantPool(SDValue Op, SelectionDAG &DAG) const;
|
2015-12-19 04:19:30 +08:00
|
|
|
SDValue LowerJumpTable(SDValue Op, SelectionDAG &DAG) const;
|
2016-12-17 09:09:05 +08:00
|
|
|
|
2015-07-09 10:09:04 +08:00
|
|
|
EVT getSetCCResultType(const DataLayout &, LLVMContext &C,
|
|
|
|
EVT VT) const override {
|
2013-11-13 09:57:54 +08:00
|
|
|
if (!VT.isVector())
|
|
|
|
return MVT::i1;
|
|
|
|
else
|
|
|
|
return EVT::getVectorVT(C, MVT::i1, VT.getVectorNumElements());
|
2011-12-13 05:14:40 +08:00
|
|
|
}
|
|
|
|
|
2014-04-29 15:58:16 +08:00
|
|
|
bool getPostIndexedAddressParts(SDNode *N, SDNode *Op,
|
|
|
|
SDValue &Base, SDValue &Offset,
|
|
|
|
ISD::MemIndexedMode &AM,
|
|
|
|
SelectionDAG &DAG) const override;
|
2011-12-13 05:14:40 +08:00
|
|
|
|
2016-05-18 22:34:51 +08:00
|
|
|
ConstraintType getConstraintType(StringRef Constraint) const override;
|
|
|
|
|
2015-02-27 06:38:43 +08:00
|
|
|
std::pair<unsigned, const TargetRegisterClass *>
|
|
|
|
getRegForInlineAsmConstraint(const TargetRegisterInfo *TRI,
|
2015-07-06 03:29:18 +08:00
|
|
|
StringRef Constraint, MVT VT) const override;
|
2011-12-13 05:14:40 +08:00
|
|
|
|
2015-07-06 03:29:18 +08:00
|
|
|
unsigned
|
|
|
|
getInlineAsmMemConstraint(StringRef ConstraintCode) const override {
|
2015-03-17 22:37:39 +08:00
|
|
|
if (ConstraintCode == "o")
|
|
|
|
return InlineAsm::Constraint_o;
|
|
|
|
return TargetLowering::getInlineAsmMemConstraint(ConstraintCode);
|
2015-03-16 21:13:41 +08:00
|
|
|
}
|
|
|
|
|
2011-12-13 05:14:40 +08:00
|
|
|
// Intrinsics
|
2014-04-29 15:58:16 +08:00
|
|
|
SDValue LowerINTRINSIC_WO_CHAIN(SDValue Op, SelectionDAG &DAG) const;
|
2016-02-18 21:58:38 +08:00
|
|
|
SDValue LowerINTRINSIC_VOID(SDValue Op, SelectionDAG &DAG) const;
|
2011-12-13 05:14:40 +08:00
|
|
|
/// isLegalAddressingMode - Return true if the addressing mode represented
|
|
|
|
/// by AM is legal for this target, for a load/store of the specified type.
|
|
|
|
/// The type may be VoidTy, in which case only return true if the addressing
|
|
|
|
/// mode is legal for a load/store of any legal type.
|
|
|
|
/// TODO: Handle pre/postinc as well.
|
2015-07-09 10:09:40 +08:00
|
|
|
bool isLegalAddressingMode(const DataLayout &DL, const AddrMode &AM,
|
2017-07-21 19:59:37 +08:00
|
|
|
Type *Ty, unsigned AS,
|
|
|
|
Instruction *I = nullptr) const override;
|
2015-12-19 04:19:30 +08:00
|
|
|
/// Return true if folding a constant offset with the given GlobalAddress
|
|
|
|
/// is legal. It is frequently not legal in PIC relocation models.
|
|
|
|
bool isOffsetFoldingLegal(const GlobalAddressSDNode *GA) const override;
|
|
|
|
|
2019-03-19 02:40:07 +08:00
|
|
|
bool isFPImmLegal(const APFloat &Imm, EVT VT,
|
|
|
|
bool ForCodeSize) const override;
|
2011-12-13 05:14:40 +08:00
|
|
|
|
|
|
|
/// isLegalICmpImmediate - Return true if the specified immediate is legal
|
|
|
|
/// icmp immediate, that is the target has icmp instructions which can
|
|
|
|
/// compare a register against the immediate without having to materialize
|
|
|
|
/// the immediate into a register.
|
2014-04-29 15:58:16 +08:00
|
|
|
bool isLegalICmpImmediate(int64_t Imm) const override;
|
2015-07-09 22:51:21 +08:00
|
|
|
|
2016-08-03 02:34:31 +08:00
|
|
|
EVT getOptimalMemOpType(uint64_t Size, unsigned DstAlign,
|
|
|
|
unsigned SrcAlign, bool IsMemset, bool ZeroMemset, bool MemcpyStrSrc,
|
2019-04-30 16:38:12 +08:00
|
|
|
const AttributeList &FuncAttributes) const override;
|
2016-08-03 02:34:31 +08:00
|
|
|
|
2016-03-28 23:43:03 +08:00
|
|
|
bool allowsMisalignedMemoryAccesses(EVT VT, unsigned AddrSpace,
|
2019-08-16 00:13:17 +08:00
|
|
|
unsigned Align, MachineMemOperand::Flags Flags, bool *Fast)
|
|
|
|
const override;
|
2016-03-28 23:43:03 +08:00
|
|
|
|
2015-12-19 04:19:30 +08:00
|
|
|
/// Returns relocation base for the given PIC jumptable.
|
|
|
|
SDValue getPICJumpTableRelocBase(SDValue Table, SelectionDAG &DAG)
|
|
|
|
const override;
|
|
|
|
|
2018-11-02 22:17:47 +08:00
|
|
|
bool shouldReduceLoadWidth(SDNode *Load, ISD::LoadExtType ExtTy,
|
|
|
|
EVT NewVT) const override;
|
|
|
|
|
2015-07-09 22:51:21 +08:00
|
|
|
// Handling of atomic RMW instructions.
|
|
|
|
Value *emitLoadLinked(IRBuilder<> &Builder, Value *Addr,
|
|
|
|
AtomicOrdering Ord) const override;
|
|
|
|
Value *emitStoreConditional(IRBuilder<> &Builder, Value *Val,
|
|
|
|
Value *Addr, AtomicOrdering Ord) const override;
|
2015-09-12 01:08:28 +08:00
|
|
|
AtomicExpansionKind shouldExpandAtomicLoadInIR(LoadInst *LI) const override;
|
2015-07-09 22:51:21 +08:00
|
|
|
bool shouldExpandAtomicStoreInIR(StoreInst *SI) const override;
|
2018-09-19 22:51:42 +08:00
|
|
|
AtomicExpansionKind
|
|
|
|
shouldExpandAtomicCmpXchgInIR(AtomicCmpXchgInst *AI) const override;
|
2016-06-23 00:07:10 +08:00
|
|
|
|
2015-09-12 01:08:17 +08:00
|
|
|
AtomicExpansionKind
|
|
|
|
shouldExpandAtomicRMWInIR(AtomicRMWInst *AI) const override {
|
|
|
|
return AtomicExpansionKind::LLSC;
|
2015-07-09 22:51:21 +08:00
|
|
|
}
|
2015-11-27 02:38:27 +08:00
|
|
|
|
2017-11-30 03:58:10 +08:00
|
|
|
private:
|
2018-02-07 04:22:20 +08:00
|
|
|
void initializeHVXLowering();
|
2018-08-09 01:00:09 +08:00
|
|
|
void validateConstPtrAlignment(SDValue Ptr, const SDLoc &dl,
|
|
|
|
unsigned NeedAlign) const;
|
|
|
|
|
2018-02-15 04:46:06 +08:00
|
|
|
std::pair<SDValue,int> getBaseAndOffset(SDValue Addr) const;
|
2018-02-07 04:22:20 +08:00
|
|
|
|
2017-12-21 04:49:43 +08:00
|
|
|
bool getBuildVectorConstInts(ArrayRef<SDValue> Values, MVT VecTy,
|
|
|
|
SelectionDAG &DAG,
|
|
|
|
MutableArrayRef<ConstantInt*> Consts) const;
|
2017-12-08 01:37:28 +08:00
|
|
|
SDValue buildVector32(ArrayRef<SDValue> Elem, const SDLoc &dl, MVT VecTy,
|
|
|
|
SelectionDAG &DAG) const;
|
|
|
|
SDValue buildVector64(ArrayRef<SDValue> Elem, const SDLoc &dl, MVT VecTy,
|
|
|
|
SelectionDAG &DAG) const;
|
|
|
|
SDValue extractVector(SDValue VecV, SDValue IdxV, const SDLoc &dl,
|
|
|
|
MVT ValTy, MVT ResTy, SelectionDAG &DAG) const;
|
|
|
|
SDValue insertVector(SDValue VecV, SDValue ValV, SDValue IdxV,
|
|
|
|
const SDLoc &dl, MVT ValTy, SelectionDAG &DAG) const;
|
2018-01-24 01:53:59 +08:00
|
|
|
SDValue expandPredicate(SDValue Vec32, const SDLoc &dl,
|
|
|
|
SelectionDAG &DAG) const;
|
|
|
|
SDValue contractPredicate(SDValue Vec64, const SDLoc &dl,
|
|
|
|
SelectionDAG &DAG) const;
|
2018-02-07 04:22:20 +08:00
|
|
|
SDValue getVectorShiftByInt(SDValue Op, SelectionDAG &DAG) const;
|
2018-01-24 01:53:59 +08:00
|
|
|
|
2017-12-07 00:40:37 +08:00
|
|
|
bool isUndef(SDValue Op) const {
|
|
|
|
if (Op.isMachineOpcode())
|
|
|
|
return Op.getMachineOpcode() == TargetOpcode::IMPLICIT_DEF;
|
|
|
|
return Op.getOpcode() == ISD::UNDEF;
|
|
|
|
}
|
2018-02-01 05:17:03 +08:00
|
|
|
SDValue getInstr(unsigned MachineOpc, const SDLoc &dl, MVT Ty,
|
|
|
|
ArrayRef<SDValue> Ops, SelectionDAG &DAG) const {
|
2017-12-07 00:40:37 +08:00
|
|
|
SDNode *N = DAG.getMachineNode(MachineOpc, dl, Ty, Ops);
|
|
|
|
return SDValue(N, 0);
|
|
|
|
}
|
2017-12-21 04:49:43 +08:00
|
|
|
SDValue getZero(const SDLoc &dl, MVT Ty, SelectionDAG &DAG) const;
|
2017-11-23 04:56:23 +08:00
|
|
|
|
2017-12-07 00:40:37 +08:00
|
|
|
using VectorPair = std::pair<SDValue, SDValue>;
|
|
|
|
using TypePair = std::pair<MVT, MVT>;
|
|
|
|
|
|
|
|
SDValue getInt(unsigned IntId, MVT ResTy, ArrayRef<SDValue> Ops,
|
|
|
|
const SDLoc &dl, SelectionDAG &DAG) const;
|
|
|
|
|
2017-12-08 01:37:28 +08:00
|
|
|
MVT ty(SDValue Op) const {
|
|
|
|
return Op.getValueType().getSimpleVT();
|
|
|
|
}
|
2017-12-07 00:40:37 +08:00
|
|
|
TypePair ty(const VectorPair &Ops) const {
|
|
|
|
return { Ops.first.getValueType().getSimpleVT(),
|
|
|
|
Ops.second.getValueType().getSimpleVT() };
|
|
|
|
}
|
2017-12-08 01:37:28 +08:00
|
|
|
MVT tyScalar(MVT Ty) const {
|
|
|
|
if (!Ty.isVector())
|
|
|
|
return Ty;
|
|
|
|
return MVT::getIntegerVT(Ty.getSizeInBits());
|
|
|
|
}
|
|
|
|
MVT tyVector(MVT Ty, MVT ElemTy) const {
|
|
|
|
if (Ty.isVector() && Ty.getVectorElementType() == ElemTy)
|
|
|
|
return Ty;
|
2018-01-24 01:53:59 +08:00
|
|
|
unsigned TyWidth = Ty.getSizeInBits();
|
|
|
|
unsigned ElemWidth = ElemTy.getSizeInBits();
|
2017-12-08 01:37:28 +08:00
|
|
|
assert((TyWidth % ElemWidth) == 0);
|
|
|
|
return MVT::getVectorVT(ElemTy, TyWidth/ElemWidth);
|
|
|
|
}
|
2017-12-07 00:40:37 +08:00
|
|
|
|
|
|
|
MVT typeJoin(const TypePair &Tys) const;
|
|
|
|
TypePair typeSplit(MVT Ty) const;
|
|
|
|
MVT typeExtElem(MVT VecTy, unsigned Factor) const;
|
|
|
|
MVT typeTruncElem(MVT VecTy, unsigned Factor) const;
|
|
|
|
|
|
|
|
SDValue opJoin(const VectorPair &Ops, const SDLoc &dl,
|
|
|
|
SelectionDAG &DAG) const;
|
|
|
|
VectorPair opSplit(SDValue Vec, const SDLoc &dl, SelectionDAG &DAG) const;
|
|
|
|
SDValue opCastElem(SDValue Vec, MVT ElemTy, SelectionDAG &DAG) const;
|
|
|
|
|
2018-02-06 22:21:31 +08:00
|
|
|
bool isHvxSingleTy(MVT Ty) const;
|
|
|
|
bool isHvxPairTy(MVT Ty) const;
|
2017-12-07 00:40:37 +08:00
|
|
|
SDValue convertToByteIndex(SDValue ElemIdx, MVT ElemTy,
|
|
|
|
SelectionDAG &DAG) const;
|
|
|
|
SDValue getIndexInWord32(SDValue Idx, MVT ElemTy, SelectionDAG &DAG) const;
|
2017-12-08 01:37:28 +08:00
|
|
|
SDValue getByteShuffle(const SDLoc &dl, SDValue Op0, SDValue Op1,
|
|
|
|
ArrayRef<int> Mask, SelectionDAG &DAG) const;
|
2017-12-07 00:40:37 +08:00
|
|
|
|
2018-01-24 01:53:59 +08:00
|
|
|
SDValue buildHvxVectorReg(ArrayRef<SDValue> Values, const SDLoc &dl,
|
|
|
|
MVT VecTy, SelectionDAG &DAG) const;
|
2017-12-21 04:49:43 +08:00
|
|
|
SDValue buildHvxVectorPred(ArrayRef<SDValue> Values, const SDLoc &dl,
|
|
|
|
MVT VecTy, SelectionDAG &DAG) const;
|
2018-01-24 01:53:59 +08:00
|
|
|
SDValue createHvxPrefixPred(SDValue PredV, const SDLoc &dl,
|
|
|
|
unsigned BitBytes, bool ZeroFill,
|
|
|
|
SelectionDAG &DAG) const;
|
|
|
|
SDValue extractHvxElementReg(SDValue VecV, SDValue IdxV, const SDLoc &dl,
|
|
|
|
MVT ResTy, SelectionDAG &DAG) const;
|
|
|
|
SDValue extractHvxElementPred(SDValue VecV, SDValue IdxV, const SDLoc &dl,
|
|
|
|
MVT ResTy, SelectionDAG &DAG) const;
|
|
|
|
SDValue insertHvxElementReg(SDValue VecV, SDValue IdxV, SDValue ValV,
|
|
|
|
const SDLoc &dl, SelectionDAG &DAG) const;
|
|
|
|
SDValue insertHvxElementPred(SDValue VecV, SDValue IdxV, SDValue ValV,
|
|
|
|
const SDLoc &dl, SelectionDAG &DAG) const;
|
|
|
|
SDValue extractHvxSubvectorReg(SDValue VecV, SDValue IdxV, const SDLoc &dl,
|
|
|
|
MVT ResTy, SelectionDAG &DAG) const;
|
|
|
|
SDValue extractHvxSubvectorPred(SDValue VecV, SDValue IdxV, const SDLoc &dl,
|
|
|
|
MVT ResTy, SelectionDAG &DAG) const;
|
|
|
|
SDValue insertHvxSubvectorReg(SDValue VecV, SDValue SubV, SDValue IdxV,
|
|
|
|
const SDLoc &dl, SelectionDAG &DAG) const;
|
|
|
|
SDValue insertHvxSubvectorPred(SDValue VecV, SDValue SubV, SDValue IdxV,
|
|
|
|
const SDLoc &dl, SelectionDAG &DAG) const;
|
|
|
|
SDValue extendHvxVectorPred(SDValue VecV, const SDLoc &dl, MVT ResTy,
|
|
|
|
bool ZeroExt, SelectionDAG &DAG) const;
|
2017-12-21 04:49:43 +08:00
|
|
|
|
2017-12-07 00:40:37 +08:00
|
|
|
SDValue LowerHvxBuildVector(SDValue Op, SelectionDAG &DAG) const;
|
2018-01-24 01:53:59 +08:00
|
|
|
SDValue LowerHvxConcatVectors(SDValue Op, SelectionDAG &DAG) const;
|
2017-12-07 00:40:37 +08:00
|
|
|
SDValue LowerHvxExtractElement(SDValue Op, SelectionDAG &DAG) const;
|
|
|
|
SDValue LowerHvxInsertElement(SDValue Op, SelectionDAG &DAG) const;
|
|
|
|
SDValue LowerHvxExtractSubvector(SDValue Op, SelectionDAG &DAG) const;
|
|
|
|
SDValue LowerHvxInsertSubvector(SDValue Op, SelectionDAG &DAG) const;
|
2018-02-07 04:22:20 +08:00
|
|
|
|
|
|
|
SDValue LowerHvxAnyExt(SDValue Op, SelectionDAG &DAG) const;
|
|
|
|
SDValue LowerHvxSignExt(SDValue Op, SelectionDAG &DAG) const;
|
|
|
|
SDValue LowerHvxZeroExt(SDValue Op, SelectionDAG &DAG) const;
|
2018-06-01 22:52:58 +08:00
|
|
|
SDValue LowerHvxCttz(SDValue Op, SelectionDAG &DAG) const;
|
2017-12-08 01:37:28 +08:00
|
|
|
SDValue LowerHvxMul(SDValue Op, SelectionDAG &DAG) const;
|
2018-01-16 02:43:55 +08:00
|
|
|
SDValue LowerHvxMulh(SDValue Op, SelectionDAG &DAG) const;
|
2017-12-15 05:28:48 +08:00
|
|
|
SDValue LowerHvxSetCC(SDValue Op, SelectionDAG &DAG) const;
|
2017-12-19 02:32:27 +08:00
|
|
|
SDValue LowerHvxExtend(SDValue Op, SelectionDAG &DAG) const;
|
2018-02-01 04:49:24 +08:00
|
|
|
SDValue LowerHvxShift(SDValue Op, SelectionDAG &DAG) const;
|
2017-12-07 00:40:37 +08:00
|
|
|
|
2018-02-06 22:24:57 +08:00
|
|
|
SDValue SplitHvxPairOp(SDValue Op, SelectionDAG &DAG) const;
|
2018-02-15 04:46:06 +08:00
|
|
|
SDValue SplitHvxMemOp(SDValue Op, SelectionDAG &DAG) const;
|
2018-02-06 22:24:57 +08:00
|
|
|
|
2015-11-27 02:38:27 +08:00
|
|
|
std::pair<const TargetRegisterClass*, uint8_t>
|
|
|
|
findRepresentativeClass(const TargetRegisterInfo *TRI, MVT VT)
|
|
|
|
const override;
|
2018-02-06 22:24:57 +08:00
|
|
|
|
|
|
|
bool isHvxOperation(SDValue Op) const;
|
|
|
|
SDValue LowerHvxOperation(SDValue Op, SelectionDAG &DAG) const;
|
2019-08-16 00:13:17 +08:00
|
|
|
|
|
|
|
SDValue PerformHvxDAGCombine(SDNode *N, DAGCombinerInfo &DCI) const;
|
2011-12-13 05:14:40 +08:00
|
|
|
};
|
2016-12-17 09:09:05 +08:00
|
|
|
|
2011-12-13 05:14:40 +08:00
|
|
|
} // end namespace llvm
|
|
|
|
|
2016-12-17 09:09:05 +08:00
|
|
|
#endif // LLVM_LIB_TARGET_HEXAGON_HEXAGONISELLOWERING_H
|