1 //===- llvm/IR/Comdat.h - Comdat definitions --------------------*- C++ -*-===//
3 // Part of the LLVM Project, under the Apache License v2.0 with LLVM Exceptions.
4 // See https://llvm.org/LICENSE.txt for license information.
5 // SPDX-License-Identifier: Apache-2.0 WITH LLVM-exception
7 //===----------------------------------------------------------------------===//
10 /// This file contains the declaration of the Comdat class, which represents a
11 /// single COMDAT in LLVM.
13 //===----------------------------------------------------------------------===//
15 #ifndef LLVM_IR_COMDAT_H
16 #define LLVM_IR_COMDAT_H
18 #include "llvm-c/Types.h"
19 #include "llvm/Support/CBindingWrapping.h"
25 template <typename ValueTy
> class StringMapEntry
;
27 // This is a Name X SelectionKind pair. The reason for having this be an
28 // independent object instead of just adding the name and the SelectionKind
29 // to a GlobalObject is that it is invalid to have two Comdats with the same
30 // name but different SelectionKind. This structure makes that unrepresentable.
34 Any
, ///< The linker may choose any COMDAT.
35 ExactMatch
, ///< The data referenced by the COMDAT must be the same.
36 Largest
, ///< The linker will choose the largest COMDAT.
37 NoDuplicates
, ///< No other Module may specify this COMDAT.
38 SameSize
, ///< The data referenced by the COMDAT must be the same size.
41 Comdat(const Comdat
&) = delete;
44 SelectionKind
getSelectionKind() const { return SK
; }
45 void setSelectionKind(SelectionKind Val
) { SK
= Val
; }
46 StringRef
getName() const;
47 void print(raw_ostream
&OS
, bool IsForDebug
= false) const;
55 // Points to the map in Module.
56 StringMapEntry
<Comdat
> *Name
= nullptr;
57 SelectionKind SK
= Any
;
60 // Create wrappers for C Binding types (see CBindingWrapping.h).
61 DEFINE_SIMPLE_CONVERSION_FUNCTIONS(Comdat
, LLVMComdatRef
)
63 inline raw_ostream
&operator<<(raw_ostream
&OS
, const Comdat
&C
) {
68 } // end namespace llvm
70 #endif // LLVM_IR_COMDAT_H