2007-12-04 22:23:35 +00:00
|
|
|
//===-- SPUISelLowering.h - Cell SPU DAG Lowering Interface -----*- C++ -*-===//
|
|
|
|
//
|
|
|
|
// The LLVM Compiler Infrastructure
|
|
|
|
//
|
2007-12-29 20:36:04 +00:00
|
|
|
// This file is distributed under the University of Illinois Open Source
|
|
|
|
// License. See LICENSE.TXT for details.
|
2007-12-04 22:23:35 +00:00
|
|
|
//
|
|
|
|
//===----------------------------------------------------------------------===//
|
|
|
|
//
|
|
|
|
// This file defines the interfaces that Cell SPU uses to lower LLVM code into
|
|
|
|
// a selection DAG.
|
|
|
|
//
|
|
|
|
//===----------------------------------------------------------------------===//
|
|
|
|
|
|
|
|
#ifndef SPU_ISELLOWERING_H
|
|
|
|
#define SPU_ISELLOWERING_H
|
|
|
|
|
|
|
|
#include "llvm/Target/TargetLowering.h"
|
|
|
|
#include "llvm/CodeGen/SelectionDAG.h"
|
|
|
|
#include "SPU.h"
|
|
|
|
|
|
|
|
namespace llvm {
|
|
|
|
namespace SPUISD {
|
|
|
|
enum NodeType {
|
|
|
|
// Start the numbering where the builting ops and target ops leave off.
|
2008-09-23 18:42:32 +00:00
|
|
|
FIRST_NUMBER = ISD::BUILTIN_OP_END,
|
2008-12-30 23:28:25 +00:00
|
|
|
|
2007-12-04 22:23:35 +00:00
|
|
|
// Pseudo instructions:
|
|
|
|
RET_FLAG, ///< Return with flag, matched by bi instruction
|
2008-12-30 23:28:25 +00:00
|
|
|
|
2007-12-04 22:23:35 +00:00
|
|
|
Hi, ///< High address component (upper 16)
|
|
|
|
Lo, ///< Low address component (lower 16)
|
|
|
|
PCRelAddr, ///< Program counter relative address
|
2008-01-11 02:53:15 +00:00
|
|
|
AFormAddr, ///< A-form address (local store)
|
2008-01-29 02:16:57 +00:00
|
|
|
IndirectAddr, ///< D-Form "imm($r)" and X-form "$r($r)"
|
2007-12-04 22:23:35 +00:00
|
|
|
|
|
|
|
LDRESULT, ///< Load result (value, chain)
|
|
|
|
CALL, ///< CALL instruction
|
|
|
|
SHUFB, ///< Vector shuffle (permute)
|
2008-11-22 23:50:42 +00:00
|
|
|
SHUFFLE_MASK, ///< Shuffle mask
|
2008-01-30 02:55:46 +00:00
|
|
|
CNTB, ///< Count leading ones in bytes
|
2008-12-27 04:51:36 +00:00
|
|
|
PREFSLOT2VEC, ///< Promote scalar->vector
|
2008-11-24 17:11:17 +00:00
|
|
|
VEC2PREFSLOT, ///< Extract element 0
|
2008-02-23 18:41:37 +00:00
|
|
|
SHLQUAD_L_BITS, ///< Rotate quad left, by bits
|
|
|
|
SHLQUAD_L_BYTES, ///< Rotate quad left, by bytes
|
2008-01-30 02:55:46 +00:00
|
|
|
VEC_ROTL, ///< Vector rotate left
|
|
|
|
VEC_ROTR, ///< Vector rotate right
|
|
|
|
ROTBYTES_LEFT, ///< Rotate bytes (loads -> ROTQBYI)
|
2008-06-02 22:18:03 +00:00
|
|
|
ROTBYTES_LEFT_BITS, ///< Rotate bytes left by bit shift count
|
|
|
|
SELECT_MASK, ///< Select Mask (FSM, FSMB, FSMH, FSMBI)
|
2008-01-30 02:55:46 +00:00
|
|
|
SELB, ///< Select bits -> (b & mask) | (a & ~mask)
|
2009-01-15 04:41:47 +00:00
|
|
|
// Markers: These aren't used to generate target-dependent nodes, but
|
|
|
|
// are used during instruction selection.
|
|
|
|
ADD64_MARKER, ///< i64 addition marker
|
|
|
|
SUB64_MARKER, ///< i64 subtraction marker
|
|
|
|
MUL64_MARKER, ///< i64 multiply marker
|
2008-01-30 02:55:46 +00:00
|
|
|
LAST_SPUISD ///< Last user-defined instruction
|
2007-12-04 22:23:35 +00:00
|
|
|
};
|
|
|
|
}
|
|
|
|
|
2009-01-26 03:31:40 +00:00
|
|
|
//! Utility functions specific to CellSPU:
|
2007-12-04 22:23:35 +00:00
|
|
|
namespace SPU {
|
2008-07-27 21:46:04 +00:00
|
|
|
SDValue get_vec_u18imm(SDNode *N, SelectionDAG &DAG,
|
2009-08-10 22:56:29 +00:00
|
|
|
EVT ValueType);
|
2008-07-27 21:46:04 +00:00
|
|
|
SDValue get_vec_i16imm(SDNode *N, SelectionDAG &DAG,
|
2009-08-10 22:56:29 +00:00
|
|
|
EVT ValueType);
|
2008-07-27 21:46:04 +00:00
|
|
|
SDValue get_vec_i10imm(SDNode *N, SelectionDAG &DAG,
|
2009-08-10 22:56:29 +00:00
|
|
|
EVT ValueType);
|
2008-07-27 21:46:04 +00:00
|
|
|
SDValue get_vec_i8imm(SDNode *N, SelectionDAG &DAG,
|
2009-08-10 22:56:29 +00:00
|
|
|
EVT ValueType);
|
2008-07-27 21:46:04 +00:00
|
|
|
SDValue get_ILHUvec_imm(SDNode *N, SelectionDAG &DAG,
|
2009-08-10 22:56:29 +00:00
|
|
|
EVT ValueType);
|
2008-07-27 21:46:04 +00:00
|
|
|
SDValue get_v4i32_imm(SDNode *N, SelectionDAG &DAG);
|
|
|
|
SDValue get_v2i64_imm(SDNode *N, SelectionDAG &DAG);
|
2009-01-15 04:41:47 +00:00
|
|
|
|
|
|
|
SDValue LowerConstantPool(SDValue Op, SelectionDAG &DAG,
|
|
|
|
const SPUTargetMachine &TM);
|
2009-08-10 22:56:29 +00:00
|
|
|
//! Simplify a EVT::v2i64 constant splat to CellSPU-ready form
|
|
|
|
SDValue LowerV2I64Splat(EVT OpVT, SelectionDAG &DAG, uint64_t splat,
|
2009-02-06 01:31:28 +00:00
|
|
|
DebugLoc dl);
|
2007-12-04 22:23:35 +00:00
|
|
|
}
|
|
|
|
|
|
|
|
class SPUTargetMachine; // forward dec'l.
|
2008-12-30 23:28:25 +00:00
|
|
|
|
2007-12-04 22:23:35 +00:00
|
|
|
class SPUTargetLowering :
|
|
|
|
public TargetLowering
|
|
|
|
{
|
|
|
|
int VarArgsFrameIndex; // FrameIndex for start of varargs area.
|
|
|
|
SPUTargetMachine &SPUTM;
|
|
|
|
|
|
|
|
public:
|
2009-01-15 04:41:47 +00:00
|
|
|
//! The venerable constructor
|
|
|
|
/*!
|
|
|
|
This is where the CellSPU backend sets operation handling (i.e., legal,
|
|
|
|
custom, expand or promote.)
|
|
|
|
*/
|
2007-12-04 22:23:35 +00:00
|
|
|
SPUTargetLowering(SPUTargetMachine &TM);
|
2008-12-30 23:28:25 +00:00
|
|
|
|
2009-01-15 04:41:47 +00:00
|
|
|
//! Get the target machine
|
|
|
|
SPUTargetMachine &getSPUTargetMachine() {
|
|
|
|
return SPUTM;
|
|
|
|
}
|
|
|
|
|
2007-12-04 22:23:35 +00:00
|
|
|
/// getTargetNodeName() - This method returns the name of a target specific
|
|
|
|
/// DAG node.
|
|
|
|
virtual const char *getTargetNodeName(unsigned Opcode) const;
|
2008-03-10 15:42:14 +00:00
|
|
|
|
|
|
|
/// getSetCCResultType - Return the ValueType for ISD::SETCC
|
2009-08-11 20:47:22 +00:00
|
|
|
virtual MVT::SimpleValueType getSetCCResultType(EVT VT) const;
|
2008-12-30 23:28:25 +00:00
|
|
|
|
2008-11-10 23:43:06 +00:00
|
|
|
//! Custom lowering hooks
|
2008-07-27 21:46:04 +00:00
|
|
|
virtual SDValue LowerOperation(SDValue Op, SelectionDAG &DAG);
|
2008-11-10 23:43:06 +00:00
|
|
|
|
2008-12-01 11:39:25 +00:00
|
|
|
//! Custom lowering hook for nodes with illegal result types.
|
|
|
|
virtual void ReplaceNodeResults(SDNode *N, SmallVectorImpl<SDValue>&Results,
|
|
|
|
SelectionDAG &DAG);
|
|
|
|
|
2008-07-27 21:46:04 +00:00
|
|
|
virtual SDValue PerformDAGCombine(SDNode *N, DAGCombinerInfo &DCI) const;
|
2007-12-04 22:23:35 +00:00
|
|
|
|
2008-07-27 21:46:04 +00:00
|
|
|
virtual void computeMaskedBitsForTargetNode(const SDValue Op,
|
2008-02-13 22:28:48 +00:00
|
|
|
const APInt &Mask,
|
2008-12-30 23:28:25 +00:00
|
|
|
APInt &KnownZero,
|
2008-02-13 00:35:47 +00:00
|
|
|
APInt &KnownOne,
|
2007-12-04 22:23:35 +00:00
|
|
|
const SelectionDAG &DAG,
|
|
|
|
unsigned Depth = 0) const;
|
|
|
|
|
2008-12-27 04:51:36 +00:00
|
|
|
virtual unsigned ComputeNumSignBitsForTargetNode(SDValue Op,
|
|
|
|
unsigned Depth = 0) const;
|
|
|
|
|
2007-12-04 22:23:35 +00:00
|
|
|
ConstraintType getConstraintType(const std::string &ConstraintLetter) const;
|
|
|
|
|
2008-12-30 23:28:25 +00:00
|
|
|
std::pair<unsigned, const TargetRegisterClass*>
|
2007-12-04 22:23:35 +00:00
|
|
|
getRegForInlineAsmConstraint(const std::string &Constraint,
|
2009-08-10 22:56:29 +00:00
|
|
|
EVT VT) const;
|
2007-12-04 22:23:35 +00:00
|
|
|
|
2008-07-27 21:46:04 +00:00
|
|
|
void LowerAsmOperandForConstraint(SDValue Op, char ConstraintLetter,
|
2008-12-30 23:28:25 +00:00
|
|
|
bool hasMemory,
|
2008-07-27 21:46:04 +00:00
|
|
|
std::vector<SDValue> &Ops,
|
2008-04-30 00:30:08 +00:00
|
|
|
SelectionDAG &DAG) const;
|
|
|
|
|
2007-12-04 22:23:35 +00:00
|
|
|
/// isLegalAddressImmediate - Return true if the integer value can be used
|
|
|
|
/// as the offset of the target addressing mode.
|
|
|
|
virtual bool isLegalAddressImmediate(int64_t V, const Type *Ty) const;
|
|
|
|
virtual bool isLegalAddressImmediate(GlobalValue *) 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.
git-svn-id: https://llvm.org/svn/llvm-project/llvm/trunk@57748 91177308-0d34-0410-b5e6-96231b3b80d8
2008-10-18 02:06:02 +00:00
|
|
|
|
|
|
|
virtual bool isOffsetFoldingLegal(const GlobalAddressSDNode *GA) const;
|
2009-06-30 22:38:32 +00:00
|
|
|
|
2009-07-01 18:50:55 +00:00
|
|
|
/// getFunctionAlignment - Return the Log2 alignment of this function.
|
2009-06-30 22:38:32 +00:00
|
|
|
virtual unsigned getFunctionAlignment(const Function *F) 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
|
|
|
|
|
|
|
virtual SDValue
|
|
|
|
LowerFormalArguments(SDValue Chain,
|
|
|
|
unsigned CallConv, bool isVarArg,
|
|
|
|
const SmallVectorImpl<ISD::InputArg> &Ins,
|
|
|
|
DebugLoc dl, SelectionDAG &DAG,
|
|
|
|
SmallVectorImpl<SDValue> &InVals);
|
|
|
|
|
|
|
|
virtual SDValue
|
|
|
|
LowerCall(SDValue Chain, SDValue Callee,
|
|
|
|
unsigned CallConv, bool isVarArg,
|
|
|
|
bool isTailCall,
|
|
|
|
const SmallVectorImpl<ISD::OutputArg> &Outs,
|
|
|
|
const SmallVectorImpl<ISD::InputArg> &Ins,
|
|
|
|
DebugLoc dl, SelectionDAG &DAG,
|
|
|
|
SmallVectorImpl<SDValue> &InVals);
|
|
|
|
|
|
|
|
virtual SDValue
|
|
|
|
LowerReturn(SDValue Chain,
|
|
|
|
unsigned CallConv, bool isVarArg,
|
|
|
|
const SmallVectorImpl<ISD::OutputArg> &Outs,
|
|
|
|
DebugLoc dl, SelectionDAG &DAG);
|
2007-12-04 22:23:35 +00:00
|
|
|
};
|
|
|
|
}
|
|
|
|
|
|
|
|
#endif
|