1; 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: 31; DIS-LABEL:<testI8Form>: 32; IASM-LABEL:testI8Form: 33 34entry: 35 %ptr.asptr = inttoptr i32 %ptr to i8* 36 %a.arg_trunc = trunc i32 %a to i8 37 38 %v = call i8 @llvm.nacl.atomic.rmw.i8(i32 1, i8* %ptr.asptr, 39 i8 %a.arg_trunc, i32 6) 40 41; ****** Example of dmb ******* 42; ASM: dmb sy 43; DIS: 1c: f57ff05f 44; IASM: .byte 0x5f 45; IASM-NEXT: .byte 0xf0 46; IASM-NEXT: .byte 0x7f 47; IASM-NEXT: .byte 0xf5 48 49; ***** Example of ldrexb ***** 50; ASM: ldrexb r1, [r2] 51; DIS: 24: e1d21f9f 52; IASM: .byte 0x9f 53; IASM-NEXT: .byte 0x1f 54; IASM-NEXT: .byte 0xd2 55; IASM-NEXT: .byte 0xe1 56 57; ***** Example of strexb ***** 58; ASM: strexb r4, r3, [r2] 59; DIS: 2c: e1c24f93 60; IASM: .byte 0x93 61; IASM-NEXT: .byte 0x4f 62; IASM-NEXT: .byte 0xc2 63; 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: 71; DIS-LABEL:<testI16Form>: 72; IASM-LABEL:testI16Form: 73 74entry: 75 %ptr.asptr = inttoptr i32 %ptr to i16* 76 %a.arg_trunc = trunc i32 %a to i16 77 78 %v = call i16 @llvm.nacl.atomic.rmw.i16(i32 1, i16* %ptr.asptr, 79 i16 %a.arg_trunc, i32 6) 80; ***** Example of ldrexh ***** 81; ASM: ldrexh r1, [r2] 82; DIS: 84: e1f21f9f 83; IASM: .byte 0x9f 84; IASM-NEXT: .byte 0x1f 85; IASM-NEXT: .byte 0xf2 86; IASM-NEXT: .byte 0xe1 87 88; ***** Example of strexh ***** 89; ASM: strexh r4, r3, [r2] 90; DIS: 8c: e1e24f93 91; IASM: .byte 0x93 92; IASM-NEXT: .byte 0x4f 93; IASM-NEXT: .byte 0xe2 94; 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: 102; DIS-LABEL:<testI32Form>: 103; IASM-LABEL:testI32Form: 104 105entry: 106 %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 110; ***** Example of ldrex ***** 111; ASM: ldrex r1, [r2] 112; DIS: dc: e1921f9f 113; IASM: .byte 0x9f 114; IASM-NEXT: .byte 0x1f 115; IASM-NEXT: .byte 0x92 116; IASM-NEXT: .byte 0xe1 117 118; ***** Example of strex ***** 119; ASM: strex r4, r3, [r2] 120; DIS: e4: e1824f93 121; IASM: .byte 0x93 122; IASM-NEXT: .byte 0x4f 123; IASM-NEXT: .byte 0x82 124; IASM-NEXT: .byte 0xe1 125 126 ret i32 %v 127} 128 129define internal i64 @testI64Form(i32 %ptr, i64 %a) { 130; ASM-LABEL:testI64Form: 131; DIS-LABEL:<testI64Form>: 132; IASM-LABEL:testI64Form: 133 134entry: 135 %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 139; ***** Example of ldrexd ***** 140; ASM: ldrexd r4, r5, [r6] 141; DIS: 13c: e1b64f9f 142; IASM: .byte 0x9f 143; IASM-NEXT: .byte 0x4f 144; IASM-NEXT: .byte 0xb6 145; IASM-NEXT: .byte 0xe1 146 147; ***** Example of strexd ***** 148; ASM: strexd r4, r0, r1, [r6] 149; DIS: 158: e1a64f90 150; IASM: .byte 0x90 151; IASM-NEXT: .byte 0x4f 152; IASM-NEXT: .byte 0xa6 153; IASM-NEXT: .byte 0xe1 154 155 ret i64 %v 156} 157