Replace LLVMConstInBoundsGEP with LLVMConstInBoundsGEP2*
A custom reimplementation of LLVMConstInBoundsGEP2 is used, since the LLVM contains a declaration of LLVMConstInBoundsGEP2 but not the implementation.
This commit is contained in:
parent
77e5e17231
commit
8e0df32ad6
3 changed files with 16 additions and 3 deletions
|
@ -268,7 +268,8 @@ impl ConstMethods<'tcx> for CodegenCx<'ll, 'tcx> {
|
||||||
}
|
}
|
||||||
};
|
};
|
||||||
let llval = unsafe {
|
let llval = unsafe {
|
||||||
llvm::LLVMConstInBoundsGEP(
|
llvm::LLVMRustConstInBoundsGEP2(
|
||||||
|
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()),
|
||||||
1,
|
1,
|
||||||
|
@ -303,7 +304,8 @@ impl ConstMethods<'tcx> for CodegenCx<'ll, 'tcx> {
|
||||||
let base_addr = self.static_addr_of(init, alloc.align, None);
|
let base_addr = self.static_addr_of(init, alloc.align, None);
|
||||||
|
|
||||||
let llval = unsafe {
|
let llval = unsafe {
|
||||||
llvm::LLVMConstInBoundsGEP(
|
llvm::LLVMRustConstInBoundsGEP2(
|
||||||
|
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()),
|
||||||
1,
|
1,
|
||||||
|
|
|
@ -1011,7 +1011,8 @@ 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 LLVMConstInBoundsGEP(
|
pub fn LLVMRustConstInBoundsGEP2(
|
||||||
|
ty: &'a Type,
|
||||||
ConstantVal: &'a Value,
|
ConstantVal: &'a Value,
|
||||||
ConstantIndices: *const &'a Value,
|
ConstantIndices: *const &'a Value,
|
||||||
NumIndices: c_uint,
|
NumIndices: c_uint,
|
||||||
|
|
|
@ -1551,6 +1551,16 @@ extern "C" void LLVMRustSetLinkage(LLVMValueRef V,
|
||||||
LLVMSetLinkage(V, fromRust(RustLinkage));
|
LLVMSetLinkage(V, fromRust(RustLinkage));
|
||||||
}
|
}
|
||||||
|
|
||||||
|
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));
|
||||||
|
}
|
||||||
|
|
||||||
// Returns true if both high and low were successfully set. Fails in case constant wasn’t any of
|
// Returns true if both high and low were successfully set. Fails in case constant wasn’t any of
|
||||||
// the common sizes (1, 8, 16, 32, 64, 128 bits)
|
// the common sizes (1, 8, 16, 32, 64, 128 bits)
|
||||||
extern "C" bool LLVMRustConstInt128Get(LLVMValueRef CV, bool sext, uint64_t *high, uint64_t *low)
|
extern "C" bool LLVMRustConstInt128Get(LLVMValueRef CV, bool sext, uint64_t *high, uint64_t *low)
|
||||||
|
|
Loading…
Add table
Reference in a new issue