17 return 1uLL << static_cast<std::size_t>(S);
21 return static_cast<std::size_t
>(S);
27 return "BufferExtents";
31 return "WallClockTime";
57 std::bitset<number(BlockVerifier::State::StateMax)>
ToStates;
62 Error BlockVerifier::transition(State To) {
63 using ToSet = std::bitset<number(State::StateMax)>;
64 static constexpr std::array<const Transition, number(State::StateMax)>
66 {mask(State::BufferExtents) | mask(State::NewBuffer)}},
68 {State::BufferExtents, {mask(State::NewBuffer)}},
70 {State::NewBuffer, {mask(State::WallClockTime)}},
72 {State::WallClockTime,
73 {mask(State::PIDEntry) | mask(State::NewCPUId)}},
75 {State::PIDEntry, {mask(State::NewCPUId)}},
78 {mask(State::NewCPUId) | mask(State::TSCWrap) |
79 mask(State::CustomEvent) | mask(State::Function) |
80 mask(State::EndOfBuffer) | mask(State::TypedEvent)}},
83 {mask(State::TSCWrap) | mask(State::NewCPUId) |
84 mask(State::CustomEvent) | mask(State::Function) |
85 mask(State::EndOfBuffer) | mask(State::TypedEvent)}},
88 {mask(State::CustomEvent) | mask(State::TSCWrap) |
89 mask(State::NewCPUId) | mask(State::Function) |
90 mask(State::EndOfBuffer) | mask(State::TypedEvent)}},
93 {mask(State::TypedEvent) | mask(State::TSCWrap) |
94 mask(State::NewCPUId) | mask(State::Function) |
95 mask(State::EndOfBuffer) | mask(State::CustomEvent)}},
98 {mask(State::Function) | mask(State::TSCWrap) |
99 mask(State::NewCPUId) | mask(State::CustomEvent) |
101 mask(State::TypedEvent)}},
105 mask(State::TSCWrap) | mask(State::NewCPUId) |
106 mask(State::CustomEvent) | mask(State::EndOfBuffer) |
107 mask(State::TypedEvent)}},
109 {State::EndOfBuffer, {}}}};
111 if (CurrentRecord >= State::StateMax)
114 "BUG (BlockVerifier): Cannot find transition table entry for %s, " 115 "transitioning to %s.",
116 recordToString(CurrentRecord).data(), recordToString(To).data());
120 if (CurrentRecord == State::EndOfBuffer && To != State::NewBuffer)
123 auto &Mapping = TransitionTable[number(CurrentRecord)];
124 auto &Destinations = Mapping.ToStates;
125 assert(Mapping.From == CurrentRecord &&
126 "BUG: Wrong index for record mapping.");
127 if ((Destinations & ToSet(mask(To))) == 0)
130 "BlockVerifier: Invalid transition from %s to %s.",
131 recordToString(CurrentRecord).data(), recordToString(To).data());
138 return transition(State::BufferExtents);
142 return transition(State::WallClockTime);
146 return transition(State::NewCPUId);
150 return transition(State::TSCWrap);
154 return transition(State::CustomEvent);
158 return transition(State::CustomEvent);
162 return transition(State::TypedEvent);
172 return transition(State::NewBuffer);
176 return transition(State::EndOfBuffer);
180 return transition(State::Function);
185 switch (CurrentRecord) {
186 case State::EndOfBuffer:
187 case State::NewCPUId:
188 case State::CustomEvent:
189 case State::TypedEvent:
190 case State::Function:
197 "BlockVerifier: Invalid terminal condition %s, malformed block.",
198 recordToString(CurrentRecord).data());
This class represents lattice values for constants.
std::error_code make_error_code(BitcodeError E)
Error visit(BufferExtents &) override
#define llvm_unreachable(msg)
Marks that the current location is not supposed to be reachable.
static ErrorSuccess success()
Create a success value.
BlockVerifier::State From
assert(ImpDefSCC.getReg()==AMDGPU::SCC &&ImpDefSCC.isDef())
Lightweight error class with error context and mandatory checking.
std::bitset< number(BlockVerifier::State::StateMax)> ToStates
Error createStringError(std::error_code EC, char const *Fmt, const Ts &... Vals)
Create formatted StringError object.