[llvm] 0cff3e8 - [NFC][Support] Move ModRef/MemoryEffects printers to their own file (#105367)
via llvm-commits
llvm-commits at lists.llvm.org
Wed Aug 21 04:26:37 PDT 2024
Author: Rahul Joshi
Date: 2024-08-21T04:26:34-07:00
New Revision: 0cff3e85db00b5f425cc4ed0d6921445afa891ca
URL: https://github.com/llvm/llvm-project/commit/0cff3e85db00b5f425cc4ed0d6921445afa891ca
DIFF: https://github.com/llvm/llvm-project/commit/0cff3e85db00b5f425cc4ed0d6921445afa891ca.diff
LOG: [NFC][Support] Move ModRef/MemoryEffects printers to their own file (#105367)
- Move raw_ostream << operators for `ModRef` and `MemoryEffects` to a
new ModRef.cpp file under llvm/Support (instead of AliasAnalysis.cpp)
- This enables calling these operators from `Core` files like
Instructions.cpp (for instance for debugging). Currently, they live in
`LLVMAnalysis` which cannot be linked with `Core`.
Added:
llvm/lib/Support/ModRef.cpp
Modified:
llvm/include/llvm/Support/ModRef.h
llvm/lib/Analysis/AliasAnalysis.cpp
llvm/lib/Support/CMakeLists.txt
Removed:
################################################################################
diff --git a/llvm/include/llvm/Support/ModRef.h b/llvm/include/llvm/Support/ModRef.h
index 7687280111a1f8..5a9d80c87ae27a 100644
--- a/llvm/include/llvm/Support/ModRef.h
+++ b/llvm/include/llvm/Support/ModRef.h
@@ -1,4 +1,4 @@
-//===--- ModRef.h - Memory effect modelling ---------------------*- C++ -*-===//
+//===--- ModRef.h - Memory effect modeling ----------------------*- C++ -*-===//
//
// Part of the LLVM Project, under the Apache License v2.0 with LLVM Exceptions.
// See https://llvm.org/LICENSE.txt for license information.
diff --git a/llvm/lib/Analysis/AliasAnalysis.cpp b/llvm/lib/Analysis/AliasAnalysis.cpp
index 6eaaad5f332eb9..9f529fde55c20f 100644
--- a/llvm/lib/Analysis/AliasAnalysis.cpp
+++ b/llvm/lib/Analysis/AliasAnalysis.cpp
@@ -423,42 +423,6 @@ raw_ostream &llvm::operator<<(raw_ostream &OS, AliasResult AR) {
return OS;
}
-raw_ostream &llvm::operator<<(raw_ostream &OS, ModRefInfo MR) {
- switch (MR) {
- case ModRefInfo::NoModRef:
- OS << "NoModRef";
- break;
- case ModRefInfo::Ref:
- OS << "Ref";
- break;
- case ModRefInfo::Mod:
- OS << "Mod";
- break;
- case ModRefInfo::ModRef:
- OS << "ModRef";
- break;
- }
- return OS;
-}
-
-raw_ostream &llvm::operator<<(raw_ostream &OS, MemoryEffects ME) {
- for (IRMemLocation Loc : MemoryEffects::locations()) {
- switch (Loc) {
- case IRMemLocation::ArgMem:
- OS << "ArgMem: ";
- break;
- case IRMemLocation::InaccessibleMem:
- OS << "InaccessibleMem: ";
- break;
- case IRMemLocation::Other:
- OS << "Other: ";
- break;
- }
- OS << ME.getModRef(Loc) << ", ";
- }
- return OS;
-}
-
//===----------------------------------------------------------------------===//
// Helper method implementation
//===----------------------------------------------------------------------===//
diff --git a/llvm/lib/Support/CMakeLists.txt b/llvm/lib/Support/CMakeLists.txt
index a73ac54a01c5a5..c55c17fae189f5 100644
--- a/llvm/lib/Support/CMakeLists.txt
+++ b/llvm/lib/Support/CMakeLists.txt
@@ -205,6 +205,7 @@ add_llvm_component_library(LLVMSupport
MemAlloc.cpp
MemoryBuffer.cpp
MemoryBufferRef.cpp
+ ModRef.cpp
MD5.cpp
MSP430Attributes.cpp
MSP430AttributeParser.cpp
diff --git a/llvm/lib/Support/ModRef.cpp b/llvm/lib/Support/ModRef.cpp
new file mode 100644
index 00000000000000..c5978296e97f0c
--- /dev/null
+++ b/llvm/lib/Support/ModRef.cpp
@@ -0,0 +1,51 @@
+//===--- ModRef.cpp - Memory effect modeling --------------------*- C++ -*-===//
+//
+// 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
+//
+//===----------------------------------------------------------------------===//
+//
+// This file implements ModRef and MemoryEffects misc functions.
+//
+//===----------------------------------------------------------------------===//
+
+#include "llvm/Support/ModRef.h"
+
+using namespace llvm;
+
+raw_ostream &llvm::operator<<(raw_ostream &OS, ModRefInfo MR) {
+ switch (MR) {
+ case ModRefInfo::NoModRef:
+ OS << "NoModRef";
+ break;
+ case ModRefInfo::Ref:
+ OS << "Ref";
+ break;
+ case ModRefInfo::Mod:
+ OS << "Mod";
+ break;
+ case ModRefInfo::ModRef:
+ OS << "ModRef";
+ break;
+ }
+ return OS;
+}
+
+raw_ostream &llvm::operator<<(raw_ostream &OS, MemoryEffects ME) {
+ for (IRMemLocation Loc : MemoryEffects::locations()) {
+ switch (Loc) {
+ case IRMemLocation::ArgMem:
+ OS << "ArgMem: ";
+ break;
+ case IRMemLocation::InaccessibleMem:
+ OS << "InaccessibleMem: ";
+ break;
+ case IRMemLocation::Other:
+ OS << "Other: ";
+ break;
+ }
+ OS << ME.getModRef(Loc) << ", ";
+ }
+ return OS;
+}
More information about the llvm-commits
mailing list