Rollup merge of #113523 - workingjubilee:reuse-const-inbounds-gep2, r=cuviper
Reuse LLVMConstInBoundsGEP2 We have had LLVM 14 as our minimum for a bit now.
This commit is contained in:
commit
92a101866d
@ -290,7 +290,7 @@ impl<'ll, 'tcx> ConstMethods<'tcx> for CodegenCx<'ll, 'tcx> {
|
|||||||
}
|
}
|
||||||
};
|
};
|
||||||
let llval = unsafe {
|
let llval = unsafe {
|
||||||
llvm::LLVMRustConstInBoundsGEP2(
|
llvm::LLVMConstInBoundsGEP2(
|
||||||
self.type_i8(),
|
self.type_i8(),
|
||||||
self.const_bitcast(base_addr, self.type_i8p_ext(base_addr_space)),
|
self.const_bitcast(base_addr, self.type_i8p_ext(base_addr_space)),
|
||||||
&self.const_usize(offset.bytes()),
|
&self.const_usize(offset.bytes()),
|
||||||
@ -320,7 +320,7 @@ impl<'ll, 'tcx> ConstMethods<'tcx> for CodegenCx<'ll, 'tcx> {
|
|||||||
|
|
||||||
fn const_ptr_byte_offset(&self, base_addr: Self::Value, offset: abi::Size) -> Self::Value {
|
fn const_ptr_byte_offset(&self, base_addr: Self::Value, offset: abi::Size) -> Self::Value {
|
||||||
unsafe {
|
unsafe {
|
||||||
llvm::LLVMRustConstInBoundsGEP2(
|
llvm::LLVMConstInBoundsGEP2(
|
||||||
self.type_i8(),
|
self.type_i8(),
|
||||||
self.const_bitcast(base_addr, self.type_i8p()),
|
self.const_bitcast(base_addr, self.type_i8p()),
|
||||||
&self.const_usize(offset.bytes()),
|
&self.const_usize(offset.bytes()),
|
||||||
|
@ -1155,7 +1155,7 @@ extern "C" {
|
|||||||
pub fn LLVMConstVector(ScalarConstantVals: *const &Value, Size: c_uint) -> &Value;
|
pub fn LLVMConstVector(ScalarConstantVals: *const &Value, Size: c_uint) -> &Value;
|
||||||
|
|
||||||
// Constant expressions
|
// Constant expressions
|
||||||
pub fn LLVMRustConstInBoundsGEP2<'a>(
|
pub fn LLVMConstInBoundsGEP2<'a>(
|
||||||
ty: &'a Type,
|
ty: &'a Type,
|
||||||
ConstantVal: &'a Value,
|
ConstantVal: &'a Value,
|
||||||
ConstantIndices: *const &'a Value,
|
ConstantIndices: *const &'a Value,
|
||||||
|
@ -1616,17 +1616,6 @@ extern "C" void LLVMRustSetLinkage(LLVMValueRef V,
|
|||||||
LLVMSetLinkage(V, fromRust(RustLinkage));
|
LLVMSetLinkage(V, fromRust(RustLinkage));
|
||||||
}
|
}
|
||||||
|
|
||||||
// FIXME: replace with LLVMConstInBoundsGEP2 when bumped minimal version to llvm-14
|
|
||||||
extern "C" LLVMValueRef LLVMRustConstInBoundsGEP2(LLVMTypeRef Ty,
|
|
||||||
LLVMValueRef ConstantVal,
|
|
||||||
LLVMValueRef *ConstantIndices,
|
|
||||||
unsigned NumIndices) {
|
|
||||||
ArrayRef<Constant *> IdxList(unwrap<Constant>(ConstantIndices, NumIndices),
|
|
||||||
NumIndices);
|
|
||||||
Constant *Val = unwrap<Constant>(ConstantVal);
|
|
||||||
return wrap(ConstantExpr::getInBoundsGetElementPtr(unwrap(Ty), Val, IdxList));
|
|
||||||
}
|
|
||||||
|
|
||||||
extern "C" bool LLVMRustConstIntGetZExtValue(LLVMValueRef CV, uint64_t *value) {
|
extern "C" bool LLVMRustConstIntGetZExtValue(LLVMValueRef CV, uint64_t *value) {
|
||||||
auto C = unwrap<llvm::ConstantInt>(CV);
|
auto C = unwrap<llvm::ConstantInt>(CV);
|
||||||
if (C->getBitWidth() > 64)
|
if (C->getBitWidth() > 64)
|
||||||
|
Loading…
x
Reference in New Issue
Block a user