mirror of
https://github.com/c64scene-ar/llvm-6502.git
synced 2025-10-10 00:18:59 +00:00
[PM/AA] Hoist the AliasResult enum out of the AliasAnalysis class.
This will allow classes to implement the AA interface without deriving from the class or referencing an internal enum of some other class as their return types. Also, to a pretty fundamental extent, concepts such as 'NoAlias', 'MayAlias', and 'MustAlias' are first class concepts in LLVM and we aren't saving anything by scoping them heavily. My mild preference would have been to use a scoped enum, but that feature is essentially completely broken AFAICT. I'm extremely disappointed. For example, we cannot through any reasonable[1] means construct an enum class (or analog) which has scoped names but converts to a boolean in order to test for the possibility of aliasing. [1]: Richard Smith came up with a "solution", but it requires class templates, and lots of boilerplate setting up the enumeration multiple times. Something like Boost.PP could potentially bundle this up, but even that would be quite painful and it doesn't seem realistically worth it. The enum class solution would probably work without the need for a bool conversion. Differential Revision: http://reviews.llvm.org/D10495 git-svn-id: https://llvm.org/svn/llvm-project/llvm/trunk@240255 91177308-0d34-0410-b5e6-96231b3b80d8
This commit is contained in:
@@ -56,6 +56,34 @@ class MemTransferInst;
|
||||
class MemIntrinsic;
|
||||
class DominatorTree;
|
||||
|
||||
/// The possible results of an alias query.
|
||||
///
|
||||
/// These results are always computed between two MemoryLocation objects as
|
||||
/// a query to some alias analysis.
|
||||
///
|
||||
/// Note that these are unscoped enumerations because we would like to support
|
||||
/// implicitly testing a result for the existence of any possible aliasing with
|
||||
/// a conversion to bool, but an "enum class" doesn't support this. The
|
||||
/// canonical names from the literature are suffixed and unique anyways, and so
|
||||
/// they serve as global constants in LLVM for these results.
|
||||
///
|
||||
/// See docs/AliasAnalysis.html for more information on the specific meanings
|
||||
/// of these values.
|
||||
enum AliasResult {
|
||||
/// The two locations do not alias at all.
|
||||
///
|
||||
/// This value is arranged to convert to false, while all other values
|
||||
/// convert to true. This allows a boolean context to convert the result to
|
||||
/// a binary flag indicating whether there is the possibility of aliasing.
|
||||
NoAlias = 0,
|
||||
/// The two locations may or may not alias. This is the least precise result.
|
||||
MayAlias,
|
||||
/// The two locations alias, but only due to a partial overlap.
|
||||
PartialAlias,
|
||||
/// The two locations precisely alias each other.
|
||||
MustAlias,
|
||||
};
|
||||
|
||||
class AliasAnalysis {
|
||||
protected:
|
||||
const DataLayout *DL;
|
||||
@@ -95,22 +123,6 @@ public:
|
||||
/// Alias Queries...
|
||||
///
|
||||
|
||||
/// Alias analysis result - Either we know for sure that it does not alias, we
|
||||
/// know for sure it must alias, or we don't know anything: The two pointers
|
||||
/// _might_ alias. This enum is designed so you can do things like:
|
||||
/// if (AA.alias(P1, P2)) { ... }
|
||||
/// to check to see if two pointers might alias.
|
||||
///
|
||||
/// See docs/AliasAnalysis.html for more information on the specific meanings
|
||||
/// of these values.
|
||||
///
|
||||
enum AliasResult {
|
||||
NoAlias = 0, ///< No dependencies.
|
||||
MayAlias, ///< Anything goes.
|
||||
PartialAlias, ///< Pointers differ, but pointees overlap.
|
||||
MustAlias ///< Pointers are equal.
|
||||
};
|
||||
|
||||
/// alias - The main low level interface to the alias analysis implementation.
|
||||
/// Returns an AliasResult indicating whether the two pointers are aliased to
|
||||
/// each other. This is the interface that must be implemented by specific
|
||||
|
Reference in New Issue
Block a user