LLVM
8.0.1
lib
Transforms
ObjCARC
ARCRuntimeEntryPoints.h
Go to the documentation of this file.
1
//===- ARCRuntimeEntryPoints.h - ObjC ARC Optimization ----------*- 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 a class ARCRuntimeEntryPoints for use in
12
/// creating/managing references to entry points to the arc objective c runtime.
13
///
14
/// WARNING: This file knows about certain library functions. It recognizes them
15
/// by name, and hardwires knowledge of their semantics.
16
///
17
/// WARNING: This file knows about how certain Objective-C library functions are
18
/// used. Naive LLVM IR transformations which would otherwise be
19
/// behavior-preserving may break these assumptions.
20
//
21
//===----------------------------------------------------------------------===//
22
23
#ifndef LLVM_LIB_TRANSFORMS_OBJCARC_ARCRUNTIMEENTRYPOINTS_H
24
#define LLVM_LIB_TRANSFORMS_OBJCARC_ARCRUNTIMEENTRYPOINTS_H
25
26
#include "
llvm/ADT/StringRef.h
"
27
#include "
llvm/IR/Attributes.h
"
28
#include "
llvm/IR/DerivedTypes.h
"
29
#include "
llvm/IR/Intrinsics.h
"
30
#include "
llvm/IR/Module.h
"
31
#include "
llvm/IR/Type.h
"
32
#include "
llvm/Support/ErrorHandling.h
"
33
#include <cassert>
34
35
namespace
llvm
{
36
37
class
Constant
;
38
class
LLVMContext;
39
40
namespace
objcarc {
41
42
enum class
ARCRuntimeEntryPointKind
{
43
AutoreleaseRV
,
44
Release
,
45
Retain
,
46
RetainBlock
,
47
Autorelease
,
48
StoreStrong
,
49
RetainRV
,
50
RetainAutorelease
,
51
RetainAutoreleaseRV
,
52
};
53
54
/// Declarations for ObjC runtime functions and constants. These are initialized
55
/// lazily to avoid cluttering up the Module with unused declarations.
56
class
ARCRuntimeEntryPoints
{
57
public
:
58
ARCRuntimeEntryPoints
() =
default
;
59
60
void
init
(
Module
*M) {
61
TheModule = M;
62
AutoreleaseRV
=
nullptr
;
63
Release
=
nullptr
;
64
Retain
=
nullptr
;
65
RetainBlock
=
nullptr
;
66
Autorelease
=
nullptr
;
67
StoreStrong
=
nullptr
;
68
RetainRV
=
nullptr
;
69
RetainAutorelease
=
nullptr
;
70
RetainAutoreleaseRV
=
nullptr
;
71
}
72
73
Constant
*
get
(
ARCRuntimeEntryPointKind
kind) {
74
assert
(TheModule !=
nullptr
&&
"Not initialized."
);
75
76
switch
(kind) {
77
case
ARCRuntimeEntryPointKind::AutoreleaseRV
:
78
return
getIntrinsicEntryPoint(
AutoreleaseRV
,
79
Intrinsic::objc_autoreleaseReturnValue
);
80
case
ARCRuntimeEntryPointKind::Release
:
81
return
getIntrinsicEntryPoint(
Release
,
Intrinsic::objc_release
);
82
case
ARCRuntimeEntryPointKind::Retain
:
83
return
getIntrinsicEntryPoint(
Retain
,
Intrinsic::objc_retain
);
84
case
ARCRuntimeEntryPointKind::RetainBlock
:
85
return
getIntrinsicEntryPoint(
RetainBlock
,
Intrinsic::objc_retainBlock
);
86
case
ARCRuntimeEntryPointKind::Autorelease
:
87
return
getIntrinsicEntryPoint(
Autorelease
,
Intrinsic::objc_autorelease
);
88
case
ARCRuntimeEntryPointKind::StoreStrong
:
89
return
getIntrinsicEntryPoint(
StoreStrong
,
Intrinsic::objc_storeStrong
);
90
case
ARCRuntimeEntryPointKind::RetainRV
:
91
return
getIntrinsicEntryPoint(
RetainRV
,
92
Intrinsic::objc_retainAutoreleasedReturnValue
);
93
case
ARCRuntimeEntryPointKind::RetainAutorelease
:
94
return
getIntrinsicEntryPoint(
RetainAutorelease
,
95
Intrinsic::objc_retainAutorelease
);
96
case
ARCRuntimeEntryPointKind::RetainAutoreleaseRV
:
97
return
getIntrinsicEntryPoint(
RetainAutoreleaseRV
,
98
Intrinsic::objc_retainAutoreleaseReturnValue
);
99
}
100
101
llvm_unreachable
(
"Switch should be a covered switch."
);
102
}
103
104
private
:
105
/// Cached reference to the module which we will insert declarations into.
106
Module
*TheModule =
nullptr
;
107
108
/// Declaration for ObjC runtime function objc_autoreleaseReturnValue.
109
Constant
*
AutoreleaseRV
=
nullptr
;
110
111
/// Declaration for ObjC runtime function objc_release.
112
Constant
*
Release
=
nullptr
;
113
114
/// Declaration for ObjC runtime function objc_retain.
115
Constant
*
Retain
=
nullptr
;
116
117
/// Declaration for ObjC runtime function objc_retainBlock.
118
Constant
*
RetainBlock
=
nullptr
;
119
120
/// Declaration for ObjC runtime function objc_autorelease.
121
Constant
*
Autorelease
=
nullptr
;
122
123
/// Declaration for objc_storeStrong().
124
Constant
*
StoreStrong
=
nullptr
;
125
126
/// Declaration for objc_retainAutoreleasedReturnValue().
127
Constant
*
RetainRV
=
nullptr
;
128
129
/// Declaration for objc_retainAutorelease().
130
Constant
*
RetainAutorelease
=
nullptr
;
131
132
/// Declaration for objc_retainAutoreleaseReturnValue().
133
Constant
*
RetainAutoreleaseRV
=
nullptr
;
134
135
Constant
*getIntrinsicEntryPoint(
Constant
*&Decl,
Intrinsic::ID
IntID) {
136
if
(Decl)
137
return
Decl;
138
139
return
Decl =
Intrinsic::getDeclaration
(TheModule, IntID);
140
}
141
};
142
143
}
// end namespace objcarc
144
145
}
// end namespace llvm
146
147
#endif // LLVM_LIB_TRANSFORMS_OBJCARC_ARCRUNTIMEENTRYPOINTS_H
llvm::objcarc::ARCRuntimeEntryPointKind::RetainAutoreleaseRV
llvm::Intrinsic::objc_retainAutorelease
Definition:
Intrinsics.h:229
llvm
This class represents lattice values for constants.
Definition:
AllocatorList.h:24
DerivedTypes.h
llvm::Module
A Module instance is used to store all the information related to an LLVM module. ...
Definition:
Module.h:65
Type.h
llvm::Intrinsic::objc_autorelease
Definition:
Intrinsics.h:215
llvm::Intrinsic::objc_release
Definition:
Intrinsics.h:226
llvm::Intrinsic::objc_retainAutoreleaseReturnValue
Definition:
Intrinsics.h:230
llvm::objcarc::ARCRuntimeEntryPointKind::RetainRV
llvm::objcarc::ARCRuntimeEntryPointKind::Autorelease
Attributes.h
This file contains the simple types necessary to represent the attributes associated with functions a...
llvm::Intrinsic::ID
ID
Definition:
Intrinsics.h:37
llvm::Intrinsic::getDeclaration
Function * getDeclaration(Module *M, ID id, ArrayRef< Type *> Tys=None)
Create or insert an LLVM Function declaration for an intrinsic, and return it.
Definition:
Function.cpp:1020
llvm::objcarc::ARCRuntimeEntryPointKind::Release
llvm::objcarc::ARCRuntimeEntryPointKind::AutoreleaseRV
llvm::objcarc::ARCRuntimeEntryPointKind::RetainBlock
llvm::Intrinsic::objc_retain
Definition:
Intrinsics.h:227
llvm::Constant
This is an important base class in LLVM.
Definition:
Constant.h:42
llvm::objcarc::ARCRuntimeEntryPointKind::RetainAutorelease
llvm_unreachable
#define llvm_unreachable(msg)
Marks that the current location is not supposed to be reachable.
Definition:
ErrorHandling.h:136
StringRef.h
Module.h
Module.h This file contains the declarations for the Module class.
ErrorHandling.h
llvm::objcarc::ARCRuntimeEntryPointKind::Retain
Intrinsics.h
llvm::Intrinsic::objc_storeStrong
Definition:
Intrinsics.h:234
llvm::objcarc::ARCRuntimeEntryPoints
Declarations for ObjC runtime functions and constants.
Definition:
ARCRuntimeEntryPoints.h:56
llvm::Intrinsic::objc_retainBlock
Definition:
Intrinsics.h:232
assert
assert(ImpDefSCC.getReg()==AMDGPU::SCC &&ImpDefSCC.isDef())
llvm::objcarc::ARCRuntimeEntryPoints::init
void init(Module *M)
Definition:
ARCRuntimeEntryPoints.h:60
llvm::Intrinsic::objc_retainAutoreleasedReturnValue
Definition:
Intrinsics.h:231
llvm::objcarc::ARCRuntimeEntryPointKind
ARCRuntimeEntryPointKind
Definition:
ARCRuntimeEntryPoints.h:42
llvm::objcarc::ARCRuntimeEntryPointKind::StoreStrong
llvm::ISD::Constant
Definition:
ISDOpcodes.h:61
llvm::Intrinsic::objc_autoreleaseReturnValue
Definition:
Intrinsics.h:218
Generated on Sun Dec 20 2020 13:58:50 for LLVM by
1.8.13