aboutsummaryrefslogtreecommitdiffstats
path: root/include/llvm/CodeGen
diff options
context:
space:
mode:
authorAndrew Lenharth <alenhar2@cs.uiuc.edu>2008-02-21 06:45:13 +0000
committerAndrew Lenharth <alenhar2@cs.uiuc.edu>2008-02-21 06:45:13 +0000
commite44f390d1a02e4ab6beffd7e3a4178e0557cbc8a (patch)
tree3018e5189ff28d029084c130be6992796ec32e67 /include/llvm/CodeGen
parent58d032b16d90a5343811caf6ada67ac22343c91a (diff)
downloadexternal_llvm-e44f390d1a02e4ab6beffd7e3a4178e0557cbc8a.zip
external_llvm-e44f390d1a02e4ab6beffd7e3a4178e0557cbc8a.tar.gz
external_llvm-e44f390d1a02e4ab6beffd7e3a4178e0557cbc8a.tar.bz2
Atomic op support. If any gcc test uses __sync builtins, it might start failing on archs that haven't implemented them yet
git-svn-id: https://llvm.org/svn/llvm-project/llvm/trunk@47430 91177308-0d34-0410-b5e6-96231b3b80d8
Diffstat (limited to 'include/llvm/CodeGen')
-rw-r--r--include/llvm/CodeGen/SelectionDAG.h10
-rw-r--r--include/llvm/CodeGen/SelectionDAGNodes.h49
2 files changed, 57 insertions, 2 deletions
diff --git a/include/llvm/CodeGen/SelectionDAG.h b/include/llvm/CodeGen/SelectionDAG.h
index 22487dd..70c7185 100644
--- a/include/llvm/CodeGen/SelectionDAG.h
+++ b/include/llvm/CodeGen/SelectionDAG.h
@@ -356,6 +356,16 @@ public:
SDOperand getVAArg(MVT::ValueType VT, SDOperand Chain, SDOperand Ptr,
SDOperand SV);
+ /// getAtomic - Gets a node for an atomic op, produces result and chain, takes
+ // 3 operands
+ SDOperand getAtomic(unsigned Opcode, SDOperand Chain, SDOperand Ptr,
+ SDOperand A2, SDOperand A3, MVT::ValueType VT);
+
+ /// getAtomic - Gets a node for an atomic op, produces result and chain, takes
+ // 2 operands
+ SDOperand getAtomic(unsigned Opcode, SDOperand Chain, SDOperand Ptr,
+ SDOperand A2, MVT::ValueType VT);
+
/// getLoad - Loads are not normal binary operators: their result type is not
/// determined by their operands, and they produce a value AND a token chain.
///
diff --git a/include/llvm/CodeGen/SelectionDAGNodes.h b/include/llvm/CodeGen/SelectionDAGNodes.h
index c1a50bb..293bb73 100644
--- a/include/llvm/CodeGen/SelectionDAGNodes.h
+++ b/include/llvm/CodeGen/SelectionDAGNodes.h
@@ -441,7 +441,7 @@ namespace ISD {
// is added / subtracted from the base pointer to form the address (for
// indexed memory ops).
LOAD, STORE,
-
+
// DYNAMIC_STACKALLOC - Allocate some number of bytes on the stack aligned
// to a specified boundary. This node always has two return values: a new
// stack pointer value and a chain. The first operand is the token chain,
@@ -591,12 +591,30 @@ namespace ISD {
// OUTCHAIN = MEMBARRIER(INCHAIN, load-load, load-store, store-load,
// store-store, device)
- // This corresponds to the atomic.barrier intrinsic.
+ // This corresponds to the memory.barrier intrinsic.
// it takes an input chain, 4 operands to specify the type of barrier, an
// operand specifying if the barrier applies to device and uncached memory
// and produces an output chain.
MEMBARRIER,
+ // Val, OUTCHAIN = ATOMIC_LCS(INCHAIN, ptr, cmp, swap)
+ // this corresponds to the atomic.lcs intrinsic.
+ // cmp is compared to *ptr, and if equal, swap is stored in *ptr.
+ // the return is always the original value in *ptr
+ ATOMIC_LCS,
+
+ // Val, OUTCHAIN = ATOMIC_LAS(INCHAIN, ptr, amt)
+ // this corresponds to the atomic.las intrinsic.
+ // *ptr + amt is stored to *ptr atomically.
+ // the return is always the original value in *ptr
+ ATOMIC_LAS,
+
+ // Val, OUTCHAIN = ATOMIC_SWAP(INCHAIN, ptr, amt)
+ // this corresponds to the atomic.swap intrinsic.
+ // amt is stored to *ptr atomically.
+ // the return is always the original value in *ptr
+ ATOMIC_SWAP,
+
// BUILTIN_OP_END - This must be the last enum value in this list.
BUILTIN_OP_END
};
@@ -1170,6 +1188,33 @@ public:
SDOperand getValue() const { return Op; }
};
+class AtomicSDNode : public SDNode {
+ virtual void ANCHOR(); // Out-of-line virtual method to give class a home.
+ SDOperand Ops[4];
+ MVT::ValueType OrigVT;
+public:
+ AtomicSDNode(unsigned Opc, SDVTList VTL, SDOperand Chain, SDOperand X,
+ SDOperand Y, SDOperand Z, MVT::ValueType VT)
+ : SDNode(Opc, VTL) {
+ Ops[0] = Chain;
+ Ops[1] = X;
+ Ops[2] = Y;
+ Ops[3] = Z;
+ InitOperands(Ops, 4);
+ OrigVT=VT;
+ }
+ AtomicSDNode(unsigned Opc, SDVTList VTL, SDOperand Chain, SDOperand X,
+ SDOperand Y, MVT::ValueType VT)
+ : SDNode(Opc, VTL) {
+ Ops[0] = Chain;
+ Ops[1] = X;
+ Ops[2] = Y;
+ InitOperands(Ops, 3);
+ OrigVT=VT;
+ }
+ MVT::ValueType getVT() const { return OrigVT; }
+};
+
class StringSDNode : public SDNode {
std::string Value;
virtual void ANCHOR(); // Out-of-line virtual method to give class a home.