[all-commits] [llvm/llvm-project] 394f30: [Clang][LoongArch] Add inline asm support for cons...

Lu Weining via All-commits all-commits at lists.llvm.org
Sun Sep 25 18:17:45 PDT 2022


  Branch: refs/heads/main
  Home:   https://github.com/llvm/llvm-project
  Commit: 394f30919a029331ebdfe02c180bd1586c0d9ace
      https://github.com/llvm/llvm-project/commit/394f30919a029331ebdfe02c180bd1586c0d9ace
  Author: Weining Lu <luweining at loongson.cn>
  Date:   2022-09-26 (Mon, 26 Sep 2022)

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

  Log Message:
  -----------
  [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




More information about the All-commits mailing list