| 1 |
// RUN: %clang_cc1 -triple riscv32-unknown-elf -target-feature +experimental-xsfmclic -emit-llvm -DCHECK_IR < %s| FileCheck %s |
| 2 |
// RUN: %clang_cc1 -triple riscv64-unknown-elf -target-feature +experimental-xsfmclic -emit-llvm -DCHECK_IR < %s| FileCheck %s |
| 3 |
// RUN: %clang_cc1 %s -triple riscv32-unknown-elf -target-feature +experimental-xsfmclic -verify=enabled,both -fsyntax-only |
| 4 |
// RUN: %clang_cc1 %s -triple riscv64-unknown-elf -target-feature +experimental-xsfmclic -verify=enabled,both -fsyntax-only |
| 5 |
// RUN: %clang_cc1 %s -triple riscv32-unknown-elf -verify=disabled,both -fsyntax-only |
| 6 |
// RUN: %clang_cc1 %s -triple riscv64-unknown-elf -verify=disabled,both -fsyntax-only |
| 7 |
// RUN: %clang_cc1 %s -triple riscv32-unknown-elf -target-feature -experimental-xsfmclic -verify=disabled,both -fsyntax-only |
| 8 |
// RUN: %clang_cc1 %s -triple riscv64-unknown-elf -target-feature -experimental-xsfmclic -verify=disabled,both -fsyntax-only |
| 9 |
|
| 10 |
#if defined(CHECK_IR) |
| 11 |
// CHECK-LABEL: @foo_stack_swap() #0 |
| 12 |
// CHECK: ret void |
| 13 |
__attribute__((interrupt("SiFive-CLIC-stack-swap"))) void foo_stack_swap(void) {} |
| 14 |
|
| 15 |
// CHECK-LABEL: @foo_preemptible() #1 |
| 16 |
// CHECK: ret void |
| 17 |
__attribute__((interrupt("SiFive-CLIC-preemptible"))) void foo_preemptible(void) {} |
| 18 |
|
| 19 |
// CHECK-LABEL: @foo_stack_swap_preemptible() #2 |
| 20 |
// CHECK: ret void |
| 21 |
__attribute__((interrupt("SiFive-CLIC-stack-swap", "SiFive-CLIC-preemptible"))) |
| 22 |
void foo_stack_swap_preemptible(void) {} |
| 23 |
|
| 24 |
// CHECK-LABEL: @foo_preemptible_stack_swap() #2 |
| 25 |
// CHECK: ret void |
| 26 |
__attribute__((interrupt("SiFive-CLIC-preemptible", "SiFive-CLIC-stack-swap"))) |
| 27 |
void foo_preemptible_stack_swap(void) {} |
| 28 |
|
| 29 |
// CHECK-LABEL: @foo_stack_swap_repeat() #0 |
| 30 |
// CHECK: ret void |
| 31 |
__attribute__((interrupt("SiFive-CLIC-stack-swap", "SiFive-CLIC-stack-swap"))) |
| 32 |
void foo_stack_swap_repeat(void) {} |
| 33 |
|
| 34 |
// CHECK-LABEL: @foo_preemptible_repeat() #1 |
| 35 |
// CHECK: ret void |
| 36 |
__attribute__((interrupt("SiFive-CLIC-preemptible", "SiFive-CLIC-preemptible"))) |
| 37 |
void foo_preemptible_repeat(void) {} |
| 38 |
|
| 39 |
// CHECK-LABEL: @foo_machine_stack_swap() #0 |
| 40 |
// CHECK: ret void |
| 41 |
__attribute__((interrupt("machine", "SiFive-CLIC-stack-swap"))) |
| 42 |
void foo_machine_stack_swap(void) {} |
| 43 |
|
| 44 |
// CHECK-LABEL: @foo_stack_swap_machine() #0 |
| 45 |
// CHECK: ret void |
| 46 |
__attribute__((interrupt("SiFive-CLIC-stack-swap", "machine"))) |
| 47 |
void foo_stack_swap_machine(void) {} |
| 48 |
|
| 49 |
// CHECK-LABEL: @foo_preemptible_machine() #1 |
| 50 |
// CHECK: ret void |
| 51 |
__attribute__((interrupt("SiFive-CLIC-preemptible", "machine"))) |
| 52 |
void foo_preemptible_machine(void) {} |
| 53 |
|
| 54 |
// CHECK-LABEL: @foo_machine_preemptible() #1 |
| 55 |
// CHECK: ret void |
| 56 |
__attribute__((interrupt("machine", "SiFive-CLIC-preemptible"))) |
| 57 |
void foo_machine_preemptible(void) {} |
| 58 |
|
| 59 |
|
| 60 |
// CHECK: attributes #0 |
| 61 |
// CHECK: "interrupt"="SiFive-CLIC-stack-swap" |
| 62 |
// CHECK: attributes #1 |
| 63 |
// CHECK: "interrupt"="SiFive-CLIC-preemptible" |
| 64 |
// CHECK: attributes #2 |
| 65 |
// CHECK: "interrupt"="SiFive-CLIC-preemptible-stack-swap" |
| 66 |
#else |
| 67 |
|
| 68 |
__attribute__((interrupt("SiFive-CLIC-stack-swap"))) void foo15(void); // disabled-error {{RISC-V 'interrupt' attribute 'SiFive-CLIC-stack-swap' requires extension 'XSfmclic'}} |
| 69 |
__attribute__((interrupt("SiFive-CLIC-stack-swap", "SiFive-CLIC-stack-swap"))) void foo15(void); // disabled-error {{RISC-V 'interrupt' attribute 'SiFive-CLIC-stack-swap' requires extension 'XSfmclic'}} |
| 70 |
__attribute__((interrupt("SiFive-CLIC-stack-swap", "machine"))) void foo15(void); // disabled-error {{RISC-V 'interrupt' attribute 'SiFive-CLIC-stack-swap' requires extension 'XSfmclic'}} |
| 71 |
__attribute__((interrupt("machine", "SiFive-CLIC-stack-swap"))) void foo15(void); // disabled-error {{RISC-V 'interrupt' attribute 'SiFive-CLIC-stack-swap' requires extension 'XSfmclic'}} |
| 72 |
|
| 73 |
__attribute__((interrupt("SiFive-CLIC-preemptible"))) void foo15(void); // disabled-error {{RISC-V 'interrupt' attribute 'SiFive-CLIC-preemptible' requires extension 'XSfmclic'}} |
| 74 |
__attribute__((interrupt("SiFive-CLIC-preemptible", "SiFive-CLIC-preemptible"))) void foo15(void); // disabled-error {{RISC-V 'interrupt' attribute 'SiFive-CLIC-preemptible' requires extension 'XSfmclic'}} |
| 75 |
__attribute__((interrupt("SiFive-CLIC-preemptible", "machine"))) void foo15(void); // disabled-error {{RISC-V 'interrupt' attribute 'SiFive-CLIC-preemptible' requires extension 'XSfmclic'}} |
| 76 |
__attribute__((interrupt("machine", "SiFive-CLIC-preemptible"))) void foo15(void); // disabled-error {{RISC-V 'interrupt' attribute 'SiFive-CLIC-preemptible' requires extension 'XSfmclic'}} |
| 77 |
|
| 78 |
__attribute__((interrupt("SiFive-CLIC-preemptible", "SiFive-CLIC-stack-swap"))) void foo16(void) {} // disabled-error {{RISC-V 'interrupt' attribute 'SiFive-CLIC-preemptible' requires extension 'XSfmclic'}} |
| 79 |
__attribute__((interrupt("SiFive-CLIC-stack-swap", "SiFive-CLIC-preemptible"))) void foo17(void) {} // disabled-error {{RISC-V 'interrupt' attribute 'SiFive-CLIC-stack-swap' requires extension 'XSfmclic'}} |
| 80 |
|
| 81 |
__attribute__((interrupt("machine", "machine", "SiFive-CLIC-preemptible"))) void foo24(void) {} // both-error {{'interrupt' attribute takes no more than 2 arguments}} |
| 82 |
|
| 83 |
__attribute__((interrupt("SiFive-CLIC-preemptible", "supervisor"))) void foo27(void) {} // both-error {{RISC-V 'interrupt' attribute contains invalid combination of interrupt types}} |
| 84 |
|
| 85 |
__attribute__((interrupt("supervisor", "SiFive-CLIC-stack-swap"))) void foo28(void) {} // both-error {{RISC-V 'interrupt' attribute contains invalid combination of interrupt types}} |
| 86 |
|
| 87 |
__attribute__((interrupt("SiFive-CLIC-stack-swap", 1))) void foo29(void) {} // both-error {{expected string literal as argument of 'interrupt' attribute}} |
| 88 |
|
| 89 |
__attribute__((interrupt(1, "SiFive-CLIC-stack-swap"))) void foo30(void) {} // both-error {{expected string literal as argument of 'interrupt' attribute}} |
| 90 |
|
| 91 |
__attribute__((interrupt("SiFive-CLIC-stack-swap", "foo"))) void foo31(void) {} // both-warning {{'interrupt' attribute argument not supported: "foo"}} |
| 92 |
|
| 93 |
__attribute__((interrupt("foo", "SiFive-CLIC-stack-swap"))) void foo32(void) {} // both-warning {{'interrupt' attribute argument not supported: "foo"}} |
| 94 |
|
| 95 |
|
| 96 |
__attribute__((target("arch=+xsfmclic"))) __attribute__((interrupt("SiFive-CLIC-preemptible"))) void foo_sfmclic_preemptible(void) {} |
| 97 |
__attribute__((target("arch=+xsfmclic"))) __attribute__((interrupt("SiFive-CLIC-stack-swap"))) void foo_sfmclic_stack_swap(void) {} |
| 98 |
__attribute__((target("arch=+xsfmclic"))) __attribute__((interrupt("SiFive-CLIC-preemptible", "SiFive-CLIC-stack-swap"))) void foo_sfmclic_both(void) {} |
| 99 |
|
| 100 |
// The attribute order is important, the interrupt attribute must come after the |
| 101 |
// target attribute |
| 102 |
__attribute__((interrupt("SiFive-CLIC-preemptible"))) __attribute__((target("arch=+xsfmclic"))) void foo_preemptible_sfmclic(void) {} // disabled-error {{RISC-V 'interrupt' attribute 'SiFive-CLIC-preemptible' requires extension 'XSfmclic'}} |
| 103 |
__attribute__((interrupt("SiFive-CLIC-stack-swap"))) __attribute__((target("arch=+xsfmclic"))) void fooc_stack_swap_sfmclic(void) {} // disabled-error {{RISC-V 'interrupt' attribute 'SiFive-CLIC-stack-swap' requires extension 'XSfmclic'}} |
| 104 |
__attribute__((interrupt("SiFive-CLIC-preemptible", "SiFive-CLIC-stack-swap"))) __attribute__((target("arch=+xsfmclic"))) void foo_both_sfmclic(void) {} // disabled-error {{RISC-V 'interrupt' attribute 'SiFive-CLIC-preemptible' requires extension 'XSfmclic'}} |
| 105 |
|
| 106 |
#endif |