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 #include "llvm/ADT/STLExtras.h" 15 #include "llvm/ADT/StringExtras.h" 16 17 using namespace llvm; 18 19 raw_ostream &llvm::operator<<(raw_ostream &OS, ModRefInfo MR) { 20 switch (MR) { 21 case ModRefInfo::NoModRef: 22 OS << "NoModRef"; 23 break; 24 case ModRefInfo::Ref: 25 OS << "Ref"; 26 break; 27 case ModRefInfo::Mod: 28 OS << "Mod"; 29 break; 30 case ModRefInfo::ModRef: 31 OS << "ModRef"; 32 break; 33 } 34 return OS; 35 } 36 37 raw_ostream &llvm::operator<<(raw_ostream &OS, MemoryEffects ME) { 38 interleaveComma(MemoryEffects::locations(), OS, [&](IRMemLocation Loc) { 39 switch (Loc) { 40 case IRMemLocation::ArgMem: 41 OS << "ArgMem: "; 42 break; 43 case IRMemLocation::InaccessibleMem: 44 OS << "InaccessibleMem: "; 45 break; 46 case IRMemLocation::ErrnoMem: 47 OS << "ErrnoMem: "; 48 break; 49 case IRMemLocation::Other: 50 OS << "Other: "; 51 break; 52 } 53 OS << ME.getModRef(Loc); 54 }); 55 return OS; 56 } 57 58 raw_ostream &llvm::operator<<(raw_ostream &OS, CaptureComponents CC) { 59 if (capturesNothing(CC)) { 60 OS << "none"; 61 return OS; 62 } 63 64 ListSeparator LS; 65 if (capturesAddressIsNullOnly(CC)) 66 OS << LS << "address_is_null"; 67 else if (capturesAddress(CC)) 68 OS << LS << "address"; 69 if (capturesReadProvenanceOnly(CC)) 70 OS << LS << "read_provenance"; 71 if (capturesFullProvenance(CC)) 72 OS << LS << "provenance"; 73 74 return OS; 75 } 76 77 raw_ostream &llvm::operator<<(raw_ostream &OS, CaptureInfo CI) { 78 ListSeparator LS; 79 CaptureComponents Other = CI.getOtherComponents(); 80 CaptureComponents Ret = CI.getRetComponents(); 81 82 OS << "captures("; 83 if (!capturesNothing(Other) || Other == Ret) 84 OS << LS << Other; 85 if (Other != Ret) 86 OS << LS << "ret: " << Ret; 87 OS << ")"; 88 return OS; 89 } 90