From 06565dca0c0ef279d8cb79c3695ef7e6284b6e5f Mon Sep 17 00:00:00 2001 From: Reid Spencer Date: Fri, 12 Jan 2007 17:11:23 +0000 Subject: [PATCH] Update documentation for arbitrary precision integers: 1. int -> i32 2. Describe the IntegerType class. 3. Correct the description of Type and its primitive type subclasses. 4. Document OpaqueType and PackedType a little better. git-svn-id: https://llvm.org/svn/llvm-project/llvm/trunk@33120 91177308-0d34-0410-b5e6-96231b3b80d8 --- docs/ProgrammersManual.html | 84 +++++++++++++++++++++++++------------ 1 file changed, 57 insertions(+), 27 deletions(-) diff --git a/docs/ProgrammersManual.html b/docs/ProgrammersManual.html index d98573e253a..9a09c9bb484 100644 --- a/docs/ProgrammersManual.html +++ b/docs/ProgrammersManual.html @@ -521,7 +521,7 @@ STATISTIC(NumXForms, "The # of times I did stuff");

The STATISTIC macro defines a static variable, whose name is specified by the first argument. The pass name is taken from the DEBUG_TYPE macro, and the description is taken from the second argument. The variable - defined ("NumXForms" in this case) acts like an unsigned int.

+ defined ("NumXForms" in this case) acts like an unsigned integer.

  • Whenever you make a transformation, bump the counter:

    @@ -1278,8 +1278,8 @@ system. For our purposes below, we need three concepts. First, an "Opaque Type" is exactly as defined in the language reference. Second an "Abstract Type" is any type which includes an -opaque type as part of its type graph (for example "{ opaque, int }"). -Third, a concrete type is a type that is not an abstract type (e.g. "{ int, +opaque type as part of its type graph (for example "{ opaque, i32 }"). +Third, a concrete type is a type that is not an abstract type (e.g. "{ i32, float }").

    @@ -1300,7 +1300,7 @@ to be emitted to an output .ll file:
    -%mylist = type { %mylist*, int }
    +%mylist = type { %mylist*, i32 }
     
    @@ -1317,7 +1317,7 @@ Elts.push_back(PointerType::get(StructTy)); Elts.push_back(Type::IntTy); StructType *NewSTy = StructType::get(Elts); -// At this point, NewSTy = "{ opaque*, int }". Tell VMCore that +// At this point, NewSTy = "{ opaque*, i32 }". Tell VMCore that // the struct and the opaque type are actually the same. cast<OpaqueType>(StructTy.get())->refineAbstractTypeTo(NewSTy); @@ -1357,7 +1357,7 @@ existing types, and all duplicates are deleted (to preserve pointer equality).

    In the example above, the OpaqueType object is definitely deleted. -Additionally, if there is an "{ \2*, int}" type already created in the system, +Additionally, if there is an "{ \2*, i32}" type already created in the system, the pointer and struct type created are also deleted. Obviously whenever a type is deleted, any "Type*" pointers in the program are invalidated. As such, it is safest to avoid having any "Type*" pointers to abstract types @@ -1411,8 +1411,8 @@ To support this, a class can derive from the AbstractTypeUser class. This class allows it to get callbacks when certain types are resolved. To register to get callbacks for a particular type, the DerivedType::{add/remove}AbstractTypeUser methods can be called on a type. Note that these methods only work for -abstract types. Concrete types (those that do not include an opaque objects -somewhere) can never be refined. + abstract types. Concrete types (those that do not include any opaque +objects) can never be refined.

    @@ -1647,7 +1647,7 @@ method. In addition, all LLVM values can be named. The "name" of the
    -%foo = add int 1, 2
    +%foo = add i32 1, 2
     
    @@ -1988,11 +1988,11 @@ global is always a pointer to its contents. It is important to remember this when using the GetElementPtrInst instruction because this pointer must be dereferenced first. For example, if you have a GlobalVariable (a subclass of GlobalValue) that is an array of 24 ints, type [24 x -int], then the GlobalVariable is a pointer to that array. Although +i32]
    , then the GlobalVariable is a pointer to that array. Although the address of the first element of this array and the value of the GlobalVariable are the same, they have different types. The -GlobalVariable's type is [24 x int]. The first element's type -is int. Because of this, accessing a global value requires you to +GlobalVariable's type is [24 x i32]. The first element's type +is i32. Because of this, accessing a global value requires you to dereference the pointer with GetElementPtrInst first, then its elements can be accessed. This is explained in the LLVM Language Reference Manual.

    @@ -2429,15 +2429,19 @@ the various types of Constants.

    -

    Type as noted earlier is also a subclass of a Value class. Any primitive -type (like int, short etc) in LLVM is an instance of Type Class. All other -types are instances of subclasses of type like FunctionType, ArrayType -etc. DerivedType is the interface for all such dervied types including -FunctionType, ArrayType, PointerType, StructType. Types can have names. They can -be recursive (StructType). There exists exactly one instance of any type -structure at a time. This allows using pointer equality of Type *s for comparing -types.

    - +

    Type is a superclass of all type classes. Every Value has + a Type. Type cannot be instantiated directly but only + through its subclasses. Certain primitive types (VoidType, + LabelType, FloatType and DoubleType) have hidden + subclasses. They are hidden because they offer no useful functionality beyond + what the Type class offers except to distinguish themselves from + other subclasses of Type.

    +

    All other types are subclasses of DerivedType. Types can be + named, but this is not a requirement. There exists exactly + one instance of a given shape at any one time. This allows type equality to + be performed with address equality of the Type Instance. That is, given two + Type* values, the types are identical if the pointers are identical. +

    @@ -2448,17 +2452,21 @@ types.

      -
    • bool isInteger() const: True for any integer type.
    • +
    • bool isInteger() const: Returns true for any integer type except + a one-bit integer (i1).
    • -
    • bool isIntegral() const: Returns true if this is an integral - type, which is either Bool type or one of the Integer types.
    • +
    • bool isIntegral() const: Returns true for any integer type + including a one-bit integer.
    • bool isFloatingPoint(): Return true if this is one of the two floating point types.
    • -
    • isLosslesslyConvertableTo (const Type *Ty) const: Return true if - this type can be converted to 'Ty' without any reinterpretation of bits. For - example, uint to int or one pointer type to another.
    • +
    • bool isAbstract(): Return true if the type is abstract (contains + an OpaqueType anywhere in its definition).
    • + +
    • bool isSized(): Return true if the type has known size. Things + that don't have a size are abstract types, labels and void.
    • +
    @@ -2468,6 +2476,16 @@ types.

      +
    • IntegerType: Subclass of DerivedType that represents integer types of + any bit width. Any bit width between IntegerType::MIN_INT_BITS (1) + and IntegerType::MAX_INT_BITS (~8 million) can be represented. +
        +
      • static const IntegerType* get(unsigned NumBits): get an integer + type of a specific bit width.
      • +
      • unsigned getBitWidth() const: Get the bit width of an integer + type.
      • +
      +
    • SequentialType : This is subclassed by ArrayType and PointerType
      • const Type * getElementType() const: Returns the type of each @@ -2482,6 +2500,11 @@ types.

    • PointerType : Subclass of SequentialType for pointer types.
    • +
    • PackedType: Subclass of SequentialType for packed (vector) types. A + packed type is similar to an ArrayType but is distinguished because it is + a first class type wherease ArrayType is not. Packed types are used for + vector operations and are usually small vectors of of an integer or floating + point type.
    • StructType : subclass of DerivedTypes for struct types
    • FunctionType : subclass of DerivedTypes for function types.
        @@ -2495,6 +2518,13 @@ types.

        number of formal parameters.
    • +
    • OpaqueType: Sublcass of DerivedType for abstract types. This class + defines no content and is used as a placeholder for some other type. Note + that OpaqueType is used (temporarily) during type resolution for forward + references of types. Once the referenced type is resolved, the OpaqueType + is replaced with the actual type. OpaqueType can also be used for data + abstraction. At link time opaque types can be resolved to actual types + of the same name.