Skip to content

Conversation

@AmrDeveloper
Copy link
Member

Backporting renaming ComplexAttr to ConstComplexAttr from the upstream

Copy link
Collaborator

@xlauko xlauko left a comment

Choose a reason for hiding this comment

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

Why was this change introduced in the upstream in the first place?

From my point of view it is rendundant information on the attribute as it is from the difenition of an attribute a constant. I would expect us going the other way and removevingconst_ from other attributes.

Also then when used as ssa value you already mark it as constant in the operation name. Having cir.const #cir.const_complex with repeated const comes to me as unnecessary.

For instance other arithmetic constants we keep as #cir.int and #cir.fp still.

Comment on lines +2061 to +2063
return cir::ConstComplexAttr::get(builder.getContext(), complexType,
cir::IntAttr::get(complexElemTy, real),
cir::IntAttr::get(complexElemTy, imag));
Copy link
Collaborator

Choose a reason for hiding this comment

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

No need for complexType here as we can infer it in builder?

cir::FPAttr::get(complexElemTy, imag));
const llvm::APFloat &real = Value.getComplexFloatReal();
const llvm::APFloat &imag = Value.getComplexFloatImag();
return cir::ConstComplexAttr::get(builder.getContext(), complexType,
Copy link
Collaborator

Choose a reason for hiding this comment

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

No need for complexType here as we can infer it in builder?

@AmrDeveloper
Copy link
Member Author

Why was this change introduced in the upstream in the first place?

From my point of view it is rendundant information on the attribute as it is from the difenition of an attribute a constant. I would expect us going the other way and removevingconst_ from other attributes.

Also then when used as ssa value you already mark it as constant in the operation name. Having cir.const #cir.const_complex with repeated const comes to me as unnecessary.

For instance other arithmetic constants we keep as #cir.int and #cir.fp still.

I did that to be consistent with other const for example const_vector, const_record and also there is a case for example globals, it will not have const

cir.global external %g = #cir.const_complex<#cir.int<1> : !s32i, #cir.int<2> : !s32i> : !cir.complex<!s32i>

But for locals, yes it will have unnecessary const, I am okey with removing the const from the name too

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