diff options
author | Eli Friedman <eli.friedman@gmail.com> | 2008-06-13 23:01:12 +0000 |
---|---|---|
committer | Eli Friedman <eli.friedman@gmail.com> | 2008-06-13 23:01:12 +0000 |
commit | 1e692ace08959399794363e77499b73da5494af9 (patch) | |
tree | f3b2a525ece7b5a7ad2df5328e1d46db215aef4c /lib/CodeGen/CodeGenFunction.h | |
parent | ed6c70f63067ec06757aa019750765b80e23b423 (diff) |
Basic support for volatile loads and stores. Stores the volatile
qualifier in the lvalue, and changes lvalue loads/stores to honor
the volatile flag. Places which need some further attention are marked
with FIXMEs.
Patch by Cédric Venet.
git-svn-id: https://llvm.org/svn/llvm-project/cfe/trunk@52264 91177308-0d34-0410-b5e6-96231b3b80d8
Diffstat (limited to 'lib/CodeGen/CodeGenFunction.h')
-rw-r--r-- | lib/CodeGen/CodeGenFunction.h | 34 |
1 files changed, 27 insertions, 7 deletions
diff --git a/lib/CodeGen/CodeGenFunction.h b/lib/CodeGen/CodeGenFunction.h index 077a7bdbdc..313d2d1829 100644 --- a/lib/CodeGen/CodeGenFunction.h +++ b/lib/CodeGen/CodeGenFunction.h @@ -149,8 +149,7 @@ public: /// bitfields, this is not a simple LLVM pointer, it may be a pointer plus a /// bitrange. class LValue { - // FIXME: Volatility. Restrict? - // alignment? + // FIXME: alignment? enum { Simple, // This is a normal l-value, use getAddress(). @@ -174,12 +173,26 @@ class LValue { bool IsSigned; } BitfieldData; // BitField start bit and size }; + + bool Volatile:1; + // FIXME: set but never used, what effect should it have? + bool Restrict:1; + +private: + static void SetQualifiers(unsigned Qualifiers, LValue& R) { + R.Volatile = (Qualifiers&QualType::Volatile)!=0; + R.Restrict = (Qualifiers&QualType::Restrict)!=0; + } + public: bool isSimple() const { return LVType == Simple; } bool isVectorElt() const { return LVType == VectorElt; } bool isBitfield() const { return LVType == BitField; } bool isExtVectorElt() const { return LVType == ExtVectorElt; } + bool isVolatileQualified() const { return Volatile; } + bool isRestrictQualified() const { return Restrict; } + // simple lvalue llvm::Value *getAddress() const { assert(isSimple()); return V; } // vector elt lvalue @@ -206,37 +219,44 @@ public: return BitfieldData.IsSigned; } - static LValue MakeAddr(llvm::Value *V) { + static LValue MakeAddr(llvm::Value *V, unsigned Qualifiers) { LValue R; R.LVType = Simple; R.V = V; + SetQualifiers(Qualifiers,R); return R; } - static LValue MakeVectorElt(llvm::Value *Vec, llvm::Value *Idx) { + static LValue MakeVectorElt(llvm::Value *Vec, llvm::Value *Idx, + unsigned Qualifiers) { LValue R; R.LVType = VectorElt; R.V = Vec; R.VectorIdx = Idx; + SetQualifiers(Qualifiers,R); return R; } - static LValue MakeExtVectorElt(llvm::Value *Vec, llvm::Constant *Elts) { + static LValue MakeExtVectorElt(llvm::Value *Vec, llvm::Constant *Elts, + unsigned Qualifiers) { LValue R; R.LVType = ExtVectorElt; R.V = Vec; R.VectorElts = Elts; + SetQualifiers(Qualifiers,R); return R; } static LValue MakeBitfield(llvm::Value *V, unsigned short StartBit, - unsigned short Size, bool IsSigned) { + unsigned short Size, bool IsSigned, + unsigned Qualifiers) { LValue R; R.LVType = BitField; R.V = V; R.BitfieldData.StartBit = StartBit; R.BitfieldData.Size = Size; R.BitfieldData.IsSigned = IsSigned; + SetQualifiers(Qualifiers,R); return R; } }; @@ -440,7 +460,7 @@ public: LValue EmitCompoundLiteralLValue(const CompoundLiteralExpr *E); LValue EmitLValueForField(llvm::Value* Base, FieldDecl* Field, - bool isUnion); + bool isUnion, unsigned CVRQualifiers); LValue EmitObjCIvarRefLValue(const ObjCIvarRefExpr *E); //===--------------------------------------------------------------------===// |