clang 22.0.0git
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()

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

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

Referenced by appendType(), and getTypeString().

◆ appendBuiltinType()

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

Appends built-in types to Enc.

Definition at line 473 of file XCore.cpp.

References clang::BuiltinType::getKind().

Referenced by appendType().

◆ appendEnumType()

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

References clang::EnumDecl::getDefinition().

Referenced by appendType().

◆ appendFunctionType()

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

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

Referenced by appendType().

◆ appendPointerType()

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

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

Referenced by appendType().

◆ appendQualifier()

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

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

Referenced by appendArrayType(), and appendType().

◆ appendRecordType()

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

References extractFieldType(), and clang::RecordDecl::field_empty().

Referenced by appendType().

◆ appendType()

◆ extractFieldType()

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

References appendType(), and clang::RecordDecl::fields().

Referenced by appendRecordType().

◆ getTypeString()

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

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