aboutsummaryrefslogtreecommitdiffstats
path: root/include
diff options
context:
space:
mode:
authorChristopher Lamb <christopher.lamb@gmail.com>2007-04-22 19:24:39 +0000
committerChristopher Lamb <christopher.lamb@gmail.com>2007-04-22 19:24:39 +0000
commit43c7f37942a35398fd1e14b22f435f483a0ee863 (patch)
tree7b5086671d5743f3187e8f8f3bc6d7fe1e507b39 /include
parentcb403d69fb620d4df66233d27a6f8c545ce0d0e4 (diff)
downloadexternal_llvm-43c7f37942a35398fd1e14b22f435f483a0ee863.zip
external_llvm-43c7f37942a35398fd1e14b22f435f483a0ee863.tar.gz
external_llvm-43c7f37942a35398fd1e14b22f435f483a0ee863.tar.bz2
PR400 work phase 1. Add attributed load/store instructions for volatile/align to LLVM.
git-svn-id: https://llvm.org/svn/llvm-project/llvm/trunk@36349 91177308-0d34-0410-b5e6-96231b3b80d8
Diffstat (limited to 'include')
-rw-r--r--include/llvm/Instructions.h44
1 files changed, 37 insertions, 7 deletions
diff --git a/include/llvm/Instructions.h b/include/llvm/Instructions.h
index 3a59e58..61d0efa 100644
--- a/include/llvm/Instructions.h
+++ b/include/llvm/Instructions.h
@@ -211,9 +211,11 @@ public:
/// SubclassData field in Value to store whether or not the load is volatile.
///
class LoadInst : public UnaryInstruction {
+
LoadInst(const LoadInst &LI)
: UnaryInstruction(LI.getType(), Load, LI.getOperand(0)) {
setVolatile(LI.isVolatile());
+ setAlignment(LI.getAlignment());
#ifndef NDEBUG
AssertOK();
@@ -223,14 +225,16 @@ class LoadInst : public UnaryInstruction {
public:
LoadInst(Value *Ptr, const std::string &Name, Instruction *InsertBefore);
LoadInst(Value *Ptr, const std::string &Name, BasicBlock *InsertAtEnd);
- LoadInst(Value *Ptr, const std::string &Name, bool isVolatile = false,
+ LoadInst(Value *Ptr, const std::string &Name, bool isVolatile = false,
+ Instruction *InsertBefore = 0);
+ LoadInst(Value *Ptr, const std::string &Name, bool isVolatile, unsigned Align,
Instruction *InsertBefore = 0);
LoadInst(Value *Ptr, const std::string &Name, bool isVolatile,
BasicBlock *InsertAtEnd);
LoadInst(Value *Ptr, const char *Name, Instruction *InsertBefore);
LoadInst(Value *Ptr, const char *Name, BasicBlock *InsertAtEnd);
- explicit LoadInst(Value *Ptr, const char *Name = 0, bool isVolatile = false,
+ explicit LoadInst(Value *Ptr, const char *Name = 0, bool isVolatile = false,
Instruction *InsertBefore = 0);
LoadInst(Value *Ptr, const char *Name, bool isVolatile,
BasicBlock *InsertAtEnd);
@@ -238,14 +242,25 @@ public:
/// isVolatile - Return true if this is a load from a volatile memory
/// location.
///
- bool isVolatile() const { return SubclassData; }
+ bool isVolatile() const { return SubclassData & 1; }
/// setVolatile - Specify whether this is a volatile load or not.
///
- void setVolatile(bool V) { SubclassData = V; }
+ void setVolatile(bool V) {
+ SubclassData = (SubclassData & ~1) | ((V) ? 1 : 0);
+ }
virtual LoadInst *clone() const;
+ /// getAlignment - Return the alignment of the access that is being performed
+ ///
+ unsigned getAlignment() const {
+ signed Log2AlignVal = ((SubclassData>>1)-1);
+ return ((Log2AlignVal < 0) ? 0 : 1<<Log2AlignVal);
+ }
+
+ void setAlignment(unsigned Align);
+
Value *getPointerOperand() { return getOperand(0); }
const Value *getPointerOperand() const { return getOperand(0); }
static unsigned getPointerOperandIndex() { return 0U; }
@@ -269,10 +284,13 @@ public:
///
class StoreInst : public Instruction {
Use Ops[2];
+
StoreInst(const StoreInst &SI) : Instruction(SI.getType(), Store, Ops, 2) {
Ops[0].init(SI.Ops[0], this);
Ops[1].init(SI.Ops[1], this);
setVolatile(SI.isVolatile());
+ setAlignment(SI.getAlignment());
+
#ifndef NDEBUG
AssertOK();
#endif
@@ -283,17 +301,21 @@ public:
StoreInst(Value *Val, Value *Ptr, BasicBlock *InsertAtEnd);
StoreInst(Value *Val, Value *Ptr, bool isVolatile = false,
Instruction *InsertBefore = 0);
+ StoreInst(Value *Val, Value *Ptr, bool isVolatile,
+ unsigned Align, Instruction *InsertBefore = 0);
StoreInst(Value *Val, Value *Ptr, bool isVolatile, BasicBlock *InsertAtEnd);
/// isVolatile - Return true if this is a load from a volatile memory
/// location.
///
- bool isVolatile() const { return SubclassData; }
+ bool isVolatile() const { return SubclassData & 1; }
/// setVolatile - Specify whether this is a volatile load or not.
///
- void setVolatile(bool V) { SubclassData = V; }
+ void setVolatile(bool V) {
+ SubclassData = (SubclassData & ~1) | ((V) ? 1 : 0);
+ }
/// Transparently provide more efficient getOperand methods.
Value *getOperand(unsigned i) const {
@@ -306,7 +328,15 @@ public:
}
unsigned getNumOperands() const { return 2; }
-
+ /// getAlignment - Return the alignment of the access that is being performed
+ ///
+ unsigned getAlignment() const {
+ signed Log2AlignVal = ((SubclassData>>1)-1);
+ return ((Log2AlignVal < 0) ? 0 : 1<<Log2AlignVal);
+ }
+
+ void setAlignment(unsigned Align);
+
virtual StoreInst *clone() const;
Value *getPointerOperand() { return getOperand(1); }