Skip to content

Commit cf95541

Browse files
authored
Merge pull request #42 from tempdragon/master
feat(gccjit): Allow set_loccation to various classes
2 parents d24c8da + c0f216d commit cf95541

File tree

4 files changed

+67
-0
lines changed

4 files changed

+67
-0
lines changed

gcc/jit/jit-recording.h

+7
Original file line numberDiff line numberDiff line change
@@ -1044,6 +1044,7 @@ class array_type : public type
10441044
bool is_signed () const final override { return false; }
10451045

10461046
void replay_into (replayer *) final override;
1047+
void set_loc(location * loc) { m_loc = loc; }
10471048

10481049
private:
10491050
string * make_debug_string () final override;
@@ -1133,6 +1134,7 @@ class field : public memento
11331134

11341135
compound_type * get_container () const { return m_container; }
11351136
void set_container (compound_type *c) { m_container = c; }
1137+
void set_loc (location * loc) { m_loc = loc; }
11361138

11371139
void replay_into (replayer *) override;
11381140

@@ -1207,6 +1209,7 @@ class compound_type : public type
12071209
bool is_signed () const final override { return false; }
12081210

12091211
bool has_known_size () const final override { return m_fields != NULL; }
1212+
void set_loc (location * loc) { m_loc = loc; }
12101213

12111214
playback::compound_type *
12121215
playback_compound_type ()
@@ -1348,6 +1351,7 @@ class rvalue : public memento
13481351
}
13491352

13501353
location * get_loc () const { return m_loc; }
1354+
void set_loc (location * loc) { m_loc = loc; }
13511355

13521356
/* Get the recording::type of this rvalue.
13531357
@@ -1539,6 +1543,7 @@ class function : public memento
15391543
new_block (const char *name);
15401544

15411545
location *get_loc () const { return m_loc; }
1546+
void set_loc (location * loc) { m_loc = loc; }
15421547
type *get_return_type () const { return m_return_type; }
15431548
string * get_name () const { return m_name; }
15441549
const vec<param *> &get_params () const { return m_params; }
@@ -1676,6 +1681,7 @@ class block : public memento
16761681
bool validate ();
16771682

16781683
location *get_loc () const;
1684+
void set_loc (location * loc);
16791685

16801686
statement *get_first_statement () const;
16811687
statement *get_last_statement () const;
@@ -2483,6 +2489,7 @@ class statement : public memento
24832489

24842490
block *get_block () const { return m_block; }
24852491
location *get_loc () const { return m_loc; }
2492+
void set_loc (location * loc) { m_loc = loc; }
24862493

24872494
protected:
24882495
statement (block *b, location *loc)

gcc/jit/libgccjit.cc

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

gcc/jit/libgccjit.h

+10
Original file line numberDiff line numberDiff line change
@@ -2183,6 +2183,16 @@ gcc_jit_target_info_supports_128bit_int (gcc_jit_target_info *info);
21832183
extern void
21842184
gcc_jit_type_set_packed (gcc_jit_type *type);
21852185

2186+
extern void
2187+
gcc_jit_field_set_location (gcc_jit_field *field,
2188+
gcc_jit_location *loc);
2189+
extern void
2190+
gcc_jit_function_set_location (gcc_jit_function *func,
2191+
gcc_jit_location *loc);
2192+
extern void
2193+
gcc_jit_rvalue_set_location (gcc_jit_rvalue *rvalue,
2194+
gcc_jit_location *loc);
2195+
21862196
#ifdef __cplusplus
21872197
}
21882198
#endif /* __cplusplus */

gcc/jit/libgccjit.map

+7
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)