Skip to content

Commit

Permalink
Merge pull request #2893 from kinke/2.083-final
Browse files Browse the repository at this point in the history
Upgrade to v2.083.0
  • Loading branch information
kinke committed Nov 2, 2018
2 parents bba1eef + 0e00487 commit 3c45ba4
Show file tree
Hide file tree
Showing 8 changed files with 34 additions and 155 deletions.
4 changes: 3 additions & 1 deletion cmake/Modules/FindLLVM.cmake
Original file line number Diff line number Diff line change
Expand Up @@ -28,7 +28,9 @@
# We also want an user-specified LLVM_ROOT_DIR to take precedence over the
# system default locations such as /usr/local/bin. Executing find_program()
# multiples times is the approach recommended in the docs.
set(llvm_config_names llvm-config-6.0 llvm-config60
set(llvm_config_names llvm-config-8.0 llvm-config80
llvm-config-7.0 llvm-config70
llvm-config-6.0 llvm-config60
llvm-config-5.0 llvm-config50
llvm-config-4.0 llvm-config40
llvm-config-3.9 llvm-config39
Expand Down
135 changes: 6 additions & 129 deletions dmd/compiler.d
Original file line number Diff line number Diff line change
Expand Up @@ -30,27 +30,19 @@ import dmd.semantic2;
import dmd.semantic3;
import dmd.tokens;

version (IN_LLVM)
extern (C++) __gshared
{
extern (C++) __gshared:

/// DMD-generated module `__entrypoint` where the C main resides
Module entrypoint = null;
/// Module in which the D main is
Module rootHasMain = null;

bool includeImports = false;
// array of module patterns used to include/exclude imported modules
Array!(const(char)*) includeModulePatterns;
Modules compiledImports;
}
else
{
/// DMD-generated module `__entrypoint` where the C main resides
package __gshared Module entrypoint = null;
/// Module in which the D main is
package __gshared Module rootHasMain = null;

package __gshared bool includeImports = false;
// array of module patterns used to include/exclude imported modules
package __gshared Array!(const(char)*) includeModulePatterns;
}
package __gshared Modules compiledImports;

/**
* A data structure that describes a back-end compiler and implements
Expand Down Expand Up @@ -140,8 +132,6 @@ else
*/
extern (C++) static Expression paintAsType(Expression e, Type type)
{
version (IN_LLVM)
{
union U
{
d_int32 int32value;
Expand Down Expand Up @@ -191,43 +181,6 @@ version (IN_LLVM)
default:
assert(0, "Unsupported target type");
}
}
else
{
// We support up to 512-bit values.
ubyte[64] buffer;
assert(e.type.size() == type.size());
// Write the expression into the buffer.
switch (e.type.ty)
{
case Tint32:
case Tuns32:
case Tint64:
case Tuns64:
encodeInteger(e, buffer.ptr);
break;
case Tfloat32:
case Tfloat64:
encodeReal(e, buffer.ptr);
break;
default:
assert(0);
}
// Interpret the buffer as a new type.
switch (type.ty)
{
case Tint32:
case Tuns32:
case Tint64:
case Tuns64:
return decodeInteger(e.loc, type, buffer.ptr);
case Tfloat32:
case Tfloat64:
return decodeReal(e.loc, type, buffer.ptr);
default:
assert(0);
}
}
}

/******************************
Expand Down Expand Up @@ -263,82 +216,6 @@ else
}
}

/******************************
* Private helpers for Compiler::paintAsType.
*/
// Write the integer value of 'e' into a unsigned byte buffer.
private void encodeInteger(Expression e, ubyte* buffer)
{
dinteger_t value = e.toInteger();
int size = cast(int)e.type.size();
for (int p = 0; p < size; p++)
{
int offset = p; // Would be (size - 1) - p; on BigEndian
buffer[offset] = ((value >> (p * 8)) & 0xFF);
}
}

// Write the bytes encoded in 'buffer' into an integer and returns
// the value as a new IntegerExp.
private Expression decodeInteger(const ref Loc loc, Type type, ubyte* buffer)
{
dinteger_t value = 0;
int size = cast(int)type.size();
for (int p = 0; p < size; p++)
{
int offset = p; // Would be (size - 1) - p; on BigEndian
value |= (cast(dinteger_t)buffer[offset] << (p * 8));
}
return new IntegerExp(loc, value, type);
}

// Write the real_t value of 'e' into a unsigned byte buffer.
private void encodeReal(Expression e, ubyte* buffer)
{
switch (e.type.ty)
{
case Tfloat32:
{
float* p = cast(float*)buffer;
*p = cast(float)e.toReal();
break;
}
case Tfloat64:
{
double* p = cast(double*)buffer;
*p = cast(double)e.toReal();
break;
}
default:
assert(0);
}
}

// Write the bytes encoded in 'buffer' into a real_t and returns
// the value as a new RealExp.
private Expression decodeReal(const ref Loc loc, Type type, ubyte* buffer)
{
real_t value;
switch (type.ty)
{
case Tfloat32:
{
float* p = cast(float*)buffer;
value = real_t(*p);
break;
}
case Tfloat64:
{
double* p = cast(double*)buffer;
value = real_t(*p);
break;
}
default:
assert(0);
}
return new RealExp(loc, value, type);
}

/******************************
* Private helpers for Compiler::onImport.
*/
Expand Down
12 changes: 12 additions & 0 deletions dmd/compiler.h
Original file line number Diff line number Diff line change
Expand Up @@ -10,6 +10,8 @@

#pragma once

#include "root/array.h"

// This file contains a data structure that describes a back-end compiler
// and implements compiler-specific actions.

Expand All @@ -18,6 +20,16 @@ class Module;
class Type;
struct Scope;

// DMD-generated module `__entrypoint` where the C main resides
extern Module *entrypoint;
// Module in which the D main is
extern Module *rootHasMain;

extern bool includeImports;
// array of module patterns used to include/exclude imported modules
extern Array<const char*> includeModulePatterns;
extern Array<Module *> compiledImports;

struct Compiler
{
// CTFE support for cross-compilation.
Expand Down
11 changes: 10 additions & 1 deletion dmd/func.d
Original file line number Diff line number Diff line change
Expand Up @@ -98,8 +98,17 @@ public:
{
DtorExpStatement des;
if (fd.nrvo_can && s.finalbody && (des = s.finalbody.isDtorExpStatement()) !is null &&
fd.nrvo_var == des.var && global.params.useExceptions && ClassDeclaration.throwable)
fd.nrvo_var == des.var)
{
if (!(global.params.useExceptions && ClassDeclaration.throwable))
{
/* Don't need to call destructor at all, since it is nrvo
*/
replaceCurrent(s._body);
s._body.accept(this);
return;
}

/* Normally local variable dtors are called regardless exceptions.
* But for nrvo_var, its dtor should be called only when exception is thrown.
*
Expand Down
15 changes: 0 additions & 15 deletions dmd/root/port.h
Original file line number Diff line number Diff line change
Expand Up @@ -12,24 +12,9 @@
// Portable wrapper around compiler/system specific things.
// The idea is to minimize #ifdef's in the app code.

#ifdef IN_LLVM
#include <stddef.h>
#else
#include <stdlib.h> // for alloca
#endif
#include <stdint.h>

#ifndef IN_LLVM
#if _MSC_VER
#include <alloca.h>
typedef __int64 longlong;
typedef unsigned __int64 ulonglong;
#else
typedef long long longlong;
typedef unsigned long long ulonglong;
#endif
#endif

typedef unsigned char utf8_t;

struct Port
Expand Down
7 changes: 1 addition & 6 deletions driver/codegenerator.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -9,6 +9,7 @@

#include "driver/codegenerator.h"

#include "dmd/compiler.h"
#include "dmd/id.h"
#include "dmd/mars.h"
#include "dmd/module.h"
Expand All @@ -26,12 +27,6 @@
#include "llvm/Support/ToolOutputFile.h"
#include "llvm/Support/YAMLTraits.h"

/// The module with the frontend-generated C main() definition.
extern Module *entrypoint; // defined in dmd/mars.d

/// The module that contains the actual D main() (_Dmain) definition.
extern Module *rootHasMain; // defined in dmd/mars.d

#if LDC_LLVM_VER < 600
namespace llvm {
using ToolOutputFile = tool_output_file;
Expand Down
3 changes: 1 addition & 2 deletions driver/main.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -7,6 +7,7 @@
//
//===----------------------------------------------------------------------===//

#include "dmd/compiler.h"
#include "dmd/cond.h"
#include "dmd/errors.h"
#include "dmd/id.h"
Expand Down Expand Up @@ -83,8 +84,6 @@ int rt_init();
void gendocfile(Module *m);

// In dmd/mars.d
extern bool includeImports;
extern Strings includeModulePatterns;
void generateJson(Modules *modules);

using namespace opts;
Expand Down
2 changes: 1 addition & 1 deletion tests/d2/dmd-testsuite

0 comments on commit 3c45ba4

Please sign in to comment.