Created
March 17, 2022 09:41
-
-
Save colemancda/bab5a634176b53f0f8c76d6ab5eec578 to your computer and use it in GitHub Desktop.
LLVM 5.6 patched for RISCV64
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
diff --git a/clang/lib/Basic/Targets/RISCV.h b/clang/lib/Basic/Targets/RISCV.h | |
index 7e0846581ca1..60d676ee1761 100644 | |
--- a/clang/lib/Basic/Targets/RISCV.h | |
+++ b/clang/lib/Basic/Targets/RISCV.h | |
@@ -111,7 +111,19 @@ public: | |
DiagnosticsEngine &Diags) override; | |
bool hasExtIntType() const override { return true; } | |
+ | |
+ CallingConvCheckResult checkCallingConvention(CallingConv CC) const override { | |
+ switch (CC) { | |
+ case CC_Swift: | |
+ return CCCR_OK; | |
+ case CC_SwiftAsync: | |
+ return CCCR_Error; | |
+ default: | |
+ return CCCR_Warning; | |
+ } | |
+ } | |
}; | |
+ | |
class LLVM_LIBRARY_VISIBILITY RISCV32TargetInfo : public RISCVTargetInfo { | |
public: | |
RISCV32TargetInfo(const llvm::Triple &Triple, const TargetOptions &Opts) | |
diff --git a/clang/lib/CodeGen/TargetInfo.cpp b/clang/lib/CodeGen/TargetInfo.cpp | |
index a2b68a04d351..d0ab8c0f2849 100644 | |
--- a/clang/lib/CodeGen/TargetInfo.cpp | |
+++ b/clang/lib/CodeGen/TargetInfo.cpp | |
@@ -10489,8 +10489,9 @@ static bool getTypeString(SmallStringEnc &Enc, const Decl *D, | |
//===----------------------------------------------------------------------===// | |
namespace { | |
-class RISCVABIInfo : public DefaultABIInfo { | |
+class RISCVABIInfo : public SwiftABIInfo { | |
private: | |
+ DefaultABIInfo defaultInfo; | |
// Size of the integer ('x') registers in bits. | |
unsigned XLen; | |
// Size of the floating point ('f') registers in bits. Note that the target | |
@@ -10507,7 +10508,7 @@ private: | |
public: | |
RISCVABIInfo(CodeGen::CodeGenTypes &CGT, unsigned XLen, unsigned FLen) | |
- : DefaultABIInfo(CGT), XLen(XLen), FLen(FLen) {} | |
+ : SwiftABIInfo(CGT), defaultInfo(CGT), XLen(XLen), FLen(FLen) {} | |
// DefaultABIInfo's classifyReturnType and classifyArgumentType are | |
// non-virtual, but computeInfo is virtual, so we overload it. | |
@@ -10530,6 +10531,16 @@ public: | |
CharUnits Field1Off, | |
llvm::Type *Field2Ty, | |
CharUnits Field2Off) const; | |
+ | |
+ private: | |
+ bool shouldPassIndirectlyForSwift(ArrayRef<llvm::Type*> scalars, | |
+ bool asReturnValue) const override { | |
+ return occupiesMoreThan(CGT, scalars, /*total*/ 4); | |
+ } | |
+ | |
+ bool isSwiftErrorInRegister() const override { | |
+ return false; | |
+ } | |
}; | |
} // end anonymous namespace | |
diff --git a/llvm/lib/Target/RISCV/RISCVISelLowering.cpp b/llvm/lib/Target/RISCV/RISCVISelLowering.cpp | |
index 91a5d1adad4f..3f3232e3642d 100644 | |
--- a/llvm/lib/Target/RISCV/RISCVISelLowering.cpp | |
+++ b/llvm/lib/Target/RISCV/RISCVISelLowering.cpp | |
@@ -7621,6 +7621,8 @@ SDValue RISCVTargetLowering::LowerFormalArguments( | |
default: | |
report_fatal_error("Unsupported calling convention"); | |
case CallingConv::C: | |
+ case CallingConv::Swift: | |
+ case CallingConv::SwiftTail: | |
case CallingConv::Fast: | |
break; | |
case CallingConv::GHC: |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment