[PATCH] D69715: NeonEmitter: change Type representation. NFC.

2019-11-06 Thread Tim Northover via Phabricator via cfe-commits
t.p.northover closed this revision.
t.p.northover added a comment.

> I guess the extra checks are due to existing code "accidentally" doing the 
> right thing?

Yep, they were helpful while I was in the process of converting (in the end I 
went via `AAAFloating` enumerators to make sure all uses were flushed out). And 
yes, diff showed no change in clang-tblgen output.

Anyway, thanks, committed as 9577ee84e6 
.


Repository:
  rG LLVM Github Monorepo

CHANGES SINCE LAST ACTION
  https://reviews.llvm.org/D69715/new/

https://reviews.llvm.org/D69715



___
cfe-commits mailing list
cfe-commits@lists.llvm.org
https://lists.llvm.org/cgi-bin/mailman/listinfo/cfe-commits


[PATCH] D69715: NeonEmitter: change Type representation. NFC.

2019-11-01 Thread Eli Friedman via Phabricator via cfe-commits
efriedma accepted this revision.
efriedma added a comment.
This revision is now accepted and ready to land.

I guess the extra checks are due to existing code "accidentally" doing the 
right thing?

Have you verified this is NFC in terms of the generated arm_neon.h etc?

LGTM


Repository:
  rG LLVM Github Monorepo

CHANGES SINCE LAST ACTION
  https://reviews.llvm.org/D69715/new/

https://reviews.llvm.org/D69715



___
cfe-commits mailing list
cfe-commits@lists.llvm.org
https://lists.llvm.org/cgi-bin/mailman/listinfo/cfe-commits


[PATCH] D69715: NeonEmitter: change Type representation. NFC.

2019-11-01 Thread Tim Northover via Phabricator via cfe-commits
t.p.northover created this revision.
t.p.northover added a reviewer: efriedma.
Herald added a subscriber: mcrosier.
Herald added a project: clang.

This has been separated off from D69618  to 
reduce clutter. Instead of using a sequence of bools to describe whether a type 
is floating, signed, ..., which can fairly easily end up in an inconsistent or 
otherwise meaningless state this switches to a single enum Kind. There should 
be no functional changes from this.


Repository:
  rG LLVM Github Monorepo

https://reviews.llvm.org/D69715

Files:
  clang/utils/TableGen/NeonEmitter.cpp

Index: clang/utils/TableGen/NeonEmitter.cpp
===
--- clang/utils/TableGen/NeonEmitter.cpp
+++ clang/utils/TableGen/NeonEmitter.cpp
@@ -140,7 +140,15 @@
 private:
   TypeSpec TS;
 
-  bool Float, Signed, Immediate, Void, Poly, Constant, Pointer;
+  enum TypeKind {
+Void,
+Float,
+SInt,
+UInt,
+Poly,
+  };
+  TypeKind Kind;
+  bool Immediate, Constant, Pointer;
   // ScalarForMangling and NoManglingQ are really not suited to live here as
   // they are not related to the type. But they live in the TypeSpec (not the
   // prototype), so this is really the only place to store them.
@@ -149,15 +157,14 @@
 
 public:
   Type()
-  : Float(false), Signed(false), Immediate(false), Void(true), Poly(false),
-Constant(false), Pointer(false), ScalarForMangling(false),
-NoManglingQ(false), Bitwidth(0), ElementBitwidth(0), NumVectors(0) {}
+  : Kind(Void), Immediate(false), Constant(false),
+Pointer(false), ScalarForMangling(false), NoManglingQ(false),
+Bitwidth(0), ElementBitwidth(0), NumVectors(0) {}
 
   Type(TypeSpec TS, char CharMod)
-  : TS(std::move(TS)), Float(false), Signed(false), Immediate(false),
-Void(false), Poly(false), Constant(false), Pointer(false),
-ScalarForMangling(false), NoManglingQ(false), Bitwidth(0),
-ElementBitwidth(0), NumVectors(0) {
+  : TS(std::move(TS)), Kind(Void), Immediate(false),
+Constant(false), Pointer(false), ScalarForMangling(false),
+NoManglingQ(false), Bitwidth(0), ElementBitwidth(0), NumVectors(0) {
 applyModifier(CharMod);
   }
 
@@ -174,21 +181,21 @@
   bool noManglingQ() const { return NoManglingQ; }
 
   bool isPointer() const { return Pointer; }
-  bool isFloating() const { return Float; }
-  bool isInteger() const { return !Float && !Poly; }
-  bool isSigned() const { return Signed; }
+  bool isFloating() const { return Kind == Float; }
+  bool isInteger() const { return Kind == SInt || Kind == UInt; }
+  bool isPoly() const { return Kind == Poly; }
+  bool isSigned() const { return Kind == SInt; }
   bool isImmediate() const { return Immediate; }
   bool isScalar() const { return NumVectors == 0; }
   bool isVector() const { return NumVectors > 0; }
-  bool isFloat() const { return Float && ElementBitwidth == 32; }
-  bool isDouble() const { return Float && ElementBitwidth == 64; }
-  bool isHalf() const { return Float && ElementBitwidth == 16; }
-  bool isPoly() const { return Poly; }
+  bool isFloat() const { return isFloating() && ElementBitwidth == 32; }
+  bool isDouble() const { return isFloating() && ElementBitwidth == 64; }
+  bool isHalf() const { return isFloating() && ElementBitwidth == 16; }
   bool isChar() const { return ElementBitwidth == 8; }
-  bool isShort() const { return !Float && ElementBitwidth == 16; }
-  bool isInt() const { return !Float && ElementBitwidth == 32; }
-  bool isLong() const { return !Float && ElementBitwidth == 64; }
-  bool isVoid() const { return Void; }
+  bool isShort() const { return isInteger() && ElementBitwidth == 16; }
+  bool isInt() const { return isInteger() && ElementBitwidth == 32; }
+  bool isLong() const { return isInteger() && ElementBitwidth == 64; }
+  bool isVoid() const { return Kind == Void; }
   unsigned getNumElements() const { return Bitwidth / ElementBitwidth; }
   unsigned getSizeInBits() const { return Bitwidth; }
   unsigned getElementSizeInBits() const { return ElementBitwidth; }
@@ -197,21 +204,24 @@
   //
   // Mutator functions
   //
-  void makeUnsigned() { Signed = false; }
-  void makeSigned() { Signed = true; }
+  void makeUnsigned() {
+assert(isInteger() && "not a potentially signed type");
+Kind = UInt;
+  }
+  void makeSigned() {
+assert(isInteger() && "not a potentially signed type");
+Kind = SInt;
+  }
 
   void makeInteger(unsigned ElemWidth, bool Sign) {
-Float = false;
-Poly = false;
-Signed = Sign;
+assert(!isVoid() && "converting void to int probably not useful");
+Kind = Sign ? SInt : UInt;
 Immediate = false;
 ElementBitwidth = ElemWidth;
   }
 
   void makeImmediate(unsigned ElemWidth) {
-Float = false;
-Poly = false;
-Signed = true;
+Kind = SInt;
 Immediate = true;
 ElementBitwidth = ElemWidth;
   }
@@ -257,7 +267,7 @@
   /// seen.