[llvm] Use Module level target-abi to assign target features for codegenerated functions. (PR #100833)

via llvm-commits llvm-commits at lists.llvm.org
Thu Feb 6 15:53:53 PST 2025


================
@@ -387,6 +388,25 @@ Function *Function::Create(FunctionType *Ty, LinkageTypes Linkage,
   return Create(Ty, Linkage, M.getDataLayout().getProgramAddressSpace(), N, &M);
 }
 
+StringRef Function::getDefaultTargetFeatures(const StringRef TargetABI) {
+  Triple T(getParent()->getTargetTriple());
+  StringRef attr = "";
+  if (T.isRISCV64()) {
+    if (TargetABI.equals_insensitive("lp64d"))
+      attr = "+d";
+    else if (TargetABI.equals_insensitive("lp64f"))
+      attr = "+f";
+    else if (TargetABI.equals_insensitive("lp64q"))
+      attr = "+q";
+  } else if (T.isRISCV32() && TargetABI.contains("ilp32f")) {
+    attr = "+f";
+  } else if (T.isARM() || T.isThumb()) {
+    attr = "+thumb-mode";
----------------
hiraditya wrote:

(To be tested) but i think https://github.com/llvm/llvm-project/pull/78253/files should have fixed it. https://godbolt.org/z/67hdMvfGv clang adds all the required attributes.

https://github.com/llvm/llvm-project/pull/100833


More information about the llvm-commits mailing list