This validate and lower arguments to inline asm nodes which have the constraints vi, vi and vk, with the following semantics (equivalent to GCC):
vi: vector 5-bit signed immediate.
vj: vector negated 5-bit signed immediate.
vk: vector 5-bit unsigned immediate.
Details
Details
Diff Detail
Diff Detail
- Repository
- rG LLVM Github Monorepo
Event Timeline
llvm/lib/Target/RISCV/RISCVISelLowering.cpp | ||
---|---|---|
16095 | Can we merge this if into the previous else so we have if (Constraint.length() == 1) { ... } else if (Constraint == "vi") { ... } else if (Constraint == "vk") { ... } else if (Constraint == "vj") { ... } |
Comment Actions
Ooops, hold on, GCC actually is accepting immediate vector value instead of immediate scalar value.
(define_constraint "vi" "A vector 5-bit signed immediate." (and (match_code "const_vector") (match_test "riscv_vector::const_vec_all_same_in_range_p (op, -16, 15)"))) (define_constraint "vj" "A vector negated 5-bit signed immediate." (and (match_code "const_vector") (match_test "riscv_vector::const_vec_all_same_in_range_p (op, -15, 16)"))) (define_constraint "vk" "A vector 5-bit unsigned immediate." (and (match_code "const_vector") (match_test "riscv_vector::const_vec_all_same_in_range_p (op, 0, 31)")))
I mean GCC can't really accept immediate value with either vi, vk or vj:
$ cat x.c int foo() { asm volatile("## %0" :/*write*/ :/*read*/ "vi"(10): /* clobber */); return 0; } $ riscv64-unknown-linux-gnu-gcc x.c -o - -S -O3 .file "x.c" .option nopic .attribute arch, "rv64i2p1_m2p0_a2p1_f2p2_d2p2_c2p0_zicsr2p0" .attribute unaligned_access, 0 .attribute stack_align, 16 .text x.c: In function 'foo': x.c:2:5: warning: 'asm' operand 0 probably does not match constraints 2 | asm volatile("## %0" :/*write*/ :/*read*/ "vi"(10): /* clobber */); | ^~~ x.c:2:5: error: impossible constraint in 'asm' .align 1 .globl foo .type foo, @function foo: .LFB0: .cfi_startproc li a0,0 ret .cfi_endproc .LFE0: .size foo, .-foo
Can we merge this if into the previous else so we have