MCPcopy Create free account
hub / github.com/Vector35/binaryninja-api / LoadStoreOperandSize

Function LoadStoreOperandSize

arch/arm64/il.cpp:1005–1142  ·  view source on GitHub ↗

Source from the content-addressed store, hash-verified

1003}
1004
1005static void LoadStoreOperandSize(LowLevelILFunction& il, bool load, bool sign_extend, size_t size,
1006 InstructionOperand& operand1, InstructionOperand& operand2)
1007{
1008 ExprId tmp;
1009 if (load)
1010 {
1011 // LLIL_TEMP registers will be reported to have size 0, so override with size
1012 size_t extendSize = REGSZ_O(operand1) ? REGSZ_O(operand1) : size;
1013 switch (operand2.operandClass)
1014 {
1015 case MEM_REG:
1016 // operand1.reg = [operand2.reg]
1017 tmp = il.Operand(1, il.Load(size, ILREG_O(operand2)));
1018
1019 if (sign_extend)
1020 tmp = il.SignExtend(extendSize, tmp);
1021 else
1022 tmp = il.ZeroExtend(extendSize, tmp);
1023
1024 il.AddInstruction(ILSETREG_O(operand1, tmp));
1025 break;
1026 case MEM_OFFSET:
1027 // operand1.reg = [operand2.reg + operand2.imm]
1028 if (IMM_O(operand2) == 0)
1029 tmp = ILREG_O(operand2);
1030 else
1031 tmp = ILADDREG_O(operand2, il.Const(REGSZ_O(operand2), IMM_O(operand2)));
1032
1033 tmp = il.Operand(1, il.Load(size, tmp));
1034
1035 if (sign_extend)
1036 tmp = il.SignExtend(extendSize, tmp);
1037 else
1038 tmp = il.ZeroExtend(extendSize, tmp);
1039
1040 il.AddInstruction(ILSETREG_O(operand1, tmp));
1041 break;
1042 case MEM_PRE_IDX:
1043 // operand2.reg += operand2.imm
1044 if (IMM_O(operand2) != 0)
1045 il.AddInstruction(ILSETREG_O(operand2, il.Add(REGSZ_O(operand2), ILREG_O(operand2),
1046 il.Const(REGSZ_O(operand2), IMM_O(operand2)))));
1047 // operand1.reg = [operand2.reg]
1048 tmp = il.Operand(1, il.Load(size, ILREG_O(operand2)));
1049
1050 if (sign_extend)
1051 tmp = il.SignExtend(extendSize, tmp);
1052 else
1053 tmp = il.ZeroExtend(extendSize, tmp);
1054
1055 il.AddInstruction(ILSETREG_O(operand1, tmp));
1056 break;
1057 case MEM_POST_IDX:
1058 // operand1.reg = [operand2.reg]
1059 tmp = il.Operand(1, il.Load(size, ILREG_O(operand2)));
1060
1061 if (sign_extend)
1062 tmp = il.SignExtend(extendSize, tmp);

Callers 1

Calls 13

OperandMethod · 0.80
GetShiftedRegisterFunction · 0.70
LoadMethod · 0.45
SignExtendMethod · 0.45
ZeroExtendMethod · 0.45
AddInstructionMethod · 0.45
ConstMethod · 0.45
AddMethod · 0.45
ConstPointerMethod · 0.45
UnimplementedMethod · 0.45
LowPartMethod · 0.45
StoreMethod · 0.45

Tested by

no test coverage detected