<commit_before>//===--- SILValue.h - Value base class for SIL ------------------*- C++ -*-===//
//
// This source file is part of the Swift.org open source project
//
// Copyright (c) 2014 - 2015 Apple Inc. and the Swift project authors
// Licensed under Apache License v2.0 with Runtime Library Exception
//
// See http://swift.org/LICENSE.txt for license information
// See http://swift.org/CONTRIBUTORS.txt for the list of Swift project authors
//
//===----------------------------------------------------------------------===//
//
// This file defines the SILValue class.
//
//===----------------------------------------------------------------------===//

#ifndef SWIFT_SIL_VALUE_H
#define SWIFT_SIL_VALUE_H

#include "swift/Basic/Range.h"
#include "swift/SIL/SILType.h"
#include "llvm/ADT/ArrayRef.h"
#include "llvm/ADT/PointerUnion.h"

namespace swift {
  class SILTypeList;
  class Operand;
  class SILValue;
  class ValueBaseUseIterator;
  class ValueUseIterator;
  class SILInstruction;

  enum class ValueKind {
#define VALUE(Id, Parent) Id,
#define VALUE_RANGE(Id, FirstId, LastId) \
    First_##Id = FirstId, Last_##Id = LastId,
#include "swift/SIL/SILNodes.def"
  };

/// ValueBase - This is the base class of the SIL value hierarchy, which
/// represents a runtime computed value.  Things like SILInstruction derive
/// from this.
class alignas(8) ValueBase : public SILAllocated<ValueBase> {
  PointerUnion<SILType, SILTypeList*> TypeOrTypeList;
  Operand *FirstUse = nullptr;
  friend class Operand;
  friend class SILValue;
  
  const ValueKind Kind;

  ValueBase(const ValueBase &) = delete;
  ValueBase &operator=(const ValueBase &) = delete;

protected:
  ValueBase(ValueKind Kind, SILTypeList *TypeList = 0)
    : TypeOrTypeList(TypeList), Kind(Kind) {}
  ValueBase(ValueKind Kind, SILType Ty)
    : TypeOrTypeList(Ty), Kind(Kind) {}
  
public:
  ~ValueBase() {
    assert(use_empty() && "Cannot destroy a value that still has uses!");
  }


  ValueKind getKind() const { return Kind; }

  ArrayRef<SILType> getTypes() const;
  
  /// True if the "value" is actually a value that can be used by other
  /// instructions.
  bool hasValue() const { return !TypeOrTypeList.isNull(); }

  SILType getType(unsigned i) const {
    if (TypeOrTypeList.is<SILType>()) {
      assert(i == 0);
      return TypeOrTypeList.get<SILType>();
    }
    return getTypes()[i];
  }
  
  unsigned getNumTypes() const {
    if (TypeOrTypeList.isNull())
      return 0;
    if (TypeOrTypeList.is<SILType>())
      return 1;
    return getTypes().size();
  }


  bool use_empty() const { return FirstUse == nullptr; }
  inline ValueBaseUseIterator use_begin();
  inline ValueBaseUseIterator use_end();
  inline Range<ValueBaseUseIterator> getUses();

  inline bool hasOneUse();

  /// Pretty-print the value.
  void dump() const;
  void print(raw_ostream &OS) const;
  
  /// Pretty-print the value in context, preceded by its operands (if the
  /// value represents the result of an instruction) and followed by its
  /// users.
  void dumpInContext() const;
  void printInContext(raw_ostream &OS) const;

  static bool classof(const ValueBase *V) { return true; }
};

inline llvm::raw_ostream &operator<<(llvm::raw_ostream &OS,
                                     const ValueBase &V) {
  V.print(OS);
  return OS;
}
}  // end namespace swift

namespace llvm {
// TypeBase* is always at least eight-byte aligned; make the three tag bits
// available through PointerLikeTypeTraits.
template<>
class PointerLikeTypeTraits<swift::ValueBase*> {
public:
  static inline void *getAsVoidPointer(swift::ValueBase *I) {
    return (void*)I;
  }
  static inline swift::ValueBase *getFromVoidPointer(void *P) {
    return (swift::ValueBase*)P;
  }
  enum { NumLowBitsAvailable = alignof(swift::ValueBase) };
};
} // end namespace llvm

