llvm-wrapper: adapt for LLVM API changes

No functional changes intended.

Adapts the wrapper for 0a1aa6cda2.

Found by our experimental rust + llvm @ head CI: https://buildkite.com/llvm-project/rust-llvm-integrate-prototype/builds/22301#018a9926-a810-4e56-8ac2-e6f30b78f433/253-551
This commit is contained in:
Krasimir Georgiev 2023-09-15 14:31:43 +00:00
parent e7f9f48d76
commit af401b0ca3

View File

@ -239,16 +239,22 @@ enum class LLVMRustCodeGenOptLevel {
Aggressive, Aggressive,
}; };
static CodeGenOpt::Level fromRust(LLVMRustCodeGenOptLevel Level) { #if LLVM_VERSION_GE(18, 0)
using CodeGenOptLevelEnum = llvm::CodeGenOptLevel;
#else
using CodeGenOptLevelEnum = llvm::CodeGenOpt::Level;
#endif
static CodeGenOptLevelEnum fromRust(LLVMRustCodeGenOptLevel Level) {
switch (Level) { switch (Level) {
case LLVMRustCodeGenOptLevel::None: case LLVMRustCodeGenOptLevel::None:
return CodeGenOpt::None; return CodeGenOptLevelEnum::None;
case LLVMRustCodeGenOptLevel::Less: case LLVMRustCodeGenOptLevel::Less:
return CodeGenOpt::Less; return CodeGenOptLevelEnum::Less;
case LLVMRustCodeGenOptLevel::Default: case LLVMRustCodeGenOptLevel::Default:
return CodeGenOpt::Default; return CodeGenOptLevelEnum::Default;
case LLVMRustCodeGenOptLevel::Aggressive: case LLVMRustCodeGenOptLevel::Aggressive:
return CodeGenOpt::Aggressive; return CodeGenOptLevelEnum::Aggressive;
default: default:
report_fatal_error("Bad CodeGenOptLevel."); report_fatal_error("Bad CodeGenOptLevel.");
} }
@ -554,9 +560,17 @@ enum class LLVMRustFileType {
static CodeGenFileType fromRust(LLVMRustFileType Type) { static CodeGenFileType fromRust(LLVMRustFileType Type) {
switch (Type) { switch (Type) {
case LLVMRustFileType::AssemblyFile: case LLVMRustFileType::AssemblyFile:
#if LLVM_VERSION_GE(18, 0)
return CodeGenFileType::AssemblyFile;
#else
return CGFT_AssemblyFile; return CGFT_AssemblyFile;
#endif
case LLVMRustFileType::ObjectFile: case LLVMRustFileType::ObjectFile:
#if LLVM_VERSION_GE(18, 0)
return CodeGenFileType::ObjectFile;
#else
return CGFT_ObjectFile; return CGFT_ObjectFile;
#endif
default: default:
report_fatal_error("Bad FileType."); report_fatal_error("Bad FileType.");
} }