NVPTXSubtarget.h revision 08e9cb46feb0c8e08e3d309a0f9fd75a04ca54fb
149683f3c961379fbc088871a5d6304950f1f1cbcJustin Holewinski//=====-- NVPTXSubtarget.h - Define Subtarget for the NVPTX ---*- C++ -*--====//
249683f3c961379fbc088871a5d6304950f1f1cbcJustin Holewinski//
349683f3c961379fbc088871a5d6304950f1f1cbcJustin Holewinski//                     The LLVM Compiler Infrastructure
449683f3c961379fbc088871a5d6304950f1f1cbcJustin Holewinski//
549683f3c961379fbc088871a5d6304950f1f1cbcJustin Holewinski// This file is distributed under the University of Illinois Open Source
649683f3c961379fbc088871a5d6304950f1f1cbcJustin Holewinski// License. See LICENSE.TXT for details.
749683f3c961379fbc088871a5d6304950f1f1cbcJustin Holewinski//
849683f3c961379fbc088871a5d6304950f1f1cbcJustin Holewinski//===----------------------------------------------------------------------===//
949683f3c961379fbc088871a5d6304950f1f1cbcJustin Holewinski//
1049683f3c961379fbc088871a5d6304950f1f1cbcJustin Holewinski// This file declares the NVPTX specific subclass of TargetSubtarget.
1149683f3c961379fbc088871a5d6304950f1f1cbcJustin Holewinski//
1249683f3c961379fbc088871a5d6304950f1f1cbcJustin Holewinski//===----------------------------------------------------------------------===//
1349683f3c961379fbc088871a5d6304950f1f1cbcJustin Holewinski
1449683f3c961379fbc088871a5d6304950f1f1cbcJustin Holewinski#ifndef NVPTXSUBTARGET_H
1549683f3c961379fbc088871a5d6304950f1f1cbcJustin Holewinski#define NVPTXSUBTARGET_H
1649683f3c961379fbc088871a5d6304950f1f1cbcJustin Holewinski
1749683f3c961379fbc088871a5d6304950f1f1cbcJustin Holewinski#include "llvm/Target/TargetSubtargetInfo.h"
1849683f3c961379fbc088871a5d6304950f1f1cbcJustin Holewinski#include "NVPTX.h"
1949683f3c961379fbc088871a5d6304950f1f1cbcJustin Holewinski
2049683f3c961379fbc088871a5d6304950f1f1cbcJustin Holewinski#define GET_SUBTARGETINFO_HEADER
2149683f3c961379fbc088871a5d6304950f1f1cbcJustin Holewinski#include "NVPTXGenSubtargetInfo.inc"
2249683f3c961379fbc088871a5d6304950f1f1cbcJustin Holewinski
2349683f3c961379fbc088871a5d6304950f1f1cbcJustin Holewinski#include <string>
2449683f3c961379fbc088871a5d6304950f1f1cbcJustin Holewinski
2549683f3c961379fbc088871a5d6304950f1f1cbcJustin Holewinskinamespace llvm {
2649683f3c961379fbc088871a5d6304950f1f1cbcJustin Holewinski
2749683f3c961379fbc088871a5d6304950f1f1cbcJustin Holewinskiclass NVPTXSubtarget : public NVPTXGenSubtargetInfo {
2808e9cb46feb0c8e08e3d309a0f9fd75a04ca54fbJustin Holewinski
2949683f3c961379fbc088871a5d6304950f1f1cbcJustin Holewinski  std::string TargetName;
3049683f3c961379fbc088871a5d6304950f1f1cbcJustin Holewinski  NVPTX::DrvInterface drvInterface;
3149683f3c961379fbc088871a5d6304950f1f1cbcJustin Holewinski  bool dummy; // For the 'dummy' feature, see NVPTX.td
3249683f3c961379fbc088871a5d6304950f1f1cbcJustin Holewinski  bool Is64Bit;
3349683f3c961379fbc088871a5d6304950f1f1cbcJustin Holewinski
3408e9cb46feb0c8e08e3d309a0f9fd75a04ca54fbJustin Holewinski  // PTX version x.y is represented as 10*x+y, e.g. 3.1 == 31
3508e9cb46feb0c8e08e3d309a0f9fd75a04ca54fbJustin Holewinski  unsigned PTXVersion;
3608e9cb46feb0c8e08e3d309a0f9fd75a04ca54fbJustin Holewinski
3708e9cb46feb0c8e08e3d309a0f9fd75a04ca54fbJustin Holewinski  // SM version x.y is represented as 10*x+y, e.g. 3.1 == 31
3808e9cb46feb0c8e08e3d309a0f9fd75a04ca54fbJustin Holewinski  unsigned int SmVersion;
3908e9cb46feb0c8e08e3d309a0f9fd75a04ca54fbJustin Holewinski
4049683f3c961379fbc088871a5d6304950f1f1cbcJustin Holewinskipublic:
4149683f3c961379fbc088871a5d6304950f1f1cbcJustin Holewinski  /// This constructor initializes the data members to match that
4249683f3c961379fbc088871a5d6304950f1f1cbcJustin Holewinski  /// of the specified module.
4349683f3c961379fbc088871a5d6304950f1f1cbcJustin Holewinski  ///
4449683f3c961379fbc088871a5d6304950f1f1cbcJustin Holewinski  NVPTXSubtarget(const std::string &TT, const std::string &CPU,
4549683f3c961379fbc088871a5d6304950f1f1cbcJustin Holewinski                 const std::string &FS, bool is64Bit);
4649683f3c961379fbc088871a5d6304950f1f1cbcJustin Holewinski
4749683f3c961379fbc088871a5d6304950f1f1cbcJustin Holewinski  bool hasBrkPt() const { return SmVersion >= 11; }
4849683f3c961379fbc088871a5d6304950f1f1cbcJustin Holewinski  bool hasAtomRedG32() const { return SmVersion >= 11; }
4949683f3c961379fbc088871a5d6304950f1f1cbcJustin Holewinski  bool hasAtomRedS32() const { return SmVersion >= 12; }
5049683f3c961379fbc088871a5d6304950f1f1cbcJustin Holewinski  bool hasAtomRedG64() const { return SmVersion >= 12; }
5149683f3c961379fbc088871a5d6304950f1f1cbcJustin Holewinski  bool hasAtomRedS64() const { return SmVersion >= 20; }
5249683f3c961379fbc088871a5d6304950f1f1cbcJustin Holewinski  bool hasAtomRedGen32() const { return SmVersion >= 20; }
5349683f3c961379fbc088871a5d6304950f1f1cbcJustin Holewinski  bool hasAtomRedGen64() const { return SmVersion >= 20; }
5449683f3c961379fbc088871a5d6304950f1f1cbcJustin Holewinski  bool hasAtomAddF32() const { return SmVersion >= 20; }
5549683f3c961379fbc088871a5d6304950f1f1cbcJustin Holewinski  bool hasVote() const { return SmVersion >= 12; }
5649683f3c961379fbc088871a5d6304950f1f1cbcJustin Holewinski  bool hasDouble() const { return SmVersion >= 13; }
5749683f3c961379fbc088871a5d6304950f1f1cbcJustin Holewinski  bool reqPTX20() const { return SmVersion >= 20; }
5849683f3c961379fbc088871a5d6304950f1f1cbcJustin Holewinski  bool hasF32FTZ() const { return SmVersion >= 20; }
5949683f3c961379fbc088871a5d6304950f1f1cbcJustin Holewinski  bool hasFMAF32() const { return SmVersion >= 20; }
6049683f3c961379fbc088871a5d6304950f1f1cbcJustin Holewinski  bool hasFMAF64() const { return SmVersion >= 13; }
6149683f3c961379fbc088871a5d6304950f1f1cbcJustin Holewinski  bool hasLDU() const { return SmVersion >= 20; }
6249683f3c961379fbc088871a5d6304950f1f1cbcJustin Holewinski  bool hasGenericLdSt() const { return SmVersion >= 20; }
6349683f3c961379fbc088871a5d6304950f1f1cbcJustin Holewinski  inline bool hasHWROT32() const { return false; }
6449683f3c961379fbc088871a5d6304950f1f1cbcJustin Holewinski  inline bool hasSWROT32() const {
6549683f3c961379fbc088871a5d6304950f1f1cbcJustin Holewinski    return true;
6649683f3c961379fbc088871a5d6304950f1f1cbcJustin Holewinski  }
6749683f3c961379fbc088871a5d6304950f1f1cbcJustin Holewinski  inline bool hasROT32() const { return hasHWROT32() || hasSWROT32() ; }
6849683f3c961379fbc088871a5d6304950f1f1cbcJustin Holewinski  inline bool hasROT64() const { return SmVersion >= 20; }
6949683f3c961379fbc088871a5d6304950f1f1cbcJustin Holewinski
7049683f3c961379fbc088871a5d6304950f1f1cbcJustin Holewinski
7149683f3c961379fbc088871a5d6304950f1f1cbcJustin Holewinski  bool is64Bit() const { return Is64Bit; }
7249683f3c961379fbc088871a5d6304950f1f1cbcJustin Holewinski
7349683f3c961379fbc088871a5d6304950f1f1cbcJustin Holewinski  unsigned int getSmVersion() const { return SmVersion; }
7449683f3c961379fbc088871a5d6304950f1f1cbcJustin Holewinski  NVPTX::DrvInterface getDrvInterface() const { return drvInterface; }
7549683f3c961379fbc088871a5d6304950f1f1cbcJustin Holewinski  std::string getTargetName() const { return TargetName; }
7649683f3c961379fbc088871a5d6304950f1f1cbcJustin Holewinski
7708e9cb46feb0c8e08e3d309a0f9fd75a04ca54fbJustin Holewinski  unsigned getPTXVersion() const { return PTXVersion; }
7808e9cb46feb0c8e08e3d309a0f9fd75a04ca54fbJustin Holewinski
7949683f3c961379fbc088871a5d6304950f1f1cbcJustin Holewinski  void ParseSubtargetFeatures(StringRef CPU, StringRef FS);
8049683f3c961379fbc088871a5d6304950f1f1cbcJustin Holewinski
8149683f3c961379fbc088871a5d6304950f1f1cbcJustin Holewinski  std::string getDataLayout() const {
8249683f3c961379fbc088871a5d6304950f1f1cbcJustin Holewinski    const char *p;
8349683f3c961379fbc088871a5d6304950f1f1cbcJustin Holewinski    if (is64Bit())
8449683f3c961379fbc088871a5d6304950f1f1cbcJustin Holewinski      p = "e-p:64:64:64-i1:8:8-i8:8:8-i16:16:16-i32:32:32-i64:64:64-"
8549683f3c961379fbc088871a5d6304950f1f1cbcJustin Holewinski          "f32:32:32-f64:64:64-v16:16:16-v32:32:32-v64:64:64-v128:128:128-"
8649683f3c961379fbc088871a5d6304950f1f1cbcJustin Holewinski          "n16:32:64";
8749683f3c961379fbc088871a5d6304950f1f1cbcJustin Holewinski    else
8849683f3c961379fbc088871a5d6304950f1f1cbcJustin Holewinski      p = "e-p:32:32:32-i1:8:8-i8:8:8-i16:16:16-i32:32:32-i64:64:64-"
8949683f3c961379fbc088871a5d6304950f1f1cbcJustin Holewinski          "f32:32:32-f64:64:64-v16:16:16-v32:32:32-v64:64:64-v128:128:128-"
9049683f3c961379fbc088871a5d6304950f1f1cbcJustin Holewinski          "n16:32:64";
9149683f3c961379fbc088871a5d6304950f1f1cbcJustin Holewinski
9249683f3c961379fbc088871a5d6304950f1f1cbcJustin Holewinski    return std::string(p);
9349683f3c961379fbc088871a5d6304950f1f1cbcJustin Holewinski  }
9449683f3c961379fbc088871a5d6304950f1f1cbcJustin Holewinski
9549683f3c961379fbc088871a5d6304950f1f1cbcJustin Holewinski};
9649683f3c961379fbc088871a5d6304950f1f1cbcJustin Holewinski
9749683f3c961379fbc088871a5d6304950f1f1cbcJustin Holewinski} // End llvm namespace
9849683f3c961379fbc088871a5d6304950f1f1cbcJustin Holewinski
9949683f3c961379fbc088871a5d6304950f1f1cbcJustin Holewinski#endif  // NVPTXSUBTARGET_H
100