Skip to content

Commit 4c5565b

Browse files
authored
Merge pull request #50 from zedar/add_checking_if_new_float_types_are_supported
Target Info extended with supported types (limited to Float16|32|64|128)
2 parents ab469a6 + 1c9a9b2 commit 4c5565b

7 files changed

+46
-10
lines changed

gcc/config/i386/i386-jit.cc

+13
Original file line numberDiff line numberDiff line change
@@ -23,6 +23,7 @@ along with GCC; see the file COPYING3. If not see
2323
#include "target.h"
2424
#include "tm.h"
2525
#include "tm_jit.h"
26+
#include "tree.h"
2627
#include "jit/jit-target.h"
2728
#include "jit/jit-target-def.h"
2829

@@ -70,6 +71,18 @@ ix86_jit_register_target_info (void)
7071

7172
jit_target_set_128bit_int_support (targetm.scalar_mode_supported_p (TImode));
7273

74+
if (float16_type_node != NULL && TYPE_PRECISION(float16_type_node) == 16)
75+
jit_target_add_supported_target_dependent_type(GCC_JIT_TYPE_FLOAT16);
76+
77+
if (float32_type_node != NULL && TYPE_PRECISION(float32_type_node) == 32)
78+
jit_target_add_supported_target_dependent_type(GCC_JIT_TYPE_FLOAT32);
79+
80+
if (float64_type_node != NULL && TYPE_PRECISION(float64_type_node) == 64)
81+
jit_target_add_supported_target_dependent_type(GCC_JIT_TYPE_FLOAT64);
82+
83+
if (float128_type_node != NULL && TYPE_PRECISION(float128_type_node) == 128)
84+
jit_target_add_supported_target_dependent_type(GCC_JIT_TYPE_FLOAT128);
85+
7386
if (TARGET_MMX)
7487
jit_add_target_info ("target_feature", "mmx");
7588
if (TARGET_SSE)

gcc/jit/jit-target.cc

+6
Original file line numberDiff line numberDiff line change
@@ -70,6 +70,12 @@ jit_target_set_128bit_int_support (bool support)
7070
jit_target_info.m_supports_128bit_int = support;
7171
}
7272

73+
void
74+
jit_target_add_supported_target_dependent_type(enum gcc_jit_types type_)
75+
{
76+
jit_target_info.m_supported_target_dependent_types.insert(type_);
77+
}
78+
7379
target_info *
7480
jit_get_target_info ()
7581
{

gcc/jit/jit-target.h

+3
Original file line numberDiff line numberDiff line change
@@ -24,6 +24,7 @@
2424
#define HOOKSTRUCT(FRAGMENT) FRAGMENT
2525

2626
#include "jit-target.def"
27+
#include "libgccjit.h"
2728

2829
#include <string>
2930
#include <unordered_map>
@@ -55,6 +56,7 @@ struct target_info {
5556
std::unordered_map<const char *, std::unordered_set<const char *, CStringHash, CStringEqual>, CStringHash, CStringEqual> m_info;
5657
std::string m_arch;
5758
bool m_supports_128bit_int = false;
59+
std::unordered_set<enum gcc_jit_types> m_supported_target_dependent_types;
5860
};
5961

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

gcc/jit/libgccjit.cc

+6
Original file line numberDiff line numberDiff line change
@@ -4012,6 +4012,12 @@ gcc_jit_target_info_supports_128bit_int (gcc_jit_target_info *info)
40124012
return info->m_supports_128bit_int;
40134013
}
40144014

4015+
int
4016+
gcc_jit_target_info_supports_target_dependent_type(gcc_jit_target_info *info, enum gcc_jit_types type)
4017+
{
4018+
return info->m_supported_target_dependent_types.find(type) != info->m_supported_target_dependent_types.end();
4019+
}
4020+
40154021
/* Public entrypoint. See description in libgccjit.h.
40164022
40174023
After error-checking, the real work is done by the

gcc/jit/libgccjit.h

+3
Original file line numberDiff line numberDiff line change
@@ -2196,6 +2196,9 @@ gcc_jit_target_info_arch (gcc_jit_target_info *info);
21962196
extern int
21972197
gcc_jit_target_info_supports_128bit_int (gcc_jit_target_info *info);
21982198

2199+
extern int
2200+
gcc_jit_target_info_supports_target_dependent_type(gcc_jit_target_info *info, enum gcc_jit_types type);
2201+
21992202
/* Given type "T", get type "T __attribute__ ((packed))". */
22002203
extern void
22012204
gcc_jit_type_set_packed (gcc_jit_type *type);

gcc/jit/libgccjit.map

+5
Original file line numberDiff line numberDiff line change
@@ -352,3 +352,8 @@ LIBGCCJIT_ABI_38 {
352352
global:
353353
gcc_jit_context_new_alignof;
354354
} LIBGCCJIT_ABI_37;
355+
356+
LIBGCCJIT_ABI_39 {
357+
global:
358+
gcc_jit_target_info_supports_target_dependent_type;
359+
} LIBGCCJIT_ABI_38;

patches/0001-Disable-128-bit-integers-for-testing-purposes.patch

+10-10
Original file line numberDiff line numberDiff line change
@@ -1,28 +1,28 @@
1-
From f8f19b4749ef849c814cb24c104e53c991488310 Mon Sep 17 00:00:00 2001
2-
From: Antoni Boucher <bouanto@zoho.com>
3-
Date: Fri, 16 Feb 2024 12:04:40 -0500
4-
Subject: [PATCH] Disable 128-bit integers for testing purposes
1+
From 252013d4d77dea9ce2078642d721d7ab906075ac Mon Sep 17 00:00:00 2001
2+
From: Robert Zakrzewski <robert.zakrzewski1@stellantis.com>
3+
Date: Fri, 19 Apr 2024 16:21:56 +0200
4+
Subject: [PATCH] Disable 128 bit integers for testing purposes
55

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

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

1919
- jit_target_set_128bit_int_support (targetm.scalar_mode_supported_p (TImode));
2020
+ //jit_target_set_128bit_int_support (targetm.scalar_mode_supported_p (TImode));
2121

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

0 commit comments

Comments
 (0)