clang API Documentation

Functions
CodeGen/TargetInfo.cpp File Reference
#include "TargetInfo.h"
#include "ABIInfo.h"
#include "CGCXXABI.h"
#include "CGValue.h"
#include "CodeGenFunction.h"
#include "clang/AST/RecordLayout.h"
#include "clang/CodeGen/CGFunctionInfo.h"
#include "clang/Frontend/CodeGenOptions.h"
#include "llvm/ADT/Triple.h"
#include "llvm/IR/DataLayout.h"
#include "llvm/IR/Type.h"
#include "llvm/Support/raw_ostream.h"
#include <algorithm>
Include dependency graph for CodeGen/TargetInfo.cpp:

Go to the source code of this file.

Functions

static void AssignToArrayRange (CodeGen::CGBuilderTy &Builder, llvm::Value *Array, llvm::Value *Value, unsigned FirstIndex, unsigned LastIndex)
static bool isAggregateTypeForABI (QualType T)
static CGCXXABI::RecordArgABI getRecordArgABI (const RecordType *RT, CGCXXABI &CXXABI)
static CGCXXABI::RecordArgABI getRecordArgABI (QualType T, CGCXXABI &CXXABI)
static QualType useFirstFieldIfTransparentUnion (QualType Ty)
static bool isEmptyRecord (ASTContext &Context, QualType T, bool AllowArrays)
static bool isEmptyField (ASTContext &Context, const FieldDecl *FD, bool AllowArrays)
static const TypeisSingleElementStruct (QualType T, ASTContext &Context)
static bool is32Or64BitBasicType (QualType Ty, ASTContext &Context)
static bool canExpandIndirectArgument (QualType Ty, ASTContext &Context)
static void rewriteInputConstraintReferences (unsigned FirstIn, unsigned NumNewOuts, std::string &AsmString)
static bool isSSEVectorType (ASTContext &Context, QualType Ty)
static bool isRecordWithSSEVectorType (ASTContext &Context, QualType Ty)
static bool isArgInAlloca (const ABIArgInfo &Info)
static bool BitsContainNoUserData (QualType Ty, unsigned StartBit, unsigned EndBit, ASTContext &Context)
static bool ContainsFloatAtOffset (llvm::Type *IRType, unsigned IROffset, const llvm::DataLayout &TD)
static llvm::Type * GetX86_64ByValArgumentPair (llvm::Type *Lo, llvm::Type *Hi, const llvm::DataLayout &TD)
static llvm::ValueEmitVAArgFromMemory (llvm::Value *VAListAddr, QualType Ty, CodeGenFunction &CGF)
static bool PPC64_initDwarfEHRegSizeTable (CodeGen::CodeGenFunction &CGF, llvm::Value *Address)
static bool isIntegerLikeType (QualType Ty, ASTContext &Context, llvm::LLVMContext &VMContext)
static bool getTypeString (SmallStringEnc &Enc, const Decl *D, CodeGen::CodeGenModule &CGM, TypeStringCache &TSC)
static bool appendType (SmallStringEnc &Enc, QualType QType, const CodeGen::CodeGenModule &CGM, TypeStringCache &TSC)
static bool extractFieldType (SmallVectorImpl< FieldEncoding > &FE, const RecordDecl *RD, const CodeGen::CodeGenModule &CGM, TypeStringCache &TSC)
static bool appendRecordType (SmallStringEnc &Enc, const RecordType *RT, const CodeGen::CodeGenModule &CGM, TypeStringCache &TSC, const IdentifierInfo *ID)
static bool appendEnumType (SmallStringEnc &Enc, const EnumType *ET, TypeStringCache &TSC, const IdentifierInfo *ID)
 Appends enum types to Enc and adds the encoding to the cache.
static void appendQualifier (SmallStringEnc &Enc, QualType QT)
static bool appendBuiltinType (SmallStringEnc &Enc, const BuiltinType *BT)
 Appends built-in types to Enc.
