[all-commits] [llvm/llvm-project] 704a39: [APInt] Enable APInt to support zero bit integers.

Chris Lattner via All-commits all-commits at lists.llvm.org
Thu Sep 9 22:44:10 PDT 2021


  Branch: refs/heads/main
  Home:   https://github.com/llvm/llvm-project
  Commit: 704a39569346401e96a6a3978ddc490dfa828ccc
      https://github.com/llvm/llvm-project/commit/704a39569346401e96a6a3978ddc490dfa828ccc
  Author: Chris Lattner <clattner at nondot.org>
  Date:   2021-09-09 (Thu, 09 Sep 2021)

  Changed paths:
    M llvm/include/llvm/ADT/APInt.h
    M llvm/lib/Support/APInt.cpp
    M llvm/unittests/ADT/APIntTest.cpp

  Log Message:
  -----------
  [APInt] Enable APInt to support zero bit integers.

Motivation: APInt not supporting zero bit values leads to
a lot of special cases in various bits of code, particularly
when using APInt as a bit vector (where you want to start with
zero bits and then concat on more.  This is particularly
challenging in the CIRCT project, where the absence of zero-bit
ConstantOp forces duplication of ops and makes instcombine-like
logic far more complicated.

Approach: zero bit integers are weird.  There are two reasonable
approaches: either make it illegal to do general arithmetic on
them (e.g. sign extends), or treat them as as implicitly having
a zero value.  This patch takes the conservative approach, which
enables their use in bitvector applications.

Differential Revision: https://reviews.llvm.org/D109555




More information about the All-commits mailing list