[LLVMdev] Being able to know the jitted code-size before emitting

Nicolas Geoffray
Wed, 16 Apr 2008 08:46:25 -0000

>
> How about a  default GetInstSize() as well? Return 1 for every
> instruction except for some special TargetInstrInfo instructions, e.g.
> PHI, IMPLICIT_DEF, LABEL. I don't know if it's useful or not. But
> perhaps we can default most targets to it?
>
>

I prefer not giving a default implementation and aborting with a message
that says the target did not implement it. This way we know why it's not
working. Is it OK?

>> //
>> -unsigned X86RegisterInfo::getX86RegNum(unsigned RegNo) const {
>> +unsigned X86RegisterInfo::getX86RegNum(unsigned RegNo) {
>>
>
> What happened to "const"?
>

I made the function static.

>> +  unsigned Size = GetInstSizeWithDesc(*MI, &Desc, IsPIC,
>> Is64BitMode);
>> +  if (Desc.getOpcode() == X86::MOVPC32r) {
>> +      Size += GetInstSizeWithDesc(*MI, &get(X86::POP32r), IsPIC,
>> Is64BitMode);
>> +  }
>>
>
> I would prefer this special case is handled in GetInstSizeWithDesc().
>
>

I can not do that in GetInstSizeWithDesc because the test is on the
MachineInstruction, which will always say that Desc.getOpcode == MOVPC32
in GetInstSizeWithDesc (hence the function will endlessly call itself).
X86CodeEmitter is doing the same.

>
> Looks great! Thanks.
>

Thx to you for reviewing the patch! I'll modify it with your suggestions
and wait for your response to this email before committing it.

Nicolas

> Evan