static bool appendPointerType (SmallStringEnc &Enc, const PointerType *PT, const CodeGen::CodeGenModule &CGM, TypeStringCache &TSC)
 Appends a pointer encoding to Enc before calling appendType for the pointee.
static bool appendArrayType (SmallStringEnc &Enc, QualType QT, const ArrayType *AT, const CodeGen::CodeGenModule &CGM, TypeStringCache &TSC, StringRef NoSizeEnc)
 Appends array encoding to Enc before calling appendType for the element.
static bool appendFunctionType (SmallStringEnc &Enc, const FunctionType *FT, const CodeGen::CodeGenModule &CGM, TypeStringCache &TSC)

Function Documentation

static bool appendArrayType ( SmallStringEnc &  Enc,
QualType  QT,
const ArrayType AT,
const CodeGen::CodeGenModule CGM,
TypeStringCache &  TSC,
StringRef  NoSizeEnc 
) [static]

Appends array encoding to Enc before calling appendType for the element.

Definition at line 6983 of file CodeGen/TargetInfo.cpp.

References appendQualifier(), appendType(), clang::ArrayType::getElementType(), clang::ArrayType::getSizeModifier(), and clang::ArrayType::Normal.

Referenced by appendType(), and getTypeString().

static bool appendBuiltinType ( SmallStringEnc &  Enc,
const BuiltinType BT 
) [static]

Appends built-in types to Enc.

Definition at line 6913 of file CodeGen/TargetInfo.cpp.

References clang::BuiltinType::getKind().

Referenced by appendType().

static bool appendEnumType ( SmallStringEnc &  Enc,
const EnumType ET,
TypeStringCache &  TSC,
const IdentifierInfo ID 
) [static]

Appends enum types to Enc and adds the encoding to the cache.

Definition at line 6855 of file CodeGen/TargetInfo.cpp.

References clang::EnumType::getDecl(), clang::EnumDecl::getDefinition(), and clang::IdentifierInfo::getName().

Referenced by appendType().

static bool appendFunctionType ( SmallStringEnc &  Enc,
const FunctionType FT,
const CodeGen::CodeGenModule CGM,
TypeStringCache &  TSC 
) [static]

Appends a function encoding to Enc, calling appendType for the return type and the arguments.

Definition at line 7005 of file CodeGen/TargetInfo.cpp.

References appendType(), clang::Type::getAs(), and clang::FunctionType::getReturnType().

Referenced by appendType().

static bool appendPointerType ( SmallStringEnc &  Enc,
const PointerType PT,
const CodeGen::CodeGenModule CGM,
TypeStringCache &  TSC 
) [static]

Appends a pointer encoding to Enc before calling appendType for the pointee.

Definition at line 6972 of file CodeGen/TargetInfo.cpp.

References appendType(), and clang::PointerType::getPointeeType().

Referenced by appendType().

static void appendQualifier ( SmallStringEnc &  Enc,
QualType  QT 
) [static]

Appends type's qualifier to Enc. This is done prior to appending the type's encoding.

Definition at line 6899 of file CodeGen/TargetInfo.cpp.

References clang::QualType::isConstQualified(), clang::QualType::isRestrictQualified(), and clang::QualType::isVolatileQualified().

Referenced by appendArrayType(), and appendType().

static bool appendRecordType ( SmallStringEnc &  Enc,
const RecordType RT,
const CodeGen::CodeGenModule CGM,
TypeStringCache &  TSC,
const IdentifierInfo ID 
) [static]

Appends structure and union types to Enc and adds encoding to cache. Recursively calls appendType (via extractFieldType) for each field. Union types have their fields ordered according to the ABI.

Definition at line 6803 of file CodeGen/TargetInfo.cpp.

References extractFieldType(), clang::RecordType::getDecl(), clang::RecordDecl::getDefinition(), clang::IdentifierInfo::getName(), and clang::Type::isUnionType().

Referenced by appendType().

static bool appendType ( SmallStringEnc &  Enc,
QualType  QType,
const CodeGen::CodeGenModule CGM,
TypeStringCache &  TSC 
) [static]
static void AssignToArrayRange ( CodeGen::CGBuilderTy Builder,
llvm::Value Array,
llvm::Value Value,
unsigned  FirstIndex,
unsigned  LastIndex 
) [static]

