Skip to content
This repository has been archived by the owner on Apr 23, 2020. It is now read-only.
Permalink

Comparing changes

Choose two branches to see what’s changed or to start a new pull request. If you need to, you can also or learn more about diff comparisons.

Open a pull request

Create a new pull request by comparing changes across two branches. If you need to, you can also . Learn more about diff comparisons here.
base repository: llvm-mirror/dragonegg
Failed to load repositories. Confirm that selected base ref is valid, then try again.
Loading
base: master
Choose a base ref
...
head repository: LLVM-China/dragonegg
Failed to load repositories. Confirm that selected head ref is valid, then try again.
Loading
compare: gcc-8-branch
Choose a head ref
Able to merge. These branches can be automatically merged.
  • 2 commits
  • 33 files changed
  • 1 contributor

Commits on Sep 5, 2017

  1. Copy the full SHA
    80334cb View commit details

Commits on Sep 6, 2017

  1. Copy the full SHA
    6b3ec63 View commit details
4 changes: 4 additions & 0 deletions .gitignore
Original file line number Diff line number Diff line change
@@ -21,6 +21,10 @@
# In-tree build files
*.d
*.o
*.sh
*.s
*.gcc
*.out

#==============================================================================#
# Explicit files to ignore (only matches one).
29 changes: 19 additions & 10 deletions Makefile
Original file line number Diff line number Diff line change
@@ -42,7 +42,10 @@ else
COMMON_FLAGS+=-fvisibility=hidden
endif
CFLAGS+=$(COMMON_FLAGS) $(shell $(LLVM_CONFIG) --cflags)
CXXFLAGS+=$(COMMON_FLAGS) $(shell $(LLVM_CONFIG) --cxxflags)
LLVM_CXXFLAGS=$(shell $(LLVM_CONFIG) --cxxflags)
LLVM_CXXFLAGS_Wcwd=$(subst -Wcovered-switch-default, -Wno-switch-default, $(LLVM_CXXFLAGS))
LLVM_CXXFLAGS_Wsc=$(subst -Wstring-conversion, , $(LLVM_CXXFLAGS_Wcwd))
CXXFLAGS+=$(COMMON_FLAGS) $(LLVM_CXXFLAGS_Wsc)

ifeq ($(shell uname),Darwin)
LOADABLE_MODULE_OPTIONS=-bundle -undefined dynamic_lookup
@@ -54,13 +57,13 @@ endif
endif

GCC_PLUGIN_DIR=$(shell $(GCC) -print-file-name=plugin)
GCC_VERSION=$(shell $(GCC) -dumpversion).0
GCC_MAJOR=$(word 1, $(subst ., ,$(GCC_VERSION)))
GCC_MINOR=$(word 2, $(subst ., ,$(GCC_VERSION)))
GCC_MICRO=$(word 3, $(subst ., ,$(GCC_VERSION)))
GCC_VERSION_STRING=$(shell $(GCC) -dumpversion).0
GCC_MAJOR=$(word 1, $(subst ., ,$(GCC_VERSION_STRING)))
GCC_MINOR=$(word 2, $(subst ., ,$(GCC_VERSION_STRING)))
GCC_MICRO=$(word 3, $(subst ., ,$(GCC_VERSION_STRING)))
TARGET_TRIPLE=$(shell $(GCC) -dumpmachine)

LLVM_VERSION=$(shell $(LLVM_CONFIG) --version)
LLVM_VERSION_STRING=$(shell $(LLVM_CONFIG) --version)

PLUGIN=dragonegg.so
PLUGIN_OBJECTS=Aliasing.o Backend.o Cache.o ConstantConversion.o Convert.o \
@@ -77,7 +80,7 @@ ALL_OBJECTS=$(PLUGIN_OBJECTS) $(TARGET_OBJECT) $(TARGET_UTIL_OBJECTS)
CPP_OPTIONS+=$(CPPFLAGS) $(shell $(LLVM_CONFIG) --cppflags) \
-fno-rtti \
-MD -MP \
-DIN_GCC -DLLVM_VERSION=\"$(LLVM_VERSION)\" \
-DIN_GCC -DLLVM_VERSION_STRING=\"$(LLVM_VERSION_STRING)\" \
-DTARGET_TRIPLE=\"$(TARGET_TRIPLE)\" \
-DGCC_MAJOR=$(GCC_MAJOR) -DGCC_MINOR=$(GCC_MINOR) \
-DGCC_MICRO=$(GCC_MICRO) \
@@ -94,6 +97,10 @@ ifneq ($(GCC_MINOR), 5)
endif
endif

ifdef DRAGONEGG_DEBUG
CPP_OPTIONS+=-DDRAGONEGG_DEBUG -g
endif

