Skip to content

Commit 1241d69

Browse files
committed
Add support for setting the alignment
1 parent 297b735 commit 1241d69

File tree

5 files changed

+64
-1
lines changed

5 files changed

+64
-1
lines changed

gcc/jit/jit-playback.h

+7
Original file line numberDiff line numberDiff line change
@@ -715,6 +715,13 @@ class lvalue : public rvalue
715715
DECL_HARD_REGISTER (as_tree ()) = 1;
716716
}
717717

718+
void
719+
set_alignment (int alignment)
720+
{
721+
SET_DECL_ALIGN (as_tree (), alignment);
722+
DECL_USER_ALIGN (as_tree ()) = 1;
723+
}
724+
718725
private:
719726
bool mark_addressable (location *loc);
720727
};

gcc/jit/jit-recording.cc

+8
Original file line numberDiff line numberDiff line change
@@ -3978,6 +3978,11 @@ void recording::lvalue::set_register_name (const char *reg_name)
39783978
m_reg_name = new_string (reg_name);
39793979
}
39803980

3981+
void recording::lvalue::set_alignment (int alignment)
3982+
{
3983+
m_alignment = alignment;
3984+
}
3985+
39813986
/* The implementation of class gcc::jit::recording::param. */
39823987

39833988
/* Implementation of pure virtual hook recording::memento::replay_into
@@ -4847,6 +4852,9 @@ recording::global::replay_into (replayer *r)
48474852
if (m_reg_name != NULL)
48484853
global->set_register_name (m_reg_name->c_str ());
48494854

4855+
if (m_alignment != 0)
4856+
global->set_alignment (m_alignment);
4857+
48504858
set_playback_obj (global);
48514859
}
48524860

gcc/jit/jit-recording.h

+5-1
Original file line numberDiff line numberDiff line change
@@ -1170,7 +1170,8 @@ class lvalue : public rvalue
11701170
: rvalue (ctxt, loc, type_),
11711171
m_link_section (NULL),
11721172
m_reg_name (NULL),
1173-
m_tls_model (GCC_JIT_TLS_MODEL_NONE)
1173+
m_tls_model (GCC_JIT_TLS_MODEL_NONE),
1174+
m_alignment (0)
11741175
{}
11751176

11761177
playback::lvalue *
@@ -1195,11 +1196,14 @@ class lvalue : public rvalue
11951196
void set_tls_model (enum gcc_jit_tls_model model);
11961197
void set_link_section (const char *name);
11971198
void set_register_name (const char *reg_name);
1199+
void set_alignment (int alignment);
1200+
int get_alignment () { return m_alignment; }
11981201

11991202
protected:
12001203
string *m_link_section;
12011204
string *m_reg_name;
12021205
enum gcc_jit_tls_model m_tls_model;
1206+
int m_alignment;
12031207
};
12041208

12051209
class param : public lvalue

gcc/jit/libgccjit.cc

+25
Original file line numberDiff line numberDiff line change
@@ -2702,6 +2702,31 @@ gcc_jit_lvalue_set_register_name (gcc_jit_lvalue *lvalue,
27022702
lvalue->set_register_name (reg_name);
27032703
}
27042704

2705+
/* Public entrypoint. See description in libgccjit.h.
2706+
2707+
After error-checking, the real work is done by the
2708+
gcc::jit::recording::lvalue::get_link_section method in jit-recording.cc. */
2709+
2710+
int
2711+
gcc_jit_lvalue_get_alignment (gcc_jit_lvalue *lvalue)
2712+
{
2713+
RETURN_VAL_IF_FAIL (lvalue, 0, NULL, NULL, "NULL lvalue");
2714+
return lvalue->get_alignment ();
2715+
}
2716+
2717+
/* Public entrypoint. See description in libgccjit.h.
2718+
2719+
After error-checking, the real work is done by the
2720+
gcc::jit::recording::lvalue::set_alignment method in jit-recording.cc. */
2721+
2722+
void
2723+
gcc_jit_lvalue_set_alignment (gcc_jit_lvalue *lvalue,
2724+
int alignment)
2725+
{
2726+
RETURN_IF_FAIL (lvalue, NULL, NULL, "NULL lvalue");
2727+
lvalue->set_alignment (alignment);
2728+
}
2729+
27052730
/* Public entrypoint. See description in libgccjit.h.
27062731
27072732
After error-checking, the real work is done by the

gcc/jit/libgccjit.h

+19
Original file line numberDiff line numberDiff line change
@@ -1342,6 +1342,25 @@ void
13421342
gcc_jit_lvalue_set_register_name (gcc_jit_lvalue *lvalue,
13431343
const char *reg_name);
13441344

1345+
#define LIBGCCJIT_HAVE_gcc_jit_lvalue_set_alignment
1346+
1347+
/* Set the alignment of a variable.
1348+
1349+
This API entrypoint was added in LIBGCCJIT_ABI_24; you can test for its
1350+
presence using
1351+
#ifdef LIBGCCJIT_HAVE_ALIGNMENT */
1352+
extern void
1353+
gcc_jit_lvalue_set_alignment (gcc_jit_lvalue *lvalue,
1354+
int alignment);
1355+
1356+
/* Get the alignment of a variable.
1357+
1358+
This API entrypoint was added in LIBGCCJIT_ABI_24; you can test for its
1359+
presence using
1360+
#ifdef LIBGCCJIT_HAVE_ALIGNMENT */
1361+
extern int
1362+
gcc_jit_lvalue_get_alignment (gcc_jit_lvalue *lvalue);
1363+
13451364
extern gcc_jit_lvalue *
13461365
gcc_jit_function_new_local (gcc_jit_function *func,
13471366
gcc_jit_location *loc,

0 commit comments

Comments
 (0)