<commit_before>//===-- llvm/Attributes.h - Container for Attributes ------------*- C++ -*-===//
//
//                     The LLVM Compiler Infrastructure
//
// This file is distributed under the University of Illinois Open Source
// License. See LICENSE.TXT for details.
//
//===----------------------------------------------------------------------===//
//
// This file contains the simple types necessary to represent the
// attributes associated with functions and their calls.
//
//===----------------------------------------------------------------------===//

#ifndef LLVM_ATTRIBUTES_H
#define LLVM_ATTRIBUTES_H

#include "llvm/ADT/ArrayRef.h"
#include "llvm/Support/MathExtras.h"
#include <cassert>
#include <string>

namespace llvm {

class AttrBuilder;
class AttributesImpl;
class LLVMContext;
class Type;

//===----------------------------------------------------------------------===//
/// \class Functions, function parameters, and return types can have attributes
/// to indicate how they should be treated by optimizations and code
/// generation. This class represents one of those attributes. It's light-weight
/// and should be passed around by-value.
class Attribute {
public:
  /// This enumeration lists the attributes that can be associated with
  /// parameters, function results or the function itself.
  ///
  /// Note: uwtable is about the ABI or the user mandating an entry in the
  /// unwind table. The nounwind attribute is about an exception passing by the
  /// function.
  ///
  /// In a theoretical system that uses tables for profiling and sjlj for
  /// exceptions, they would be fully independent. In a normal system that uses
  /// tables for both, the semantics are:
  ///
  /// nil                = Needs an entry because an exception might pass by.
  /// nounwind           = No need for an entry
  /// uwtable            = Needs an entry because the ABI says so and because
  ///                      an exception might pass by.
  /// uwtable + nounwind = Needs an entry because the ABI says so.

  enum AttrVal {
    // IR-Level Attributes
    None,                  ///< No attributes have been set
    AddressSafety,         ///< Address safety checking is on.
    Alignment,             ///< Alignment of parameter (5 bits)
                           ///< stored as log2 of alignment with +1 bias
                           ///< 0 means unaligned different from align 1
    AlwaysInline,          ///< inline=always
    ByVal,                 ///< Pass structure by value
    InlineHint,            ///< Source said inlining was desirable
    InReg,                 ///< Force argument to be passed in register
    MinSize,               ///< Function must be optimized for size first
    Naked,                 ///< Naked function
    Nest,                  ///< Nested function static chain
    NoAlias,               ///< Considered to not alias after call
    NoCapture,             ///< Function creates no aliases of pointer
    NoImplicitFloat,       ///< Disable implicit floating point insts
    NoInline,              ///< inline=never
    NonLazyBind,           ///< Function is called early and/or
                           ///< often, so lazy binding isn't worthwhile
    NoRedZone,             ///< Disable redzone
    NoReturn,              ///< Mark the function as not returning
    NoUnwind,              ///< Function doesn't unwind stack
    OptimizeForSize,       ///< opt_size
    ReadNone,              ///< Function does not access memory
    ReadOnly,              ///< Function only reads from memory
    ReturnsTwice,          ///< Function can return twice
    SExt,                  ///< Sign extended before/after call
    StackAlignment,        ///< Alignment of stack for function (3 bits)
                           ///< stored as log2 of alignment with +1 bias 0
                           ///< means unaligned (different from
                           ///< alignstack={1))
    StackProtect,          ///< Stack protection.
    StackProtectReq,       ///< Stack protection required.
    StructRet,             ///< Hidden pointer to structure to return
    UWTable,               ///< Function must be in a unwind table
    ZExt                   ///< Zero extended before/after call
  };
private:
  AttributesImpl *Attrs;
  Attribute(AttributesImpl *A) : Attrs(A) {}
public:
  Attribute() : Attrs(0) {}

  /// \brief Return a uniquified Attribute object. This takes the uniquified
  /// value from the Builder and wraps it in the Attribute class.
  static Attribute get(LLVMContext &Context, ArrayRef<AttrVal> Vals);
  static Attribute get(LLVMContext &Context, AttrBuilder &B);

  /// \brief Return true if the attribute is present.
  bool hasAttribute(AttrVal Val) const;

  /// \brief Return true if attributes exist
  bool hasAttributes() const;

  /// \brief Return true if the attributes are a non-null intersection.
  bool hasAttributes(const Attribute &A) const;

  /// \brief Returns the alignment field of an attribute as a byte alignment
  /// value.
  unsigned getAlignment() const;

  /// \brief Returns the stack alignment field of an attribute as a byte
  /// alignment value.
  unsigned getStackAlignment() const;

