From f80a96059dc9a43724e2615aeb0a6ec2c75584b7 Mon Sep 17 00:00:00 2001 From: Cyrill Leutwiler Date: Wed, 8 May 2024 15:55:24 +0200 Subject: [PATCH] allow register sized int type for memory offsets Signed-off-by: Cyrill Leutwiler --- crates/llvm-context/src/polkavm/context/mod.rs | 9 +++++++++ 1 file changed, 9 insertions(+) diff --git a/crates/llvm-context/src/polkavm/context/mod.rs b/crates/llvm-context/src/polkavm/context/mod.rs index ca0be4d..287538b 100644 --- a/crates/llvm-context/src/polkavm/context/mod.rs +++ b/crates/llvm-context/src/polkavm/context/mod.rs @@ -1182,6 +1182,15 @@ where &self, value: inkwell::values::IntValue<'ctx>, ) -> anyhow::Result> { + if value.get_type() == self.xlen_type() { + return Ok(value); + } + assert_eq!( + value.get_type(), + self.word_type(), + "expected XLEN or WORD sized int type for memory offset", + ); + let truncated = self.builder().build_int_truncate_or_bit_cast( value, self.xlen_type(),