Skip to content
Projects
Groups
Snippets
Help
This project
Loading...
Sign in / Register
Toggle navigation
T
tic
Overview
Overview
Details
Activity
Cycle Analytics
Repository
Repository
Files
Commits
Branches
Tags
Contributors
Graph
Compare
Charts
Issues
0
Issues
0
List
Board
Labels
Milestones
Merge Requests
0
Merge Requests
0
CI / CD
CI / CD
Pipelines
Jobs
Schedules
Charts
Wiki
Wiki
Snippets
Snippets
Members
Members
Collapse sidebar
Close sidebar
Activity
Graph
Charts
Create a new issue
Jobs
Commits
Issue Boards
Open sidebar
wenyuanbo
tic
Commits
eaf0fde3
Commit
eaf0fde3
authored
Jun 17, 2017
by
Tianqi Chen
Committed by
GitHub
Jun 17, 2017
Browse files
Options
Browse Files
Download
Email Patches
Plain Diff
[LLVM] More optimized option, allow emit assembly (#187)
parent
54450614
Hide whitespace changes
Inline
Side-by-side
Showing
3 changed files
with
29 additions
and
0 deletions
+29
-0
src/codegen/llvm/llvm_common.cc
+20
-0
src/codegen/llvm/llvm_module.cc
+7
-0
tests/python/unittest/test_codegen_cross_llvm.py
+2
-0
No files found.
src/codegen/llvm/llvm_common.cc
View file @
eaf0fde3
...
...
@@ -46,6 +46,7 @@ GetLLVMTargetMachine(const std::string& target_str) {
std
::
string
target_triple
=
""
;
std
::
string
cpu
=
"generic"
;
std
::
string
attr
=
""
;
bool
soft_float_abi
=
false
;
std
::
string
key
,
value
;
if
(
target_str
.
length
()
>
5
)
{
std
::
istringstream
is
(
target_str
.
substr
(
5
,
target_str
.
length
()
-
5
));
...
...
@@ -67,6 +68,14 @@ GetLLVMTargetMachine(const std::string& target_str) {
cpu
=
value
;
}
else
if
(
key
==
"-mattr"
)
{
attr
=
value
;
}
else
if
(
key
==
"-mfloat-abi"
)
{
if
(
value
==
"hard"
)
{
soft_float_abi
=
false
;
}
else
if
(
value
==
"soft"
)
{
soft_float_abi
=
true
;
}
else
{
LOG
(
FATAL
)
<<
"invalid -mfloat-abi option "
<<
value
;
}
}
else
{
LOG
(
FATAL
)
<<
"unknown option "
<<
key
;
}
...
...
@@ -80,7 +89,18 @@ GetLLVMTargetMachine(const std::string& target_str) {
const
llvm
::
Target
*
target
=
llvm
::
TargetRegistry
::
lookupTarget
(
target_triple
,
err
);
CHECK
(
target
)
<<
err
<<
" target_triple="
<<
target_triple
;
// set target option
llvm
::
TargetOptions
opt
;
opt
.
LessPreciseFPMADOption
=
true
;
opt
.
AllowFPOpFusion
=
llvm
::
FPOpFusion
::
Fast
;
opt
.
UnsafeFPMath
=
true
;
opt
.
NoInfsFPMath
=
true
;
opt
.
NoNaNsFPMath
=
true
;
if
(
soft_float_abi
)
{
opt
.
FloatABIType
=
llvm
::
FloatABI
::
Soft
;
}
else
{
opt
.
FloatABIType
=
llvm
::
FloatABI
::
Hard
;
}
auto
rmodel
=
llvm
::
Reloc
::
PIC_
;
llvm
::
TargetMachine
*
tm
=
target
->
createTargetMachine
(
target_triple
,
cpu
,
attr
,
opt
,
rmodel
);
...
...
src/codegen/llvm/llvm_module.cc
View file @
eaf0fde3
...
...
@@ -66,6 +66,13 @@ class LLVMModuleNode final : public runtime::ModuleNode {
pass
,
dest
,
llvm
::
TargetMachine
::
CGFT_ObjectFile
)
==
0
)
<<
"Cannot emit target CGFT_ObjectFile"
;
pass
.
run
(
*
mptr_
);
}
else
if
(
fmt
==
"s"
||
fmt
==
"asm"
)
{
llvm
::
legacy
::
PassManager
pass
;
CHECK
(
tm_
);
CHECK
(
tm_
->
addPassesToEmitFile
(
pass
,
dest
,
llvm
::
TargetMachine
::
CGFT_AssemblyFile
)
==
0
)
<<
"Cannot emit target CGFT_AssemblyFile"
;
pass
.
run
(
*
mptr_
);
}
else
if
(
fmt
==
"ll"
)
{
mptr_
->
print
(
dest
,
nullptr
);
}
else
if
(
fmt
==
"bc"
)
{
...
...
tests/python/unittest/test_codegen_cross_llvm.py
View file @
eaf0fde3
...
...
@@ -45,6 +45,8 @@ def test_llvm_add_pipeline():
path
=
temp
.
relpath
(
"myadd.o"
)
f
.
save
(
path
)
verify_elf
(
path
,
0x28
)
asm_path
=
temp
.
relpath
(
"myadd.asm"
)
f
.
save
(
asm_path
)
# Do a RPC verification, launch kernel on Arm Board if available.
host
=
os
.
environ
.
get
(
'TVM_RPC_ARM_HOST'
,
None
)
remote
=
None
...
...
Write
Preview
Markdown
is supported
0%
Try again
or
attach a new file
Attach a file
Cancel
You are about to add
0
people
to the discussion. Proceed with caution.
Finish editing this message first!
Cancel
Please
register
or
sign in
to comment