Skip to content

Commit 0cff3e8

Browse files
authored
[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`.
1 parent 7a19194 commit 0cff3e8

File tree

4 files changed

+53
-37
lines changed

4 files changed

+53
-37
lines changed

llvm/include/llvm/Support/ModRef.h

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,4 +1,4 @@
1-
//===--- ModRef.h - Memory effect modelling ---------------------*- C++ -*-===//
1+
//===--- ModRef.h - Memory effect modeling ----------------------*- C++ -*-===//
22
//
33
// Part of the LLVM Project, under the Apache License v2.0 with LLVM Exceptions.
44
// See https://llvm.org/LICENSE.txt for license information.

llvm/lib/Analysis/AliasAnalysis.cpp

Lines changed: 0 additions & 36 deletions
Original file line numberDiff line numberDiff line change
@@ -423,42 +423,6 @@ raw_ostream &llvm::operator<<(raw_ostream &OS, AliasResult AR) {
423423
return OS;
424424
}
425425

426-
raw_ostream &llvm::operator<<(raw_ostream &OS, ModRefInfo MR) {
427-
switch (MR) {
428-
case ModRefInfo::NoModRef:
429-
OS << "NoModRef";
430-
break;
431-
case ModRefInfo::Ref:
432-
OS << "Ref";
433-
break;
434-
case ModRefInfo::Mod:
435-
OS << "Mod";
436-
break;
437-
case ModRefInfo::ModRef:
438-
OS << "ModRef";
439-
break;
440-
}
441-
return OS;
442-
}
443-
444-
raw_ostream &llvm::operator<<(raw_ostream &OS, MemoryEffects ME) {
445-
for (IRMemLocation Loc : MemoryEffects::locations()) {
446-
switch (Loc) {
447-
case IRMemLocation::ArgMem:
448-
OS << "ArgMem: ";
449-
break;
450-
case IRMemLocation::InaccessibleMem:
451-
OS << "InaccessibleMem: ";
452-
break;
453-
case IRMemLocation::Other:
454-
OS << "Other: ";
455-
break;
456-
}
457-
OS << ME.getModRef(Loc) << ", ";
458-
}
459-
return OS;
460-
}
461-
462426
//===----------------------------------------------------------------------===//
463427
// Helper method implementation
464428
//===----------------------------------------------------------------------===//

llvm/lib/Support/CMakeLists.txt

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -205,6 +205,7 @@ add_llvm_component_library(LLVMSupport
205205
MemAlloc.cpp
206206
MemoryBuffer.cpp
207207
MemoryBufferRef.cpp
208+
ModRef.cpp
208209
MD5.cpp
209210
MSP430Attributes.cpp
210211
MSP430AttributeParser.cpp

llvm/lib/Support/ModRef.cpp

Lines changed: 51 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,51 @@
1+
//===--- ModRef.cpp - Memory effect modeling --------------------*- 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 file implements ModRef and MemoryEffects misc functions.
10+
//
11+
//===----------------------------------------------------------------------===//
12+
13+
#include "llvm/Support/ModRef.h"
14+
15+
using namespace llvm;
16+
17+
raw_ostream &llvm::operator<<(raw_ostream &OS, ModRefInfo MR) {
18+
switch (MR) {
19+
case ModRefInfo::NoModRef:
20+
OS << "NoModRef";
21+
break;
22+
case ModRefInfo::Ref:
23+
OS << "Ref";
24+
break;
25+
case ModRefInfo::Mod:
26+
OS << "Mod";
27+
break;
28+
case ModRefInfo::ModRef:
29+
OS << "ModRef";
30+
break;
31+
}
32+
return OS;
33+
}
34+
35+
raw_ostream &llvm::operator<<(raw_ostream &OS, MemoryEffects ME) {
36+
for (IRMemLocation Loc : MemoryEffects::locations()) {
37+
switch (Loc) {
38+
case IRMemLocation::ArgMem:
39+
OS << "ArgMem: ";
40+
break;
41+
case IRMemLocation::InaccessibleMem:
42+
OS << "InaccessibleMem: ";
43+
break;
44+
case IRMemLocation::Other:
45+
OS << "Other: ";
46+
break;
47+
}
48+
OS << ME.getModRef(Loc) << ", ";
49+
}
50+
return OS;
51+
}

0 commit comments

Comments
 (0)