2011-04-16 05:51:11 +08:00
|
|
|
//===-- MipsISelLowering.h - Mips DAG Lowering Interface --------*- C++ -*-===//
|
2007-06-06 15:42:06 +08:00
|
|
|
//
|
|
|
|
// The LLVM Compiler Infrastructure
|
|
|
|
//
|
2007-12-30 04:36:04 +08:00
|
|
|
// This file is distributed under the University of Illinois Open Source
|
|
|
|
// License. See LICENSE.TXT for details.
|
2007-06-06 15:42:06 +08:00
|
|
|
//
|
2011-04-16 05:51:11 +08:00
|
|
|
//===----------------------------------------------------------------------===//
|
2007-06-06 15:42:06 +08:00
|
|
|
//
|
|
|
|
// This file defines the interfaces that Mips uses to lower LLVM code into a
|
|
|
|
// selection DAG.
|
|
|
|
//
|
2011-04-16 05:51:11 +08:00
|
|
|
//===----------------------------------------------------------------------===//
|
2007-06-06 15:42:06 +08:00
|
|
|
|
|
|
|
#ifndef MipsISELLOWERING_H
|
|
|
|
#define MipsISELLOWERING_H
|
|
|
|
|
|
|
|
#include "Mips.h"
|
|
|
|
#include "MipsSubtarget.h"
|
2013-09-28 03:51:35 +08:00
|
|
|
#include "MCTargetDesc/MipsBaseInfo.h"
|
2012-10-27 07:56:38 +08:00
|
|
|
#include "llvm/CodeGen/CallingConvLower.h"
|
2012-03-18 02:46:09 +08:00
|
|
|
#include "llvm/CodeGen/SelectionDAG.h"
|
2013-03-06 06:13:04 +08:00
|
|
|
#include "llvm/IR/Function.h"
|
2012-03-18 02:46:09 +08:00
|
|
|
#include "llvm/Target/TargetLowering.h"
|
2013-01-23 04:05:56 +08:00
|
|
|
#include <deque>
|
2013-01-24 12:24:02 +08:00
|
|
|
#include <string>
|
2007-06-06 15:42:06 +08:00
|
|
|
|
|
|
|
namespace llvm {
|
|
|
|
namespace MipsISD {
|
|
|
|
enum NodeType {
|
|
|
|
// Start the numbering from where ISD NodeType finishes.
|
2008-09-24 02:42:32 +08:00
|
|
|
FIRST_NUMBER = ISD::BUILTIN_OP_END,
|
2007-06-06 15:42:06 +08:00
|
|
|
|
|
|
|
// Jump and link (call)
|
|
|
|
JmpLink,
|
|
|
|
|
2012-10-20 04:59:39 +08:00
|
|
|
// Tail call
|
|
|
|
TailCall,
|
|
|
|
|
2007-06-06 15:42:06 +08:00
|
|
|
// Get the Higher 16 bits from a 32-bit immediate
|
|
|
|
// No relation with Mips Hi register
|
2011-03-05 01:51:39 +08:00
|
|
|
Hi,
|
2007-06-06 15:42:06 +08:00
|
|
|
|
|
|
|
// Get the Lower 16 bits from a 32-bit immediate
|
|
|
|
// No relation with Mips Lo register
|
2011-03-05 01:51:39 +08:00
|
|
|
Lo,
|
2007-06-06 15:42:06 +08:00
|
|
|
|
2008-07-22 02:52:34 +08:00
|
|
|
// Handle gp_rel (small data/bss sections) relocation.
|
|
|
|
GPRel,
|
|
|
|
|
2011-05-31 10:53:58 +08:00
|
|
|
// Thread Pointer
|
|
|
|
ThreadPointer,
|
|
|
|
|
2008-07-09 12:45:36 +08:00
|
|
|
// Floating Point Branch Conditional
|
Several changes to Mips backend, experimental fp support being the most
important.
- Cleanup in the Subtarget info with addition of new features, not all support
yet, but they allow the future inclusion of features easier. Among new features,
we have : Arch family info (mips1, mips2, ...), ABI info (o32, eabi), 64-bit
integer
and float registers, allegrex vector FPU (VFPU), single float only support.
- TargetMachine now detects allegrex core.
- Added allegrex (Mips32r2) sext_inreg instructions.
- *Added Float Point Instructions*, handling single float only, and
aliased accesses for 32-bit FPUs.
- Some cleanup in FP instruction formats and FP register classes.
- Calling conventions improved to support mips 32-bit EABI.
- Added Asm Printer support for fp cond codes.
- Added support for sret copy to a return register.
- EABI support added into LowerCALL and FORMAL_ARGS.
- MipsFunctionInfo now keeps a virtual register per function to track the
sret on function entry until function ret.
- MipsInstrInfo FP support into methods (isMoveInstr, isLoadFromStackSlot, ...),
FP cond codes mapping and initial FP Branch Analysis.
- Two new Mips SDNode to handle fp branch and compare instructions : FPBrcond,
FPCmp
- MipsTargetLowering : handling different FP classes, Allegrex support, sret
return copy, no homing location within EABI, non 32-bit stack objects
arguments, and asm constraint for float.
llvm-svn: 53146
2008-07-06 03:05:21 +08:00
|
|
|
FPBrcond,
|
|
|
|
|
2008-07-09 12:45:36 +08:00
|
|
|
// Floating Point Compare
|
Several changes to Mips backend, experimental fp support being the most
important.
- Cleanup in the Subtarget info with addition of new features, not all support
yet, but they allow the future inclusion of features easier. Among new features,
we have : Arch family info (mips1, mips2, ...), ABI info (o32, eabi), 64-bit
integer
and float registers, allegrex vector FPU (VFPU), single float only support.
- TargetMachine now detects allegrex core.
- Added allegrex (Mips32r2) sext_inreg instructions.
- *Added Float Point Instructions*, handling single float only, and
aliased accesses for 32-bit FPUs.
- Some cleanup in FP instruction formats and FP register classes.
- Calling conventions improved to support mips 32-bit EABI.
- Added Asm Printer support for fp cond codes.
- Added support for sret copy to a return register.
- EABI support added into LowerCALL and FORMAL_ARGS.
- MipsFunctionInfo now keeps a virtual register per function to track the
sret on function entry until function ret.
- MipsInstrInfo FP support into methods (isMoveInstr, isLoadFromStackSlot, ...),
FP cond codes mapping and initial FP Branch Analysis.
- Two new Mips SDNode to handle fp branch and compare instructions : FPBrcond,
FPCmp
- MipsTargetLowering : handling different FP classes, Allegrex support, sret
return copy, no homing location within EABI, non 32-bit stack objects
arguments, and asm constraint for float.
llvm-svn: 53146
2008-07-06 03:05:21 +08:00
|
|
|
FPCmp,
|
|
|
|
|
2011-04-01 02:26:17 +08:00
|
|
|
// Floating Point Conditional Moves
|
|
|
|
CMovFP_T,
|
|
|
|
CMovFP_F,
|
|
|
|
|
2013-05-17 05:17:15 +08:00
|
|
|
// FP-to-int truncation node.
|
|
|
|
TruncIntFP,
|
|
|
|
|
2011-03-05 01:51:39 +08:00
|
|
|
// Return
|
2011-01-19 03:29:17 +08:00
|
|
|
Ret,
|
|
|
|
|
2013-01-30 08:26:49 +08:00
|
|
|
EH_RETURN,
|
|
|
|
|
2013-03-30 09:14:04 +08:00
|
|
|
// Node used to extract integer from accumulator.
|
2013-10-08 02:49:46 +08:00
|
|
|
ExtractHI,
|
|
|
|
ExtractLO,
|
2013-03-30 09:14:04 +08:00
|
|
|
|
|
|
|
// Node used to insert integers to accumulator.
|
|
|
|
InsertLOHI,
|
|
|
|
|
|
|
|
// Mult nodes.
|
|
|
|
Mult,
|
|
|
|
Multu,
|
|
|
|
|
2011-01-19 03:29:17 +08:00
|
|
|
// MAdd/Sub nodes
|
|
|
|
MAdd,
|
|
|
|
MAddu,
|
|
|
|
MSub,
|
2011-03-05 05:03:24 +08:00
|
|
|
MSubu,
|
|
|
|
|
|
|
|
// DivRem(u)
|
|
|
|
DivRem,
|
2011-04-16 03:52:08 +08:00
|
|
|
DivRemU,
|
2013-03-30 09:14:04 +08:00
|
|
|
DivRem16,
|
|
|
|
DivRemU16,
|
2011-04-16 03:52:08 +08:00
|
|
|
|
|
|
|
BuildPairF64,
|
2011-05-28 09:07:07 +08:00
|
|
|
ExtractElementF64,
|
|
|
|
|
2011-12-09 09:53:17 +08:00
|
|
|
Wrapper,
|
2011-06-21 08:40:49 +08:00
|
|
|
|
2011-07-20 07:30:50 +08:00
|
|
|
DynAlloc,
|
|
|
|
|
2011-08-17 10:05:42 +08:00
|
|
|
Sync,
|
|
|
|
|
|
|
|
Ext,
|
2012-06-02 08:03:12 +08:00
|
|
|
Ins,
|
|
|
|
|
2012-09-22 07:52:47 +08:00
|
|
|
// EXTR.W instrinsic nodes.
|
|
|
|
EXTP,
|
|
|
|
EXTPDP,
|
|
|
|
EXTR_S_H,
|
|
|
|
EXTR_W,
|
|
|
|
EXTR_R_W,
|
|
|
|
EXTR_RS_W,
|
|
|
|
SHILO,
|
|
|
|
MTHLIP,
|
|
|
|
|
|
|
|
// DPA.W intrinsic nodes.
|
|
|
|
MULSAQ_S_W_PH,
|
|
|
|
MAQ_S_W_PHL,
|
|
|
|
MAQ_S_W_PHR,
|
|
|
|
MAQ_SA_W_PHL,
|
|
|
|
MAQ_SA_W_PHR,
|
|
|
|
DPAU_H_QBL,
|
|
|
|
DPAU_H_QBR,
|
|
|
|
DPSU_H_QBL,
|
|
|
|
DPSU_H_QBR,
|
|
|
|
DPAQ_S_W_PH,
|
|
|
|
DPSQ_S_W_PH,
|
|
|
|
DPAQ_SA_L_W,
|
|
|
|
DPSQ_SA_L_W,
|
|
|
|
DPA_W_PH,
|
|
|
|
DPS_W_PH,
|
|
|
|
DPAQX_S_W_PH,
|
|
|
|
DPAQX_SA_W_PH,
|
|
|
|
DPAX_W_PH,
|
|
|
|
DPSX_W_PH,
|
|
|
|
DPSQX_S_W_PH,
|
|
|
|
DPSQX_SA_W_PH,
|
|
|
|
MULSA_W_PH,
|
|
|
|
|
|
|
|
MULT,
|
|
|
|
MULTU,
|
|
|
|
MADD_DSP,
|
|
|
|
MADDU_DSP,
|
|
|
|
MSUB_DSP,
|
|
|
|
MSUBU_DSP,
|
|
|
|
|
2013-04-20 07:21:32 +08:00
|
|
|
// DSP shift nodes.
|
|
|
|
SHLL_DSP,
|
|
|
|
SHRA_DSP,
|
|
|
|
SHRL_DSP,
|
|
|
|
|
2013-05-01 06:37:26 +08:00
|
|
|
// DSP setcc and select_cc nodes.
|
|
|
|
SETCC_DSP,
|
|
|
|
SELECT_CC_DSP,
|
|
|
|
|
2013-09-23 20:02:46 +08:00
|
|
|
// Vector comparisons.
|
2013-09-24 18:46:19 +08:00
|
|
|
// These take a vector and return a boolean.
|
2013-08-28 20:14:50 +08:00
|
|
|
VALL_ZERO,
|
|
|
|
VANY_ZERO,
|
|
|
|
VALL_NONZERO,
|
|
|
|
VANY_NONZERO,
|
|
|
|
|
2013-09-24 18:46:19 +08:00
|
|
|
// These take a vector and return a vector bitmask.
|
|
|
|
VCEQ,
|
|
|
|
VCLE_S,
|
|
|
|
VCLE_U,
|
|
|
|
VCLT_S,
|
|
|
|
VCLT_U,
|
|
|
|
|
2013-09-24 20:18:31 +08:00
|
|
|
// Element-wise vector max/min.
|
|
|
|
VSMAX,
|
|
|
|
VSMIN,
|
|
|
|
VUMAX,
|
|
|
|
VUMIN,
|
|
|
|
|
2013-09-24 22:02:15 +08:00
|
|
|
// Vector Shuffle with mask as an operand
|
|
|
|
VSHF, // Generic shuffle
|
2013-09-24 22:20:00 +08:00
|
|
|
SHF, // 4-element set shuffle.
|
2013-09-24 22:36:12 +08:00
|
|
|
ILVEV, // Interleave even elements
|
|
|
|
ILVOD, // Interleave odd elements
|
|
|
|
ILVL, // Interleave left elements
|
|
|
|
ILVR, // Interleave right elements
|
2013-09-24 22:53:25 +08:00
|
|
|
PCKEV, // Pack even elements
|
|
|
|
PCKOD, // Pack odd elements
|
2013-09-24 22:02:15 +08:00
|
|
|
|
2013-09-23 21:22:24 +08:00
|
|
|
// Combined (XOR (OR $a, $b), -1)
|
|
|
|
VNOR,
|
|
|
|
|
2013-09-23 22:03:12 +08:00
|
|
|
// Extended vector element extraction
|
|
|
|
VEXTRACT_SEXT_ELT,
|
|
|
|
VEXTRACT_ZEXT_ELT,
|
|
|
|
|
2012-06-02 08:03:12 +08:00
|
|
|
// Load/Store Left/Right nodes.
|
|
|
|
LWL = ISD::FIRST_TARGET_MEMORY_OPCODE,
|
|
|
|
LWR,
|
|
|
|
SWL,
|
|
|
|
SWR,
|
|
|
|
LDL,
|
|
|
|
LDR,
|
|
|
|
SDL,
|
|
|
|
SDR
|
2007-06-06 15:42:06 +08:00
|
|
|
};
|
|
|
|
}
|
|
|
|
|
2011-04-16 05:51:11 +08:00
|
|
|
//===--------------------------------------------------------------------===//
|
2007-06-06 15:42:06 +08:00
|
|
|
// TargetLowering Implementation
|
2011-04-16 05:51:11 +08:00
|
|
|
//===--------------------------------------------------------------------===//
|
2012-10-31 04:16:31 +08:00
|
|
|
class MipsFunctionInfo;
|
2011-03-05 01:51:39 +08:00
|
|
|
|
2009-08-13 13:41:27 +08:00
|
|
|
class MipsTargetLowering : public TargetLowering {
|
2007-06-06 15:42:06 +08:00
|
|
|
public:
|
2007-08-03 05:21:54 +08:00
|
|
|
explicit MipsTargetLowering(MipsTargetMachine &TM);
|
2007-06-06 15:42:06 +08:00
|
|
|
|
2013-03-13 08:54:29 +08:00
|
|
|
static const MipsTargetLowering *create(MipsTargetMachine &TM);
|
2011-11-08 02:59:49 +08:00
|
|
|
|
2013-03-13 08:54:29 +08:00
|
|
|
virtual MVT getScalarShiftAmountTy(EVT LHSTy) const { return MVT::i32; }
|
2011-08-13 05:30:06 +08:00
|
|
|
|
2012-09-22 07:58:31 +08:00
|
|
|
virtual void LowerOperationWrapper(SDNode *N,
|
|
|
|
SmallVectorImpl<SDValue> &Results,
|
|
|
|
SelectionDAG &DAG) const;
|
|
|
|
|
2007-06-06 15:42:06 +08:00
|
|
|
/// LowerOperation - Provide custom lowering hooks for some operations.
|
2010-04-17 23:26:15 +08:00
|
|
|
virtual SDValue LowerOperation(SDValue Op, SelectionDAG &DAG) const;
|
2007-06-06 15:42:06 +08:00
|
|
|
|
2012-09-22 07:58:31 +08:00
|
|
|
/// ReplaceNodeResults - Replace the results of node with an illegal result
|
|
|
|
/// type with new values built out of custom code.
|
|
|
|
///
|
|
|
|
virtual void ReplaceNodeResults(SDNode *N, SmallVectorImpl<SDValue>&Results,
|
|
|
|
SelectionDAG &DAG) const;
|
|
|
|
|
2011-03-05 01:51:39 +08:00
|
|
|
/// getTargetNodeName - This method returns the name of a target specific
|
2007-06-06 15:42:06 +08:00
|
|
|
// DAG node.
|
|
|
|
virtual const char *getTargetNodeName(unsigned Opcode) const;
|
|
|
|
|
2008-03-10 23:42:14 +08:00
|
|
|
/// getSetCCResultType - get the ISD::SETCC result ValueType
|
2013-05-18 08:21:46 +08:00
|
|
|
EVT getSetCCResultType(LLVMContext &Context, EVT VT) const;
|
2008-03-10 23:42:14 +08:00
|
|
|
|
2011-03-05 01:51:39 +08:00
|
|
|
virtual SDValue PerformDAGCombine(SDNode *N, DAGCombinerInfo &DCI) const;
|
2012-10-27 07:56:38 +08:00
|
|
|
|
2013-03-13 08:54:29 +08:00
|
|
|
virtual MachineBasicBlock *
|
|
|
|
EmitInstrWithCustomInserter(MachineInstr *MI, MachineBasicBlock *MBB) const;
|
|
|
|
|
|
|
|
struct LTStr {
|
|
|
|
bool operator()(const char *S1, const char *S2) const {
|
|
|
|
return strcmp(S1, S2) < 0;
|
|
|
|
}
|
|
|
|
};
|
|
|
|
|
|
|
|
protected:
|
|
|
|
SDValue getGlobalReg(SelectionDAG &DAG, EVT Ty) const;
|
2013-01-28 10:46:49 +08:00
|
|
|
|
2013-09-28 03:51:35 +08:00
|
|
|
// This method creates the following nodes, which are necessary for
|
|
|
|
// computing a local symbol's address:
|
|
|
|
//
|
|
|
|
// (add (load (wrapper $gp, %got(sym)), %lo(sym))
|
|
|
|
template<class NodeTy>
|
|
|
|
SDValue getAddrLocal(NodeTy *N, EVT Ty, SelectionDAG &DAG,
|
|
|
|
bool HasMips64) const {
|
|
|
|
SDLoc DL(N);
|
|
|
|
unsigned GOTFlag = HasMips64 ? MipsII::MO_GOT_PAGE : MipsII::MO_GOT;
|
|
|
|
SDValue GOT = DAG.getNode(MipsISD::Wrapper, DL, Ty, getGlobalReg(DAG, Ty),
|
|
|
|
getTargetNode(N, Ty, DAG, GOTFlag));
|
|
|
|
SDValue Load = DAG.getLoad(Ty, DL, DAG.getEntryNode(), GOT,
|
|
|
|
MachinePointerInfo::getGOT(), false, false,
|
|
|
|
false, 0);
|
|
|
|
unsigned LoFlag = HasMips64 ? MipsII::MO_GOT_OFST : MipsII::MO_ABS_LO;
|
|
|
|
SDValue Lo = DAG.getNode(MipsISD::Lo, DL, Ty,
|
|
|
|
getTargetNode(N, Ty, DAG, LoFlag));
|
|
|
|
return DAG.getNode(ISD::ADD, DL, Ty, Load, Lo);
|
|
|
|
}
|
|
|
|
|
|
|
|
// This method creates the following nodes, which are necessary for
|
|
|
|
// computing a global symbol's address:
|
|
|
|
//
|
|
|
|
// (load (wrapper $gp, %got(sym)))
|
|
|
|
template<class NodeTy>
|
|
|
|
SDValue getAddrGlobal(NodeTy *N, EVT Ty, SelectionDAG &DAG,
|
2013-09-28 08:12:32 +08:00
|
|
|
unsigned Flag, SDValue Chain,
|
|
|
|
const MachinePointerInfo &PtrInfo) const {
|
2013-09-28 03:51:35 +08:00
|
|
|
SDLoc DL(N);
|
|
|
|
SDValue Tgt = DAG.getNode(MipsISD::Wrapper, DL, Ty, getGlobalReg(DAG, Ty),
|
|
|
|
getTargetNode(N, Ty, DAG, Flag));
|
2013-09-28 08:12:32 +08:00
|
|
|
return DAG.getLoad(Ty, DL, Chain, Tgt, PtrInfo, false, false, false, 0);
|
2013-09-28 03:51:35 +08:00
|
|
|
}
|
|
|
|
|
|
|
|
// This method creates the following nodes, which are necessary for
|
|
|
|
// computing a global symbol's address in large-GOT mode:
|
|
|
|
//
|
|
|
|
// (load (wrapper (add %hi(sym), $gp), %lo(sym)))
|
|
|
|
template<class NodeTy>
|
|
|
|
SDValue getAddrGlobalLargeGOT(NodeTy *N, EVT Ty, SelectionDAG &DAG,
|
2013-09-28 08:12:32 +08:00
|
|
|
unsigned HiFlag, unsigned LoFlag,
|
|
|
|
SDValue Chain,
|
|
|
|
const MachinePointerInfo &PtrInfo) const {
|
2013-09-28 03:51:35 +08:00
|
|
|
SDLoc DL(N);
|
|
|
|
SDValue Hi = DAG.getNode(MipsISD::Hi, DL, Ty,
|
|
|
|
getTargetNode(N, Ty, DAG, HiFlag));
|
|
|
|
Hi = DAG.getNode(ISD::ADD, DL, Ty, Hi, getGlobalReg(DAG, Ty));
|
|
|
|
SDValue Wrapper = DAG.getNode(MipsISD::Wrapper, DL, Ty, Hi,
|
|
|
|
getTargetNode(N, Ty, DAG, LoFlag));
|
2013-09-28 08:12:32 +08:00
|
|
|
return DAG.getLoad(Ty, DL, Chain, Wrapper, PtrInfo, false, false, false,
|
|
|
|
0);
|
2013-09-28 03:51:35 +08:00
|
|
|
}
|
|
|
|
|
|
|
|
// This method creates the following nodes, which are necessary for
|
|
|
|
// computing a symbol's address in non-PIC mode:
|
|
|
|
//
|
|
|
|
// (add %hi(sym), %lo(sym))
|
|
|
|
template<class NodeTy>
|
|
|
|
SDValue getAddrNonPIC(NodeTy *N, EVT Ty, SelectionDAG &DAG) const {
|
|
|
|
SDLoc DL(N);
|
|
|
|
SDValue Hi = getTargetNode(N, Ty, DAG, MipsII::MO_ABS_HI);
|
|
|
|
SDValue Lo = getTargetNode(N, Ty, DAG, MipsII::MO_ABS_LO);
|
|
|
|
return DAG.getNode(ISD::ADD, DL, Ty,
|
|
|
|
DAG.getNode(MipsISD::Hi, DL, Ty, Hi),
|
|
|
|
DAG.getNode(MipsISD::Lo, DL, Ty, Lo));
|
|
|
|
}
|
2013-03-13 08:54:29 +08:00
|
|
|
|
|
|
|
/// This function fills Ops, which is the list of operands that will later
|
|
|
|
/// be used when a function call node is created. It also generates
|
|
|
|
/// copyToReg nodes to set up argument registers.
|
|
|
|
virtual void
|
|
|
|
getOpndList(SmallVectorImpl<SDValue> &Ops,
|
|
|
|
std::deque< std::pair<unsigned, SDValue> > &RegsToPass,
|
|
|
|
bool IsPICCall, bool GlobalOrExternal, bool InternalLinkage,
|
|
|
|
CallLoweringInfo &CLI, SDValue Callee, SDValue Chain) const;
|
2013-01-24 12:24:02 +08:00
|
|
|
|
2012-10-27 07:56:38 +08:00
|
|
|
/// ByValArgInfo - Byval argument information.
|
|
|
|
struct ByValArgInfo {
|
|
|
|
unsigned FirstIdx; // Index of the first register used.
|
|
|
|
unsigned NumRegs; // Number of registers used for this argument.
|
|
|
|
unsigned Address; // Offset of the stack area used to pass this argument.
|
|
|
|
|
|
|
|
ByValArgInfo() : FirstIdx(0), NumRegs(0), Address(0) {}
|
|
|
|
};
|
|
|
|
|
|
|
|
/// MipsCC - This class provides methods used to analyze formal and call
|
|
|
|
/// arguments and inquire about calling convention information.
|
|
|
|
class MipsCC {
|
|
|
|
public:
|
Checkin in of first of several patches to finish implementation of
mips16/mips32 floating point interoperability.
This patch fixes returns from mips16 functions so that if the function
was in fact called by a mips32 hard float routine, then values
that would have been returned in floating point registers are so returned.
Mips16 mode has no floating point instructions so there is no way to
load values into floating point registers.
This is needed when returning float, double, single complex, double complex
in the Mips ABI.
Helper functions in libc for mips16 are available to do this.
For efficiency purposes, these helper functions have a different calling
convention from normal Mips calls.
Registers v0,v1,a0,a1 are used to pass parameters instead of
a0,a1,a2,a3.
This is because v0,v1,a0,a1 are the natural registers used to return
floating point values in soft float. These values can then be moved
to the appropriate floating point registers with no extra cost.
The only register that is modified is ra in this call.
The helper functions make sure that the return values are in the floating
point registers that they would be in if soft float was not in effect
(which it is for mips16, though the soft float is implemented using a mips32
library that uses hard float).
llvm-svn: 181641
2013-05-11 06:25:39 +08:00
|
|
|
enum SpecialCallingConvType {
|
|
|
|
Mips16RetHelperConv, NoSpecialCallingConv
|
|
|
|
};
|
|
|
|
|
2013-08-21 07:38:40 +08:00
|
|
|
MipsCC(CallingConv::ID CallConv, bool IsO32, bool IsFP64, CCState &Info,
|
|
|
|
SpecialCallingConvType SpecialCallingConv = NoSpecialCallingConv);
|
Checkin in of first of several patches to finish implementation of
mips16/mips32 floating point interoperability.
This patch fixes returns from mips16 functions so that if the function
was in fact called by a mips32 hard float routine, then values
that would have been returned in floating point registers are so returned.
Mips16 mode has no floating point instructions so there is no way to
load values into floating point registers.
This is needed when returning float, double, single complex, double complex
in the Mips ABI.
Helper functions in libc for mips16 are available to do this.
For efficiency purposes, these helper functions have a different calling
convention from normal Mips calls.
Registers v0,v1,a0,a1 are used to pass parameters instead of
a0,a1,a2,a3.
This is because v0,v1,a0,a1 are the natural registers used to return
floating point values in soft float. These values can then be moved
to the appropriate floating point registers with no extra cost.
The only register that is modified is ra in this call.
The helper functions make sure that the return values are in the floating
point registers that they would be in if soft float was not in effect
(which it is for mips16, though the soft float is implemented using a mips32
library that uses hard float).
llvm-svn: 181641
2013-05-11 06:25:39 +08:00
|
|
|
|
2012-10-27 07:56:38 +08:00
|
|
|
|
2013-02-16 05:45:11 +08:00
|
|
|
void analyzeCallOperands(const SmallVectorImpl<ISD::OutputArg> &Outs,
|
2013-03-06 06:20:28 +08:00
|
|
|
bool IsVarArg, bool IsSoftFloat,
|
|
|
|
const SDNode *CallNode,
|
|
|
|
std::vector<ArgListEntry> &FuncArgs);
|
2013-03-06 06:13:04 +08:00
|
|
|
void analyzeFormalArguments(const SmallVectorImpl<ISD::InputArg> &Ins,
|
|
|
|
bool IsSoftFloat,
|
|
|
|
Function::const_arg_iterator FuncArg);
|
2013-03-06 06:41:55 +08:00
|
|
|
|
|
|
|
void analyzeCallResult(const SmallVectorImpl<ISD::InputArg> &Ins,
|
|
|
|
bool IsSoftFloat, const SDNode *CallNode,
|
|
|
|
const Type *RetTy) const;
|
|
|
|
|
|
|
|
void analyzeReturn(const SmallVectorImpl<ISD::OutputArg> &Outs,
|
|
|
|
bool IsSoftFloat, const Type *RetTy) const;
|
|
|
|
|
2012-10-27 07:56:38 +08:00
|
|
|
const CCState &getCCInfo() const { return CCInfo; }
|
|
|
|
|
|
|
|
/// hasByValArg - Returns true if function has byval arguments.
|
|
|
|
bool hasByValArg() const { return !ByValArgs.empty(); }
|
|
|
|
|
|
|
|
/// regSize - Size (in number of bits) of integer registers.
|
2013-02-16 05:45:11 +08:00
|
|
|
unsigned regSize() const { return IsO32 ? 4 : 8; }
|
2012-10-27 07:56:38 +08:00
|
|
|
|
|
|
|
/// numIntArgRegs - Number of integer registers available for calls.
|
2013-02-16 05:45:11 +08:00
|
|
|
unsigned numIntArgRegs() const;
|
2012-10-27 07:56:38 +08:00
|
|
|
|
|
|
|
/// reservedArgArea - The size of the area the caller reserves for
|
|
|
|
/// register arguments. This is 16-byte if ABI is O32.
|
2013-02-16 05:45:11 +08:00
|
|
|
unsigned reservedArgArea() const;
|
2012-10-27 07:56:38 +08:00
|
|
|
|
2013-02-16 05:45:11 +08:00
|
|
|
/// Return pointer to array of integer argument registers.
|
|
|
|
const uint16_t *intArgRegs() const;
|
2012-10-27 07:56:38 +08:00
|
|
|
|
2013-07-03 23:07:05 +08:00
|
|
|
typedef SmallVectorImpl<ByValArgInfo>::const_iterator byval_iterator;
|
2012-10-27 07:56:38 +08:00
|
|
|
byval_iterator byval_begin() const { return ByValArgs.begin(); }
|
|
|
|
byval_iterator byval_end() const { return ByValArgs.end(); }
|
|
|
|
|
|
|
|
private:
|
2013-02-16 05:45:11 +08:00
|
|
|
void handleByValArg(unsigned ValNo, MVT ValVT, MVT LocVT,
|
|
|
|
CCValAssign::LocInfo LocInfo,
|
|
|
|
ISD::ArgFlagsTy ArgFlags);
|
|
|
|
|
|
|
|
/// useRegsForByval - Returns true if the calling convention allows the
|
|
|
|
/// use of registers to pass byval arguments.
|
|
|
|
bool useRegsForByval() const { return CallConv != CallingConv::Fast; }
|
|
|
|
|
|
|
|
/// Return the function that analyzes fixed argument list functions.
|
|
|
|
llvm::CCAssignFn *fixedArgFn() const;
|
|
|
|
|
|
|
|
/// Return the function that analyzes variable argument list functions.
|
|
|
|
llvm::CCAssignFn *varArgFn() const;
|
|
|
|
|
|
|
|
const uint16_t *shadowRegs() const;
|
|
|
|
|
2012-10-27 07:56:38 +08:00
|
|
|
void allocateRegs(ByValArgInfo &ByVal, unsigned ByValSize,
|
|
|
|
unsigned Align);
|
|
|
|
|
2013-03-06 06:13:04 +08:00
|
|
|
/// Return the type of the register which is used to pass an argument or
|
|
|
|
/// return a value. This function returns f64 if the argument is an i64
|
|
|
|
/// value which has been generated as a result of softening an f128 value.
|
|
|
|
/// Otherwise, it just returns VT.
|
|
|
|
MVT getRegVT(MVT VT, const Type *OrigTy, const SDNode *CallNode,
|
|
|
|
bool IsSoftFloat) const;
|
|
|
|
|
2013-03-06 06:41:55 +08:00
|
|
|
template<typename Ty>
|
|
|
|
void analyzeReturn(const SmallVectorImpl<Ty> &RetVals, bool IsSoftFloat,
|
|
|
|
const SDNode *CallNode, const Type *RetTy) const;
|
|
|
|
|
2012-10-27 07:56:38 +08:00
|
|
|
CCState &CCInfo;
|
2013-02-16 05:45:11 +08:00
|
|
|
CallingConv::ID CallConv;
|
2013-08-21 07:38:40 +08:00
|
|
|
bool IsO32, IsFP64;
|
Checkin in of first of several patches to finish implementation of
mips16/mips32 floating point interoperability.
This patch fixes returns from mips16 functions so that if the function
was in fact called by a mips32 hard float routine, then values
that would have been returned in floating point registers are so returned.
Mips16 mode has no floating point instructions so there is no way to
load values into floating point registers.
This is needed when returning float, double, single complex, double complex
in the Mips ABI.
Helper functions in libc for mips16 are available to do this.
For efficiency purposes, these helper functions have a different calling
convention from normal Mips calls.
Registers v0,v1,a0,a1 are used to pass parameters instead of
a0,a1,a2,a3.
This is because v0,v1,a0,a1 are the natural registers used to return
floating point values in soft float. These values can then be moved
to the appropriate floating point registers with no extra cost.
The only register that is modified is ra in this call.
The helper functions make sure that the return values are in the floating
point registers that they would be in if soft float was not in effect
(which it is for mips16, though the soft float is implemented using a mips32
library that uses hard float).
llvm-svn: 181641
2013-05-11 06:25:39 +08:00
|
|
|
SpecialCallingConvType SpecialCallingConv;
|
2012-10-27 07:56:38 +08:00
|
|
|
SmallVector<ByValArgInfo, 2> ByValArgs;
|
|
|
|
};
|
Checkin in of first of several patches to finish implementation of
mips16/mips32 floating point interoperability.
This patch fixes returns from mips16 functions so that if the function
was in fact called by a mips32 hard float routine, then values
that would have been returned in floating point registers are so returned.
Mips16 mode has no floating point instructions so there is no way to
load values into floating point registers.
This is needed when returning float, double, single complex, double complex
in the Mips ABI.
Helper functions in libc for mips16 are available to do this.
For efficiency purposes, these helper functions have a different calling
convention from normal Mips calls.
Registers v0,v1,a0,a1 are used to pass parameters instead of
a0,a1,a2,a3.
This is because v0,v1,a0,a1 are the natural registers used to return
floating point values in soft float. These values can then be moved
to the appropriate floating point registers with no extra cost.
The only register that is modified is ra in this call.
The helper functions make sure that the return values are in the floating
point registers that they would be in if soft float was not in effect
(which it is for mips16, though the soft float is implemented using a mips32
library that uses hard float).
llvm-svn: 181641
2013-05-11 06:25:39 +08:00
|
|
|
protected:
|
2013-09-07 08:52:30 +08:00
|
|
|
SDValue lowerLOAD(SDValue Op, SelectionDAG &DAG) const;
|
|
|
|
SDValue lowerSTORE(SDValue Op, SelectionDAG &DAG) const;
|
|
|
|
|
Several changes to Mips backend, experimental fp support being the most
important.
- Cleanup in the Subtarget info with addition of new features, not all support
yet, but they allow the future inclusion of features easier. Among new features,
we have : Arch family info (mips1, mips2, ...), ABI info (o32, eabi), 64-bit
integer
and float registers, allegrex vector FPU (VFPU), single float only support.
- TargetMachine now detects allegrex core.
- Added allegrex (Mips32r2) sext_inreg instructions.
- *Added Float Point Instructions*, handling single float only, and
aliased accesses for 32-bit FPUs.
- Some cleanup in FP instruction formats and FP register classes.
- Calling conventions improved to support mips 32-bit EABI.
- Added Asm Printer support for fp cond codes.
- Added support for sret copy to a return register.
- EABI support added into LowerCALL and FORMAL_ARGS.
- MipsFunctionInfo now keeps a virtual register per function to track the
sret on function entry until function ret.
- MipsInstrInfo FP support into methods (isMoveInstr, isLoadFromStackSlot, ...),
FP cond codes mapping and initial FP Branch Analysis.
- Two new Mips SDNode to handle fp branch and compare instructions : FPBrcond,
FPCmp
- MipsTargetLowering : handling different FP classes, Allegrex support, sret
return copy, no homing location within EABI, non 32-bit stack objects
arguments, and asm constraint for float.
llvm-svn: 53146
2008-07-06 03:05:21 +08:00
|
|
|
// Subtarget Info
|
|
|
|
const MipsSubtarget *Subtarget;
|
2012-02-28 15:46:26 +08:00
|
|
|
|
2011-10-29 02:47:24 +08:00
|
|
|
bool HasMips64, IsN64, IsO32;
|
2009-08-13 13:41:27 +08:00
|
|
|
|
2013-03-13 08:54:29 +08:00
|
|
|
private:
|
2013-09-28 03:51:35 +08:00
|
|
|
// Create a TargetGlobalAddress node.
|
|
|
|
SDValue getTargetNode(GlobalAddressSDNode *N, EVT Ty, SelectionDAG &DAG,
|
|
|
|
unsigned Flag) const;
|
|
|
|
|
|
|
|
// Create a TargetExternalSymbol node.
|
|
|
|
SDValue getTargetNode(ExternalSymbolSDNode *N, EVT Ty, SelectionDAG &DAG,
|
|
|
|
unsigned Flag) const;
|
|
|
|
|
|
|
|
// Create a TargetBlockAddress node.
|
|
|
|
SDValue getTargetNode(BlockAddressSDNode *N, EVT Ty, SelectionDAG &DAG,
|
|
|
|
unsigned Flag) const;
|
|
|
|
|
|
|
|
// Create a TargetJumpTable node.
|
|
|
|
SDValue getTargetNode(JumpTableSDNode *N, EVT Ty, SelectionDAG &DAG,
|
|
|
|
unsigned Flag) const;
|
|
|
|
|
|
|
|
// Create a TargetConstantPool node.
|
|
|
|
SDValue getTargetNode(ConstantPoolSDNode *N, EVT Ty, SelectionDAG &DAG,
|
|
|
|
unsigned Flag) const;
|
Checkin in of first of several patches to finish implementation of
mips16/mips32 floating point interoperability.
This patch fixes returns from mips16 functions so that if the function
was in fact called by a mips32 hard float routine, then values
that would have been returned in floating point registers are so returned.
Mips16 mode has no floating point instructions so there is no way to
load values into floating point registers.
This is needed when returning float, double, single complex, double complex
in the Mips ABI.
Helper functions in libc for mips16 are available to do this.
For efficiency purposes, these helper functions have a different calling
convention from normal Mips calls.
Registers v0,v1,a0,a1 are used to pass parameters instead of
a0,a1,a2,a3.
This is because v0,v1,a0,a1 are the natural registers used to return
floating point values in soft float. These values can then be moved
to the appropriate floating point registers with no extra cost.
The only register that is modified is ra in this call.
The helper functions make sure that the return values are in the floating
point registers that they would be in if soft float was not in effect
(which it is for mips16, though the soft float is implemented using a mips32
library that uses hard float).
llvm-svn: 181641
2013-05-11 06:25:39 +08:00
|
|
|
|
|
|
|
MipsCC::SpecialCallingConvType getSpecialCallingConv(SDValue Callee) const;
|
2007-06-06 15:42:06 +08:00
|
|
|
// Lower Operand helpers
|
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,
|
2013-03-06 06:41:55 +08:00
|
|
|
SmallVectorImpl<SDValue> &InVals,
|
|
|
|
const SDNode *CallNode, const Type *RetTy) const;
|
2007-06-06 15:42:06 +08:00
|
|
|
|
|
|
|
// Lower Operand specifics
|
2013-03-12 08:16:36 +08:00
|
|
|
SDValue lowerBR_JT(SDValue Op, SelectionDAG &DAG) const;
|
|
|
|
SDValue lowerBRCOND(SDValue Op, SelectionDAG &DAG) const;
|
|
|
|
SDValue lowerConstantPool(SDValue Op, SelectionDAG &DAG) const;
|
|
|
|
SDValue lowerGlobalAddress(SDValue Op, SelectionDAG &DAG) const;
|
|
|
|
SDValue lowerBlockAddress(SDValue Op, SelectionDAG &DAG) const;
|
|
|
|
SDValue lowerGlobalTLSAddress(SDValue Op, SelectionDAG &DAG) const;
|
|
|
|
SDValue lowerJumpTable(SDValue Op, SelectionDAG &DAG) const;
|
|
|
|
SDValue lowerSELECT(SDValue Op, SelectionDAG &DAG) const;
|
|
|
|
SDValue lowerSELECT_CC(SDValue Op, SelectionDAG &DAG) const;
|
|
|
|
SDValue lowerSETCC(SDValue Op, SelectionDAG &DAG) const;
|
|
|
|
SDValue lowerVASTART(SDValue Op, SelectionDAG &DAG) const;
|
|
|
|
SDValue lowerFCOPYSIGN(SDValue Op, SelectionDAG &DAG) const;
|
|
|
|
SDValue lowerFABS(SDValue Op, SelectionDAG &DAG) const;
|
|
|
|
SDValue lowerFRAMEADDR(SDValue Op, SelectionDAG &DAG) const;
|
|
|
|
SDValue lowerRETURNADDR(SDValue Op, SelectionDAG &DAG) const;
|
|
|
|
SDValue lowerEH_RETURN(SDValue Op, SelectionDAG &DAG) const;
|
|
|
|
SDValue lowerATOMIC_FENCE(SDValue Op, SelectionDAG& DAG) const;
|
|
|
|
SDValue lowerShiftLeftParts(SDValue Op, SelectionDAG& DAG) const;
|
|
|
|
SDValue lowerShiftRightParts(SDValue Op, SelectionDAG& DAG,
|
2012-06-15 05:10:56 +08:00
|
|
|
bool IsSRA) const;
|
2013-03-12 08:16:36 +08:00
|
|
|
SDValue lowerADD(SDValue Op, SelectionDAG &DAG) const;
|
2013-05-17 05:17:15 +08:00
|
|
|
SDValue lowerFP_TO_SINT(SDValue Op, SelectionDAG &DAG) const;
|
2008-06-06 08:58:26 +08:00
|
|
|
|
2013-03-12 08:16:36 +08:00
|
|
|
/// isEligibleForTailCallOptimization - Check whether the call is eligible
|
2012-10-20 05:47:33 +08:00
|
|
|
/// for tail call optimization.
|
2013-03-13 08:54:29 +08:00
|
|
|
virtual bool
|
|
|
|
isEligibleForTailCallOptimization(const MipsCC &MipsCCInfo,
|
|
|
|
unsigned NextStackOffset,
|
|
|
|
const MipsFunctionInfo& FI) const = 0;
|
2012-10-20 05:47:33 +08:00
|
|
|
|
2012-10-27 08:10:18 +08:00
|
|
|
/// copyByValArg - Copy argument registers which were used to pass a byval
|
|
|
|
/// argument to the stack. Create a stack frame object for the byval
|
|
|
|
/// argument.
|
2013-05-25 10:42:55 +08:00
|
|
|
void copyByValRegs(SDValue Chain, SDLoc DL,
|
2012-10-27 08:10:18 +08:00
|
|
|
std::vector<SDValue> &OutChains, SelectionDAG &DAG,
|
|
|
|
const ISD::ArgFlagsTy &Flags,
|
|
|
|
SmallVectorImpl<SDValue> &InVals,
|
|
|
|
const Argument *FuncArg,
|
|
|
|
const MipsCC &CC, const ByValArgInfo &ByVal) const;
|
|
|
|
|
2012-10-27 08:16:36 +08:00
|
|
|
/// passByValArg - Pass a byval argument in registers or on stack.
|
2013-05-25 10:42:55 +08:00
|
|
|
void passByValArg(SDValue Chain, SDLoc DL,
|
2013-01-23 04:05:56 +08:00
|
|
|
std::deque< std::pair<unsigned, SDValue> > &RegsToPass,
|
2013-07-14 12:42:23 +08:00
|
|
|
SmallVectorImpl<SDValue> &MemOpChains, SDValue StackPtr,
|
2012-10-27 08:16:36 +08:00
|
|
|
MachineFrameInfo *MFI, SelectionDAG &DAG, SDValue Arg,
|
|
|
|
const MipsCC &CC, const ByValArgInfo &ByVal,
|
|
|
|
const ISD::ArgFlagsTy &Flags, bool isLittle) const;
|
|
|
|
|
2012-10-27 08:21:13 +08:00
|
|
|
/// writeVarArgRegs - Write variable function arguments passed in registers
|
|
|
|
/// to the stack. Also create a stack frame object for the first variable
|
|
|
|
/// argument.
|
|
|
|
void writeVarArgRegs(std::vector<SDValue> &OutChains, const MipsCC &CC,
|
2013-05-25 10:42:55 +08:00
|
|
|
SDValue Chain, SDLoc DL, SelectionDAG &DAG) const;
|
2012-10-27 08:21:13 +08:00
|
|
|
|
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
|
|
|
virtual SDValue
|
|
|
|
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,
|
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
|
|
|
|
2012-10-31 03:23:25 +08:00
|
|
|
SDValue passArgOnStack(SDValue StackPtr, unsigned Offset, SDValue Chain,
|
2013-05-25 10:42:55 +08:00
|
|
|
SDValue Arg, SDLoc DL, bool IsTailCall,
|
2012-10-31 03:23:25 +08:00
|
|
|
SelectionDAG &DAG) 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
|
|
|
virtual SDValue
|
2012-05-26 00:35:28 +08:00
|
|
|
LowerCall(TargetLowering::CallLoweringInfo &CLI,
|
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
|
|
|
|
2012-10-10 09:27:09 +08:00
|
|
|
virtual bool
|
|
|
|
CanLowerReturn(CallingConv::ID CallConv, MachineFunction &MF,
|
|
|
|
bool isVarArg,
|
|
|
|
const SmallVectorImpl<ISD::OutputArg> &Outs,
|
|
|
|
LLVMContext &Context) 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
|
|
|
virtual SDValue
|
|
|
|
LowerReturn(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::OutputArg> &Outs,
|
2010-07-07 23:54:55 +08:00
|
|
|
const SmallVectorImpl<SDValue> &OutVals,
|
2013-05-25 10:42:55 +08:00
|
|
|
SDLoc dl, SelectionDAG &DAG) 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
|
|
|
|
2007-08-22 00:09:25 +08:00
|
|
|
// Inline asm support
|
|
|
|
ConstraintType getConstraintType(const std::string &Constraint) const;
|
|
|
|
|
2011-04-16 05:51:11 +08:00
|
|
|
/// Examine constraint string and operand type and determine a weight value.
|
|
|
|
/// The operand object must already have been set up with the operand type.
|
2010-10-30 01:29:13 +08:00
|
|
|
ConstraintWeight getSingleConstraintMatchWeight(
|
|
|
|
AsmOperandInfo &info, const char *constraint) const;
|
|
|
|
|
2013-08-14 08:21:25 +08:00
|
|
|
/// This function parses registers that appear in inline-asm constraints.
|
|
|
|
/// It returns pair (0, 0) on failure.
|
|
|
|
std::pair<unsigned, const TargetRegisterClass *>
|
|
|
|
parseRegForInlineAsmConstraint(const StringRef &C, MVT VT) const;
|
|
|
|
|
2011-03-05 01:51:39 +08:00
|
|
|
std::pair<unsigned, const TargetRegisterClass*>
|
2007-08-22 00:09:25 +08:00
|
|
|
getRegForInlineAsmConstraint(const std::string &Constraint,
|
2013-06-23 02:37:38 +08:00
|
|
|
MVT VT) const;
|
2007-08-22 00:09:25 +08:00
|
|
|
|
2012-05-07 11:13:32 +08:00
|
|
|
/// LowerAsmOperandForConstraint - Lower the specified operand into the Ops
|
|
|
|
/// vector. If it is invalid, don't add anything to Ops. If hasMemory is
|
|
|
|
/// true it means one of the asm constraint of the inline asm instruction
|
|
|
|
/// being processed is 'm'.
|
|
|
|
virtual void LowerAsmOperandForConstraint(SDValue Op,
|
|
|
|
std::string &Constraint,
|
|
|
|
std::vector<SDValue> &Ops,
|
|
|
|
SelectionDAG &DAG) const;
|
|
|
|
|
2012-11-17 08:25:41 +08:00
|
|
|
virtual bool isLegalAddressingMode(const AddrMode &AM, Type *Ty) const;
|
|
|
|
|
Teach DAGCombine to fold constant offsets into GlobalAddress nodes,
and add a TargetLowering hook for it to use to determine when this
is legal (i.e. not in PIC mode, etc.)
This allows instruction selection to emit folded constant offsets
in more cases, such as the included testcase, eliminating the need
for explicit arithmetic instructions.
This eliminates the need for the C++ code in X86ISelDAGToDAG.cpp
that attempted to achieve the same effect, but wasn't as effective.
Also, fix handling of offsets in GlobalAddressSDNodes in several
places, including changing GlobalAddressSDNode's offset from
int to int64_t.
The Mips, Alpha, Sparc, and CellSPU targets appear to be
unaware of GlobalAddress offsets currently, so set the hook to
false on those targets.
llvm-svn: 57748
2008-10-18 10:06:02 +08:00
|
|
|
virtual bool isOffsetFoldingLegal(const GlobalAddressSDNode *GA) const;
|
2009-10-28 03:56:55 +08:00
|
|
|
|
2012-06-14 03:33:32 +08:00
|
|
|
virtual EVT getOptimalMemOpType(uint64_t Size, unsigned DstAlign,
|
2012-12-12 10:34:41 +08:00
|
|
|
unsigned SrcAlign,
|
|
|
|
bool IsMemset, bool ZeroMemset,
|
2012-06-14 03:33:32 +08:00
|
|
|
bool MemcpyStrSrc,
|
|
|
|
MachineFunction &MF) const;
|
|
|
|
|
2009-10-28 03:56:55 +08:00
|
|
|
/// isFPImmLegal - Returns true if the target can instruction select the
|
|
|
|
/// specified FP immediate natively. If false, the legalizer will
|
|
|
|
/// materialize the FP immediate as a load from a constant pool.
|
2009-10-28 09:43:28 +08:00
|
|
|
virtual bool isFPImmLegal(const APFloat &Imm, EVT VT) const;
|
2011-05-31 10:54:07 +08:00
|
|
|
|
2012-02-03 12:33:00 +08:00
|
|
|
virtual unsigned getJumpTableEncoding() const;
|
|
|
|
|
2013-03-12 08:16:36 +08:00
|
|
|
MachineBasicBlock *emitAtomicBinary(MachineInstr *MI, MachineBasicBlock *BB,
|
2011-05-31 10:54:07 +08:00
|
|
|
unsigned Size, unsigned BinOpcode, bool Nand = false) const;
|
2013-03-12 08:16:36 +08:00
|
|
|
MachineBasicBlock *emitAtomicBinaryPartword(MachineInstr *MI,
|
2011-05-31 10:54:07 +08:00
|
|
|
MachineBasicBlock *BB, unsigned Size, unsigned BinOpcode,
|
|
|
|
bool Nand = false) const;
|
2013-03-12 08:16:36 +08:00
|
|
|
MachineBasicBlock *emitAtomicCmpSwap(MachineInstr *MI,
|
2011-05-31 10:54:07 +08:00
|
|
|
MachineBasicBlock *BB, unsigned Size) const;
|
2013-03-12 08:16:36 +08:00
|
|
|
MachineBasicBlock *emitAtomicCmpSwapPartword(MachineInstr *MI,
|
2011-05-31 10:54:07 +08:00
|
|
|
MachineBasicBlock *BB, unsigned Size) const;
|
2007-06-06 15:42:06 +08:00
|
|
|
};
|
2013-03-13 08:54:29 +08:00
|
|
|
|
|
|
|
/// Create MipsTargetLowering objects.
|
|
|
|
const MipsTargetLowering *createMips16TargetLowering(MipsTargetMachine &TM);
|
|
|
|
const MipsTargetLowering *createMipsSETargetLowering(MipsTargetMachine &TM);
|
2007-06-06 15:42:06 +08:00
|
|
|
}
|
|
|
|
|
|
|
|
#endif // MipsISELLOWERING_H
|