Skip to content

Commit

Permalink
arcv: Update expect scripts of dejagnu for ARC-V
Browse files Browse the repository at this point in the history
Update expect scripts of dejagnu to define compiler and nSIM ARC-V options.

Signed-off-by: Evgeny Semenov <[email protected]>
  • Loading branch information
qwersem committed Apr 2, 2024
1 parent 8e1ca51 commit bb27387
Show file tree
Hide file tree
Showing 5 changed files with 70 additions and 46 deletions.
4 changes: 3 additions & 1 deletion README.md
Original file line number Diff line number Diff line change
Expand Up @@ -315,7 +315,9 @@ Prefixes which start with `arc-` correspond to little endian toolchains. Prefixe
### Using nSIM simulator to run bare metal ARC applications

nSIM simulator supports GNU IO hostlink used by the libc library of bare metal
GNU toolchain for ARC. nSIM option `nsim_emt=1` enables GNU IO hostlink.
GNU toolchain for ARC. nSIM option `nsim_emt=1` enables GNU IO hostlink. nSIM
simulator also supports semihosting, which is essential for ARC-V targets, more
details can be found in nSIM documentation.

To start nSIM in gdbserver mode for ARC EM6:

Expand Down
28 changes: 16 additions & 12 deletions dejagnu/arc-common.exp
Original file line number Diff line number Diff line change
Expand Up @@ -49,18 +49,22 @@ proc arc_get_cflags {} {

# Use cflags instead ldflags because lto tests of ld testsuite ignore
# ldflags
if { ![info exists env(ARC_HOSTLINK_LIBRARY)] } {
if [board_info $board exists arc,hostlink] {
if { [board_info $board arc,hostlink] == "nsim" } {
lappend cflags --specs=nsim.specs
} elseif { [board_info $board arc,hostlink] == "metaware" } {
lappend cflags --specs=hl.specs
} else {
lappend cflags --specs=nosys.specs
}
} else {
lappend cflags --specs=nosys.specs
}
if {![info exists env(ARC_HOSTLINK_LIBRARY)]} {
if {[board_info $board exists arc,hostlink]} {
if {[board_info $board arc,hostlink] == "nsim"} {
lappend cflags --specs=nsim.specs
} elseif {[board_info $board arc,hostlink] == "metaware"} {
lappend cflags --specs=hl.specs
} elseif {[board_info $board arc,hostlink] == "semihost"} {
lappend cflags --specs=semihost.specs --specs=arcv.specs \
-mabi=ilp32 -march=rv32im_zba_zbb_zbs_zca_zcb_zcmp_zicsr \
-T arcv.ld
} else {
lappend cflags --specs=nosys.specs
}
} else {
lappend cflags --specs=nosys.specs
}
}

# GCC generates improper DWARF info when frame-pointer is involved - all
Expand Down
34 changes: 18 additions & 16 deletions dejagnu/baseboards/arc-nsim.exp
Original file line number Diff line number Diff line change
Expand Up @@ -100,25 +100,27 @@ if { $tool == "libstdc++" } {
}

# Check if nsim_download_elf_sections option is required - whether nSIM version
# is > 2015.06. If revision.txt doesn't exist - this is a private verification
# build of nSIM, so assume that this is the latest version.
# is > 2015.06 and a target is not ARC-V. If revision.txt doesn't exist - this
# is a private verification build of nSIM, so assume that this is the latest
# version.
set nsim_version_path "$::env(NSIM_HOME)/revision.txt"
if [file exists $nsim_version_path] {
set nsim_version_fid [open $nsim_version_path r]
set nsim_version_text [read $nsim_version_fid]
close $nsim_version_fid
regexp "Version\\s+: (\\d+)\.(\\d+)" $nsim_version_text -> \
nsim_version_year nsim_version_month
if { $nsim_version_year > 2015 || \
($nsim_version_year == 2015 && $nsim_version_month > 6) } {
# Avoid performance penalty of useless initialization of heap and stack
# sections.
lappend nsim_flags "-on nsim_download_elf_sections"
if {![check_target_arcv]} {
if {[file exists $nsim_version_path]} {
set nsim_version_fid [open $nsim_version_path r]
set nsim_version_text [read $nsim_version_fid]
close $nsim_version_fid
regexp "Version\\s+: (\\d+)\.(\\d+)" $nsim_version_text -> \
nsim_version_year nsim_version_month
if {$nsim_version_year > 2015 || \
($nsim_version_year == 2015 && $nsim_version_month > 6)} {
# Avoid performance penalty of useless initialization of heap and
# stack sections.
lappend nsim_flags "-on nsim_download_elf_sections"
}
} else {
lappend nsim_flags "-on nsim_download_elf_sections"
}
} else {
lappend nsim_flags "-on nsim_download_elf_sections"
}

set_board_info nsim_flags [join $nsim_flags]

# nSIM is an exclusive resource -- only one client can connect at a time.
Expand Down
45 changes: 28 additions & 17 deletions dejagnu/baseboards/arc-sim-nsimdrv.exp
Original file line number Diff line number Diff line change
Expand Up @@ -80,23 +80,26 @@ if { $tool == "libstdc++" } {
}

# Check if nsim_download_elf_sections option is required - whether nSIM version
# is > 2015.06. If revision.txt doesn't exist - this is a private verification
# build of nSIM, so assume that this is the latest version.
# is > 2015.06 and a target is not ARC-V. If revision.txt doesn't exist - this
# is a private verification build of nSIM, so assume that this is the latest
# version.
set nsim_version_path "$::env(NSIM_HOME)/revision.txt"
if [file exists $nsim_version_path] {
set nsim_version_fid [open $nsim_version_path r]
set nsim_version_text [read $nsim_version_fid]
close $nsim_version_fid
regexp "Version\\s+: (\\d+)\.(\\d+)" $nsim_version_text -> \
nsim_version_year nsim_version_month
if { $nsim_version_year > 2015 || \
($nsim_version_year == 2015 && $nsim_version_month > 6) } {
# Avoid performance penalty of useless initialization of heap and stack
# sections.
lappend nsim_flags "-on nsim_download_elf_sections"
if {![check_target_arcv]} {
if {[file exists $nsim_version_path]} {
set nsim_version_fid [open $nsim_version_path r]
set nsim_version_text [read $nsim_version_fid]
close $nsim_version_fid
regexp "Version\\s+: (\\d+)\.(\\d+)" $nsim_version_text -> \
nsim_version_year nsim_version_month
if {$nsim_version_year > 2015 || \
($nsim_version_year == 2015 && $nsim_version_month > 6)} {
# Avoid performance penalty of useless initialization of heap and
# stack sections.
lappend nsim_flags "-on nsim_download_elf_sections"
}
} else {
lappend nsim_flags "-on nsim_download_elf_sections"
}
} else {
lappend nsim_flags "-on nsim_download_elf_sections"
}

# Hostlink library support
Expand All @@ -106,8 +109,9 @@ if { [info exists env(ARC_HOSTLINK_LIBRARY)] } {
} elseif { [info exists env(ARC_NSIM_HOSTLINK)] } {
set_board_info arc,hostlink $env(ARC_NSIM_HOSTLINK)

if { [board_info $board arc,hostlink] != "metaware" && \
[board_info $board arc,hostlink] != "nsim" } {
if {[board_info $board arc,hostlink] != "metaware" && \
[board_info $board arc,hostlink] != "nsim" && \
[board_info $board arc,hostlink] != "semihost"} {
perror "Unknown nSIM HOSTLINK type $env(ARC_NSIM_HOSTLINK)"
exit 1
}
Expand Down Expand Up @@ -210,6 +214,13 @@ if { [check_target_arc64_64] } {
-p nsim_isa_family=av2em \
-p nsim_isa_core=3 \
-on nsim_isa_sat
} elseif {[check_target_arcv]} {
set ext "-all.i.zicsr.zifencei.zihintpause.b.zca.zcb.zcmp.zcmt.a.m.zbb"
lappend nsim_flags \
-p nsim_isa_family=rv32 \
-p nsim_isa_ext=${ext} \
-p nsim_semihosting=1 \
-off=enable_exceptions
} else {
perror "Unknown CPU configuration"
}
Expand Down
5 changes: 5 additions & 0 deletions dejagnu/tool-extra.exp
Original file line number Diff line number Diff line change
Expand Up @@ -86,6 +86,11 @@ proc compile_quarkse_em_nsim_apex { } {
}
}

# Return 1 if we compile for ARC-V
proc check_target_arcv { } {
return [check_target_arc "__riscv"]
}

# Return 1 if we compile for ARC64
proc check_target_arc64_64 { } {
return [check_target_arc "__ARC64_ARCH64__"]
Expand Down

0 comments on commit bb27387

Please sign in to comment.