blob: b02822a099d97e0fbad333e89af57d4f6630e1ab [file] [log] [blame]
Justin Holewinskiae556d32012-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
Benjamin Kramera7c40ef2014-08-13 16:26:38 +000014#ifndef LLVM_LIB_TARGET_NVPTX_NVPTXSUBTARGET_H
15#define LLVM_LIB_TARGET_NVPTX_NVPTXSUBTARGET_H
Justin Holewinskiae556d32012-05-04 20:18:50 +000016
Justin Holewinskiae556d32012-05-04 20:18:50 +000017#include "NVPTX.h"
Eric Christopher493f91b2014-06-27 04:33:14 +000018#include "NVPTXFrameLowering.h"
19#include "NVPTXISelLowering.h"
20#include "NVPTXInstrInfo.h"
21#include "NVPTXRegisterInfo.h"
Benjamin Kramerf9172fd42016-01-27 16:32:26 +000022#include "llvm/CodeGen/SelectionDAGTargetInfo.h"
David Blaikieb3bde2e2017-11-17 01:07:10 +000023#include "llvm/CodeGen/TargetSubtargetInfo.h"
Eric Christopher493f91b2014-06-27 04:33:14 +000024#include "llvm/IR/DataLayout.h"
Chandler Carruthff555932014-04-22 02:28:45 +000025#include <string>
Justin Holewinskiae556d32012-05-04 20:18:50 +000026
27#define GET_SUBTARGETINFO_HEADER
28#include "NVPTXGenSubtargetInfo.inc"
29
Justin Holewinskiae556d32012-05-04 20:18:50 +000030namespace llvm {
31
32class NVPTXSubtarget : public NVPTXGenSubtargetInfo {
Juergen Ributzkad12ccbd2013-11-19 00:57:56 +000033 virtual void anchor();
Justin Holewinskiae556d32012-05-04 20:18:50 +000034 std::string TargetName;
Justin Holewinskiae556d32012-05-04 20:18:50 +000035
Justin Holewinski1812ee92012-11-12 03:16:43 +000036 // PTX version x.y is represented as 10*x+y, e.g. 3.1 == 31
37 unsigned PTXVersion;
38
39 // SM version x.y is represented as 10*x+y, e.g. 3.1 == 31
40 unsigned int SmVersion;
41
Eric Christopher6aad8b12015-02-19 00:08:14 +000042 const NVPTXTargetMachine &TM;
Eric Christopher493f91b2014-06-27 04:33:14 +000043 NVPTXInstrInfo InstrInfo;
44 NVPTXTargetLowering TLInfo;
Benjamin Kramerf9172fd42016-01-27 16:32:26 +000045 SelectionDAGTargetInfo TSInfo;
Eric Christopher493f91b2014-06-27 04:33:14 +000046
47 // NVPTX does not have any call stack frame, but need a NVPTX specific
48 // FrameLowering class because TargetFrameLowering is abstract.
49 NVPTXFrameLowering FrameLowering;
50
Justin Holewinskiae556d32012-05-04 20:18:50 +000051public:
52 /// This constructor initializes the data members to match that
53 /// of the specified module.
54 ///
Daniel Sandersa73f1fd2015-06-10 12:11:26 +000055 NVPTXSubtarget(const Triple &TT, const std::string &CPU,
Eric Christopher02389e32015-02-19 00:08:27 +000056 const std::string &FS, const NVPTXTargetMachine &TM);
Eric Christopher493f91b2014-06-27 04:33:14 +000057
Eric Christopherd9134482014-08-04 21:25:23 +000058 const TargetFrameLowering *getFrameLowering() const override {
59 return &FrameLowering;
60 }
61 const NVPTXInstrInfo *getInstrInfo() const override { return &InstrInfo; }
Eric Christopherd9134482014-08-04 21:25:23 +000062 const NVPTXRegisterInfo *getRegisterInfo() const override {
Eric Christopher493f91b2014-06-27 04:33:14 +000063 return &InstrInfo.getRegisterInfo();
64 }
Eric Christopherd9134482014-08-04 21:25:23 +000065 const NVPTXTargetLowering *getTargetLowering() const override {
66 return &TLInfo;
67 }
Benjamin Kramerf9172fd42016-01-27 16:32:26 +000068 const SelectionDAGTargetInfo *getSelectionDAGInfo() const override {
Eric Christopherd9134482014-08-04 21:25:23 +000069 return &TSInfo;
70 }
Justin Holewinskiae556d32012-05-04 20:18:50 +000071
Artem Belevich3e121152016-09-28 17:25:38 +000072 bool hasAtomAddF64() const { return SmVersion >= 60; }
Artem Belevich24e8a682018-04-11 17:51:19 +000073 bool hasAtomScope() const { return SmVersion >= 60; }
Artem Belevich3e121152016-09-28 17:25:38 +000074 bool hasAtomBitwise64() const { return SmVersion >= 32; }
75 bool hasAtomMinMax64() const { return SmVersion >= 32; }
Justin Holewinskibe8dc642013-02-12 14:18:49 +000076 bool hasLDG() const { return SmVersion >= 32; }
Justin Holewinskic3f31eb2014-06-27 18:35:16 +000077 inline bool hasHWROT32() const { return SmVersion >= 32; }
Eric Christopherbeffc4e2015-02-19 00:08:23 +000078 bool hasImageHandles() const;
Artem Belevich64dc9be2017-01-13 20:56:17 +000079 bool hasFP16Math() const { return SmVersion >= 53; }
80 bool allowFP16Math() const;
Justin Holewinskiae556d32012-05-04 20:18:50 +000081 unsigned int getSmVersion() const { return SmVersion; }
Justin Holewinskiae556d32012-05-04 20:18:50 +000082 std::string getTargetName() const { return TargetName; }
83
Justin Holewinski1812ee92012-11-12 03:16:43 +000084 unsigned getPTXVersion() const { return PTXVersion; }
85
Eric Christopher493f91b2014-06-27 04:33:14 +000086 NVPTXSubtarget &initializeSubtargetDependencies(StringRef CPU, StringRef FS);
Justin Holewinskiae556d32012-05-04 20:18:50 +000087 void ParseSubtargetFeatures(StringRef CPU, StringRef FS);
Justin Holewinskiae556d32012-05-04 20:18:50 +000088};
89
Alexander Kornienkof00654e2015-06-23 09:49:53 +000090} // End llvm namespace
Justin Holewinskiae556d32012-05-04 20:18:50 +000091
Benjamin Kramera7c40ef2014-08-13 16:26:38 +000092#endif