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 "NVPTX.h"
18a1514e24cc24b050f53a12650e047799358833a1Chandler Carruth#include "llvm/Target/TargetSubtargetInfo.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 {
283639ce2575660a0e6938d2e84e8bd9a738fd7051Justin Holewinski
2949683f3c961379fbc088871a5d6304950f1f1cbcJustin Holewinski  std::string TargetName;
3049683f3c961379fbc088871a5d6304950f1f1cbcJustin Holewinski  NVPTX::DrvInterface drvInterface;
3149683f3c961379fbc088871a5d6304950f1f1cbcJustin Holewinski  bool Is64Bit;
3249683f3c961379fbc088871a5d6304950f1f1cbcJustin Holewinski
3308e9cb46feb0c8e08e3d309a0f9fd75a04ca54fbJustin Holewinski  // PTX version x.y is represented as 10*x+y, e.g. 3.1 == 31
3408e9cb46feb0c8e08e3d309a0f9fd75a04ca54fbJustin Holewinski  unsigned PTXVersion;
3508e9cb46feb0c8e08e3d309a0f9fd75a04ca54fbJustin Holewinski
3608e9cb46feb0c8e08e3d309a0f9fd75a04ca54fbJustin Holewinski  // SM version x.y is represented as 10*x+y, e.g. 3.1 == 31
3708e9cb46feb0c8e08e3d309a0f9fd75a04ca54fbJustin Holewinski  unsigned int SmVersion;
3808e9cb46feb0c8e08e3d309a0f9fd75a04ca54fbJustin Holewinski
3949683f3c961379fbc088871a5d6304950f1f1cbcJustin Holewinskipublic:
4049683f3c961379fbc088871a5d6304950f1f1cbcJustin Holewinski  /// This constructor initializes the data members to match that
4149683f3c961379fbc088871a5d6304950f1f1cbcJustin Holewinski  /// of the specified module.
4249683f3c961379fbc088871a5d6304950f1f1cbcJustin Holewinski  ///
4349683f3c961379fbc088871a5d6304950f1f1cbcJustin Holewinski  NVPTXSubtarget(const std::string &TT, const std::string &CPU,
4449683f3c961379fbc088871a5d6304950f1f1cbcJustin Holewinski                 const std::string &FS, bool is64Bit);
4549683f3c961379fbc088871a5d6304950f1f1cbcJustin Holewinski
4649683f3c961379fbc088871a5d6304950f1f1cbcJustin Holewinski  bool hasBrkPt() const { return SmVersion >= 11; }
4749683f3c961379fbc088871a5d6304950f1f1cbcJustin Holewinski  bool hasAtomRedG32() const { return SmVersion >= 11; }
4849683f3c961379fbc088871a5d6304950f1f1cbcJustin Holewinski  bool hasAtomRedS32() const { return SmVersion >= 12; }
4949683f3c961379fbc088871a5d6304950f1f1cbcJustin Holewinski  bool hasAtomRedG64() const { return SmVersion >= 12; }
5049683f3c961379fbc088871a5d6304950f1f1cbcJustin Holewinski  bool hasAtomRedS64() const { return SmVersion >= 20; }
5149683f3c961379fbc088871a5d6304950f1f1cbcJustin Holewinski  bool hasAtomRedGen32() const { return SmVersion >= 20; }
5249683f3c961379fbc088871a5d6304950f1f1cbcJustin Holewinski  bool hasAtomRedGen64() const { return SmVersion >= 20; }
5349683f3c961379fbc088871a5d6304950f1f1cbcJustin Holewinski  bool hasAtomAddF32() const { return SmVersion >= 20; }
5449683f3c961379fbc088871a5d6304950f1f1cbcJustin Holewinski  bool hasVote() const { return SmVersion >= 12; }
5549683f3c961379fbc088871a5d6304950f1f1cbcJustin Holewinski  bool hasDouble() const { return SmVersion >= 13; }
5649683f3c961379fbc088871a5d6304950f1f1cbcJustin Holewinski  bool reqPTX20() const { return SmVersion >= 20; }
5749683f3c961379fbc088871a5d6304950f1f1cbcJustin Holewinski  bool hasF32FTZ() const { return SmVersion >= 20; }
5849683f3c961379fbc088871a5d6304950f1f1cbcJustin Holewinski  bool hasFMAF32() const { return SmVersion >= 20; }
5949683f3c961379fbc088871a5d6304950f1f1cbcJustin Holewinski  bool hasFMAF64() const { return SmVersion >= 13; }
607eacad03efda36e09ebd96e95d7891cadaaa9087Justin Holewinski  bool hasLDG() const { return SmVersion >= 32; }
6149683f3c961379fbc088871a5d6304950f1f1cbcJustin Holewinski  bool hasLDU() const { return SmVersion >= 20; }
6249683f3c961379fbc088871a5d6304950f1f1cbcJustin Holewinski  bool hasGenericLdSt() const { return SmVersion >= 20; }
6349683f3c961379fbc088871a5d6304950f1f1cbcJustin Holewinski  inline bool hasHWROT32() const { return false; }
643639ce2575660a0e6938d2e84e8bd9a738fd7051Justin Holewinski  inline bool hasSWROT32() const { return true; }
653639ce2575660a0e6938d2e84e8bd9a738fd7051Justin Holewinski  inline bool hasROT32() const { return hasHWROT32() || hasSWROT32(); }
6649683f3c961379fbc088871a5d6304950f1f1cbcJustin Holewinski  inline bool hasROT64() const { return SmVersion >= 20; }
6749683f3c961379fbc088871a5d6304950f1f1cbcJustin Holewinski
6849683f3c961379fbc088871a5d6304950f1f1cbcJustin Holewinski  bool is64Bit() const { return Is64Bit; }
6949683f3c961379fbc088871a5d6304950f1f1cbcJustin Holewinski
7049683f3c961379fbc088871a5d6304950f1f1cbcJustin Holewinski  unsigned int getSmVersion() const { return SmVersion; }
7149683f3c961379fbc088871a5d6304950f1f1cbcJustin Holewinski  NVPTX::DrvInterface getDrvInterface() const { return drvInterface; }
7249683f3c961379fbc088871a5d6304950f1f1cbcJustin Holewinski  std::string getTargetName() const { return TargetName; }
7349683f3c961379fbc088871a5d6304950f1f1cbcJustin Holewinski
7408e9cb46feb0c8e08e3d309a0f9fd75a04ca54fbJustin Holewinski  unsigned getPTXVersion() const { return PTXVersion; }
7508e9cb46feb0c8e08e3d309a0f9fd75a04ca54fbJustin Holewinski
7649683f3c961379fbc088871a5d6304950f1f1cbcJustin Holewinski  void ParseSubtargetFeatures(StringRef CPU, StringRef FS);
7749683f3c961379fbc088871a5d6304950f1f1cbcJustin Holewinski
7849683f3c961379fbc088871a5d6304950f1f1cbcJustin Holewinski  std::string getDataLayout() const {
7949683f3c961379fbc088871a5d6304950f1f1cbcJustin Holewinski    const char *p;
8049683f3c961379fbc088871a5d6304950f1f1cbcJustin Holewinski    if (is64Bit())
8149683f3c961379fbc088871a5d6304950f1f1cbcJustin Holewinski      p = "e-p:64:64:64-i1:8:8-i8:8:8-i16:16:16-i32:32:32-i64:64:64-"
8249683f3c961379fbc088871a5d6304950f1f1cbcJustin Holewinski          "f32:32:32-f64:64:64-v16:16:16-v32:32:32-v64:64:64-v128:128:128-"
8349683f3c961379fbc088871a5d6304950f1f1cbcJustin Holewinski          "n16:32:64";
8449683f3c961379fbc088871a5d6304950f1f1cbcJustin Holewinski    else
8549683f3c961379fbc088871a5d6304950f1f1cbcJustin Holewinski      p = "e-p:32:32:32-i1:8:8-i8:8:8-i16:16:16-i32:32:32-i64:64:64-"
8649683f3c961379fbc088871a5d6304950f1f1cbcJustin Holewinski          "f32:32:32-f64:64:64-v16:16:16-v32:32:32-v64:64:64-v128:128:128-"
8749683f3c961379fbc088871a5d6304950f1f1cbcJustin Holewinski          "n16:32:64";
8849683f3c961379fbc088871a5d6304950f1f1cbcJustin Holewinski
8949683f3c961379fbc088871a5d6304950f1f1cbcJustin Holewinski    return std::string(p);
9049683f3c961379fbc088871a5d6304950f1f1cbcJustin Holewinski  }
9149683f3c961379fbc088871a5d6304950f1f1cbcJustin Holewinski
9249683f3c961379fbc088871a5d6304950f1f1cbcJustin Holewinski};
9349683f3c961379fbc088871a5d6304950f1f1cbcJustin Holewinski
9449683f3c961379fbc088871a5d6304950f1f1cbcJustin Holewinski} // End llvm namespace
9549683f3c961379fbc088871a5d6304950f1f1cbcJustin Holewinski
963639ce2575660a0e6938d2e84e8bd9a738fd7051Justin Holewinski#endif // NVPTXSUBTARGET_H
97