Skip to content

Commit 63d8033

Browse files
author
sewardj
committed
Add a port to Linux/TileGx. Zhi-Gang Liu ([email protected])
Valgrind aspects, to match vex r3124. See bug 339778 - Linux/TileGx platform support to Valgrind git-svn-id: svn://svn.valgrind.org/valgrind/trunk@15080 a5019735-40e9-0310-863c-91ae7b9d1cf9
1 parent f7ab01b commit 63d8033

File tree

87 files changed

+5924
-298
lines changed

Some content is hidden

Large Commits have some content hidden by default. Use the searchbox below for content that may be hidden.

87 files changed

+5924
-298
lines changed

Makefile.all.am

+4
Original file line numberDiff line numberDiff line change
@@ -234,6 +234,9 @@ AM_CFLAGS_PSO_MIPS64_LINUX = @FLAG_M64@ $(AM_CFLAGS_BASE) @FLAG_MIPS64@ \
234234
$(AM_CFLAGS_PSO_BASE)
235235
AM_CCASFLAGS_MIPS64_LINUX = @FLAG_M64@ -g @FLAG_MIPS64@
236236

237+
AM_CFLAGS_TILEGX_LINUX = @FLAG_M64@ $(AM_CFLAGS_BASE)
238+
AM_CFLAGS_PSO_TILEGX_LINUX = @FLAG_M64@ $(AM_CFLAGS_BASE) $(AM_CFLAGS_PSO_BASE)
239+
237240
# Flags for the primary target. These must be used to build the
238241
# regtests and performance tests. In fact, these must be used to
239242
# build anything which is built only once on a dual-arch build.
@@ -274,4 +277,5 @@ PRELOAD_LDFLAGS_AMD64_DARWIN = $(PRELOAD_LDFLAGS_COMMON_DARWIN) -arch x86_64
274277
PRELOAD_LDFLAGS_S390X_LINUX = $(PRELOAD_LDFLAGS_COMMON_LINUX) @FLAG_M64@
275278
PRELOAD_LDFLAGS_MIPS32_LINUX = $(PRELOAD_LDFLAGS_COMMON_LINUX) @FLAG_M32@
276279
PRELOAD_LDFLAGS_MIPS64_LINUX = $(PRELOAD_LDFLAGS_COMMON_LINUX) @FLAG_M64@
280+
PRELOAD_LDFLAGS_TILEGX_LINUX = $(PRELOAD_LDFLAGS_COMMON_LINUX) @FLAG_M64@
277281

Makefile.tool.am

+11
Original file line numberDiff line numberDiff line change
@@ -76,6 +76,9 @@ TOOL_LDFLAGS_MIPS64_LINUX = \
7676
-static -nodefaultlibs -nostartfiles -u __start @FLAG_NO_BUILD_ID@ \
7777
@FLAG_M64@
7878

79+
TOOL_LDFLAGS_TILEGX_LINUX = \
80+
$(TOOL_LDFLAGS_COMMON_LINUX) @FLAG_M64@
81+
7982
# On Android we must ask for non-executable stack, not sure why.
8083
if VGCONF_PLATFORMS_INCLUDE_ARM_LINUX
8184
if VGCONF_PLATVARIANT_IS_ANDROID
@@ -132,6 +135,9 @@ LIBREPLACEMALLOC_MIPS32_LINUX = \
132135
LIBREPLACEMALLOC_MIPS64_LINUX = \
133136
$(top_builddir)/coregrind/libreplacemalloc_toolpreload-mips64-linux.a
134137

138+
LIBREPLACEMALLOC_TILEGX_LINUX = \
139+
$(top_builddir)/coregrind/libreplacemalloc_toolpreload-tilegx-linux.a
140+
135141
LIBREPLACEMALLOC_LDFLAGS_X86_LINUX = \
136142
-Wl,--whole-archive \
137143
$(LIBREPLACEMALLOC_X86_LINUX) \
@@ -188,6 +194,11 @@ LIBREPLACEMALLOC_LDFLAGS_MIPS64_LINUX = \
188194
$(LIBREPLACEMALLOC_MIPS64_LINUX) \
189195
-Wl,--no-whole-archive
190196

