2012-05-05 04:18:50 +08:00
|
|
|
//===-- NVPTXISelLowering.h - NVPTX DAG Lowering Interface ------*- C++ -*-===//
|
|
|
|
//
|
|
|
|
// 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 NVPTX uses to lower LLVM code into a
|
|
|
|
// selection DAG.
|
|
|
|
//
|
|
|
|
//===----------------------------------------------------------------------===//
|
|
|
|
|
|
|
|
#ifndef NVPTXISELLOWERING_H
|
|
|
|
#define NVPTXISELLOWERING_H
|
|
|
|
|
|
|
|
#include "NVPTX.h"
|
|
|
|
#include "NVPTXSubtarget.h"
|
|
|
|
#include "llvm/CodeGen/SelectionDAG.h"
|
|
|
|
#include "llvm/Target/TargetLowering.h"
|
|
|
|
|
|
|
|
namespace llvm {
|
|
|
|
namespace NVPTXISD {
|
|
|
|
enum NodeType {
|
|
|
|
// Start the numbering from where ISD NodeType finishes.
|
|
|
|
FIRST_NUMBER = ISD::BUILTIN_OP_END,
|
|
|
|
Wrapper,
|
|
|
|
CALL,
|
|
|
|
RET_FLAG,
|
|
|
|
LOAD_PARAM,
|
|
|
|
NVBuiltin,
|
|
|
|
DeclareParam,
|
|
|
|
DeclareScalarParam,
|
|
|
|
DeclareRetParam,
|
|
|
|
DeclareRet,
|
|
|
|
DeclareScalarRet,
|
|
|
|
LoadParam,
|
|
|
|
StoreParam,
|
|
|
|
StoreParamS32, // to sext and store a <32bit value, not used currently
|
|
|
|
StoreParamU32, // to zext and store a <32bit value, not used currently
|
|
|
|
MoveToParam,
|
|
|
|
PrintCall,
|
|
|
|
PrintCallUni,
|
|
|
|
CallArgBegin,
|
|
|
|
CallArg,
|
|
|
|
LastCallArg,
|
|
|
|
CallArgEnd,
|
|
|
|
CallVoid,
|
|
|
|
CallVal,
|
|
|
|
CallSymbol,
|
|
|
|
Prototype,
|
|
|
|
MoveParam,
|
|
|
|
MoveRetval,
|
|
|
|
MoveToRetval,
|
|
|
|
StoreRetval,
|
|
|
|
PseudoUseParam,
|
|
|
|
RETURN,
|
|
|
|
CallSeqBegin,
|
|
|
|
CallSeqEnd,
|
2013-02-12 22:18:49 +08:00
|
|
|
Dummy,
|
|
|
|
|
|
|
|
LoadV2 = ISD::FIRST_TARGET_MEMORY_OPCODE,
|
|
|
|
LoadV4,
|
|
|
|
LDGV2, // LDG.v2
|
|
|
|
LDGV4, // LDG.v4
|
|
|
|
LDUV2, // LDU.v2
|
|
|
|
LDUV4, // LDU.v4
|
|
|
|
StoreV2,
|
|
|
|
StoreV4
|
2012-05-05 04:18:50 +08:00
|
|
|
};
|
|
|
|
}
|
|
|
|
|
|
|
|
//===--------------------------------------------------------------------===//
|
|
|
|
// TargetLowering Implementation
|
|
|
|
//===--------------------------------------------------------------------===//
|
|
|
|
class NVPTXTargetLowering : public TargetLowering {
|
|
|
|
public:
|
|
|
|
explicit NVPTXTargetLowering(NVPTXTargetMachine &TM);
|
|
|
|
virtual SDValue LowerOperation(SDValue Op, SelectionDAG &DAG) const;
|
|
|
|
|
|
|
|
SDValue LowerGlobalAddress(SDValue Op, SelectionDAG &DAG) const;
|
|
|
|
SDValue LowerGlobalAddress(const GlobalValue *GV, int64_t Offset,
|
|
|
|
SelectionDAG &DAG) const;
|
|
|
|
|
|
|
|
virtual const char *getTargetNodeName(unsigned Opcode) const;
|
|
|
|
|
|
|
|
bool isTypeSupportedInIntrinsic(MVT VT) const;
|
|
|
|
|
2013-03-30 22:29:21 +08:00
|
|
|
bool getTgtMemIntrinsic(IntrinsicInfo &Info, const CallInst &I,
|
2012-05-05 04:18:50 +08:00
|
|
|
unsigned Intrinsic) const;
|
|
|
|
|
|
|
|
/// isLegalAddressingMode - Return true if the addressing mode represented
|
|
|
|
/// by AM is legal for this target, for a load/store of the specified type
|
|
|
|
/// Used to guide target specific optimizations, like loop strength
|
|
|
|
/// reduction (LoopStrengthReduce.cpp) and memory optimization for
|
|
|
|
/// address mode (CodeGenPrepare.cpp)
|
|
|
|
virtual bool isLegalAddressingMode(const AddrMode &AM, Type *Ty) const;
|
|
|
|
|
|
|
|
/// getFunctionAlignment - Return the Log2 alignment of this function.
|
|
|
|
virtual unsigned getFunctionAlignment(const Function *F) const;
|
|
|
|
|
|
|
|
virtual EVT getSetCCResultType(EVT VT) const {
|
2012-11-29 22:26:24 +08:00
|
|
|
if (VT.isVector())
|
|
|
|
return MVT::getVectorVT(MVT::i1, VT.getVectorNumElements());
|
2012-05-05 04:18:50 +08:00
|
|
|
return MVT::i1;
|
|
|
|
}
|
|
|
|
|
|
|
|
ConstraintType getConstraintType(const std::string &Constraint) const;
|
2013-03-30 22:29:21 +08:00
|
|
|
std::pair<unsigned, const TargetRegisterClass *>
|
2012-05-05 04:18:50 +08:00
|
|
|
getRegForInlineAsmConstraint(const std::string &Constraint, EVT VT) const;
|
|
|
|
|
2013-03-30 22:29:21 +08:00
|
|
|
virtual SDValue LowerFormalArguments(
|
|
|
|
SDValue Chain, CallingConv::ID CallConv, bool isVarArg,
|
|
|
|
const SmallVectorImpl<ISD::InputArg> &Ins, DebugLoc dl, SelectionDAG &DAG,
|
|
|
|
SmallVectorImpl<SDValue> &InVals) const;
|
2012-05-05 04:18:50 +08:00
|
|
|
|
2012-05-26 00:35:28 +08:00
|
|
|
virtual SDValue
|
|
|
|
LowerCall(CallLoweringInfo &CLI, SmallVectorImpl<SDValue> &InVals) const;
|
2012-05-05 04:18:50 +08:00
|
|
|
|
|
|
|
std::string getPrototype(Type *, const ArgListTy &,
|
|
|
|
const SmallVectorImpl<ISD::OutputArg> &,
|
|
|
|
unsigned retAlignment) const;
|
|
|
|
|
|
|
|
virtual SDValue
|
|
|
|
LowerReturn(SDValue Chain, CallingConv::ID CallConv, bool isVarArg,
|
|
|
|
const SmallVectorImpl<ISD::OutputArg> &Outs,
|
|
|
|
const SmallVectorImpl<SDValue> &OutVals, DebugLoc dl,
|
|
|
|
SelectionDAG &DAG) const;
|
|
|
|
|
|
|
|
virtual void LowerAsmOperandForConstraint(SDValue Op, std::string &Constraint,
|
|
|
|
std::vector<SDValue> &Ops,
|
|
|
|
SelectionDAG &DAG) const;
|
|
|
|
|
|
|
|
NVPTXTargetMachine *nvTM;
|
|
|
|
|
|
|
|
// PTX always uses 32-bit shift amounts
|
2013-03-30 22:29:21 +08:00
|
|
|
virtual MVT getScalarShiftAmountTy(EVT LHSTy) const { return MVT::i32; }
|
2012-05-05 04:18:50 +08:00
|
|
|
|
2012-11-29 22:26:24 +08:00
|
|
|
virtual bool shouldSplitVectorElementType(EVT VT) const;
|
|
|
|
|
2012-05-05 04:18:50 +08:00
|
|
|
private:
|
2013-03-30 22:29:21 +08:00
|
|
|
const NVPTXSubtarget &nvptxSubtarget; // cache the subtarget here
|
2012-05-05 04:18:50 +08:00
|
|
|
|
2013-03-30 22:29:21 +08:00
|
|
|
SDValue getExtSymb(SelectionDAG &DAG, const char *name, int idx,
|
|
|
|
EVT = MVT::i32) const;
|
2012-05-05 04:18:50 +08:00
|
|
|
SDValue getParamSymbol(SelectionDAG &DAG, int idx, EVT = MVT::i32) const;
|
|
|
|
SDValue getParamHelpSymbol(SelectionDAG &DAG, int idx);
|
|
|
|
|
|
|
|
SDValue LowerCONCAT_VECTORS(SDValue Op, SelectionDAG &DAG) const;
|
2012-11-15 03:19:16 +08:00
|
|
|
|
|
|
|
SDValue LowerLOAD(SDValue Op, SelectionDAG &DAG) const;
|
2013-02-12 22:18:49 +08:00
|
|
|
SDValue LowerLOADi1(SDValue Op, SelectionDAG &DAG) const;
|
|
|
|
|
|
|
|
SDValue LowerSTORE(SDValue Op, SelectionDAG &DAG) const;
|
|
|
|
SDValue LowerSTOREi1(SDValue Op, SelectionDAG &DAG) const;
|
|
|
|
SDValue LowerSTOREVector(SDValue Op, SelectionDAG &DAG) const;
|
|
|
|
|
2013-03-30 22:29:21 +08:00
|
|
|
virtual void ReplaceNodeResults(SDNode *N, SmallVectorImpl<SDValue> &Results,
|
2013-02-12 22:18:49 +08:00
|
|
|
SelectionDAG &DAG) const;
|
2012-05-05 04:18:50 +08:00
|
|
|
};
|
|
|
|
} // namespace llvm
|
|
|
|
|
|
|
|
#endif // NVPTXISELLOWERING_H
|