Debian Codegraph @

clang/test/Sema/riscv-interrupt-attr-qci.c

raw
1 // RUN: %clang_cc1 -triple riscv32-unknown-elf -target-feature +xqciint -emit-llvm -DCHECK_IR < %s | FileCheck %s
2 // RUN: %clang_cc1 %s -triple riscv32-unknown-elf -target-feature +xqciint -verify=enabled,both -fsyntax-only
3 // RUN: %clang_cc1 %s -triple riscv32-unknown-elf -verify=disabled,both -fsyntax-only
4 // RUN: %clang_cc1 %s -triple riscv32-unknown-elf -target-feature -xqciint -verify=disabled,both -fsyntax-only
5 // RUN: %clang_cc1 %s -triple riscv64-unknown-elf -verify=disabled,both -fsyntax-only -DRV64
6
7 #if defined(CHECK_IR)
8 // Test for QCI extension's interrupt attribute support
9 // CHECK-LABEL: @foo_nest_interrupt() #0
10 // CHECK: ret void
11 __attribute__((interrupt("qci-nest")))
12 void foo_nest_interrupt(void) {}
13
14 // CHECK-LABEL: @foo_nest_nest_interrupt() #0
15 // CHECK: ret void
16 __attribute__((interrupt("qci-nest", "qci-nest")))
17 void foo_nest_nest_interrupt(void) {}
18
19 // CHECK-LABEL: @foo_nonest_interrupt() #1
20 // CHECK: ret void
21 __attribute__((interrupt("qci-nonest")))
22 void foo_nonest_interrupt(void) {}
23
24 // CHECK-LABEL: @foo_nonest_nonest_interrupt() #1
25 // CHECK: ret void
26 __attribute__((interrupt("qci-nonest", "qci-nonest")))
27 void foo_nonest_nonest_interrupt(void) {}
28
29 // CHECK: attributes #0
30 // CHECK: "interrupt"="qci-nest"
31 // CHECK: attributes #1
32 // CHECK: "interrupt"="qci-nonest"
33 #else
34 // Test for QCI extension's interrupt attribute support
35 __attribute__((interrupt(1))) void foo1(void) {} // both-error {{expected string literal as argument of 'interrupt' attribute}}
36 __attribute__((interrupt("qci-nonest", 1))) void foo_nonest2(void) {} // both-error {{expected string literal as argument of 'interrupt' attribute}}
37 __attribute__((interrupt("qci-nest", 1))) void foo_nest2(void) {} // both-error {{expected string literal as argument of 'interrupt' attribute}}
38 __attribute__((interrupt("qci-est"))) void foo_nest3(void) {} // both-warning {{'interrupt' attribute argument not supported: "qci-est"}}
39 __attribute__((interrupt("qci-noest"))) void foo_nonest3(void) {} // both-warning {{'interrupt' attribute argument not supported: "qci-noest"}}
40 __attribute__((interrupt("", "qci-nonest"))) void foo_nonest4(void) {} // both-warning {{'interrupt' attribute argument not supported: ""}}
41 __attribute__((interrupt("", "qci-nest"))) void foo_nest4(void) {} // both-warning {{'interrupt' attribute argument not supported: ""}}
42
43 __attribute__((interrupt("qci-nonest", "qci-nest"))) void foo_nonest5(void) {} // both-error {{RISC-V 'interrupt' attribute contains invalid combination of interrupt types}}
44 __attribute__((interrupt("qci-nest", "qci-nonest"))) void foo_nest5(void) {} // both-error {{RISC-V 'interrupt' attribute contains invalid combination of interrupt types}}
45
46 __attribute__((interrupt("qci-nest"))) void foo_nest(void) {} // disabled-error {{RISC-V 'interrupt' attribute 'qci-nest' requires extension 'Xqciint'}}
47 __attribute__((interrupt("qci-nonest"))) void foo_nonest(void) {} // disabled-error {{RISC-V 'interrupt' attribute 'qci-nonest' requires extension 'Xqciint'}}
48
49 __attribute__((interrupt("qci-nest", "qci-nest"))) void foo_nest_nest(void) {} // disabled-error {{RISC-V 'interrupt' attribute 'qci-nest' requires extension 'Xqciint'}}
50 __attribute__((interrupt("qci-nonest", "qci-nonest"))) void foo_nonest_nonest(void) {} // disabled-error {{RISC-V 'interrupt' attribute 'qci-nonest' requires extension 'Xqciint'}}
51
52
53 // This tests the errors for the qci interrupts when using
54 // `__attribute__((target(...)))` - but they fail on RV64, because you cannot
55 // enable xqciint on rv64.
56 #if __riscv_xlen == 32
57 __attribute__((target("arch=+xqciint"))) __attribute__((interrupt("qci-nest"))) void foo_nest_xqciint(void) {}
58 __attribute__((target("arch=+xqciint"))) __attribute__((interrupt("qci-nonest"))) void foo_nonest_xqciint(void) {}
59
60 // The attribute order is important, the interrupt attribute must come after the
61 // target attribute
62 __attribute__((interrupt("qci-nest"))) __attribute__((target("arch=+xqciint"))) void foo_nest_xqciint2(void) {} // disabled-error {{RISC-V 'interrupt' attribute 'qci-nest' requires extension 'Xqciint'}}
63 __attribute__((interrupt("qci-nonest"))) __attribute__((target("arch=+xqciint"))) void foo_nonest_xqciint2(void) {} // disabled-error {{RISC-V 'interrupt' attribute 'qci-nonest' requires extension 'Xqciint'}}
64 #endif
65
66 #endif