  bool operator==(const Attribute &A) const {
    return Attrs == A.Attrs;
  }
  bool operator!=(const Attribute &A) const {
    return Attrs != A.Attrs;
  }

  uint64_t Raw() const;

  /// \brief Which attributes cannot be applied to a type.
  static Attribute typeIncompatible(Type *Ty);

  /// \brief This returns an integer containing an encoding of all the LLVM
  /// attributes found in the given attribute bitset.  Any change to this
  /// encoding is a breaking change to bitcode compatibility.
  static uint64_t encodeLLVMAttributesForBitcode(Attribute Attrs);

  /// \brief This returns an attribute bitset containing the LLVM attributes
  /// that have been decoded from the given integer.  This function must stay in
  /// sync with 'encodeLLVMAttributesForBitcode'.
  static Attribute decodeLLVMAttributesForBitcode(LLVMContext &C,
                                                   uint64_t EncodedAttrs);

  /// \brief The set of attributes set in Attribute is converted to a string of
  /// equivalent mnemonics. This is, presumably, for writing out the mnemonics
  /// for the assembly writer.  @brief Convert attribute bits to text
  std::string getAsString() const;
};

//===----------------------------------------------------------------------===//
/// AttrBuilder - This class is used in conjunction with the Attribute::get
/// method to create an Attribute object. The object itself is uniquified. The
/// Builder's value, however, is not. So this can be used as a quick way to test
/// for equality, presence of attributes, etc.
class AttrBuilder {
  uint64_t Bits;
public:
  AttrBuilder() : Bits(0) {}
  explicit AttrBuilder(uint64_t B) : Bits(B) {}
  AttrBuilder(const Attribute &A) : Bits(A.Raw()) {}

  void clear() { Bits = 0; }

  /// addAttribute - Add an attribute to the builder.
  AttrBuilder &addAttribute(Attribute::AttrVal Val);

  /// removeAttribute - Remove an attribute from the builder.<commit_msg>Remove superfluous brief command from getAsString.<commit_after>//===-- llvm/Attributes.h - Container for Attributes ------------*- C++ -*-===//
//
//                     The LLVM Compiler Infrastructure
//
// This file is distributed under the University of Illinois Open Source
// License. See LICENSE.TXT for details.
//
//===----------------------------------------------------------------------===//
//
// This file contains the simple types necessary to represent the
// attributes associated with functions and their calls.
//
//===----------------------------------------------------------------------===//

#ifndef LLVM_ATTRIBUTES_H
#define LLVM_ATTRIBUTES_H

#include "llvm/ADT/ArrayRef.h"
#include "llvm/Support/MathExtras.h"
#include <cassert>
#include <string>

namespace llvm {

class AttrBuilder;
class AttributesImpl;
class LLVMContext;
class Type;

//===----------------------------------------------------------------------===//
/// \class Functions, function parameters, and return types can have attributes
/// to indicate how they should be treated by optimizations and code
/// generation. This class represents one of those attributes. It's light-weight
/// and should be passed around by-value.
class Attribute {
public:
  /// This enumeration lists the attributes that can be associated with
  /// parameters, function results or the function itself.
  ///
  /// Note: uwtable is about the ABI or the user mandating an entry in the
  /// unwind table. The nounwind attribute is about an exception passing by the
  /// function.
  ///
  /// In a theoretical system that uses tables for profiling and sjlj for
  /// exceptions, they would be fully independent. In a normal system that uses
  /// tables for both, the semantics are:
  ///
  /// nil                = Needs an entry because an exception might pass by.
  /// nounwind           = No need for an entry
  /// uwtable            = Needs an entry because the ABI says so and because
  ///                      an exception might pass by.
  /// uwtable + nounwind = Needs an entry because the ABI says so.

  enum AttrVal {
    // IR-Level Attributes
    None,                  ///< No attributes have been set
    AddressSafety,         ///< Address safety checking is on.
    Alignment,             ///< Alignment of parameter (5 bits)
                           ///< stored as log2 of alignment with +1 bias
                           ///< 0 means unaligned different from align 1
    AlwaysInline,          ///< inline=always
    ByVal,                 ///< Pass structure by value
    InlineHint,            ///< Source said inlining was desirable
    InReg,                 ///< Force argument to be passed in register
    MinSize,               ///< Function must be optimized for size first
    Naked,                 ///< Naked function
    Nest,                  ///< Nested function static chain
    NoAlias,               ///< Considered to not alias after call
    NoCapture,             ///< Function creates no aliases of pointer
    NoImplicitFloat,       ///< Disable implicit floating point insts
    NoInline,              ///< inline=never
    NonLazyBind,           ///< Function is called early and/or
                           ///< often, so lazy binding isn't worthwhile
    NoRedZone,             ///< Disable redzone
    NoReturn,              ///< Mark the function as not returning
    NoUnwind,              ///< Function doesn't unwind stack
    OptimizeForSize,       ///< opt_size
    ReadNone,              ///< Function does not access memory
    ReadOnly,              ///< Function only reads from memory
    ReturnsTwice,          ///< Function can return twice
    SExt,                  ///< Sign extended before/after call
    StackAlignment,        ///< Alignment of stack for function (3 bits)
                           ///< stored as log2 of alignment with +1 bias 0
                           ///< means unaligned (different from
                           ///< alignstack={1))
    StackProtect,          ///< Stack protection.
    StackProtectReq,       ///< Stack protection required.
    StructRet,             ///< Hidden pointer to structure to return
    UWTable,               ///< Function must be in a unwind table
    ZExt                   ///< Zero extended before/after call
  };
private:
  AttributesImpl *Attrs;
  Attribute(AttributesImpl *A) : Attrs(A) {}
public:
  Attribute() : Attrs(0) {}

  /// \brief Return a uniquified Attribute object. This takes the uniquified
  /// value from the Builder and wraps it in the Attribute class.
  static Attribute get(LLVMContext &Context, ArrayRef<AttrVal> Vals);
  static Attribute get(LLVMContext &Context, AttrBuilder &B);

  /// \brief Return true if the attribute is present.
  bool hasAttribute(AttrVal Val) const;

  /// \brief Return true if attributes exist
  bool hasAttributes() const;

  /// \brief Return true if the attributes are a non-null intersection.
  bool hasAttributes(const Attribute &A) const;

  /// \brief Returns the alignment field of an attribute as a byte alignment
  /// value.
  unsigned getAlignment() const;

  /// \brief Returns the stack alignment field of an attribute as a byte
  /// alignment value.
  unsigned getStackAlignment() const;

  bool operator==(const Attribute &A) const {
    return Attrs == A.Attrs;
  }
  bool operator!=(const Attribute &A) const {
    return Attrs != A.Attrs;
  }

  uint64_t Raw() const;

  /// \brief Which attributes cannot be applied to a type.
  static Attribute typeIncompatible(Type *Ty);

  /// \brief This returns an integer containing an encoding of all the LLVM
  /// attributes found in the given attribute bitset.  Any change to this
  /// encoding is a breaking change to bitcode compatibility.
  static uint64_t encodeLLVMAttributesForBitcode(Attribute Attrs);

  /// \brief This returns an attribute bitset containing the LLVM attributes
  /// that have been decoded from the given integer.  This function must stay in
  /// sync with 'encodeLLVMAttributesForBitcode'.
  static Attribute decodeLLVMAttributesForBitcode(LLVMContext &C,
                                                   uint64_t EncodedAttrs);

  /// \brief The set of attributes set in Attribute is converted to a string of
  /// equivalent mnemonics. This is, presumably, for writing out the mnemonics
  /// for the assembly writer.
  std::string getAsString() const;
};

//===----------------------------------------------------------------------===//
/// AttrBuilder - This class is used in conjunction with the Attribute::get
/// method to create an Attribute object. The object itself is uniquified. The
/// Builder's value, however, is not. So this can be used as a quick way to test
/// for equality, presence of attributes, etc.
class AttrBuilder {
  uint64_t Bits;
public:
  AttrBuilder() : Bits(0) {}
  explicit AttrBuilder(uint64_t B) : Bits(B) {}
  AttrBuilder(const Attribute &A) : Bits(A.Raw()) {}

  void clear() { Bits = 0; }

  /// addAttribute - Add an attribute to the builder.
  AttrBuilder &addAttribute(Attribute::AttrVal Val);

  /// removeAttribute - Remove an attribute from the builder.
{'fraction_non_alphanumeric': 0.13169299594575704, 'fraction_numerical': 0.003215434083601286, 'mean_word_length': 1.9245707277187245, 'pattern_counts': {'":': 0, '<': 79, '<?xml version=': 0, '>': 9, 'https://': 0, 'lorem ipsum': 0, 'www.': 0, 'xml': 0}, 'pii_count': 0, 'substrings_counts': 0, 'word_list_counts': {'cursed_substrings.json': 4, 'profanity_word_list.json': 0, 'sexual_word_list.json': 0, 'zh_pornsignals.json': 0}}
{'dir': 'git-commits-cleaned', 'id': '4978843', 'n_tokens_mistral': 3565, 'n_tokens_neox': 3452, 'n_words': 1488}