96 lines · cpp
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-exception6//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 17using namespace llvm;18 19raw_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 37raw_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 case IRMemLocation::TargetMem0:53 OS << "TargetMem0: ";54 break;55 case IRMemLocation::TargetMem1:56 OS << "TargetMem1: ";57 break;58 }59 OS << ME.getModRef(Loc);60 });61 return OS;62}63 64raw_ostream &llvm::operator<<(raw_ostream &OS, CaptureComponents CC) {65 if (capturesNothing(CC)) {66 OS << "none";67 return OS;68 }69 70 ListSeparator LS;71 if (capturesAddressIsNullOnly(CC))72 OS << LS << "address_is_null";73 else if (capturesAddress(CC))74 OS << LS << "address";75 if (capturesReadProvenanceOnly(CC))76 OS << LS << "read_provenance";77 if (capturesFullProvenance(CC))78 OS << LS << "provenance";79 80 return OS;81}82 83raw_ostream &llvm::operator<<(raw_ostream &OS, CaptureInfo CI) {84 ListSeparator LS;85 CaptureComponents Other = CI.getOtherComponents();86 CaptureComponents Ret = CI.getRetComponents();87 88 OS << "captures(";89 if (!capturesNothing(Other) || Other == Ret)90 OS << LS << Other;91 if (Other != Ret)92 OS << LS << "ret: " << Ret;93 OS << ")";94 return OS;95}96