-
Notifications
You must be signed in to change notification settings - Fork 232
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Add op access for OpCodeInfo
and Code
#614
base: master
Are you sure you want to change the base?
Conversation
…ums::{OP_ACCESS_1, OP_ACCESS_2}` from `pub(super) static` to `pub(crate) const`
…ut the need of using unsafe blocks
70d3794
to
d5d4411
Compare
d5d4411
to
c1d5e8d
Compare
…ng the generator up to date with the changes in 40f17c3
Makes sense to add those functions to Code/OpCodeInfo. Not sure if OpCodeInfo needs the extra op_accesses field since it can just call the Code functions. One thing missing is tests for all new APIs. Could be a lot more work so maybe I'll add that sometime. Would require (C# code, see generator code) generating a new txt file for at least the Code test that would include the Code value and the OpAccess values, write a parser for it (should be easy, split the line), add the test code somewhere. |
Removed op access from There is one more thing I am not sure about, and that is Also, I could not find any info about |
Sorry, forgot to reply. This is the reason I didn't add those functions to I don't like a new enum, that reveals too much about the implementation. The correct way is to add the required input, I think that's only bitness, if it's more than that, this could get ugly. |
We need at most 2 inputs to disambiguate: bitness and whether the instruction has memory operands. Both are for operand 0. First, there are the 32 bit After giving it some thought, I think this should be Second, there are
To support this, we would need an argument, To summarize: the proposal is to add |
The upper 32 bits are cleared in 64-bit mode if operand size is 32 bits.
So the the CPU actually does
It would need two args, and it's now getting very ugly since the user has to pass in bitness and check if the instruction has a memory operand. |
I know that this is from the manual, I'm arguing that this code is not really correct when you actually try to implement it.
What is
then what is Nevertheless, I'm not here to argue. If you still think that the 2 argument version is better, that works too. I won't make more of a case against it and finish the PR 😄 |
Hopefully I didn't misunderstand you. Let me explain again. In 16/32-bit mode, Cmovo_r32_rm32 should be CondWrite because it's not possible to observe the CPU writing to the upper 32 bits of a 64-bit GPR. So we can ignore the upper 32 bits of the 64-bit GPR and just assume the CPU does this: In 64-bit mode, Cmovo_r32_rm32 is not CondWrite, it would have to be ReadWrite since the CPU always clears the upper 64 bits of the 64-bit destination GPR. In 64-bit mode, the CPU does this: So we would need a bitness argument. However, in this case we could just return ReadWrite (NOT CondWrite) for both so we won't have to use an extra bitness arg, but then the caller has to check if it's a CMOVcc if it's 16/32-bit code. So we're back to just one arg again, the 'is mem op' argument. That's acceptable, 2 args would be 1 arg too much. |
Iced provides
OpAccess
through theInstructionInfoFactory
interface which does advanced analysis based on concrete operands of an instruction. This merge request aims to add a simplerOpAccess
API which uses data derivable from theCode
enum and does not need full instructions.The code compiles but it is a WORK IN PROGRESS.
Unresolved issues:
InstructionInfo
about how it simplifies operand accesses.src/rust/iced-x86/src/encoder/code_flags.rs
, some of it might be better placed somewhere else.todo!()
-s inCode::op0_access
. I didn't know how some of them should be converted. I would appreciate any feedback/help you can give me.