write_reg is my function for writing "v" to the register indicated by
"index". ptr_gpr is the struct pointer for my general register file.
write_reg(cpu_t *cpu, uint32_t index, Value *v,BasicBlock *bb ){
Value **regs = cpu->ptr_gpr;
}
If index do not need to do any runtime calculation, I can write the
following sentence to fulfil my requirement.
new StoreInst(v, regs[index], bb);
But if I need to do some runtime calculation for index such as
modular. Since my register index is a kind of logic register number, it
will dynamic map to a physical register by register window in runtime.
1. Use IR to calculate index by some
"BinaryOperator::Create(Instruction::Add, a, b, "", bb)" sentences.
2. Use the above index to refer the register in "regs".
Should I use GEP in second step ? And how to use it?
Thanks
MK