Skip to content

Commit

Permalink
Target Info extended with supported target dependent types
Browse files Browse the repository at this point in the history
Update path: disable 128 bit integers for testing purposes

Target info extended with supported target dependent types

update patches
  • Loading branch information
Robert Zakrzewski committed Apr 19, 2024
1 parent ab469a6 commit a45f03e
Show file tree
Hide file tree
Showing 7 changed files with 46 additions and 10 deletions.
13 changes: 13 additions & 0 deletions gcc/config/i386/i386-jit.cc
Original file line number Diff line number Diff line change
Expand Up @@ -23,6 +23,7 @@ along with GCC; see the file COPYING3. If not see
#include "target.h"
#include "tm.h"
#include "tm_jit.h"
#include "tree.h"
#include "jit/jit-target.h"
#include "jit/jit-target-def.h"

Expand Down Expand Up @@ -70,6 +71,18 @@ ix86_jit_register_target_info (void)

jit_target_set_128bit_int_support (targetm.scalar_mode_supported_p (TImode));

if (float16_type_node != NULL && TYPE_PRECISION(float16_type_node) == 16)
jit_target_add_supported_target_dependent_type(GCC_JIT_TYPE_FLOAT16);

if (float32_type_node != NULL && TYPE_PRECISION(float32_type_node) == 32)
jit_target_add_supported_target_dependent_type(GCC_JIT_TYPE_FLOAT32);

if (float64_type_node != NULL && TYPE_PRECISION(float64_type_node) == 64)
jit_target_add_supported_target_dependent_type(GCC_JIT_TYPE_FLOAT64);

if (float128_type_node != NULL && TYPE_PRECISION(float128_type_node) == 128)
jit_target_add_supported_target_dependent_type(GCC_JIT_TYPE_FLOAT128);

if (TARGET_MMX)
jit_add_target_info ("target_feature", "mmx");
if (TARGET_SSE)
Expand Down
6 changes: 6 additions & 0 deletions gcc/jit/jit-target.cc
Original file line number Diff line number Diff line change
Expand Up @@ -70,6 +70,12 @@ jit_target_set_128bit_int_support (bool support)
jit_target_info.m_supports_128bit_int = support;
}

void
jit_target_add_supported_target_dependent_type(enum gcc_jit_types type_)
{
jit_target_info.m_supported_target_dependent_types.insert({type_, type_});
}

target_info *
jit_get_target_info ()
{
Expand Down
3 changes: 3 additions & 0 deletions gcc/jit/jit-target.h
Original file line number Diff line number Diff line change
Expand Up @@ -24,6 +24,7 @@
#define HOOKSTRUCT(FRAGMENT) FRAGMENT

#include "jit-target.def"
#include "libgccjit.h"

#include <string>
#include <unordered_map>
Expand Down Expand Up @@ -55,6 +56,7 @@ struct target_info {
std::unordered_map<const char *, std::unordered_set<const char *, CStringHash, CStringEqual>, CStringHash, CStringEqual> m_info;
std::string m_arch;
bool m_supports_128bit_int = false;
std::unordered_map<enum gcc_jit_types, enum gcc_jit_types> m_supported_target_dependent_types;
};

/* Each target can provide their own. */
Expand All @@ -63,6 +65,7 @@ extern struct gcc_targetjitm targetjitm;
extern void jit_target_init ();
extern void jit_target_set_arch (std::string const& arch);
extern void jit_target_set_128bit_int_support (bool support);
extern void jit_target_add_supported_target_dependent_type(enum gcc_jit_types type_);
extern void jit_add_target_info (const char *key, const char *value);
extern target_info * jit_get_target_info ();

Expand Down
6 changes: 6 additions & 0 deletions gcc/jit/libgccjit.cc
Original file line number Diff line number Diff line change
Expand Up @@ -4012,6 +4012,12 @@ gcc_jit_target_info_supports_128bit_int (gcc_jit_target_info *info)
return info->m_supports_128bit_int;
}

int
gcc_jit_target_info_supports_target_dependent_type(gcc_jit_target_info *info, enum gcc_jit_types type)
{
return info->m_supported_target_dependent_types.find(type) != info->m_supported_target_dependent_types.end();
}

