Implement CodeGen/CBackend/2005-02-14-VolatileOperations.ll
authorChris Lattner <sabre@nondot.org>
Mon, 14 Feb 2005 16:47:52 +0000 (16:47 +0000)
committerChris Lattner <sabre@nondot.org>
Mon, 14 Feb 2005 16:47:52 +0000 (16:47 +0000)
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

lib/Target/CBackend/CBackend.cpp
lib/Target/CBackend/Writer.cpp

index cb831ae5d54151fe6924065315a6c448e37d8679..adac8e2f334b7c6ac97fcd92b00c525a960590ca 100644 (file)
@@ -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));
 }
index cb831ae5d54151fe6924065315a6c448e37d8679..adac8e2f334b7c6ac97fcd92b00c525a960590ca 100644 (file)
@@ -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));
 }