1 // Licensed to the .NET Foundation under one or more agreements.
2 // The .NET Foundation licenses this file to you under the MIT license.
3 // See the LICENSE file in the project root for more information.
6 // This include file determines how BlockSet is implemented.
8 #ifndef _BLOCKSET_INCLUDED_
9 #define _BLOCKSET_INCLUDED_ 1
11 // A BlockSet is a set of BasicBlocks, represented by the BasicBlock number (bbNum).
12 // Unlike VARSET_TP, we only support a single implementation: the bitset "shortlong"
15 // Note that BasicBlocks in the JIT are numbered starting at 1. We always just waste the
16 // 0th bit to avoid having to do "bbNum - 1" calculations everywhere (at the BlockSet call
17 // sites). This makes reading the code easier, and avoids potential problems of forgetting
18 // to do a "- 1" somewhere.
20 // Basic blocks can be renumbered during compilation, so it is important to not mix
21 // BlockSets created before and after a renumbering. Every time the blocks are renumbered
22 // creates a different "epoch", during which the basic block numbers are stable.
25 #include "compilerbitsettraits.h"
26 #include "bitsetasshortlong.h"
28 class BlockSetOps : public BitSetOps</*BitSetType*/ BitSetShortLongRep,
29 /*Brand*/ BSShortLong,
31 /*BitSetTraits*/ BasicBlockBitSetTraits>
34 // Specialize BlockSetOps::MakeFull(). Since we number basic blocks from one, we remove bit zero from
35 // the block set. Otherwise, IsEmpty() would never return true.
36 static BitSetShortLongRep MakeFull(Compiler* env)
38 BitSetShortLongRep retval;
40 // First, make a full set using the BitSetOps::MakeFull
42 retval = BitSetOps</*BitSetType*/ BitSetShortLongRep,
43 /*Brand*/ BSShortLong,
45 /*BitSetTraits*/ BasicBlockBitSetTraits>::MakeFull(env);
47 // Now, remove element zero, since we number basic blocks starting at one, and index the set with the
48 // basic block number. If we left this, then IsEmpty() would never return true.
49 BlockSetOps::RemoveElemD(env, retval, 0);
55 typedef BitSetShortLongRep BlockSet;
57 // These types should be used as the types for BlockSet arguments and return values, respectively.
58 typedef BlockSetOps::ValArgType BlockSet_ValArg_T;
59 typedef BlockSetOps::RetValType BlockSet_ValRet_T;
61 #endif // _BLOCKSET_INCLUDED_