llvm.org GIT mirror llvm / 5d159ad
[GISel]: Add pattern matchers for G_BITCAST/PTRTOINT/INTTOPTR Adds pattern matchers for the above along with unit tests for the same. https://reviews.llvm.org/D43479 git-svn-id: https://llvm.org/svn/llvm-project/llvm/trunk@325542 91177308-0d34-0410-b5e6-96231b3b80d8 Aditya Nandakumar 2 years ago
2 changed file(s) with 32 addition(s) and 0 deletion(s). Raw diff Collapse all Expand all
262262 }
263263
264264 template
265 inline UnaryOp_match
266 m_GBitcast(const SrcTy &Src) {
267 return UnaryOp_match(Src);
268 }
269
270 template
271 inline UnaryOp_match
272 m_GPtrToInt(const SrcTy &Src) {
273 return UnaryOp_match(Src);
274 }
275
276 template
277 inline UnaryOp_match
278 m_GIntToPtr(const SrcTy &Src) {
279 return UnaryOp_match(Src);
280 }
281
282 template
265283 inline UnaryOp_match
266284 m_GFPTrunc(const SrcTy &Src) {
267285 return UnaryOp_match(Src);
313313 LLT v2s32 = LLT::vector(2, 32);
314314 auto MIBCast = B.buildCast(v2s32, Copies[0]);
315315 ASSERT_TRUE(
316 mi_match(MIBCast->getOperand(0).getReg(), MRI, m_GBitcast(m_Reg())));
317 ASSERT_TRUE(
316318 mi_match(MIBCast->getOperand(0).getReg(), MRI, m_SpecificType(v2s32)));
317319 ASSERT_TRUE(
318320 mi_match(MIBCast->getOperand(1).getReg(), MRI, m_SpecificType(s64)));
321
322 // Build a PTRToInt and INTTOPTR and match and test them.
323 LLT PtrTy = LLT::pointer(0, 64);
324 auto MIBIntToPtr = B.buildCast(PtrTy, Copies[0]);
325 auto MIBPtrToInt = B.buildCast(s64, MIBIntToPtr);
326 unsigned Src0;
327
328 // match the ptrtoint(inttoptr reg)
329 bool match = mi_match(MIBPtrToInt->getOperand(0).getReg(), MRI,
330 m_GPtrToInt(m_GIntToPtr(m_Reg(Src0))));
331 ASSERT_TRUE(match);
332 ASSERT_EQ(Src0, Copies[0]);
319333 }
320334
321335 TEST(PatternMatchInstr, MatchCombinators) {