1 ; RUN: llc -mtriple=arm64-apple-darwin -enable-misched=0 -mcpu=cyclone < %s | FileCheck %s 2 ; RUN: llc -mtriple=arm64-apple-darwin -enable-misched=0 -mcpu=cyclone -fast-isel < %s | FileCheck %s --check-prefix=FAST 3 4 ; One argument will be passed in register, the other will be pushed on the stack. 5 ; Return value in x0. 6 define void @jscall_patchpoint_codegen(i64 %p1, i64 %p2, i64 %p3, i64 %p4) { 7 entry: 8 ; CHECK-LABEL: jscall_patchpoint_codegen: 9 ; CHECK: Ltmp 10 ; CHECK: str x{{.+}}, [sp, #-16]! 11 ; CHECK-NEXT: mov x0, x{{.+}} 12 ; CHECK: Ltmp 13 ; CHECK-NEXT: movz x16, #0xffff, lsl #32 14 ; CHECK-NEXT: movk x16, #0xdead, lsl #16 15 ; CHECK-NEXT: movk x16, #0xbeef 16 ; CHECK-NEXT: blr x16 17 ; FAST-LABEL: jscall_patchpoint_codegen: 18 ; FAST: Ltmp 19 ; FAST: str x{{.+}}, [sp, #-16]! 20 ; FAST: Ltmp 21 ; FAST-NEXT: movz x16, #0xffff, lsl #32 22 ; FAST-NEXT: movk x16, #0xdead, lsl #16 23 ; FAST-NEXT: movk x16, #0xbeef 24 ; FAST-NEXT: blr x16 25 %resolveCall2 = inttoptr i64 281474417671919 to i8* 26 %result = tail call webkit_jscc i64 (i64, i32, i8*, i32, ...) @llvm.experimental.patchpoint.i64(i64 5, i32 20, i8* %resolveCall2, i32 2, i64 %p4, i64 %p2) 27 %resolveCall3 = inttoptr i64 244837814038255 to i8* 28 tail call webkit_jscc void (i64, i32, i8*, i32, ...) @llvm.experimental.patchpoint.void(i64 6, i32 20, i8* %resolveCall3, i32 2, i64 %p4, i64 %result) 29 ret void 30 } 31 32 ; Test if the arguments are properly aligned and that we don't store undef arguments. 33 define i64 @jscall_patchpoint_codegen2(i64 %callee) { 34 entry: 35 ; CHECK-LABEL: jscall_patchpoint_codegen2: 36 ; CHECK: Ltmp 37 ; CHECK: orr w[[REG:[0-9]+]], wzr, #0x6 38 ; CHECK-NEXT: str x[[REG]], [sp, #24] 39 ; CHECK-NEXT: orr w[[REG:[0-9]+]], wzr, #0x4 40 ; CHECK-NEXT: str w[[REG]], [sp, #16] 41 ; CHECK-NEXT: orr w[[REG:[0-9]+]], wzr, #0x2 42 ; CHECK-NEXT: str x[[REG]], [sp] 43 ; CHECK: Ltmp 44 ; CHECK-NEXT: movz x16, #0xffff, lsl #32 45 ; CHECK-NEXT: movk x16, #0xdead, lsl #16 46 ; CHECK-NEXT: movk x16, #0xbeef 47 ; CHECK-NEXT: blr x16 48 ; FAST-LABEL: jscall_patchpoint_codegen2: 49 ; FAST: Ltmp 50 ; FAST: orr [[REG1:x[0-9]+]], xzr, #0x2 51 ; FAST-NEXT: orr [[REG2:w[0-9]+]], wzr, #0x4 52 ; FAST-NEXT: orr [[REG3:x[0-9]+]], xzr, #0x6 53 ; FAST-NEXT: str [[REG1]], [sp, #-32]! 54 ; FAST-NEXT: str [[REG2]], [sp, #16] 55 ; FAST-NEXT: str [[REG3]], [sp, #24] 56 ; FAST: Ltmp 57 ; FAST-NEXT: movz x16, #0xffff, lsl #32 58 ; FAST-NEXT: movk x16, #0xdead, lsl #16 59 ; FAST-NEXT: movk x16, #0xbeef 60 ; FAST-NEXT: blr x16 61 %call = inttoptr i64 281474417671919 to i8* 62 %result = call webkit_jscc i64 (i64, i32, i8*, i32, ...) @llvm.experimental.patchpoint.i64(i64 7, i32 20, i8* %call, i32 6, i64 %callee, i64 2, i64 undef, i32 4, i32 undef, i64 6) 63 ret i64 %result 64 } 65 66 ; Test if the arguments are properly aligned and that we don't store undef arguments. 67 define i64 @jscall_patchpoint_codegen3(i64 %callee) { 68 entry: 69 ; CHECK-LABEL: jscall_patchpoint_codegen3: 70 ; CHECK: Ltmp 71 ; CHECK: movz w[[REG:[0-9]+]], #0xa 72 ; CHECK-NEXT: str x[[REG]], [sp, #48] 73 ; CHECK-NEXT: orr w[[REG:[0-9]+]], wzr, #0x8 74 ; CHECK-NEXT: str w[[REG]], [sp, #36] 75 ; CHECK-NEXT: orr w[[REG:[0-9]+]], wzr, #0x6 76 ; CHECK-NEXT: str x[[REG]], [sp, #24] 77 ; CHECK-NEXT: orr w[[REG:[0-9]+]], wzr, #0x4 78 ; CHECK-NEXT: str w[[REG]], [sp, #16] 79 ; CHECK-NEXT: orr w[[REG:[0-9]+]], wzr, #0x2 80 ; CHECK-NEXT: str x[[REG]], [sp] 81 ; CHECK: Ltmp 82 ; CHECK-NEXT: movz x16, #0xffff, lsl #32 83 ; CHECK-NEXT: movk x16, #0xdead, lsl #16 84 ; CHECK-NEXT: movk x16, #0xbeef 85 ; CHECK-NEXT: blr x16 86 ; FAST-LABEL: jscall_patchpoint_codegen3: 87 ; FAST: Ltmp 88 ; FAST: orr [[REG1:x[0-9]+]], xzr, #0x2 89 ; FAST-NEXT: orr [[REG2:w[0-9]+]], wzr, #0x4 90 ; FAST-NEXT: orr [[REG3:x[0-9]+]], xzr, #0x6 91 ; FAST-NEXT: orr [[REG4:w[0-9]+]], wzr, #0x8 92 ; FAST-NEXT: movz [[REG5:x[0-9]+]], #0xa 93 ; FAST-NEXT: str [[REG1]], [sp, #-64]! 94 ; FAST-NEXT: str [[REG2]], [sp, #16] 95 ; FAST-NEXT: str [[REG3]], [sp, #24] 96 ; FAST-NEXT: str [[REG4]], [sp, #36] 97 ; FAST-NEXT: str [[REG5]], [sp, #48] 98 ; FAST: Ltmp 99 ; FAST-NEXT: movz x16, #0xffff, lsl #32 100 ; FAST-NEXT: movk x16, #0xdead, lsl #16 101 ; FAST-NEXT: movk x16, #0xbeef 102 ; FAST-NEXT: blr x16 103 %call = inttoptr i64 281474417671919 to i8* 104 %result = call webkit_jscc i64 (i64, i32, i8*, i32, ...) @llvm.experimental.patchpoint.i64(i64 7, i32 20, i8* %call, i32 10, i64 %callee, i64 2, i64 undef, i32 4, i32 undef, i64 6, i32 undef, i32 8, i32 undef, i64 10) 105 ret i64 %result 106 } 107 108 ; CHECK-LABEL: test_i16: 109 ; CHECK: ldrh [[BREG:w[0-9]+]], [sp] 110 ; CHECK: add {{w[0-9]+}}, w0, [[BREG]] 111 define webkit_jscc zeroext i16 @test_i16(i16 zeroext %a, i16 zeroext %b) { 112 %sum = add i16 %a, %b 113 ret i16 %sum 114 } 115 116 declare void @llvm.experimental.patchpoint.void(i64, i32, i8*, i32, ...) 117 declare i64 @llvm.experimental.patchpoint.i64(i64, i32, i8*, i32, ...) 118 119