LLVM 20.0.0git
MCDCTypes.h
Go to the documentation of this file.
1//===- MCDCTypes.h - Types related to MC/DC Coverage ------------*- C++ -*-===//
2//
3// Part of the LLVM Project, under the Apache License v2.0 with LLVM Exceptions.
4// See https://llvm.org/LICENSE.txt for license information.
5// SPDX-License-Identifier: Apache-2.0 WITH LLVM-exception
6//
7//===----------------------------------------------------------------------===//
8//
9// Types related to MC/DC Coverage.
10//
11//===----------------------------------------------------------------------===//
12
13#ifndef LLVM_PROFILEDATA_COVERAGE_MCDCTYPES_H
14#define LLVM_PROFILEDATA_COVERAGE_MCDCTYPES_H
15
16#include <array>
17#include <cassert>
18#include <type_traits>
19#include <variant>
20
21namespace llvm::coverage::mcdc {
22
23/// The ID for MCDCBranch.
24using ConditionID = int16_t;
25using ConditionIDs = std::array<ConditionID, 2>;
26
28 /// Byte Index of Bitmap Coverage Object for a Decision Region.
29 unsigned BitmapIdx;
30
31 /// Number of Conditions used for a Decision Region.
33
38 }
39};
40
42 /// IDs used to represent a branch region and other branch regions
43 /// evaluated based on True and False branches.
46
47 BranchParameters() = delete;
49 : ID(ID), Conds(Conds) {
50 assert(ID >= 0);
51 }
52};
53
54/// The type of MC/DC-specific parameters.
56 std::variant<std::monostate, DecisionParameters, BranchParameters>;
57
58/// Check and get underlying params in MCDCParams.
59/// \tparam MaybeConstInnerParameters Type to get. May be const.
60/// \tparam MaybeConstMCDCParameters Expected inferred. May be const.
61/// \param MCDCParams May be const.
62template <class MaybeConstInnerParameters, class MaybeConstMCDCParameters>
63static auto &getParams(MaybeConstMCDCParameters &MCDCParams) {
64 using InnerParameters =
65 typename std::remove_const<MaybeConstInnerParameters>::type;
66 MaybeConstInnerParameters *Params = std::get_if<InnerParameters>(&MCDCParams);
67 assert(Params && "InnerParameters unavailable");
68 return *Params;
69}
70
71} // namespace llvm::coverage::mcdc
72
73#endif // LLVM_PROFILEDATA_COVERAGE_MCDCTYPES_H
assert(ImpDefSCC.getReg()==AMDGPU::SCC &&ImpDefSCC.isDef())
static auto & getParams(MaybeConstMCDCParameters &MCDCParams)
Check and get underlying params in MCDCParams.
Definition: MCDCTypes.h:63
std::variant< std::monostate, DecisionParameters, BranchParameters > Parameters
The type of MC/DC-specific parameters.
Definition: MCDCTypes.h:56
int16_t ConditionID
The ID for MCDCBranch.
Definition: MCDCTypes.h:24
std::array< ConditionID, 2 > ConditionIDs
Definition: MCDCTypes.h:25
BranchParameters(ConditionID ID, const ConditionIDs &Conds)
Definition: MCDCTypes.h:48
ConditionID ID
IDs used to represent a branch region and other branch regions evaluated based on True and False bran...
Definition: MCDCTypes.h:44
unsigned BitmapIdx
Byte Index of Bitmap Coverage Object for a Decision Region.
Definition: MCDCTypes.h:29
DecisionParameters(unsigned BitmapIdx, unsigned NumConditions)
Definition: MCDCTypes.h:35
uint16_t NumConditions
Number of Conditions used for a Decision Region.
Definition: MCDCTypes.h:32