@@ -37,33 +37,22 @@ 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, and can be populated with
41
- // getGlobalMetadataFromDevice/Image.
40
+ // / Both size and address may be absent (signified by 0/nullptr) , and can be
41
+ // / populated with getGlobalMetadataFromDevice/Image.
42
42
class GlobalTy {
43
43
// NOTE: Maybe we can have a pointer to the offload entry name instead of
44
44
// holding a private copy of the name as a std::string.
45
45
std::string Name;
46
- std::optional< uint32_t > Size;
47
- std::optional< void *> Ptr;
46
+ uint32_t Size;
47
+ void *Ptr;
48
48
49
49
public:
50
- GlobalTy (const std::string &Name) : Name(Name) {}
51
- GlobalTy (const std::string &Name, uint32_t Size) : Name(Name), Size(Size) {}
52
- GlobalTy (const std::string &Name, uint32_t Size, void *Ptr)
50
+ GlobalTy (const std::string &Name, uint32_t Size = 0 , void *Ptr = nullptr )
53
51
: Name(Name), Size(Size), Ptr(Ptr) {}
54
52
55
53
const std::string &getName () const { return Name; }
56
- uint32_t getSize () const {
57
- assert (hasSize () && " Size not initialised" );
58
- return *Size;
59
- }
60
- void *getPtr () const {
61
- assert (hasPtr () && " Ptr not initialised" );
62
- return *Ptr;
63
- }
64
-
65
- bool hasSize () const { return Size.has_value (); }
66
- bool hasPtr () const { return Ptr.has_value (); }
54
+ uint32_t getSize () const { return Size; }
55
+ void *getPtr () const { return Ptr; }
67
56
68
57
void setSize (int32_t S) { Size = S; }
69
58
void setPtr (void *P) { Ptr = P; }
0 commit comments