/* Public entrypoint. See description in libgccjit.h.
After error-checking, the real work is done by the
Expand Down
3 changes: 3 additions & 0 deletions gcc/jit/libgccjit.h
Original file line number Diff line number Diff line change
Expand Up @@ -2196,6 +2196,9 @@ gcc_jit_target_info_arch (gcc_jit_target_info *info);
extern int
gcc_jit_target_info_supports_128bit_int (gcc_jit_target_info *info);

extern int
gcc_jit_target_info_supports_target_dependent_type(gcc_jit_target_info *info, enum gcc_jit_types type);

/* Given type "T", get type "T __attribute__ ((packed))". */
extern void
gcc_jit_type_set_packed (gcc_jit_type *type);
Expand Down
5 changes: 5 additions & 0 deletions gcc/jit/libgccjit.map
Original file line number Diff line number Diff line change
Expand Up @@ -352,3 +352,8 @@ LIBGCCJIT_ABI_38 {
global:
gcc_jit_context_new_alignof;
} LIBGCCJIT_ABI_37;

LIBGCCJIT_ABI_39 {
global:
gcc_jit_target_info_supports_target_dependent_type;
} LIBGCCJIT_ABI_38;
20 changes: 10 additions & 10 deletions patches/0001-Disable-128-bit-integers-for-testing-purposes.patch
Original file line number Diff line number Diff line change
@@ -1,28 +1,28 @@
From f8f19b4749ef849c814cb24c104e53c991488310 Mon Sep 17 00:00:00 2001
From: Antoni Boucher <bouanto@zoho.com>
Date: Fri, 16 Feb 2024 12:04:40 -0500
Subject: [PATCH] Disable 128-bit integers for testing purposes
From b52c80a1afc8f9dd2d958ef901031326342ce25e Mon Sep 17 00:00:00 2001
From: Robert Zakrzewski <robert.zakrzewski1@stellantis.com>
Date: Fri, 19 Apr 2024 15:19:25 +0200
Subject: [PATCH] Disable 128 bit integers for testing purposes

---
gcc/config/i386/i386-jit.cc | 2 +-
gcc/jit/jit-playback.cc | 8 ++++----
2 files changed, 5 insertions(+), 5 deletions(-)

diff --git a/gcc/config/i386/i386-jit.cc b/gcc/config/i386/i386-jit.cc
index 49e54aa7990..67c50bdc6dd 100644
index 8c7c8cd45e8..2dc35b6a746 100644
--- a/gcc/config/i386/i386-jit.cc
+++ b/gcc/config/i386/i386-jit.cc
@@ -68,7 +68,7 @@ ix86_jit_register_target_info (void)
@@ -69,7 +69,7 @@ ix86_jit_register_target_info (void)
std::string cpu = arch.substr (arg_pos, end_pos - arg_pos);
jit_target_set_arch (cpu);

- jit_target_set_128bit_int_support (targetm.scalar_mode_supported_p (TImode));
+ //jit_target_set_128bit_int_support (targetm.scalar_mode_supported_p (TImode));

if (TARGET_MMX)
jit_add_target_info ("target_feature", "mmx");
if (float16_type_node != NULL && TYPE_PRECISION(float16_type_node) == 16)
jit_target_add_supported_target_dependent_type(GCC_JIT_TYPE_FLOAT16);
diff --git a/gcc/jit/jit-playback.cc b/gcc/jit/jit-playback.cc
index 6b0522d6f88..73efa6b5bc0 100644
index 625af722741..a6ddfa179d0 100644
--- a/gcc/jit/jit-playback.cc
+++ b/gcc/jit/jit-playback.cc
@@ -249,8 +249,8 @@ get_tree_node_for_type (enum gcc_jit_types type_)
Expand All @@ -48,5 +48,5 @@ index 6b0522d6f88..73efa6b5bc0 100644
add_error (NULL, "gcc_jit_types value unsupported on this target: %i",
type_);
--
2.43.0
2.25.1

0 comments on commit a45f03e

Please sign in to comment.