# Changeset View

Changeset View

# Standalone View

Standalone View

# llvm/lib/Target/ARM/ARMISelDAGToDAG.cpp

Show First 20 Lines • Show All 140 Lines • ▼ Show 20 Line(s) | 57 | public: | |||
---|---|---|---|---|---|

141 | bool SelectThumbAddrModeSP(SDValue N, SDValue &Base, SDValue &OffImm); | 141 | bool SelectThumbAddrModeSP(SDValue N, SDValue &Base, SDValue &OffImm); | ||

142 | 142 | | |||

143 | // Thumb 2 Addressing Modes: | 143 | // Thumb 2 Addressing Modes: | ||

144 | bool SelectT2AddrModeImm12(SDValue N, SDValue &Base, SDValue &OffImm); | 144 | bool SelectT2AddrModeImm12(SDValue N, SDValue &Base, SDValue &OffImm); | ||

145 | bool SelectT2AddrModeImm8(SDValue N, SDValue &Base, | 145 | bool SelectT2AddrModeImm8(SDValue N, SDValue &Base, | ||

146 | SDValue &OffImm); | 146 | SDValue &OffImm); | ||

147 | bool SelectT2AddrModeImm8Offset(SDNode *Op, SDValue N, | 147 | bool SelectT2AddrModeImm8Offset(SDNode *Op, SDValue N, | ||

148 | SDValue &OffImm); | 148 | SDValue &OffImm); | ||

149 | template<unsigned Shift> | ||||

150 | bool SelectT2AddrModeImm7(SDValue N, SDValue &Base, | ||||

151 | SDValue &OffImm); | ||||

149 | bool SelectT2AddrModeSoReg(SDValue N, SDValue &Base, | 152 | bool SelectT2AddrModeSoReg(SDValue N, SDValue &Base, | ||

150 | SDValue &OffReg, SDValue &ShImm); | 153 | SDValue &OffReg, SDValue &ShImm); | ||

151 | bool SelectT2AddrModeExclusive(SDValue N, SDValue &Base, SDValue &OffImm); | 154 | bool SelectT2AddrModeExclusive(SDValue N, SDValue &Base, SDValue &OffImm); | ||

152 | 155 | | |||

153 | inline bool is_so_imm(unsigned Imm) const { | 156 | inline bool is_so_imm(unsigned Imm) const { | ||

154 | return ARM_AM::getSOImmVal(Imm) != -1; | 157 | return ARM_AM::getSOImmVal(Imm) != -1; | ||

155 | } | 158 | } | ||

156 | 159 | | |||

▲ Show 20 Lines • Show All 1106 Lines • ▼ Show 20 Line(s) | 1265 | OffImm = ((AM == ISD::PRE_INC) || (AM == ISD::POST_INC)) | |||

1263 | ? CurDAG->getTargetConstant(RHSC, SDLoc(N), MVT::i32) | 1266 | ? CurDAG->getTargetConstant(RHSC, SDLoc(N), MVT::i32) | ||

1264 | : CurDAG->getTargetConstant(-RHSC, SDLoc(N), MVT::i32); | 1267 | : CurDAG->getTargetConstant(-RHSC, SDLoc(N), MVT::i32); | ||

1265 | return true; | 1268 | return true; | ||

1266 | } | 1269 | } | ||

1267 | 1270 | | |||

1268 | return false; | 1271 | return false; | ||

1269 | } | 1272 | } | ||

1270 | 1273 | | |||

1274 | template<unsigned Shift> | ||||

1275 | bool ARMDAGToDAGISel::SelectT2AddrModeImm7(SDValue N, | ||||

1276 | SDValue &Base, SDValue &OffImm) { | ||||

1277 | if (N.getOpcode() == ISD::SUB || | ||||

1278 | CurDAG->isBaseWithConstantOffset(N)) { | ||||

1279 | if (auto RHS = dyn_cast<ConstantSDNode>(N.getOperand(1))) { | ||||

1280 | int RHSC = (int)RHS->getZExtValue(); | ||||

1281 | if (N.getOpcode() == ISD::SUB) | ||||

1282 | RHSC = -RHSC; | ||||

1283 | | ||||

1284 | if (isShiftedInt<7, Shift>(RHSC)) { | ||||

1285 | Base = N.getOperand(0); | ||||

1286 | if (Base.getOpcode() == ISD::FrameIndex) { | ||||

t.p.northover: I think this would be clearer if you used the `isInt<7>` functions from `MathExtras.h`. | |||||

1287 | int FI = cast<FrameIndexSDNode>(Base)->getIndex(); | ||||

1288 | Base = CurDAG->getTargetFrameIndex( | ||||

1289 | FI, TLI->getPointerTy(CurDAG->getDataLayout())); | ||||

1290 | } | ||||

1291 | OffImm = CurDAG->getTargetConstant(RHSC, SDLoc(N), MVT::i32); | ||||

1292 | return true; | ||||

1293 | } | ||||

1294 | } | ||||

1295 | } | ||||

1296 | | ||||

1297 | // Base only. | ||||

1298 | Base = N; | ||||

1299 | OffImm = CurDAG->getTargetConstant(0, SDLoc(N), MVT::i32); | ||||

1300 | return true; | ||||

1301 | } | ||||

1302 | | ||||

1271 | bool ARMDAGToDAGISel::SelectT2AddrModeSoReg(SDValue N, | 1303 | bool ARMDAGToDAGISel::SelectT2AddrModeSoReg(SDValue N, | ||

1272 | SDValue &Base, | 1304 | SDValue &Base, | ||

1273 | SDValue &OffReg, SDValue &ShImm) { | 1305 | SDValue &OffReg, SDValue &ShImm) { | ||

1274 | // (R - imm8) should be handled by t2LDRi8. The rest are handled by t2LDRi12. | 1306 | // (R - imm8) should be handled by t2LDRi8. The rest are handled by t2LDRi12. | ||

1275 | if (N.getOpcode() != ISD::ADD && !CurDAG->isBaseWithConstantOffset(N)) | 1307 | if (N.getOpcode() != ISD::ADD && !CurDAG->isBaseWithConstantOffset(N)) | ||

1276 | return false; | 1308 | return false; | ||

1277 | 1309 | | |||

1278 | // Leave (R + imm12) for t2LDRi12, (R - imm8) for t2LDRi8. | 1310 | // Leave (R + imm12) for t2LDRi12, (R - imm8) for t2LDRi8. | ||

▲ Show 20 Lines • Show All 3152 Lines • Show Last 20 Lines |

I think this would be clearer if you used the

isInt<7>functions fromMathExtras.h.