[llvm] [CodeGen] Use 128bits for LaneBitmask. (PR #111157)
Sander de Smalen via llvm-commits
llvm-commits at lists.llvm.org
Fri Oct 4 07:23:13 PDT 2024
================
@@ -29,72 +29,120 @@
#ifndef LLVM_MC_LANEBITMASK_H
#define LLVM_MC_LANEBITMASK_H
+#include "llvm/ADT/APInt.h"
+#include "llvm/ADT/SmallString.h"
#include "llvm/Support/Compiler.h"
#include "llvm/Support/Format.h"
#include "llvm/Support/MathExtras.h"
#include "llvm/Support/Printable.h"
#include "llvm/Support/raw_ostream.h"
+#include <utility>
namespace llvm {
- struct LaneBitmask {
- // When changing the underlying type, change the format string as well.
- using Type = uint64_t;
- enum : unsigned { BitWidth = 8*sizeof(Type) };
- constexpr static const char *const FormatStr = "%016llX";
+struct LaneBitmask {
+ static constexpr unsigned int BitWidth = 128;
- constexpr LaneBitmask() = default;
- explicit constexpr LaneBitmask(Type V) : Mask(V) {}
-
- constexpr bool operator== (LaneBitmask M) const { return Mask == M.Mask; }
- constexpr bool operator!= (LaneBitmask M) const { return Mask != M.Mask; }
- constexpr bool operator< (LaneBitmask M) const { return Mask < M.Mask; }
- constexpr bool none() const { return Mask == 0; }
- constexpr bool any() const { return Mask != 0; }
- constexpr bool all() const { return ~Mask == 0; }
-
- constexpr LaneBitmask operator~() const {
- return LaneBitmask(~Mask);
- }
- constexpr LaneBitmask operator|(LaneBitmask M) const {
- return LaneBitmask(Mask | M.Mask);
- }
- constexpr LaneBitmask operator&(LaneBitmask M) const {
- return LaneBitmask(Mask & M.Mask);
- }
- LaneBitmask &operator|=(LaneBitmask M) {
- Mask |= M.Mask;
- return *this;
- }
- LaneBitmask &operator&=(LaneBitmask M) {
- Mask &= M.Mask;
- return *this;
+ explicit LaneBitmask(APInt V) {
+ switch (V.getBitWidth()) {
+ case BitWidth:
+ Mask[0] = V.getRawData()[0];
+ Mask[1] = V.getRawData()[1];
+ break;
+ default:
+ llvm_unreachable("Unsupported bitwidth");
}
+ }
+ constexpr explicit LaneBitmask(uint64_t Lo = 0, uint64_t Hi = 0) : Mask{Lo, Hi} {}
- constexpr Type getAsInteger() const { return Mask; }
+ constexpr bool operator==(LaneBitmask M) const {
+ return Mask[0] == M.Mask[0] && Mask[1] == M.Mask[1];
+ }
+ constexpr bool operator!=(LaneBitmask M) const {
+ return Mask[0] != M.Mask[0] || Mask[1] != M.Mask[1];
+ }
+ constexpr bool operator<(LaneBitmask M) const {
+ return Mask[1] < M.Mask[1] || Mask[0] < M.Mask[0];
----------------
sdesmalen-arm wrote:
I had changed this locally but forgot to squash the change!
https://github.com/llvm/llvm-project/pull/111157
More information about the llvm-commits
mailing list