Skip to content

Commit fbec9ec

Browse files
tempdragonantoyo
authored andcommitted
feat(gccjit): Allow set_loccation to various classes
Including: 1. field 2. function 3. rvalue
1 parent 3d63c17 commit fbec9ec

File tree

4 files changed

+67
-0
lines changed

4 files changed

+67
-0
lines changed

gcc/jit/jit-recording.h

Lines changed: 7 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -1041,6 +1041,7 @@ class array_type : public type
10411041
bool is_signed () const final override { return false; }
10421042

10431043
void replay_into (replayer *) final override;
1044+
void set_loc(location * loc) { m_loc = loc; }
10441045

10451046
private:
10461047
string * make_debug_string () final override;
@@ -1130,6 +1131,7 @@ class field : public memento
11301131

11311132
compound_type * get_container () const { return m_container; }
11321133
void set_container (compound_type *c) { m_container = c; }
1134+
void set_loc (location * loc) { m_loc = loc; }
11331135

11341136
void replay_into (replayer *) override;
11351137

@@ -1204,6 +1206,7 @@ class compound_type : public type
12041206
bool is_signed () const final override { return false; }
12051207

12061208
bool has_known_size () const final override { return m_fields != NULL; }
1209+
void set_loc (location * loc) { m_loc = loc; }
12071210

12081211
playback::compound_type *
12091212
playback_compound_type ()
@@ -1345,6 +1348,7 @@ class rvalue : public memento
13451348
}
13461349

13471350
location * get_loc () const { return m_loc; }
1351+
void set_loc (location * loc) { m_loc = loc; }
13481352

13491353
/* Get the recording::type of this rvalue.
13501354
@@ -1536,6 +1540,7 @@ class function : public memento
15361540
new_block (const char *name);
15371541

15381542
location *get_loc () const { return m_loc; }
1543+
void set_loc (location * loc) { m_loc = loc; }
15391544
type *get_return_type () const { return m_return_type; }
15401545
string * get_name () const { return m_name; }
15411546
const vec<param *> &get_params () const { return m_params; }
@@ -1673,6 +1678,7 @@ class block : public memento
16731678
bool validate ();
16741679

16751680
location *get_loc () const;
1681+
void set_loc (location * loc);
16761682

16771683
statement *get_first_statement () const;
16781684
statement *get_last_statement () const;
@@ -2480,6 +2486,7 @@ class statement : public memento
24802486

24812487
block *get_block () const { return m_block; }
24822488
location *get_loc () const { return m_loc; }
2489+
void set_loc (location * loc) { m_loc = loc; }
24832490

24842491
protected:
24852492
statement (block *b, location *loc)

gcc/jit/libgccjit.cc

Lines changed: 43 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -4745,3 +4745,46 @@ gcc_jit_context_add_top_level_asm (gcc_jit_context *ctxt,
47454745
RETURN_IF_FAIL (asm_stmts, ctxt, NULL, "NULL asm_stmts");
47464746
ctxt->add_top_level_asm (loc, asm_stmts);
47474747
}
4748+
4749+
/* Public entrypoint. See description in libgccjit.h.
4750+
4751+
After error-checking, this calls the trivial
4752+
gcc::jit::recording::field::set_loc method, in jit-recording.h. */
4753+
4754+
void
4755+
gcc_jit_field_set_location (gcc_jit_field *field,
4756+
gcc_jit_location *loc)
4757+
{
4758+
RETURN_IF_FAIL (field, NULL, NULL, "NULL field");
4759+
4760+
field->set_loc (loc);
4761+
}
4762+
4763+
4764+
/* Public entrypoint. See description in libgccjit.h.
4765+
4766+
After error-checking, this calls the trivial
4767+
gcc::jit::recording::rvalue::set_loc method , in jit-recording.h. */
4768+
4769+
void
4770+
gcc_jit_rvalue_set_location (gcc_jit_rvalue *rvalue,
4771+
gcc_jit_location *loc)
4772+
{
4773+
RETURN_IF_FAIL (rvalue, NULL, NULL, "NULL rvalue");
4774+
4775+
rvalue->set_loc (loc);
4776+
}
4777+
4778+
/* Public entrypoint. See description in libgccjit.h.
4779+
4780+
After error-checking, this calls the trivial
4781+
gcc::jit::recording::function::set_loc method, in jit-recording.h. */
4782+
4783+
void
4784+
gcc_jit_function_set_location (gcc_jit_function *func,
4785+
gcc_jit_location *loc)
4786+
{
4787+
RETURN_IF_FAIL (func, NULL, NULL, "NULL func");
4788+
4789+
func->set_loc (loc);
4790+
}

gcc/jit/libgccjit.h

Lines changed: 10 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -2180,6 +2180,16 @@ gcc_jit_target_info_supports_128bit_int (gcc_jit_target_info *info);
21802180
extern void
21812181
gcc_jit_type_set_packed (gcc_jit_type *type);
21822182

2183+
extern void
2184+
gcc_jit_field_set_location (gcc_jit_field *field,
2185+
gcc_jit_location *loc);
2186+
extern void
2187+
gcc_jit_function_set_location (gcc_jit_function *func,
2188+
gcc_jit_location *loc);
2189+
extern void
2190+
gcc_jit_rvalue_set_location (gcc_jit_rvalue *rvalue,
2191+
gcc_jit_location *loc);
2192+
21832193
#ifdef __cplusplus
21842194
}
21852195
#endif /* __cplusplus */

gcc/jit/libgccjit.map

Lines changed: 7 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -340,3 +340,10 @@ LIBGCCJIT_ABI_36 {
340340
global:
341341
gcc_jit_function_new_temp;
342342
} LIBGCCJIT_ABI_35;
343+
344+
LIBGCCJIT_ABI_37 {
345+
global:
346+
gcc_jit_field_set_location;
347+
gcc_jit_function_set_location;
348+
gcc_jit_rvalue_set_location;
349+
} LIBGCCJIT_ABI_36;

0 commit comments

Comments
 (0)