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

hugr-llvm: Add expect_tag to LLVMSumValue #1858

Open
doug-q opened this issue Jan 13, 2025 · 0 comments
Open

hugr-llvm: Add expect_tag to LLVMSumValue #1858

doug-q opened this issue Jan 13, 2025 · 0 comments
Labels
llvm Pertains to LLVM emission

Comments

@doug-q
Copy link
Collaborator

doug-q commented Jan 13, 2025

We should emit https://llvm.org/docs/LangRef.html#llvm-expect-intrinsic llvm ops when we can, to help the optimiser know where hot paths are.

I suggest we can do this easily by adding

impl LLVMSumValue {
  fn expect_tag(mut self, tag: usize) -> Self {
    self.expect = Some(self.tag_type().const_int(tag, false));
    self
  }

And where expect: Option<IntValue<'c>> is an additional field in LLVMSumValue.

Now when we build_get_tag we insert an expect intrinsic if self.expect.is_some().

@doug-q doug-q added the llvm Pertains to LLVM emission label Jan 13, 2025
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
llvm Pertains to LLVM emission
Projects
None yet
Development

No branches or pull requests

1 participant