File tree 2 files changed +54
-0
lines changed
2 files changed +54
-0
lines changed Original file line number Diff line number Diff line change
1
+ // RUN: %clang_cc1 -triple riscv32 -O2 -emit-llvm %s -o - \
2
+ // RUN: | FileCheck %s
3
+ // RUN: %clang_cc1 -triple riscv64 -O2 -emit-llvm %s -o - \
4
+ // RUN: | FileCheck %s
5
+
6
+ // Test RISC-V specific inline assembly constraints.
7
+
8
+ void test_I () {
9
+ // CHECK-LABEL: define void @test_I()
10
+ // CHECK: call void asm sideeffect "", "I"(i32 2047)
11
+ asm volatile ("" :: "I" (2047 ));
12
+ // CHECK: call void asm sideeffect "", "I"(i32 -2048)
13
+ asm volatile ("" :: "I" (-2048 ));
14
+ }
15
+
16
+ void test_J () {
17
+ // CHECK-LABEL: define void @test_J()
18
+ // CHECK: call void asm sideeffect "", "J"(i32 0)
19
+ asm volatile ("" :: "J" (0 ));
20
+ }
21
+
22
+ void test_K () {
23
+ // CHECK-LABEL: define void @test_K()
24
+ // CHECK: call void asm sideeffect "", "K"(i32 31)
25
+ asm volatile ("" :: "K" (31 ));
26
+ // CHECK: call void asm sideeffect "", "K"(i32 0)
27
+ asm volatile ("" :: "K" (0 ));
28
+ }
Original file line number Diff line number Diff line change
1
+ // RUN: %clang_cc1 -triple riscv32 -fsyntax-only -verify %s
2
+ // RUN: %clang_cc1 -triple riscv64 -fsyntax-only -verify %s
3
+
4
+ void I (int i ) {
5
+ static const int BelowMin = -2049 ;
6
+ static const int AboveMax = 2048 ;
7
+ asm volatile ("" :: "I" (i )); // expected-error{{constraint 'I' expects an integer constant expression}}
8
+ asm volatile ("" :: "I" (BelowMin )); // expected-error{{value '-2049' out of range for constraint 'I'}}
9
+ asm volatile ("" :: "I" (AboveMax )); // expected-error{{value '2048' out of range for constraint 'I'}}
10
+ }
11
+
12
+ void J (int j ) {
13
+ static const int BelowMin = -1 ;
14
+ static const int AboveMax = 1 ;
15
+ asm volatile ("" :: "J" (j )); // expected-error{{constraint 'J' expects an integer constant expression}}
16
+ asm volatile ("" :: "J" (BelowMin )); // expected-error{{value '-1' out of range for constraint 'J'}}
17
+ asm volatile ("" :: "J" (AboveMax )); // expected-error{{value '1' out of range for constraint 'J'}}
18
+ }
19
+
20
+ void K (int k ) {
21
+ static const int BelowMin = -1 ;
22
+ static const int AboveMax = 32 ;
23
+ asm volatile ("" :: "K" (k )); // expected-error{{constraint 'K' expects an integer constant expression}}
24
+ asm volatile ("" :: "K" (BelowMin )); // expected-error{{value '-1' out of range for constraint 'K'}}
25
+ asm volatile ("" :: "K" (AboveMax )); // expected-error{{value '32' out of range for constraint 'K'}}
26
+ }
You can’t perform that action at this time.
0 commit comments