llvm::FunctionComparator::cmpTypes

cmpType - compares two types, defines total ordering among the types set.

Synopsis

Declared in <llvm/Transforms/Utils/FunctionComparator.h>

int
cmpTypes(
    Type* TyL,
    Type* TyR) const;

Description

Return values: 0 if types are equal, -1 if Left is less than Right, +1 if Left is greater than Right.

Description: Comparison is broken onto stages. Like in lexicographical comparison stage coming first has higher priority. On each explanation stage keep in mind total ordering properties.

0. Before comparison we coerce pointer types of 0 address space to integer. We also don't bother with same type at left and right, so just return 0 in this case.

1. If types are of different kind (different type IDs). Return result of type IDs comparison, treating them as numbers. 2. If types are integers, check that they have the same width. If they are vectors, check that they have the same count and subtype. 3. Types have the same ID, so check whether they are one of: * Void * Float * Double * X86_FP80 * FP128 * PPC_FP128 * Label * Metadata We can treat these types as equal whenever their IDs are same. 4. If Left and Right are pointers, return result of address space comparison (numbers comparison). We can treat pointer types of same address space as equal. 5. If types are complex. Then both Left and Right are to be expanded and their element types will be checked with the same way. If we get Res != 0 on some stage, return it. Otherwise return 0. 6. For all other cases put llvm_unreachable.

Return Value

Negative if TyL is less than TyR, zero if equal, positive if greater.

Parameters

NameDescription
TyLLeft-hand type.
TyRRight-hand type.