[DAGCombiner] Add target hook function to decide folding (mul (add x, c1), c2)
[llvm-project.git] / llvm / test / MC / RISCV / option-pushpop.s
blob909f3d027b85ba00fba7dc4f714c474847f1d3f7
1 # RUN: llvm-mc -triple riscv32 -mattr=-relax -riscv-no-aliases < %s \
2 # RUN: | FileCheck -check-prefix=CHECK-INST %s
3 # RUN: llvm-mc -filetype=obj -triple riscv32 < %s \
4 # RUN: | llvm-readobj -r - | FileCheck -check-prefix=CHECK-RELOC %s
5 # RUN: llvm-mc -triple riscv32 -filetype=obj < %s \
6 # RUN: | llvm-objdump --triple=riscv32 --mattr=+c -d - \
7 # RUN: | FileCheck -check-prefixes=CHECK-BYTES,CHECK-ALIAS %s
9 # RUN: llvm-mc -triple riscv64 -mattr=-relax -riscv-no-aliases < %s \
10 # RUN: | FileCheck -check-prefix=CHECK-INST %s
11 # RUN: llvm-mc -filetype=obj -triple riscv64 < %s \
12 # RUN: | llvm-readobj -r - | FileCheck -check-prefix=CHECK-RELOC %s
13 # RUN: llvm-mc -triple riscv64 -filetype=obj < %s \
14 # RUN: | llvm-objdump --triple=riscv64 --mattr=+c -d - \
15 # RUN: | FileCheck -check-prefixes=CHECK-BYTES,CHECK-ALIAS %s
17 # Test the operation of the push and pop assembler directives when
18 # using .option relax and .option rvc. Checks that using .option pop
19 # correctly restores all target features to their state at the point
20 # where .option pop was last used.
22 # CHECK-INST: call foo
23 # CHECK-RELOC: R_RISCV_CALL foo 0x0
24 # CHECK-RELOC-NOT: R_RISCV_RELAX - 0x0
25 call foo
27 # CHECK-INST: addi s0, sp, 1020
28 # CHECK-BYTES: 13 04 c1 3f
29 # CHECK-ALIAS: addi s0, sp, 1020
30 addi s0, sp, 1020
32 .option push # Push relax=false, rvc=false
33 # CHECK-INST: .option push
35 .option relax
36 # CHECK-INST: .option relax
37 # CHECK-INST: call bar
38 # CHECK-RELOC-NEXT: R_RISCV_CALL bar 0x0
39 # CHECK-RELOC-NEXT: R_RISCV_RELAX - 0x0
40 call bar
42 .option push # Push relax=true, rvc=false
43 # CHECK-INST: .option push
45 .option rvc
46 # CHECK-INST: .option rvc
47 # CHECK-INST: c.addi4spn s0, sp, 1020
48 # CHECK-BYTES: e0 1f
49 # CHECK-ALIAS: addi s0, sp, 1020
50 addi s0, sp, 1020
52 .option pop # Pop relax=true, rvc=false
53 # CHECK-INST: .option pop
54 # CHECK-INST: addi s0, sp, 1020
55 # CHECK-BYTES: 13 04 c1 3f
56 # CHECK-ALIAS: addi s0, sp, 1020
57 addi s0, sp, 1020
59 # CHECK-INST: call bar
60 # CHECK-RELOC-NEXT: R_RISCV_CALL bar 0x0
61 # CHECK-RELOC-NEXT: R_RISCV_RELAX - 0x0
62 call bar
64 .option pop # Pop relax=false, rvc=false
65 # CHECK-INST: .option pop
66 # CHECK-INST: call baz
67 # CHECK-RELOC: R_RISCV_CALL baz 0x0
68 # CHECK-RELOC-NOT: R_RISCV_RELAX - 0x0
69 call baz
71 # CHECK-INST: addi s0, sp, 1020
72 # CHECK-BYTES: 13 04 c1 3f
73 # CHECK-ALIAS: addi s0, sp, 1020
74 addi s0, sp, 1020
76 .option push # Push pic=false
77 # CHECK-INST: .option push
79 .option pic
80 # CHECK-INST: .option pic
82 la s0, symbol
83 # CHECK-INST: auipc s0, %got_pcrel_hi(symbol)
84 # CHECK-INST: l{{[wd]}} s0, %pcrel_lo(.Lpcrel_hi0)(s0)
85 # CHECK-RELOC: R_RISCV_GOT_HI20 symbol 0x0
86 # CHECK-RELOC: R_RISCV_PCREL_LO12_I .Lpcrel_hi0 0x0
88 .option push # Push pic=true
89 # CHECK-INST: .option push
91 .option nopic
92 # CHECK-INST: .option nopic
94 la s0, symbol
95 # CHECK-INST: auipc s0, %pcrel_hi(symbol)
96 # CHECK-INST: addi s0, s0, %pcrel_lo(.Lpcrel_hi1)
97 # CHECK-RELOC: R_RISCV_PCREL_HI20 symbol 0x0
98 # CHECK-RELOC: R_RISCV_PCREL_LO12_I .Lpcrel_hi1 0x0
100 .option pop # Push pic=true
101 # CHECK-INST: .option pop
103 la s0, symbol
104 # CHECK-INST: auipc s0, %got_pcrel_hi(symbol)
105 # CHECK-INST: l{{[wd]}} s0, %pcrel_lo(.Lpcrel_hi2)(s0)
106 # CHECK-RELOC: R_RISCV_GOT_HI20 symbol 0x0
107 # CHECK-RELOC: R_RISCV_PCREL_LO12_I .Lpcrel_hi2 0x0
109 .option pop # Push pic=false
110 # CHECK-INST: .option pop
112 la s0, symbol
113 # CHECK-INST: auipc s0, %pcrel_hi(symbol)
114 # CHECK-INST: addi s0, s0, %pcrel_lo(.Lpcrel_hi3)
115 # CHECK-RELOC: R_RISCV_PCREL_HI20 symbol 0x0
116 # CHECK-RELOC: R_RISCV_PCREL_LO12_I .Lpcrel_hi3 0x0