llvm.org GIT mirror llvm / ed22c23
[globalisel][tablegen] Add support for extload. git-svn-id: https://llvm.org/svn/llvm-project/llvm/trunk@318068 91177308-0d34-0410-b5e6-96231b3b80d8 Daniel Sanders 1 year, 11 months ago
2 changed file(s) with 36 addition(s) and 14 deletion(s). Raw diff Collapse all Expand all
3232
3333 define void @sextload_s32_from_s16(i16 *%addr) { ret void }
3434 define void @zextload_s32_from_s16(i16 *%addr) { ret void }
35 define void @aextload_s32_from_s16(i16 *%addr) { ret void }
3536 ...
3637
3738 ---
9495 ; CHECK-LABEL: name: load_s16_gpr
9596 ; CHECK: [[COPY:%[0-9]+]]:gpr64sp = COPY %x0
9697 ; CHECK: [[LDRHHui:%[0-9]+]]:gpr32 = LDRHHui [[COPY]], 0 :: (load 2 from %ir.addr)
97 ; CHECK: [[COPY1:%[0-9]+]]:gpr32all = COPY [[LDRHHui]]
98 ; CHECK: %w0 = COPY [[COPY1]]
98 ; CHECK: %w0 = COPY [[LDRHHui]]
9999 %0(p0) = COPY %x0
100100 %1(s16) = G_LOAD %0 :: (load 2 from %ir.addr)
101101 %2:gpr(s32) = G_ANYEXT %1
118118 ; CHECK-LABEL: name: load_s8_gpr
119119 ; CHECK: [[COPY:%[0-9]+]]:gpr64sp = COPY %x0
120120 ; CHECK: [[LDRBBui:%[0-9]+]]:gpr32 = LDRBBui [[COPY]], 0 :: (load 1 from %ir.addr)
121 ; CHECK: [[COPY1:%[0-9]+]]:gpr32all = COPY [[LDRBBui]]
122 ; CHECK: %w0 = COPY [[COPY1]]
121 ; CHECK: %w0 = COPY [[LDRBBui]]
123122 %0(p0) = COPY %x0
124123 %1(s8) = G_LOAD %0 :: (load 1 from %ir.addr)
125124 %2:gpr(s32) = G_ANYEXT %1
220219 ; CHECK-LABEL: name: load_gep_64_s16_gpr
221220 ; CHECK: [[COPY:%[0-9]+]]:gpr64sp = COPY %x0
222221 ; CHECK: [[LDRHHui:%[0-9]+]]:gpr32 = LDRHHui [[COPY]], 32 :: (load 2 from %ir.addr)
223 ; CHECK: [[COPY1:%[0-9]+]]:gpr32all = COPY [[LDRHHui]]
224 ; CHECK: %w0 = COPY [[COPY1]]
222 ; CHECK: %w0 = COPY [[LDRHHui]]
225223 %0(p0) = COPY %x0
226224 %1(s64) = G_CONSTANT i64 64
227225 %2(p0) = G_GEP %0, %1
248246 ; CHECK-LABEL: name: load_gep_1_s8_gpr
249247 ; CHECK: [[COPY:%[0-9]+]]:gpr64sp = COPY %x0
250248 ; CHECK: [[LDRBBui:%[0-9]+]]:gpr32 = LDRBBui [[COPY]], 1 :: (load 1 from %ir.addr)
251 ; CHECK: [[COPY1:%[0-9]+]]:gpr32all = COPY [[LDRBBui]]
252 ; CHECK: %w0 = COPY [[COPY1]]
249 ; CHECK: %w0 = COPY [[LDRBBui]]
253250 %0(p0) = COPY %x0
254251 %1(s64) = G_CONSTANT i64 1
255252 %2(p0) = G_GEP %0, %1
507504 %2:gpr(s32) = G_ZEXT %1
508505 %w0 = COPY %2(s32)
509506 ...
507
508 ---
509 name: aextload_s32_from_s16
510 legalized: true
511 regBankSelected: true
512
513 body: |
514 bb.0:
515 liveins: %w0
516
517 ; CHECK-LABEL: name: aextload_s32_from_s16
518 ; CHECK: [[COPY:%[0-9]+]]:gpr64sp = COPY %x0
519 ; CHECK: [[T0:%[0-9]+]]:gpr32 = LDRHHui [[COPY]], 0 :: (load 2 from %ir.addr)
520 ; CHECK: %w0 = COPY [[T0]]
521 %0:gpr(p0) = COPY %x0
522 %1:gpr(s16) = G_LOAD %0 :: (load 2 from %ir.addr)
523 %2:gpr(s32) = G_ANYEXT %1
524 %w0 = COPY %2(s32)
525 ...
35063506 // must be transformed into:
35073507 // (sext:[i32] (ld:[i16] [iPTR])<>)
35083508 //
3509 // Likewise for zeroext-load.
3509 // Likewise for zeroext-load and anyext-load.
35103510
35113511 std::vector Predicates;
35123512 bool IsSignExtLoad = false;
35133513 bool IsZeroExtLoad = false;
3514 bool IsAnyExtLoad = false;
35143515 Record *MemVT = nullptr;
35153516 for (const auto &P : N->getPredicateFns()) {
35163517 if (P.isLoad() && P.isSignExtLoad()) {
35213522 IsZeroExtLoad = true;
35223523 continue;
35233524 }
3525 if (P.isLoad() && P.isAnyExtLoad()) {
3526 IsAnyExtLoad = true;
3527 continue;
3528 }
35243529 if (P.isLoad() && P.getMemoryVT()) {
35253530 MemVT = P.getMemoryVT();
35263531 continue;
35283533 Predicates.push_back(P);
35293534 }
35303535
3531 if ((IsSignExtLoad || IsZeroExtLoad) && MemVT) {
3532 assert(((IsSignExtLoad && !IsZeroExtLoad) ||
3533 (!IsSignExtLoad && IsZeroExtLoad)) &&
3534 "IsSignExtLoad and IsZeroExtLoad are mutually exclusive");
3536 if ((IsSignExtLoad || IsZeroExtLoad || IsAnyExtLoad) && MemVT) {
3537 assert((IsSignExtLoad + IsZeroExtLoad + IsAnyExtLoad) == 1 &&
3538 "IsSignExtLoad, IsZeroExtLoad, IsAnyExtLoad are mutually exclusive");
35353539 TreePatternNode *Ext = new TreePatternNode(
3536 RK.getDef(IsSignExtLoad ? "sext" : "zext"), {N}, 1);
3540 RK.getDef(IsSignExtLoad ? "sext"
3541 : IsZeroExtLoad ? "zext" : "anyext"),
3542 {N}, 1);
35373543 Ext->setType(0, N->getType(0));
35383544 N->clearPredicateFns();
35393545 N->setPredicateFns(Predicates);