Definition at line 33 of file CodeGen/TargetInfo.cpp.

Referenced by PPC64_initDwarfEHRegSizeTable().

static bool BitsContainNoUserData ( QualType  Ty,
unsigned  StartBit,
unsigned  EndBit,
ASTContext Context 
) [static]

BitsContainNoUserData - Return true if the specified [start,end) bit range is known to either be off the end of the specified type or being in alignment padding. The user type specified is known to be at most 128 bits in size, and have passed through X86_64ABIInfo::classify with a successful classification that put one of the two halves in the INTEGER class.

It is conservatively correct to return false.

Definition at line 2178 of file CodeGen/TargetInfo.cpp.

References Context, clang::Type::getAs(), clang::ASTContext::getAsConstantArrayType(), clang::ASTContext::getASTRecordLayout(), clang::ASTRecordLayout::getBaseClassOffset(), clang::RecordType::getDecl(), clang::ASTRecordLayout::getFieldOffset(), clang::ASTContext::getTypeSize(), and clang::ASTContext::toBits().

static bool canExpandIndirectArgument ( QualType  Ty,
ASTContext Context 
) [static]

canExpandIndirectArgument - Test whether an argument type which is to be passed indirectly (on the stack) would have the equivalent layout if it was expanded into separate arguments. If so, we prefer to do the latter to avoid inhibiting optimizations.

Definition at line 332 of file CodeGen/TargetInfo.cpp.

References Context, clang::Type::getAs(), clang::RecordType::getDecl(), clang::ASTContext::getTypeSize(), is32Or64BitBasicType(), and clang::TagDecl::isStruct().

static bool ContainsFloatAtOffset ( llvm::Type *  IRType,
unsigned  IROffset,
const llvm::DataLayout &  TD 
) [static]

ContainsFloatAtOffset - Return true if the specified LLVM IR type has a float member at the specified offset. For example, {int,{float}} has a float at offset 4. It is conservatively correct for this routine to return false.

Definition at line 2259 of file CodeGen/TargetInfo.cpp.

static llvm::Value* EmitVAArgFromMemory ( llvm::Value VAListAddr,
QualType  Ty,
CodeGenFunction CGF 
) [static]
static bool extractFieldType ( SmallVectorImpl< FieldEncoding > &  FE,
const RecordDecl RD,
const CodeGen::CodeGenModule CGM,
TypeStringCache &  TSC 
) [static]

Helper function for appendRecordType(). Builds a SmallVector containing the encoded field types in declaration order.

Definition at line 6773 of file CodeGen/TargetInfo.cpp.

References appendType(), and clang::CodeGen::CodeGenModule::getContext().

Referenced by appendRecordType().

static CGCXXABI::RecordArgABI getRecordArgABI ( const RecordType RT,
CGCXXABI CXXABI 
) [static]
static CGCXXABI::RecordArgABI getRecordArgABI ( QualType  T,
CGCXXABI CXXABI 
) [static]
static bool getTypeString ( SmallStringEnc &  Enc,
const Decl D,
CodeGen::CodeGenModule CGM,
TypeStringCache &  TSC 
) [static]

The XCore ABI includes a type information section that communicates symbol type information to the linker. The linker uses this information to verify safety/correctness of things such as array bound and pointers et al. The ABI only requires C (and XC) language modules to emit TypeStrings. This type information (TypeString) is emitted into meta data for all global symbols: definitions, declarations, functions & variables.

The TypeString carries type, qualifier, name, size & value details. Please see 'Tools Development Guide' section 2.16.2 for format details: <https://www.xmos.com/download/public/Tools-Development-Guide%28X9114A%29.pdf> The output is tested by test/CodeGen/xcore-stringtype.c.

Definition at line 7073 of file CodeGen/TargetInfo.cpp.

References appendArrayType(), appendType(), clang::CLanguageLinkage, clang::Type::getAsArrayTypeUnsafe(), clang::FunctionDecl::getLanguageLinkage(), and clang::ValueDecl::getType().

static llvm::Type* GetX86_64ByValArgumentPair ( llvm::Type *  Lo,
llvm::Type *  Hi,
const llvm::DataLayout &  TD 
) [static]

GetX86_64ByValArgumentPair - Given a high and low type that can ideally be used as elements of a two register pair to pass or return, return a first class aggregate to represent them. For example, if the low part of a by-value argument should be passed as i32* and the high part as float, return {i32*, float}.

Definition at line 2391 of file CodeGen/TargetInfo.cpp.

References NULL.

static bool is32Or64BitBasicType ( QualType  Ty,
ASTContext Context 
) [static]
static bool isAggregateTypeForABI ( QualType  T) [static]
static bool isArgInAlloca ( const ABIArgInfo Info) [static]
static bool isEmptyField ( ASTContext Context,
const FieldDecl FD,
bool  AllowArrays 
) [static]

isEmptyField - Return true iff a the field is "empty", that is it is an unnamed bit-field or an (array of) empty record(s).

Definition at line 179 of file CodeGen/TargetInfo.cpp.

References clang::Type::getAs(), clang::ASTContext::getAsConstantArrayType(), clang::RecordType::getDecl(), clang::ValueDecl::getType(), isEmptyRecord(), and clang::FieldDecl::isUnnamedBitfield().

Referenced by isEmptyRecord(), and isSingleElementStruct().

static bool isEmptyRecord ( ASTContext Context,
QualType  T,
bool  AllowArrays 
) [static]

isEmptyRecord - Return true iff a structure contains only empty fields. Note that a structure with a flexible array member is not considered empty.

Definition at line 212 of file CodeGen/TargetInfo.cpp.

References clang::Type::getAs(), clang::RecordType::getDecl(), clang::RecordDecl::hasFlexibleArrayMember(), and isEmptyField().

Referenced by isEmptyField(), clang::ABIInfo::isHomogeneousAggregate(), and isSingleElementStruct().

static bool isIntegerLikeType ( QualType  Ty,
ASTContext Context,
llvm::LLVMContext &  VMContext 
) [static]
static bool isRecordWithSSEVectorType ( ASTContext Context,
QualType  Ty 
) [static]
static const Type* isSingleElementStruct ( QualType  T,
ASTContext Context 
) [static]

isSingleElementStruct - Determine if a structure is a "single element struct", i.e. it has exactly one non-empty field or exactly one field which is itself a single element struct. Structures with flexible array members are never considered single element structs.

Returns:
The field declaration for the single non-empty field, if it exists.

Definition at line 240 of file CodeGen/TargetInfo.cpp.

References Context, clang::ASTContext::getAsConstantArrayType(), clang::Type::getAsStructureType(), clang::RecordType::getDecl(), clang::QualType::getTypePtr(), clang::ASTContext::getTypeSize(), clang::RecordDecl::hasFlexibleArrayMember(), isAggregateTypeForABI(), isEmptyField(), and isEmptyRecord().

static bool isSSEVectorType ( ASTContext Context,
QualType  Ty 
) [static]
static bool PPC64_initDwarfEHRegSizeTable ( CodeGen::CodeGenFunction CGF,
llvm::Value Address 
) [static]
static void rewriteInputConstraintReferences ( unsigned  FirstIn,
unsigned  NumNewOuts,
std::string &  AsmString 
) [static]

Rewrite input constraint references after adding some output constraints. In the case where there is one output and one input and we add one output, we need to replace all operand references greater than or equal to 1: mov $0, $1 mov eax, $1 The result will be: mov $0, $2 mov eax, $2

Definition at line 680 of file CodeGen/TargetInfo.cpp.

Pass transparent unions as if they were the type of the first element. Sema should ensure that all elements of the union have the same "machine type".

Definition at line 70 of file CodeGen/TargetInfo.cpp.

References clang::Type::getAsUnionType(), and clang::Decl::hasAttr().