Index: include/llvm/IR/Instructions.h =================================================================== --- include/llvm/IR/Instructions.h +++ include/llvm/IR/Instructions.h @@ -735,6 +735,37 @@ return static_cast(getSubclassDataFromInstruction() >> 5); } + static StringRef getOperationName(BinOp Op) { + switch (Op) { + case AtomicRMWInst::Xchg: + return "xchg"; + case AtomicRMWInst::Add: + return "add"; + case AtomicRMWInst::Sub: + return "sub"; + case AtomicRMWInst::And: + return "and"; + case AtomicRMWInst::Nand: + return "nand"; + case AtomicRMWInst::Or: + return "or"; + case AtomicRMWInst::Xor: + return "xor"; + case AtomicRMWInst::Max: + return "max"; + case AtomicRMWInst::Min: + return "min"; + case AtomicRMWInst::UMax: + return "umax"; + case AtomicRMWInst::UMin: + return "umin"; + case AtomicRMWInst::BAD_BINOP: + return ""; + } + + llvm_unreachable("invalid atomicrmw operation"); + } + void setOperation(BinOp Operation) { unsigned short SubclassData = getSubclassDataFromInstruction(); setInstructionSubclassData((SubclassData & 31) | Index: lib/IR/AsmWriter.cpp =================================================================== --- lib/IR/AsmWriter.cpp +++ lib/IR/AsmWriter.cpp @@ -1217,24 +1217,6 @@ SlotTracker *Machine, const Module *Context, bool FromValue = false); -static void writeAtomicRMWOperation(raw_ostream &Out, - AtomicRMWInst::BinOp Op) { - switch (Op) { - default: Out << " "; break; - case AtomicRMWInst::Xchg: Out << " xchg"; break; - case AtomicRMWInst::Add: Out << " add"; break; - case AtomicRMWInst::Sub: Out << " sub"; break; - case AtomicRMWInst::And: Out << " and"; break; - case AtomicRMWInst::Nand: Out << " nand"; break; - case AtomicRMWInst::Or: Out << " or"; break; - case AtomicRMWInst::Xor: Out << " xor"; break; - case AtomicRMWInst::Max: Out << " max"; break; - case AtomicRMWInst::Min: Out << " min"; break; - case AtomicRMWInst::UMax: Out << " umax"; break; - case AtomicRMWInst::UMin: Out << " umin"; break; - } -} - static void WriteOptimizationInfo(raw_ostream &Out, const User *U) { if (const FPMathOperator *FPO = dyn_cast(U)) { // 'Fast' is an abbreviation for all fast-math-flags. @@ -3568,7 +3550,7 @@ // Print out the atomicrmw operation if (const AtomicRMWInst *RMWI = dyn_cast(&I)) - writeAtomicRMWOperation(Out, RMWI->getOperation()); + Out << ' ' << AtomicRMWInst::getOperationName(RMWI->getOperation()); // Print out the type of the operands... const Value *Operand = I.getNumOperands() ? I.getOperand(0) : nullptr;