Skip to content

Commit 2462c06

Browse files
committed
[M68k] Add anyext patterns for PCD addressing mode
1 parent 1f5047e commit 2462c06

File tree

2 files changed

+49
-0
lines changed

2 files changed

+49
-0
lines changed

llvm/lib/Target/M68k/M68kInstrData.td

Lines changed: 4 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -701,18 +701,22 @@ def: Pat<(MxExtLoadi16i8 MxCP_ARID:$src),
701701
(EXTRACT_SUBREG (MOVZXd32p8 MxARID8:$src), MxSubRegIndex16Lo)>;
702702
def: Pat<(MxExtLoadi16i8 MxCP_ARII:$src),
703703
(EXTRACT_SUBREG (MOVZXd32f8 MxARII8:$src), MxSubRegIndex16Lo)>;
704+
def: Pat<(MxExtLoadi16i8 MxCP_PCD:$src),
705+
(EXTRACT_SUBREG (MOVZXd32q8 MxPCD8:$src), MxSubRegIndex16Lo)>;
704706

705707
// i32 <- anyext i8
706708
def: Pat<(i32 (anyext i8:$src)), (MOVZXd32d8 MxDRD8:$src)>;
707709
def: Pat<(MxExtLoadi32i8 MxCP_ARI :$src), (MOVZXd32j8 MxARI8 :$src)>;
708710
def: Pat<(MxExtLoadi32i8 MxCP_ARID:$src), (MOVZXd32p8 MxARID8:$src)>;
709711
def: Pat<(MxExtLoadi32i8 MxCP_ARII:$src), (MOVZXd32f8 MxARII8:$src)>;
712+
def: Pat<(MxExtLoadi32i8 MxCP_PCD:$src), (MOVZXd32q8 MxPCD8:$src)>;
710713

711714
// i32 <- anyext i16
712715
def: Pat<(i32 (anyext i16:$src)), (MOVZXd32d16 MxDRD16:$src)>;
713716
def: Pat<(MxExtLoadi32i16 MxCP_ARI :$src), (MOVZXd32j16 MxARI16 :$src)>;
714717
def: Pat<(MxExtLoadi32i16 MxCP_ARID:$src), (MOVZXd32p16 MxARID16:$src)>;
715718
def: Pat<(MxExtLoadi32i16 MxCP_ARII:$src), (MOVZXd32f16 MxARII16:$src)>;
719+
def: Pat<(MxExtLoadi32i16 MxCP_PCD:$src), (MOVZXd32q16 MxPCD16:$src)>;
716720

717721
// trunc patterns
718722
def : Pat<(i16 (trunc i32:$src)),

llvm/test/CodeGen/M68k/Data/load-extend.ll

Lines changed: 45 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -41,3 +41,48 @@ define i32 @"test_zext_pcd_i16_to_i32"() {
4141
%val2 = zext i16 %val to i32
4242
ret i32 %val2
4343
}
44+
45+
define i16 @"test_anyext_pcd_i8_to_i16"() {
46+
; CHECK-LABEL: test_anyext_pcd_i8_to_i16:
47+
; CHECK: .cfi_startproc
48+
; CHECK-NEXT: ; %bb.0:
49+
; CHECK-NEXT: move.b (__unnamed_1+4,%pc), %d0
50+
; CHECK-NEXT: and.l #255, %d0
51+
; CHECK-NEXT: lsl.w #8, %d0
52+
; CHECK-NEXT: ; kill: def $wd0 killed $wd0 killed $d0
53+
; CHECK-NEXT: rts
54+
%copyload = load i8, ptr getelementptr inbounds nuw (i8, ptr @0, i32 4)
55+
%insert_ext = zext i8 %copyload to i16
56+
%insert_shift = shl i16 %insert_ext, 8
57+
ret i16 %insert_shift
58+
}
59+
60+
define i32 @"test_anyext_pcd_i8_to_i32"() {
61+
; CHECK-LABEL: test_anyext_pcd_i8_to_i32:
62+
; CHECK: .cfi_startproc
63+
; CHECK-NEXT: ; %bb.0:
64+
; CHECK-NEXT: moveq #24, %d1
65+
; CHECK-NEXT: move.b (__unnamed_1+4,%pc), %d0
66+
; CHECK-NEXT: and.l #255, %d0
67+
; CHECK-NEXT: lsl.l %d1, %d0
68+
; CHECK-NEXT: rts
69+
%copyload = load i8, ptr getelementptr inbounds nuw (i8, ptr @0, i32 4)
70+
%insert_ext = zext i8 %copyload to i32
71+
%insert_shift = shl i32 %insert_ext, 24
72+
ret i32 %insert_shift
73+
}
74+
75+
define i32 @"test_anyext_pcd_i16_to_i32"() {
76+
; CHECK-LABEL: test_anyext_pcd_i16_to_i32:
77+
; CHECK: .cfi_startproc
78+
; CHECK-NEXT: ; %bb.0:
79+
; CHECK-NEXT: moveq #16, %d1
80+
; CHECK-NEXT: move.w (__unnamed_1+4,%pc), %d0
81+
; CHECK-NEXT: and.l #65535, %d0
82+
; CHECK-NEXT: lsl.l %d1, %d0
83+
; CHECK-NEXT: rts
84+
%copyload = load i16, ptr getelementptr inbounds nuw (i8, ptr @0, i32 4)
85+
%insert_ext = zext i16 %copyload to i32
86+
%insert_shift = shl i32 %insert_ext, 16
87+
ret i32 %insert_shift
88+
}

0 commit comments

Comments
 (0)