2008-11-07 18:59:00 +08:00
|
|
|
//===-- XCoreISelLowering.h - XCore 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
|
2008-11-07 18:59:00 +08:00
|
|
|
//
|
|
|
|
//===----------------------------------------------------------------------===//
|
|
|
|
//
|
|
|
|
// This file defines the interfaces that XCore uses to lower LLVM code into a
|
|
|
|
// selection DAG.
|
|
|
|
//
|
|
|
|
//===----------------------------------------------------------------------===//
|
|
|
|
|
2014-08-14 00:26:38 +08:00
|
|
|
#ifndef LLVM_LIB_TARGET_XCORE_XCOREISELLOWERING_H
|
|
|
|
#define LLVM_LIB_TARGET_XCORE_XCOREISELLOWERING_H
|
2008-11-07 18:59:00 +08:00
|
|
|
|
2012-03-18 02:46:09 +08:00
|
|
|
#include "XCore.h"
|
2008-11-07 18:59:00 +08:00
|
|
|
#include "llvm/CodeGen/SelectionDAG.h"
|
2017-11-17 09:07:10 +08:00
|
|
|
#include "llvm/CodeGen/TargetLowering.h"
|
2008-11-07 18:59:00 +08:00
|
|
|
|
|
|
|
namespace llvm {
|
2011-02-26 05:41:48 +08:00
|
|
|
|
2008-11-07 18:59:00 +08:00
|
|
|
// Forward delcarations
|
|
|
|
class XCoreSubtarget;
|
|
|
|
class XCoreTargetMachine;
|
2011-02-26 05:41:48 +08:00
|
|
|
|
2008-11-07 18:59:00 +08:00
|
|
|
namespace XCoreISD {
|
2015-05-08 05:33:59 +08:00
|
|
|
enum NodeType : unsigned {
|
2008-11-07 18:59:00 +08:00
|
|
|
// Start the numbering where the builtin ops and target ops leave off.
|
2010-02-15 14:38:41 +08:00
|
|
|
FIRST_NUMBER = ISD::BUILTIN_OP_END,
|
2008-11-07 18:59:00 +08:00
|
|
|
|
|
|
|
// Branch and link (call)
|
|
|
|
BL,
|
|
|
|
|
|
|
|
// pc relative address
|
|
|
|
PCRelativeWrapper,
|
|
|
|
|
|
|
|
// dp relative address
|
|
|
|
DPRelativeWrapper,
|
2011-02-26 05:41:48 +08:00
|
|
|
|
2008-11-07 18:59:00 +08:00
|
|
|
// cp relative address
|
|
|
|
CPRelativeWrapper,
|
2011-02-26 05:41:48 +08:00
|
|
|
|
2014-02-28 01:47:54 +08:00
|
|
|
// Load word from stack
|
|
|
|
LDWSP,
|
|
|
|
|
2008-11-07 18:59:00 +08:00
|
|
|
// Store word to stack
|
|
|
|
STWSP,
|
|
|
|
|
|
|
|
// Corresponds to retsp instruction
|
|
|
|
RETSP,
|
2011-02-26 05:41:48 +08:00
|
|
|
|
2008-11-07 18:59:00 +08:00
|
|
|
// Corresponds to LADD instruction
|
|
|
|
LADD,
|
|
|
|
|
|
|
|
// Corresponds to LSUB instruction
|
2010-02-23 21:25:07 +08:00
|
|
|
LSUB,
|
|
|
|
|
2010-03-10 21:27:10 +08:00
|
|
|
// Corresponds to LMUL instruction
|
|
|
|
LMUL,
|
|
|
|
|
2010-03-10 19:41:08 +08:00
|
|
|
// Corresponds to MACCU instruction
|
|
|
|
MACCU,
|
|
|
|
|
|
|
|
// Corresponds to MACCS instruction
|
|
|
|
MACCS,
|
|
|
|
|
2013-01-26 05:20:28 +08:00
|
|
|
// Corresponds to CRC8 instruction
|
|
|
|
CRC8,
|
|
|
|
|
2010-02-23 21:25:07 +08:00
|
|
|
// Jumptable branch.
|
|
|
|
BR_JT,
|
|
|
|
|
|
|
|
// Jumptable branch using long branches for each entry.
|
2013-11-12 18:11:26 +08:00
|
|
|
BR_JT32,
|
|
|
|
|
2014-01-06 22:21:00 +08:00
|
|
|
// Offset from frame pointer to the first (possible) on-stack argument
|
|
|
|
FRAME_TO_ARGS_OFFSET,
|
|
|
|
|
2014-01-06 22:21:07 +08:00
|
|
|
// Exception handler return. The stack is restored to the first
|
|
|
|
// followed by a jump to the second argument.
|
|
|
|
EH_RETURN,
|
|
|
|
|
2013-11-12 18:11:26 +08:00
|
|
|
// Memory barrier.
|
|
|
|
MEMBARRIER
|
2008-11-07 18:59:00 +08:00
|
|
|
};
|
2015-06-23 17:49:53 +08:00
|
|
|
}
|
2008-11-07 18:59:00 +08:00
|
|
|
|
|
|
|
//===--------------------------------------------------------------------===//
|
|
|
|
// TargetLowering Implementation
|
|
|
|
//===--------------------------------------------------------------------===//
|
2011-02-26 05:41:48 +08:00
|
|
|
class XCoreTargetLowering : public TargetLowering
|
2008-11-07 18:59:00 +08:00
|
|
|
{
|
|
|
|
public:
|
2015-02-03 01:52:27 +08:00
|
|
|
explicit XCoreTargetLowering(const TargetMachine &TM,
|
|
|
|
const XCoreSubtarget &Subtarget);
|
2008-11-07 18:59:00 +08:00
|
|
|
|
2013-10-11 18:26:29 +08:00
|
|
|
using TargetLowering::isZExtFree;
|
2014-04-29 15:57:00 +08:00
|
|
|
bool isZExtFree(SDValue Val, EVT VT2) const override;
|
2013-10-11 18:26:29 +08:00
|
|
|
|
|
|
|
|
2014-04-29 15:57:00 +08:00
|
|
|
unsigned getJumpTableEncoding() const override;
|
2015-07-09 23:12:23 +08:00
|
|
|
MVT getScalarShiftAmountTy(const DataLayout &DL, EVT) const override {
|
2015-07-09 10:09:20 +08:00
|
|
|
return MVT::i32;
|
|
|
|
}
|
2010-03-11 22:58:56 +08:00
|
|
|
|
2008-11-07 18:59:00 +08:00
|
|
|
/// LowerOperation - Provide custom lowering hooks for some operations.
|
2014-04-29 15:57:00 +08:00
|
|
|
SDValue LowerOperation(SDValue Op, SelectionDAG &DAG) const override;
|
2008-11-14 23:59:19 +08:00
|
|
|
|
2008-12-01 19:39:25 +08:00
|
|
|
/// ReplaceNodeResults - Replace the results of node with an illegal result
|
|
|
|
/// type with new values built out of custom code.
|
|
|
|
///
|
2014-04-29 15:57:00 +08:00
|
|
|
void ReplaceNodeResults(SDNode *N, SmallVectorImpl<SDValue>&Results,
|
|
|
|
SelectionDAG &DAG) const override;
|
2008-11-07 18:59:00 +08:00
|
|
|
|
2011-02-26 05:41:48 +08:00
|
|
|
/// getTargetNodeName - This method returns the name of a target specific
|
2008-11-07 18:59:00 +08:00
|
|
|
// DAG node.
|
2014-04-29 15:57:00 +08:00
|
|
|
const char *getTargetNodeName(unsigned Opcode) const override;
|
2011-02-26 05:41:48 +08:00
|
|
|
|
2014-04-29 15:57:00 +08:00
|
|
|
MachineBasicBlock *
|
2016-07-01 06:52:52 +08:00
|
|
|
EmitInstrWithCustomInserter(MachineInstr &MI,
|
|
|
|
MachineBasicBlock *MBB) const override;
|
2008-11-07 18:59:00 +08:00
|
|
|
|
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;
|
2008-11-07 18:59:00 +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 XCore::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 XCore::R1;
|
|
|
|
}
|
|
|
|
|
2008-11-07 18:59:00 +08:00
|
|
|
private:
|
2014-07-02 08:10:09 +08:00
|
|
|
const TargetMachine &TM;
|
2008-11-07 18:59:00 +08:00
|
|
|
const XCoreSubtarget &Subtarget;
|
2011-02-26 05:41:48 +08:00
|
|
|
|
2008-11-07 18:59:00 +08:00
|
|
|
// Lower Operand helpers
|
2016-06-12 23:39:02 +08:00
|
|
|
SDValue LowerCCCArguments(SDValue Chain, CallingConv::ID CallConv,
|
Major calling convention code refactoring.
Instead of awkwardly encoding calling-convention information with ISD::CALL,
ISD::FORMAL_ARGUMENTS, ISD::RET, and ISD::ARG_FLAGS nodes, TargetLowering
provides three virtual functions for targets to override:
LowerFormalArguments, LowerCall, and LowerRet, which replace the custom
lowering done on the special nodes. They provide the same information, but
in a more immediately usable format.
This also reworks much of the target-independent tail call logic. The
decision of whether or not to perform a tail call is now cleanly split
between target-independent portions, and the target dependent portion
in IsEligibleForTailCallOptimization.
This also synchronizes all in-tree targets, to help enable future
refactoring and feature work.
llvm-svn: 78142
2009-08-05 09:29:28 +08:00
|
|
|
bool isVarArg,
|
|
|
|
const SmallVectorImpl<ISD::InputArg> &Ins,
|
2016-06-12 23:39:02 +08:00
|
|
|
const SDLoc &dl, SelectionDAG &DAG,
|
2010-04-17 23:26:15 +08:00
|
|
|
SmallVectorImpl<SDValue> &InVals) const;
|
Major calling convention code refactoring.
Instead of awkwardly encoding calling-convention information with ISD::CALL,
ISD::FORMAL_ARGUMENTS, ISD::RET, and ISD::ARG_FLAGS nodes, TargetLowering
provides three virtual functions for targets to override:
LowerFormalArguments, LowerCall, and LowerRet, which replace the custom
lowering done on the special nodes. They provide the same information, but
in a more immediately usable format.
This also reworks much of the target-independent tail call logic. The
decision of whether or not to perform a tail call is now cleanly split
between target-independent portions, and the target dependent portion
in IsEligibleForTailCallOptimization.
This also synchronizes all in-tree targets, to help enable future
refactoring and feature work.
llvm-svn: 78142
2009-08-05 09:29:28 +08:00
|
|
|
SDValue LowerCCCCallTo(SDValue Chain, SDValue Callee,
|
2009-09-02 16:44:58 +08:00
|
|
|
CallingConv::ID CallConv, bool isVarArg,
|
Major calling convention code refactoring.
Instead of awkwardly encoding calling-convention information with ISD::CALL,
ISD::FORMAL_ARGUMENTS, ISD::RET, and ISD::ARG_FLAGS nodes, TargetLowering
provides three virtual functions for targets to override:
LowerFormalArguments, LowerCall, and LowerRet, which replace the custom
lowering done on the special nodes. They provide the same information, but
in a more immediately usable format.
This also reworks much of the target-independent tail call logic. The
decision of whether or not to perform a tail call is now cleanly split
between target-independent portions, and the target dependent portion
in IsEligibleForTailCallOptimization.
This also synchronizes all in-tree targets, to help enable future
refactoring and feature work.
llvm-svn: 78142
2009-08-05 09:29:28 +08:00
|
|
|
bool isTailCall,
|
|
|
|
const SmallVectorImpl<ISD::OutputArg> &Outs,
|
2010-07-07 23:54:55 +08:00
|
|
|
const SmallVectorImpl<SDValue> &OutVals,
|
Major calling convention code refactoring.
Instead of awkwardly encoding calling-convention information with ISD::CALL,
ISD::FORMAL_ARGUMENTS, ISD::RET, and ISD::ARG_FLAGS nodes, TargetLowering
provides three virtual functions for targets to override:
LowerFormalArguments, LowerCall, and LowerRet, which replace the custom
lowering done on the special nodes. They provide the same information, but
in a more immediately usable format.
This also reworks much of the target-independent tail call logic. The
decision of whether or not to perform a tail call is now cleanly split
between target-independent portions, and the target dependent portion
in IsEligibleForTailCallOptimization.
This also synchronizes all in-tree targets, to help enable future
refactoring and feature work.
llvm-svn: 78142
2009-08-05 09:29:28 +08:00
|
|
|
const SmallVectorImpl<ISD::InputArg> &Ins,
|
2016-06-12 23:39:02 +08:00
|
|
|
const SDLoc &dl, SelectionDAG &DAG,
|
2010-04-17 23:26:15 +08:00
|
|
|
SmallVectorImpl<SDValue> &InVals) const;
|
|
|
|
SDValue getReturnAddressFrameIndex(SelectionDAG &DAG) const;
|
2010-04-15 09:51:59 +08:00
|
|
|
SDValue getGlobalAddressWrapper(SDValue GA, const GlobalValue *GV,
|
2010-04-17 23:26:15 +08:00
|
|
|
SelectionDAG &DAG) const;
|
2016-06-12 23:39:02 +08:00
|
|
|
SDValue lowerLoadWordFromAlignedBasePlusOffset(const SDLoc &DL,
|
|
|
|
SDValue Chain, SDValue Base,
|
|
|
|
int64_t Offset,
|
2013-05-05 01:17:10 +08:00
|
|
|
SelectionDAG &DAG) const;
|
2008-11-07 18:59:00 +08:00
|
|
|
|
|
|
|
// Lower Operand specifics
|
2010-04-17 23:26:15 +08:00
|
|
|
SDValue LowerLOAD(SDValue Op, SelectionDAG &DAG) const;
|
|
|
|
SDValue LowerSTORE(SDValue Op, SelectionDAG &DAG) const;
|
2014-01-06 22:21:07 +08:00
|
|
|
SDValue LowerEH_RETURN(SDValue Op, SelectionDAG &DAG) const;
|
2010-04-17 23:26:15 +08:00
|
|
|
SDValue LowerGlobalAddress(SDValue Op, SelectionDAG &DAG) const;
|
|
|
|
SDValue LowerGlobalTLSAddress(SDValue Op, SelectionDAG &DAG) const;
|
|
|
|
SDValue LowerBlockAddress(SDValue Op, SelectionDAG &DAG) const;
|
|
|
|
SDValue LowerConstantPool(SDValue Op, SelectionDAG &DAG) const;
|
|
|
|
SDValue LowerBR_JT(SDValue Op, SelectionDAG &DAG) const;
|
|
|
|
SDValue LowerVAARG(SDValue Op, SelectionDAG &DAG) const;
|
|
|
|
SDValue LowerVASTART(SDValue Op, SelectionDAG &DAG) const;
|
|
|
|
SDValue LowerUMUL_LOHI(SDValue Op, SelectionDAG &DAG) const;
|
|
|
|
SDValue LowerSMUL_LOHI(SDValue Op, SelectionDAG &DAG) const;
|
|
|
|
SDValue LowerFRAMEADDR(SDValue Op, SelectionDAG &DAG) const;
|
2014-01-06 22:21:00 +08:00
|
|
|
SDValue LowerFRAME_TO_ARGS_OFFSET(SDValue Op, SelectionDAG &DAG) const;
|
2014-01-06 22:20:53 +08:00
|
|
|
SDValue LowerRETURNADDR(SDValue Op, SelectionDAG &DAG) const;
|
2011-09-06 21:37:06 +08:00
|
|
|
SDValue LowerINIT_TRAMPOLINE(SDValue Op, SelectionDAG &DAG) const;
|
|
|
|
SDValue LowerADJUST_TRAMPOLINE(SDValue Op, SelectionDAG &DAG) const;
|
2013-01-26 05:20:28 +08:00
|
|
|
SDValue LowerINTRINSIC_WO_CHAIN(SDValue Op, SelectionDAG &DAG) const;
|
2013-11-12 18:11:26 +08:00
|
|
|
SDValue LowerATOMIC_FENCE(SDValue Op, SelectionDAG &DAG) const;
|
2014-02-11 18:36:18 +08:00
|
|
|
SDValue LowerATOMIC_LOAD(SDValue Op, SelectionDAG &DAG) const;
|
|
|
|
SDValue LowerATOMIC_STORE(SDValue Op, SelectionDAG &DAG) const;
|
2011-02-26 05:41:48 +08:00
|
|
|
|
2008-11-07 18:59:00 +08:00
|
|
|
// Inline asm support
|
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-02-26 05:41:48 +08:00
|
|
|
|
2008-11-07 18:59:00 +08:00
|
|
|
// Expand specifics
|
2010-04-17 23:26:15 +08:00
|
|
|
SDValue TryExpandADDWithMul(SDNode *Op, SelectionDAG &DAG) const;
|
|
|
|
SDValue ExpandADDSUB(SDNode *Op, SelectionDAG &DAG) const;
|
2009-07-16 20:50:48 +08:00
|
|
|
|
2014-04-29 15:57:00 +08:00
|
|
|
SDValue PerformDAGCombine(SDNode *N, DAGCombinerInfo &DCI) const override;
|
Major calling convention code refactoring.
Instead of awkwardly encoding calling-convention information with ISD::CALL,
ISD::FORMAL_ARGUMENTS, ISD::RET, and ISD::ARG_FLAGS nodes, TargetLowering
provides three virtual functions for targets to override:
LowerFormalArguments, LowerCall, and LowerRet, which replace the custom
lowering done on the special nodes. They provide the same information, but
in a more immediately usable format.
This also reworks much of the target-independent tail call logic. The
decision of whether or not to perform a tail call is now cleanly split
between target-independent portions, and the target dependent portion
in IsEligibleForTailCallOptimization.
This also synchronizes all in-tree targets, to help enable future
refactoring and feature work.
llvm-svn: 78142
2009-08-05 09:29:28 +08:00
|
|
|
|
2014-05-15 05:14:37 +08:00
|
|
|
void computeKnownBitsForTargetNode(const SDValue Op,
|
2017-04-28 13:31:46 +08:00
|
|
|
KnownBits &Known,
|
2017-03-31 19:24:16 +08:00
|
|
|
const APInt &DemandedElts,
|
2014-05-15 05:14:37 +08:00
|
|
|
const SelectionDAG &DAG,
|
|
|
|
unsigned Depth = 0) const override;
|
2010-03-10 00:07:47 +08:00
|
|
|
|
2014-04-29 15:57:00 +08:00
|
|
|
SDValue
|
2016-06-12 23:39:02 +08:00
|
|
|
LowerFormalArguments(SDValue Chain, CallingConv::ID CallConv, bool isVarArg,
|
|
|
|
const SmallVectorImpl<ISD::InputArg> &Ins,
|
|
|
|
const SDLoc &dl, SelectionDAG &DAG,
|
|
|
|
SmallVectorImpl<SDValue> &InVals) const override;
|
Major calling convention code refactoring.
Instead of awkwardly encoding calling-convention information with ISD::CALL,
ISD::FORMAL_ARGUMENTS, ISD::RET, and ISD::ARG_FLAGS nodes, TargetLowering
provides three virtual functions for targets to override:
LowerFormalArguments, LowerCall, and LowerRet, which replace the custom
lowering done on the special nodes. They provide the same information, but
in a more immediately usable format.
This also reworks much of the target-independent tail call logic. The
decision of whether or not to perform a tail call is now cleanly split
between target-independent portions, and the target dependent portion
in IsEligibleForTailCallOptimization.
This also synchronizes all in-tree targets, to help enable future
refactoring and feature work.
llvm-svn: 78142
2009-08-05 09:29:28 +08:00
|
|
|
|
2014-04-29 15:57:00 +08:00
|
|
|
SDValue
|
2012-05-26 00:35:28 +08:00
|
|
|
LowerCall(TargetLowering::CallLoweringInfo &CLI,
|
2014-04-29 15:57:00 +08:00
|
|
|
SmallVectorImpl<SDValue> &InVals) const override;
|
Major calling convention code refactoring.
Instead of awkwardly encoding calling-convention information with ISD::CALL,
ISD::FORMAL_ARGUMENTS, ISD::RET, and ISD::ARG_FLAGS nodes, TargetLowering
provides three virtual functions for targets to override:
LowerFormalArguments, LowerCall, and LowerRet, which replace the custom
lowering done on the special nodes. They provide the same information, but
in a more immediately usable format.
This also reworks much of the target-independent tail call logic. The
decision of whether or not to perform a tail call is now cleanly split
between target-independent portions, and the target dependent portion
in IsEligibleForTailCallOptimization.
This also synchronizes all in-tree targets, to help enable future
refactoring and feature work.
llvm-svn: 78142
2009-08-05 09:29:28 +08:00
|
|
|
|
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;
|
2009-11-15 03:33:35 +08:00
|
|
|
|
2014-04-29 15:57:00 +08:00
|
|
|
bool
|
2011-06-09 07:55:35 +08:00
|
|
|
CanLowerReturn(CallingConv::ID CallConv, MachineFunction &MF,
|
2012-07-19 08:11:40 +08:00
|
|
|
bool isVarArg,
|
2010-07-10 17:00:22 +08:00
|
|
|
const SmallVectorImpl<ISD::OutputArg> &ArgsFlags,
|
2014-04-29 15:57:00 +08:00
|
|
|
LLVMContext &Context) const override;
|
2016-03-17 06:12:04 +08:00
|
|
|
bool shouldInsertFencesForAtomic(const Instruction *I) const override {
|
|
|
|
return true;
|
|
|
|
}
|
2008-11-07 18:59:00 +08:00
|
|
|
};
|
2015-06-23 17:49:53 +08:00
|
|
|
}
|
2008-11-07 18:59:00 +08:00
|
|
|
|
2014-08-14 00:26:38 +08:00
|
|
|
#endif
|