| 1 |
|
| 2 |
|
| 3 |
|
| 4 |
|
| 5 |
|
| 6 |
|
| 7 |
|
| 8 |
|
| 9 |
|
| 10 |
|
| 11 |
|
| 12 |
|
| 13 |
|
| 14 |
|
| 15 |
#ifndef LLVM_IR_COMDAT_H |
| 16 |
#define LLVM_IR_COMDAT_H |
| 17 |
|
| 18 |
#include "llvm-c/Types.h" |
| 19 |
#include "llvm/ADT/SmallPtrSet.h" |
| 20 |
#include "llvm/Support/CBindingWrapping.h" |
| 21 |
|
| 22 |
namespace llvm { |
| 23 |
|
| 24 |
class GlobalObject; |
| 25 |
class raw_ostream; |
| 26 |
class StringRef; |
| 27 |
template <typename ValueTy> class StringMapEntry; |
| 28 |
|
| 29 |
|
| 30 |
|
| 31 |
|
| 32 |
|
| 33 |
class Comdat { |
| 34 |
public: |
| 35 |
enum SelectionKind { |
| 36 |
Any, |
| 37 |
ExactMatch, |
| 38 |
Largest, |
| 39 |
NoDeduplicate, |
| 40 |
SameSize, |
| 41 |
}; |
| 42 |
|
| 43 |
Comdat(const Comdat &) = delete; |
| 44 |
Comdat(Comdat &&C); |
| 45 |
|
| 46 |
SelectionKind getSelectionKind() const { return SK; } |
| 47 |
void setSelectionKind(SelectionKind Val) { SK = Val; } |
| 48 |
StringRef getName() const; |
| 49 |
void print(raw_ostream &OS, bool IsForDebug = false) const; |
| 50 |
void dump() const; |
| 51 |
const SmallPtrSetImpl<GlobalObject *> &getUsers() const { return Users; } |
| 52 |
|
| 53 |
private: |
| 54 |
friend class Module; |
| 55 |
friend class GlobalObject; |
| 56 |
|
| 57 |
Comdat(); |
| 58 |
void addUser(GlobalObject *GO); |
| 59 |
void removeUser(GlobalObject *GO); |
| 60 |
|
| 61 |
|
| 62 |
StringMapEntry<Comdat> *Name = nullptr; |
| 63 |
SelectionKind SK = Any; |
| 64 |
|
| 65 |
SmallPtrSet<GlobalObject *, 2> Users; |
| 66 |
}; |
| 67 |
|
| 68 |
|
| 69 |
DEFINE_SIMPLE_CONVERSION_FUNCTIONS(Comdat, LLVMComdatRef) |
| 70 |
|
| 71 |
inline raw_ostream &operator<<(raw_ostream &OS, const Comdat &C) { |
| 72 |
C.print(OS); |
| 73 |
return OS; |
| 74 |
} |
| 75 |
|
| 76 |
} |
| 77 |
|
| 78 |
#endif |