2012-02-18 12:03:15 +00:00
|
|
|
//===-- MSP430ISelLowering.h - MSP430 DAG Lowering Interface ----*- C++ -*-===//
|
2009-05-03 12:57:15 +00:00
|
|
|
//
|
|
|
|
// The LLVM Compiler Infrastructure
|
|
|
|
//
|
|
|
|
// This file is distributed under the University of Illinois Open Source
|
|
|
|
// License. See LICENSE.TXT for details.
|
|
|
|
//
|
|
|
|
//===----------------------------------------------------------------------===//
|
|
|
|
//
|
|
|
|
// This file defines the interfaces that MSP430 uses to lower LLVM code into a
|
|
|
|
// selection DAG.
|
|
|
|
//
|
|
|
|
//===----------------------------------------------------------------------===//
|
|
|
|
|
2014-08-13 16:26:38 +00:00
|
|
|
#ifndef LLVM_LIB_TARGET_MSP430_MSP430ISELLOWERING_H
|
|
|
|
#define LLVM_LIB_TARGET_MSP430_MSP430ISELLOWERING_H
|
2009-05-03 12:57:15 +00:00
|
|
|
|
|
|
|
#include "MSP430.h"
|
|
|
|
#include "llvm/CodeGen/SelectionDAG.h"
|
|
|
|
#include "llvm/Target/TargetLowering.h"
|
|
|
|
|
|
|
|
namespace llvm {
|
2009-05-03 12:59:50 +00:00
|
|
|
namespace MSP430ISD {
|
|
|
|
enum {
|
|
|
|
FIRST_NUMBER = ISD::BUILTIN_OP_END,
|
|
|
|
|
|
|
|
/// Return with a flag operand. Operand 0 is the chain operand.
|
2009-05-03 13:03:33 +00:00
|
|
|
RET_FLAG,
|
|
|
|
|
2009-12-07 02:27:53 +00:00
|
|
|
/// Same as RET_FLAG, but used for returning from ISRs.
|
|
|
|
RETI_FLAG,
|
|
|
|
|
2009-05-03 13:13:17 +00:00
|
|
|
/// Y = R{R,L}A X, rotate right (left) arithmetically
|
|
|
|
RRA, RLA,
|
2009-05-03 13:07:31 +00:00
|
|
|
|
2009-05-03 13:16:17 +00:00
|
|
|
/// Y = RRC X, rotate right via carry
|
|
|
|
RRC,
|
|
|
|
|
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.
git-svn-id: https://llvm.org/svn/llvm-project/llvm/trunk@78142 91177308-0d34-0410-b5e6-96231b3b80d8
2009-08-05 01:29:28 +00:00
|
|
|
/// CALL - These operations represent an abstract call
|
2009-05-03 13:07:31 +00:00
|
|
|
/// instruction, which includes a bunch of information.
|
2009-05-03 13:08:33 +00:00
|
|
|
CALL,
|
|
|
|
|
|
|
|
/// Wrapper - A wrapper node for TargetConstantPool, TargetExternalSymbol,
|
|
|
|
/// and TargetGlobalAddress.
|
2009-05-03 13:12:06 +00:00
|
|
|
Wrapper,
|
|
|
|
|
|
|
|
/// CMP - Compare instruction.
|
|
|
|
CMP,
|
|
|
|
|
2009-12-12 18:55:37 +00:00
|
|
|
/// SetCC - Operand 0 is condition code, and operand 1 is the flag
|
2009-05-03 13:12:06 +00: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 13:19:09 +00:00
|
|
|
BR_CC,
|
2009-05-03 13:12:23 +00:00
|
|
|
|
2009-12-12 18:55:37 +00:00
|
|
|
/// SELECT_CC - Operand 0 and operand 1 are selection variable, operand 3
|
2009-05-03 13:19:09 +00:00
|
|
|
/// is condition code and operand 4 is flag operand.
|
2009-12-12 18:55:37 +00:00
|
|
|
SELECT_CC,
|
|
|
|
|
|
|
|
/// SHL, SRA, SRL - Non-constant shifts.
|
|
|
|
SHL, SRA, SRL
|
2009-05-03 12:59:50 +00:00
|
|
|
};
|
|
|
|
}
|
2009-05-03 12:57:15 +00:00
|
|
|
|
|
|
|
class MSP430TargetLowering : public TargetLowering {
|
|
|
|
public:
|
2014-06-27 00:37:59 +00:00
|
|
|
explicit MSP430TargetLowering(const TargetMachine &TM);
|
2009-05-03 12:57:15 +00:00
|
|
|
|
2014-04-29 07:58:09 +00:00
|
|
|
MVT getScalarShiftAmountTy(EVT LHSTy) const override { return MVT::i8; }
|
2011-02-25 21:41:48 +00:00
|
|
|
|
2009-05-03 12:57:15 +00:00
|
|
|
/// LowerOperation - Provide custom lowering hooks for some operations.
|
2014-04-29 07:58:09 +00:00
|
|
|
SDValue LowerOperation(SDValue Op, SelectionDAG &DAG) const override;
|
2009-05-03 12:59:50 +00:00
|
|
|
|
|
|
|
/// getTargetNodeName - This method returns the name of a target specific
|
|
|
|
/// DAG node.
|
2014-04-29 07:58:09 +00:00
|
|
|
const char *getTargetNodeName(unsigned Opcode) const override;
|
2009-05-03 12:59:50 +00:00
|
|
|
|
2010-04-17 15:26:15 +00:00
|
|
|
SDValue LowerShifts(SDValue Op, SelectionDAG &DAG) const;
|
|
|
|
SDValue LowerGlobalAddress(SDValue Op, SelectionDAG &DAG) const;
|
2010-05-01 12:04:32 +00:00
|
|
|
SDValue LowerBlockAddress(SDValue Op, SelectionDAG &DAG) const;
|
2010-04-17 15:26:15 +00: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-21 17:28:27 +00:00
|
|
|
SDValue LowerVASTART(SDValue Op, SelectionDAG &DAG) const;
|
2013-07-01 19:44:44 +00:00
|
|
|
SDValue LowerJumpTable(SDValue Op, SelectionDAG &DAG) const;
|
2010-04-17 15:26:15 +00:00
|
|
|
SDValue getReturnAddressFrameIndex(SelectionDAG &DAG) const;
|
2009-05-03 13:07:31 +00:00
|
|
|
|
2009-08-26 13:44:29 +00:00
|
|
|
TargetLowering::ConstraintType
|
2014-04-29 07:58:09 +00:00
|
|
|
getConstraintType(const std::string &Constraint) const override;
|
2009-08-26 13:44:29 +00:00
|
|
|
std::pair<unsigned, const TargetRegisterClass*>
|
2014-04-29 07:58:09 +00:00
|
|
|
getRegForInlineAsmConstraint(const std::string &Constraint,
|
|
|
|
MVT VT) const override;
|
2009-08-26 13:44:29 +00:00
|
|
|
|
2010-01-15 21:19:43 +00: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 07:58:09 +00:00
|
|
|
bool isTruncateFree(Type *Ty1, Type *Ty2) const override;
|
|
|
|
bool isTruncateFree(EVT VT1, EVT VT2) const override;
|
2010-01-15 21:19:43 +00: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 07:58:09 +00: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-15 21:19:43 +00:00
|
|
|
|
2009-05-03 13:12:23 +00:00
|
|
|
MachineBasicBlock* EmitInstrWithCustomInserter(MachineInstr *MI,
|
2014-04-29 07:58:09 +00:00
|
|
|
MachineBasicBlock *BB) const override;
|
2009-12-12 18:55:37 +00:00
|
|
|
MachineBasicBlock* EmitShiftInstr(MachineInstr *MI,
|
2010-05-01 00:01:06 +00:00
|
|
|
MachineBasicBlock *BB) const;
|
2009-05-03 13:07:31 +00:00
|
|
|
|
2009-05-03 12:57:15 +00: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.
git-svn-id: https://llvm.org/svn/llvm-project/llvm/trunk@78142 91177308-0d34-0410-b5e6-96231b3b80d8
2009-08-05 01:29:28 +00:00
|
|
|
SDValue LowerCCCCallTo(SDValue Chain, SDValue Callee,
|
2009-09-02 08:44:58 +00: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.
git-svn-id: https://llvm.org/svn/llvm-project/llvm/trunk@78142 91177308-0d34-0410-b5e6-96231b3b80d8
2009-08-05 01:29:28 +00:00
|
|
|
bool isTailCall,
|
|
|
|
const SmallVectorImpl<ISD::OutputArg> &Outs,
|
2010-07-07 15:54:55 +00: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.
git-svn-id: https://llvm.org/svn/llvm-project/llvm/trunk@78142 91177308-0d34-0410-b5e6-96231b3b80d8
2009-08-05 01:29:28 +00:00
|
|
|
const SmallVectorImpl<ISD::InputArg> &Ins,
|
2013-05-25 02:42:55 +00:00
|
|
|
SDLoc dl, SelectionDAG &DAG,
|
2010-04-17 15:26:15 +00: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.
git-svn-id: https://llvm.org/svn/llvm-project/llvm/trunk@78142 91177308-0d34-0410-b5e6-96231b3b80d8
2009-08-05 01:29:28 +00:00
|
|
|
|
|
|
|
SDValue LowerCCCArguments(SDValue Chain,
|
2009-09-02 08:44:58 +00:00
|
|
|
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.
git-svn-id: https://llvm.org/svn/llvm-project/llvm/trunk@78142 91177308-0d34-0410-b5e6-96231b3b80d8
2009-08-05 01:29:28 +00:00
|
|
|
bool isVarArg,
|
|
|
|
const SmallVectorImpl<ISD::InputArg> &Ins,
|
2013-05-25 02:42:55 +00:00
|
|
|
SDLoc dl,
|
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.
git-svn-id: https://llvm.org/svn/llvm-project/llvm/trunk@78142 91177308-0d34-0410-b5e6-96231b3b80d8
2009-08-05 01:29:28 +00:00
|
|
|
SelectionDAG &DAG,
|
2010-04-17 15:26:15 +00: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.
git-svn-id: https://llvm.org/svn/llvm-project/llvm/trunk@78142 91177308-0d34-0410-b5e6-96231b3b80d8
2009-08-05 01:29:28 +00:00
|
|
|
|
|
|
|
SDValue LowerCallResult(SDValue Chain, SDValue InFlag,
|
2009-09-02 08:44:58 +00: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.
git-svn-id: https://llvm.org/svn/llvm-project/llvm/trunk@78142 91177308-0d34-0410-b5e6-96231b3b80d8
2009-08-05 01:29:28 +00:00
|
|
|
const SmallVectorImpl<ISD::InputArg> &Ins,
|
2013-05-25 02:42:55 +00:00
|
|
|
SDLoc dl, SelectionDAG &DAG,
|
2010-04-17 15:26:15 +00: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.
git-svn-id: https://llvm.org/svn/llvm-project/llvm/trunk@78142 91177308-0d34-0410-b5e6-96231b3b80d8
2009-08-05 01:29:28 +00:00
|
|
|
|
2014-04-29 07:58:09 +00:00
|
|
|
SDValue
|
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.
git-svn-id: https://llvm.org/svn/llvm-project/llvm/trunk@78142 91177308-0d34-0410-b5e6-96231b3b80d8
2009-08-05 01:29:28 +00:00
|
|
|
LowerFormalArguments(SDValue Chain,
|
2009-09-02 08:44:58 +00: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.
git-svn-id: https://llvm.org/svn/llvm-project/llvm/trunk@78142 91177308-0d34-0410-b5e6-96231b3b80d8
2009-08-05 01:29:28 +00:00
|
|
|
const SmallVectorImpl<ISD::InputArg> &Ins,
|
2013-05-25 02:42:55 +00:00
|
|
|
SDLoc dl, SelectionDAG &DAG,
|
2014-04-29 07:58:09 +00:00
|
|
|
SmallVectorImpl<SDValue> &InVals) const override;
|
|
|
|
SDValue
|
2012-05-25 16:35:28 +00:00
|
|
|
LowerCall(TargetLowering::CallLoweringInfo &CLI,
|
2014-04-29 07:58:09 +00:00
|
|
|
SmallVectorImpl<SDValue> &InVals) const override;
|
|
|
|
|
|
|
|
SDValue LowerReturn(SDValue Chain,
|
|
|
|
CallingConv::ID CallConv, bool isVarArg,
|
|
|
|
const SmallVectorImpl<ISD::OutputArg> &Outs,
|
|
|
|
const SmallVectorImpl<SDValue> &OutVals,
|
|
|
|
SDLoc dl, SelectionDAG &DAG) const override;
|
|
|
|
|
|
|
|
bool getPostIndexedAddressParts(SDNode *N, SDNode *Op,
|
|
|
|
SDValue &Base,
|
|
|
|
SDValue &Offset,
|
|
|
|
ISD::MemIndexedMode &AM,
|
|
|
|
SelectionDAG &DAG) const override;
|
2009-05-03 12:57:15 +00:00
|
|
|
};
|
|
|
|
} // namespace llvm
|
|
|
|
|
2014-08-13 16:26:38 +00:00
|
|
|
#endif
|