1239310Sdim//=====-- NVPTXSubtarget.h - Define Subtarget for the NVPTX ---*- C++ -*--====//
2239310Sdim//
3239310Sdim//                     The LLVM Compiler Infrastructure
4239310Sdim//
5239310Sdim// This file is distributed under the University of Illinois Open Source
6239310Sdim// License. See LICENSE.TXT for details.
7239310Sdim//
8239310Sdim//===----------------------------------------------------------------------===//
9239310Sdim//
10239310Sdim// This file declares the NVPTX specific subclass of TargetSubtarget.
11239310Sdim//
12239310Sdim//===----------------------------------------------------------------------===//
13239310Sdim
14280031Sdim#ifndef LLVM_LIB_TARGET_NVPTX_NVPTXSUBTARGET_H
15280031Sdim#define LLVM_LIB_TARGET_NVPTX_NVPTXSUBTARGET_H
16239310Sdim
17249423Sdim#include "NVPTX.h"
18276479Sdim#include "NVPTXFrameLowering.h"
19276479Sdim#include "NVPTXISelLowering.h"
20276479Sdim#include "NVPTXInstrInfo.h"
21276479Sdim#include "NVPTXRegisterInfo.h"
22276479Sdim#include "llvm/IR/DataLayout.h"
23276479Sdim#include "llvm/Target/TargetSelectionDAGInfo.h"
24239310Sdim#include "llvm/Target/TargetSubtargetInfo.h"
25276479Sdim#include <string>
26239310Sdim
27239310Sdim#define GET_SUBTARGETINFO_HEADER
28239310Sdim#include "NVPTXGenSubtargetInfo.inc"
29239310Sdim
30239310Sdimnamespace llvm {
31239310Sdim
32239310Sdimclass NVPTXSubtarget : public NVPTXGenSubtargetInfo {
33261991Sdim  virtual void anchor();
34239310Sdim  std::string TargetName;
35239310Sdim
36243830Sdim  // PTX version x.y is represented as 10*x+y, e.g. 3.1 == 31
37243830Sdim  unsigned PTXVersion;
38243830Sdim
39243830Sdim  // SM version x.y is represented as 10*x+y, e.g. 3.1 == 31
40243830Sdim  unsigned int SmVersion;
41243830Sdim
42288943Sdim  const NVPTXTargetMachine &TM;
43276479Sdim  NVPTXInstrInfo InstrInfo;
44276479Sdim  NVPTXTargetLowering TLInfo;
45276479Sdim  TargetSelectionDAGInfo TSInfo;
46276479Sdim
47276479Sdim  // NVPTX does not have any call stack frame, but need a NVPTX specific
48276479Sdim  // FrameLowering class because TargetFrameLowering is abstract.
49276479Sdim  NVPTXFrameLowering FrameLowering;
50276479Sdim
51239310Sdimpublic:
52239310Sdim  /// This constructor initializes the data members to match that
53239310Sdim  /// of the specified module.
54239310Sdim  ///
55288943Sdim  NVPTXSubtarget(const Triple &TT, const std::string &CPU,
56288943Sdim                 const std::string &FS, const NVPTXTargetMachine &TM);
57239310Sdim
58280031Sdim  const TargetFrameLowering *getFrameLowering() const override {
59280031Sdim    return &FrameLowering;
60280031Sdim  }
61280031Sdim  const NVPTXInstrInfo *getInstrInfo() const override { return &InstrInfo; }
62280031Sdim  const NVPTXRegisterInfo *getRegisterInfo() const override {
63276479Sdim    return &InstrInfo.getRegisterInfo();
64276479Sdim  }
65280031Sdim  const NVPTXTargetLowering *getTargetLowering() const override {
66280031Sdim    return &TLInfo;
67280031Sdim  }
68280031Sdim  const TargetSelectionDAGInfo *getSelectionDAGInfo() const override {
69280031Sdim    return &TSInfo;
70280031Sdim  }
71276479Sdim
72239310Sdim  bool hasBrkPt() const { return SmVersion >= 11; }
73239310Sdim  bool hasAtomRedG32() const { return SmVersion >= 11; }
74239310Sdim  bool hasAtomRedS32() const { return SmVersion >= 12; }
75239310Sdim  bool hasAtomRedG64() const { return SmVersion >= 12; }
76239310Sdim  bool hasAtomRedS64() const { return SmVersion >= 20; }
77239310Sdim  bool hasAtomRedGen32() const { return SmVersion >= 20; }
78239310Sdim  bool hasAtomRedGen64() const { return SmVersion >= 20; }
79239310Sdim  bool hasAtomAddF32() const { return SmVersion >= 20; }
80239310Sdim  bool hasVote() const { return SmVersion >= 12; }
81239310Sdim  bool hasDouble() const { return SmVersion >= 13; }
82239310Sdim  bool reqPTX20() const { return SmVersion >= 20; }
83239310Sdim  bool hasF32FTZ() const { return SmVersion >= 20; }
84239310Sdim  bool hasFMAF32() const { return SmVersion >= 20; }
85239310Sdim  bool hasFMAF64() const { return SmVersion >= 13; }
86249423Sdim  bool hasLDG() const { return SmVersion >= 32; }
87276479Sdim  bool hasLDU() const { return ((SmVersion >= 20) && (SmVersion < 30)); }
88239310Sdim  bool hasGenericLdSt() const { return SmVersion >= 20; }
89276479Sdim  inline bool hasHWROT32() const { return SmVersion >= 32; }
90276479Sdim  inline bool hasSWROT32() const {
91276479Sdim    return ((SmVersion >= 20) && (SmVersion < 32));
92276479Sdim  }
93249423Sdim  inline bool hasROT32() const { return hasHWROT32() || hasSWROT32(); }
94239310Sdim  inline bool hasROT64() const { return SmVersion >= 20; }
95288943Sdim  bool hasImageHandles() const;
96239310Sdim
97239310Sdim  unsigned int getSmVersion() const { return SmVersion; }
98239310Sdim  std::string getTargetName() const { return TargetName; }
99239310Sdim
100243830Sdim  unsigned getPTXVersion() const { return PTXVersion; }
101243830Sdim
102276479Sdim  NVPTXSubtarget &initializeSubtargetDependencies(StringRef CPU, StringRef FS);
103239310Sdim  void ParseSubtargetFeatures(StringRef CPU, StringRef FS);
104239310Sdim};
105239310Sdim
106239310Sdim} // End llvm namespace
107239310Sdim
108280031Sdim#endif
109