Skip to content

[Clang-Format] Tablegen formatter should prefer breaking after let ... in #160414

@arichardson

Description

@arichardson

We currently end up with formatting like the following (running clang-format on RISCVInstrInfo.td:

  let isTrap =
      1 in def EBREAK : RVInstI<0b000, OPC_SYSTEM, (outs), (ins), "ebreak", "">,
      Sched<[]> {
    let rs1 = 0;
    let rd = 0;
    let imm12 = 1;
  }

It looks better with curly braces, but still not ideal:

  let isTrap = 1 in {
    def EBREAK : RVInstI<0b000, OPC_SYSTEM, (outs), (ins), "ebreak", "">,
                 Sched<[]> {
      let rs1 = 0;
      let rd = 0;
      let imm12 = 1;
    }
  }

IMO it would be cleanest to use something like this, i.e. break after let ... in and no indentation.

  let isTrap = 1 in
  def EBREAK : RVInstI<0b000, OPC_SYSTEM, (outs), (ins), "ebreak", "">,
               Sched<[]> {
    let rs1 = 0;
    let rd = 0;
    let imm12 = 1;
  }

Metadata

Metadata

Assignees

No one assigned

    Type

    No type

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions