[PATCH] D108624: [Clang][RISCV] Implement getConstraintRegister for RISC-V

Luís Marques via Phabricator via cfe-commits cfe-commits at lists.llvm.org
Tue Aug 24 05:19:31 PDT 2021


luismarques updated this revision to Diff 368323.
luismarques added a comment.

Nit: remove nop.


Repository:
  rG LLVM Github Monorepo

CHANGES SINCE LAST ACTION
  https://reviews.llvm.org/D108624/new/

https://reviews.llvm.org/D108624

Files:
  clang/lib/Basic/Targets/RISCV.h
  clang/test/Sema/inline-asm-validate-riscv.c


Index: clang/test/Sema/inline-asm-validate-riscv.c
===================================================================
--- clang/test/Sema/inline-asm-validate-riscv.c
+++ clang/test/Sema/inline-asm-validate-riscv.c
@@ -21,3 +21,11 @@
   asm volatile ("" :: "K"(BelowMin)); // expected-error{{value '-1' out of range for constraint 'K'}}
   asm volatile ("" :: "K"(AboveMax)); // expected-error{{value '32' out of range for constraint 'K'}}
 }
+
+void test_clobber_conflict(void) {
+  register long x10 asm("x10");
+  asm volatile("" :: "r"(x10) : "x10"); // expected-error {{conflicts with asm clobber list}}
+  asm volatile("" :: "r"(x10) : "a0"); // expected-error {{conflicts with asm clobber list}}
+  asm volatile("" : "=r"(x10) :: "x10"); // expected-error {{conflicts with asm clobber list}}
+  asm volatile("" : "=r"(x10) :: "a0"); // expected-error {{conflicts with asm clobber list}}
+}
Index: clang/lib/Basic/Targets/RISCV.h
===================================================================
--- clang/lib/Basic/Targets/RISCV.h
+++ clang/lib/Basic/Targets/RISCV.h
@@ -82,6 +82,11 @@
 
   const char *getClobbers() const override { return ""; }
 
+  StringRef getConstraintRegister(StringRef Constraint,
+                                  StringRef Expression) const override {
+    return Expression;
+  }
+
   ArrayRef<const char *> getGCCRegNames() const override;
 
   int getEHDataRegisterNumber(unsigned RegNo) const override {


-------------- next part --------------
A non-text attachment was scrubbed...
Name: D108624.368323.patch
Type: text/x-patch
Size: 1445 bytes
Desc: not available
URL: <http://lists.llvm.org/pipermail/cfe-commits/attachments/20210824/9c6c7974/attachment.bin>


More information about the cfe-commits mailing list