about summary refs log tree commit diff
path: root/compiler/rustc_llvm/llvm-wrapper/RustWrapper.cpp
diff options
context:
space:
mode:
authorbors <bors@rust-lang.org>2021-08-04 18:22:29 +0000
committerbors <bors@rust-lang.org>2021-08-04 18:22:29 +0000
commitd54fbb98555c107fb62fb5ae1a5b8f4fc6ed3edc (patch)
tree63f0a2cc0ac3e03b2a749db84f2c2477ba381d23 /compiler/rustc_llvm/llvm-wrapper/RustWrapper.cpp
parent6fe0886723c9e08b800c9951f1c6f6a57b2bf22c (diff)
parent8e0df32ad6dd4e171742dc159a08f247c1a256ab (diff)
downloadrust-d54fbb98555c107fb62fb5ae1a5b8f4fc6ed3edc.tar.gz
rust-d54fbb98555c107fb62fb5ae1a5b8f4fc6ed3edc.zip
Auto merge of #87695 - tmiasko:gep-opaque-pointers, r=nagisa
Prepare GEP building for opaque pointers
Diffstat (limited to 'compiler/rustc_llvm/llvm-wrapper/RustWrapper.cpp')
-rw-r--r--compiler/rustc_llvm/llvm-wrapper/RustWrapper.cpp10
1 files changed, 10 insertions, 0 deletions
diff --git a/compiler/rustc_llvm/llvm-wrapper/RustWrapper.cpp b/compiler/rustc_llvm/llvm-wrapper/RustWrapper.cpp
index 4cdc8a4155b..7666803911e 100644
--- a/compiler/rustc_llvm/llvm-wrapper/RustWrapper.cpp
+++ b/compiler/rustc_llvm/llvm-wrapper/RustWrapper.cpp
@@ -1551,6 +1551,16 @@ extern "C" void LLVMRustSetLinkage(LLVMValueRef V,
   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
 // the common sizes (1, 8, 16, 32, 64, 128 bits)
 extern "C" bool LLVMRustConstInt128Get(LLVMValueRef CV, bool sext, uint64_t *high, uint64_t *low)