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::Other: 47 OS << "Other: "; 48 break; 49 } 50 OS << ME.getModRef(Loc); 51 }); 52 return OS; 53 } 54 55 raw_ostream &llvm::operator<<(raw_ostream &OS, CaptureComponents CC) { 56 if (capturesNothing(CC)) { 57 OS << "none"; 58 return OS; 59 } 60 61 ListSeparator LS; 62 if (capturesAddressIsNullOnly(CC)) 63 OS << LS << "address_is_null"; 64 else if (capturesAddress(CC)) 65 OS << LS << "address"; 66 if (capturesReadProvenanceOnly(CC)) 67 OS << LS << "read_provenance"; 68 if (capturesFullProvenance(CC)) 69 OS << LS << "provenance"; 70 71 return OS; 72 } 73 74 raw_ostream &llvm::operator<<(raw_ostream &OS, CaptureInfo CI) { 75 ListSeparator LS; 76 CaptureComponents Other = CI.getOtherComponents(); 77 CaptureComponents Ret = CI.getRetComponents(); 78 79 OS << "captures("; 80 if (!capturesNothing(Other) || Other == Ret) 81 OS << LS << Other; 82 if (Other != Ret) 83 OS << LS << "ret: " << Ret; 84 OS << ")"; 85 return OS; 86 } 87