Files
clang-p2996/llvm/test/CodeGen/LoongArch/inline-asm-reg-names-error.ll
Weining Lu 394f30919a [Clang][LoongArch] Add inline asm support for constraints f/l/I/K
This patch adds support for constraints `f`, `l`, `I`, `K` according
to [1]. The remain constraints (`k`, `m`, `ZB`, `ZC`) will be added
later as they are a little more complex than the others.
f: A floating-point register (if available).
l: A signed 16-bit constant.
I: A signed 12-bit constant (for arithmetic instructions).
K: An unsigned 12-bit constant (for logic instructions).

For now, no need to support register alias (e.g. `$a0`) in llvm as
clang will correctly decode the usage of register name aliases into
their official names. And AFAIK, the not yet upstreamed `rustc` for
LoongArch will always use official register names (e.g. `$r4`).

[1] https://gcc.gnu.org/onlinedocs/gccint/Machine-Constraints.html

Differential Revision: https://reviews.llvm.org/D134157
2022-09-26 08:49:58 +08:00

15 lines
510 B
LLVM

; RUN: not llc --mtriple=loongarch32 2>&1 < %s | FileCheck %s
; RUN: not llc --mtriple=loongarch64 2>&1 < %s | FileCheck %s
define i32 @non_exit_r32(i32 %a) nounwind {
; CHECK: error: couldn't allocate input reg for constraint '{$r32}'
%1 = tail call i32 asm "addi.w $0, $1, 1", "=r,{$r32}"(i32 %a)
ret i32 %1
}
define i32 @non_exit_foo(i32 %a) nounwind {
; CHECK: error: couldn't allocate input reg for constraint '{$foo}'
%1 = tail call i32 asm "addi.w $0, $1, 1", "=r,{$foo}"(i32 %a)
ret i32 %1
}