llvm.org GIT mirror llvm / 2c2c51b
IR: Move AtomicRMW string names into class This will be used to improve error messages in a future commit. git-svn-id: https://llvm.org/svn/llvm-project/llvm/trunk@343647 91177308-0d34-0410-b5e6-96231b3b80d8 Matt Arsenault 1 year, 11 days ago
3 changed file(s) with 34 addition(s) and 19 deletion(s). Raw diff Collapse all Expand all
734734 return static_cast(getSubclassDataFromInstruction() >> 5);
735735 }
736736
737 static StringRef getOperationName(BinOp Op);
738
737739 void setOperation(BinOp Operation) {
738740 unsigned short SubclassData = getSubclassDataFromInstruction();
739741 setInstructionSubclassData((SubclassData & 31) |
12401240 SlotTracker *Machine, const Module *Context,
12411241 bool FromValue = false);
12421242
1243 static void writeAtomicRMWOperation(raw_ostream &Out,
1244 AtomicRMWInst::BinOp Op) {
1245 switch (Op) {
1246 default: Out << " "; break;
1247 case AtomicRMWInst::Xchg: Out << " xchg"; break;
1248 case AtomicRMWInst::Add: Out << " add"; break;
1249 case AtomicRMWInst::Sub: Out << " sub"; break;
1250 case AtomicRMWInst::And: Out << " and"; break;
1251 case AtomicRMWInst::Nand: Out << " nand"; break;
1252 case AtomicRMWInst::Or: Out << " or"; break;
1253 case AtomicRMWInst::Xor: Out << " xor"; break;
1254 case AtomicRMWInst::Max: Out << " max"; break;
1255 case AtomicRMWInst::Min: Out << " min"; break;
1256 case AtomicRMWInst::UMax: Out << " umax"; break;
1257 case AtomicRMWInst::UMin: Out << " umin"; break;
1258 }
1259 }
1260
12611243 static void WriteOptimizationInfo(raw_ostream &Out, const User *U) {
12621244 if (const FPMathOperator *FPO = dyn_cast(U)) {
12631245 // 'Fast' is an abbreviation for all fast-math-flags.
36113593
36123594 // Print out the atomicrmw operation
36133595 if (const AtomicRMWInst *RMWI = dyn_cast(&I))
3614 writeAtomicRMWOperation(Out, RMWI->getOperation());
3596 Out << ' ' << AtomicRMWInst::getOperationName(RMWI->getOperation());
36153597
36163598 // Print out the type of the operands...
36173599 const Value *Operand = I.getNumOperands() ? I.getOperand(0) : nullptr;
13331333 OperandTraits::operands(this),
13341334 InsertAtEnd) {
13351335 Init(Operation, Ptr, Val, Ordering, SSID);
1336 }
1337
1338 StringRef AtomicRMWInst::getOperationName(BinOp Op) {
1339 switch (Op) {
1340 case AtomicRMWInst::Xchg:
1341 return "xchg";
1342 case AtomicRMWInst::Add:
1343 return "add";
1344 case AtomicRMWInst::Sub:
1345 return "sub";
1346 case AtomicRMWInst::And:
1347 return "and";
1348 case AtomicRMWInst::Nand:
1349 return "nand";
1350 case AtomicRMWInst::Or:
1351 return "or";
1352 case AtomicRMWInst::Xor:
1353 return "xor";
1354 case AtomicRMWInst::Max:
1355 return "max";
1356 case AtomicRMWInst::Min:
1357 return "min";
1358 case AtomicRMWInst::UMax:
1359 return "umax";
1360 case AtomicRMWInst::UMin:
1361 return "umin";
1362 case AtomicRMWInst::BAD_BINOP:
1363 return "";
1364 }
1365
1366 llvm_unreachable("invalid atomicrmw operation");
13361367 }
13371368
13381369 //===----------------------------------------------------------------------===//