LD_OPTIONS+=$(shell $(LLVM_CONFIG) --ldflags) $(LDFLAGS)

LLVM_COMPONENTS=ipo scalaropts target
@@ -133,7 +140,7 @@ $(TARGET_UTIL_OBJECTS): %.o : $(TOP_DIR)/utils/%.cpp
$(TARGET_UTIL): $(TARGET_UTIL_OBJECTS)
@echo Linking $@
$(QUIET)$(CXX) -o $@ $^ \
$(shell $(LLVM_CONFIG) --libs support --system-libs) \
$(shell $(LLVM_CONFIG) --libs support) \
$(LD_OPTIONS)

%.o : $(SRC_DIR)/%.cpp $(TARGET_UTIL)
@@ -149,7 +156,7 @@ $(PLUGIN): $(PLUGIN_OBJECTS) $(TARGET_OBJECT) $(TARGET_UTIL)
@echo Linking $@
$(QUIET)$(CXX) -o $@ $(LOADABLE_MODULE_OPTIONS) $(CXXFLAGS) \
$(PLUGIN_OBJECTS) $(TARGET_OBJECT) \
$(shell $(LLVM_CONFIG) --libs $(LLVM_COMPONENTS) --system-libs \
$(shell $(LLVM_CONFIG) --libs $(LLVM_COMPONENTS) \
$(shell $(TARGET_UTIL) -p)) \
$(LD_OPTIONS)

@@ -191,7 +198,9 @@ clean:
# The following target exists for the benefit of the dragonegg maintainers, and
# is not used in a normal build. You need to specify the path to the GCC build
# directory in GCC_BUILD_DIR.
GENGTYPE_INPUT=$(SRC_DIR)/Cache.cpp
# FIXME: gengtype does not support macro https://gcc.gnu.org/ml/gcc/2017-07/msg00061.html
# You have to comment #if (GCC_MAJOR == XXX) not feet your GCC version.
GENGTYPE_INPUT=$(SRC_DIR)/Cache$(GCC_MAJOR).cpp
GENGTYPE_OUTPUT=$(INCLUDE_DIR)/dragonegg/gt-cache-$(GCC_MAJOR).$(GCC_MINOR).inc
.PHONY: gt-cache.inc
gt-cache.inc:
17 changes: 9 additions & 8 deletions README
Original file line number Diff line number Diff line change
@@ -5,20 +5,21 @@
Prerequisites
-------------

The dragonegg plugin works with gcc 4.5, 4.6, 4.7 or 4.8, so you will need to
have one of these installed. Many linux distributions ship one or both of them,
perhaps as an addon package; binaries can be downloaded for most platforms.
Otherwise you can always build gcc yourself. Plugin support (--enable-plugin)
needs to be enabled in gcc, but since it is enabled by default on most platforms
you usually won't need to do this explicitly.
The dragonegg plugin works with gcc 4.5, 4.6, 4.7 or 4.8, 6.3, 6.4, 8.x so you
will need to have one of these installed. Many linux distributions ship one or
both of them, perhaps as an addon package; binaries can be downloaded for most
platforms. Otherwise you can always build gcc (such as GCC v8.x)yourself.
Plugin support (--enable-plugin) needs to be enabled in gcc, but since it is
enabled by default on most platforms you usually won't need to do this explicitly.

Step 0: Build and install llvm
------------------------------

I'm assuming anyone reading this knows how to build and install llvm. The
I'm assuming anyone reading this knows how to build and install llvm. The
version of llvm must match the version of the plugin, so if you are building
dragonegg-3.0 then you should use llvm-3.0, while if you are building the
development version of dragonegg then use the development version of llvm.
development version of dragonegg then use the development version of llvm (such
as LLVM v4.x, v5.x and v6.x).


Step 1: Build the plugin
18 changes: 9 additions & 9 deletions include/arm/dragonegg/Target.h
Original file line number Diff line number Diff line change
@@ -31,8 +31,8 @@
(isVoid || hasArgList). */

/* from TARGET_AAPCS_BASED */
#define DEFAULT_TARGET_AAPCS_BASED(ARM_DEFAULT_ABI != ARM_ABI_APCS && \
ARM_DEFAULT_ABI != ARM_ABI_ATPCS)
#define DEFAULT_TARGET_AAPCS_BASED ARM_DEFAULT_ABI != ARM_ABI_APCS && \
ARM_DEFAULT_ABI != ARM_ABI_ATPCS

