llvm.org GIT mirror llvm / 331120b
Some legalization fixes for atomic load and store. git-svn-id: https://llvm.org/svn/llvm-project/llvm/trunk@139851 91177308-0d34-0410-b5e6-96231b3b80d8 Eli Friedman 8 years ago
4 changed file(s) with 38 addition(s) and 1 deletion(s). Raw diff Collapse all Expand all
29702970 }
29712971 case ISD::ATOMIC_LOAD: {
29722972 // There is no libcall for atomic load; fake it with ATOMIC_CMP_SWAP.
2973 SDValue Zero = DAG.getConstant(0, cast(Node)->getMemoryVT());
2973 SDValue Zero = DAG.getConstant(0, Node->getValueType(0));
29742974 SDValue Swap = DAG.getAtomic(ISD::ATOMIC_CMP_SWAP, dl,
29752975 cast(Node)->getMemoryVT(),
29762976 Node->getOperand(0),
115115 case ISD::SMULO:
116116 case ISD::UMULO: Res = PromoteIntRes_XMULO(N, ResNo); break;
117117
118 case ISD::ATOMIC_LOAD:
119 Res = PromoteIntRes_Atomic0(cast(N)); break;
120
118121 case ISD::ATOMIC_LOAD_ADD:
119122 case ISD::ATOMIC_LOAD_SUB:
120123 case ISD::ATOMIC_LOAD_AND:
154157 SDValue Op = ZExtPromotedInteger(N->getOperand(0));
155158 return DAG.getNode(ISD::AssertZext, N->getDebugLoc(),
156159 Op.getValueType(), Op, N->getOperand(1));
160 }
161
162 SDValue DAGTypeLegalizer::PromoteIntRes_Atomic0(AtomicSDNode *N) {
163 EVT ResVT = TLI.getTypeToTransformTo(*DAG.getContext(), N->getValueType(0));
164 SDValue Res = DAG.getAtomic(N->getOpcode(), N->getDebugLoc(),
165 N->getMemoryVT(), ResVT,
166 N->getChain(), N->getBasePtr(),
167 N->getMemOperand(), N->getOrdering(),
168 N->getSynchScope());
169 // Legalized the chain result - switch anything that used the old chain to
170 // use the new one.
171 ReplaceValueWith(SDValue(N, 1), Res.getValue(1));
172 return Res;
157173 }
158174
159175 SDValue DAGTypeLegalizer::PromoteIntRes_Atomic1(AtomicSDNode *N) {
725741 llvm_unreachable("Do not know how to promote this operator's operand!");
726742
727743 case ISD::ANY_EXTEND: Res = PromoteIntOp_ANY_EXTEND(N); break;
744 case ISD::ATOMIC_STORE:
745 Res = PromoteIntOp_ATOMIC_STORE(cast(N));
746 break;
728747 case ISD::BITCAST: Res = PromoteIntOp_BITCAST(N); break;
729748 case ISD::BR_CC: Res = PromoteIntOp_BR_CC(N, OpNo); break;
730749 case ISD::BRCOND: Res = PromoteIntOp_BRCOND(N, OpNo); break;
808827 SDValue DAGTypeLegalizer::PromoteIntOp_ANY_EXTEND(SDNode *N) {
809828 SDValue Op = GetPromotedInteger(N->getOperand(0));
810829 return DAG.getNode(ISD::ANY_EXTEND, N->getDebugLoc(), N->getValueType(0), Op);
830 }
831
832 SDValue DAGTypeLegalizer::PromoteIntOp_ATOMIC_STORE(AtomicSDNode *N) {
833 SDValue Op2 = GetPromotedInteger(N->getOperand(2));
834 return DAG.getAtomic(N->getOpcode(), N->getDebugLoc(), N->getMemoryVT(),
835 N->getChain(), N->getBasePtr(), Op2, N->getMemOperand(),
836 N->getOrdering(), N->getSynchScope());
811837 }
812838
813839 SDValue DAGTypeLegalizer::PromoteIntOp_BITCAST(SDNode *N) {
215215 SDValue PromoteIntRes_MERGE_VALUES(SDNode *N);
216216 SDValue PromoteIntRes_AssertSext(SDNode *N);
217217 SDValue PromoteIntRes_AssertZext(SDNode *N);
218 SDValue PromoteIntRes_Atomic0(AtomicSDNode *N);
218219 SDValue PromoteIntRes_Atomic1(AtomicSDNode *N);
219220 SDValue PromoteIntRes_Atomic2(AtomicSDNode *N);
220221 SDValue PromoteIntRes_EXTRACT_SUBVECTOR(SDNode *N);
257258 // Integer Operand Promotion.
258259 bool PromoteIntegerOperand(SDNode *N, unsigned OperandNo);
259260 SDValue PromoteIntOp_ANY_EXTEND(SDNode *N);
261 SDValue PromoteIntOp_ATOMIC_STORE(AtomicSDNode *N);
260262 SDValue PromoteIntOp_BITCAST(SDNode *N);
261263 SDValue PromoteIntOp_BUILD_PAIR(SDNode *N);
262264 SDValue PromoteIntOp_BR_CC(SDNode *N, unsigned OpNo);
2929 %val = load atomic i32* %ptr seq_cst, align 4
3030 ret i32 %val
3131 }
32
33 define void @test3(i8* %ptr1, i8* %ptr2) {
34 ; ARM: test3
35 ; ARM: ldrb
36 ; ARM: strb
37 %val = load atomic i8* %ptr1 unordered, align 1
38 store atomic i8 %val, i8* %ptr2 unordered, align 1
39 ret void
40 }