LLVM: include/llvm/CAS/BuiltinObjectHasher.h Source File (original) (raw)

1

2

3

4

5

6

7

8

9#ifndef LLVM_CAS_BUILTINOBJECTHASHER_H

10#define LLVM_CAS_BUILTINOBJECTHASHER_H

11

14

16

17

18template class BuiltinObjectHasher {

19public:

21

24 BuiltinObjectHasher H;

25 H.updateSize(Refs.size());

27 H.updateRef(CAS, Ref);

28 H.updateArray(Data);

29 return H.finish();

30 }

31

34 BuiltinObjectHasher H;

35 H.updateSize(Refs.size());

37 H.updateID(Ref);

38 H.updateArray(Data);

39 return H.finish();

40 }

41

42private:

43 HashT finish() { return Hasher.final(); }

44

45 void updateRef(const ObjectStore &CAS, ObjectRef Ref) {

46 updateID(CAS.getID(Ref));

47 }

48

49 void updateID(const CASID &ID) { updateID(ID.getHash()); }

50

51 void updateID(ArrayRef<uint8_t> Hash) {

52

53

55 "Expected object ref to match the hash size");

56 Hasher.update(Hash);

57 }

58

59 void updateArray(ArrayRef<uint8_t> Bytes) {

60 updateSize(Bytes.size());

61 Hasher.update(Bytes);

62 }

63

64 void updateArray(ArrayRef Bytes) {

65 updateArray(ArrayRef(reinterpret_cast<const uint8_t *>(Bytes.data()),

66 Bytes.size()));

67 }

68

69 void updateSize(uint64_t Size) {

71 Hasher.update(

72 ArrayRef(reinterpret_cast<const uint8_t *>(&Size), sizeof(Size)));

73 }

74

75 BuiltinObjectHasher() = default;

76 ~BuiltinObjectHasher() = default;

78};

79

80}

81

82#endif

assert(UImm &&(UImm !=~static_cast< T >(0)) &&"Invalid immediate!")

This file contains the declaration of the ObjectStore class.

ArrayRef - Represent a constant reference to an array (0 or more elements consecutively in memory),...

size_t size() const

size - Get the array size.

static HashT hashObject(const ObjectStore &CAS, ArrayRef< ObjectRef > Refs, ArrayRef< char > Data)

Definition BuiltinObjectHasher.h:22

static HashT hashObject(ArrayRef< ArrayRef< uint8_t > > Refs, ArrayRef< char > Data)

Definition BuiltinObjectHasher.h:32

decltype(HasherT::hash(std::declval< ArrayRef< uint8_t > & >())) HashT

Definition BuiltinObjectHasher.h:20

Reference to an object in an ObjectStore instance.

Content-addressable storage for objects.

unsigned ID

LLVM IR allows to use arbitrary numbers as calling convention identifiers.

BLAKE3 HasherT

Current hash type for the builtin CAS.

value_type byte_swap(value_type value, endianness endian)

@ Ref

The access may reference the value stored in memory.

FunctionAddr VTableAddr uintptr_t uintptr_t Data

ArrayRef(const T &OneElt) -> ArrayRef< T >