diff options
author | Chris Lattner <sabre@nondot.org> | 2005-02-14 16:47:52 +0000 |
---|---|---|
committer | Chris Lattner <sabre@nondot.org> | 2005-02-14 16:47:52 +0000 |
commit | 9d30e22da0d6e59cab0813899adaf9e7c109cf5d (patch) | |
tree | cf93603d7bd7c574282de51077097634a4542e7b /lib | |
parent | ee6cfda17cbecc23ffe03739ed5946c30561570d (diff) | |
download | external_llvm-9d30e22da0d6e59cab0813899adaf9e7c109cf5d.zip external_llvm-9d30e22da0d6e59cab0813899adaf9e7c109cf5d.tar.gz external_llvm-9d30e22da0d6e59cab0813899adaf9e7c109cf5d.tar.bz2 |
Implement CodeGen/CBackend/2005-02-14-VolatileOperations.ll
Volatile loads and stores need to emit volatile pointer operations in C.
git-svn-id: https://llvm.org/svn/llvm-project/llvm/trunk@20177 91177308-0d34-0410-b5e6-96231b3b80d8
Diffstat (limited to 'lib')
-rw-r--r-- | lib/Target/CBackend/CBackend.cpp | 15 | ||||
-rw-r--r-- | lib/Target/CBackend/Writer.cpp | 15 |
2 files changed, 30 insertions, 0 deletions
diff --git a/lib/Target/CBackend/CBackend.cpp b/lib/Target/CBackend/CBackend.cpp index cb831ae..adac8e2 100644 --- a/lib/Target/CBackend/CBackend.cpp +++ b/lib/Target/CBackend/CBackend.cpp @@ -1655,12 +1655,27 @@ void CWriter::printIndexingExpression(Value *Ptr, gep_type_iterator I, void CWriter::visitLoadInst(LoadInst &I) { Out << "*"; + if (I.isVolatile()) { + Out << "((volatile "; + printType(Out, I.getOperand(0)->getType()); + Out << ")"; + } + writeOperand(I.getOperand(0)); + + if (I.isVolatile()) + Out << ")"; } void CWriter::visitStoreInst(StoreInst &I) { Out << "*"; + if (I.isVolatile()) { + Out << "((volatile "; + printType(Out, I.getPointerOperand()->getType()); + Out << ")"; + } writeOperand(I.getPointerOperand()); + if (I.isVolatile()) Out << ")"; Out << " = "; writeOperand(I.getOperand(0)); } diff --git a/lib/Target/CBackend/Writer.cpp b/lib/Target/CBackend/Writer.cpp index cb831ae..adac8e2 100644 --- a/lib/Target/CBackend/Writer.cpp +++ b/lib/Target/CBackend/Writer.cpp @@ -1655,12 +1655,27 @@ void CWriter::printIndexingExpression(Value *Ptr, gep_type_iterator I, void CWriter::visitLoadInst(LoadInst &I) { Out << "*"; + if (I.isVolatile()) { + Out << "((volatile "; + printType(Out, I.getOperand(0)->getType()); + Out << ")"; + } + writeOperand(I.getOperand(0)); + + if (I.isVolatile()) + Out << ")"; } void CWriter::visitStoreInst(StoreInst &I) { Out << "*"; + if (I.isVolatile()) { + Out << "((volatile "; + printType(Out, I.getPointerOperand()->getType()); + Out << ")"; + } writeOperand(I.getPointerOperand()); + if (I.isVolatile()) Out << ")"; Out << " = "; writeOperand(I.getOperand(0)); } |