[llvm-commits] CVS: llvm/include/llvm/iMemory.h

Chris Lattner lattner at cs.uiuc.edu
Mon Sep 8 12:47:05 PDT 2003


Changes in directory llvm/include/llvm:

iMemory.h updated: 1.38 -> 1.39

---
Log message:

Add support for volatile loads/stores



---
Diffs of the changes:

Index: llvm/include/llvm/iMemory.h
diff -u llvm/include/llvm/iMemory.h:1.38 llvm/include/llvm/iMemory.h:1.39
--- llvm/include/llvm/iMemory.h:1.38	Mon Feb 24 14:48:28 2003
+++ llvm/include/llvm/iMemory.h	Mon Sep  8 12:45:59 2003
@@ -1,7 +1,7 @@
-//===-- llvm/iMemory.h - Memory Operator node definitions --------*- C++ -*--=//
+//===-- llvm/iMemory.h - Memory Operator node definitions -------*- C++ -*-===//
 //
 // This file contains the declarations of all of the memory related operators.
-// This includes: malloc, free, alloca, load, store, getfield, putfield
+// This includes: malloc, free, alloca, load, store, and getelementptr
 //
 //===----------------------------------------------------------------------===//
 
@@ -139,13 +139,24 @@
 
 class LoadInst : public Instruction {
   LoadInst(const LoadInst &LI) : Instruction(LI.getType(), Load) {
+    Volatile = LI.isVolatile();
     Operands.reserve(1);
     Operands.push_back(Use(LI.Operands[0], this));
   }
+  bool Volatile;   // True if this is a volatile load
 public:
-  LoadInst(Value *Ptr, const std::string &Name = "",
+  LoadInst(Value *Ptr, const std::string &Name, Instruction *InsertBefore);
+  LoadInst(Value *Ptr, const std::string &Name = "", bool isVolatile = false,
            Instruction *InsertBefore = 0);
 
+  /// isVolatile - Return true if this is a load from a volatile memory
+  /// location.
+  bool isVolatile() const { return Volatile; }
+
+  /// setVolatile - Specify whether this is a volatile load or not.
+  ///
+  void setVolatile(bool V) { Volatile = V; }
+
   virtual Instruction *clone() const { return new LoadInst(*this); }
 
   Value *getPointerOperand() { return getOperand(0); }
@@ -155,7 +166,7 @@
   // Methods for support type inquiry through isa, cast, and dyn_cast:
   static inline bool classof(const LoadInst *) { return true; }
   static inline bool classof(const Instruction *I) {
-    return (I->getOpcode() == Instruction::Load);
+    return I->getOpcode() == Instruction::Load;
   }
   static inline bool classof(const Value *V) {
     return isa<Instruction>(V) && classof(cast<Instruction>(V));
@@ -169,12 +180,26 @@
 
 class StoreInst : public Instruction {
   StoreInst(const StoreInst &SI) : Instruction(SI.getType(), Store) {
+    Volatile = SI.isVolatile();
     Operands.reserve(2);
     Operands.push_back(Use(SI.Operands[0], this));
     Operands.push_back(Use(SI.Operands[1], this));
   }
+  bool Volatile;   // True if this is a volatile store
 public:
-  StoreInst(Value *Val, Value *Ptr, Instruction *InsertBefore = 0);
+  StoreInst(Value *Val, Value *Ptr, Instruction *InsertBefore);
+  StoreInst(Value *Val, Value *Ptr, bool isVolatile = false,
+            Instruction *InsertBefore = 0);
+
+
+  /// isVolatile - Return true if this is a load from a volatile memory
+  /// location.
+  bool isVolatile() const { return Volatile; }
+
+  /// setVolatile - Specify whether this is a volatile load or not.
+  ///
+  void setVolatile(bool V) { Volatile = V; }
+
   virtual Instruction *clone() const { return new StoreInst(*this); }
 
   virtual bool mayWriteToMemory() const { return true; }
@@ -186,7 +211,7 @@
   // Methods for support type inquiry through isa, cast, and dyn_cast:
   static inline bool classof(const StoreInst *) { return true; }
   static inline bool classof(const Instruction *I) {
-    return (I->getOpcode() == Instruction::Store);
+    return I->getOpcode() == Instruction::Store;
   }
   static inline bool classof(const Value *V) {
     return isa<Instruction>(V) && classof(cast<Instruction>(V));





More information about the llvm-commits mailing list