[PATCH] D134157: [LoongArch] Add inline asm support for constraints f/l/I/K

Lu Weining via Phabricator via cfe-commits cfe-commits at lists.llvm.org
Sun Sep 18 22:56:26 PDT 2022


SixWeining created this revision.
SixWeining added reviewers: xen0n, MaskRay, xry111, rengolin, myhsu, wangleiat, gonglingqin.
Herald added subscribers: StephenFan, JDevlieghere, hiraditya.
Herald added a project: All.
SixWeining requested review of this revision.
Herald added projects: clang, LLVM.
Herald added subscribers: llvm-commits, cfe-commits.

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


Repository:
  rG LLVM Github Monorepo

https://reviews.llvm.org/D134157

Files:
  clang/lib/Basic/Targets/LoongArch.cpp
  clang/test/CodeGen/LoongArch/inline-asm-constraints-error.c
  clang/test/CodeGen/LoongArch/inline-asm-constraints.c
  clang/test/CodeGen/LoongArch/inline-asm-gcc-regs-error.c
  clang/test/CodeGen/LoongArch/inline-asm-gcc-regs.c
  llvm/lib/Target/LoongArch/LoongArchAsmPrinter.cpp
  llvm/lib/Target/LoongArch/LoongArchAsmPrinter.h
  llvm/lib/Target/LoongArch/LoongArchISelLowering.cpp
  llvm/lib/Target/LoongArch/LoongArchISelLowering.h
  llvm/test/CodeGen/LoongArch/inline-asm-clobbers.ll
  llvm/test/CodeGen/LoongArch/inline-asm-constraint-error.ll
  llvm/test/CodeGen/LoongArch/inline-asm-constraint-f.ll
  llvm/test/CodeGen/LoongArch/inline-asm-constraint.ll
  llvm/test/CodeGen/LoongArch/inline-asm-reg-names-error.ll
  llvm/test/CodeGen/LoongArch/inline-asm-reg-names-f-error.ll
  llvm/test/CodeGen/LoongArch/inline-asm-reg-names-f.ll
  llvm/test/CodeGen/LoongArch/inline-asm-reg-names.ll

-------------- next part --------------
A non-text attachment was scrubbed...
Name: D134157.461137.patch
Type: text/x-patch
Size: 43100 bytes
Desc: not available
URL: <http://lists.llvm.org/pipermail/cfe-commits/attachments/20220919/ad464e9a/attachment-0001.bin>


More information about the cfe-commits mailing list