BAD_ICMP_PREDICATE = ICMP_SLE + 1
};
using PredicateField =
- Bitfield::Element<Predicate, 0, 6, LAST_ICMP_PREDICATE>; // Next bit:6
+ Bitfield::Element<Predicate, 0, 6, LAST_ICMP_PREDICATE>;
protected:
CmpInst(Type *ty, Instruction::OtherOps op, Predicate pred,
/// subclass requires. Note that accessing the end of the argument list isn't
/// as cheap as most other operations on the base class.
class CallBase : public Instruction {
- // The first two bits are reserved by CallInst for fast retrieving,
- using CallInstReservedField = Bitfield::Element<unsigned, 0, 2>; // Next bit:2
- using CallingConvField = Bitfield::Element<CallingConv::ID, 2, 10,
- CallingConv::MaxID>; // Next bit:12
-
protected:
+ // The first two bits are reserved by CallInst for fast retrieval,
+ using CallInstReservedField = Bitfield::Element<unsigned, 0, 2>;
+ using CallingConvField =
+ Bitfield::Element<CallingConv::ID, CallInstReservedField::NextBit, 10,
+ CallingConv::MaxID>;
+ static_assert(
+ Bitfield::areContiguous<CallInstReservedField, CallingConvField>(),
+ "Bitfields must be contiguous");
+
/// The last operand is the called operand.
static constexpr int CalledOperandOpEndIdx = -1;
#include "llvm/IR/SymbolTableListTraits.h"
#include "llvm/IR/User.h"
#include "llvm/IR/Value.h"
+#include "llvm/Support/AtomicOrdering.h"
#include "llvm/Support/Casting.h"
#include <algorithm>
#include <cassert>
protected:
// The 15 first bits of `Value::SubclassData` are available for subclasses of
// `Instruction` to use.
- using OpaqueField = Bitfield::Element<uint16_t, 0, 15>; // Next bit:15
+ using OpaqueField = Bitfield::Element<uint16_t, 0, 15>;
// Template alias so that all Instruction storing alignment use the same
// definiton.
// 2^29. We store them as Log2(Alignment), so we need 5 bits to encode the 30
// possible values.
template <unsigned Offset>
- using AlignmentBitfieldElement =
+ using AlignmentBitfieldElementT =
typename Bitfield::Element<unsigned, Offset, 5,
Value::MaxAlignmentExponent>;
+ template <unsigned Offset>
+ using BoolBitfieldElementT = typename Bitfield::Element<bool, Offset, 1>;
+
+ template <unsigned Offset>
+ using AtomicOrderingBitfieldElementT =
+ typename Bitfield::Element<AtomicOrdering, Offset, 3,
+ AtomicOrdering::LAST>;
+
private:
// The last bit is used to store whether the instruction has metadata attached
// or not.
class AllocaInst : public UnaryInstruction {
Type *AllocatedType;
- using AlignmentField = AlignmentBitfieldElement<0>; // Next bit:5
- using UsedWithInAllocaField = Bitfield::Element<bool, 5, 1>; // Next bit:6
- using SwiftErrorField = Bitfield::Element<bool, 6, 1>; // Next bit:7
+ using AlignmentField = AlignmentBitfieldElementT<0>;
+ using UsedWithInAllocaField = BoolBitfieldElementT<AlignmentField::NextBit>;
+ using SwiftErrorField = BoolBitfieldElementT<UsedWithInAllocaField::NextBit>;
+ static_assert(Bitfield::areContiguous<AlignmentField, UsedWithInAllocaField,
+ SwiftErrorField>(),
+ "Bitfields must be contiguous");
protected:
// Note: Instruction needs to be a friend here to call cloneImpl.
/// An instruction for reading from memory. This uses the SubclassData field in
/// Value to store whether or not the load is volatile.
class LoadInst : public UnaryInstruction {
- using VolatileField = Bitfield::Element<bool, 0, 1>; // Next bit:1
- using AlignmentField = AlignmentBitfieldElement<1>; // Next bit:6
- using OrderingField = Bitfield::Element<AtomicOrdering, 6, 3,
- AtomicOrdering::LAST>; // Next bit:9
+ using VolatileField = BoolBitfieldElementT<0>;
+ using AlignmentField = AlignmentBitfieldElementT<VolatileField::NextBit>;
+ using OrderingField = AtomicOrderingBitfieldElementT<AlignmentField::NextBit>;
+ static_assert(
+ Bitfield::areContiguous<VolatileField, AlignmentField, OrderingField>(),
+ "Bitfields must be contiguous");
void AssertOK();
/// An instruction for storing to memory.
class StoreInst : public Instruction {
- using VolatileField = Bitfield::Element<bool, 0, 1>; // Next bit:1
- using AlignmentField = AlignmentBitfieldElement<1>; // Next bit:6
- using OrderingField = Bitfield::Element<AtomicOrdering, 6, 3,
- AtomicOrdering::LAST>; // Next bit:9
+ using VolatileField = BoolBitfieldElementT<0>;
+ using AlignmentField = AlignmentBitfieldElementT<VolatileField::NextBit>;
+ using OrderingField = AtomicOrderingBitfieldElementT<AlignmentField::NextBit>;
+ static_assert(
+ Bitfield::areContiguous<VolatileField, AlignmentField, OrderingField>(),
+ "Bitfields must be contiguous");
void AssertOK();
/// An instruction for ordering other memory operations.
class FenceInst : public Instruction {
- using OrderingField = Bitfield::Element<AtomicOrdering, 1, 3,
- AtomicOrdering::LAST>; // Next bit:4
+ using OrderingField = AtomicOrderingBitfieldElementT<0>;
void Init(AtomicOrdering Ordering, SyncScope::ID SSID);
return User::operator new(s, 3);
}
- using VolatileField = Bitfield::Element<bool, 0, 1>; // Next bit:1
- using WeakField = Bitfield::Element<bool, 1, 1>; // Next bit:2
- using SuccessOrderingField = AtomicOrderingBitfieldElement<2>; // Next bit:5
- using FailureOrderingField = AtomicOrderingBitfieldElement<5>; // Next bit:8
- using AlignmentField = AlignmentBitfieldElement<8>; // Next bit:13
+ using VolatileField = BoolBitfieldElementT<0>;
+ using WeakField = BoolBitfieldElementT<VolatileField::NextBit>;
+ using SuccessOrderingField =
+ AtomicOrderingBitfieldElementT<WeakField::NextBit>;
+ using FailureOrderingField =
+ AtomicOrderingBitfieldElementT<SuccessOrderingField::NextBit>;
+ using AlignmentField =
+ AlignmentBitfieldElementT<FailureOrderingField::NextBit>;
+ static_assert(
+ Bitfield::areContiguous<VolatileField, WeakField, SuccessOrderingField,
+ FailureOrderingField, AlignmentField>(),
+ "Bitfields must be contiguous");
/// Return the alignment of the memory that is being allocated by the
/// instruction.
return User::operator new(s, 2);
}
- using VolatileField = Bitfield::Element<bool, 0, 1>; // Next bit:1
- using AtomicOrderingField = AtomicOrderingBitfieldElement<1>; // Next bit:4
- using OperationField = BinOpBitfieldElement<4>; // Next bit:8
- using AlignmentField = AlignmentBitfieldElement<8>; // Next bit:13
+ using VolatileField = BoolBitfieldElementT<0>;
+ using AtomicOrderingField =
+ AtomicOrderingBitfieldElementT<VolatileField::NextBit>;
+ using OperationField = BinOpBitfieldElement<AtomicOrderingField::NextBit>;
+ using AlignmentField = AlignmentBitfieldElementT<OperationField::NextBit>;
+ static_assert(Bitfield::areContiguous<VolatileField, AtomicOrderingField,
+ OperationField, AlignmentField>(),
+ "Bitfields must be contiguous");
BinOp getOperation() const { return getSubclassData<OperationField>(); }
};
using TailCallKindField = Bitfield::Element<TailCallKind, 0, 2, TCK_LAST>;
+ static_assert(
+ Bitfield::areContiguous<TailCallKindField, CallBase::CallingConvField>(),
+ "Bitfields must be contiguous");
TailCallKind getTailCallKind() const {
return getSubclassData<TailCallKindField>();
/// cleanup.
///
class LandingPadInst : public Instruction {
- using CleanupField = Bitfield::Element<bool, 0, 1>;
+ using CleanupField = BoolBitfieldElementT<0>;
/// The number of operands actually allocated. NumOperands is
/// the number actually in use.
// CatchSwitchInst Class
//===----------------------------------------------------------------------===//
class CatchSwitchInst : public Instruction {
- using UnwindDestField = Bitfield::Element<unsigned, 0, 1>; // Next bit:1
+ using UnwindDestField = BoolBitfieldElementT<0>;
/// The number of operands actually allocated. NumOperands is
/// the number actually in use.
//===----------------------------------------------------------------------===//
class CleanupReturnInst : public Instruction {
- using UnwindDestField = Bitfield::Element<unsigned, 0, 1>; // Next bit:1
+ using UnwindDestField = BoolBitfieldElementT<0>;
+
private:
CleanupReturnInst(const CleanupReturnInst &RI);
CleanupReturnInst(Value *CleanupPad, BasicBlock *UnwindBB, unsigned Values,