Skip to content

[CIR][CIRGen][Builtin][X86] Lower __rdtscp #1686

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

Open
wants to merge 1 commit into
base: main
Choose a base branch
from

Conversation

RiverDave
Copy link
Contributor

@RiverDave RiverDave commented Jun 15, 2025

Moved rd related intrinsic tests, to a different file similar to clang/test/CodeGen/X86/rd-builtins.c. Let me know if that's the right call.

related: #1404

@@ -144,5 +144,26 @@ mlir::Value CIRGenFunction::emitX86BuiltinExpr(unsigned BuiltinID,
getLoc(E->getExprLoc()), builder.getStringAttr("x86.rdtsc"), intTy)
.getResult();
}
case X86::BI__builtin_ia32_rdtscp: {

Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Not for this PR, but something to note here: in OG CGM.getIntrinsic seems to be able to figure out the type of the intrinsic, we should do the same in CIR to make writing these easier:

  case X86::BI__builtin_ia32_rdtscp: {
    Value *Call = Builder.CreateCall(CGM.getIntrinsic(Intrinsic::x86_rdtscp));
    Builder.CreateDefaultAlignedStore(Builder.CreateExtractValue(Call, 1),
                                      Ops[0]);
    return Builder.CreateExtractValue(Call, 0);
  }

Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Thanks for your suggestion, will definitely help as I wanna cover these intrinsics.

@bcardosolopes
Copy link
Member

Good to land once conflict is fixed

@RiverDave
Copy link
Contributor Author

Good to land once conflict is fixed

👍

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