2017-02-17 01:00:09 +01:00
|
|
|
//===- llvm/IR/Comdat.h - Comdat definitions --------------------*- C++ -*-===//
|
2014-06-27 20:19:56 +02:00
|
|
|
//
|
2019-01-19 09:50:56 +01:00
|
|
|
// Part of the LLVM Project, under the Apache License v2.0 with LLVM Exceptions.
|
|
|
|
// See https://llvm.org/LICENSE.txt for license information.
|
|
|
|
// SPDX-License-Identifier: Apache-2.0 WITH LLVM-exception
|
2014-06-27 20:19:56 +02:00
|
|
|
//
|
|
|
|
//===----------------------------------------------------------------------===//
|
|
|
|
//
|
|
|
|
/// @file
|
|
|
|
/// This file contains the declaration of the Comdat class, which represents a
|
|
|
|
/// single COMDAT in LLVM.
|
|
|
|
//
|
|
|
|
//===----------------------------------------------------------------------===//
|
|
|
|
|
|
|
|
#ifndef LLVM_IR_COMDAT_H
|
|
|
|
#define LLVM_IR_COMDAT_H
|
|
|
|
|
2018-03-14 19:33:53 +01:00
|
|
|
#include "llvm-c/Types.h"
|
|
|
|
#include "llvm/Support/CBindingWrapping.h"
|
|
|
|
|
2014-06-27 20:19:56 +02:00
|
|
|
namespace llvm {
|
|
|
|
|
|
|
|
class raw_ostream;
|
2016-04-16 09:51:28 +02:00
|
|
|
class StringRef;
|
2014-06-27 20:19:56 +02:00
|
|
|
template <typename ValueTy> class StringMapEntry;
|
|
|
|
|
|
|
|
// This is a Name X SelectionKind pair. The reason for having this be an
|
|
|
|
// independent object instead of just adding the name and the SelectionKind
|
|
|
|
// to a GlobalObject is that it is invalid to have two Comdats with the same
|
|
|
|
// name but different SelectionKind. This structure makes that unrepresentable.
|
|
|
|
class Comdat {
|
|
|
|
public:
|
|
|
|
enum SelectionKind {
|
2021-07-20 21:47:10 +02:00
|
|
|
Any, ///< The linker may choose any COMDAT.
|
|
|
|
ExactMatch, ///< The data referenced by the COMDAT must be the same.
|
|
|
|
Largest, ///< The linker will choose the largest COMDAT.
|
|
|
|
NoDeduplicate, ///< No deduplication is performed.
|
|
|
|
SameSize, ///< The data referenced by the COMDAT must be the same size.
|
2014-06-27 20:19:56 +02:00
|
|
|
};
|
|
|
|
|
2016-12-06 23:00:57 +01:00
|
|
|
Comdat(const Comdat &) = delete;
|
2014-06-27 20:19:56 +02:00
|
|
|
Comdat(Comdat &&C);
|
2016-12-06 23:00:57 +01:00
|
|
|
|
2014-06-27 20:19:56 +02:00
|
|
|
SelectionKind getSelectionKind() const { return SK; }
|
|
|
|
void setSelectionKind(SelectionKind Val) { SK = Val; }
|
|
|
|
StringRef getName() const;
|
2015-09-28 00:38:50 +02:00
|
|
|
void print(raw_ostream &OS, bool IsForDebug = false) const;
|
2014-06-27 20:19:56 +02:00
|
|
|
void dump() const;
|
|
|
|
|
|
|
|
private:
|
|
|
|
friend class Module;
|
2016-12-06 23:00:57 +01:00
|
|
|
|
2014-06-27 20:19:56 +02:00
|
|
|
Comdat();
|
|
|
|
|
|
|
|
// Points to the map in Module.
|
2017-02-17 01:00:09 +01:00
|
|
|
StringMapEntry<Comdat> *Name = nullptr;
|
|
|
|
SelectionKind SK = Any;
|
2014-06-27 20:19:56 +02:00
|
|
|
};
|
|
|
|
|
2018-03-14 19:33:53 +01:00
|
|
|
// Create wrappers for C Binding types (see CBindingWrapping.h).
|
|
|
|
DEFINE_SIMPLE_CONVERSION_FUNCTIONS(Comdat, LLVMComdatRef)
|
|
|
|
|
2014-06-27 20:19:56 +02:00
|
|
|
inline raw_ostream &operator<<(raw_ostream &OS, const Comdat &C) {
|
|
|
|
C.print(OS);
|
|
|
|
return OS;
|
|
|
|
}
|
|
|
|
|
2016-12-06 23:00:57 +01:00
|
|
|
} // end namespace llvm
|
2014-06-27 20:19:56 +02:00
|
|
|
|
2016-12-06 23:00:57 +01:00
|
|
|
#endif // LLVM_IR_COMDAT_H
|