#define TARGET_ADJUST_LLVM_CC(CC, type) \
{ \
@@ -51,43 +51,43 @@
#ifdef DRAGONEGG_ABI_H

extern bool llvm_arm_should_pass_aggregate_in_mixed_regs(
tree_node *, Type *Ty, CallingConv::ID, std::vector<Type *> &);
tree_node *, llvm::Type *Ty, llvm::CallingConv::ID, std::vector<llvm::Type *> &);

#define LLVM_SHOULD_PASS_AGGREGATE_IN_MIXED_REGS(T, TY, CC, E) \
llvm_arm_should_pass_aggregate_in_mixed_regs((T), (TY), (CC), (E))

struct DefaultABIClient;
extern bool llvm_arm_try_pass_aggregate_custom(
tree_node *, std::vector<Type *> &, CallingConv::ID CC,
tree_node *, std::vector<llvm::Type *> &, llvm::CallingConv::ID CC,
struct DefaultABIClient *);

#define LLVM_TRY_PASS_AGGREGATE_CUSTOM(T, E, CC, C) \
llvm_arm_try_pass_aggregate_custom((T), (E), (CC), (C))

extern bool llvm_arm_aggregate_partially_passed_in_regs(
std::vector<Type *> &, std::vector<Type *> &, CallingConv::ID CC);
std::vector<llvm::Type *> &, std::vector<llvm::Type *> &, llvm::CallingConv::ID CC);

#define LLVM_AGGREGATE_PARTIALLY_PASSED_IN_REGS(E, SE, ISR, CC) \
llvm_arm_aggregate_partially_passed_in_regs((E), (SE), (CC))

extern Type *
llvm_arm_aggr_type_for_struct_return(tree_node *type, CallingConv::ID CC);
extern llvm::Type *
llvm_arm_aggr_type_for_struct_return(tree_node *type, llvm::CallingConv::ID CC);

/* LLVM_AGGR_TYPE_FOR_STRUCT_RETURN - Return LLVM Type if X can be
returned as an aggregate, otherwise return NULL. */
#define LLVM_AGGR_TYPE_FOR_STRUCT_RETURN(X, CC) \
llvm_arm_aggr_type_for_struct_return((X), (CC))

extern void llvm_arm_extract_multiple_return_value(
Value *Src, Value *Dest, bool isVolatile, LLVMBuilder &B);
llvm::Value *Src, llvm::Value *Dest, bool isVolatile, LLVMBuilder &B);

/* LLVM_EXTRACT_MULTIPLE_RETURN_VALUE - Extract multiple return value from
SRC and assign it to DEST. */
#define LLVM_EXTRACT_MULTIPLE_RETURN_VALUE(Src, Dest, V, B) \
llvm_arm_extract_multiple_return_value((Src), (Dest), (V), (B))

extern bool llvm_arm_should_pass_or_return_aggregate_in_regs(
tree_node *TreeType, CallingConv::ID CC);
tree_node *TreeType, llvm::CallingConv::ID CC);

/* LLVM_SHOULD_NOT_USE_SHADOW_RETURN = Return true is the given type should
not be returned via a shadow parameter with the given calling conventions. */
20 changes: 13 additions & 7 deletions include/dragonegg/ABI.h
Original file line number Diff line number Diff line change
@@ -142,20 +142,26 @@ getLLVMScalarTypeForStructReturn(tree_node *type, unsigned *Offset) {
llvm::Type *Ty = ConvertType(type);
uint64_t Size = getDataLayout().getTypeAllocSize(Ty);
*Offset = 0;
llvm::LLVMContext &Context =
#if LLVM_VERSION_CODE > LLVM_VERSION(3, 8)
Ty->getContext();
#else
llvm::getGlobalContext();
#endif
if (Size == 0)
return llvm::Type::getVoidTy(llvm::getGlobalContext());
return llvm::Type::getVoidTy(Context);
else if (Size == 1)
return llvm::Type::getInt8Ty(llvm::getGlobalContext());
return llvm::Type::getInt8Ty(Context);
else if (Size == 2)
return llvm::Type::getInt16Ty(llvm::getGlobalContext());
return llvm::Type::getInt16Ty(Context);
else if (Size <= 4)
return llvm::Type::getInt32Ty(llvm::getGlobalContext());
return llvm::Type::getInt32Ty(Context);
else if (Size <= 8)
return llvm::Type::getInt64Ty(llvm::getGlobalContext());
return llvm::Type::getInt64Ty(Context);
else if (Size <= 16)
return llvm::IntegerType::get(llvm::getGlobalContext(), 128);
return llvm::IntegerType::get(Context, 128);
else if (Size <= 32)
return llvm::IntegerType::get(llvm::getGlobalContext(), 256);
return llvm::IntegerType::get(Context, 256);

return NULL;
}
Loading