LLVM API Documentation

Comdat.h
Go to the documentation of this file.
00001 //===-- llvm/IR/Comdat.h - Comdat definitions -------------------*- C++ -*-===//
00002 //
00003 //                     The LLVM Compiler Infrastructure
00004 //
00005 // This file is distributed under the University of Illinois Open Source
00006 // License. See LICENSE.TXT for details.
00007 //
00008 //===----------------------------------------------------------------------===//
00009 //
00010 /// @file
00011 /// This file contains the declaration of the Comdat class, which represents a
00012 /// single COMDAT in LLVM.
00013 //
00014 //===----------------------------------------------------------------------===//
00015 
00016 #ifndef LLVM_IR_COMDAT_H
00017 #define LLVM_IR_COMDAT_H
00018 
00019 #include "llvm/ADT/StringRef.h"
00020 #include "llvm/Support/Compiler.h"
00021 
00022 namespace llvm {
00023 
00024 class raw_ostream;
00025 template <typename ValueTy> class StringMapEntry;
00026 
00027 // This is a Name X SelectionKind pair. The reason for having this be an
00028 // independent object instead of just adding the name and the SelectionKind
00029 // to a GlobalObject is that it is invalid to have two Comdats with the same
00030 // name but different SelectionKind. This structure makes that unrepresentable.
00031 class Comdat {
00032 public:
00033   enum SelectionKind {
00034     Any,          ///< The linker may choose any COMDAT.
00035     ExactMatch,   ///< The data referenced by the COMDAT must be the same.
00036     Largest,      ///< The linker will choose the largest COMDAT.
00037     NoDuplicates, ///< No other Module may specify this COMDAT.
00038     SameSize,     ///< The data referenced by the COMDAT must be the same size.
00039   };
00040 
00041   Comdat(Comdat &&C);
00042   SelectionKind getSelectionKind() const { return SK; }
00043   void setSelectionKind(SelectionKind Val) { SK = Val; }
00044   StringRef getName() const;
00045   void print(raw_ostream &OS) const;
00046   void dump() const;
00047 
00048 private:
00049   friend class Module;
00050   Comdat();
00051   Comdat(SelectionKind SK, StringMapEntry<Comdat> *Name);
00052   Comdat(const Comdat &) LLVM_DELETED_FUNCTION;
00053 
00054   // Points to the map in Module.
00055   StringMapEntry<Comdat> *Name;
00056   SelectionKind SK;
00057 };
00058 
00059 inline raw_ostream &operator<<(raw_ostream &OS, const Comdat &C) {
00060   C.print(OS);
00061   return OS;
00062 }
00063 
00064 } // end llvm namespace
00065 
00066 #endif