//===- llvm/DerivedTypes.h - Classes for handling data types ----*- C++ -*-===// // // Part of the LLVM Project, under the Apache License v2.0 with LLVM Exceptions. // See https://llvm.org/LICENSE.txt for license information. // SPDX-License-Identifier: Apache-2.0 WITH LLVM-exception // //===----------------------------------------------------------------------===// // // This file contains the declarations of classes that represent "derived // types". These are things like "arrays of x" or "structure of x, y, z" or // "function returning x taking (y,z) as parameters", etc... // // The implementations of these classes live in the Type.cpp file. // //===----------------------------------------------------------------------===// #ifndef LLVM_IR_DERIVEDTYPES_H #define LLVM_IR_DERIVEDTYPES_H #include "llvm/ADT/ArrayRef.h" #include "llvm/ADT/STLExtras.h" #include "llvm/ADT/StringRef.h" #include "llvm/IR/Type.h" #include "llvm/Support/Casting.h" #include "llvm/Support/Compiler.h" #include "llvm/Support/TypeSize.h" #include <cassert> #include <cstdint> namespace llvm { class Value; class APInt; class LLVMContext; template <typename T> class Expected; /// Class to represent integer types. Note that this class is also used to /// represent the built-in integer types: Int1Ty, Int8Ty, Int16Ty, Int32Ty and /// Int64Ty. /// Integer representation type class IntegerType : public Type { … }; unsigned Type::getIntegerBitWidth() const { … } /// Class to represent function types /// class FunctionType : public Type { … }; static_assert …; bool Type::isFunctionVarArg() const { … } Type *Type::getFunctionParamType(unsigned i) const { … } unsigned Type::getFunctionNumParams() const { … } /// A handy container for a FunctionType+Callee-pointer pair, which can be /// passed around as a single entity. This assists in replacing the use of /// PointerType::getElementType() to access the function's type, since that's /// slated for removal as part of the [opaque pointer types] project. class FunctionCallee { … }; /// Class to represent struct types. There are two different kinds of struct /// types: Literal structs and Identified structs. /// /// Literal struct types (e.g. { i32, i32 }) are uniqued structurally, and must /// always have a body when created. You can get one of these by using one of /// the StructType::get() forms. /// /// Identified structs (e.g. %foo or %42) may optionally have a name and are not /// uniqued. The names for identified structs are managed at the LLVMContext /// level, so there can only be a single identified struct with a given name in /// a particular LLVMContext. Identified structs may also optionally be opaque /// (have no body specified). You get one of these by using one of the /// StructType::create() forms. /// /// Independent of what kind of struct you have, the body of a struct type are /// laid out in memory consecutively with the elements directly one after the /// other (if the struct is packed) or (if not packed) with padding between the /// elements as defined by DataLayout (which is required to match what the code /// generator for a target expects). /// class StructType : public Type { … }; StringRef Type::getStructName() const { … } unsigned Type::getStructNumElements() const { … } Type *Type::getStructElementType(unsigned N) const { … } /// Class to represent array types. class ArrayType : public Type { … }; uint64_t Type::getArrayNumElements() const { … } /// Base class of all SIMD vector types class VectorType : public Type { … }; /// Class to represent fixed width SIMD vectors class FixedVectorType : public VectorType { … }; /// Class to represent scalable SIMD vectors class ScalableVectorType : public VectorType { … }; inline ElementCount VectorType::getElementCount() const { … } /// Class to represent pointers. class PointerType : public Type { … }; Type *Type::getExtendedType() const { … } Type *Type::getWithNewType(Type *EltTy) const { … } Type *Type::getWithNewBitWidth(unsigned NewBitWidth) const { … } unsigned Type::getPointerAddressSpace() const { … } /// Class to represent target extensions types, which are generally /// unintrospectable from target-independent optimizations. /// /// Target extension types have a string name, and optionally have type and/or /// integer parameters. The exact meaning of any parameters is dependent on the /// target. class TargetExtType : public Type { … }; StringRef Type::getTargetExtName() const { … } } // end namespace llvm #endif // LLVM_IR_DERIVEDTYPES_H