Open esaulenka opened 4 months ago
My apologies. I should have read more closely.
@esaulenka my mistake in removing the extension="inttype". I had mistakenly removed it thinking it was metatype="inttype". I'll put it back in. metatype is being deprecated, extension is not.
I'll add that into a tricore patch I'm about to commit.
@ryanmkurtz, why you marked it as closed? There are a few others architectures that can be improved in the same way.
I can provide samples for it, but decompiled code will be exactly the same.
Oh, it was auto-closed due to our merge process and an misunderstanding of how our internal work linked to this issue.
The PPC has extension="inttype" on the return value, but not on the parameters. Based on pulling up a pcode unit test PPC binary, it appears it needs it on the parameters as well.
char pcode_i1_complexLogic
(char param_1,char param_2,char param_3,char param_4,char param_5,char param_6)
{
char cVar1;
char cVar2;
undefined3 in_register_0000000c;
uint uVar3;
undefined3 in_register_00000010;
uint uVar4;
undefined3 in_register_00000014;
uint uVar5;
undefined3 in_register_00000018;
uint uVar6;
undefined3 in_register_0000001c;
uint uVar7;
undefined3 in_register_00000020;
uint uVar8;
byte bVar9;
uVar8 = CONCAT31(in_register_00000020,param_6);
uVar7 = CONCAT31(in_register_0000001c,param_5);
uVar6 = CONCAT31(in_register_00000018,param_4);
uVar5 = CONCAT31(in_register_00000014,param_3);
uVar4 = CONCAT31(in_register_00000010,param_2);
uVar3 = CONCAT31(in_register_0000000c,param_1);
The need for the extension tag would depend on the compiler and how it treats passing/returning smaller data types than the full register size. The mips needs extension="sign". The ABI specifies explicitly what is assumed for smaller data types in params and returns.
We've been considering adding an automated test for this in the pcodeunit test binaries. This does depend on having a compiler that can cross-compile a test binary.
We can do a zero based review with the test binaries we have with known small datatype parameters and return values.
Describe the bug
It is a some continiuation of conversation #5757 Some architectures (like ARM, Power, V850, Tricore, ...) transfers function inputs and return value through registers.
If these values are smaller than register size, decompiler makes some additional noise.
To Reproduce
For clarify, lets talk about Tricore.
Callee:
decompiled as
Caller:
decompiled as
Similar behavior can be found in the input parameters:
Expected behavior
I don't understand why @emteere said (https://github.com/NationalSecurityAgency/ghidra/pull/5757#issuecomment-2012612306) that such extension is not needed. If declare all input/output pentries in
cspec
file with attributeextension="inttype"
all these extraout / in_registerXX is gone.Yes, I know workaroud 'always use native-wide variables'. But I think will be better to use byte, if you sure that this variable always contains values less than 255.
Environment (please complete the following information):