mirror of
https://github.com/rust-lang/rust.git
synced 2026-05-22 18:15:07 +03:00
Adjust getMCSubtargetInfo signature for LLVM 23+
This commit is contained in:
@@ -91,8 +91,13 @@ extern "C" void LLVMRustTimeTraceProfilerFinish(const char *FileName) {
|
||||
extern "C" bool LLVMRustHasFeature(LLVMTargetMachineRef TM,
|
||||
const char *Feature) {
|
||||
TargetMachine *Target = unwrap(TM);
|
||||
#if LLVM_VERSION_GE(23, 0)
|
||||
const MCSubtargetInfo &MCInfo = Target->getMCSubtargetInfo();
|
||||
return MCInfo.checkFeatures(std::string("+") + Feature);
|
||||
#else
|
||||
const MCSubtargetInfo *MCInfo = Target->getMCSubtargetInfo();
|
||||
return MCInfo->checkFeatures(std::string("+") + Feature);
|
||||
#endif
|
||||
}
|
||||
|
||||
/// Check whether the target has a specific assembly mnemonic like `ret` or
|
||||
@@ -274,7 +279,11 @@ static llvm::DebugCompressionType fromRust(LLVMRustCompressionKind Kind) {
|
||||
extern "C" void LLVMRustPrintTargetCPUs(LLVMTargetMachineRef TM,
|
||||
RustStringRef OutStr) {
|
||||
ArrayRef<SubtargetSubTypeKV> CPUTable =
|
||||
#if LLVM_VERSION_GE(23, 0)
|
||||
unwrap(TM)->getMCSubtargetInfo().getAllProcessorDescriptions();
|
||||
#else
|
||||
unwrap(TM)->getMCSubtargetInfo()->getAllProcessorDescriptions();
|
||||
#endif
|
||||
auto OS = RawRustStringOstream(OutStr);
|
||||
|
||||
// Just print a bare list of target CPU names, and let Rust-side code handle
|
||||
@@ -286,9 +295,15 @@ extern "C" void LLVMRustPrintTargetCPUs(LLVMTargetMachineRef TM,
|
||||
|
||||
extern "C" size_t LLVMRustGetTargetFeaturesCount(LLVMTargetMachineRef TM) {
|
||||
const TargetMachine *Target = unwrap(TM);
|
||||
#if LLVM_VERSION_GE(23, 0)
|
||||
const MCSubtargetInfo &MCInfo = Target->getMCSubtargetInfo();
|
||||
const ArrayRef<SubtargetFeatureKV> FeatTable =
|
||||
MCInfo.getAllProcessorFeatures();
|
||||
#else
|
||||
const MCSubtargetInfo *MCInfo = Target->getMCSubtargetInfo();
|
||||
const ArrayRef<SubtargetFeatureKV> FeatTable =
|
||||
MCInfo->getAllProcessorFeatures();
|
||||
#endif
|
||||
return FeatTable.size();
|
||||
}
|
||||
|
||||
@@ -296,9 +311,15 @@ extern "C" void LLVMRustGetTargetFeature(LLVMTargetMachineRef TM, size_t Index,
|
||||
const char **Feature,
|
||||
const char **Desc) {
|
||||
const TargetMachine *Target = unwrap(TM);
|
||||
#if LLVM_VERSION_GE(23, 0)
|
||||
const MCSubtargetInfo &MCInfo = Target->getMCSubtargetInfo();
|
||||
const ArrayRef<SubtargetFeatureKV> FeatTable =
|
||||
MCInfo.getAllProcessorFeatures();
|
||||
#else
|
||||
const MCSubtargetInfo *MCInfo = Target->getMCSubtargetInfo();
|
||||
const ArrayRef<SubtargetFeatureKV> FeatTable =
|
||||
MCInfo->getAllProcessorFeatures();
|
||||
#endif
|
||||
const SubtargetFeatureKV Feat = FeatTable[Index];
|
||||
*Feature = Feat.Key;
|
||||
*Desc = Feat.Desc;
|
||||
|
||||
Reference in New Issue
Block a user