197+
LIBREPLACEMALLOC_LDFLAGS_TILEGX_LINUX = \
198+
-Wl,--whole-archive \
199+
$(LIBREPLACEMALLOC_TILEGX_LINUX) \
200+
-Wl,--no-whole-archive
201+
191202
#----------------------------------------------------------------------------
192203
# General stuff
193204
#----------------------------------------------------------------------------

Makefile.vex.am

+12-3
Original file line numberDiff line numberDiff line change
@@ -26,6 +26,7 @@ pkginclude_HEADERS = \
2626
pub/libvex_guest_s390x.h \
2727
pub/libvex_guest_mips32.h \
2828
pub/libvex_guest_mips64.h \
29+
pub/libvex_guest_tilegx.h \
2930
pub/libvex_s390x_common.h \
3031
pub/libvex_ir.h \
3132
pub/libvex_trc_values.h
@@ -44,6 +45,7 @@ noinst_HEADERS = \
4445
priv/guest_arm64_defs.h \
4546
priv/guest_s390_defs.h \
4647
priv/guest_mips_defs.h \
48+
priv/guest_tilegx_defs.h \
4749
priv/host_generic_regs.h \
4850
priv/host_generic_simd64.h \
4951
priv/host_generic_simd128.h \
@@ -57,7 +59,8 @@ noinst_HEADERS = \
5759
priv/host_s390_defs.h \
5860
priv/s390_disasm.h \
5961
priv/s390_defs.h \
60-
priv/host_mips_defs.h
62+
priv/host_mips_defs.h \
63+
priv/tilegx_disasm.h
6164

6265
BUILT_SOURCES = pub/libvex_guest_offsets.h
6366
CLEANFILES = pub/libvex_guest_offsets.h
@@ -82,7 +85,8 @@ pub/libvex_guest_offsets.h: auxprogs/genoffsets.c \
8285
pub/libvex_guest_arm64.h \
8386
pub/libvex_guest_s390x.h \
8487
pub/libvex_guest_mips32.h \
85-
pub/libvex_guest_mips64.h
88+
pub/libvex_guest_mips64.h \
89+
pub/libvex_guest_tilegx.h
8690
rm -f auxprogs/genoffsets.s
8791
$(mkdir_p) auxprogs pub
8892
$(CC) $(CFLAGS_FOR_GENOFFSETS) \
@@ -137,6 +141,8 @@ LIBVEX_SOURCES_COMMON = \
137141
priv/guest_s390_toIR.c \
138142
priv/guest_mips_helpers.c \
139143
priv/guest_mips_toIR.c \
144+
priv/guest_tilegx_helpers.c \
145+
priv/guest_tilegx_toIR.c \
140146
priv/host_generic_regs.c \
141147
priv/host_generic_simd64.c \
142148
priv/host_generic_simd128.c \
@@ -157,7 +163,10 @@ LIBVEX_SOURCES_COMMON = \
157163
priv/host_s390_isel.c \
158164
priv/s390_disasm.c \
159165
priv/host_mips_defs.c \
160-
priv/host_mips_isel.c
166+
priv/host_mips_isel.c \
167+
priv/host_tilegx_defs.c \
168+
priv/host_tilegx_isel.c \
169+
priv/tilegx_disasm.c
161170

162171
LIBVEXMULTIARCH_SOURCES = priv/multiarch_main_main.c
163172

cachegrind/cg_arch.c

