dmd.target
Handles target
-specific parameters
Discussion
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 through Target
.
Note: While 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.
License
Source: target.d
Documentation: https://dlang.org/phobos/dmd_target.html
-
Declaration
void
addDefaultVersionIdentifiers
(const ref Paramparams
, const ref Targettgt
);Add default
version
identifier for dmd, and set the target platform in
. https://dlang.org/spec/version.html#predefined-versionsparams
Discussion
Needs to be run after all arguments parsing (command line, DFLAGS environment variable and config file) in order to add final flags (such as
X86_64
or theCRuntime
used).Parameters
Param
params
which target to compile for (set by
setTarget()
)Target
tgt
target
-
Declaration
struct
Target
;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.
Discussion
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.
-
Declaration
enum
OS
: ubyte;Bit decoding of the Target.
OS
-
Declaration
ubyte
ptrsize
;size of a pointer in bytes
-
Declaration
ubyte
realsize
;size a real consumes in memory
-
Declaration
ubyte
realpad
;padding added to the CPU real size to bring it up to realsize
-
Declaration
ubyte
realalignsize
;alignment for reals
-
Declaration
ubyte
classinfosize
;size of
ClassInfo
-
Declaration
ulong
maxStaticDataSize
;maximum size of static data
-
Declaration
TargetC
c
;C ABI
-
Declaration
TargetCPP
cpp
;C++ ABI
-
Declaration
TargetObjC
objc
;Objective-C ABI
-
Declaration
const(char)[]
architectureName
;Architecture name
-
Declaration
const(char)[]
obj_ext
;extension for object files
-
Declaration
const(char)[]
lib_ext
;extension for static library files
-
Declaration
const(char)[]
dll_ext
;extension for dynamic library files
-
Declaration
bool
run_noext
;allow -run sources without extensions
-
Declaration
struct
FPTypeProperties
(T);Values representing all properties for floating point types
-
Declaration
real_t
max
;largest representable value that's not infinity
-
Declaration
real_t
min_normal
;smallest representable normalized value that's not 0
-
Declaration
real_t
nan
;NaN value
-
Declaration
real_t
infinity
;infinity
value -
Declaration
real_t
epsilon
;smallest increment to the value 1
-
Declaration
long
dig
;number of decimal digits of precision
-
Declaration
long
mant_dig
;number of bits in mantissa
-
Declaration
long
max_exp
;maximum int value such that 2 is representable
-
Declaration
long
min_exp
;minimum int value such that 2 is representable as a normalized value
-
Declaration
long
max_10_exp
;maximum int value such that 10
-
Declaration
long
min_10_exp
;minimum int value such that 10 is representable as a normalized value
-
-
Declaration
FPTypeProperties!float
FloatProperties
; -
Declaration
FPTypeProperties!double
DoubleProperties
; -
Declaration
FPTypeProperties!real_t
RealProperties
; -
Declaration
void
_init
(const ref Paramparams
);Initialize the Target
-
Declaration
@safe Target.ObjectFormat
objectFormat
();Determine the object format to be used
-
Declaration
@safe void
setCPU
();Determine the instruction set to be used
-
Declaration
@safe void
deinitialize
();Deinitializes the global state of the compiler.
Discussion
This can be used to restore the state set by
_init
to its original state. -
Declaration
uint
alignsize
(Typetype
);Requested target memory alignment size of the given
type
.Parameters
Type
type
type
to inspectReturn Value
alignment in bytes
-
Declaration
uint
fieldalign
(Typetype
);Requested target field alignment size of the given
type
.Parameters
Type
type
type
to inspectReturn Value
alignment in bytes
-
Declaration
Type
va_listType
(const ref Locloc
, Scope*sc
);Type for the
va_list
type for the target; e.g., required for_argptr
declarations.NOTE: For Posix/x86_64 this returns the type which will really be used for passing an argument of type va_list.
Return Value
Type
that representsva_list
. -
Declaration
@safe int
isVectorTypeSupported
(intsz
, Typetype
);Checks whether the target supports a vector
type
.Parameters
int
sz
vector
type
size in bytesType
type
vector element
type
Return Value
0 vector
type
is supported, 1 vectortype
is not supported on the target at all 2 vector elementtype
is not supported 3 vector size is not supported -
Declaration
bool
isVectorOpSupported
(Typetype
, EXPop
, Typet2
= null);Checks whether the target supports the given operation for vectors.
Parameters
Type
type
target
type
of operationEXP
op
the unary or binary
op
being done on thetype
Type
t2
type
of second operand if
is a binary operationop
Return Value
true
if the operation is supported ortype
is not a vector -
Declaration
@safe LINK
systemLinkage
();Default system linkage for the target.
Return Value
LINK
to use forextern(System)
-
Declaration
TypeTuple
toArgTypes
(Typet
);Describes how an argument type is passed to a function on target.
Parameters
Type
t
type to break down
Return Value
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 -
Declaration
bool
isReturnOnStack
(TypeFunctiontf
, boolneedsThis
);Determine return style of function - whether in registers or through a hidden pointer to the caller's stack.
Parameters
TypeFunction
tf
function type to check
bool
needsThis
true
if the function type is for a non-static member functionReturn Value
true
if return value from function is on the stack -
Declaration
bool
preferPassByRef
(Typet
);Decides whether an
in
parameter of the specified POD type is to be passed by reference or by value. To be used with-preview=in
only!Parameters
Type
t
type of the
in
parameter, must be a PODReturn Value
true
if thein
parameter is to be passed by reference -
Declaration
Expression
getTargetInfo
(const(char)*name
, const ref Locloc
);Get targetInfo by key
Parameters
const(char)*
name
name
of targetInfo to getLoc
loc
location to use for error messages
Return Value
Expression for the requested targetInfo
-
Declaration
@safe bool
isCalleeDestroyingArgs
(TypeFunctiontf
);Parameters
TypeFunction
tf
type of function being called
Return Value
true
if the callee invokes destructors for arguments. -
Declaration
bool
libraryObjectMonitors
(FuncDeclarationfd
, Statementfbody
);Returns
true
if the implementation for object monitors is always defined in the D runtime library (rt/monitor_.d).Parameters
FuncDeclaration
fd
function with
synchronized
storage class.Statement
fbody
entire function body of
fd
Return Value
false
if the target backend handles synchronizing monitors. -
Declaration
const @safe bool
supportsLinkerDirective
();Returns
true
if the target supportspragma(linkerDirective)
.Return Value
false
if the target does not supportpragma(linkerDirective)
. -
Declaration
@safe bool
isXmmSupported
();Return Value
true
if xmm usage is supported -
Declaration
const nothrow @nogc @property scope @safe bool
isPOSIX
();Return Value
true
if generating code for POSIX -
Declaration
@safe uint
stackAlign
();Return Value
alignment of the stack
-
-
Declaration
struct
TargetC
;Functions and variables specific to interfacing with extern(C) ABI.
-
Declaration
bool
crtDestructorsSupported
;Not all platforms support crt_destructor
-
Declaration
ubyte
boolsize
;size of a C
_Bool
type -
Declaration
ubyte
shortsize
;size of a C
short
orunsigned short
type -
Declaration
ubyte
intsize
;size of a C
int
orunsigned int
type -
Declaration
ubyte
longsize
;size of a C
long
orunsigned long
type -
Declaration
ubyte
long_longsize
;size of a C
long long
orunsigned long long
type -
Declaration
ubyte
long_doublesize
;size of a C
long double
-
Declaration
ubyte
wchar_tsize
;size of a C
wchar_t
type -
Declaration
Runtime
runtime
;vendor of the C
runtime
to link against -
Declaration
BitFieldStyle
bitFieldStyle
;different C compilers do it differently
-
-
Declaration
struct
TargetCPP
;Functions and variables specific to interface with extern(C++) ABI.
-
Declaration
bool
reverseOverloads
;set if overloaded functions are grouped and in reverse order (such as in dmc and cl)
-
Declaration
bool
exceptions
;set if catching C++
exceptions
is supported -
Declaration
bool
twoDtorInVtable
;target C++ ABI puts deleting and non-deleting destructor into vtable
-
Declaration
bool
splitVBasetable
;set if C++ ABI uses separate tables for virtual functions and virtual bases
-
Declaration
bool
wrapDtorInExternD
;set if C++ dtors require a D wrapper to be callable from runtime
-
Declaration
Runtime
runtime
;vendor of the C++
runtime
to link against -
Declaration
const(char)*
toMangle
(Dsymbols
);Mangle the given symbol for C++ ABI.
Parameters
Dsymbol
s
declaration with C++ linkage
Return Value
string mangling of symbol
-
Declaration
const(char)*
typeInfoMangle
(ClassDeclarationcd
);Get RTTI mangling of the given class declaration for C++ ABI.
Parameters
ClassDeclaration
cd
class with C++ linkage
Return Value
string mangling of C++ typeinfo
-
Declaration
const(char)*
thunkMangle
(FuncDeclarationfd
, intoffset
);Get mangle name of a this-adjusting thunk to the given function declaration for C++ ABI.
Parameters
FuncDeclaration
fd
function with C++ linkage
int
offset
call
offset
to the vptrReturn Value
string mangling of C++ thunk, or
null
if unhandled -
Declaration
const(char)*
typeMangle
(Typet
);Gets vendor-specific type mangling for C++ ABI.
Parameters
Type
t
type to inspect
Return Value
string if type is mangled specially on target
null
if unhandled -
Declaration
Type
parameterType
(Typet
);Get the type that will really be used for passing the given argument to an
extern(C++)
function, ornull
if unhandled.Parameters
Type
t
type to be passed.
Return Value
Type
to use for type
.t
-
Declaration
bool
fundamentalType
(const Typet
, ref boolisFundamental
);Checks whether type is a vendor-specific fundamental type.
Parameters
Type
t
type to inspect
bool
isFundamental
where to store result
Return Value
true
ifisFundamental
was set by function -
Declaration
uint
derivedClassOffset
(ClassDeclarationbaseClass
);Get the starting offset position for fields of an
extern(C++)
class that is derived from the given base class.Parameters
ClassDeclaration
baseClass
base class with C++ linkage
Return Value
starting offset to lay out derived class fields
-
-
Declaration
struct
TargetObjC
;Functions and variables specific to interface with extern(Objective-C) ABI.
-
Declaration
bool
supported
;set if compiler can interface with Objective-C
-
-
Declaration
Target
target
;