-
Notifications
You must be signed in to change notification settings - Fork 5
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
Lower PtrToInst instructions. #158
Conversation
llvm/lib/YkIR/YkIRWriter.cpp
Outdated
// opcode: | ||
serialiseOpcode(OpCodeCast); | ||
// cast_kind: | ||
serialiseCastKind(CastKindZeroExt); |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Just reading the LLVM reference, ptrtoint
has more semantics than we first thought:
https://llvm.org/docs/LangRef.html#ptrtoint-to-instruction
- We should reject the vector variant (encode an unimplemented instruction). You can copy/adapt existing code from other opcodes that have vector variants.
ptrtoint
can truncate to a smaller integer size, so zero extension isn't generally correct. If you don't want to handle those now, you can make an unimplemented instruction if the output type isn't pointer sized.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
(when rejecting certain versions of instructions, I've also been adding a case to tests/ir_lowering/unsupported_variants.ll
to check they are properly rejected)
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
My first instinct after your comment was to just add a aot_ir::PtrToIntInst
. But reading the langref, it does say they either truncate/zeroextend/noop anyway. So we can probably do without such an instruction and just lower each case to different existing aot instructions.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
that would be fine by me.
I've updated the PR. |
Bitwidth check looks good to me. We just need to reject the vector variant of
You can adapt this kind of thing: ykllvm/llvm/lib/YkIR/YkIRWriter.cpp Line 380 in c645c79
|
Here you go. |
Perfect. Please squash. |
Done. |
Ok to squash? |
Please squash |
Done. |
No description provided.