OLD | NEW |
1 ; Test encoding of MIPS32 instructions used in intrinsic calls | 1 ; Test encoding of MIPS32 instructions used in intrinsic calls |
2 | 2 |
3 ; REQUIRES: allow_dump | 3 ; REQUIRES: allow_dump |
4 | 4 |
5 ; Compile using standalone assembler. | 5 ; Compile using standalone assembler. |
6 ; RUN: %p2i --filetype=asm -i %s --target=mips32 --args -O2 \ | 6 ; RUN: %p2i --filetype=asm -i %s --target=mips32 --args -O2 \ |
7 ; RUN: --allow-externally-defined-symbols \ | 7 ; RUN: --allow-externally-defined-symbols \ |
8 ; RUN: | FileCheck %s --check-prefix=ASM | 8 ; RUN: | FileCheck %s --check-prefix=ASM |
9 | 9 |
10 ; Show bytes in assembled standalone code. | 10 ; Show bytes in assembled standalone code. |
(...skipping 23 matching lines...) Expand all Loading... |
34 define internal i32 @encBswap16(i32 %x) { | 34 define internal i32 @encBswap16(i32 %x) { |
35 entry: | 35 entry: |
36 %x_trunc = trunc i32 %x to i16 | 36 %x_trunc = trunc i32 %x to i16 |
37 %r = call i16 @llvm.bswap.i16(i16 %x_trunc) | 37 %r = call i16 @llvm.bswap.i16(i16 %x_trunc) |
38 %r_zext = zext i16 %r to i32 | 38 %r_zext = zext i16 %r to i32 |
39 ret i32 %r_zext | 39 ret i32 %r_zext |
40 } | 40 } |
41 | 41 |
42 ; ASM-LABEL: encBswap16 | 42 ; ASM-LABEL: encBswap16 |
43 ; ASM-NEXT: .LencBswap16$entry: | 43 ; ASM-NEXT: .LencBswap16$entry: |
| 44 ; ASM-NEXT: andi $a0, $a0, 65535 |
44 ; ASM-NEXT: sll $v0, $a0, 8 | 45 ; ASM-NEXT: sll $v0, $a0, 8 |
45 ; ASM-NEXT: lui $v1, 255 | 46 ; ASM-NEXT: lui $v1, 255 |
46 ; ASM-NEXT: and $v0, $v0, $v1 | 47 ; ASM-NEXT: and $v0, $v0, $v1 |
47 ; ASM-NEXT: sll $a0, $a0, 24 | 48 ; ASM-NEXT: sll $a0, $a0, 24 |
48 ; ASM-NEXT: or $v0, $a0, $v0 | 49 ; ASM-NEXT: or $v0, $a0, $v0 |
49 ; ASM-NEXT: srl $v0, $v0, 16 | 50 ; ASM-NEXT: srl $v0, $v0, 16 |
50 ; ASM-NEXT: andi $v0, $v0, 65535 | 51 ; ASM-NEXT: andi $v0, $v0, 65535 |
51 ; ASM-NEXT: jr $ra | 52 ; ASM-NEXT: jr $ra |
52 | 53 |
53 ; DIS-LABEL: <encBswap16>: | 54 ; DIS-LABEL: <encBswap16>: |
| 55 ; DIS-NEXT: 3084ffff andi a0,a0,0xffff |
54 ; DIS-NEXT: 00041200 sll v0,a0,0x8 | 56 ; DIS-NEXT: 00041200 sll v0,a0,0x8 |
55 ; DIS-NEXT: 3c0300ff lui v1,0xff | 57 ; DIS-NEXT: 3c0300ff lui v1,0xff |
56 ; DIS-NEXT: 00431024 and v0,v0,v1 | 58 ; DIS-NEXT: 00431024 and v0,v0,v1 |
57 ; DIS-NEXT: 00042600 sll a0,a0,0x18 | 59 ; DIS-NEXT: 00042600 sll a0,a0,0x18 |
58 ; DIS-NEXT: 00821025 or v0,a0,v0 | 60 ; DIS-NEXT: 00821025 or v0,a0,v0 |
59 ; DIS-NEXT: 00021402 srl v0,v0,0x10 | 61 ; DIS-NEXT: 00021402 srl v0,v0,0x10 |
60 ; DIS-NEXT: 3042ffff andi v0,v0,0xffff | 62 ; DIS-NEXT: 3042ffff andi v0,v0,0xffff |
61 ; DIS-NEXT: 03e00008 jr ra | 63 ; DIS-NEXT: 03e00008 jr ra |
62 | 64 |
63 ; IASM-LABEL: encBswap16 | 65 ; IASM-LABEL: encBswap16 |
64 ; IASM-NEXT: .LencBswap16$entry: | 66 ; IASM-NEXT: .LencBswap16$entry: |
| 67 ; IASM-NEXT: .byte 0xff |
| 68 ; IASM-NEXT: .byte 0xff |
| 69 ; IASM-NEXT: .byte 0x84 |
| 70 ; IASM-NEXT: .byte 0x30 |
65 ; IASM-NEXT: .byte 0x0 | 71 ; IASM-NEXT: .byte 0x0 |
66 ; IASM-NEXT: .byte 0x12 | 72 ; IASM-NEXT: .byte 0x12 |
67 ; IASM-NEXT: .byte 0x4 | 73 ; IASM-NEXT: .byte 0x4 |
68 ; IASM-NEXT: .byte 0x0 | 74 ; IASM-NEXT: .byte 0x0 |
69 ; IASM-NEXT: .byte 0xff | 75 ; IASM-NEXT: .byte 0xff |
70 ; IASM-NEXT: .byte 0x0 | 76 ; IASM-NEXT: .byte 0x0 |
71 ; IASM-NEXT: .byte 0x3 | 77 ; IASM-NEXT: .byte 0x3 |
72 ; IASM-NEXT: .byte 0x3c | 78 ; IASM-NEXT: .byte 0x3c |
73 ; IASM-NEXT: .byte 0x24 | 79 ; IASM-NEXT: .byte 0x24 |
74 ; IASM-NEXT: .byte 0x10 | 80 ; IASM-NEXT: .byte 0x10 |
(...skipping 494 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
569 %r = call i64 @llvm.ctlz.i64(i64 %x, i1 false) | 575 %r = call i64 @llvm.ctlz.i64(i64 %x, i1 false) |
570 ret i64 %r | 576 ret i64 %r |
571 } | 577 } |
572 | 578 |
573 ; ASM-LABEL: encCtlz64 | 579 ; ASM-LABEL: encCtlz64 |
574 ; ASM-NEXT: .LencCtlz64$entry: | 580 ; ASM-NEXT: .LencCtlz64$entry: |
575 ; ASM-NEXT: clz $v0, $a1 | 581 ; ASM-NEXT: clz $v0, $a1 |
576 ; ASM-NEXT: clz $a0, $a0 | 582 ; ASM-NEXT: clz $a0, $a0 |
577 ; ASM-NEXT: addiu $a0, $a0, 32 | 583 ; ASM-NEXT: addiu $a0, $a0, 32 |
578 ; ASM-NEXT: movn $a0, $v0, $a1 | 584 ; ASM-NEXT: movn $a0, $v0, $a1 |
579 ; ASM-NEXT: » addiu» $v0, $zero, 0 | 585 ; ASM: » addiu» $v0, $zero, 0 |
580 ; ASM-NEXT: move $v1, $v0 | 586 ; ASM-NEXT: move $v1, $v0 |
581 ; ASM-NEXT: move $v0, $a0 | 587 ; ASM-NEXT: move $v0, $a0 |
582 ; ASM-NEXT: jr $ra | 588 ; ASM-NEXT: jr $ra |
583 | 589 |
584 ; DIS-LABEL: <encCtlz64>: | 590 ; DIS-LABEL: <encCtlz64>: |
585 ; DIS-NEXT: 70a21020 clz v0,a1 | 591 ; DIS-NEXT: 70a21020 clz v0,a1 |
586 ; DIS-NEXT: 70842020 clz a0,a0 | 592 ; DIS-NEXT: 70842020 clz a0,a0 |
587 ; DIS-NEXT: 24840020 addiu a0,a0,32 | 593 ; DIS-NEXT: 24840020 addiu a0,a0,32 |
588 ; DIS-NEXT: 0045200b movn a0,v0,a1 | 594 ; DIS-NEXT: 0045200b movn a0,v0,a1 |
589 ; DIS-NEXT: 24020000 li v0,0 | 595 ; DIS-NEXT: 24020000 li v0,0 |
(...skipping 108 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
698 | 704 |
699 define internal i32 @encCttz32(i32 %x) { | 705 define internal i32 @encCttz32(i32 %x) { |
700 entry: | 706 entry: |
701 %r = call i32 @llvm.cttz.i32(i32 %x, i1 false) | 707 %r = call i32 @llvm.cttz.i32(i32 %x, i1 false) |
702 ret i32 %r | 708 ret i32 %r |
703 } | 709 } |
704 | 710 |
705 ; ASM-LABEL: encCttz32 | 711 ; ASM-LABEL: encCttz32 |
706 ; ASM-NEXT: .LencCttz32$entry: | 712 ; ASM-NEXT: .LencCttz32$entry: |
707 ; ASM-NEXT: addiu $v0, $a0, -1 | 713 ; ASM-NEXT: addiu $v0, $a0, -1 |
708 ; ASM-NEXT: » nor» $a0, $a0, $zero | 714 ; ASM: »nor» $a0, $a0, $zero |
709 ; ASM-NEXT: and $a0, $a0, $v0 | 715 ; ASM-NEXT: and $a0, $a0, $v0 |
710 ; ASM-NEXT: clz $a0, $a0 | 716 ; ASM-NEXT: clz $a0, $a0 |
711 ; ASM-NEXT: » addiu» $v0, $zero, 32 | 717 ; ASM: »addiu» $v0, $zero, 32 |
712 ; ASM-NEXT: subu $v0, $v0, $a0 | 718 ; ASM-NEXT: subu $v0, $v0, $a0 |
713 ; ASM-NEXT: jr $ra | 719 ; ASM-NEXT: jr $ra |
714 | 720 |
715 ; DIS-LABEL: <encCttz32>: | 721 ; DIS-LABEL: <encCttz32>: |
716 ; DIS-NEXT: 2482ffff addiu v0,a0,-1 | 722 ; DIS-NEXT: 2482ffff addiu v0,a0,-1 |
717 ; DIS-NEXT: 00802027 nor a0,a0,zero | 723 ; DIS-NEXT: 00802027 nor a0,a0,zero |
718 ; DIS-NEXT: 00822024 and a0,a0,v0 | 724 ; DIS-NEXT: 00822024 and a0,a0,v0 |
719 ; DIS-NEXT: 70842020 clz a0,a0 | 725 ; DIS-NEXT: 70842020 clz a0,a0 |
720 ; DIS-NEXT: 24020020 li v0,32 | 726 ; DIS-NEXT: 24020020 li v0,32 |
721 ; DIS-NEXT: 00441023 subu v0,v0,a0 | 727 ; DIS-NEXT: 00441023 subu v0,v0,a0 |
(...skipping 34 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
756 entry: | 762 entry: |
757 %r = call i32 @llvm.cttz.i32(i32 123456, i1 false) | 763 %r = call i32 @llvm.cttz.i32(i32 123456, i1 false) |
758 ret i32 %r | 764 ret i32 %r |
759 } | 765 } |
760 | 766 |
761 ; ASM-LABEL: encCttz32Const | 767 ; ASM-LABEL: encCttz32Const |
762 ; ASM-NEXT: .LencCttz32Const$entry: | 768 ; ASM-NEXT: .LencCttz32Const$entry: |
763 ; ASM-NEXT: lui $v0, 1 | 769 ; ASM-NEXT: lui $v0, 1 |
764 ; ASM-NEXT: ori $v0, $v0, 57920 | 770 ; ASM-NEXT: ori $v0, $v0, 57920 |
765 ; ASM-NEXT: addiu $v1, $v0, -1 | 771 ; ASM-NEXT: addiu $v1, $v0, -1 |
766 ; ASM-NEXT: » nor $v0, $v0, $zero | 772 ; ASM: »nor $v0, $v0, $zero |
767 ; ASM-NEXT: and $v0, $v0, $v1 | 773 ; ASM-NEXT: and $v0, $v0, $v1 |
768 ; ASM-NEXT: clz $v0, $v0 | 774 ; ASM-NEXT: clz $v0, $v0 |
769 ; ASM-NEXT: » addiu $v1, $zero, 32 | 775 ; ASM: »addiu $v1, $zero, 32 |
770 ; ASM-NEXT: subu $v1, $v1, $v0 | 776 ; ASM-NEXT: subu $v1, $v1, $v0 |
771 ; ASM-NEXT: move $v0, $v1 | 777 ; ASM-NEXT: move $v0, $v1 |
772 ; ASM-NEXT: jr $ra | 778 ; ASM-NEXT: jr $ra |
773 | 779 |
774 ; DIS-LABEL: <encCttz32Const>: | 780 ; DIS-LABEL: <encCttz32Const>: |
775 ; DIS-NEXT: 3c020001 lui v0,0x1 | 781 ; DIS-NEXT: 3c020001 lui v0,0x1 |
776 ; DIS-NEXT: 3442e240 ori v0,v0,0xe240 | 782 ; DIS-NEXT: 3442e240 ori v0,v0,0xe240 |
777 ; DIS-NEXT: 2443ffff addiu v1,v0,-1 | 783 ; DIS-NEXT: 2443ffff addiu v1,v0,-1 |
778 ; DIS-NEXT: 00401027 nor v0,v0,zero | 784 ; DIS-NEXT: 00401027 nor v0,v0,zero |
779 ; DIS-NEXT: 00431024 and v0,v0,v1 | 785 ; DIS-NEXT: 00431024 and v0,v0,v1 |
(...skipping 48 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
828 | 834 |
829 define internal i64 @encCttz64(i64 %x) { | 835 define internal i64 @encCttz64(i64 %x) { |
830 entry: | 836 entry: |
831 %r = call i64 @llvm.cttz.i64(i64 %x, i1 false) | 837 %r = call i64 @llvm.cttz.i64(i64 %x, i1 false) |
832 ret i64 %r | 838 ret i64 %r |
833 } | 839 } |
834 | 840 |
835 ; ASM-LABEL: encCttz64 | 841 ; ASM-LABEL: encCttz64 |
836 ; ASM-NEXT: .LencCttz64$entry: | 842 ; ASM-NEXT: .LencCttz64$entry: |
837 ; ASM-NEXT: addiu $v0, $a1, -1 | 843 ; ASM-NEXT: addiu $v0, $a1, -1 |
838 ; ASM-NEXT: » nor $a1, $a1, $zero | 844 ; ASM: »nor $a1, $a1, $zero |
839 ; ASM-NEXT: and $a1, $a1, $v0 | 845 ; ASM-NEXT: and $a1, $a1, $v0 |
840 ; ASM-NEXT: clz $a1, $a1 | 846 ; ASM-NEXT: clz $a1, $a1 |
841 ; ASM-NEXT: » addiu $v0, $zero, 64 | 847 ; ASM: »addiu $v0, $zero, 64 |
842 ; ASM-NEXT: subu $v0, $v0, $a1 | 848 ; ASM-NEXT: subu $v0, $v0, $a1 |
843 ; ASM-NEXT: addiu $v1, $a0, -1 | 849 ; ASM-NEXT: addiu $v1, $a0, -1 |
844 ; ASM-NEXT: » nor $a1, $a0, $zero | 850 ; ASM: »nor $a1, $a0, $zero |
845 ; ASM-NEXT: and $a1, $a1, $v1 | 851 ; ASM-NEXT: and $a1, $a1, $v1 |
846 ; ASM-NEXT: clz $a1, $a1 | 852 ; ASM-NEXT: clz $a1, $a1 |
847 ; ASM-NEXT: » addiu $v1, $zero, 32 | 853 ; ASM: »addiu $v1, $zero, 32 |
848 ; ASM-NEXT: subu $v1, $v1, $a1 | 854 ; ASM-NEXT: subu $v1, $v1, $a1 |
849 ; ASM-NEXT: movn $v0, $v1, $a0 | 855 ; ASM-NEXT: movn $v0, $v1, $a0 |
850 ; ASM-NEXT: » addiu $v1, $zero, 0 | 856 ; ASM: »addiu $v1, $zero, 0 |
851 ; ASM-NEXT: jr $ra | 857 ; ASM-NEXT: jr $ra |
852 | 858 |
853 ; DIS-LABEL: <encCttz64>: | 859 ; DIS-LABEL: <encCttz64>: |
854 ; DIS-NEXT: 24a2ffff addiu v0,a1,-1 | 860 ; DIS-NEXT: 24a2ffff addiu v0,a1,-1 |
855 ; DIS-NEXT: 00a02827 nor a1,a1,zero | 861 ; DIS-NEXT: 00a02827 nor a1,a1,zero |
856 ; DIS-NEXT: 00a22824 and a1,a1,v0 | 862 ; DIS-NEXT: 00a22824 and a1,a1,v0 |
857 ; DIS-NEXT: 70a52820 clz a1,a1 | 863 ; DIS-NEXT: 70a52820 clz a1,a1 |
858 ; DIS-NEXT: 24020040 li v0,64 | 864 ; DIS-NEXT: 24020040 li v0,64 |
859 ; DIS-NEXT: 00451023 subu v0,v0,a1 | 865 ; DIS-NEXT: 00451023 subu v0,v0,a1 |
860 ; DIS-NEXT: 2483ffff addiu v1,a0,-1 | 866 ; DIS-NEXT: 2483ffff addiu v1,a0,-1 |
(...skipping 76 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
937 ret i64 %r | 943 ret i64 %r |
938 } | 944 } |
939 | 945 |
940 ; ASM-LABEL: encCttz64Const | 946 ; ASM-LABEL: encCttz64Const |
941 ; ASM-NEXT: .LencCttz64Const$entry: | 947 ; ASM-NEXT: .LencCttz64Const$entry: |
942 ; ASM-NEXT: # $zero = def.pseudo | 948 ; ASM-NEXT: # $zero = def.pseudo |
943 ; ASM-NEXT: addiu $v0, $zero, 28 | 949 ; ASM-NEXT: addiu $v0, $zero, 28 |
944 ; ASM-NEXT: lui $v1, 48793 | 950 ; ASM-NEXT: lui $v1, 48793 |
945 ; ASM-NEXT: ori $v1, $v1, 6676 | 951 ; ASM-NEXT: ori $v1, $v1, 6676 |
946 ; ASM-NEXT: addiu $a0, $v0, -1 | 952 ; ASM-NEXT: addiu $a0, $v0, -1 |
947 ; ASM-NEXT: » nor $v0, $v0, $zero | 953 ; ASM: »nor $v0, $v0, $zero |
948 ; ASM-NEXT: and $v0, $v0, $a0 | 954 ; ASM-NEXT: and $v0, $v0, $a0 |
949 ; ASM-NEXT: clz $v0, $v0 | 955 ; ASM-NEXT: clz $v0, $v0 |
950 ; ASM-NEXT: » addiu $a0, $zero, 64 | 956 ; ASM: »addiu $a0, $zero, 64 |
951 ; ASM-NEXT: subu $a0, $a0, $v0 | 957 ; ASM-NEXT: subu $a0, $a0, $v0 |
952 ; ASM-NEXT: addiu $v0, $v1, -1 | 958 ; ASM-NEXT: addiu $v0, $v1, -1 |
953 ; ASM-NEXT: » nor $a1, $v1, $zero | 959 ; ASM: »nor $a1, $v1, $zero |
954 ; ASM-NEXT: and $a1, $a1, $v0 | 960 ; ASM-NEXT: and $a1, $a1, $v0 |
955 ; ASM-NEXT: clz $a1, $a1 | 961 ; ASM-NEXT: clz $a1, $a1 |
956 ; ASM-NEXT: » addiu $v0, $zero, 32 | 962 ; ASM: »addiu $v0, $zero, 32 |
957 ; ASM-NEXT: subu $v0, $v0, $a1 | 963 ; ASM-NEXT: subu $v0, $v0, $a1 |
958 ; ASM-NEXT: movn $a0, $v0, $v1 | 964 ; ASM-NEXT: movn $a0, $v0, $v1 |
959 ; ASM-NEXT: » addiu $v0, $zero, 0 | 965 ; ASM: »addiu $v0, $zero, 0 |
960 ; ASM-NEXT: move $v1, $v0 | 966 ; ASM-NEXT: move $v1, $v0 |
961 ; ASM-NEXT: move $v0, $a0 | 967 ; ASM-NEXT: move $v0, $a0 |
962 ; ASM-NEXT: jr $ra | 968 ; ASM-NEXT: jr $ra |
963 | 969 |
964 ; DIS-LABEL: <encCttz64Const>: | 970 ; DIS-LABEL: <encCttz64Const>: |
965 ; DIS-NEXT: 2402001c li v0,28 | 971 ; DIS-NEXT: 2402001c li v0,28 |
966 ; DIS-NEXT: 3c03be99 lui v1,0xbe99 | 972 ; DIS-NEXT: 3c03be99 lui v1,0xbe99 |
967 ; DIS-NEXT: 34631a14 ori v1,v1,0x1a14 | 973 ; DIS-NEXT: 34631a14 ori v1,v1,0x1a14 |
968 ; DIS-NEXT: 2444ffff addiu a0,v0,-1 | 974 ; DIS-NEXT: 2444ffff addiu a0,v0,-1 |
969 ; DIS-NEXT: 00401027 nor v0,v0,zero | 975 ; DIS-NEXT: 00401027 nor v0,v0,zero |
(...skipping 95 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
1065 ; IASM-NEXT: .byte 0x0 | 1071 ; IASM-NEXT: .byte 0x0 |
1066 ; IASM-NEXT: .byte 0xe0 | 1072 ; IASM-NEXT: .byte 0xe0 |
1067 ; IASM-NEXT: .byte 0x3 | 1073 ; IASM-NEXT: .byte 0x3 |
1068 | 1074 |
1069 define internal void @encTrap() { | 1075 define internal void @encTrap() { |
1070 unreachable | 1076 unreachable |
1071 } | 1077 } |
1072 | 1078 |
1073 ; ASM-LABEL: encTrap | 1079 ; ASM-LABEL: encTrap |
1074 ; ASM-NEXT: .LencTrap$__0: | 1080 ; ASM-NEXT: .LencTrap$__0: |
1075 ; ASM-NEXT: » teq» $zero, $zero, 0 | 1081 ; ASM: »teq» $zero, $zero, 0 |
1076 | 1082 |
1077 ; DIS-LABEL: <encTrap>: | 1083 ; DIS-LABEL: <encTrap>: |
1078 ; DIS-NEXT: 00000034 teq zero,zero | 1084 ; DIS-NEXT: 00000034 teq zero,zero |
1079 | 1085 |
1080 ; IASM-LABEL: encTrap: | 1086 ; IASM-LABEL: encTrap: |
1081 ; IASM-NEXT: .LencTrap$__0: | 1087 ; IASM-NEXT: .LencTrap$__0: |
1082 ; IASM-NEXT: .byte 0x34 | 1088 ; IASM-NEXT: .byte 0x34 |
1083 ; IASM-NEXT: .byte 0x0 | 1089 ; IASM-NEXT: .byte 0x0 |
1084 ; IASM-NEXT: .byte 0x0 | 1090 ; IASM-NEXT: .byte 0x0 |
1085 ; IASM-NEXT: .byte 0x0 | 1091 ; IASM-NEXT: .byte 0x0 |
OLD | NEW |