LLVM  13.0.0git
Comdat.cpp
Go to the documentation of this file.
1 //===- Comdat.cpp - Implement Metadata classes ----------------------------===//
2 //
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
6 //
7 //===----------------------------------------------------------------------===//
8 //
9 // This file implements the Comdat class (including the C bindings).
10 //
11 //===----------------------------------------------------------------------===//
12 
13 #include "llvm-c/Comdat.h"
14 #include "llvm/ADT/StringMap.h"
15 #include "llvm/ADT/StringRef.h"
16 #include "llvm/IR/Comdat.h"
17 #include "llvm/IR/GlobalObject.h"
18 #include "llvm/IR/Module.h"
19 
20 using namespace llvm;
21 
22 Comdat::Comdat(Comdat &&C) : Name(C.Name), SK(C.SK) {}
23 
24 Comdat::Comdat() = default;
25 
26 StringRef Comdat::getName() const { return Name->first(); }
27 
29  return wrap(unwrap(M)->getOrInsertComdat(Name));
30 }
31 
33  GlobalObject *G = unwrap<GlobalObject>(V);
34  return wrap(G->getComdat());
35 }
36 
38  GlobalObject *G = unwrap<GlobalObject>(V);
39  G->setComdat(unwrap(C));
40 }
41 
43  switch (unwrap(C)->getSelectionKind()) {
44  case Comdat::Any:
46  case Comdat::ExactMatch:
48  case Comdat::Largest:
52  case Comdat::SameSize:
54  }
55  llvm_unreachable("Invalid Comdat SelectionKind!");
56 }
57 
59  Comdat *Cd = unwrap(C);
60  switch (kind) {
63  break;
66  break;
69  break;
72  break;
75  break;
76  }
77 }
llvm
Definition: AllocatorList.h:23
M
We currently emits eax Perhaps this is what we really should generate is Is imull three or four cycles eax eax The current instruction priority is based on pattern complexity The former is more complex because it folds a load so the latter will not be emitted Perhaps we should use AddedComplexity to give LEA32r a higher priority We should always try to match LEA first since the LEA matching code does some estimate to determine whether the match is profitable if we care more about code then imull is better It s two bytes shorter than movl leal On a Pentium M
Definition: README.txt:252
Comdat.h
llvm::Comdat::getName
StringRef getName() const
Definition: Comdat.cpp:26
llvm::Comdat::NoDuplicates
@ NoDuplicates
No other Module may specify this COMDAT.
Definition: Comdat.h:37
llvm::Comdat::ExactMatch
@ ExactMatch
The data referenced by the COMDAT must be the same.
Definition: Comdat.h:35
StringRef.h
LLVMSetComdat
void LLVMSetComdat(LLVMValueRef V, LLVMComdatRef C)
Assign the Comdat to the given global object.
Definition: Comdat.cpp:37
LLVMComdatSelectionKind
LLVMComdatSelectionKind
Definition: Comdat.h:22
Module.h
GlobalObject.h
llvm::Comdat::Largest
@ Largest
The linker will choose the largest COMDAT.
Definition: Comdat.h:36
LLVMLargestComdatSelectionKind
@ LLVMLargestComdatSelectionKind
The linker will choose the largest COMDAT.
Definition: Comdat.h:26
C
(vector float) vec_cmpeq(*A, *B) C
Definition: README_ALTIVEC.txt:86
llvm::GlobalObject
Definition: GlobalObject.h:28
LLVMNoDuplicatesComdatSelectionKind
@ LLVMNoDuplicatesComdatSelectionKind
No other Module may specify this COMDAT.
Definition: Comdat.h:28
llvm::Comdat::Any
@ Any
The linker may choose any COMDAT.
Definition: Comdat.h:34
llvm::unwrap
Attribute unwrap(LLVMAttributeRef Attr)
Definition: Attributes.h:244
llvm::Comdat::SameSize
@ SameSize
The data referenced by the COMDAT must be the same size.
Definition: Comdat.h:38
StringMap.h
llvm::Comdat
Definition: Comdat.h:31
LLVMGetComdatSelectionKind
LLVMComdatSelectionKind LLVMGetComdatSelectionKind(LLVMComdatRef C)
Definition: Comdat.cpp:42
G
const DataFlowGraph & G
Definition: RDFGraph.cpp:202
Comdat.h
LLVMSameSizeComdatSelectionKind
@ LLVMSameSizeComdatSelectionKind
The data referenced by the COMDAT must be the same size.
Definition: Comdat.h:30
LLVMSetComdatSelectionKind
void LLVMSetComdatSelectionKind(LLVMComdatRef C, LLVMComdatSelectionKind kind)
Definition: Comdat.cpp:58
llvm::wrap
LLVMAttributeRef wrap(Attribute Attr)
Definition: Attributes.h:239
llvm::StringRef
StringRef - Represent a constant reference to a string, i.e.
Definition: StringRef.h:58
LLVMExactMatchComdatSelectionKind
@ LLVMExactMatchComdatSelectionKind
The data referenced by the COMDAT must be the same.
Definition: Comdat.h:24
llvm_unreachable
#define llvm_unreachable(msg)
Marks that the current location is not supposed to be reachable.
Definition: ErrorHandling.h:136
LLVMAnyComdatSelectionKind
@ LLVMAnyComdatSelectionKind
The linker may choose any COMDAT.
Definition: Comdat.h:23
llvm::GraphProgram::Name
Name
Definition: GraphWriter.h:52
llvm::Comdat::setSelectionKind
void setSelectionKind(SelectionKind Val)
Definition: Comdat.h:45
LLVMValueRef
struct LLVMOpaqueValue * LLVMValueRef
Represents an individual value in LLVM IR.
Definition: Types.h:75
LLVMGetOrInsertComdat
LLVMComdatRef LLVMGetOrInsertComdat(LLVMModuleRef M, const char *Name)
Return the Comdat in the module with the specified name.
Definition: Comdat.cpp:28
LLVMComdatRef
struct LLVMComdat * LLVMComdatRef
Definition: Types.h:153
LLVMGetComdat
LLVMComdatRef LLVMGetComdat(LLVMValueRef V)
Get the Comdat assigned to the given global object.
Definition: Comdat.cpp:32
LLVMModuleRef
struct LLVMOpaqueModule * LLVMModuleRef
The top-level container for all other LLVM Intermediate Representation (IR) objects.
Definition: Types.h:61