File indexing completed on 2026-05-10 08:43:27
0001
0002
0003
0004
0005
0006
0007
0008
0009
0010
0011
0012
0013
0014
0015
0016
0017 #ifndef LLVM_CODEGEN_BYTEPROVIDER_H
0018 #define LLVM_CODEGEN_BYTEPROVIDER_H
0019
0020 #include <optional>
0021 #include <type_traits>
0022
0023 namespace llvm {
0024
0025
0026
0027
0028
0029
0030 template <typename ISelOp> class ByteProvider {
0031 private:
0032 ByteProvider(std::optional<ISelOp> Src, int64_t DestOffset, int64_t SrcOffset)
0033 : Src(Src), DestOffset(DestOffset), SrcOffset(SrcOffset) {}
0034
0035
0036
0037 template <typename T> class is_op {
0038 private:
0039 using yes = std::true_type;
0040 using no = std::false_type;
0041
0042
0043 template <typename U>
0044 static auto test(int) -> decltype(std::declval<U>().getOpcode(), yes());
0045
0046 template <typename> static no test(...);
0047
0048 public:
0049 using remove_pointer_t = typename std::remove_pointer<T>::type;
0050 static constexpr bool value =
0051 std::is_same<decltype(test<remove_pointer_t>(0)), yes>::value;
0052 };
0053
0054 public:
0055
0056
0057 std::optional<ISelOp> Src = std::nullopt;
0058
0059 int64_t DestOffset = 0;
0060
0061
0062 int64_t SrcOffset = 0;
0063
0064 ByteProvider() = default;
0065
0066 static ByteProvider getSrc(std::optional<ISelOp> Val, int64_t ByteOffset,
0067 int64_t VectorOffset) {
0068 static_assert(is_op<ISelOp>().value,
0069 "ByteProviders must contain an operation in selection DAG.");
0070 return ByteProvider(Val, ByteOffset, VectorOffset);
0071 }
0072
0073 static ByteProvider getConstantZero() {
0074 return ByteProvider<ISelOp>(std::nullopt, 0, 0);
0075 }
0076 bool isConstantZero() const { return !Src; }
0077
0078 bool hasSrc() const { return Src.has_value(); }
0079
0080 bool hasSameSrc(const ByteProvider &Other) const { return Other.Src == Src; }
0081
0082 bool operator==(const ByteProvider &Other) const {
0083 return Other.Src == Src && Other.DestOffset == DestOffset &&
0084 Other.SrcOffset == SrcOffset;
0085 }
0086 };
0087 }
0088
0089 #endif