[DAGCombiner] Add target hook function to decide folding (mul (add x, c1), c2)
[llvm-project.git] / llvm / test / MC / RISCV / rv32i-aliases-valid.s
blob566680d754fcc3daa2a99c047bd6739794b5d9d4
1 # RUN: llvm-mc %s -triple=riscv32 -riscv-no-aliases \
2 # RUN: | FileCheck -check-prefixes=CHECK-EXPAND,CHECK-INST %s
3 # RUN: llvm-mc %s -triple=riscv32 \
4 # RUN: | FileCheck -check-prefixes=CHECK-EXPAND,CHECK-ALIAS %s
5 # RUN: llvm-mc -filetype=obj -triple riscv32 < %s \
6 # RUN: | llvm-objdump -M no-aliases -d -r - \
7 # RUN: | FileCheck -check-prefixes=CHECK-OBJ-NOALIAS,CHECK-EXPAND,CHECK-INST %s
8 # RUN: llvm-mc -filetype=obj -triple riscv32 < %s \
9 # RUN: | llvm-objdump -d -r - \
10 # RUN: | FileCheck -check-prefixes=CHECK-EXPAND,CHECK-ALIAS %s
12 # The following check prefixes are used in this test:
13 # CHECK-INST.....Match the canonical instr (tests alias to instr. mapping)
14 # CHECK-ALIAS....Match the alias (tests instr. to alias mapping)
15 # CHECK-EXPAND...Match canonical instr. unconditionally (tests alias expansion)
17 # Needed for testing valid %pcrel_lo expressions
18 .Lpcrel_hi0: auipc a0, %pcrel_hi(foo)
20 # CHECK-INST: addi a0, zero, 0
21 # CHECK-ALIAS: mv a0, zero
22 li x10, 0
23 # CHECK-EXPAND: addi a0, zero, 1
24 li x10, 1
25 # CHECK-EXPAND: addi a0, zero, -1
26 li x10, -1
27 # CHECK-EXPAND: addi a0, zero, 2047
28 li x10, 2047
29 # CHECK-EXPAND: addi a0, zero, -2047
30 li x10, -2047
31 # CHECK-EXPAND: lui a1, 1
32 # CHECK-EXPAND: addi a1, a1, -2048
33 li x11, 2048
34 # CHECK-EXPAND: addi a1, zero, -2048
35 li x11, -2048
36 # CHECK-EXPAND: lui a1, 1
37 # CHECK-EXPAND: addi a1, a1, -2047
38 li x11, 2049
39 # CHECK-EXPAND: lui a1, 1048575
40 # CHECK-EXPAND: addi a1, a1, 2047
41 li x11, -2049
42 # CHECK-EXPAND: lui a1, 1
43 # CHECK-EXPAND: addi a1, a1, -1
44 li x11, 4095
45 # CHECK-EXPAND: lui a1, 1048575
46 # CHECK-EXPAND: addi a1, a1, 1
47 li x11, -4095
48 # CHECK-EXPAND: lui a2, 1
49 li x12, 4096
50 # CHECK-EXPAND: lui a2, 1048575
51 li x12, -4096
52 # CHECK-EXPAND: lui a2, 1
53 # CHECK-EXPAND: addi a2, a2, 1
54 li x12, 4097
55 # CHECK-EXPAND: lui a2, 1048575
56 # CHECK-EXPAND: addi a2, a2, -1
57 li x12, -4097
58 # CHECK-EXPAND: lui a2, 524288
59 # CHECK-EXPAND: addi a2, a2, -1
60 li x12, 2147483647
61 # CHECK-EXPAND: lui a2, 524288
62 # CHECK-EXPAND: addi a2, a2, 1
63 li x12, -2147483647
64 # CHECK-EXPAND: lui a2, 524288
65 li x12, -2147483648
66 # CHECK-EXPAND: lui a2, 524288
67 li x12, -0x80000000
69 # CHECK-EXPAND: lui a2, 524288
70 li x12, 0x80000000
71 # CHECK-EXPAND: addi a2, zero, -1
72 li x12, 0xFFFFFFFF
74 # CHECK-EXPAND: addi a0, zero, 1110
75 li a0, %lo(0x123456)
77 # CHECK-OBJ-NOALIAS: addi a0, zero, 0
78 # CHECK-OBJ: R_RISCV_LO12
79 li a0, %lo(foo)
80 # CHECK-OBJ-NOALIAS: addi a0, zero, 0
81 # CHECK-OBJ: R_RISCV_PCREL_LO12
82 li a0, %pcrel_lo(.Lpcrel_hi0)
84 .equ CONST, 0x123456
85 # CHECK-EXPAND: lui a0, 291
86 # CHECK-EXPAND: addi a0, a0, 1110
87 li a0, CONST
88 # CHECK-EXPAND: lui a0, 291
89 # CHECK-EXPAND: addi a0, a0, 1111
90 li a0, CONST+1
92 .equ CONST, 0x654321
93 # CHECK-EXPAND: lui a0, 1620
94 # CHECK-EXPAND: addi a0, a0, 801
95 li a0, CONST
97 # CHECK-INST: csrrs t4, instreth, zero
98 # CHECK-ALIAS: rdinstreth t4
99 rdinstreth x29
100 # CHECK-INST: csrrs s11, cycleh, zero
101 # CHECK-ALIAS: rdcycleh s11
102 rdcycleh x27
103 # CHECK-INST: csrrs t3, timeh, zero
104 # CHECK-ALIAS: rdtimeh t3
105 rdtimeh x28
107 # CHECK-EXPAND: lb a0, 0(a1)
108 lb x10, (x11)
109 # CHECK-EXPAND: lh a0, 0(a1)
110 lh x10, (x11)
111 # CHECK-EXPAND: lw a0, 0(a1)
112 lw x10, (x11)
113 # CHECK-EXPAND: lbu a0, 0(a1)
114 lbu x10, (x11)
115 # CHECK-EXPAND: lhu a0, 0(a1)
116 lhu x10, (x11)
118 # CHECK-EXPAND: sb a0, 0(a1)
119 sb x10, (x11)
120 # CHECK-EXPAND: sh a0, 0(a1)
121 sh x10, (x11)
122 # CHECK-EXPAND: sw a0, 0(a1)
123 sw x10, (x11)
125 # CHECK-EXPAND: slli a0, a1, 24
126 # CHECK-EXPAND: srai a0, a0, 24
127 sext.b x10, x11
129 # CHECK-EXPAND: slli a0, a1, 16
130 # CHECK-EXPAND: srai a0, a0, 16
131 sext.h x10, x11
133 # CHECK-INST: andi a0, a1, 255
134 # CHECK-ALIAS: andi a0, a1, 255
135 zext.b x10, x11
137 # CHECK-EXPAND: slli a0, a1, 16
138 # CHECK-EXPAND: srli a0, a0, 16
139 zext.h x10, x11