Movatterモバイル変換


[0]ホーム

URL:


D Logo
Menu
Search

Library Reference

version 2.112.0

overview

Report a bug
If you spot a problem with this page, click here to create a Bugzilla issue.
Improve this page
Quickly fork, edit online, and submit a pull request for this page.Requires a signed-in GitHub account. This works well for small changes.If you'd like to make larger changes you may want to consider usinga local clone.

dmd.target

Handles target-specific parameters
In order to allow for cross compilation, when the compiler produces a binary for a different platform than it is running on, target information needs to be abstracted. This is done in this module, primarily throughTarget.

NoteWhile DMD itself does not support cross-compilation, GDC and LDC do. Hence, this module is (sometimes heavily) modified by them, and contributors should review how their changes affect them.

See Also:
Authors:
Walter Bright
License:
Boost License 1.0

Sourcetarget.d

Documentationhttps://dlang.org/phobos/dmd_target.html

Coveragehttps://codecov.io/gh/dlang/dmd/src/master/compiler/src/dmd/target.d

voidaddDefaultVersionIdentifiers(ref const Paramparams, ref const Targettgt);
Add defaultversion identifier for dmd, and set the target platform inparams.https://dlang.org/spec/version.html#predefined-versions
Needs to be run after all arguments parsing (command line, DFLAGS environment variable and config file) in order to add final flags (such asX86_64 or theCRuntime used).
Parameters:
Paramparamswhich target to compile for (set bysetTarget())
Targettgttarget
structTarget;
Describes a back-end target. At present it is incomplete, but in the future it should grow to contain most or all target machine and target O/S specific information.
In many cases, calls to sizeof() can't be used directly for getting data type sizes since cross compiling is supported and would end up using the host sizes rather than the target sizes.
enumOS: ubyte;
Bit decoding of the Target.OS
ubyteptrsize;
size of a pointer in bytes
ubyterealsize;
size a real consumes in memory
ubyterealpad;
padding added to the CPU real size to bring it up to realsize
ubyterealalignsize;
alignment for reals
ubyteclassinfosize;
size ofClassInfo
ulongmaxStaticDataSize;
maximum size of static data
TargetCc;
C ABI
TargetCPPcpp;
C++ ABI
TargetObjCobjc;
Objective-C ABI
const(char)[]architectureName;
Architecture name
const(char)[]obj_ext;
extension for object files
const(char)[]lib_ext;
extension for static library files
const(char)[]dll_ext;
extension for dynamic library files
boolrun_noext;
allow -run sources without extensions
structFPTypeProperties(T);
Values representing all properties for floating point types
real_tmax;
largest representable value that's not infinity
real_tmin_normal;
smallest representable normalized value that's not 0
real_tnan;
NaN value
real_tinfinity;
infinity value
real_tepsilon;
smallest increment to the value 1
longdig;
number of decimal digits of precision
longmant_dig;
number of bits in mantissa
longmax_exp;
maximum int value such that 2max_exp-1 is representable
longmin_exp;
minimum int value such that 2min_exp-1 is representable as a normalized value
longmax_10_exp;
maximum int value such that 10max_10_exp is representable
longmin_10_exp;
minimum int value such that 10min_10_exp is representable as a normalized value
FPTypeProperties!floatFloatProperties;
FPTypeProperties!doubleDoubleProperties;
FPTypeProperties!real_tRealProperties;
void_init(ref const Paramparams);
Initialize the Target
@safe Target.ObjectFormatobjectFormat() const;
Determine the object format to be used
@safe voidsetCPU();
Determine the instruction set to be used
@safe voiddeinitialize();
Deinitializes the global state of the compiler.
This can be used to restore the state set by_init to its original state.
uintalignsize(Typetype);
Requested target memory alignment size of the given type.
Parameters:
Typetypetype to inspect
Returns:
alignment in bytes
uintfieldalign(Typetype);
Requested target field alignment size of the given type.
Parameters:
Typetypetype to inspect
Returns:
alignment in bytes
Typeva_listType(Locloc, Scope*sc);
Type for theva_list type for the target; e.g., required for_argptr declarations.

NOTEFor Posix/x86_64 this returns the type which will really be used for passing an argument of type va_list.

