From 21006d40ac9ec7715bca2095451075a83773dc52 Mon Sep 17 00:00:00 2001 From: Eli Friedman Date: Tue, 9 Aug 2011 23:02:53 +0000 Subject: Representation of 'atomic load' and 'atomic store' in IR. git-svn-id: https://llvm.org/svn/llvm-project/llvm/trunk@137170 91177308-0d34-0410-b5e6-96231b3b80d8 --- lib/VMCore/AsmWriter.cpp | 30 ++++++++++++++++++++---------- 1 file changed, 20 insertions(+), 10 deletions(-) (limited to 'lib/VMCore/AsmWriter.cpp') diff --git a/lib/VMCore/AsmWriter.cpp b/lib/VMCore/AsmWriter.cpp index 442e8b8f7f..005f51aae3 100644 --- a/lib/VMCore/AsmWriter.cpp +++ b/lib/VMCore/AsmWriter.cpp @@ -1659,14 +1659,18 @@ void AssemblyWriter::printInstruction(const Instruction &I) { Out << '%' << SlotNum << " = "; } + // If this is an atomic load or store, print out the atomic marker. + if ((isa(I) && cast(I).isAtomic()) || + (isa(I) && cast(I).isAtomic())) + Out << "atomic "; + // If this is a volatile load or store, print out the volatile marker. if ((isa(I) && cast(I).isVolatile()) || - (isa(I) && cast(I).isVolatile())) { - Out << "volatile "; - } else if (isa(I) && cast(I).isTailCall()) { - // If this is a call, check if it's a tail call. + (isa(I) && cast(I).isVolatile())) + Out << "volatile "; + + if (isa(I) && cast(I).isTailCall()) Out << "tail "; - } // Print out the opcode... Out << I.getOpcodeName(); @@ -1913,11 +1917,17 @@ void AssemblyWriter::printInstruction(const Instruction &I) { } } - // Print post operand alignment for load/store. - if (isa(I) && cast(I).getAlignment()) { - Out << ", align " << cast(I).getAlignment(); - } else if (isa(I) && cast(I).getAlignment()) { - Out << ", align " << cast(I).getAlignment(); + // Print atomic ordering/alignment for memory operations + if (const LoadInst *LI = dyn_cast(&I)) { + if (LI->isAtomic()) + writeAtomic(LI->getOrdering(), LI->getSynchScope()); + if (LI->getAlignment()) + Out << ", align " << LI->getAlignment(); + } else if (const StoreInst *SI = dyn_cast(&I)) { + if (SI->isAtomic()) + writeAtomic(SI->getOrdering(), SI->getSynchScope()); + if (SI->getAlignment()) + Out << ", align " << SI->getAlignment(); } else if (const AtomicCmpXchgInst *CXI = dyn_cast(&I)) { writeAtomic(CXI->getOrdering(), CXI->getSynchScope()); } else if (const AtomicRMWInst *RMWI = dyn_cast(&I)) { -- cgit v1.2.3