]> git.ipfire.org Git - thirdparty/gcc.git/blame - gcc/d/dmd/target.h
d: Merge upstream dmd 7132b3537
[thirdparty/gcc.git] / gcc / d / dmd / target.h
CommitLineData
b4c522fa
IB
1
2/* Compiler implementation of the D programming language
a3b38b77 3 * Copyright (C) 2013-2021 by The D Language Foundation, All Rights Reserved
b4c522fa
IB
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
9 */
10
11#pragma once
12
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.
16#include "globals.h"
17#include "tokens.h"
18
19class ClassDeclaration;
20class Dsymbol;
21class Expression;
5d4b824f 22class FuncDeclaration;
f9ab59ff 23class Parameter;
b4c522fa 24class Type;
c5e94699 25class TypeFunction;
a1ccbae6 26class TypeTuple;
b4c522fa
IB
27struct OutBuffer;
28
5905cbdb
IB
29struct TargetC
30{
31 unsigned longsize; // size of a C 'long' or 'unsigned long' type
32 unsigned long_doublesize; // size of a C 'long double'
5905cbdb
IB
33};
34
35struct TargetCPP
36{
37 bool reverseOverloads; // with dmc and cl, overloaded functions are grouped and in reverse order
38 bool exceptions; // set if catching C++ exceptions is supported
39 bool twoDtorInVtable; // target C++ ABI puts deleting and non-deleting destructor into vtable
40
41 const char *toMangle(Dsymbol *s);
42 const char *typeInfoMangle(ClassDeclaration *cd);
5d4b824f 43 const char *thunkMangle(FuncDeclaration *fd, int offset);
5905cbdb
IB
44 const char *typeMangle(Type *t);
45 Type *parameterType(Parameter *p);
46 bool fundamentalType(const Type *t, bool& isFundamental);
47};
48
49struct TargetObjC
50{
51 bool supported; // set if compiler can interface with Objective-C
52};
53
b4c522fa
IB
54struct Target
55{
5905cbdb
IB
56 // D ABI
57 unsigned ptrsize;
58 unsigned realsize; // size a real consumes in memory
59 unsigned realpad; // 'padding' added to the CPU real size to bring it up to realsize
60 unsigned realalignsize; // alignment for reals
61 unsigned classinfosize; // size of 'ClassInfo'
62 unsigned long long maxStaticDataSize; // maximum size of static data
63
64 // C ABI
65 TargetC c;
66
67 // C++ ABI
68 TargetCPP cpp;
69
70 // Objective-C ABI
71 TargetObjC objc;
b4c522fa
IB
72
73 template <typename T>
74 struct FPTypeProperties
75 {
5905cbdb
IB
76 real_t max;
77 real_t min_normal;
78 real_t nan;
79 real_t snan;
80 real_t infinity;
81 real_t epsilon;
82
83 d_int64 dig;
84 d_int64 mant_dig;
85 d_int64 max_exp;
86 d_int64 min_exp;
87 d_int64 max_10_exp;
88 d_int64 min_10_exp;
b4c522fa
IB
89 };
90
5905cbdb
IB
91 FPTypeProperties<float> FloatProperties;
92 FPTypeProperties<double> DoubleProperties;
93 FPTypeProperties<real_t> RealProperties;
b4c522fa 94
5905cbdb
IB
95private:
96 Type *tvalist;
97
98public:
99 void _init(const Param& params);
b4c522fa 100 // Type sizes and support.
5905cbdb
IB
101 unsigned alignsize(Type *type);
102 unsigned fieldalign(Type *type);
5905cbdb
IB
103 Type *va_listType(const Loc &loc, Scope *sc); // get type of va_list
104 int isVectorTypeSupported(int sz, Type *type);
105 bool isVectorOpSupported(Type *type, TOK op, Type *t2 = NULL);
b4c522fa 106 // ABI and backend.
5905cbdb
IB
107 LINK systemLinkage();
108 TypeTuple *toArgTypes(Type *t);
c5e94699
IB
109 bool isReturnOnStack(TypeFunction *tf, bool needsThis);
110 Expression *getTargetInfo(const char* name, const Loc& loc);
b4c522fa 111};
5905cbdb
IB
112
113extern Target target;