Skip to content
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

Merged
merged 1 commit into from
May 16, 2024
Merged

Conversation

ptersilie
Copy link

No description provided.

// opcode:
serialiseOpcode(OpCodeCast);
// cast_kind:
serialiseCastKind(CastKindZeroExt);
Copy link

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.

Copy link

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)

Copy link
Author

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.

Copy link

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.

@ptersilie
Copy link
Author

I've updated the PR.

@vext01
Copy link

vext01 commented May 15, 2024

Bitwidth check looks good to me.

We just need to reject the vector variant of inttoptr now. e.g.

%Z = inttoptr <4 x i32> %G to <4 x ptr>

You can adapt this kind of thing:

I->getType()->isVectorTy()) {

@ptersilie
Copy link
Author

Here you go.

@vext01
Copy link

vext01 commented May 16, 2024

Perfect. Please squash.

@ptersilie
Copy link
Author

Done.

@vext01 vext01 added this pull request to the merge queue May 16, 2024
@github-merge-queue github-merge-queue bot removed this pull request from the merge queue due to failed status checks May 16, 2024
@ptersilie
Copy link
Author

Ok to squash?

@vext01
Copy link

vext01 commented May 16, 2024

Please squash

@ptersilie
Copy link
Author

Done.

@vext01 vext01 added this pull request to the merge queue May 16, 2024
Merged via the queue into ykjit:main with commit c47d7c9 May 16, 2024
2 checks passed
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

2 participants