llvm / clangir

A new (MLIR based) high-level IR for clang.
https://clangir.org
Other
312 stars 86 forks source link

Prevent eye bleeding type repetition in the assembly form of ConstantOp. #578

Closed orbiri closed 2 months ago

orbiri commented 2 months ago
def ConstantOp : CIR_Op<"const",
    [ConstantLike, Pure]> {
  // FIXME: Use SameOperandsAndResultType or similar and prevent eye bleeding
  // type repetition in the assembly form.

I'm taking a look at that. Writing tests with constants needed required too much effort :)

bcardosolopes commented 2 months ago

Awesome!

Lancern commented 2 months ago

Since @orbiri pointed this out, I also want to say that the current CIR assembly syntax is not consistent across all operations. Besides the problem of parenthesis around operands, another inconsistency is how we represent the types of operands and results:

I think we may need some "style guide" stuff to close the gap between different style choices and give CIR a consistent assembly syntax style. I don't know if the MLIR community has similar style guide; we may refer to that if it exists.

bcardosolopes commented 2 months ago

Thanks for bring more info, I'm down for having something like a style guide (if anyone is willing to write a doc for the webpage that'd be great). @orbiri also made some comments about this in the discord channel (just in case you haven't seen).

bcardosolopes commented 2 months ago

@orbiri since your PR landed we should probably close this one and open a new one for the overall asm style consistency.

bcardosolopes commented 2 months ago

Created, closing.