clang 19.0.0git
Functions
XCore.cpp File Reference
#include "ABIInfoImpl.h"
#include "TargetInfo.h"

Go to the source code of this file.

Functions

static bool getTypeString (SmallStringEnc &Enc, const Decl *D, const CodeGen::CodeGenModule &CGM, TypeStringCache &TSC)
 The XCore ABI includes a type information section that communicates symbol type information to the linker.
 
static bool appendType (SmallStringEnc &Enc, QualType QType, const CodeGen::CodeGenModule &CGM, TypeStringCache &TSC)
 Handles the type's qualifier before dispatching a call to handle specific type encodings.
 
static bool extractFieldType (SmallVectorImpl< FieldEncoding > &FE, const RecordDecl *RD, const CodeGen::CodeGenModule &CGM, TypeStringCache &TSC)
 Helper function for appendRecordType().
 
static bool appendRecordType (SmallStringEnc &Enc, const RecordType *RT, const CodeGen::CodeGenModule &CGM, TypeStringCache &TSC, const IdentifierInfo *ID)
 Appends structure and union types to Enc and adds encoding to cache.
 
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)
 Appends type's qualifier to Enc.
 
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)
 Appends a function encoding to Enc, calling appendType for the return type and the arguments.
 

Function Documentation

◆ appendArrayType()

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 542 of file XCore.cpp.

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

Referenced by appendType(), and getTypeString().

◆ appendBuiltinType()

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

Appends built-in types to Enc.

Definition at line 472 of file XCore.cpp.

References clang::BuiltinType::getKind().

Referenced by appendType().

◆ appendEnumType()

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 414 of file XCore.cpp.

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

Referenced by appendType().

◆ appendFunctionType()

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 564 of file XCore.cpp.

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

Referenced by appendType().

◆ appendPointerType()

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 531 of file XCore.cpp.

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

Referenced by appendType().

◆ appendQualifier()

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 458 of file XCore.cpp.

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

Referenced by appendArrayType(), and appendType().

◆ appendRecordType()

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 362 of file XCore.cpp.

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

Referenced by appendType().

◆ appendType()

static bool appendType ( SmallStringEnc &  Enc,
QualType  QType,
const CodeGen::CodeGenModule CGM,
TypeStringCache &  TSC 
)
static

◆ extractFieldType()

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 334 of file XCore.cpp.

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

Referenced by appendRecordType().

◆ getTypeString()

static bool getTypeString ( SmallStringEnc &  Enc,
const Decl D,
const 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 632 of file XCore.cpp.

References appendArrayType(), appendType(), clang::CLanguageLinkage, and clang::Type::getAsArrayTypeUnsafe().