mirror of
https://github.com/c64scene-ar/llvm-6502.git
synced 2024-12-15 20:29:48 +00:00
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
This commit is contained in:
parent
6b3ae4638b
commit
331120b1a4
@ -2971,7 +2971,7 @@ void SelectionDAGLegalize::ExpandNode(SDNode *Node,
|
||||
}
|
||||
case ISD::ATOMIC_LOAD: {
|
||||
// There is no libcall for atomic load; fake it with ATOMIC_CMP_SWAP.
|
||||
SDValue Zero = DAG.getConstant(0, cast<AtomicSDNode>(Node)->getMemoryVT());
|
||||
SDValue Zero = DAG.getConstant(0, Node->getValueType(0));
|
||||
SDValue Swap = DAG.getAtomic(ISD::ATOMIC_CMP_SWAP, dl,
|
||||
cast<AtomicSDNode>(Node)->getMemoryVT(),
|
||||
Node->getOperand(0),
|
||||
|
@ -116,6 +116,9 @@ void DAGTypeLegalizer::PromoteIntegerResult(SDNode *N, unsigned ResNo) {
|
||||
case ISD::SMULO:
|
||||
case ISD::UMULO: Res = PromoteIntRes_XMULO(N, ResNo); break;
|
||||
|
||||
case ISD::ATOMIC_LOAD:
|
||||
Res = PromoteIntRes_Atomic0(cast<AtomicSDNode>(N)); break;
|
||||
|
||||
case ISD::ATOMIC_LOAD_ADD:
|
||||
case ISD::ATOMIC_LOAD_SUB:
|
||||
case ISD::ATOMIC_LOAD_AND:
|
||||
@ -157,6 +160,19 @@ SDValue DAGTypeLegalizer::PromoteIntRes_AssertZext(SDNode *N) {
|
||||
Op.getValueType(), Op, N->getOperand(1));
|
||||
}
|
||||
|
||||
SDValue DAGTypeLegalizer::PromoteIntRes_Atomic0(AtomicSDNode *N) {
|
||||
EVT ResVT = TLI.getTypeToTransformTo(*DAG.getContext(), N->getValueType(0));
|
||||
SDValue Res = DAG.getAtomic(N->getOpcode(), N->getDebugLoc(),
|
||||
N->getMemoryVT(), ResVT,
|
||||
N->getChain(), N->getBasePtr(),
|
||||
N->getMemOperand(), N->getOrdering(),
|
||||
N->getSynchScope());
|
||||
// Legalized the chain result - switch anything that used the old chain to
|
||||
// use the new one.
|
||||
ReplaceValueWith(SDValue(N, 1), Res.getValue(1));
|
||||
return Res;
|
||||
}
|
||||
|
||||
SDValue DAGTypeLegalizer::PromoteIntRes_Atomic1(AtomicSDNode *N) {
|
||||
SDValue Op2 = GetPromotedInteger(N->getOperand(2));
|
||||
SDValue Res = DAG.getAtomic(N->getOpcode(), N->getDebugLoc(),
|
||||
@ -726,6 +742,9 @@ bool DAGTypeLegalizer::PromoteIntegerOperand(SDNode *N, unsigned OpNo) {
|
||||
llvm_unreachable("Do not know how to promote this operator's operand!");
|
||||
|
||||
case ISD::ANY_EXTEND: Res = PromoteIntOp_ANY_EXTEND(N); break;
|
||||
case ISD::ATOMIC_STORE:
|
||||
Res = PromoteIntOp_ATOMIC_STORE(cast<AtomicSDNode>(N));
|
||||
break;
|
||||
case ISD::BITCAST: Res = PromoteIntOp_BITCAST(N); break;
|
||||
case ISD::BR_CC: Res = PromoteIntOp_BR_CC(N, OpNo); break;
|
||||
case ISD::BRCOND: Res = PromoteIntOp_BRCOND(N, OpNo); break;
|
||||
@ -811,6 +830,13 @@ SDValue DAGTypeLegalizer::PromoteIntOp_ANY_EXTEND(SDNode *N) {
|
||||
return DAG.getNode(ISD::ANY_EXTEND, N->getDebugLoc(), N->getValueType(0), Op);
|
||||
}
|
||||
|
||||
SDValue DAGTypeLegalizer::PromoteIntOp_ATOMIC_STORE(AtomicSDNode *N) {
|
||||
SDValue Op2 = GetPromotedInteger(N->getOperand(2));
|
||||
return DAG.getAtomic(N->getOpcode(), N->getDebugLoc(), N->getMemoryVT(),
|
||||
N->getChain(), N->getBasePtr(), Op2, N->getMemOperand(),
|
||||
N->getOrdering(), N->getSynchScope());
|
||||
}
|
||||
|
||||
SDValue DAGTypeLegalizer::PromoteIntOp_BITCAST(SDNode *N) {
|
||||
// This should only occur in unusual situations like bitcasting to an
|
||||
// x86_fp80, so just turn it into a store+load
|
||||
|
@ -216,6 +216,7 @@ private:
|
||||
SDValue PromoteIntRes_MERGE_VALUES(SDNode *N);
|
||||
SDValue PromoteIntRes_AssertSext(SDNode *N);
|
||||
SDValue PromoteIntRes_AssertZext(SDNode *N);
|
||||
SDValue PromoteIntRes_Atomic0(AtomicSDNode *N);
|
||||
SDValue PromoteIntRes_Atomic1(AtomicSDNode *N);
|
||||
SDValue PromoteIntRes_Atomic2(AtomicSDNode *N);
|
||||
SDValue PromoteIntRes_EXTRACT_SUBVECTOR(SDNode *N);
|
||||
@ -258,6 +259,7 @@ private:
|
||||
// Integer Operand Promotion.
|
||||
bool PromoteIntegerOperand(SDNode *N, unsigned OperandNo);
|
||||
SDValue PromoteIntOp_ANY_EXTEND(SDNode *N);
|
||||
SDValue PromoteIntOp_ATOMIC_STORE(AtomicSDNode *N);
|
||||
SDValue PromoteIntOp_BITCAST(SDNode *N);
|
||||
SDValue PromoteIntOp_BUILD_PAIR(SDNode *N);
|
||||
SDValue PromoteIntOp_BR_CC(SDNode *N, unsigned OpNo);
|
||||
|
@ -30,3 +30,12 @@ define i32 @test2(i32* %ptr) {
|
||||
%val = load atomic i32* %ptr seq_cst, align 4
|
||||
ret i32 %val
|
||||
}
|
||||
|
||||
define void @test3(i8* %ptr1, i8* %ptr2) {
|
||||
; ARM: test3
|
||||
; ARM: ldrb
|
||||
; ARM: strb
|
||||
%val = load atomic i8* %ptr1 unordered, align 1
|
||||
store atomic i8 %val, i8* %ptr2 unordered, align 1
|
||||
ret void
|
||||
}
|
||||
|
Loading…
Reference in New Issue
Block a user