1 //===- llvm/IR/Comdat.h - Comdat definitions --------------------*- C++ -*-===//
3 // The LLVM Compiler Infrastructure
5 // This file is distributed under the University of Illinois Open Source
6 // License. See LICENSE.TXT for details.
8 //===----------------------------------------------------------------------===//
11 /// This file contains the declaration of the Comdat class, which represents a
12 /// single COMDAT in LLVM.
14 //===----------------------------------------------------------------------===//
16 #ifndef LLVM_IR_COMDAT_H
17 #define LLVM_IR_COMDAT_H
19 #include "llvm-c/Types.h"
20 #include "llvm/Support/CBindingWrapping.h"
26 template <typename ValueTy> class StringMapEntry;
28 // This is a Name X SelectionKind pair. The reason for having this be an
29 // independent object instead of just adding the name and the SelectionKind
30 // to a GlobalObject is that it is invalid to have two Comdats with the same
31 // name but different SelectionKind. This structure makes that unrepresentable.
35 Any, ///< The linker may choose any COMDAT.
36 ExactMatch, ///< The data referenced by the COMDAT must be the same.
37 Largest, ///< The linker will choose the largest COMDAT.
38 NoDuplicates, ///< No other Module may specify this COMDAT.
39 SameSize, ///< The data referenced by the COMDAT must be the same size.
42 Comdat(const Comdat &) = delete;
45 SelectionKind getSelectionKind() const { return SK; }
46 void setSelectionKind(SelectionKind Val) { SK = Val; }
47 StringRef getName() const;
48 void print(raw_ostream &OS, bool IsForDebug = false) const;
56 // Points to the map in Module.
57 StringMapEntry<Comdat> *Name = nullptr;
58 SelectionKind SK = Any;
61 // Create wrappers for C Binding types (see CBindingWrapping.h).
62 DEFINE_SIMPLE_CONVERSION_FUNCTIONS(Comdat, LLVMComdatRef)
64 inline raw_ostream &operator<<(raw_ostream &OS, const Comdat &C) {
69 } // end namespace llvm
71 #endif // LLVM_IR_COMDAT_H