AMDILDevice.h revision a75c6163e605f35b14f26930dd9227e4f337ec9e
1//===---- AMDILDevice.h - Define Device Data for AMDIL -----*- 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// Interface for the subtarget data classes. 11// 12//===----------------------------------------------------------------------===// 13// This file will define the interface that each generation needs to 14// implement in order to correctly answer queries on the capabilities of the 15// specific hardware. 16//===----------------------------------------------------------------------===// 17#ifndef _AMDILDEVICEIMPL_H_ 18#define _AMDILDEVICEIMPL_H_ 19#include "AMDIL.h" 20#include "llvm/ADT/BitVector.h" 21 22namespace llvm { 23 class AMDILSubtarget; 24 class AMDILAsmPrinter; 25 class AMDILIOExpansion; 26 class AMDILPointerManager; 27 class AsmPrinter; 28 class MCStreamer; 29//===----------------------------------------------------------------------===// 30// Interface for data that is specific to a single device 31//===----------------------------------------------------------------------===// 32class AMDILDevice { 33public: 34 AMDILDevice(AMDILSubtarget *ST); 35 virtual ~AMDILDevice(); 36 37 // Enum values for the various memory types. 38 enum { 39 RAW_UAV_ID = 0, 40 ARENA_UAV_ID = 1, 41 LDS_ID = 2, 42 GDS_ID = 3, 43 SCRATCH_ID = 4, 44 CONSTANT_ID = 5, 45 GLOBAL_ID = 6, 46 MAX_IDS = 7 47 } IO_TYPE_IDS; 48 49 // Returns the max LDS size that the hardware supports. Size is in 50 // bytes. 51 virtual size_t getMaxLDSSize() const = 0; 52 53 // Returns the max GDS size that the hardware supports if the GDS is 54 // supported by the hardware. Size is in bytes. 55 virtual size_t getMaxGDSSize() const; 56 57 // Returns the max number of hardware constant address spaces that 58 // are supported by this device. 59 virtual size_t getMaxNumCBs() const; 60 61 // Returns the max number of bytes a single hardware constant buffer 62 // can support. Size is in bytes. 63 virtual size_t getMaxCBSize() const; 64 65 // Returns the max number of bytes allowed by the hardware scratch 66 // buffer. Size is in bytes. 67 virtual size_t getMaxScratchSize() const; 68 69 // Get the flag that corresponds to the device. 70 virtual uint32_t getDeviceFlag() const; 71 72 // Returns the number of work-items that exist in a single hardware 73 // wavefront. 74 virtual size_t getWavefrontSize() const = 0; 75 76 // Get the generational name of this specific device. 77 virtual uint32_t getGeneration() const = 0; 78 79 // Get the stack alignment of this specific device. 80 virtual uint32_t getStackAlignment() const; 81 82 // Get the resource ID for this specific device. 83 virtual uint32_t getResourceID(uint32_t DeviceID) const = 0; 84 85 // Get the max number of UAV's for this device. 86 virtual uint32_t getMaxNumUAVs() const = 0; 87 88 // Interface to get the IO Expansion pass for each device. 89 virtual FunctionPass* 90 getIOExpansion(TargetMachine& AMDIL_OPT_LEVEL_DECL) const = 0; 91 92 // Interface to get the Asm printer for each device. 93 virtual AsmPrinter* 94 getAsmPrinter(TargetMachine& TM, MCStreamer &Streamer) const = 0; 95 96 // Interface to get the Pointer manager pass for each device. 97 virtual FunctionPass* 98 getPointerManager(TargetMachine& AMDIL_OPT_LEVEL_DECL) const = 0; 99 100 101 // API utilizing more detailed capabilities of each family of 102 // cards. If a capability is supported, then either usesHardware or 103 // usesSoftware returned true. If usesHardware returned true, then 104 // usesSoftware must return false for the same capability. Hardware 105 // execution means that the feature is done natively by the hardware 106 // and is not emulated by the softare. Software execution means 107 // that the feature could be done in the hardware, but there is 108 // software that emulates it with possibly using the hardware for 109 // support since the hardware does not fully comply with OpenCL 110 // specs. 111 bool isSupported(AMDILDeviceInfo::Caps Mode) const; 112 bool usesHardware(AMDILDeviceInfo::Caps Mode) const; 113 bool usesSoftware(AMDILDeviceInfo::Caps Mode) const; 114 virtual std::string getDataLayout() const; 115 static const unsigned int MAX_LDS_SIZE_700 = 16384; 116 static const unsigned int MAX_LDS_SIZE_800 = 32768; 117 static const unsigned int WavefrontSize = 64; 118 static const unsigned int HalfWavefrontSize = 32; 119 static const unsigned int QuarterWavefrontSize = 16; 120protected: 121 virtual void setCaps(); 122 llvm::BitVector mHWBits; 123 llvm::BitVector mSWBits; 124 AMDILSubtarget *mSTM; 125 uint32_t mDeviceFlag; 126private: 127 AMDILDeviceInfo::ExecutionMode 128 getExecutionMode(AMDILDeviceInfo::Caps Caps) const; 129}; // AMDILDevice 130 131} // namespace llvm 132#endif // _AMDILDEVICEIMPL_H_ 133