Search code examples
assemblyllvmllvm-clangllvm-ir

Converting instruction involving CPU registers to memory instruction


I am new to LLVM and understanding the instruction generation by LLVM. As part of this, I am trying to convert a basic boolean instruction to use memory registers directly as operands. For example, in the below IR, I would like the and operation to use %a and %b instead of %11 and %12.

%11 = load i32, i32* %a, align 4 \n
%12 = load i32, i32* %b, align 4 \n
%13 = and i32 %11, %12\  
store i32 %13, i32* %d, align 4\n

Do I need to write a new and instruction for this, or is there another easier way?


Solution

  • I don't think it's feasible. Memory in LLVM cannot be accessed without explicit loads or stores.