1
0
mirror of https://github.com/RPCS3/llvm-mirror.git synced 2024-10-19 19:12:56 +02:00

IR: Move AtomicRMW string names into class

This will be used to improve error messages in a future commit.

llvm-svn: 343647
This commit is contained in:
Matt Arsenault 2018-10-02 23:44:11 +00:00
parent c3aeae17d1
commit bec02cb2e5
3 changed files with 34 additions and 19 deletions

View File

@ -735,6 +735,8 @@ public:
return static_cast<BinOp>(getSubclassDataFromInstruction() >> 5);
}
static StringRef getOperationName(BinOp Op);
void setOperation(BinOp Operation) {
unsigned short SubclassData = getSubclassDataFromInstruction();
setInstructionSubclassData((SubclassData & 31) |

View File

@ -1241,24 +1241,6 @@ static void WriteAsOperandInternal(raw_ostream &Out, const Metadata *MD,
SlotTracker *Machine, const Module *Context,
bool FromValue = false);
static void writeAtomicRMWOperation(raw_ostream &Out,
AtomicRMWInst::BinOp Op) {
switch (Op) {
default: Out << " <unknown operation " << Op << ">"; 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<const FPMathOperator>(U)) {
// 'Fast' is an abbreviation for all fast-math-flags.
@ -3612,7 +3594,7 @@ void AssemblyWriter::printInstruction(const Instruction &I) {
// Print out the atomicrmw operation
if (const AtomicRMWInst *RMWI = dyn_cast<AtomicRMWInst>(&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;

View File

@ -1336,6 +1336,37 @@ AtomicRMWInst::AtomicRMWInst(BinOp Operation, Value *Ptr, Value *Val,
Init(Operation, Ptr, Val, Ordering, SSID);
}
StringRef AtomicRMWInst::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 "<invalid operation>";
}
llvm_unreachable("invalid atomicrmw operation");
}
//===----------------------------------------------------------------------===//
// FenceInst Implementation
//===----------------------------------------------------------------------===//