1 //===- AMDILSubtarget.cpp - AMDIL Subtarget Information -------------------===//
3 // The LLVM Compiler Infrastructure
5 // This file is distributed under the University of Illinois Open Source
6 // License. See LICENSE.TXT for details.
8 //==-----------------------------------------------------------------------===//
10 // This file implements the AMD IL specific subclass of TargetSubtarget.
12 //===----------------------------------------------------------------------===//
14 #include "AMDILSubtarget.h"
16 #include "AMDILDevices.h"
17 #include "AMDILUtilityFunctions.h"
18 #include "llvm/ADT/SmallVector.h"
19 #include "llvm/ADT/StringExtras.h"
20 #include "llvm/ADT/StringRef.h"
21 #include "llvm/MC/SubtargetFeature.h"
25 #define GET_SUBTARGETINFO_ENUM
26 #define GET_SUBTARGETINFO_CTOR
27 #define GET_SUBTARGETINFO_TARGET_DESC
28 #include "AMDGPUGenSubtargetInfo.inc"
30 AMDILSubtarget::AMDILSubtarget(llvm::StringRef TT
, llvm::StringRef CPU
, llvm::StringRef FS
) : AMDILGenSubtargetInfo( TT
, CPU
, FS
),
33 memset(CapsOverride
, 0, sizeof(*CapsOverride
)
34 * AMDILDeviceInfo::MaxNumberCapabilities
);
36 std::string GPU
= "rv770";
40 SmallVector
<StringRef
, DEFAULT_VEC_SLOTS
> Features
;
41 SplitString(FS
, Features
, ",");
45 std::string newFeatures
= "";
46 #if defined(_DEBUG) || defined(DEBUG)
49 for (size_t x
= 0; x
< Features
.size(); ++x
) {
50 if (Features
[x
].startswith("+mwgs")) {
51 SmallVector
<StringRef
, DEFAULT_VEC_SLOTS
> sizes
;
52 SplitString(Features
[x
], sizes
, "-");
53 size_t mDim
= ::atoi(sizes
[1].data());
57 for (size_t y
= 0; y
< mDim
; ++y
) {
58 mDefaultSize
[y
] = ::atoi(sizes
[y
+2].data());
60 #if defined(_DEBUG) || defined(DEBUG)
61 } else if (!Features
[x
].compare("test")) {
64 } else if (Features
[x
].startswith("+cal")) {
65 SmallVector
<StringRef
, DEFAULT_VEC_SLOTS
> version
;
66 SplitString(Features
[x
], version
, "=");
67 mVersion
= ::atoi(version
[1].data());
70 if (x
> 0) newFeatures
+= ',';
71 newFeatures
+= Features
[x
];
74 // If we don't have a version then set it to
75 // -1 which enables everything. This is for
78 mVersion
= (uint32_t)-1;
80 for (int x
= 0; x
< 3; ++x
) {
81 if (!mDefaultSize
[x
]) {
85 #if defined(_DEBUG) || defined(DEBUG)
90 ParseSubtargetFeatures(GPU
, newFeatures
);
91 #if defined(_DEBUG) || defined(DEBUG)
97 mDevice
= AMDILDeviceInfo::getDeviceFromName(mDevName
, this, mIs64bit
);
99 AMDILSubtarget::~AMDILSubtarget()
104 AMDILSubtarget::isOverride(AMDILDeviceInfo::Caps caps
) const
106 assert(caps
< AMDILDeviceInfo::MaxNumberCapabilities
&&
107 "Caps index is out of bounds!");
108 return CapsOverride
[caps
];
111 AMDILSubtarget::is64bit() const
116 AMDILSubtarget::isTargetELF() const
121 AMDILSubtarget::getDefaultSize(uint32_t dim
) const
126 return mDefaultSize
[dim
];
130 AMDILSubtarget::calVersion() const
136 AMDILSubtarget::getGlobalManager() const
141 AMDILSubtarget::setGlobalManager(AMDILGlobalManager
*gm
) const
147 AMDILSubtarget::getKernelManager() const
152 AMDILSubtarget::setKernelManager(AMDILKernelManager
*km
) const
157 AMDILSubtarget::getDataLayout() const
160 return std::string("e-p:32:32:32-i1:8:8-i8:8:8-i16:16:16"
161 "-i32:32:32-i64:64:64-f32:32:32-f64:64:64-f80:32:32"
162 "-v16:16:16-v24:32:32-v32:32:32-v48:64:64-v64:64:64"
163 "-v96:128:128-v128:128:128-v192:256:256-v256:256:256"
164 "-v512:512:512-v1024:1024:1024-v2048:2048:2048-a0:0:64");
166 return mDevice
->getDataLayout();
170 AMDILSubtarget::getDeviceName() const
175 AMDILSubtarget::device() const