clang
20.0.0git
lib
CodeGen
CodeGenTBAA.h
Go to the documentation of this file.
1
//===--- CodeGenTBAA.h - TBAA information for LLVM CodeGen ------*- C++ -*-===//
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 is the code that manages TBAA information and defines the TBAA policy
10
// for the optimizer to use.
11
//
12
//===----------------------------------------------------------------------===//
13
14
#ifndef LLVM_CLANG_LIB_CODEGEN_CODEGENTBAA_H
15
#define LLVM_CLANG_LIB_CODEGEN_CODEGENTBAA_H
16
17
#include "
clang/AST/Type.h
"
18
#include "
clang/Basic/LLVM.h
"
19
#include "llvm/ADT/DenseMap.h"
20
#include "llvm/IR/MDBuilder.h"
21
#include "llvm/IR/Metadata.h"
22
23
namespace
clang
{
24
class
ASTContext;
25
class
CodeGenOptions;
26
class
LangOptions;
27
class
MangleContext;
28
class
QualType;
29
class
Type
;
30
31
namespace
CodeGen {
32
class
CodeGenTypes;
33
34
// TBAAAccessKind - A kind of TBAA memory access descriptor.
35
enum class
TBAAAccessKind
:
unsigned
{
36
Ordinary
,
37
MayAlias
,
38
Incomplete
,
39
};
40
41
// TBAAAccessInfo - Describes a memory access in terms of TBAA.
42
struct
TBAAAccessInfo
{
43
TBAAAccessInfo
(
TBAAAccessKind
Kind
, llvm::MDNode *
BaseType
,
44
llvm::MDNode *
AccessType
, uint64_t
Offset
, uint64_t
Size
)
45
:
Kind
(
Kind
),
BaseType
(
BaseType
),
AccessType
(
AccessType
),
46
Offset
(
Offset
),
Size
(
Size
)
47
{}
48
49
TBAAAccessInfo
(llvm::MDNode *
BaseType
, llvm::MDNode *
AccessType
,
50
uint64_t
Offset
, uint64_t
Size
)
51
:
TBAAAccessInfo
(
TBAAAccessKind
::
Ordinary
,
BaseType
,
AccessType
,
52
Offset
,
Size
)
53
{}
54
55
explicit
TBAAAccessInfo
(llvm::MDNode *
AccessType
, uint64_t
Size
)
56
:
TBAAAccessInfo
(
/* BaseType= */
nullptr,
AccessType
,
/* Offset= */
0,
Size
)
57
{}
58
59
TBAAAccessInfo
()
60
:
TBAAAccessInfo
(
/* AccessType= */
nullptr,
/* Size= */
0)
61
{}
62
63
static
TBAAAccessInfo
getMayAliasInfo
() {
64
return
TBAAAccessInfo
(
TBAAAccessKind::MayAlias
,
65
/* BaseType= */
nullptr
,
/* AccessType= */
nullptr
,
66
/* Offset= */
0,
/* Size= */
0);
67
}
68
69
bool
isMayAlias
()
const
{
return
Kind
==
TBAAAccessKind::MayAlias
; }
70
71
static
TBAAAccessInfo
getIncompleteInfo
() {
72
return
TBAAAccessInfo
(
TBAAAccessKind::Incomplete
,
73
/* BaseType= */
nullptr
,
/* AccessType= */
nullptr
,
74
/* Offset= */
0,
/* Size= */
0);
75
}
76
77
bool
isIncomplete
()
const
{
return
Kind
==
TBAAAccessKind::Incomplete
; }
78
79
bool
operator==
(
const
TBAAAccessInfo
&
Other
)
const
{
80
return
Kind
==
Other
.Kind &&
81