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

[CIR][CIRGen] Support for signed #cir.ptr #598

Merged
merged 3 commits into from May 18, 2024

Conversation

Laity000
Copy link
Contributor

@Laity000 Laity000 commented May 10, 2024

The constant initialization isn't related to the pointee. We should be able to write #cir.ptr<-1 : i64> : !cir.ptr

Copy link
Member

@bcardosolopes bcardosolopes left a comment

Choose a reason for hiding this comment

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

Thanks for improving this. Only necessary change is to change ConstPtrAttr definition: the value to be a mlir::IntegerAttr instead and build that attribute in terms of i64. This way we don't have to worry specifying what the contract using int64_t should be.

clang/lib/CIR/CodeGen/CIRGenExprScalar.cpp Show resolved Hide resolved
The constant initialization isn't related to the pointee. We should be able to write #cir.ptr<-1 : i64> : !cir.ptr<whatever>
@Laity000
Copy link
Contributor Author

Thanks! I updated this PR.

Copy link
Member

@bcardosolopes bcardosolopes left a comment

Choose a reason for hiding this comment

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

Thanks for fixing the comments. One more nit and we should be good

let description = [{
A pointer attribute is a literal attribute that represents an integral
value of a pointer type.
}];
let builders = [
AttrBuilderWithInferredContext<(ins "Type":$type, "uint64_t":$value), [{
return $_get(type.getContext(), type.cast<mlir::cir::PointerType>(), value);
AttrBuilderWithInferredContext<(ins "Type":$type, "int64_t":$value), [{
Copy link
Member

Choose a reason for hiding this comment

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

I suggest we remove this functionality, better if we force whomever is creating the attribute to pass in the mlir::IntegerType, assumptions might lead to subtle mistakes here.

Copy link
Contributor Author

Choose a reason for hiding this comment

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

updated

@bcardosolopes
Copy link
Member

Will merge on the code formatting gets fixed.

@Laity000
Copy link
Contributor Author

Will merge on the code formatting gets fixed.

thanks! Fixed

@bcardosolopes bcardosolopes merged commit 5730174 into llvm:main May 18, 2024
6 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.

None yet

2 participants