mirror of
https://github.com/rust-lang/rust.git
synced 2025-02-11 22:43:42 +00:00
Rollup merge of #97840 - durin42:llvm-15-apint, r=nikic
RustWrapper: adapt to APInt API changes in LLVM 15 In https://reviews.llvm.org/D125556 upstream changed sext() and zext() to allow some no-op cases, which previously required use of the *OrSelf() methods, which I assume is what was going on here. The *OrSelf() methods got removed in https://reviews.llvm.org/D125559 after two weeks of deprecation because they came with some bonus (probably-undesired) behavior. Since the behavior of sext() and zext() changed slightly, I kept the old *OrSelf() calls in LLVM 14 and earlier, and only use the new version in LLVM 15. r? `@nikic`
This commit is contained in:
commit
5870156d85
@ -1542,11 +1542,19 @@ extern "C" bool LLVMRustConstInt128Get(LLVMValueRef CV, bool sext, uint64_t *hig
|
|||||||
auto C = unwrap<llvm::ConstantInt>(CV);
|
auto C = unwrap<llvm::ConstantInt>(CV);
|
||||||
if (C->getBitWidth() > 128) { return false; }
|
if (C->getBitWidth() > 128) { return false; }
|
||||||
APInt AP;
|
APInt AP;
|
||||||
|
#if LLVM_VERSION_GE(15, 0)
|
||||||
|
if (sext) {
|
||||||
|
AP = C->getValue().sext(128);
|
||||||
|
} else {
|
||||||
|
AP = C->getValue().zext(128);
|
||||||
|
}
|
||||||
|
#else
|
||||||
if (sext) {
|
if (sext) {
|
||||||
AP = C->getValue().sextOrSelf(128);
|
AP = C->getValue().sextOrSelf(128);
|
||||||
} else {
|
} else {
|
||||||
AP = C->getValue().zextOrSelf(128);
|
AP = C->getValue().zextOrSelf(128);
|
||||||
}
|
}
|
||||||
|
#endif
|
||||||
*low = AP.getLoBits(64).getZExtValue();
|
*low = AP.getLoBits(64).getZExtValue();
|
||||||
*high = AP.getHiBits(64).getZExtValue();
|
*high = AP.getHiBits(64).getZExtValue();
|
||||||
return true;
|
return true;
|
||||||
|
Loading…
Reference in New Issue
Block a user