diff options
author | Dan Gohman <gohman@apple.com> | 2008-12-23 21:37:04 +0000 |
---|---|---|
committer | Dan Gohman <gohman@apple.com> | 2008-12-23 21:37:04 +0000 |
commit | 0b1d4a798d1dd2f39521b6b381cd1c1911c9ab52 (patch) | |
tree | b3edf8b330ceaee6b098e99f138410a59887cbc9 /lib/CodeGen/SelectionDAG/SelectionDAGBuild.cpp | |
parent | 9cf8ef63c62b0c8865bc4febd45c83e9965b34f2 (diff) |
Clean up the atomic opcodes in SelectionDAG.
This removes all the _8, _16, _32, and _64 opcodes and replaces each
group with an unsuffixed opcode. The MemoryVT field of the AtomicSDNode
is now used to carry the size information. In tablegen, the size-specific
opcodes are replaced by size-independent opcodes that utilize the
ability to compose them with predicates.
This shrinks the per-opcode tables and makes the code that handles
atomics much more concise.
git-svn-id: https://llvm.org/svn/llvm-project/llvm/trunk@61389 91177308-0d34-0410-b5e6-96231b3b80d8
Diffstat (limited to 'lib/CodeGen/SelectionDAG/SelectionDAGBuild.cpp')
-rw-r--r-- | lib/CodeGen/SelectionDAG/SelectionDAGBuild.cpp | 206 |
1 files changed, 25 insertions, 181 deletions
diff --git a/lib/CodeGen/SelectionDAG/SelectionDAGBuild.cpp b/lib/CodeGen/SelectionDAG/SelectionDAGBuild.cpp index 853e0549f7..920cca4ea4 100644 --- a/lib/CodeGen/SelectionDAG/SelectionDAGBuild.cpp +++ b/lib/CodeGen/SelectionDAG/SelectionDAGBuild.cpp @@ -2959,10 +2959,12 @@ getF32Constant(SelectionDAG &DAG, unsigned Flt) { const char * SelectionDAGLowering::implVisitBinaryAtomic(CallInst& I, ISD::NodeType Op) { SDValue Root = getRoot(); - SDValue L = DAG.getAtomic(Op, Root, - getValue(I.getOperand(1)), - getValue(I.getOperand(2)), - I.getOperand(1)); + SDValue L = + DAG.getAtomic(Op, getValue(I.getOperand(2)).getValueType().getSimpleVT(), + Root, + getValue(I.getOperand(1)), + getValue(I.getOperand(2)), + I.getOperand(1)); setValue(&I, L); DAG.setRoot(L.getValue(1)); return 0; @@ -4145,198 +4147,40 @@ SelectionDAGLowering::visitIntrinsicCall(CallInst &I, unsigned Intrinsic) { } case Intrinsic::atomic_cmp_swap: { SDValue Root = getRoot(); - SDValue L; - switch (getValue(I.getOperand(2)).getValueType().getSimpleVT()) { - case MVT::i8: - L = DAG.getAtomic(ISD::ATOMIC_CMP_SWAP_8, Root, - getValue(I.getOperand(1)), - getValue(I.getOperand(2)), - getValue(I.getOperand(3)), - I.getOperand(1)); - break; - case MVT::i16: - L = DAG.getAtomic(ISD::ATOMIC_CMP_SWAP_16, Root, - getValue(I.getOperand(1)), - getValue(I.getOperand(2)), - getValue(I.getOperand(3)), - I.getOperand(1)); - break; - case MVT::i32: - L = DAG.getAtomic(ISD::ATOMIC_CMP_SWAP_32, Root, - getValue(I.getOperand(1)), - getValue(I.getOperand(2)), - getValue(I.getOperand(3)), - I.getOperand(1)); - break; - case MVT::i64: - L = DAG.getAtomic(ISD::ATOMIC_CMP_SWAP_64, Root, - getValue(I.getOperand(1)), - getValue(I.getOperand(2)), - getValue(I.getOperand(3)), - I.getOperand(1)); - break; - default: - assert(0 && "Invalid atomic type"); - abort(); - } + SDValue L = + DAG.getAtomic(ISD::ATOMIC_CMP_SWAP, + getValue(I.getOperand(2)).getValueType().getSimpleVT(), + Root, + getValue(I.getOperand(1)), + getValue(I.getOperand(2)), + getValue(I.getOperand(3)), + I.getOperand(1)); setValue(&I, L); DAG.setRoot(L.getValue(1)); return 0; } case Intrinsic::atomic_load_add: - switch (getValue(I.getOperand(2)).getValueType().getSimpleVT()) { - case MVT::i8: - return implVisitBinaryAtomic(I, ISD::ATOMIC_LOAD_ADD_8); - case MVT::i16: - return implVisitBinaryAtomic(I, ISD::ATOMIC_LOAD_ADD_16); - case MVT::i32: - return implVisitBinaryAtomic(I, ISD::ATOMIC_LOAD_ADD_32); - case MVT::i64: - return implVisitBinaryAtomic(I, ISD::ATOMIC_LOAD_ADD_64); - default: - assert(0 && "Invalid atomic type"); - abort(); - } + return implVisitBinaryAtomic(I, ISD::ATOMIC_LOAD_ADD); case Intrinsic::atomic_load_sub: - switch (getValue(I.getOperand(2)).getValueType().getSimpleVT()) { - case MVT::i8: - return implVisitBinaryAtomic(I, ISD::ATOMIC_LOAD_SUB_8); - case MVT::i16: - return implVisitBinaryAtomic(I, ISD::ATOMIC_LOAD_SUB_16); - case MVT::i32: - return implVisitBinaryAtomic(I, ISD::ATOMIC_LOAD_SUB_32); - case MVT::i64: - return implVisitBinaryAtomic(I, ISD::ATOMIC_LOAD_SUB_64); - default: - assert(0 && "Invalid atomic type"); - abort(); - } + return implVisitBinaryAtomic(I, ISD::ATOMIC_LOAD_SUB); case Intrinsic::atomic_load_or: - switch (getValue(I.getOperand(2)).getValueType().getSimpleVT()) { - case MVT::i8: - return implVisitBinaryAtomic(I, ISD::ATOMIC_LOAD_OR_8); - case MVT::i16: - return implVisitBinaryAtomic(I, ISD::ATOMIC_LOAD_OR_16); - case MVT::i32: - return implVisitBinaryAtomic(I, ISD::ATOMIC_LOAD_OR_32); - case MVT::i64: - return implVisitBinaryAtomic(I, ISD::ATOMIC_LOAD_OR_64); - default: - assert(0 && "Invalid atomic type"); - abort(); - } + return implVisitBinaryAtomic(I, ISD::ATOMIC_LOAD_OR); case Intrinsic::atomic_load_xor: - switch (getValue(I.getOperand(2)).getValueType().getSimpleVT()) { - case MVT::i8: - return implVisitBinaryAtomic(I, ISD::ATOMIC_LOAD_XOR_8); - case MVT::i16: - return implVisitBinaryAtomic(I, ISD::ATOMIC_LOAD_XOR_16); - case MVT::i32: - return implVisitBinaryAtomic(I, ISD::ATOMIC_LOAD_XOR_32); - case MVT::i64: - return implVisitBinaryAtomic(I, ISD::ATOMIC_LOAD_XOR_64); - default: - assert(0 && "Invalid atomic type"); - abort(); - } + return implVisitBinaryAtomic(I, ISD::ATOMIC_LOAD_XOR); case Intrinsic::atomic_load_and: - switch (getValue(I.getOperand(2)).getValueType().getSimpleVT()) { - case MVT::i8: - return implVisitBinaryAtomic(I, ISD::ATOMIC_LOAD_AND_8); - case MVT::i16: - return implVisitBinaryAtomic(I, ISD::ATOMIC_LOAD_AND_16); - case MVT::i32: - return implVisitBinaryAtomic(I, ISD::ATOMIC_LOAD_AND_32); - case MVT::i64: - return implVisitBinaryAtomic(I, ISD::ATOMIC_LOAD_AND_64); - default: - assert(0 && "Invalid atomic type"); - abort(); - } + return implVisitBinaryAtomic(I, ISD::ATOMIC_LOAD_AND); case Intrinsic::atomic_load_nand: - switch (getValue(I.getOperand(2)).getValueType().getSimpleVT()) { - case MVT::i8: - return implVisitBinaryAtomic(I, ISD::ATOMIC_LOAD_NAND_8); - case MVT::i16: - return implVisitBinaryAtomic(I, ISD::ATOMIC_LOAD_NAND_16); - case MVT::i32: - return implVisitBinaryAtomic(I, ISD::ATOMIC_LOAD_NAND_32); - case MVT::i64: - return implVisitBinaryAtomic(I, ISD::ATOMIC_LOAD_NAND_64); - default: - assert(0 && "Invalid atomic type"); - abort(); - } + return implVisitBinaryAtomic(I, ISD::ATOMIC_LOAD_NAND); case Intrinsic::atomic_load_max: - switch (getValue(I.getOperand(2)).getValueType().getSimpleVT()) { - case MVT::i8: - return implVisitBinaryAtomic(I, ISD::ATOMIC_LOAD_MAX_8); - case MVT::i16: - return implVisitBinaryAtomic(I, ISD::ATOMIC_LOAD_MAX_16); - case MVT::i32: - return implVisitBinaryAtomic(I, ISD::ATOMIC_LOAD_MAX_32); - case MVT::i64: - return implVisitBinaryAtomic(I, ISD::ATOMIC_LOAD_MAX_64); - default: - assert(0 && "Invalid atomic type"); - abort(); - } + return implVisitBinaryAtomic(I, ISD::ATOMIC_LOAD_MAX); case Intrinsic::atomic_load_min: - switch (getValue(I.getOperand(2)).getValueType().getSimpleVT()) { - case MVT::i8: - return implVisitBinaryAtomic(I, ISD::ATOMIC_LOAD_MIN_8); - case MVT::i16: - return implVisitBinaryAtomic(I, ISD::ATOMIC_LOAD_MIN_16); - case MVT::i32: - return implVisitBinaryAtomic(I, ISD::ATOMIC_LOAD_MIN_32); - case MVT::i64: - return implVisitBinaryAtomic(I, ISD::ATOMIC_LOAD_MIN_64); - default: - assert(0 && "Invalid atomic type"); - abort(); - } + return implVisitBinaryAtomic(I, ISD::ATOMIC_LOAD_MIN); case Intrinsic::atomic_load_umin: - switch (getValue(I.getOperand(2)).getValueType().getSimpleVT()) { - case MVT::i8: - return implVisitBinaryAtomic(I, ISD::ATOMIC_LOAD_UMIN_8); - case MVT::i16: - return implVisitBinaryAtomic(I, ISD::ATOMIC_LOAD_UMIN_16); - case MVT::i32: - return implVisitBinaryAtomic(I, ISD::ATOMIC_LOAD_UMIN_32); - case MVT::i64: - return implVisitBinaryAtomic(I, ISD::ATOMIC_LOAD_UMIN_64); - default: - assert(0 && "Invalid atomic type"); - abort(); - } + return implVisitBinaryAtomic(I, ISD::ATOMIC_LOAD_UMIN); case Intrinsic::atomic_load_umax: - switch (getValue(I.getOperand(2)).getValueType().getSimpleVT()) { - case MVT::i8: - return implVisitBinaryAtomic(I, ISD::ATOMIC_LOAD_UMAX_8); - case MVT::i16: - return implVisitBinaryAtomic(I, ISD::ATOMIC_LOAD_UMAX_16); - case MVT::i32: - return implVisitBinaryAtomic(I, ISD::ATOMIC_LOAD_UMAX_32); - case MVT::i64: - return implVisitBinaryAtomic(I, ISD::ATOMIC_LOAD_UMAX_64); - default: - assert(0 && "Invalid atomic type"); - abort(); - } + return implVisitBinaryAtomic(I, ISD::ATOMIC_LOAD_UMAX); case Intrinsic::atomic_swap: - switch (getValue(I.getOperand(2)).getValueType().getSimpleVT()) { - case MVT::i8: - return implVisitBinaryAtomic(I, ISD::ATOMIC_SWAP_8); - case MVT::i16: - return implVisitBinaryAtomic(I, ISD::ATOMIC_SWAP_16); - case MVT::i32: - return implVisitBinaryAtomic(I, ISD::ATOMIC_SWAP_32); - case MVT::i64: - return implVisitBinaryAtomic(I, ISD::ATOMIC_SWAP_64); - default: - assert(0 && "Invalid atomic type"); - abort(); - } + return implVisitBinaryAtomic(I, ISD::ATOMIC_SWAP); } } |