// TODO: select appropiate ABI.
return Triple.getArch() == llvm::Triple::loongarch32 ? "ilp32d" : "lp64d";
}
+
+void loongarch::getLoongArchTargetFeatures(const Driver &D,
+ const llvm::Triple &Triple,
+ const ArgList &Args,
+ std::vector<StringRef> &Features) {
+ // FIXME: hornor various clang options that may affect target features, e.g.
+ // -march/-mtune/-mdouble-float/-msingle-float/-msoft-float/-mfpu. See:
+ // https://loongson.github.io/LoongArch-Documentation/LoongArch-toolchain-conventions-EN.html
+ Features.push_back("+f");
+ Features.push_back("+d");
+}
namespace loongarch {
StringRef getLoongArchABI(const llvm::opt::ArgList &Args,
const llvm::Triple &Triple);
+
+void getLoongArchTargetFeatures(const Driver &D, const llvm::Triple &Triple,
+ const llvm::opt::ArgList &Args,
+ std::vector<llvm::StringRef> &Features);
} // end namespace loongarch
} // end namespace tools
} // end namespace driver
case llvm::Triple::csky:
csky::getCSKYTargetFeatures(D, Triple, Args, CmdArgs, Features);
break;
+ case llvm::Triple::loongarch32:
+ case llvm::Triple::loongarch64:
+ loongarch::getLoongArchTargetFeatures(D, Triple, Args, Features);
+ break;
}
for (auto Feature : unifyTargetFeatures(Features)) {
--- /dev/null
+// RUN: %clang --target=loongarch32 -S -emit-llvm %s -o - | FileCheck %s --check-prefix=LA32
+// RUN: %clang --target=loongarch64 -S -emit-llvm %s -o - | FileCheck %s --check-prefix=LA64
+
+// LA32: "target-features"="+d,+f"
+// LA64: "target-features"="+d,+f"
+
+/// Dummy function
+int foo(void) {
+ return 3;
+}