@@ -37,6 +37,8 @@ using namespace llvm::object;
37
37
// / Common abstraction for globals that live on the host and device.
38
38
// / It simply encapsulates the symbol name, symbol size, and symbol address
39
39
// / (which might be host or device depending on the context).
40
+ // / Both size and address may be absent (signified by 0/nullptr), and can be
41
+ // / populated with getGlobalMetadataFromDevice/Image.
40
42
class GlobalTy {
41
43
// NOTE: Maybe we can have a pointer to the offload entry name instead of
42
44
// holding a private copy of the name as a std::string.
@@ -45,7 +47,7 @@ class GlobalTy {
45
47
void *Ptr;
46
48
47
49
public:
48
- GlobalTy (const std::string &Name, uint32_t Size, void *Ptr = nullptr )
50
+ GlobalTy (const std::string &Name, uint32_t Size = 0 , void *Ptr = nullptr )
49
51
: Name(Name), Size(Size), Ptr(Ptr) {}
50
52
51
53
const std::string &getName () const { return Name; }
@@ -139,8 +141,11 @@ class GenericGlobalHandlerTy {
139
141
bool isSymbolInImage (GenericDeviceTy &Device, DeviceImageTy &Image,
140
142
StringRef SymName);
141
143
142
- // / Get the address and size of a global in the image. Address and size are
143
- // / return in \p ImageGlobal, the global name is passed in \p ImageGlobal.
144
+ // / Get the address and size of a global in the image. Address is
145
+ // / returned in \p ImageGlobal and the global name is passed in \p
146
+ // / ImageGlobal. If no size is present in \p ImageGlobal, then the size of the
147
+ // / global will be stored there. If it is present, it will be validated
148
+ // / against the real size of the global.
144
149
Error getGlobalMetadataFromImage (GenericDeviceTy &Device,
145
150
DeviceImageTy &Image, GlobalTy &ImageGlobal);
146
151
@@ -149,9 +154,11 @@ class GenericGlobalHandlerTy {
149
154
Error readGlobalFromImage (GenericDeviceTy &Device, DeviceImageTy &Image,
150
155
const GlobalTy &HostGlobal);
151
156
152
- // / Get the address and size of a global from the device. Address is return in
153
- // / \p DeviceGlobal, the global name and expected size are passed in
154
- // / \p DeviceGlobal.
157
+ // / Get the address and size of a global from the device. Address is
158
+ // / returned in \p ImageGlobal and the global name is passed in \p
159
+ // / ImageGlobal. If no size is present in \p ImageGlobal, then the size of the
160
+ // / global will be stored there. If it is present, it will be validated
161
+ // / against the real size of the global.
155
162
virtual Error getGlobalMetadataFromDevice (GenericDeviceTy &Device,
156
163
DeviceImageTy &Image,
157
164
GlobalTy &DeviceGlobal) = 0;
0 commit comments