aboutsummaryrefslogtreecommitdiffstats
path: root/lib
diff options
context:
space:
mode:
authorSverker Eriksson <[email protected]>2017-04-11 14:48:55 +0200
committerGitHub <[email protected]>2017-04-11 14:48:55 +0200
commitf6e1e5615f7c9e0e887762738c400d779e211a2e (patch)
treecdc0d305be1458a0e5bd2631bb9c9f094508ad57 /lib
parenta7307600a2b8dbcf628ae8ccf26137bc32f060cc (diff)
parentd9a6b8d2f761f6c16fd0772b65a3c4b6169f3b64 (diff)
downloadotp-f6e1e5615f7c9e0e887762738c400d779e211a2e.tar.gz
otp-f6e1e5615f7c9e0e887762738c400d779e211a2e.tar.bz2
otp-f6e1e5615f7c9e0e887762738c400d779e211a2e.zip
Merge PR-1397 from margnus1/hipe-m32-build OTP-14330
Allow HiPE-enabled VMs to be built with --enable-m32-build
Diffstat (limited to 'lib')
-rw-r--r--lib/hipe/llvm/Makefile3
-rw-r--r--lib/hipe/llvm/hipe_llvm_main.erl17
2 files changed, 17 insertions, 3 deletions
diff --git a/lib/hipe/llvm/Makefile b/lib/hipe/llvm/Makefile
index 88016a7d8b..e8d9a0e8bb 100644
--- a/lib/hipe/llvm/Makefile
+++ b/lib/hipe/llvm/Makefile
@@ -73,8 +73,7 @@ include ../native.mk
ERL_COMPILE_FLAGS += -Werror +inline +warn_export_vars #+warn_missing_spec
# if in 32 bit backend define BIT32 symbol
-ARCH = $(shell echo $(TARGET) | sed 's/^\(x86_64\)-.*/64bit/')
-ifneq ($(ARCH), 64bit)
+ifneq ($(BITS64),yes)
ERL_COMPILE_FLAGS += -DBIT32
endif
diff --git a/lib/hipe/llvm/hipe_llvm_main.erl b/lib/hipe/llvm/hipe_llvm_main.erl
index 0957dd4df2..4eec0c752b 100644
--- a/lib/hipe/llvm/hipe_llvm_main.erl
+++ b/lib/hipe/llvm/hipe_llvm_main.erl
@@ -108,8 +108,10 @@ llvm_llc(Dir, Filename, Ver, Options) ->
OptLevel = trans_optlev_flag(llc, Options),
VerFlags = llc_ver_flags(Ver),
Align = find_stack_alignment(),
+ Target = llc_target_opt(),
LlcFlags = [OptLevel, "-code-model=medium", "-stack-alignment=" ++ Align
, "-tailcallopt", "-filetype=asm" %FIXME
+ , Target
| VerFlags],
Command = "llc " ++ fix_opts(LlcFlags) ++ " " ++ Source,
%% io:format("LLC: ~s~n", [Command]),
@@ -123,7 +125,8 @@ llvm_llc(Dir, Filename, Ver, Options) ->
compile(Dir, Fun_Name, Compiler) ->
Source = Dir ++ Fun_Name ++ ".s",
Dest = Dir ++ Fun_Name ++ ".o",
- Command = Compiler ++ " -c " ++ Source ++ " -o " ++ Dest,
+ Target = compiler_target_opt(),
+ Command = Compiler ++ " " ++ Target ++ " -c " ++ Source ++ " -o " ++ Dest,
%% io:format("~s: ~s~n", [Compiler, Command]),
case os:cmd(Command) of
"" -> ok;
@@ -137,6 +140,18 @@ find_stack_alignment() ->
_ -> exit({?MODULE, find_stack_alignment, "Unimplemented architecture"})
end.
+llc_target_opt() ->
+ case get(hipe_target_arch) of
+ x86 -> "-march=x86";
+ amd64 -> "-march=x86-64"
+ end.
+
+compiler_target_opt() ->
+ case get(hipe_target_arch) of
+ x86 -> "-m32";
+ amd64 -> "-m64"
+ end.
+
%% @doc Join options.
fix_opts(Opts) ->
string:join(Opts, " ").