2012-02-18 20:03:15 +08:00
|
|
|
//===-- MSP430ISelLowering.h - MSP430 DAG Lowering Interface ----*- C++ -*-===//
|
2009-05-03 20:57:15 +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
|
2009-05-03 20:57:15 +08:00
|
|
|
//
|
|
|
|
//===----------------------------------------------------------------------===//
|
|
|
|
//
|
|
|
|
// This file defines the interfaces that MSP430 uses to lower LLVM code into a
|
|
|
|
// selection DAG.
|
|
|
|
//
|
|
|
|
//===----------------------------------------------------------------------===//
|
|
|
|
|
2014-08-14 00:26:38 +08:00
|
|
|
#ifndef LLVM_LIB_TARGET_MSP430_MSP430ISELLOWERING_H
|
|
|
|
#define LLVM_LIB_TARGET_MSP430_MSP430ISELLOWERING_H
|
2009-05-03 20:57:15 +08:00
|
|
|
|
|
|
|
#include "MSP430.h"
|
|
|
|
#include "llvm/CodeGen/SelectionDAG.h"
|
2017-11-17 09:07:10 +08:00
|
|
|
#include "llvm/CodeGen/TargetLowering.h"
|
2009-05-03 20:57:15 +08:00
|
|
|
|
|
|
|
namespace llvm {
|
2009-05-03 20:59:50 +08:00
|
|
|
namespace MSP430ISD {
|
2015-05-08 05:33:59 +08:00
|
|
|
enum NodeType : unsigned {
|
2009-05-03 20:59:50 +08:00
|
|
|
FIRST_NUMBER = ISD::BUILTIN_OP_END,
|
|
|
|
|
|
|
|
/// Return with a flag operand. Operand 0 is the chain operand.
|
2009-05-03 21:03:33 +08:00
|
|
|
RET_FLAG,
|
|
|
|
|
2009-12-07 10:27:53 +08:00
|
|
|
/// Same as RET_FLAG, but used for returning from ISRs.
|
|
|
|
RETI_FLAG,
|
|
|
|
|
2009-05-03 21:13:17 +08:00
|
|
|
/// Y = R{R,L}A X, rotate right (left) arithmetically
|
|
|
|
RRA, RLA,
|
2009-05-03 21:07:31 +08:00
|
|
|
|
2009-05-03 21:16:17 +08:00
|
|
|
/// Y = RRC X, rotate right via carry
|
|
|
|
RRC,
|
|
|
|
|
2018-11-15 20:29:43 +08:00
|
|
|
/// Rotate right via carry, carry gets cleared beforehand by clrc
|
|
|
|
RRCL,
|
|
|
|
|
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
|
|
|
/// CALL - These operations represent an abstract call
|
2009-05-03 21:07:31 +08:00
|
|
|
/// instruction, which includes a bunch of information.
|
2009-05-03 21:08:33 +08:00
|
|
|
CALL,
|
|
|
|
|
|
|
|
/// Wrapper - A wrapper node for TargetConstantPool, TargetExternalSymbol,
|
|
|
|
/// and TargetGlobalAddress.
|
2009-05-03 21:12:06 +08:00
|
|
|
Wrapper,
|
|
|
|
|
|
|
|
/// CMP - Compare instruction.
|
|
|
|
CMP,
|
|
|
|
|
2009-12-13 02:55:37 +08:00
|
|
|
/// SetCC - Operand 0 is condition code, and operand 1 is the flag
|
2009-05-03 21:12:06 +08:00
|
|
|
/// operand produced by a CMP instruction.
|
|
|
|
SETCC,
|
|
|
|
|
|
|
|
/// MSP430 conditional branches. Operand 0 is the chain operand, operand 1
|
|
|
|
/// is the block to branch if condition is true, operand 2 is the
|
|
|
|
/// condition code, and operand 3 is the flag operand produced by a CMP
|
|
|
|
/// instruction.
|
2009-05-03 21:19:09 +08:00
|
|
|
BR_CC,
|
2009-05-03 21:12:23 +08:00
|
|
|
|
2009-12-13 02:55:37 +08:00
|
|
|
/// SELECT_CC - Operand 0 and operand 1 are selection variable, operand 3
|
2009-05-03 21:19:09 +08:00
|
|
|
/// is condition code and operand 4 is flag operand.
|
2009-12-13 02:55:37 +08:00
|
|
|
SELECT_CC,
|
|
|
|
|
2018-11-15 20:29:43 +08:00
|
|
|
/// DADD - Decimal addition with carry
|
|
|
|
/// TODO Nothing generates a node of this type yet.
|
|
|
|
DADD,
|
2009-05-03 20:59:50 +08:00
|
|
|
};
|
2015-06-23 17:49:53 +08:00
|
|
|
}
|
2009-05-03 20:57:15 +08:00
|
|
|
|
2015-02-26 08:00:24 +08:00
|
|
|
class MSP430Subtarget;
|
2009-05-03 20:57:15 +08:00
|
|
|
class MSP430TargetLowering : public TargetLowering {
|
|
|
|
public:
|
2015-02-26 08:00:24 +08:00
|
|
|
explicit MSP430TargetLowering(const TargetMachine &TM,
|
|
|
|
const MSP430Subtarget &STI);
|
2009-05-03 20:57:15 +08:00
|
|
|
|
2015-07-09 23:12:23 +08:00
|
|
|
MVT getScalarShiftAmountTy(const DataLayout &, EVT) const override {
|
2015-07-09 10:09:20 +08:00
|
|
|
return MVT::i8;
|
|
|
|
}
|
2011-02-26 05:41:48 +08:00
|
|
|
|
2009-05-03 20:57:15 +08:00
|
|
|
/// LowerOperation - Provide custom lowering hooks for some operations.
|
2014-04-29 15:58:09 +08:00
|
|
|
SDValue LowerOperation(SDValue Op, SelectionDAG &DAG) const override;
|
2009-05-03 20:59:50 +08:00
|
|
|
|
|
|
|
/// getTargetNodeName - This method returns the name of a target specific
|
|
|
|
/// DAG node.
|
2014-04-29 15:58:09 +08:00
|
|
|
const char *getTargetNodeName(unsigned Opcode) const override;
|
2009-05-03 20:59:50 +08:00
|
|
|
|
2010-04-17 23:26:15 +08:00
|
|
|
SDValue LowerShifts(SDValue Op, SelectionDAG &DAG) const;
|
|
|
|
SDValue LowerGlobalAddress(SDValue Op, SelectionDAG &DAG) const;
|
2010-05-01 20:04:32 +08:00
|
|
|
SDValue LowerBlockAddress(SDValue Op, SelectionDAG &DAG) const;
|
2010-04-17 23:26:15 +08:00
|
|
|
SDValue LowerExternalSymbol(SDValue Op, SelectionDAG &DAG) const;
|
|
|
|
SDValue LowerBR_CC(SDValue Op, SelectionDAG &DAG) const;
|
|
|
|
SDValue LowerSETCC(SDValue Op, SelectionDAG &DAG) const;
|
|
|
|
SDValue LowerSELECT_CC(SDValue Op, SelectionDAG &DAG) const;
|
|
|
|
SDValue LowerSIGN_EXTEND(SDValue Op, SelectionDAG &DAG) const;
|
|
|
|
SDValue LowerRETURNADDR(SDValue Op, SelectionDAG &DAG) const;
|
|
|
|
SDValue LowerFRAMEADDR(SDValue Op, SelectionDAG &DAG) const;
|
2012-11-22 01:28:27 +08:00
|
|
|
SDValue LowerVASTART(SDValue Op, SelectionDAG &DAG) const;
|
2013-07-02 03:44:44 +08:00
|
|
|
SDValue LowerJumpTable(SDValue Op, SelectionDAG &DAG) const;
|
2010-04-17 23:26:15 +08:00
|
|
|
SDValue getReturnAddressFrameIndex(SelectionDAG &DAG) const;
|
2009-05-03 21:07:31 +08:00
|
|
|
|
2009-08-26 21:44:29 +08:00
|
|
|
TargetLowering::ConstraintType
|
2015-07-06 03:29:18 +08:00
|
|
|
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;
|
2009-08-26 21:44:29 +08:00
|
|
|
|
2010-01-16 05:19:43 +08:00
|
|
|
/// isTruncateFree - Return true if it's free to truncate a value of type
|
|
|
|
/// Ty1 to type Ty2. e.g. On msp430 it's free to truncate a i16 value in
|
|
|
|
/// register R15W to i8 by referencing its sub-register R15B.
|
2014-04-29 15:58:09 +08:00
|
|
|
bool isTruncateFree(Type *Ty1, Type *Ty2) const override;
|
|
|
|
bool isTruncateFree(EVT VT1, EVT VT2) const override;
|
2010-01-16 05:19:43 +08:00
|
|
|
|
|
|
|
/// isZExtFree - Return true if any actual instruction that defines a value
|
|
|
|
/// of type Ty1 implicit zero-extends the value to Ty2 in the result
|
|
|
|
/// register. This does not necessarily include registers defined in unknown
|
|
|
|
/// ways, such as incoming arguments, or copies from unknown virtual
|
|
|
|
/// registers. Also, if isTruncateFree(Ty2, Ty1) is true, this does not
|
|
|
|
/// necessarily apply to truncate instructions. e.g. on msp430, all
|
|
|
|
/// instructions that define 8-bit values implicit zero-extend the result
|
|
|
|
/// out to 16 bits.
|
2014-04-29 15:58:09 +08:00
|
|
|
bool isZExtFree(Type *Ty1, Type *Ty2) const override;
|
|
|
|
bool isZExtFree(EVT VT1, EVT VT2) const override;
|
|
|
|
bool isZExtFree(SDValue Val, EVT VT2) const override;
|
2010-01-16 05:19:43 +08:00
|
|
|
|
2019-11-09 06:16:44 +08:00
|
|
|
bool isLegalICmpImmediate(int64_t) const override;
|
2019-11-13 16:23:08 +08:00
|
|
|
bool shouldAvoidTransformToShift(EVT VT, unsigned Amount) const override;
|
2019-10-20 00:57:02 +08:00
|
|
|
|
2016-07-01 06:52:52 +08:00
|
|
|
MachineBasicBlock *
|
|
|
|
EmitInstrWithCustomInserter(MachineInstr &MI,
|
|
|
|
MachineBasicBlock *BB) const override;
|
|
|
|
MachineBasicBlock *EmitShiftInstr(MachineInstr &MI,
|
2010-05-01 08:01:06 +08:00
|
|
|
MachineBasicBlock *BB) const;
|
2009-05-03 21:07:31 +08:00
|
|
|
|
2009-05-03 20:57:15 +08:00
|
|
|
private:
|
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;
|
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 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 LowerCallResult(SDValue Chain, SDValue InFlag,
|
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
|
|
|
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
|
|
|
|
2014-04-29 15:58:09 +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;
|
2014-04-29 15:58:09 +08:00
|
|
|
SDValue
|
2012-05-26 00:35:28 +08:00
|
|
|
LowerCall(TargetLowering::CallLoweringInfo &CLI,
|
2014-04-29 15:58:09 +08:00
|
|
|
SmallVectorImpl<SDValue> &InVals) const override;
|
|
|
|
|
2017-03-03 04:25:10 +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,
|
2014-04-29 15:58:09 +08:00
|
|
|
const SmallVectorImpl<ISD::OutputArg> &Outs,
|
|
|
|
const SmallVectorImpl<SDValue> &OutVals,
|
2016-06-12 23:39:02 +08:00
|
|
|
const SDLoc &dl, SelectionDAG &DAG) const override;
|
2014-04-29 15:58:09 +08:00
|
|
|
|
|
|
|
bool getPostIndexedAddressParts(SDNode *N, SDNode *Op,
|
|
|
|
SDValue &Base,
|
|
|
|
SDValue &Offset,
|
|
|
|
ISD::MemIndexedMode &AM,
|
|
|
|
SelectionDAG &DAG) const override;
|
2009-05-03 20:57:15 +08:00
|
|
|
};
|
|
|
|
} // namespace llvm
|
|
|
|
|
2014-08-14 00:26:38 +08:00
|
|
|
#endif
|