I want to access an array element without a ConstantInt LLVM

47 Views Asked by At

I'm currently creating a compiler for my programming language. Each statement has a codegen method which generate the IR for it. When creating the codegen method for the subscript expression (e.g. array[i]), I'm facing some issues. In order to get an element at an nth index, I used the GetElementPtrInst. When trying to do it with constant integers indices (e.g. 5: array[5]) it works perfectly, but with other llvm::Values like LoadInsts I get an error: Invalid GetElementPtrInst indices for type!

LLVM version: Ubuntu LLVM v14.0.0

0

There are 0 best solutions below