@@ -405,10 +405,6 @@ const char *DPUTargetLowering::getTargetNodeName(unsigned Opcode) const {
405
405
switch (Opcode) {
406
406
default :
407
407
return nullptr ;
408
- case DPUISD::SEQREAD_GET:
409
- return " DPUISD::SEQREAD_GET" ;
410
- case DPUISD::SEQREAD_GET_CST:
411
- return " DPUISD::SEQREAD_GET_CST" ;
412
408
case DPUISD::LHU_BIG:
413
409
return " DPUISD::LHU_BIG" ;
414
410
case DPUISD::LHS_BIG:
@@ -1848,15 +1844,13 @@ SDValue DPUTargetLowering::LowerShift(SDValue Op, SelectionDAG &DAG,
1848
1844
}
1849
1845
}
1850
1846
1851
- static uint64_t FormatDMASize (uint64_t size) { return (size >> 3 ) - 1 ; }
1852
-
1853
1847
SDValue DPUTargetLowering::LowerDMAUnchecked (
1854
1848
SelectionDAG &DAG, const SDLoc &dl, const EVT &evt, SDValue Chain,
1855
1849
SDValue ra, SDValue rb, SDValue Size, bool CanFetchConstant,
1856
1850
uint64_t Length, int DPUISD) const {
1857
1851
1858
1852
if (CanFetchConstant) {
1859
- Size = DAG.getConstant (FormatDMASize (Length) , dl, MVT::i32 );
1853
+ Size = DAG.getConstant ((Length >> 3 ) - 1 , dl, MVT::i32 );
1860
1854
} else {
1861
1855
const EVT &raVT = ra.getValueType ();
1862
1856
// to + (((nb_of_bytes >> 3) - 1) << 24);
@@ -1907,71 +1901,6 @@ SDValue DPUTargetLowering::LowerDMA(SDValue Op, SelectionDAG &DAG,
1907
1901
CanFetchConstant, size, DPUISD);
1908
1902
}
1909
1903
1910
- static uint64_t PageSizeLog2ToNcCondition (uint64_t pageSize) {
1911
- switch (pageSize) {
1912
- case 5 :
1913
- return DPUAsmCondition::NotCarry5;
1914
- case 6 :
1915
- return DPUAsmCondition::NotCarry6;
1916
- case 7 :
1917
- return DPUAsmCondition::NotCarry7;
1918
- case 8 :
1919
- return DPUAsmCondition::NotCarry8;
1920
- case 9 :
1921
- return DPUAsmCondition::NotCarry9;
1922
- case 10 :
1923
- return DPUAsmCondition::NotCarry10;
1924
- case 11 :
1925
- return DPUAsmCondition::NotCarry11;
1926
- case 12 :
1927
- return DPUAsmCondition::NotCarry12;
1928
- case 13 :
1929
- return DPUAsmCondition::NotCarry13;
1930
- case 14 :
1931
- return DPUAsmCondition::NotCarry14;
1932
- default :
1933
- return DPUAsmCondition::NR_CONDITIONS;
1934
- }
1935
- }
1936
-
1937
- SDValue DPUTargetLowering::LowerSeqreadGet (SDValue Op,
1938
- SelectionDAG &DAG) const {
1939
- SDLoc dl (Op);
1940
- SDValue incValue = Op.getOperand (3 );
1941
- SDValue pageSizeValue = Op.getOperand (5 );
1942
- uint64_t pageSize, pageSizeLog2, inc;
1943
- if (!canFetchConstantTo (pageSizeValue, &pageSize)) {
1944
- LowerUnsupported (
1945
- Op, DAG, " NC only apply on constant and staticaly defined page size" );
1946
- }
1947
- pageSizeLog2 = (uint64_t )log2 ((double )pageSize);
1948
- if (pageSize != ((uint64_t )pow (2 , (double )pageSizeLog2)) ||
1949
- pageSizeLog2 < 5 || pageSizeLog2 > 14 ) {
1950
- LowerUnsupported (
1951
- Op, DAG,
1952
- " NC only apply on a page size of a power of 2 in range [64;32768]" );
1953
- }
1954
-
1955
- int Opcode = DPUISD::SEQREAD_GET;
1956
- SDValue cond =
1957
- DAG.getConstant (PageSizeLog2ToNcCondition (pageSizeLog2), dl, MVT::i32 );
1958
- if (canFetchConstantTo (incValue, &inc) && (inc > 0 ) && (inc < 128 )) {
1959
- Opcode = DPUISD::SEQREAD_GET_CST;
1960
- incValue = DAG.getConstant (inc, dl, MVT::i32 );
1961
- }
1962
-
1963
- SmallVector<EVT, 2 > ResTys;
1964
-
1965
- for (SDNode::value_iterator I = Op->value_begin (), E = Op->value_end ();
1966
- I != E; ++I)
1967
- ResTys.push_back (*I);
1968
-
1969
- SDValue Ops[] = {
1970
- Op.getOperand (0 ), Op.getOperand (2 ), incValue, Op.getOperand (4 ), cond,
1971
- pageSizeValue};
1972
- return DAG.getNode (Opcode, dl, ResTys, Ops);
1973
- }
1974
-
1975
1904
SDValue DPUTargetLowering::LowerIntrinsic (SDValue Op, SelectionDAG &DAG,
1976
1905
int IntrinsicType) const {
1977
1906
SDLoc dl (Op);
@@ -1992,12 +1921,6 @@ SDValue DPUTargetLowering::LowerIntrinsic(SDValue Op, SelectionDAG &DAG,
1992
1921
}
1993
1922
break ;
1994
1923
case ISD::INTRINSIC_W_CHAIN:
1995
- switch (cast<ConstantSDNode>(Op->getOperand (1 ))->getZExtValue ()) {
1996
- case Intrinsic::dpu_seqread_get: {
1997
- result = LowerSeqreadGet (Op, DAG);
1998
- break ;
1999
- }
2000
- }
2001
1924
break ;
2002
1925
case ISD::INTRINSIC_VOID:
2003
1926
switch (cast<ConstantSDNode>(Op->getOperand (1 ))->getZExtValue ()) {
@@ -3134,92 +3057,12 @@ static MachineBasicBlock *EmitClz64WithCustomInserter(MachineInstr &MI,
3134
3057
return endMBB;
3135
3058
}
3136
3059
3137
- static MachineBasicBlock *EmitSeqreadGet (MachineInstr &MI,
3138
- MachineBasicBlock *BB, bool IsIncCst) {
3139
- const TargetInstrInfo &TII = *BB->getParent ()->getSubtarget ().getInstrInfo ();
3140
- DebugLoc dl = MI.getDebugLoc ();
3141
- const BasicBlock *LLVM_BB = BB->getBasicBlock ();
3142
- MachineFunction::iterator I = ++BB->getIterator ();
3143
- MachineFunction *F = BB->getParent ();
3144
- MachineBasicBlock *slowMBB = F->CreateMachineBasicBlock (LLVM_BB);
3145
- MachineBasicBlock *fastMBB = F->CreateMachineBasicBlock (LLVM_BB);
3146
- F->insert (I, slowMBB);
3147
- F->insert (I, fastMBB);
3148
- // Update machine-CFG edges by transferring all successors of the current
3149
- // block to the new block which will contain the Phi node for the select.
3150
- fastMBB->splice (fastMBB->begin (), BB,
3151
- std::next (MachineBasicBlock::iterator (MI)), BB->end ());
3152
- fastMBB->transferSuccessorsAndUpdatePHIs (BB);
3153
- // Next, add the true and fallthrough blocks as its successors.
3154
- BB->addSuccessor (slowMBB);
3155
- BB->addSuccessor (fastMBB);
3156
- slowMBB->addSuccessor (fastMBB);
3157
-
3158
- unsigned int Dest = MI.getOperand (0 ).getReg ();
3159
- unsigned int PtrInit = MI.getOperand (1 ).getReg ();
3160
- unsigned int Reader = MI.getOperand (3 ).getReg ();
3161
- unsigned int Cond = MI.getOperand (4 ).getImm ();
3162
- unsigned int PageSize = MI.getOperand (5 ).getImm ();
3163
-
3164
- MachineRegisterInfo &RI = F->getRegInfo ();
3165
- unsigned int PtrIncremented = RI.createVirtualRegister (&DPU::GP_REGRegClass);
3166
-
3167
- if (IsIncCst) {
3168
- BuildMI (BB, dl, TII.get (DPU::ADDrrici), PtrIncremented)
3169
- .addReg (PtrInit)
3170
- .addImm (MI.getOperand (2 ).getImm ())
3171
- .addImm (Cond)
3172
- .addMBB (fastMBB);
3173
- } else {
3174
- BuildMI (BB, dl, TII.get (DPU::ADDrrrci), PtrIncremented)
3175
- .addReg (PtrInit)
3176
- .addReg (MI.getOperand (2 ).getReg ())
3177
- .addImm (Cond)
3178
- .addMBB (fastMBB);
3179
- }
3180
-
3181
- unsigned int WramCache = RI.createVirtualRegister (&DPU::GP_REGRegClass);
3182
- unsigned int MramCache = RI.createVirtualRegister (&DPU::GP_REGRegClass);
3183
- unsigned int MramCacheUpdated =
3184
- RI.createVirtualRegister (&DPU::GP_REGRegClass);
3185
- unsigned int PtrUpdated = RI.createVirtualRegister (&DPU::GP_REGRegClass);
3186
- BuildMI (slowMBB, dl, TII.get (DPU::LWrri), MramCache).addReg (Reader).addImm (4 );
3187
- BuildMI (slowMBB, dl, TII.get (DPU::ADDrri), MramCacheUpdated)
3188
- .addReg (MramCache)
3189
- .addImm (PageSize);
3190
- BuildMI (slowMBB, dl, TII.get (DPU::SWrir))
3191
- .addReg (Reader)
3192
- .addImm (4 )
3193
- .addReg (MramCacheUpdated);
3194
- BuildMI (slowMBB, dl, TII.get (DPU::LWrri), WramCache).addReg (Reader).addImm (0 );
3195
- BuildMI (slowMBB, dl, TII.get (DPU::LDMArri))
3196
- .addReg (WramCache)
3197
- .addReg (MramCacheUpdated)
3198
- .addImm (FormatDMASize (PageSize * 2 ));
3199
- BuildMI (slowMBB, dl, TII.get (DPU::ADDrri), PtrUpdated)
3200
- .addReg (PtrIncremented)
3201
- .addImm (-PageSize);
3202
-
3203
- BuildMI (*fastMBB, fastMBB->begin (), dl, TII.get (TargetOpcode::PHI), Dest)
3204
- .addReg (PtrIncremented)
3205
- .addMBB (BB)
3206
- .addReg (PtrUpdated)
3207
- .addMBB (slowMBB);
3208
-
3209
- MI.eraseFromParent (); // The pseudo instruction is gone now.
3210
- return fastMBB;
3211
- }
3212
-
3213
3060
MachineBasicBlock *
3214
3061
DPUTargetLowering::EmitInstrWithCustomInserter (MachineInstr &MI,
3215
3062
MachineBasicBlock *BB) const {
3216
3063
switch (MI.getOpcode ()) {
3217
3064
default :
3218
3065
llvm_unreachable (" Unexpected instr type to insert" );
3219
- case DPU::SEQREAD_GET:
3220
- return EmitSeqreadGet (MI, BB, false );
3221
- case DPU::SEQREAD_GET_CST:
3222
- return EmitSeqreadGet (MI, BB, true );
3223
3066
case DPU::Mul16UUrr:
3224
3067
return EmitMul16WithCustomInserter (MI, BB, DPU::MUL_UL_ULrrrci,
3225
3068
DPU::MUL_UH_ULrrr, DPU::MUL_UH_ULrrr,
0 commit comments