blob: 8f2a629d229b57dfc19d81c54c96c91855ccea50 [file] [log] [blame]
Justin Holewinski49683f32012-05-04 20:18:50 +00001//=====-- NVPTXSubtarget.h - Define Subtarget for the NVPTX ---*- C++ -*--====//
2//
3// The LLVM Compiler Infrastructure
4//
5// This file is distributed under the University of Illinois Open Source
6// License. See LICENSE.TXT for details.
7//
8//===----------------------------------------------------------------------===//
9//
10// This file declares the NVPTX specific subclass of TargetSubtarget.
11//
12//===----------------------------------------------------------------------===//
13
14#ifndef NVPTXSUBTARGET_H
15#define NVPTXSUBTARGET_H
16
17#include "llvm/Target/TargetSubtargetInfo.h"
18#include "NVPTX.h"
19
20#define GET_SUBTARGETINFO_HEADER
21#include "NVPTXGenSubtargetInfo.inc"
22
23#include <string>
24
25namespace llvm {
26
27class NVPTXSubtarget : public NVPTXGenSubtargetInfo {
28
29 unsigned int SmVersion;
30 std::string TargetName;
31 NVPTX::DrvInterface drvInterface;
32 bool dummy; // For the 'dummy' feature, see NVPTX.td
33 bool Is64Bit;
34
35public:
36 /// This constructor initializes the data members to match that
37 /// of the specified module.
38 ///
39 NVPTXSubtarget(const std::string &TT, const std::string &CPU,
40 const std::string &FS, bool is64Bit);
41
42 bool hasBrkPt() const { return SmVersion >= 11; }
43 bool hasAtomRedG32() const { return SmVersion >= 11; }
44 bool hasAtomRedS32() const { return SmVersion >= 12; }
45 bool hasAtomRedG64() const { return SmVersion >= 12; }
46 bool hasAtomRedS64() const { return SmVersion >= 20; }
47 bool hasAtomRedGen32() const { return SmVersion >= 20; }
48 bool hasAtomRedGen64() const { return SmVersion >= 20; }
49 bool hasAtomAddF32() const { return SmVersion >= 20; }
50 bool hasVote() const { return SmVersion >= 12; }
51 bool hasDouble() const { return SmVersion >= 13; }
52 bool reqPTX20() const { return SmVersion >= 20; }
53 bool hasF32FTZ() const { return SmVersion >= 20; }
54 bool hasFMAF32() const { return SmVersion >= 20; }
55 bool hasFMAF64() const { return SmVersion >= 13; }
56 bool hasLDU() const { return SmVersion >= 20; }
57 bool hasGenericLdSt() const { return SmVersion >= 20; }
58 inline bool hasHWROT32() const { return false; }
59 inline bool hasSWROT32() const {
60 return true;
61 }
62 inline bool hasROT32() const { return hasHWROT32() || hasSWROT32() ; }
63 inline bool hasROT64() const { return SmVersion >= 20; }
64
65
66 bool is64Bit() const { return Is64Bit; }
67
68 unsigned int getSmVersion() const { return SmVersion; }
69 NVPTX::DrvInterface getDrvInterface() const { return drvInterface; }
70 std::string getTargetName() const { return TargetName; }
71
72 void ParseSubtargetFeatures(StringRef CPU, StringRef FS);
73
74 std::string getDataLayout() const {
75 const char *p;
76 if (is64Bit())
77 p = "e-p:64:64:64-i1:8:8-i8:8:8-i16:16:16-i32:32:32-i64:64:64-"
78 "f32:32:32-f64:64:64-v16:16:16-v32:32:32-v64:64:64-v128:128:128-"
79 "n16:32:64";
80 else
81 p = "e-p:32:32:32-i1:8:8-i8:8:8-i16:16:16-i32:32:32-i64:64:64-"
82 "f32:32:32-f64:64:64-v16:16:16-v32:32:32-v64:64:64-v128:128:128-"
83 "n16:32:64";
84
85 return std::string(p);
86 }
87
88};
89
90} // End llvm namespace
91
92#endif // NVPTXSUBTARGET_H