2012-02-18 20:03:15 +08:00
|
|
|
//===-- MSP430ISelLowering.h - MSP430 DAG Lowering Interface ----*- C++ -*-===//
|
2009-05-03 20:57:15 +08: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-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"
|
|
|
|
#include "llvm/Target/TargetLowering.h"
|
|
|
|
|
|
|
|
namespace llvm {
|
2009-05-03 20:59:50 +08:00
|
|
|
namespace MSP430ISD {
|
|
|
|
enum {
|
|
|
|
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,
|
|
|
|
|
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,
|
|
|
|
|
|
|
|
/// SHL, SRA, SRL - Non-constant shifts.
|
|
|
|
SHL, SRA, SRL
|
2009-05-03 20:59:50 +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
|
|
|
|
2014-04-29 15:58:09 +08:00
|
|
|
MVT getScalarShiftAmountTy(EVT LHSTy) const override { 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
|
2014-04-29 15:58:09 +08:00
|
|
|
getConstraintType(const std::string &Constraint) const override;
|
2015-02-27 06:38:43 +08:00
|
|
|
std::pair<unsigned, const TargetRegisterClass *>
|
|
|
|
getRegForInlineAsmConstraint(const TargetRegisterInfo *TRI,
|
|
|
|
const std::string &Constraint,
|
2014-04-29 15:58:09 +08:00
|
|
|
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
|
|
|
|
2009-05-03 21:12:23 +08:00
|
|
|
MachineBasicBlock* EmitInstrWithCustomInserter(MachineInstr *MI,
|
2014-04-29 15:58:09 +08:00
|
|
|
MachineBasicBlock *BB) const override;
|
2009-12-13 02:55:37 +08:00
|
|
|
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,
|
2013-05-25 10:42:55 +08:00
|
|
|
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 LowerCCCArguments(SDValue Chain,
|
2009-09-02 16:44:58 +08: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.
llvm-svn: 78142
2009-08-05 09:29:28 +08:00
|
|
|
bool isVarArg,
|
|
|
|
const SmallVectorImpl<ISD::InputArg> &Ins,
|
2013-05-25 10:42:55 +08: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.
llvm-svn: 78142
2009-08-05 09:29:28 +08:00
|
|
|
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,
|
2013-05-25 10:42:55 +08:00
|
|
|
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
|
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
|
|
|
LowerFormalArguments(SDValue Chain,
|
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,
|
2013-05-25 10:42:55 +08:00
|
|
|
SDLoc dl, SelectionDAG &DAG,
|
2014-04-29 15:58:09 +08:00
|
|
|
SmallVectorImpl<SDValue> &InVals) const override;
|
|
|
|
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;
|
|
|
|
|
|
|
|
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 20:57:15 +08:00
|
|
|
};
|
|
|
|
} // namespace llvm
|
|
|
|
|
2014-08-14 00:26:38 +08:00
|
|
|
#endif
|