[PATCH] D54091: [RISCV] Add inline asm constraints I, J & K for RISC-V

Lewis Revill via Phabricator via cfe-commits cfe-commits at lists.llvm.org
Tue Jun 11 05:40:57 PDT 2019


This revision was automatically updated to reflect the committed changes.
Closed by commit rL363055: [RISCV] Add inline asm constraints I, J & K for RISC-V (authored by lewis-revill, committed by ).

Changed prior to commit:
  https://reviews.llvm.org/D54091?vs=203367&id=204043#toc

Repository:
  rL LLVM

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

https://reviews.llvm.org/D54091

Files:
  cfe/trunk/lib/Basic/Targets/RISCV.cpp
  cfe/trunk/lib/Basic/Targets/RISCV.h


Index: cfe/trunk/lib/Basic/Targets/RISCV.cpp
===================================================================
--- cfe/trunk/lib/Basic/Targets/RISCV.cpp
+++ cfe/trunk/lib/Basic/Targets/RISCV.cpp
@@ -39,6 +39,26 @@
   return llvm::makeArrayRef(GCCRegAliases);
 }
 
+bool RISCVTargetInfo::validateAsmConstraint(
+    const char *&Name, TargetInfo::ConstraintInfo &Info) const {
+  switch (*Name) {
+  default:
+    return false;
+  case 'I':
+    // A 12-bit signed immediate.
+    Info.setRequiresImmediate(-2048, 2047);
+    return true;
+  case 'J':
+    // Integer zero.
+    Info.setRequiresImmediate(0);
+    return true;
+  case 'K':
+    // A 5-bit unsigned immediate for CSR access instructions.
+    Info.setRequiresImmediate(0, 31);
+    return true;
+  }
+}
+
 void RISCVTargetInfo::getTargetDefines(const LangOptions &Opts,
                                        MacroBuilder &Builder) const {
   Builder.defineMacro("__ELF__");
Index: cfe/trunk/lib/Basic/Targets/RISCV.h
===================================================================
--- cfe/trunk/lib/Basic/Targets/RISCV.h
+++ cfe/trunk/lib/Basic/Targets/RISCV.h
@@ -61,9 +61,7 @@
   ArrayRef<TargetInfo::GCCRegAlias> getGCCRegAliases() const override;
 
   bool validateAsmConstraint(const char *&Name,
-                             TargetInfo::ConstraintInfo &Info) const override {
-    return false;
-  }
+                             TargetInfo::ConstraintInfo &Info) const override;
 
   bool hasFeature(StringRef Feature) const override;
 


-------------- next part --------------
A non-text attachment was scrubbed...
Name: D54091.204043.patch
Type: text/x-patch
Size: 1518 bytes
Desc: not available
URL: <http://lists.llvm.org/pipermail/cfe-commits/attachments/20190611/a0dceed9/attachment-0001.bin>


More information about the cfe-commits mailing list