1 //===-- AMDILDeviceInfo.cpp - AMDILDeviceInfo class -----------------------===//
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 // Function that creates DeviceInfo from a device name and other information.
11 //
12 //==-----------------------------------------------------------------------===//
13 #include "AMDILDevices.h"
14 #include "AMDGPUSubtarget.h"
15 
16 using namespace llvm;
17 namespace llvm {
18 namespace AMDGPUDeviceInfo {
19     AMDGPUDevice*
getDeviceFromName(const std::string & deviceName,AMDGPUSubtarget * ptr,bool is64bit,bool is64on32bit)20 getDeviceFromName(const std::string &deviceName, AMDGPUSubtarget *ptr,
21                   bool is64bit, bool is64on32bit)
22 {
23     if (deviceName.c_str()[2] == '7') {
24         switch (deviceName.c_str()[3]) {
25             case '1':
26                 return new AMDGPU710Device(ptr);
27             case '7':
28                 return new AMDGPU770Device(ptr);
29             default:
30                 return new AMDGPU7XXDevice(ptr);
31         };
32     } else if (deviceName == "cypress") {
33 #if DEBUG
34       assert(!is64bit && "This device does not support 64bit pointers!");
35       assert(!is64on32bit && "This device does not support 64bit"
36           " on 32bit pointers!");
37 #endif
38         return new AMDGPUCypressDevice(ptr);
39     } else if (deviceName == "juniper") {
40 #if DEBUG
41       assert(!is64bit && "This device does not support 64bit pointers!");
42       assert(!is64on32bit && "This device does not support 64bit"
43           " on 32bit pointers!");
44 #endif
45         return new AMDGPUEvergreenDevice(ptr);
46     } else if (deviceName == "redwood") {
47 #if DEBUG
48       assert(!is64bit && "This device does not support 64bit pointers!");
49       assert(!is64on32bit && "This device does not support 64bit"
50           " on 32bit pointers!");
51 #endif
52       return new AMDGPURedwoodDevice(ptr);
53     } else if (deviceName == "cedar") {
54 #if DEBUG
55       assert(!is64bit && "This device does not support 64bit pointers!");
56       assert(!is64on32bit && "This device does not support 64bit"
57           " on 32bit pointers!");
58 #endif
59         return new AMDGPUCedarDevice(ptr);
60     } else if (deviceName == "barts"
61       || deviceName == "turks") {
62 #if DEBUG
63       assert(!is64bit && "This device does not support 64bit pointers!");
64       assert(!is64on32bit && "This device does not support 64bit"
65           " on 32bit pointers!");
66 #endif
67         return new AMDGPUNIDevice(ptr);
68     } else if (deviceName == "cayman") {
69 #if DEBUG
70       assert(!is64bit && "This device does not support 64bit pointers!");
71       assert(!is64on32bit && "This device does not support 64bit"
72           " on 32bit pointers!");
73 #endif
74         return new AMDGPUCaymanDevice(ptr);
75     } else if (deviceName == "caicos") {
76 #if DEBUG
77       assert(!is64bit && "This device does not support 64bit pointers!");
78       assert(!is64on32bit && "This device does not support 64bit"
79           " on 32bit pointers!");
80 #endif
81         return new AMDGPUNIDevice(ptr);
82     } else if (deviceName == "SI") {
83         return new AMDGPUSIDevice(ptr);
84     } else {
85 #if DEBUG
86       assert(!is64bit && "This device does not support 64bit pointers!");
87       assert(!is64on32bit && "This device does not support 64bit"
88           " on 32bit pointers!");
89 #endif
90         return new AMDGPU7XXDevice(ptr);
91     }
92 }
93 } // End namespace AMDGPUDeviceInfo
94 } // End namespace llvm
95