Skip to content

Commit b6dbda3

Browse files
committed
add m68k isel support for non-ARI atomic loads/stores
1 parent eabda06 commit b6dbda3

File tree

2 files changed

+21
-2
lines changed

2 files changed

+21
-2
lines changed

llvm/lib/Target/M68k/M68kISelDAGToDAG.cpp

Lines changed: 14 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -772,6 +772,19 @@ static bool isAddressBase(const SDValue &N) {
772772
}
773773
}
774774

775+
static bool AllowARIIWithZeroDisp(SDNode *Parent) {
776+
if (!Parent) return false;
777+
switch (Parent->getOpcode()) {
778+
case ISD::LOAD:
779+
case ISD::STORE:
780+
case ISD::ATOMIC_LOAD:
781+
case ISD::ATOMIC_STORE:
782+
return true;
783+
default:
784+
return false;
785+
}
786+
}
787+
775788
bool M68kDAGToDAGISel::SelectARII(SDNode *Parent, SDValue N, SDValue &Disp,
776789
SDValue &Base, SDValue &Index) {
777790
M68kISelAddressMode AM(M68kISelAddressMode::AddrType::ARII);
@@ -811,8 +824,7 @@ bool M68kDAGToDAGISel::SelectARII(SDNode *Parent, SDValue N, SDValue &Disp,
811824
// The idea here is that we want to use AddrType::ARII without displacement
812825
// only if necessary like memory operations, otherwise this must be lowered
813826
// into addition
814-
if (AM.Disp == 0 && (!Parent || (Parent->getOpcode() != ISD::LOAD &&
815-
Parent->getOpcode() != ISD::STORE))) {
827+
if (AM.Disp == 0 && !AllowARIIWithZeroDisp(Parent)) {
816828
LLVM_DEBUG(dbgs() << "REJECT: Displacement is Zero\n");
817829
return false;
818830
}

llvm/lib/Target/M68k/M68kInstrAtomics.td

Lines changed: 7 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -10,9 +10,16 @@ foreach size = [8, 16, 32] in {
1010
def : Pat<(!cast<SDPatternOperator>("atomic_load_"#size) MxCP_ARI:$ptr),
1111
(!cast<MxInst>("MOV"#size#"dj") !cast<MxMemOp>("MxARI"#size):$ptr)>;
1212

13+
def : Pat<(!cast<SDPatternOperator>("atomic_load_"#size) MxCP_ARII:$ptr),
14+
(!cast<MxInst>("MOV"#size#"df") !cast<MxMemOp>("MxARII"#size):$ptr)>;
15+
1316
def : Pat<(!cast<SDPatternOperator>("atomic_store_"#size) !cast<MxRegOp>("MxDRD"#size):$val, MxCP_ARI:$ptr),
1417
(!cast<MxInst>("MOV"#size#"jd") !cast<MxMemOp>("MxARI"#size):$ptr,
1518
!cast<MxRegOp>("MxDRD"#size):$val)>;
19+
20+
def : Pat<(!cast<SDPatternOperator>("atomic_store_"#size) !cast<MxRegOp>("MxDRD"#size):$val, MxCP_ARII:$ptr),
21+
(!cast<MxInst>("MOV"#size#"fd") !cast<MxMemOp>("MxARII"#size):$ptr,
22+
!cast<MxRegOp>("MxDRD"#size):$val)>;
1623
}
1724

1825
let Predicates = [AtLeastM68020] in {

0 commit comments

Comments
 (0)