Returns:
Type that representsva_list.
@safe intisVectorTypeSupported(intsz, Typetype);
Checks whether the target supports a vector type.
Parameters:
intszvector type size in bytes
Typetypevector element type
Returns:
0 vector type is supported, 1 vector type is not supported on the target at all 2 vector element type is not supported 3 vector size is not supported
boolisVectorOpSupported(Typetype, EXPop, Typet2 = null);
Checks whether the target supports the given operation for vectors.
Parameters:
Typetypetarget type of operation
EXPopthe unary or binary op being done on thetype
Typet2type of second operand ifop is a binary operation
Returns:
true if the operation is supported or type is not a vector
@safe LINKsystemLinkage();
Default system linkage for the target.
Returns:
LINK to use forextern(System)
TypeTupletoArgTypes(Typet);
Describes how an argument type is passed to a function on target.
Parameters:
Typettype to break down
Returns:
tuple of types if type is passed in one or more registers empty tuple if type is always passed on the stack null if the type is avoid or argtypes aren't supported by the target
boolisReturnOnStack(TypeFunctiontf, boolneedsThis);
Determine return style of function - whether in registers or through a hidden pointer to the caller's stack.
Parameters:
TypeFunctiontffunction type to check
boolneedsThistrue if the function type is for a non-static member function
Returns:
true if return value from function is on the stack
boolpreferPassByRef(Typet);
Decides whether anin parameter of the specified POD type is to be passed by reference or by value. To be used with-preview=in only!
Parameters:
Typettype of thein parameter, must be a POD
Returns:
true if thein parameter is to be passed by reference
ExpressiongetTargetInfo(const(char)*name, Locloc);
Get targetInfo by key
Parameters:
const(char)*namename of targetInfo to get
Locloclocation to use for error messages
Returns:
Expression for the requested targetInfo
@safe boolisCalleeDestroyingArgs(TypeFunctiontf);
Parameters:
TypeFunctiontftype of function being called
Returns:
true if the callee invokes destructors for arguments.
boollibraryObjectMonitors(FuncDeclarationfd, Statementfbody);
Returns true if the implementation for object monitors is always defined in the D runtime library (rt/monitor_.d).
Parameters:
FuncDeclarationfdfunction withsynchronized storage class.
Statementfbodyentire function body offd
Returns:
false if the target backend handles synchronizing monitors.
@safe boolsupportsLinkerDirective() const;
Returns true if the target supportspragma(linkerDirective).
Returns:
false if the target does not supportpragma(linkerDirective).
@safe boolisXmmSupported();
Returns:
true if xmm usage is supported
nothrow @nogc @property @safe boolisPOSIX() const scope;
Returns:
true if generating code for POSIX
@safe uintstackAlign();
Returns:
alignment of the stack
structTargetC;
Functions and variables specific to interfacing with extern(C) ABI.
boolcrtDestructorsSupported;
Not all platforms support crt_destructor
ubyteboolsize;
size of a C_Bool type
ubyteshortsize;
size of a Cshort orunsigned short type
ubyteintsize;
size of a Cint orunsigned int type
ubytelongsize;
size of a Clong orunsigned long type
ubytelong_longsize;
size of a Clong long orunsigned long long type
ubytelong_doublesize;
size of a Clong double
ubytewchar_tsize;
size of a Cwchar_t type
Runtimeruntime;
vendor of the C runtime to link against
BitFieldStylebitFieldStyle;
different C compilers do it differently
boolcontributesToAggregateAlignment(BitFieldDeclarationbfd);
Indicates whether the specified bitfield contributes to the alignment of the containing aggregate. E.g., (not all) ARM ABIs do NOT ignore anonymous (incl. 0-length) bitfields.
structTargetCPP;
Functions and variables specific to interface with extern(C++) ABI.
boolreverseOverloads;
set if overloaded functions are grouped and in reverse order (such as in dmc and cl)
boolexceptions;
set if catching C++ exceptions is supported
booltwoDtorInVtable;
target C++ ABI puts deleting and non-deleting destructor into vtable
boolsplitVBasetable;
set if C++ ABI uses separate tables for virtual functions and virtual bases
boolwrapDtorInExternD;
set if C++ dtors require a D wrapper to be callable from runtime
Runtimeruntime;
vendor of the C++ runtime to link against
const(char)*toMangle(Dsymbols);
Mangle the given symbol for C++ ABI.
Parameters:
Dsymbolsdeclaration with C++ linkage
Returns:
string mangling of symbol
const(char)*typeInfoMangle(ClassDeclarationcd);
Get RTTI mangling of the given class declaration for C++ ABI.
Parameters:
ClassDeclarationcdclass with C++ linkage
Returns:
string mangling of C++ typeinfo
const(char)*thunkMangle(FuncDeclarationfd, intoffset);
Get mangle name of a this-adjusting thunk to the given function declaration for C++ ABI.
Parameters:
FuncDeclarationfdfunction with C++ linkage
intoffsetcall offset to the vptr
Returns:
string mangling of C++ thunk, or null if unhandled
const(char)*typeMangle(Typet);
Gets vendor-specific type mangling for C++ ABI.
Parameters:
Typettype to inspect
Returns:
string if type is mangled specially on target null if unhandled
TypeparameterType(Typet);
Get the type that will really be used for passing the given argument to anextern(C++) function, ornull if unhandled.
Parameters:
Typettype to be passed.
Returns:
Type to use for typet.
boolfundamentalType(const Typet, ref boolisFundamental);
Checks whether type is a vendor-specific fundamental type.
Parameters:
Typettype to inspect
boolisFundamentalwhere to store result
Returns:
true if isFundamental was set by function
uintderivedClassOffset(ClassDeclarationbaseClass);
Get the starting offset position for fields of anextern(C++) class that is derived from the given base class.
Parameters:
ClassDeclarationbaseClassbase class with C++ linkage
Returns:
starting offset to lay out derived class fields
structTargetObjC;
Functions and variables specific to interface with extern(Objective-C) ABI.
boolsupported;
set if compiler can interface with Objective-C
Targettarget;
Copyright © 1999-2026 by theD Language Foundation | Page generated byDdoc on Fri Feb 20 11:33:48 2026

[8]ページ先頭

©2009-2026 Movatter.jp