namespace swift {

enum {
  /// The number of bits required to store a ResultNumber.
  /// This is primarily here as a way to allow everything that
  /// depends on it to be easily grepped.<commit_msg>Fix misuse of alignof, which returns alignment as 2^N instead of N.<commit_after>//===--- SILValue.h - Value base class for SIL ------------------*- C++ -*-===//
//
// This source file is part of the Swift.org open source project
//
// Copyright (c) 2014 - 2015 Apple Inc. and the Swift project authors
// Licensed under Apache License v2.0 with Runtime Library Exception
//
// See http://swift.org/LICENSE.txt for license information
// See http://swift.org/CONTRIBUTORS.txt for the list of Swift project authors
//
//===----------------------------------------------------------------------===//
//
// This file defines the SILValue class.
//
//===----------------------------------------------------------------------===//

#ifndef SWIFT_SIL_VALUE_H
#define SWIFT_SIL_VALUE_H

#include "swift/Basic/Range.h"
#include "swift/SIL/SILType.h"
#include "llvm/ADT/ArrayRef.h"
#include "llvm/ADT/PointerUnion.h"

namespace swift {
  class SILTypeList;
  class Operand;
  class SILValue;
  class ValueBaseUseIterator;
  class ValueUseIterator;
  class SILInstruction;

  enum class ValueKind {
#define VALUE(Id, Parent) Id,
#define VALUE_RANGE(Id, FirstId, LastId) \
    First_##Id = FirstId, Last_##Id = LastId,
#include "swift/SIL/SILNodes.def"
  };

/// ValueBase - This is the base class of the SIL value hierarchy, which
/// represents a runtime computed value.  Things like SILInstruction derive
/// from this.
class alignas(8) ValueBase : public SILAllocated<ValueBase> {
  PointerUnion<SILType, SILTypeList*> TypeOrTypeList;
  Operand *FirstUse = nullptr;
  friend class Operand;
  friend class SILValue;
  
  const ValueKind Kind;

  ValueBase(const ValueBase &) = delete;
  ValueBase &operator=(const ValueBase &) = delete;

protected:
  ValueBase(ValueKind Kind, SILTypeList *TypeList = 0)
    : TypeOrTypeList(TypeList), Kind(Kind) {}
  ValueBase(ValueKind Kind, SILType Ty)
    : TypeOrTypeList(Ty), Kind(Kind) {}
  
public:
  ~ValueBase() {
    assert(use_empty() && "Cannot destroy a value that still has uses!");
  }


  ValueKind getKind() const { return Kind; }

  ArrayRef<SILType> getTypes() const;
  
  /// True if the "value" is actually a value that can be used by other
  /// instructions.
  bool hasValue() const { return !TypeOrTypeList.isNull(); }

  SILType getType(unsigned i) const {
    if (TypeOrTypeList.is<SILType>()) {
      assert(i == 0);
      return TypeOrTypeList.get<SILType>();
    }
    return getTypes()[i];
  }
  
  unsigned getNumTypes() const {
    if (TypeOrTypeList.isNull())
      return 0;
    if (TypeOrTypeList.is<SILType>())
      return 1;
    return getTypes().size();
  }


  bool use_empty() const { return FirstUse == nullptr; }
  inline ValueBaseUseIterator use_begin();
  inline ValueBaseUseIterator use_end();
  inline Range<ValueBaseUseIterator> getUses();

  inline bool hasOneUse();

  /// Pretty-print the value.
  void dump() const;
  void print(raw_ostream &OS) const;
  
  /// Pretty-print the value in context, preceded by its operands (if the
  /// value represents the result of an instruction) and followed by its
  /// users.
  void dumpInContext() const;
  void printInContext(raw_ostream &OS) const;

  static bool classof(const ValueBase *V) { return true; }
};

inline llvm::raw_ostream &operator<<(llvm::raw_ostream &OS,
                                     const ValueBase &V) {
  V.print(OS);
  return OS;
}
}  // end namespace swift

namespace llvm {
// TypeBase* is always at least eight-byte aligned; make the three tag bits
// available through PointerLikeTypeTraits.
template<>
class PointerLikeTypeTraits<swift::ValueBase*> {
public:
  static inline void *getAsVoidPointer(swift::ValueBase *I) {
    return (void*)I;
  }
  static inline swift::ValueBase *getFromVoidPointer(void *P) {
    return (swift::ValueBase*)P;
  }
  enum { NumLowBitsAvailable = 3 };
};
} // end namespace llvm

namespace swift {

enum {
  /// The number of bits required to store a ResultNumber.
  /// This is primarily here as a way to allow everything that
  /// depends on it to be easily grepped.
{'fraction_non_alphanumeric': 0.1545027214250371, 'fraction_numerical': 0.0039584364176150424, 'mean_word_length': 2.9651790093182933, 'pattern_counts': {'":': 0, '<': 25, '<?xml version=': 0, '>': 21, 'https://': 0, 'lorem ipsum': 0, 'www.': 0, 'xml': 0}, 'pii_count': 0, 'substrings_counts': 0, 'word_list_counts': {'cursed_substrings.json': 2, 'profanity_word_list.json': 0, 'sexual_word_list.json': 0, 'zh_pornsignals.json': 0}}
{'dir': 'git-commits-cleaned', 'id': '3488910', 'n_tokens_mistral': 2496, 'n_tokens_neox': 2433, 'n_words': 770}