December 2015
Beginner to intermediate
166 pages
3h 8m
English
LLVM uses the store instruction to write into a memory location. There are two arguments to the store instruction: a value to store and an address at which to store it. The store instruction has no return value. Let's say that we want to write a data to the second element of the vector of two integers. The store instruction looks like store i32 3, i32* %a1. To emit the store instruction, we can use the following API provided by LLVM:
void getStore(IRBuilder<> &Builder, Value *Address, Value *V) {
Builder.CreateStore(V, Address);
}For example, we will multiply the second element of the <2 x i32> vector by 16 and store it back at the same location.
Consider the following code:
#include "llvm/IR/IRBuilder.h" #include "llvm/IR/LLVMContext.h" ...
Read now
Unlock full access