+7
Original file line numberDiff line numberDiff line change
@@ -477,6 +477,13 @@ configure_caches(cache_t *I1c, cache_t *D1c, cache_t *LLc,
477477
*D1c = (cache_t) { 65536, 2, 64 };
478478
*LLc = (cache_t) { 262144, 8, 64 };
479479

480+
#elif defined(VGA_tilegx)
481+
482+
// Set caches to default for Tilegx.
483+
*I1c = (cache_t) { 0x8000, 2, 64 };
484+
*D1c = (cache_t) { 0x8000, 2, 64 };
485+
*LLc = (cache_t) { 0x40000, 8, 64 };
486+
480487
#else
481488

482489
#error "Unknown arch"

cachegrind/cg_branchpred.c

+2
Original file line numberDiff line numberDiff line change
@@ -51,6 +51,8 @@
5151
# define N_IADDR_LO_ZERO_BITS 0
5252
#elif defined(VGA_s390x) || defined(VGA_arm)
5353
# define N_IADDR_LO_ZERO_BITS 1
54+
#elif defined(VGA_tilegx)
55+
# define N_IADDR_LO_ZERO_BITS 3
5456
#else
5557
# error "Unsupported architecture"
5658
#endif

configure.ac

+24-1
Original file line numberDiff line numberDiff line change
@@ -268,6 +268,12 @@ case "${host_cpu}" in
268268
AC_MSG_RESULT([ok (${host_cpu})])
269269
ARCH_MAX="mips64"
270270
;;
271+
272+
tilegx)
273+
AC_MSG_RESULT([ok (${host_cpu})])
274+
ARCH_MAX="tilegx"
275+
;;
276+
271277
*)
272278
AC_MSG_RESULT([no (${host_cpu})])
273279
AC_MSG_ERROR([Unsupported host architecture. Sorry])
@@ -690,6 +696,17 @@ case "$ARCH_MAX-$VGCONF_OS" in
690696
valt_load_address_sec_inner="0xUNSET"
691697
AC_MSG_RESULT([ok (${ARCH_MAX}-${VGCONF_OS})])
692698
;;
699+
tilegx-linux)
700+
VGCONF_ARCH_PRI="tilegx"
701+
VGCONF_ARCH_SEC=""
702+
VGCONF_PLATFORM_PRI_CAPS="TILEGX_LINUX"
703+
VGCONF_PLATFORM_SEC_CAPS=""
704+
valt_load_address_pri_norml="0x38000000"
705+
valt_load_address_pri_inner="0x28000000"
706+
valt_load_address_sec_norml="0xUNSET"
707+
valt_load_address_sec_inner="0xUNSET"
708+
AC_MSG_RESULT([ok (${ARCH_MAX}-${VGCONF_OS})])
709+
;;
693710
*)
694711
VGCONF_ARCH_PRI="unknown"
695712
VGCONF_ARCH_SEC="unknown"
@@ -733,6 +750,8 @@ AM_CONDITIONAL(VGCONF_ARCHS_INCLUDE_MIPS32,
733750
test x$VGCONF_PLATFORM_PRI_CAPS = xMIPS32_LINUX )
734751
AM_CONDITIONAL(VGCONF_ARCHS_INCLUDE_MIPS64,
735752
test x$VGCONF_PLATFORM_PRI_CAPS = xMIPS64_LINUX )
753+
AM_CONDITIONAL(VGCONF_ARCHS_INCLUDE_TILEGX,
754+
test x$VGCONF_PLATFORM_PRI_CAPS = xTILEGX_LINUX )
736755

