2 /* Compiler implementation of the D programming language
3 * Copyright (C) 2013-2021 by The D Language Foundation, All Rights Reserved
4 * written by Iain Buclaw
5 * http://www.digitalmars.com
6 * Distributed under the Boost Software License, Version 1.0.
7 * http://www.boost.org/LICENSE_1_0.txt
8 * https://github.com/dlang/dmd/blob/master/src/dmd/target.h
13 // This file contains a data structure that describes a back-end target.
14 // At present it is incomplete, but in future it should grow to contain
15 // most or all target machine and target O/S specific information.
19 class ClassDeclaration
;
22 class FuncDeclaration
;
39 avx
, // AVX1 instruction set
40 avx2
, // AVX2 instruction set
41 avx512
, // AVX-512 instruction set
43 // Special values that don't survive past the command line processing
44 baseline
, // (default) the minimum capability CPU
45 native
// the machine the compiler is being run on
50 enum class Runtime
: unsigned char
63 enum class BitFieldStyle
: unsigned char
66 DM
, // Digital Mars 32 bit C compiler
67 MS
, // Microsoft 32 and 64 bit C compilers
68 // https://docs.microsoft.com/en-us/cpp/c-language/c-bit-fields?view=msvc-160
69 // https://docs.microsoft.com/en-us/cpp/cpp/cpp-bit-fields?view=msvc-160
70 Gcc_Clang
, // gcc and clang
73 uint8_t longsize
; // size of a C 'long' or 'unsigned long' type
74 uint8_t long_doublesize
; // size of a C 'long double'
75 uint8_t wchar_tsize
; // size of a C 'wchar_t' type
77 BitFieldStyle bitFieldStyle
; // different C compilers do it differently
82 enum class Runtime
: unsigned char
91 bool reverseOverloads
; // with dmc and cl, overloaded functions are grouped and in reverse order
92 bool exceptions
; // set if catching C++ exceptions is supported
93 bool twoDtorInVtable
; // target C++ ABI puts deleting and non-deleting destructor into vtable
94 bool wrapDtorInExternD
; // set if C++ dtors require a D wrapper to be callable from runtime
97 const char *toMangle(Dsymbol
*s
);
98 const char *typeInfoMangle(ClassDeclaration
*cd
);
99 const char *thunkMangle(FuncDeclaration
*fd
, int offset
);
100 const char *typeMangle(Type
*t
);
101 Type
*parameterType(Parameter
*p
);
102 bool fundamentalType(const Type
*t
, bool& isFundamental
);
103 unsigned derivedClassOffset(ClassDeclaration
*baseClass
);
108 bool supported
; // set if compiler can interface with Objective-C
113 typedef unsigned char OS
;
116 /* These are mutually exclusive; one and only one is set.
117 * Match spelling and casing of corresponding version identifiers
126 OS_DragonFlyBSD
= 0x40,
129 all
= OS_linux
| OS_Windows
| OS_OSX
| OS_OpenBSD
| OS_FreeBSD
| OS_Solaris
| OS_DragonFlyBSD
,
130 Posix
= OS_linux
| OS_OSX
| OS_OpenBSD
| OS_FreeBSD
| OS_Solaris
| OS_DragonFlyBSD
,
137 uint8_t realsize
; // size a real consumes in memory
138 uint8_t realpad
; // 'padding' added to the CPU real size to bring it up to realsize
139 uint8_t realalignsize
; // alignment for reals
140 uint8_t classinfosize
; // size of 'ClassInfo'
141 uint64_t maxStaticDataSize
; // maximum size of static data
152 DString architectureName
; // name of the platform architecture (e.g. X86_64)
153 CPU cpu
; // CPU instruction set to target
154 bool is64bit
; // generate 64 bit code for x86_64; true by default for 64 bit dmd
155 bool isLP64
; // pointers are 64 bits
158 DString obj_ext
; /// extension for object files
159 DString lib_ext
; /// extension for static library files
160 DString dll_ext
; /// extension for dynamic library files
161 bool run_noext
; /// allow -run sources without extensions
162 bool mscoff
; /// for Win32: write COFF object files instead of OMF
164 template <typename T
>
165 struct FPTypeProperties
181 FPTypeProperties
<float> FloatProperties
;
182 FPTypeProperties
<double> DoubleProperties
;
183 FPTypeProperties
<real_t
> RealProperties
;
190 void _init(const Param
& params
);
191 // Type sizes and support.
192 void setTriple(const char* _triple
);
193 unsigned alignsize(Type
*type
);
194 unsigned fieldalign(Type
*type
);
195 Type
*va_listType(const Loc
&loc
, Scope
*sc
); // get type of va_list
196 int isVectorTypeSupported(int sz
, Type
*type
);
197 bool isVectorOpSupported(Type
*type
, unsigned op
, Type
*t2
= NULL
);
199 LINK
systemLinkage();
200 TypeTuple
*toArgTypes(Type
*t
);
201 bool isReturnOnStack(TypeFunction
*tf
, bool needsThis
);
202 d_uns64
parameterSize(const Loc
& loc
, Type
*t
);
203 bool preferPassByRef(Type
*t
);
204 Expression
*getTargetInfo(const char* name
, const Loc
& loc
);
205 bool isCalleeDestroyingArgs(TypeFunction
* tf
);
206 bool libraryObjectMonitors(FuncDeclaration
*fd
, Statement
*fbody
);
207 void addPredefinedGlobalIdentifiers() const;
210 extern Target target
;