1 //===- lib/CodeGen/MachineOperand.cpp -------------------------------------===// 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 /// \file Methods common to all machine operands. 10 // 11 //===----------------------------------------------------------------------===// 12 13 #include "llvm/CodeGen/MachineOperand.h" 14 #include "llvm/ADT/FoldingSet.h" 15 #include "llvm/ADT/StringExtras.h" 16 #include "llvm/Analysis/Loads.h" 17 #include "llvm/Analysis/MemoryLocation.h" 18 #include "llvm/CodeGen/MIRFormatter.h" 19 #include "llvm/CodeGen/MIRPrinter.h" 20 #include "llvm/CodeGen/MachineFrameInfo.h" 21 #include "llvm/CodeGen/MachineJumpTableInfo.h" 22 #include "llvm/CodeGen/MachineRegisterInfo.h" 23 #include "llvm/CodeGen/TargetInstrInfo.h" 24 #include "llvm/CodeGen/TargetRegisterInfo.h" 25 #include "llvm/Config/llvm-config.h" 26 #include "llvm/IR/Constants.h" 27 #include "llvm/IR/IRPrintingPasses.h" 28 #include "llvm/IR/ModuleSlotTracker.h" 29 #include "llvm/MC/MCDwarf.h" 30 #include "llvm/Target/TargetIntrinsicInfo.h" 31 #include "llvm/Target/TargetMachine.h" 32 33 using namespace llvm; 34 35 static cl::opt<int> 36 PrintRegMaskNumRegs("print-regmask-num-regs", 37 cl::desc("Number of registers to limit to when " 38 "printing regmask operands in IR dumps. " 39 "unlimited = -1"), 40 cl::init(32), cl::Hidden); 41 42 static const MachineFunction *getMFIfAvailable(const MachineOperand &MO) { 43 if (const MachineInstr *MI = MO.getParent()) 44 if (const MachineBasicBlock *MBB = MI->getParent()) 45 if (const MachineFunction *MF = MBB->getParent()) 46 return MF; 47 return nullptr; 48 } 49 static MachineFunction *getMFIfAvailable(MachineOperand &MO) { 50 return const_cast<MachineFunction *>( 51 getMFIfAvailable(const_cast<const MachineOperand &>(MO))); 52 } 53 54 void MachineOperand::setReg(Register Reg) { 55 if (getReg() == Reg) 56 return; // No change. 57 58 // Clear the IsRenamable bit to keep it conservatively correct. 59 IsRenamable = false; 60 61 // Otherwise, we have to change the register. If this operand is embedded 62 // into a machine function, we need to update the old and new register's 63 // use/def lists. 64 if (MachineFunction *MF = getMFIfAvailable(*this)) { 65 MachineRegisterInfo &MRI = MF->getRegInfo(); 66 MRI.removeRegOperandFromUseList(this); 67 SmallContents.RegNo = Reg; 68 MRI.addRegOperandToUseList(this); 69 return; 70 } 71 72 // Otherwise, just change the register, no problem. :) 73 SmallContents.RegNo = Reg; 74 } 75 76 void MachineOperand::substVirtReg(Register Reg, unsigned SubIdx, 77 const TargetRegisterInfo &TRI) { 78 assert(Reg.isVirtual()); 79 if (SubIdx && getSubReg()) 80 SubIdx = TRI.composeSubRegIndices(SubIdx, getSubReg()); 81 setReg(Reg); 82 if (SubIdx) 83 setSubReg(SubIdx); 84 } 85 86 void MachineOperand::substPhysReg(MCRegister Reg, const TargetRegisterInfo &TRI) { 87 assert(Reg.isPhysical()); 88 if (getSubReg()) { 89 Reg = TRI.getSubReg(Reg, getSubReg()); 90 // Note that getSubReg() may return 0 if the sub-register doesn't exist. 91 // That won't happen in legal code. 92 setSubReg(0); 93 if (isDef()) 94 setIsUndef(false); 95 } 96 setReg(Reg); 97 } 98 99 /// Change a def to a use, or a use to a def. 100 void MachineOperand::setIsDef(bool Val) { 101 assert(isReg() && "Wrong MachineOperand accessor"); 102 assert((!Val || !isDebug()) && "Marking a debug operation as def"); 103 if (IsDef == Val) 104 return; 105 assert(!IsDeadOrKill && "Changing def/use with dead/kill set not supported"); 106 // MRI may keep uses and defs in different list positions. 107 if (MachineFunction *MF = getMFIfAvailable(*this)) { 108 MachineRegisterInfo &MRI = MF->getRegInfo(); 109 MRI.removeRegOperandFromUseList(this); 110 IsDef = Val; 111 MRI.addRegOperandToUseList(this); 112 return; 113 } 114 IsDef = Val; 115 } 116 117 bool MachineOperand::isRenamable() const { 118 assert(isReg() && "Wrong MachineOperand accessor"); 119 assert(Register::isPhysicalRegister(getReg()) && 120 "isRenamable should only be checked on physical registers"); 121 if (!IsRenamable) 122 return false; 123 124 const MachineInstr *MI = getParent(); 125 if (!MI) 126 return true; 127 128 if (isDef()) 129 return !MI->hasExtraDefRegAllocReq(MachineInstr::IgnoreBundle); 130 131 assert(isUse() && "Reg is not def or use"); 132 return !MI->hasExtraSrcRegAllocReq(MachineInstr::IgnoreBundle); 133 } 134 135 void MachineOperand::setIsRenamable(bool Val) { 136 assert(isReg() && "Wrong MachineOperand accessor"); 137 assert(Register::isPhysicalRegister(getReg()) && 138 "setIsRenamable should only be called on physical registers"); 139 IsRenamable = Val; 140 } 141 142 // If this operand is currently a register operand, and if this is in a 143 // function, deregister the operand from the register's use/def list. 144 void MachineOperand::removeRegFromUses() { 145 if (!isReg() || !isOnRegUseList()) 146 return; 147 148 if (MachineFunction *MF = getMFIfAvailable(*this)) 149 MF->getRegInfo().removeRegOperandFromUseList(this); 150 } 151 152 /// ChangeToImmediate - Replace this operand with a new immediate operand of 153 /// the specified value. If an operand is known to be an immediate already, 154 /// the setImm method should be used. 155 void MachineOperand::ChangeToImmediate(int64_t ImmVal) { 156 assert((!isReg() || !isTied()) && "Cannot change a tied operand into an imm"); 157 158 removeRegFromUses(); 159 160 OpKind = MO_Immediate; 161 Contents.ImmVal = ImmVal; 162 } 163 164 void MachineOperand::ChangeToFPImmediate(const ConstantFP *FPImm) { 165 assert((!isReg() || !isTied()) && "Cannot change a tied operand into an imm"); 166 167 removeRegFromUses(); 168 169 OpKind = MO_FPImmediate; 170 Contents.CFP = FPImm; 171 } 172 173 void MachineOperand::ChangeToES(const char *SymName, 174 unsigned TargetFlags) { 175 assert((!isReg() || !isTied()) && 176 "Cannot change a tied operand into an external symbol"); 177 178 removeRegFromUses(); 179 180 OpKind = MO_ExternalSymbol; 181 Contents.OffsetedInfo.Val.SymbolName = SymName; 182 setOffset(0); // Offset is always 0. 183 setTargetFlags(TargetFlags); 184 } 185 186 void MachineOperand::ChangeToGA(const GlobalValue *GV, int64_t Offset, 187 unsigned TargetFlags) { 188 assert((!isReg() || !isTied()) && 189 "Cannot change a tied operand into a global address"); 190 191 removeRegFromUses(); 192 193 OpKind = MO_GlobalAddress; 194 Contents.OffsetedInfo.Val.GV = GV; 195 setOffset(Offset); 196 setTargetFlags(TargetFlags); 197 } 198 199 void MachineOperand::ChangeToMCSymbol(MCSymbol *Sym) { 200 assert((!isReg() || !isTied()) && 201 "Cannot change a tied operand into an MCSymbol"); 202 203 removeRegFromUses(); 204 205 OpKind = MO_MCSymbol; 206 Contents.Sym = Sym; 207 } 208 209 void MachineOperand::ChangeToFrameIndex(int Idx) { 210 assert((!isReg() || !isTied()) && 211 "Cannot change a tied operand into a FrameIndex"); 212 213 removeRegFromUses(); 214 215 OpKind = MO_FrameIndex; 216 setIndex(Idx); 217 } 218 219 void MachineOperand::ChangeToTargetIndex(unsigned Idx, int64_t Offset, 220 unsigned TargetFlags) { 221 assert((!isReg() || !isTied()) && 222 "Cannot change a tied operand into a FrameIndex"); 223 224 removeRegFromUses(); 225 226 OpKind = MO_TargetIndex; 227 setIndex(Idx); 228 setOffset(Offset); 229 setTargetFlags(TargetFlags); 230 } 231 232 /// ChangeToRegister - Replace this operand with a new register operand of 233 /// the specified value. If an operand is known to be an register already, 234 /// the setReg method should be used. 235 void MachineOperand::ChangeToRegister(Register Reg, bool isDef, bool isImp, 236 bool isKill, bool isDead, bool isUndef, 237 bool isDebug) { 238 MachineRegisterInfo *RegInfo = nullptr; 239 if (MachineFunction *MF = getMFIfAvailable(*this)) 240 RegInfo = &MF->getRegInfo(); 241 // If this operand is already a register operand, remove it from the 242 // register's use/def lists. 243 bool WasReg = isReg(); 244 if (RegInfo && WasReg) 245 RegInfo->removeRegOperandFromUseList(this); 246 247 // Change this to a register and set the reg#. 248 assert(!(isDead && !isDef) && "Dead flag on non-def"); 249 assert(!(isKill && isDef) && "Kill flag on def"); 250 OpKind = MO_Register; 251 SmallContents.RegNo = Reg; 252 SubReg_TargetFlags = 0; 253 IsDef = isDef; 254 IsImp = isImp; 255 IsDeadOrKill = isKill | isDead; 256 IsRenamable = false; 257 IsUndef = isUndef; 258 IsInternalRead = false; 259 IsEarlyClobber = false; 260 IsDebug = isDebug; 261 // Ensure isOnRegUseList() returns false. 262 Contents.Reg.Prev = nullptr; 263 // Preserve the tie when the operand was already a register. 264 if (!WasReg) 265 TiedTo = 0; 266 267 // If this operand is embedded in a function, add the operand to the 268 // register's use/def list. 269 if (RegInfo) 270 RegInfo->addRegOperandToUseList(this); 271 } 272 273 /// isIdenticalTo - Return true if this operand is identical to the specified 274 /// operand. Note that this should stay in sync with the hash_value overload 275 /// below. 276 bool MachineOperand::isIdenticalTo(const MachineOperand &Other) const { 277 if (getType() != Other.getType() || 278 getTargetFlags() != Other.getTargetFlags()) 279 return false; 280 281 switch (getType()) { 282 case MachineOperand::MO_Register: 283 return getReg() == Other.getReg() && isDef() == Other.isDef() && 284 getSubReg() == Other.getSubReg(); 285 case MachineOperand::MO_Immediate: 286 return getImm() == Other.getImm(); 287 case MachineOperand::MO_CImmediate: 288 return getCImm() == Other.getCImm(); 289 case MachineOperand::MO_FPImmediate: 290 return getFPImm() == Other.getFPImm(); 291 case MachineOperand::MO_MachineBasicBlock: 292 return getMBB() == Other.getMBB(); 293 case MachineOperand::MO_FrameIndex: 294 return getIndex() == Other.getIndex(); 295 case MachineOperand::MO_ConstantPoolIndex: 296 case MachineOperand::MO_TargetIndex: 297 return getIndex() == Other.getIndex() && getOffset() == Other.getOffset(); 298 case MachineOperand::MO_JumpTableIndex: 299 return getIndex() == Other.getIndex(); 300 case MachineOperand::MO_GlobalAddress: 301 return getGlobal() == Other.getGlobal() && getOffset() == Other.getOffset(); 302 case MachineOperand::MO_ExternalSymbol: 303 return strcmp(getSymbolName(), Other.getSymbolName()) == 0 && 304 getOffset() == Other.getOffset(); 305 case MachineOperand::MO_BlockAddress: 306 return getBlockAddress() == Other.getBlockAddress() && 307 getOffset() == Other.getOffset(); 308 case MachineOperand::MO_RegisterMask: 309 case MachineOperand::MO_RegisterLiveOut: { 310 // Shallow compare of the two RegMasks 311 const uint32_t *RegMask = getRegMask(); 312 const uint32_t *OtherRegMask = Other.getRegMask(); 313 if (RegMask == OtherRegMask) 314 return true; 315 316 if (const MachineFunction *MF = getMFIfAvailable(*this)) { 317 // Calculate the size of the RegMask 318 const TargetRegisterInfo *TRI = MF->getSubtarget().getRegisterInfo(); 319 unsigned RegMaskSize = (TRI->getNumRegs() + 31) / 32; 320 321 // Deep compare of the two RegMasks 322 return std::equal(RegMask, RegMask + RegMaskSize, OtherRegMask); 323 } 324 // We don't know the size of the RegMask, so we can't deep compare the two 325 // reg masks. 326 return false; 327 } 328 case MachineOperand::MO_MCSymbol: 329 return getMCSymbol() == Other.getMCSymbol(); 330 case MachineOperand::MO_CFIIndex: 331 return getCFIIndex() == Other.getCFIIndex(); 332 case MachineOperand::MO_Metadata: 333 return getMetadata() == Other.getMetadata(); 334 case MachineOperand::MO_IntrinsicID: 335 return getIntrinsicID() == Other.getIntrinsicID(); 336 case MachineOperand::MO_Predicate: 337 return getPredicate() == Other.getPredicate(); 338 case MachineOperand::MO_ShuffleMask: 339 return getShuffleMask() == Other.getShuffleMask(); 340 } 341 llvm_unreachable("Invalid machine operand type"); 342 } 343 344 // Note: this must stay exactly in sync with isIdenticalTo above. 345 hash_code llvm::hash_value(const MachineOperand &MO) { 346 switch (MO.getType()) { 347 case MachineOperand::MO_Register: 348 // Register operands don't have target flags. 349 return hash_combine(MO.getType(), (unsigned)MO.getReg(), MO.getSubReg(), MO.isDef()); 350 case MachineOperand::MO_Immediate: 351 return hash_combine(MO.getType(), MO.getTargetFlags(), MO.getImm()); 352 case MachineOperand::MO_CImmediate: 353 return hash_combine(MO.getType(), MO.getTargetFlags(), MO.getCImm()); 354 case MachineOperand::MO_FPImmediate: 355 return hash_combine(MO.getType(), MO.getTargetFlags(), MO.getFPImm()); 356 case MachineOperand::MO_MachineBasicBlock: 357 return hash_combine(MO.getType(), MO.getTargetFlags(), MO.getMBB()); 358 case MachineOperand::MO_FrameIndex: 359 return hash_combine(MO.getType(), MO.getTargetFlags(), MO.getIndex()); 360 case MachineOperand::MO_ConstantPoolIndex: 361 case MachineOperand::MO_TargetIndex: 362 return hash_combine(MO.getType(), MO.getTargetFlags(), MO.getIndex(), 363 MO.getOffset()); 364 case MachineOperand::MO_JumpTableIndex: 365 return hash_combine(MO.getType(), MO.getTargetFlags(), MO.getIndex()); 366 case MachineOperand::MO_ExternalSymbol: 367 return hash_combine(MO.getType(), MO.getTargetFlags(), MO.getOffset(), 368 StringRef(MO.getSymbolName())); 369 case MachineOperand::MO_GlobalAddress: 370 return hash_combine(MO.getType(), MO.getTargetFlags(), MO.getGlobal(), 371 MO.getOffset()); 372 case MachineOperand::MO_BlockAddress: 373 return hash_combine(MO.getType(), MO.getTargetFlags(), MO.getBlockAddress(), 374 MO.getOffset()); 375 case MachineOperand::MO_RegisterMask: 376 case MachineOperand::MO_RegisterLiveOut: 377 return hash_combine(MO.getType(), MO.getTargetFlags(), MO.getRegMask()); 378 case MachineOperand::MO_Metadata: 379 return hash_combine(MO.getType(), MO.getTargetFlags(), MO.getMetadata()); 380 case MachineOperand::MO_MCSymbol: 381 return hash_combine(MO.getType(), MO.getTargetFlags(), MO.getMCSymbol()); 382 case MachineOperand::MO_CFIIndex: 383 return hash_combine(MO.getType(), MO.getTargetFlags(), MO.getCFIIndex()); 384 case MachineOperand::MO_IntrinsicID: 385 return hash_combine(MO.getType(), MO.getTargetFlags(), MO.getIntrinsicID()); 386 case MachineOperand::MO_Predicate: 387 return hash_combine(MO.getType(), MO.getTargetFlags(), MO.getPredicate()); 388 case MachineOperand::MO_ShuffleMask: 389 return hash_combine(MO.getType(), MO.getTargetFlags(), MO.getShuffleMask()); 390 } 391 llvm_unreachable("Invalid machine operand type"); 392 } 393 394 // Try to crawl up to the machine function and get TRI and IntrinsicInfo from 395 // it. 396 static void tryToGetTargetInfo(const MachineOperand &MO, 397 const TargetRegisterInfo *&TRI, 398 const TargetIntrinsicInfo *&IntrinsicInfo) { 399 if (const MachineFunction *MF = getMFIfAvailable(MO)) { 400 TRI = MF->getSubtarget().getRegisterInfo(); 401 IntrinsicInfo = MF->getTarget().getIntrinsicInfo(); 402 } 403 } 404 405 static const char *getTargetIndexName(const MachineFunction &MF, int Index) { 406 const auto *TII = MF.getSubtarget().getInstrInfo(); 407 assert(TII && "expected instruction info"); 408 auto Indices = TII->getSerializableTargetIndices(); 409 auto Found = find_if(Indices, [&](const std::pair<int, const char *> &I) { 410 return I.first == Index; 411 }); 412 if (Found != Indices.end()) 413 return Found->second; 414 return nullptr; 415 } 416 417 static const char *getTargetFlagName(const TargetInstrInfo *TII, unsigned TF) { 418 auto Flags = TII->getSerializableDirectMachineOperandTargetFlags(); 419 for (const auto &I : Flags) { 420 if (I.first == TF) { 421 return I.second; 422 } 423 } 424 return nullptr; 425 } 426 427 static void printCFIRegister(unsigned DwarfReg, raw_ostream &OS, 428 const TargetRegisterInfo *TRI) { 429 if (!TRI) { 430 OS << "%dwarfreg." << DwarfReg; 431 return; 432 } 433 434 if (Optional<unsigned> Reg = TRI->getLLVMRegNum(DwarfReg, true)) 435 OS << printReg(*Reg, TRI); 436 else 437 OS << "<badreg>"; 438 } 439 440 static void printIRBlockReference(raw_ostream &OS, const BasicBlock &BB, 441 ModuleSlotTracker &MST) { 442 OS << "%ir-block."; 443 if (BB.hasName()) { 444 printLLVMNameWithoutPrefix(OS, BB.getName()); 445 return; 446 } 447 Optional<int> Slot; 448 if (const Function *F = BB.getParent()) { 449 if (F == MST.getCurrentFunction()) { 450 Slot = MST.getLocalSlot(&BB); 451 } else if (const Module *M = F->getParent()) { 452 ModuleSlotTracker CustomMST(M, /*ShouldInitializeAllMetadata=*/false); 453 CustomMST.incorporateFunction(*F); 454 Slot = CustomMST.getLocalSlot(&BB); 455 } 456 } 457 if (Slot) 458 MachineOperand::printIRSlotNumber(OS, *Slot); 459 else 460 OS << "<unknown>"; 461 } 462 463 static void printSyncScope(raw_ostream &OS, const LLVMContext &Context, 464 SyncScope::ID SSID, 465 SmallVectorImpl<StringRef> &SSNs) { 466 switch (SSID) { 467 case SyncScope::System: 468 break; 469 default: 470 if (SSNs.empty()) 471 Context.getSyncScopeNames(SSNs); 472 473 OS << "syncscope(\""; 474 printEscapedString(SSNs[SSID], OS); 475 OS << "\") "; 476 break; 477 } 478 } 479 480 static const char *getTargetMMOFlagName(const TargetInstrInfo &TII, 481 unsigned TMMOFlag) { 482 auto Flags = TII.getSerializableMachineMemOperandTargetFlags(); 483 for (const auto &I : Flags) { 484 if (I.first == TMMOFlag) { 485 return I.second; 486 } 487 } 488 return nullptr; 489 } 490 491 static void printFrameIndex(raw_ostream& OS, int FrameIndex, bool IsFixed, 492 const MachineFrameInfo *MFI) { 493 StringRef Name; 494 if (MFI) { 495 IsFixed = MFI->isFixedObjectIndex(FrameIndex); 496 if (const AllocaInst *Alloca = MFI->getObjectAllocation(FrameIndex)) 497 if (Alloca->hasName()) 498 Name = Alloca->getName(); 499 if (IsFixed) 500 FrameIndex -= MFI->getObjectIndexBegin(); 501 } 502 MachineOperand::printStackObjectReference(OS, FrameIndex, IsFixed, Name); 503 } 504 505 void MachineOperand::printSubRegIdx(raw_ostream &OS, uint64_t Index, 506 const TargetRegisterInfo *TRI) { 507 OS << "%subreg."; 508 if (TRI) 509 OS << TRI->getSubRegIndexName(Index); 510 else 511 OS << Index; 512 } 513 514 void MachineOperand::printTargetFlags(raw_ostream &OS, 515 const MachineOperand &Op) { 516 if (!Op.getTargetFlags()) 517 return; 518 const MachineFunction *MF = getMFIfAvailable(Op); 519 if (!MF) 520 return; 521 522 const auto *TII = MF->getSubtarget().getInstrInfo(); 523 assert(TII && "expected instruction info"); 524 auto Flags = TII->decomposeMachineOperandsTargetFlags(Op.getTargetFlags()); 525 OS << "target-flags("; 526 const bool HasDirectFlags = Flags.first; 527 const bool HasBitmaskFlags = Flags.second; 528 if (!HasDirectFlags && !HasBitmaskFlags) { 529 OS << "<unknown>) "; 530 return; 531 } 532 if (HasDirectFlags) { 533 if (const auto *Name = getTargetFlagName(TII, Flags.first)) 534 OS << Name; 535 else 536 OS << "<unknown target flag>"; 537 } 538 if (!HasBitmaskFlags) { 539 OS << ") "; 540 return; 541 } 542 bool IsCommaNeeded = HasDirectFlags; 543 unsigned BitMask = Flags.second; 544 auto BitMasks = TII->getSerializableBitmaskMachineOperandTargetFlags(); 545 for (const auto &Mask : BitMasks) { 546 // Check if the flag's bitmask has the bits of the current mask set. 547 if ((BitMask & Mask.first) == Mask.first) { 548 if (IsCommaNeeded) 549 OS << ", "; 550 IsCommaNeeded = true; 551 OS << Mask.second; 552 // Clear the bits which were serialized from the flag's bitmask. 553 BitMask &= ~(Mask.first); 554 } 555 } 556 if (BitMask) { 557 // When the resulting flag's bitmask isn't zero, we know that we didn't 558 // serialize all of the bit flags. 559 if (IsCommaNeeded) 560 OS << ", "; 561 OS << "<unknown bitmask target flag>"; 562 } 563 OS << ") "; 564 } 565 566 void MachineOperand::printSymbol(raw_ostream &OS, MCSymbol &Sym) { 567 OS << "<mcsymbol " << Sym << ">"; 568 } 569 570 void MachineOperand::printStackObjectReference(raw_ostream &OS, 571 unsigned FrameIndex, 572 bool IsFixed, StringRef Name) { 573 if (IsFixed) { 574 OS << "%fixed-stack." << FrameIndex; 575 return; 576 } 577 578 OS << "%stack." << FrameIndex; 579 if (!Name.empty()) 580 OS << '.' << Name; 581 } 582 583 void MachineOperand::printOperandOffset(raw_ostream &OS, int64_t Offset) { 584 if (Offset == 0) 585 return; 586 if (Offset < 0) { 587 OS << " - " << -Offset; 588 return; 589 } 590 OS << " + " << Offset; 591 } 592 593 void MachineOperand::printIRSlotNumber(raw_ostream &OS, int Slot) { 594 if (Slot == -1) 595 OS << "<badref>"; 596 else 597 OS << Slot; 598 } 599 600 static void printCFI(raw_ostream &OS, const MCCFIInstruction &CFI, 601 const TargetRegisterInfo *TRI) { 602 switch (CFI.getOperation()) { 603 case MCCFIInstruction::OpSameValue: 604 OS << "same_value "; 605 if (MCSymbol *Label = CFI.getLabel()) 606 MachineOperand::printSymbol(OS, *Label); 607 printCFIRegister(CFI.getRegister(), OS, TRI); 608 break; 609 case MCCFIInstruction::OpRememberState: 610 OS << "remember_state "; 611 if (MCSymbol *Label = CFI.getLabel()) 612 MachineOperand::printSymbol(OS, *Label); 613 break; 614 case MCCFIInstruction::OpRestoreState: 615 OS << "restore_state "; 616 if (MCSymbol *Label = CFI.getLabel()) 617 MachineOperand::printSymbol(OS, *Label); 618 break; 619 case MCCFIInstruction::OpOffset: 620 OS << "offset "; 621 if (MCSymbol *Label = CFI.getLabel()) 622 MachineOperand::printSymbol(OS, *Label); 623 printCFIRegister(CFI.getRegister(), OS, TRI); 624 OS << ", " << CFI.getOffset(); 625 break; 626 case MCCFIInstruction::OpDefCfaRegister: 627 OS << "def_cfa_register "; 628 if (MCSymbol *Label = CFI.getLabel()) 629 MachineOperand::printSymbol(OS, *Label); 630 printCFIRegister(CFI.getRegister(), OS, TRI); 631 break; 632 case MCCFIInstruction::OpDefCfaOffset: 633 OS << "def_cfa_offset "; 634 if (MCSymbol *Label = CFI.getLabel()) 635 MachineOperand::printSymbol(OS, *Label); 636 OS << CFI.getOffset(); 637 break; 638 case MCCFIInstruction::OpDefCfa: 639 OS << "def_cfa "; 640 if (MCSymbol *Label = CFI.getLabel()) 641 MachineOperand::printSymbol(OS, *Label); 642 printCFIRegister(CFI.getRegister(), OS, TRI); 643 OS << ", " << CFI.getOffset(); 644 break; 645 case MCCFIInstruction::OpRelOffset: 646 OS << "rel_offset "; 647 if (MCSymbol *Label = CFI.getLabel()) 648 MachineOperand::printSymbol(OS, *Label); 649 printCFIRegister(CFI.getRegister(), OS, TRI); 650 OS << ", " << CFI.getOffset(); 651 break; 652 case MCCFIInstruction::OpAdjustCfaOffset: 653 OS << "adjust_cfa_offset "; 654 if (MCSymbol *Label = CFI.getLabel()) 655 MachineOperand::printSymbol(OS, *Label); 656 OS << CFI.getOffset(); 657 break; 658 case MCCFIInstruction::OpRestore: 659 OS << "restore "; 660 if (MCSymbol *Label = CFI.getLabel()) 661 MachineOperand::printSymbol(OS, *Label); 662 printCFIRegister(CFI.getRegister(), OS, TRI); 663 break; 664 case MCCFIInstruction::OpEscape: { 665 OS << "escape "; 666 if (MCSymbol *Label = CFI.getLabel()) 667 MachineOperand::printSymbol(OS, *Label); 668 if (!CFI.getValues().empty()) { 669 size_t e = CFI.getValues().size() - 1; 670 for (size_t i = 0; i < e; ++i) 671 OS << format("0x%02x", uint8_t(CFI.getValues()[i])) << ", "; 672 OS << format("0x%02x", uint8_t(CFI.getValues()[e])) << ", "; 673 } 674 break; 675 } 676 case MCCFIInstruction::OpUndefined: 677 OS << "undefined "; 678 if (MCSymbol *Label = CFI.getLabel()) 679 MachineOperand::printSymbol(OS, *Label); 680 printCFIRegister(CFI.getRegister(), OS, TRI); 681 break; 682 case MCCFIInstruction::OpRegister: 683 OS << "register "; 684 if (MCSymbol *Label = CFI.getLabel()) 685 MachineOperand::printSymbol(OS, *Label); 686 printCFIRegister(CFI.getRegister(), OS, TRI); 687 OS << ", "; 688 printCFIRegister(CFI.getRegister2(), OS, TRI); 689 break; 690 case MCCFIInstruction::OpWindowSave: 691 OS << "window_save "; 692 if (MCSymbol *Label = CFI.getLabel()) 693 MachineOperand::printSymbol(OS, *Label); 694 break; 695 case MCCFIInstruction::OpNegateRAState: 696 OS << "negate_ra_sign_state "; 697 if (MCSymbol *Label = CFI.getLabel()) 698 MachineOperand::printSymbol(OS, *Label); 699 break; 700 default: 701 // TODO: Print the other CFI Operations. 702 OS << "<unserializable cfi directive>"; 703 break; 704 } 705 } 706 707 void MachineOperand::print(raw_ostream &OS, const TargetRegisterInfo *TRI, 708 const TargetIntrinsicInfo *IntrinsicInfo) const { 709 print(OS, LLT{}, TRI, IntrinsicInfo); 710 } 711 712 void MachineOperand::print(raw_ostream &OS, LLT TypeToPrint, 713 const TargetRegisterInfo *TRI, 714 const TargetIntrinsicInfo *IntrinsicInfo) const { 715 tryToGetTargetInfo(*this, TRI, IntrinsicInfo); 716 ModuleSlotTracker DummyMST(nullptr); 717 print(OS, DummyMST, TypeToPrint, None, /*PrintDef=*/false, 718 /*IsStandalone=*/true, 719 /*ShouldPrintRegisterTies=*/true, 720 /*TiedOperandIdx=*/0, TRI, IntrinsicInfo); 721 } 722 723 void MachineOperand::print(raw_ostream &OS, ModuleSlotTracker &MST, 724 LLT TypeToPrint, Optional<unsigned> OpIdx, bool PrintDef, 725 bool IsStandalone, bool ShouldPrintRegisterTies, 726 unsigned TiedOperandIdx, 727 const TargetRegisterInfo *TRI, 728 const TargetIntrinsicInfo *IntrinsicInfo) const { 729 printTargetFlags(OS, *this); 730 switch (getType()) { 731 case MachineOperand::MO_Register: { 732 Register Reg = getReg(); 733 if (isImplicit()) 734 OS << (isDef() ? "implicit-def " : "implicit "); 735 else if (PrintDef && isDef()) 736 // Print the 'def' flag only when the operand is defined after '='. 737 OS << "def "; 738 if (isInternalRead()) 739 OS << "internal "; 740 if (isDead()) 741 OS << "dead "; 742 if (isKill()) 743 OS << "killed "; 744 if (isUndef()) 745 OS << "undef "; 746 if (isEarlyClobber()) 747 OS << "early-clobber "; 748 if (Register::isPhysicalRegister(getReg()) && isRenamable()) 749 OS << "renamable "; 750 // isDebug() is exactly true for register operands of a DBG_VALUE. So we 751 // simply infer it when parsing and do not need to print it. 752 753 const MachineRegisterInfo *MRI = nullptr; 754 if (Register::isVirtualRegister(Reg)) { 755 if (const MachineFunction *MF = getMFIfAvailable(*this)) { 756 MRI = &MF->getRegInfo(); 757 } 758 } 759 760 OS << printReg(Reg, TRI, 0, MRI); 761 // Print the sub register. 762 if (unsigned SubReg = getSubReg()) { 763 if (TRI) 764 OS << '.' << TRI->getSubRegIndexName(SubReg); 765 else 766 OS << ".subreg" << SubReg; 767 } 768 // Print the register class / bank. 769 if (Register::isVirtualRegister(Reg)) { 770 if (const MachineFunction *MF = getMFIfAvailable(*this)) { 771 const MachineRegisterInfo &MRI = MF->getRegInfo(); 772 if (IsStandalone || !PrintDef || MRI.def_empty(Reg)) { 773 OS << ':'; 774 OS << printRegClassOrBank(Reg, MRI, TRI); 775 } 776 } 777 } 778 // Print ties. 779 if (ShouldPrintRegisterTies && isTied() && !isDef()) 780 OS << "(tied-def " << TiedOperandIdx << ")"; 781 // Print types. 782 if (TypeToPrint.isValid()) 783 OS << '(' << TypeToPrint << ')'; 784 break; 785 } 786 case MachineOperand::MO_Immediate: { 787 const MIRFormatter *Formatter = nullptr; 788 if (const MachineFunction *MF = getMFIfAvailable(*this)) { 789 const auto *TII = MF->getSubtarget().getInstrInfo(); 790 assert(TII && "expected instruction info"); 791 Formatter = TII->getMIRFormatter(); 792 } 793 if (Formatter) 794 Formatter->printImm(OS, *getParent(), OpIdx, getImm()); 795 else 796 OS << getImm(); 797 break; 798 } 799 case MachineOperand::MO_CImmediate: 800 getCImm()->printAsOperand(OS, /*PrintType=*/true, MST); 801 break; 802 case MachineOperand::MO_FPImmediate: 803 getFPImm()->printAsOperand(OS, /*PrintType=*/true, MST); 804 break; 805 case MachineOperand::MO_MachineBasicBlock: 806 OS << printMBBReference(*getMBB()); 807 break; 808 case MachineOperand::MO_FrameIndex: { 809 int FrameIndex = getIndex(); 810 bool IsFixed = false; 811 const MachineFrameInfo *MFI = nullptr; 812 if (const MachineFunction *MF = getMFIfAvailable(*this)) 813 MFI = &MF->getFrameInfo(); 814 printFrameIndex(OS, FrameIndex, IsFixed, MFI); 815 break; 816 } 817 case MachineOperand::MO_ConstantPoolIndex: 818 OS << "%const." << getIndex(); 819 printOperandOffset(OS, getOffset()); 820 break; 821 case MachineOperand::MO_TargetIndex: { 822 OS << "target-index("; 823 const char *Name = "<unknown>"; 824 if (const MachineFunction *MF = getMFIfAvailable(*this)) 825 if (const auto *TargetIndexName = getTargetIndexName(*MF, getIndex())) 826 Name = TargetIndexName; 827 OS << Name << ')'; 828 printOperandOffset(OS, getOffset()); 829 break; 830 } 831 case MachineOperand::MO_JumpTableIndex: 832 OS << printJumpTableEntryReference(getIndex()); 833 break; 834 case MachineOperand::MO_GlobalAddress: 835 getGlobal()->printAsOperand(OS, /*PrintType=*/false, MST); 836 printOperandOffset(OS, getOffset()); 837 break; 838 case MachineOperand::MO_ExternalSymbol: { 839 StringRef Name = getSymbolName(); 840 OS << '&'; 841 if (Name.empty()) { 842 OS << "\"\""; 843 } else { 844 printLLVMNameWithoutPrefix(OS, Name); 845 } 846 printOperandOffset(OS, getOffset()); 847 break; 848 } 849 case MachineOperand::MO_BlockAddress: { 850 OS << "blockaddress("; 851 getBlockAddress()->getFunction()->printAsOperand(OS, /*PrintType=*/false, 852 MST); 853 OS << ", "; 854 printIRBlockReference(OS, *getBlockAddress()->getBasicBlock(), MST); 855 OS << ')'; 856 MachineOperand::printOperandOffset(OS, getOffset()); 857 break; 858 } 859 case MachineOperand::MO_RegisterMask: { 860 OS << "<regmask"; 861 if (TRI) { 862 unsigned NumRegsInMask = 0; 863 unsigned NumRegsEmitted = 0; 864 for (unsigned i = 0; i < TRI->getNumRegs(); ++i) { 865 unsigned MaskWord = i / 32; 866 unsigned MaskBit = i % 32; 867 if (getRegMask()[MaskWord] & (1 << MaskBit)) { 868 if (PrintRegMaskNumRegs < 0 || 869 NumRegsEmitted <= static_cast<unsigned>(PrintRegMaskNumRegs)) { 870 OS << " " << printReg(i, TRI); 871 NumRegsEmitted++; 872 } 873 NumRegsInMask++; 874 } 875 } 876 if (NumRegsEmitted != NumRegsInMask) 877 OS << " and " << (NumRegsInMask - NumRegsEmitted) << " more..."; 878 } else { 879 OS << " ..."; 880 } 881 OS << ">"; 882 break; 883 } 884 case MachineOperand::MO_RegisterLiveOut: { 885 const uint32_t *RegMask = getRegLiveOut(); 886 OS << "liveout("; 887 if (!TRI) { 888 OS << "<unknown>"; 889 } else { 890 bool IsCommaNeeded = false; 891 for (unsigned Reg = 0, E = TRI->getNumRegs(); Reg < E; ++Reg) { 892 if (RegMask[Reg / 32] & (1U << (Reg % 32))) { 893 if (IsCommaNeeded) 894 OS << ", "; 895 OS << printReg(Reg, TRI); 896 IsCommaNeeded = true; 897 } 898 } 899 } 900 OS << ")"; 901 break; 902 } 903 case MachineOperand::MO_Metadata: 904 getMetadata()->printAsOperand(OS, MST); 905 break; 906 case MachineOperand::MO_MCSymbol: 907 printSymbol(OS, *getMCSymbol()); 908 break; 909 case MachineOperand::MO_CFIIndex: { 910 if (const MachineFunction *MF = getMFIfAvailable(*this)) 911 printCFI(OS, MF->getFrameInstructions()[getCFIIndex()], TRI); 912 else 913 OS << "<cfi directive>"; 914 break; 915 } 916 case MachineOperand::MO_IntrinsicID: { 917 Intrinsic::ID ID = getIntrinsicID(); 918 if (ID < Intrinsic::num_intrinsics) 919 OS << "intrinsic(@" << Intrinsic::getName(ID, None) << ')'; 920 else if (IntrinsicInfo) 921 OS << "intrinsic(@" << IntrinsicInfo->getName(ID) << ')'; 922 else 923 OS << "intrinsic(" << ID << ')'; 924 break; 925 } 926 case MachineOperand::MO_Predicate: { 927 auto Pred = static_cast<CmpInst::Predicate>(getPredicate()); 928 OS << (CmpInst::isIntPredicate(Pred) ? "int" : "float") << "pred(" 929 << CmpInst::getPredicateName(Pred) << ')'; 930 break; 931 } 932 case MachineOperand::MO_ShuffleMask: 933 OS << "shufflemask("; 934 ArrayRef<int> Mask = getShuffleMask(); 935 StringRef Separator; 936 for (int Elt : Mask) { 937 if (Elt == -1) 938 OS << Separator << "undef"; 939 else 940 OS << Separator << Elt; 941 Separator = ", "; 942 } 943 944 OS << ')'; 945 break; 946 } 947 } 948 949 #if !defined(NDEBUG) || defined(LLVM_ENABLE_DUMP) 950 LLVM_DUMP_METHOD void MachineOperand::dump() const { dbgs() << *this << '\n'; } 951 #endif 952 953 //===----------------------------------------------------------------------===// 954 // MachineMemOperand Implementation 955 //===----------------------------------------------------------------------===// 956 957 /// getAddrSpace - Return the LLVM IR address space number that this pointer 958 /// points into. 959 unsigned MachinePointerInfo::getAddrSpace() const { return AddrSpace; } 960 961 /// isDereferenceable - Return true if V is always dereferenceable for 962 /// Offset + Size byte. 963 bool MachinePointerInfo::isDereferenceable(unsigned Size, LLVMContext &C, 964 const DataLayout &DL) const { 965 if (!V.is<const Value *>()) 966 return false; 967 968 const Value *BasePtr = V.get<const Value *>(); 969 if (BasePtr == nullptr) 970 return false; 971 972 return isDereferenceableAndAlignedPointer( 973 BasePtr, Align::None(), APInt(DL.getPointerSizeInBits(), Offset + Size), 974 DL); 975 } 976 977 /// getConstantPool - Return a MachinePointerInfo record that refers to the 978 /// constant pool. 979 MachinePointerInfo MachinePointerInfo::getConstantPool(MachineFunction &MF) { 980 return MachinePointerInfo(MF.getPSVManager().getConstantPool()); 981 } 982 983 /// getFixedStack - Return a MachinePointerInfo record that refers to the 984 /// the specified FrameIndex. 985 MachinePointerInfo MachinePointerInfo::getFixedStack(MachineFunction &MF, 986 int FI, int64_t Offset) { 987 return MachinePointerInfo(MF.getPSVManager().getFixedStack(FI), Offset); 988 } 989 990 MachinePointerInfo MachinePointerInfo::getJumpTable(MachineFunction &MF) { 991 return MachinePointerInfo(MF.getPSVManager().getJumpTable()); 992 } 993 994 MachinePointerInfo MachinePointerInfo::getGOT(MachineFunction &MF) { 995 return MachinePointerInfo(MF.getPSVManager().getGOT()); 996 } 997 998 MachinePointerInfo MachinePointerInfo::getStack(MachineFunction &MF, 999 int64_t Offset, uint8_t ID) { 1000 return MachinePointerInfo(MF.getPSVManager().getStack(), Offset, ID); 1001 } 1002 1003 MachinePointerInfo MachinePointerInfo::getUnknownStack(MachineFunction &MF) { 1004 return MachinePointerInfo(MF.getDataLayout().getAllocaAddrSpace()); 1005 } 1006 1007 MachineMemOperand::MachineMemOperand(MachinePointerInfo ptrinfo, Flags f, 1008 uint64_t s, uint64_t a, 1009 const AAMDNodes &AAInfo, 1010 const MDNode *Ranges, SyncScope::ID SSID, 1011 AtomicOrdering Ordering, 1012 AtomicOrdering FailureOrdering) 1013 : PtrInfo(ptrinfo), Size(s), FlagVals(f), BaseAlignLog2(Log2_32(a) + 1), 1014 AAInfo(AAInfo), Ranges(Ranges) { 1015 assert((PtrInfo.V.isNull() || PtrInfo.V.is<const PseudoSourceValue *>() || 1016 isa<PointerType>(PtrInfo.V.get<const Value *>()->getType())) && 1017 "invalid pointer value"); 1018 assert(getBaseAlignment() == a && a != 0 && "Alignment is not a power of 2!"); 1019 assert((isLoad() || isStore()) && "Not a load/store!"); 1020 1021 AtomicInfo.SSID = static_cast<unsigned>(SSID); 1022 assert(getSyncScopeID() == SSID && "Value truncated"); 1023 AtomicInfo.Ordering = static_cast<unsigned>(Ordering); 1024 assert(getOrdering() == Ordering && "Value truncated"); 1025 AtomicInfo.FailureOrdering = static_cast<unsigned>(FailureOrdering); 1026 assert(getFailureOrdering() == FailureOrdering && "Value truncated"); 1027 } 1028 1029 /// Profile - Gather unique data for the object. 1030 /// 1031 void MachineMemOperand::Profile(FoldingSetNodeID &ID) const { 1032 ID.AddInteger(getOffset()); 1033 ID.AddInteger(Size); 1034 ID.AddPointer(getOpaqueValue()); 1035 ID.AddInteger(getFlags()); 1036 ID.AddInteger(getBaseAlignment()); 1037 } 1038 1039 void MachineMemOperand::refineAlignment(const MachineMemOperand *MMO) { 1040 // The Value and Offset may differ due to CSE. But the flags and size 1041 // should be the same. 1042 assert(MMO->getFlags() == getFlags() && "Flags mismatch!"); 1043 assert(MMO->getSize() == getSize() && "Size mismatch!"); 1044 1045 if (MMO->getBaseAlignment() >= getBaseAlignment()) { 1046 // Update the alignment value. 1047 BaseAlignLog2 = Log2_32(MMO->getBaseAlignment()) + 1; 1048 // Also update the base and offset, because the new alignment may 1049 // not be applicable with the old ones. 1050 PtrInfo = MMO->PtrInfo; 1051 } 1052 } 1053 1054 /// getAlignment - Return the minimum known alignment in bytes of the 1055 /// actual memory reference. 1056 uint64_t MachineMemOperand::getAlignment() const { 1057 return MinAlign(getBaseAlignment(), getOffset()); 1058 } 1059 1060 void MachineMemOperand::print(raw_ostream &OS, ModuleSlotTracker &MST, 1061 SmallVectorImpl<StringRef> &SSNs, 1062 const LLVMContext &Context, 1063 const MachineFrameInfo *MFI, 1064 const TargetInstrInfo *TII) const { 1065 OS << '('; 1066 if (isVolatile()) 1067 OS << "volatile "; 1068 if (isNonTemporal()) 1069 OS << "non-temporal "; 1070 if (isDereferenceable()) 1071 OS << "dereferenceable "; 1072 if (isInvariant()) 1073 OS << "invariant "; 1074 if (getFlags() & MachineMemOperand::MOTargetFlag1) 1075 OS << '"' << getTargetMMOFlagName(*TII, MachineMemOperand::MOTargetFlag1) 1076 << "\" "; 1077 if (getFlags() & MachineMemOperand::MOTargetFlag2) 1078 OS << '"' << getTargetMMOFlagName(*TII, MachineMemOperand::MOTargetFlag2) 1079 << "\" "; 1080 if (getFlags() & MachineMemOperand::MOTargetFlag3) 1081 OS << '"' << getTargetMMOFlagName(*TII, MachineMemOperand::MOTargetFlag3) 1082 << "\" "; 1083 1084 assert((isLoad() || isStore()) && 1085 "machine memory operand must be a load or store (or both)"); 1086 if (isLoad()) 1087 OS << "load "; 1088 if (isStore()) 1089 OS << "store "; 1090 1091 printSyncScope(OS, Context, getSyncScopeID(), SSNs); 1092 1093 if (getOrdering() != AtomicOrdering::NotAtomic) 1094 OS << toIRString(getOrdering()) << ' '; 1095 if (getFailureOrdering() != AtomicOrdering::NotAtomic) 1096 OS << toIRString(getFailureOrdering()) << ' '; 1097 1098 if (getSize() == MemoryLocation::UnknownSize) 1099 OS << "unknown-size"; 1100 else 1101 OS << getSize(); 1102 1103 if (const Value *Val = getValue()) { 1104 OS << ((isLoad() && isStore()) ? " on " : isLoad() ? " from " : " into "); 1105 MIRFormatter::printIRValue(OS, *Val, MST); 1106 } else if (const PseudoSourceValue *PVal = getPseudoValue()) { 1107 OS << ((isLoad() && isStore()) ? " on " : isLoad() ? " from " : " into "); 1108 assert(PVal && "Expected a pseudo source value"); 1109 switch (PVal->kind()) { 1110 case PseudoSourceValue::Stack: 1111 OS << "stack"; 1112 break; 1113 case PseudoSourceValue::GOT: 1114 OS << "got"; 1115 break; 1116 case PseudoSourceValue::JumpTable: 1117 OS << "jump-table"; 1118 break; 1119 case PseudoSourceValue::ConstantPool: 1120 OS << "constant-pool"; 1121 break; 1122 case PseudoSourceValue::FixedStack: { 1123 int FrameIndex = cast<FixedStackPseudoSourceValue>(PVal)->getFrameIndex(); 1124 bool IsFixed = true; 1125 printFrameIndex(OS, FrameIndex, IsFixed, MFI); 1126 break; 1127 } 1128 case PseudoSourceValue::GlobalValueCallEntry: 1129 OS << "call-entry "; 1130 cast<GlobalValuePseudoSourceValue>(PVal)->getValue()->printAsOperand( 1131 OS, /*PrintType=*/false, MST); 1132 break; 1133 case PseudoSourceValue::ExternalSymbolCallEntry: 1134 OS << "call-entry &"; 1135 printLLVMNameWithoutPrefix( 1136 OS, cast<ExternalSymbolPseudoSourceValue>(PVal)->getSymbol()); 1137 break; 1138 default: { 1139 const MIRFormatter *Formatter = TII->getMIRFormatter(); 1140 // FIXME: This is not necessarily the correct MIR serialization format for 1141 // a custom pseudo source value, but at least it allows 1142 // -print-machineinstrs to work on a target with custom pseudo source 1143 // values. 1144 OS << "custom \""; 1145 Formatter->printCustomPseudoSourceValue(OS, MST, *PVal); 1146 OS << '\"'; 1147 break; 1148 } 1149 } 1150 } 1151 MachineOperand::printOperandOffset(OS, getOffset()); 1152 if (getBaseAlignment() != getSize()) 1153 OS << ", align " << getBaseAlignment(); 1154 auto AAInfo = getAAInfo(); 1155 if (AAInfo.TBAA) { 1156 OS << ", !tbaa "; 1157 AAInfo.TBAA->printAsOperand(OS, MST); 1158 } 1159 if (AAInfo.Scope) { 1160 OS << ", !alias.scope "; 1161 AAInfo.Scope->printAsOperand(OS, MST); 1162 } 1163 if (AAInfo.NoAlias) { 1164 OS << ", !noalias "; 1165 AAInfo.NoAlias->printAsOperand(OS, MST); 1166 } 1167 if (getRanges()) { 1168 OS << ", !range "; 1169 getRanges()->printAsOperand(OS, MST); 1170 } 1171 // FIXME: Implement addrspace printing/parsing in MIR. 1172 // For now, print this even though parsing it is not available in MIR. 1173 if (unsigned AS = getAddrSpace()) 1174 OS << ", addrspace " << AS; 1175 1176 OS << ')'; 1177 } 1178