File: target.h

package info (click to toggle)
ldc 1:1.12.0-1
  • links: PTS, VCS
  • area: main
  • in suites: buster, sid
  • size: 80,880 kB
  • sloc: ansic: 123,899; cpp: 84,038; sh: 1,402; makefile: 1,083; asm: 919; objc: 65; exp: 30; python: 22
file content (95 lines) | stat: -rw-r--r-- 3,336 bytes parent folder | download
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95

/* Compiler implementation of the D programming language
 * Copyright (C) 2013-2018 by The D Language Foundation, All Rights Reserved
 * written by Iain Buclaw
 * http://www.digitalmars.com
 * Distributed under the Boost Software License, Version 1.0.
 * http://www.boost.org/LICENSE_1_0.txt
 * https://github.com/dlang/dmd/blob/master/src/target.h
 */

#ifndef TARGET_H
#define TARGET_H

// This file contains a data structure that describes a back-end target.
// At present it is incomplete, but in future it should grow to contain
// most or all target machine and target O/S specific information.
#include "globals.h"
#include "tokens.h"

class ClassDeclaration;
class Dsymbol;
class Expression;
class Parameter;
class Type;
class TypeFunction;
class TypeTuple;
class Module;
struct OutBuffer;

struct Target
{
    // D ABI
    static unsigned ptrsize;
    static unsigned realsize;           // size a real consumes in memory
    static unsigned realpad;            // 'padding' added to the CPU real size to bring it up to realsize
    static unsigned realalignsize;      // alignment for reals
    static unsigned classinfosize;      // size of 'ClassInfo'
    static unsigned long long maxStaticDataSize;  // maximum size of static data

    // C ABI
    static unsigned c_longsize;         // size of a C 'long' or 'unsigned long' type
    static unsigned c_long_doublesize;  // size of a C 'long double'

    // C++ ABI
    static bool reverseCppOverloads;    // with dmc and cl, overloaded functions are grouped and in reverse order
    static bool cppExceptions;          // set if catching C++ exceptions is supported
    static bool twoDtorInVtable;        // target C++ ABI puts deleting and non-deleting destructor into vtable

    template <typename T>
    struct FPTypeProperties
    {
        static real_t max;
        static real_t min_normal;
        static real_t nan;
        static real_t snan;
        static real_t infinity;
        static real_t epsilon;

        static d_int64 dig;
        static d_int64 mant_dig;
        static d_int64 max_exp;
        static d_int64 min_exp;
        static d_int64 max_10_exp;
        static d_int64 min_10_exp;

        static void _init();
    };

    typedef FPTypeProperties<float> FloatProperties;
    typedef FPTypeProperties<double> DoubleProperties;
    typedef FPTypeProperties<real_t> RealProperties;

    static void _init();
    // Type sizes and support.
    static unsigned alignsize(Type *type);
    static unsigned fieldalign(Type *type);
    static unsigned critsecsize();
    static Type *va_listType();  // get type of va_list
    static int isVectorTypeSupported(int sz, Type *type);
    static bool isVectorOpSupported(Type *type, TOK op, Type *t2 = NULL);
    // CTFE support for cross-compilation.
    static Expression *paintAsType(Expression *e, Type *type);
    // ABI and backend.
    static void loadModule(Module *m);
    static const char *toCppMangle(Dsymbol *s);
    static const char *cppTypeInfoMangle(ClassDeclaration *cd);
    static const char *cppTypeMangle(Type *t);
    static Type *cppParameterType(Parameter *p);
    static LINK systemLinkage();
    static TypeTuple *toArgTypes(Type *t);
    static bool isReturnOnStack(TypeFunction *tf, bool needsThis);
    static d_uns64 parameterSize(const Loc& loc, Type *t);
};

#endif