hameeza ahmed via llvm-dev
2017-Oct-07 12:04 UTC
[llvm-dev] Binary Value of Immediate field of Vector Load Instruction
Hello, I am trying to generate the binary of my implemented vector load instruction whose assembly is similar to x86 as follows: P_128B_LOAD_DWORD R_0_R1024b_0, pword ptr [rip + b] I am able to get the required fields of the instruction by using MI.getOperand(index) in x86mccodeemitter.cpp file. it works fine for register operands as std::string reg_name=Ctx.getRegisterInfo()->getName(MI.getOperand(0).getReg()); but for obtaining the immediate field immediate operand? what should i do? i came to know by using gdb that there are 6 operands involved in this vector load instruction. i read each operand 1 by 1. MI.getOperand(0) gives destination register, MI.getOperand(1) gives RIP. there is some index where MI.getOperand(index) i get immediate type value but that value is always 1. i have tested for other instructions as well. then, MI.getOperand(4) gives kexpr type value which is in hex also another value come in this same expr object with name immediate which is the decimal equivalent of this hex value. this value keeps changing for different instructions. i assume kexpr is the value of the immediate i am looking for. so i obtained the immediate from kexpr object convert it into hex then put it in the immediate field of my encoded instruction. something as follows: for example MI.getOperand(4) kexpr field; MI.getOperand(4).getExpr()=0x3067980, its immediate=50755968)decimal i used this value 50755968)decimal which is equivalent to 0x3067980, as an immediate field of my instruction. Is it correct? please help me. Thank You Regards -------------- next part -------------- An HTML attachment was scrubbed... URL: <http://lists.llvm.org/pipermail/llvm-dev/attachments/20171007/191bc149/attachment.html>