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