Code cleanup

This commit is contained in:
Pierre Pronchery 2012-12-01 02:53:51 +01:00
parent 32da9a3eb3
commit e9033fcd26

View File

@ -76,40 +76,44 @@ static int _sparc_decode(AsmArchPlugin * plugin, AsmArchInstructionCall * call)
/* sparc_encode */ /* sparc_encode */
static int _encode_branch(AsmArchInstruction * instruction, static int _sparc_encode_branch(AsmArchInstruction * instruction,
AsmArchInstructionCall * call, uint32_t * opcode);
static int _encode_integer(AsmArchPlugin * plugin, AsmArchInstruction * instruction,
AsmArchInstructionCall * call, uint32_t * opcode);
static int _encode_loadstore(AsmArchPlugin * plugin, AsmArchInstruction * instruction,
AsmArchInstructionCall * call, uint32_t * opcode);
static int _encode_sethi(AsmArchPlugin * plugin, AsmArchInstruction * instruction,
AsmArchInstructionCall * call, uint32_t * opcode); AsmArchInstructionCall * call, uint32_t * opcode);
static int _sparc_encode_integer(AsmArchPlugin * plugin,
AsmArchInstruction * instruction, AsmArchInstructionCall * call,
uint32_t * opcode);
static int _sparc_encode_loadstore(AsmArchPlugin * plugin,
AsmArchInstruction * instruction, AsmArchInstructionCall * call,
uint32_t * opcode);
static int _sparc_encode_sethi(AsmArchPlugin * plugin,
AsmArchInstruction * instruction, AsmArchInstructionCall * call,
uint32_t * opcode);
static int _sparc_encode(AsmArchPlugin * plugin, static int _sparc_encode(AsmArchPlugin * plugin,
AsmArchInstruction * instruction, AsmArchInstruction * instruction, AsmArchInstructionCall * call)
AsmArchInstructionCall * call)
{ {
AsmArchPluginHelper * helper = plugin->helper; AsmArchPluginHelper * helper = plugin->helper;
uint32_t opcode = instruction->opcode; uint32_t opcode = instruction->opcode;
if((opcode & 0xc0000000) == 0xc0000000) if((opcode & 0xc0000000) == 0xc0000000)
{ {
if(_encode_loadstore(plugin, instruction, call, &opcode) != 0) if(_sparc_encode_loadstore(plugin, instruction, call, &opcode)
!= 0)
return -1; return -1;
} }
else if((opcode & 0xc1c00000) == 0x01000000) else if((opcode & 0xc1c00000) == 0x01000000)
{ {
if(_encode_sethi(plugin, instruction, call, &opcode) != 0) if(_sparc_encode_sethi(plugin, instruction, call, &opcode) != 0)
return -1; return -1;
} }
else if((opcode & 0xc0000000) == 0x80000000) else if((opcode & 0xc0000000) == 0x80000000)
{ {
if(_encode_integer(plugin, instruction, call, &opcode) != 0) if(_sparc_encode_integer(plugin, instruction, call, &opcode)
!= 0)
return -1; return -1;
} }
else if((opcode & 0xc1c00000) == 0x00800000) else if((opcode & 0xc1c00000) == 0x00800000)
{ {
if(_encode_branch(instruction, call, &opcode) != 0) if(_sparc_encode_branch(instruction, call, &opcode) != 0)
return -1; return -1;
} }
else else
@ -121,7 +125,7 @@ static int _sparc_encode(AsmArchPlugin * plugin,
return 0; return 0;
} }
static int _encode_branch(AsmArchInstruction * instruction, static int _sparc_encode_branch(AsmArchInstruction * instruction,
AsmArchInstructionCall * call, uint32_t * opcode) AsmArchInstructionCall * call, uint32_t * opcode)
{ {
uint32_t disp; uint32_t disp;
@ -136,8 +140,9 @@ static int _encode_branch(AsmArchInstruction * instruction,
return 0; return 0;
} }
static int _encode_integer(AsmArchPlugin * plugin, AsmArchInstruction * instruction, static int _sparc_encode_integer(AsmArchPlugin * plugin,
AsmArchInstructionCall * call, uint32_t * opcode) AsmArchInstruction * instruction, AsmArchInstructionCall * call,
uint32_t * opcode)
{ {
AsmArchPluginHelper * helper = plugin->helper; AsmArchPluginHelper * helper = plugin->helper;
uint32_t rd; uint32_t rd;
@ -185,8 +190,9 @@ static int _encode_integer(AsmArchPlugin * plugin, AsmArchInstruction * instruct
return 0; return 0;
} }
static int _encode_loadstore(AsmArchPlugin * plugin, AsmArchInstruction * instruction, static int _sparc_encode_loadstore(AsmArchPlugin * plugin,
AsmArchInstructionCall * call, uint32_t * opcode) AsmArchInstruction * instruction, AsmArchInstructionCall * call,
uint32_t * opcode)
{ {
AsmArchPluginHelper * helper = plugin->helper; AsmArchPluginHelper * helper = plugin->helper;
uint32_t rd; uint32_t rd;
@ -271,8 +277,9 @@ static int _encode_loadstore(AsmArchPlugin * plugin, AsmArchInstruction * instru
return 0; return 0;
} }
static int _encode_sethi(AsmArchPlugin * plugin, AsmArchInstruction * instruction, static int _sparc_encode_sethi(AsmArchPlugin * plugin,
AsmArchInstructionCall * call, uint32_t * opcode) AsmArchInstruction * instruction, AsmArchInstructionCall * call,
uint32_t * opcode)
{ {
AsmArchPluginHelper * helper = plugin->helper; AsmArchPluginHelper * helper = plugin->helper;
uint32_t rd; uint32_t rd;