Home | History | Annotate | Line # | Download | only in dmd
target.h revision 1.1
      1 
      2 /* Compiler implementation of the D programming language
      3  * Copyright (C) 2013-2019 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
      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 
     19 class ClassDeclaration;
     20 class Dsymbol;
     21 class Expression;
     22 class Parameter;
     23 class Type;
     24 struct OutBuffer;
     25 
     26 struct Target
     27 {
     28     static int ptrsize;
     29     static int realsize;             // size a real consumes in memory
     30     static int realpad;              // 'padding' added to the CPU real size to bring it up to realsize
     31     static int realalignsize;        // alignment for reals
     32     static bool reverseCppOverloads; // with dmc and cl, overloaded functions are grouped and in reverse order
     33     static bool cppExceptions;       // set if catching C++ exceptions is supported
     34     static int c_longsize;           // size of a C 'long' or 'unsigned long' type
     35     static int c_long_doublesize;    // size of a C 'long double'
     36     static int classinfosize;        // size of 'ClassInfo'
     37     static unsigned long long maxStaticDataSize;  // maximum size of static data
     38 
     39     template <typename T>
     40     struct FPTypeProperties
     41     {
     42         static real_t max;
     43         static real_t min_normal;
     44         static real_t nan;
     45         static real_t snan;
     46         static real_t infinity;
     47         static real_t epsilon;
     48 
     49         static d_int64 dig;
     50         static d_int64 mant_dig;
     51         static d_int64 max_exp;
     52         static d_int64 min_exp;
     53         static d_int64 max_10_exp;
     54         static d_int64 min_10_exp;
     55     };
     56 
     57     typedef FPTypeProperties<float> FloatProperties;
     58     typedef FPTypeProperties<double> DoubleProperties;
     59     typedef FPTypeProperties<real_t> RealProperties;
     60 
     61     static void _init();
     62     // Type sizes and support.
     63     static unsigned alignsize(Type* type);
     64     static unsigned fieldalign(Type* type);
     65     static unsigned critsecsize();
     66     static Type *va_listType();  // get type of va_list
     67     static int isVectorTypeSupported(int sz, Type *type);
     68     static bool isVectorOpSupported(Type *type, TOK op, Type *t2 = NULL);
     69     // ABI and backend.
     70     static const char *toCppMangle(Dsymbol *s);
     71     static const char *cppTypeInfoMangle(ClassDeclaration *cd);
     72     static const char *cppTypeMangle(Type *t);
     73     static Type *cppParameterType(Parameter *p);
     74     static bool cppFundamentalType(const Type *t, bool& isFundamental);
     75     static LINK systemLinkage();
     76 };
     77