LLVM  3.7.0
Comdat.h
Go to the documentation of this file.
1 //===-- llvm/IR/Comdat.h - Comdat definitions -------------------*- C++ -*-===//
2 //
3 // The LLVM Compiler Infrastructure
4 //
5 // This file is distributed under the University of Illinois Open Source
6 // License. See LICENSE.TXT for details.
7 //
8 //===----------------------------------------------------------------------===//
9 //
10 /// @file
11 /// This file contains the declaration of the Comdat class, which represents a
12 /// single COMDAT in LLVM.
13 //
14 //===----------------------------------------------------------------------===//
15 
16 #ifndef LLVM_IR_COMDAT_H
17 #define LLVM_IR_COMDAT_H
18 
19 #include "llvm/ADT/StringRef.h"
20 #include "llvm/Support/Compiler.h"
21 
22 namespace llvm {
23 
24 class raw_ostream;
25 template <typename ValueTy> class StringMapEntry;
26 
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.
31 class Comdat {
32 public:
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.
39  };
40 
41  Comdat(Comdat &&C);
42  SelectionKind getSelectionKind() const { return SK; }
43  void setSelectionKind(SelectionKind Val) { SK = Val; }
44  StringRef getName() const;
45  void print(raw_ostream &OS) const;
46  void dump() const;
47 
48 private:
49  friend class Module;
50  Comdat();
52  Comdat(const Comdat &) = delete;
53 
54  // Points to the map in Module.
56  SelectionKind SK;
57 };
58 
59 inline raw_ostream &operator<<(raw_ostream &OS, const Comdat &C) {
60  C.print(OS);
61  return OS;
62 }
63 
64 } // end llvm namespace
65 
66 #endif
StringMapEntry - This is used to represent one value that is inserted into a StringMap.
Definition: StringMap.h:28
A Module instance is used to store all the information related to an LLVM module. ...
Definition: Module.h:114
The data referenced by the COMDAT must be the same size.
Definition: Comdat.h:38
The linker may choose any COMDAT.
Definition: Comdat.h:34
StringRef getName() const
Definition: Comdat.cpp:25
No other Module may specify this COMDAT.
Definition: Comdat.h:37
void print(raw_ostream &OS) const
Definition: AsmWriter.cpp:3161
SelectionKind getSelectionKind() const
Definition: Comdat.h:42
The data referenced by the COMDAT must be the same.
Definition: Comdat.h:35
void setSelectionKind(SelectionKind Val)
Definition: Comdat.h:43
The linker will choose the largest COMDAT.
Definition: Comdat.h:36
raw_ostream & operator<<(raw_ostream &OS, const APInt &I)
Definition: APInt.h:1738
void dump() const
Definition: AsmWriter.cpp:3365
This class implements an extremely fast bulk output stream that can only output to a stream...
Definition: raw_ostream.h:38
C - The default llvm calling convention, compatible with C.
Definition: CallingConv.h:34
StringRef - Represent a constant reference to a string, i.e.
Definition: StringRef.h:40