blob: 47e99f307e11f8cc592f228515e2365e60b9dec5 [file] [log] [blame]
Karl Schimpf4175d452015-12-17 08:06:01 -08001; Tests assembly of ldrex and strex instructions
2
3; REQUIRES: allow_dump
4
5; Compile using standalone assembler.
6; RUN: %p2i --filetype=asm -i %s --target=arm32 --args -Om1 \
7; RUN: | FileCheck %s --check-prefix=ASM
8
9; Show bytes in assembled standalone code.
10; RUN: %p2i --filetype=asm -i %s --target=arm32 --assemble --disassemble \
11; RUN: --args -Om1 | FileCheck %s --check-prefix=DIS
12
13; Compile using integrated assembler.
14; RUN: %p2i --filetype=iasm -i %s --target=arm32 --args -Om1 \
15; RUN: | FileCheck %s --check-prefix=IASM
16
17; Show bytes in assembled integrated code.
18; RUN: %p2i --filetype=iasm -i %s --target=arm32 --assemble --disassemble \
19; RUN: --args -Om1 | FileCheck %s --check-prefix=DIS
20
21declare i8 @llvm.nacl.atomic.rmw.i8(i32, i8*, i8, i32)
22
23declare i16 @llvm.nacl.atomic.rmw.i16(i32, i16*, i16, i32)
24
25declare i32 @llvm.nacl.atomic.rmw.i32(i32, i32*, i32, i32) #0
26
27declare i64 @llvm.nacl.atomic.rmw.i64(i32, i64*, i64, i32) #0
28
29define internal i32 @testI8Form(i32 %ptr, i32 %a) {
30; ASM-LABEL:testI8Form:
John Porto4b6e4b42016-02-17 05:00:59 -080031; DIS-LABEL:<testI8Form>:
Karl Schimpf4175d452015-12-17 08:06:01 -080032; IASM-LABEL:testI8Form:
33
34entry:
Karl Schimpf4175d452015-12-17 08:06:01 -080035 %ptr.asptr = inttoptr i32 %ptr to i8*
36 %a.arg_trunc = trunc i32 %a to i8
37
Karl Schimpf4175d452015-12-17 08:06:01 -080038 %v = call i8 @llvm.nacl.atomic.rmw.i8(i32 1, i8* %ptr.asptr,
39 i8 %a.arg_trunc, i32 6)
40
John Porto4b6e4b42016-02-17 05:00:59 -080041; ****** Example of dmb *******
42; ASM: dmb sy
43; DIS: 1c: f57ff05f
44; IASM: .byte 0x5f
Karl Schimpf4175d452015-12-17 08:06:01 -080045; IASM-NEXT: .byte 0xf0
46; IASM-NEXT: .byte 0x7f
47; IASM-NEXT: .byte 0xf5
48
Karl Schimpf4175d452015-12-17 08:06:01 -080049; ***** Example of ldrexb *****
John Porto4b6e4b42016-02-17 05:00:59 -080050; ASM: ldrexb r1, [r2]
51; DIS: 24: e1d21f9f
52; IASM: .byte 0x9f
53; IASM-NEXT: .byte 0x1f
54; IASM-NEXT: .byte 0xd2
Karl Schimpf4175d452015-12-17 08:06:01 -080055; IASM-NEXT: .byte 0xe1
56
Karl Schimpf4175d452015-12-17 08:06:01 -080057; ***** Example of strexb *****
John Porto4b6e4b42016-02-17 05:00:59 -080058; ASM: strexb r4, r3, [r2]
59; DIS: 2c: e1c24f93
60; IASM: .byte 0x93
61; IASM-NEXT: .byte 0x4f
62; IASM-NEXT: .byte 0xc2
Karl Schimpf4175d452015-12-17 08:06:01 -080063; IASM-NEXT: .byte 0xe1
64
65 %retval = zext i8 %v to i32
66 ret i32 %retval
67}
68
69define internal i32 @testI16Form(i32 %ptr, i32 %a) {
70; ASM-LABEL:testI16Form:
John Porto4b6e4b42016-02-17 05:00:59 -080071; DIS-LABEL:<testI16Form>:
Karl Schimpf4175d452015-12-17 08:06:01 -080072; IASM-LABEL:testI16Form:
73
74entry:
Karl Schimpf4175d452015-12-17 08:06:01 -080075 %ptr.asptr = inttoptr i32 %ptr to i16*
76 %a.arg_trunc = trunc i32 %a to i16
77
Karl Schimpf4175d452015-12-17 08:06:01 -080078 %v = call i16 @llvm.nacl.atomic.rmw.i16(i32 1, i16* %ptr.asptr,
79 i16 %a.arg_trunc, i32 6)
Karl Schimpf4175d452015-12-17 08:06:01 -080080; ***** Example of ldrexh *****
John Porto4b6e4b42016-02-17 05:00:59 -080081; ASM: ldrexh r1, [r2]
82; DIS: 84: e1f21f9f
83; IASM: .byte 0x9f
84; IASM-NEXT: .byte 0x1f
85; IASM-NEXT: .byte 0xf2
Karl Schimpf4175d452015-12-17 08:06:01 -080086; IASM-NEXT: .byte 0xe1
87
Karl Schimpf4175d452015-12-17 08:06:01 -080088; ***** Example of strexh *****
John Porto4b6e4b42016-02-17 05:00:59 -080089; ASM: strexh r4, r3, [r2]
90; DIS: 8c: e1e24f93
91; IASM: .byte 0x93
92; IASM-NEXT: .byte 0x4f
93; IASM-NEXT: .byte 0xe2
Karl Schimpf4175d452015-12-17 08:06:01 -080094; IASM-NEXT: .byte 0xe1
95
96 %retval = zext i16 %v to i32
97 ret i32 %retval
98}
99
100define internal i32 @testI32Form(i32 %ptr, i32 %a) {
101; ASM-LABEL:testI32Form:
John Porto4b6e4b42016-02-17 05:00:59 -0800102; DIS-LABEL:<testI32Form>:
Karl Schimpf4175d452015-12-17 08:06:01 -0800103; IASM-LABEL:testI32Form:
104
105entry:
Karl Schimpf4175d452015-12-17 08:06:01 -0800106 %ptr.asptr = inttoptr i32 %ptr to i32*
107 %v = call i32 @llvm.nacl.atomic.rmw.i32(i32 1, i32* %ptr.asptr,
108 i32 %a, i32 6)
109
Karl Schimpf4175d452015-12-17 08:06:01 -0800110; ***** Example of ldrex *****
John Porto4b6e4b42016-02-17 05:00:59 -0800111; ASM: ldrex r1, [r2]
112; DIS: dc: e1921f9f
113; IASM: .byte 0x9f
114; IASM-NEXT: .byte 0x1f
115; IASM-NEXT: .byte 0x92
Karl Schimpf4175d452015-12-17 08:06:01 -0800116; IASM-NEXT: .byte 0xe1
117
Karl Schimpf4175d452015-12-17 08:06:01 -0800118; ***** Example of strex *****
John Porto4b6e4b42016-02-17 05:00:59 -0800119; ASM: strex r4, r3, [r2]
120; DIS: e4: e1824f93
121; IASM: .byte 0x93
122; IASM-NEXT: .byte 0x4f
123; IASM-NEXT: .byte 0x82
Karl Schimpf4175d452015-12-17 08:06:01 -0800124; IASM-NEXT: .byte 0xe1
125
126 ret i32 %v
127}
128
129define internal i64 @testI64Form(i32 %ptr, i64 %a) {
130; ASM-LABEL:testI64Form:
John Porto4b6e4b42016-02-17 05:00:59 -0800131; DIS-LABEL:<testI64Form>:
Karl Schimpf4175d452015-12-17 08:06:01 -0800132; IASM-LABEL:testI64Form:
133
134entry:
Karl Schimpf4175d452015-12-17 08:06:01 -0800135 %ptr.asptr = inttoptr i32 %ptr to i64*
136 %v = call i64 @llvm.nacl.atomic.rmw.i64(i32 1, i64* %ptr.asptr,
137 i64 %a, i32 6)
138
Karl Schimpf4175d452015-12-17 08:06:01 -0800139; ***** Example of ldrexd *****
John Porto4b6e4b42016-02-17 05:00:59 -0800140; ASM: ldrexd r4, r5, [r6]
141; DIS: 13c: e1b64f9f
142; IASM: .byte 0x9f
Karl Schimpf4175d452015-12-17 08:06:01 -0800143; IASM-NEXT: .byte 0x4f
John Porto4b6e4b42016-02-17 05:00:59 -0800144; IASM-NEXT: .byte 0xb6
Karl Schimpf4175d452015-12-17 08:06:01 -0800145; IASM-NEXT: .byte 0xe1
146
Karl Schimpf4175d452015-12-17 08:06:01 -0800147; ***** Example of strexd *****
John Porto4b6e4b42016-02-17 05:00:59 -0800148; ASM: strexd r4, r0, r1, [r6]
149; DIS: 158: e1a64f90
150; IASM: .byte 0x90
151; IASM-NEXT: .byte 0x4f
152; IASM-NEXT: .byte 0xa6
Karl Schimpf4175d452015-12-17 08:06:01 -0800153; IASM-NEXT: .byte 0xe1
154
155 ret i64 %v
156}