On 02/23/18 12:04, Pankaj Bansal wrote:
> However Laszlo, with the method you suggest (using STATIC CONST
> UINT16 mOne), would it not add delay in each Mmio Operation ?
> I am concerned about boot delay using this approach.
The condition can be evaluated at compile time, so I expect optimizing
compilers to eliminate the dead branch.
Assuming the condition cannot be eliminated at build time, what is your
concern: the single byte access, or the branch instruction?
I don't think the single byte access matters. (If you tried to replace
that with a HOB or PCD lookup, it could only be worse.)
I also doubt the branch should be a concern. You could replace the "if"
(or the ternary operator "?:") with function pointers that you set e.g.
in a constructor function. But I think an "if" with an invariable
(constant) controlling expression is at least as friendly towards branch
predictors as a function pointer variable (through which you might be
*forced* to make a real function call).
Personally I wouldn't worry.
Anyway: please do not mistake my willingness / preference to go into
such detail for having high stakes at this. If you go an entirely
different route, I'm OK with that too. I felt I was asked for my opinion
and I tried to express it in detail, that's all.
edk2-devel mailing list