737756
# Set up VGCONF_PLATFORMS_INCLUDE_<platform>. Either one or two of these
738757
# become defined.
@@ -760,6 +779,8 @@ AM_CONDITIONAL(VGCONF_PLATFORMS_INCLUDE_MIPS32_LINUX,
760779
test x$VGCONF_PLATFORM_PRI_CAPS = xMIPS32_LINUX)
761780
AM_CONDITIONAL(VGCONF_PLATFORMS_INCLUDE_MIPS64_LINUX,
762781
test x$VGCONF_PLATFORM_PRI_CAPS = xMIPS64_LINUX)
782+
AM_CONDITIONAL(VGCONF_PLATFORMS_INCLUDE_TILEGX_LINUX,
783+
test x$VGCONF_PLATFORM_PRI_CAPS = xTILEGX_LINUX)
763784
AM_CONDITIONAL(VGCONF_PLATFORMS_INCLUDE_X86_DARWIN,
764785
test x$VGCONF_PLATFORM_PRI_CAPS = xX86_DARWIN \
765786
-o x$VGCONF_PLATFORM_SEC_CAPS = xX86_DARWIN)
@@ -780,7 +801,8 @@ AM_CONDITIONAL(VGCONF_OS_IS_LINUX,
780801
-o x$VGCONF_PLATFORM_PRI_CAPS = xARM64_LINUX \
781802
-o x$VGCONF_PLATFORM_PRI_CAPS = xS390X_LINUX \
782803
-o x$VGCONF_PLATFORM_PRI_CAPS = xMIPS32_LINUX \
783-
-o x$VGCONF_PLATFORM_PRI_CAPS = xMIPS64_LINUX)
804+
-o x$VGCONF_PLATFORM_PRI_CAPS = xMIPS64_LINUX \
805+
-o x$VGCONF_PLATFORM_PRI_CAPS = xTILEGX_LINUX)
784806
AM_CONDITIONAL(VGCONF_OS_IS_DARWIN,
785807
test x$VGCONF_PLATFORM_PRI_CAPS = xX86_DARWIN \
786808
-o x$VGCONF_PLATFORM_PRI_CAPS = xAMD64_DARWIN)
@@ -3008,6 +3030,7 @@ AC_CONFIG_FILES([
30083030
none/tests/s390x/Makefile
30093031
none/tests/mips32/Makefile
30103032
none/tests/mips64/Makefile
3033+
none/tests/tilegx/Makefile
30113034
none/tests/linux/Makefile
30123035
none/tests/darwin/Makefile
30133036
none/tests/x86-linux/Makefile

coregrind/Makefile.am

+5
Original file line numberDiff line numberDiff line change
@@ -343,6 +343,7 @@ COREGRIND_SOURCES_COMMON = \
343343
m_dispatch/dispatch-s390x-linux.S \
344344
m_dispatch/dispatch-mips32-linux.S \
345345
m_dispatch/dispatch-mips64-linux.S \
346+
m_dispatch/dispatch-tilegx-linux.S \
346347
m_dispatch/dispatch-x86-darwin.S \
347348
m_dispatch/dispatch-amd64-darwin.S \
348349
m_gdbserver/inferiors.c \
@@ -362,6 +363,7 @@ COREGRIND_SOURCES_COMMON = \
362363
m_gdbserver/valgrind-low-s390x.c \
363364
m_gdbserver/valgrind-low-mips32.c \
364365
m_gdbserver/valgrind-low-mips64.c \
366+
m_gdbserver/valgrind-low-tilegx.c \
365367
m_gdbserver/version.c \
366368
m_initimg/initimg-linux.c \
367369
m_initimg/initimg-darwin.c \
@@ -384,6 +386,7 @@ COREGRIND_SOURCES_COMMON = \
384386
m_sigframe/sigframe-s390x-linux.c \
385387
m_sigframe/sigframe-mips32-linux.c \
386388
m_sigframe/sigframe-mips64-linux.c \
389+
m_sigframe/sigframe-tilegx-linux.c \
387390
m_sigframe/sigframe-x86-darwin.c \
388391
m_sigframe/sigframe-amd64-darwin.c \
389392
m_syswrap/syscall-x86-linux.S \
@@ -396,6 +399,7 @@ COREGRIND_SOURCES_COMMON = \
396399
m_syswrap/syscall-s390x-linux.S \
397400
m_syswrap/syscall-mips32-linux.S \
398401
m_syswrap/syscall-mips64-linux.S \
402+
m_syswrap/syscall-tilegx-linux.S \
399403
m_syswrap/syscall-x86-darwin.S \
400404
m_syswrap/syscall-amd64-darwin.S \
401405
m_syswrap/syswrap-main.c \
@@ -412,6 +416,7 @@ COREGRIND_SOURCES_COMMON = \
412416
m_syswrap/syswrap-s390x-linux.c \
413417
m_syswrap/syswrap-mips32-linux.c \
414418
m_syswrap/syswrap-mips64-linux.c \
419+
m_syswrap/syswrap-tilegx-linux.c \
415420
m_syswrap/syswrap-x86-darwin.c \
416421
m_syswrap/syswrap-amd64-darwin.c \
417422
m_syswrap/syswrap-xen.c \

coregrind/launcher-linux.c

+9
Original file line numberDiff line numberDiff line change
@@ -65,6 +65,10 @@
6565
#define EM_PPC64 21 // ditto
6666
#endif
6767

68+
#ifndef EM_TILEGX
69+
#define EM_TILEGX 191
70+
#endif
71+
6872
/* Report fatal errors */
6973
__attribute__((noreturn))
7074
static void barf ( const char *format, ... )
@@ -243,6 +247,10 @@ static const char *select_platform(const char *clientname)
243247
(ehdr->e_ident[EI_OSABI] == ELFOSABI_SYSV ||
244248
ehdr->e_ident[EI_OSABI] == ELFOSABI_LINUX)) {
245249
platform = "mips64-linux";
250+
} else if (ehdr->e_machine == EM_TILEGX &&
251+
(ehdr->e_ident[EI_OSABI] == ELFOSABI_SYSV ||
252+
ehdr->e_ident[EI_OSABI] == ELFOSABI_LINUX)) {
253+
platform = "tilegx-linux";
246254
} else if (ehdr->e_machine == EM_AARCH64 &&
247255
(ehdr->e_ident[EI_OSABI] == ELFOSABI_SYSV ||
248256
ehdr->e_ident[EI_OSABI] == ELFOSABI_LINUX)) {
@@ -349,6 +357,7 @@ int main(int argc, char** argv, char** envp)
349357
(0==strcmp(VG_PLATFORM,"arm-linux")) ||
350358
(0==strcmp(VG_PLATFORM,"arm64-linux")) ||
351359
(0==strcmp(VG_PLATFORM,"s390x-linux")) ||
360+
(0==strcmp(VG_PLATFORM,"tilegx-linux")) ||
352361
(0==strcmp(VG_PLATFORM,"mips32-linux")) ||
353362
(0==strcmp(VG_PLATFORM,"mips64-linux")))
354363
default_platform = VG_PLATFORM;

coregrind/m_aspacemgr/aspacemgr-common.c

+8-1
Original file line numberDiff line numberDiff line change
@@ -158,7 +158,8 @@ SysRes VG_(am_do_mmap_NO_NOTIFY)( Addr start, SizeT length, UInt prot,
158158
# elif defined(VGP_amd64_linux) \
159159
|| defined(VGP_ppc64be_linux) || defined(VGP_ppc64le_linux) \
160160
|| defined(VGP_s390x_linux) || defined(VGP_mips32_linux) \
161-
|| defined(VGP_mips64_linux) || defined(VGP_arm64_linux)
161+
|| defined(VGP_mips64_linux) || defined(VGP_arm64_linux) \
162+
|| defined(VGP_tilegx_linux)
162163
res = VG_(do_syscall6)(__NR_mmap, (UWord)start, length,
163164
prot, flags, fd, offset);
164165
# elif defined(VGP_x86_darwin)
@@ -245,6 +246,9 @@ SysRes ML_(am_open) ( const HChar* pathname, Int flags, Int mode )
245246
/* ARM64 wants to use __NR_openat rather than __NR_open. */
246247
SysRes res = VG_(do_syscall4)(__NR_openat,
247248
VKI_AT_FDCWD, (UWord)pathname, flags, mode);
249+
# elif defined(VGP_tilegx_linux)
250+
SysRes res = VG_(do_syscall4)(__NR_openat, AT_FDCWD, (UWord)pathname,
251+
flags, mode);
248252
# else
249253
SysRes res = VG_(do_syscall3)(__NR_open, (UWord)pathname, flags, mode);
250254
# endif
@@ -268,6 +272,9 @@ Int ML_(am_readlink)(const HChar* path, HChar* buf, UInt bufsiz)
268272
# if defined(VGP_arm64_linux)
269273
res = VG_(do_syscall4)(__NR_readlinkat, VKI_AT_FDCWD,
270274
(UWord)path, (UWord)buf, bufsiz);
275+
# elif defined(VGP_tilegx_linux)
276+
res = VG_(do_syscall4)(__NR_readlinkat, AT_FDCWD, (UWord)path, (UWord)buf,
277+
bufsiz);
271278
# else
272279
res = VG_(do_syscall3)(__NR_readlink, (UWord)path, (UWord)buf, bufsiz);
273280
# endif

coregrind/m_cache.c

+2-2
Original file line numberDiff line numberDiff line change
@@ -540,8 +540,8 @@ get_cache_info(VexArchInfo *vai)
540540

541541
#elif defined(VGA_arm) || defined(VGA_ppc32) || \
542542
defined(VGA_ppc64be) || defined(VGA_ppc64le) || \
543-
defined(VGA_mips32) || defined(VGA_mips64) || defined(VGA_arm64)
544-
543+
defined(VGA_mips32) || defined(VGA_mips64) || defined(VGA_arm64) || \
544+
defined(VGA_tilegx)
545545
static Bool
546546
get_cache_info(VexArchInfo *vai)
547547
{

coregrind/m_coredump/coredump-elf.c

+12-2
Original file line numberDiff line numberDiff line change
@@ -419,7 +419,17 @@ static void fill_prstatus(const ThreadState *tst,
419419
# undef DO
420420
regs->MIPS_hi = arch->vex.guest_HI;
421421
regs->MIPS_lo = arch->vex.guest_LO;
422-
422+
#elif defined(VGP_tilegx_linux)
423+
# define DO(n) regs->regs[n] = arch->vex.guest_r##n
424+
DO(0); DO(1); DO(2); DO(3); DO(4); DO(5); DO(6); DO(7);
425+
DO(8); DO(9); DO(10); DO(11); DO(12); DO(13); DO(14); DO(15);
426+
DO(16); DO(17); DO(18); DO(19); DO(20); DO(21); DO(22); DO(23);
427+
DO(24); DO(25); DO(26); DO(27); DO(28); DO(29); DO(30); DO(31);
428+
DO(32); DO(33); DO(34); DO(35); DO(36); DO(37); DO(38); DO(39);
429+
DO(40); DO(41); DO(42); DO(43); DO(44); DO(45); DO(46); DO(47);
430+
DO(48); DO(49); DO(50); DO(51); DO(52); DO(53); DO(54); DO(55);
431+
regs->pc = arch->vex.guest_pc;
432+
regs->orig_r0 = arch->vex.guest_r0;
423433
#else
424434
# error Unknown ELF platform
425435
#endif
@@ -492,7 +502,7 @@ static void fill_fpu(const ThreadState *tst, vki_elf_fpregset_t *fpu)
492502
DO(24); DO(25); DO(26); DO(27); DO(28); DO(29); DO(30); DO(31);
493503
# undef DO
494504

495-
#elif defined(VGP_arm_linux)
505+
#elif defined(VGP_arm_linux) || defined(VGP_tilegx_linux)
496506
// umm ...
497507

498508
#elif defined(VGP_arm64_linux)

0 commit comments

Comments
 (0)