@@ -1,3 +1,30 @@
+2013-10-16 David Malcolm <dmalcolm@redhat.com>
+
+ * TODO.rst (gcc_jit_context_new_local): Remove completed item.
+ * internal-api.c (gcc::jit::context::new_local): Replace with...
+ (gcc::jit::function::new_local): ...this, and change return type
+ from (local*) to (lvalue*).
+ * internal-api.h (gcc::jit::local): Eliminate.
+ (gcc::jit::context::new_local): Replace with...
+ (gcc::jit::function::new_local): ...this, and change return type
+ from (local*) to (lvalue*).
+ * libgccjit.c (gcc_jit_local): Eliminate.
+ (gcc_jit_context_new_local): Replace with...
+ (gcc_jit_function_new_local): ...this, and change return type
+ from (gcc_jit_local*) to (gcc_jit_lvalue*).
+ (gcc_jit_local_as_lvalue): Remove.
+ (gcc_jit_local_as_rvalue): Remove.
+ * libgccjit.h (gcc_jit_local): Remove.
+ (gcc_jit_context_new_local): Replace with...
+ (gcc_jit_function_new_local): ...this, and change return type
+ from (gcc_jit_local*) to (gcc_jit_lvalue*).
+ (gcc_jit_local_as_lvalue): Remove.
+ (gcc_jit_local_as_rvalue): Remove.
+ * libgccjit.map (gcc_jit_context_new_local): Replace with...
+ (gcc_jit_function_new_local): ...this.
+ (gcc_jit_local_as_lvalue): Remove.
+ (gcc_jit_local_as_rvalue): Remove.
+
2013-10-15 David Malcolm <dmalcolm@redhat.com>
* libgccjit.h (gcc_jit_location): Rewrite comment to reflect
@@ -1,8 +1,5 @@
TODOs:
-* gcc_jit_context_new_local should take a function, not the context (is
- it building a global?)
-
* error-handling:
* have a client-provided error-handling callback for the context, and
call it, rather than asserting/crashing etc, to make the API resilient and helpful
@@ -260,23 +260,6 @@ new_global (location *loc,
return new lvalue (inner);
}
-gcc::jit::local *
-gcc::jit::context::
-new_local (location *loc,
- type *type,
- const char *name)
-{
- gcc_assert (type);
- gcc_assert (name);
- tree inner = build_decl (UNKNOWN_LOCATION, VAR_DECL,
- get_identifier (name),
- type->as_tree ());
- if (loc)
- set_tree_location (inner, loc);
- return new local (inner);
-}
-
-
gcc::jit::rvalue *
gcc::jit::context::
new_rvalue_from_int (type *type,
@@ -561,6 +544,22 @@ get_return_type_as_tree () const
return TREE_TYPE (TREE_TYPE(m_inner_fndecl));
}
+gcc::jit::lvalue *
+gcc::jit::function::
+new_local (location *loc,
+ type *type,
+ const char *name)
+{
+ gcc_assert (type);
+ gcc_assert (name);
+ tree inner = build_decl (UNKNOWN_LOCATION, VAR_DECL,
+ get_identifier (name),
+ type->as_tree ());
+ if (loc)
+ set_tree_location (inner, loc);
+ return new lvalue (inner);
+}
+
gcc::jit::label *
gcc::jit::function::
new_forward_label (const char *name)
@@ -20,7 +20,6 @@ class label;
class rvalue;
class lvalue;
class param;
-class local;
class loop;
/* A JIT-compilation context. */
@@ -86,11 +85,6 @@ public:
type *type,
const char *name);
- local *
- new_local (location *loc,
- type *type,
- const char *name);
-
rvalue *
new_rvalue_from_int (type *type,
int value);
@@ -269,6 +263,11 @@ public:
tree as_fndecl () const { return m_inner_fndecl; }
+ lvalue *
+ new_local (location *loc,
+ type *type,
+ const char *name);
+
label*
new_forward_label (const char *name);
@@ -379,14 +378,6 @@ public:
{}
};
-class local : public lvalue
-{
-public:
- local (tree inner)
- : lvalue(inner)
- {}
-};
-
class loop : public wrapper
{
public:
@@ -48,10 +48,6 @@ struct gcc_jit_param : public gcc::jit::param
{
};
-struct gcc_jit_local : public gcc::jit::local
-{
-};
-
struct gcc_jit_loop : public gcc::jit::loop
{
};
@@ -226,28 +222,6 @@ gcc_jit_context_new_global (gcc_jit_context *ctxt,
return (gcc_jit_lvalue *)ctxt->new_global (loc, type, name);
}
-gcc_jit_local *
-gcc_jit_context_new_local (gcc_jit_context *ctxt,
- gcc_jit_location *loc,
- gcc_jit_type *type,
- const char *name)
-{
- ASSERT_WITHIN_CALLBACK (ctxt);
- return (gcc_jit_local *)ctxt->new_local (loc, type, name);
-}
-
-gcc_jit_lvalue *
-gcc_jit_local_as_lvalue (gcc_jit_local *local)
-{
- return (gcc_jit_lvalue *)local->as_lvalue ();
-}
-
-gcc_jit_rvalue *
-gcc_jit_local_as_rvalue (gcc_jit_local *local)
-{
- return (gcc_jit_rvalue *)local->as_rvalue ();
-}
-
gcc_jit_rvalue *
gcc_jit_lvalue_as_rvalue (gcc_jit_lvalue *lvalue)
{
@@ -343,6 +317,16 @@ gcc_jit_context_new_field_access (gcc_jit_context *ctxt,
return (gcc_jit_lvalue *)ctxt->new_field_access (loc, ptr_or_struct, fieldname);
}
+gcc_jit_lvalue *
+gcc_jit_function_new_local (gcc_jit_function *func,
+ gcc_jit_location *loc,
+ gcc_jit_type *type,
+ const char *name)
+{
+ ASSERT_WITHIN_CALLBACK (func->m_ctxt);
+ return (gcc_jit_lvalue *)func->new_local (loc, type, name);
+}
+
gcc_jit_label *
gcc_jit_function_add_label (gcc_jit_function *func,
gcc_jit_location *loc,
@@ -71,11 +71,6 @@ typedef struct gcc_jit_lvalue gcc_jit_lvalue;
rvalue); use gcc_jit_param_as_lvalue to convert. */
typedef struct gcc_jit_param gcc_jit_param;
-/* A gcc_jit_local is a local variable within a function. It is also
- a gcc_jit_lvalue (and thus also an rvalue); use gcc_jit_local_as_lvalue
- to convert. */
-typedef struct gcc_jit_local gcc_jit_local;
-
/* A gcc_jit_loop is a pre-canned way of creating loops without needing
to manually manage gcc_jit_label instances. */
typedef struct gcc_jit_loop gcc_jit_loop;
@@ -340,18 +335,6 @@ gcc_jit_context_new_global (gcc_jit_context *ctxt,
gcc_jit_type *type,
const char *name);
-extern gcc_jit_local *
-gcc_jit_context_new_local (gcc_jit_context *ctxt,
- gcc_jit_location *loc,
- gcc_jit_type *type,
- const char *name);
-
-extern gcc_jit_lvalue *
-gcc_jit_local_as_lvalue (gcc_jit_local *local);
-
-extern gcc_jit_rvalue *
-gcc_jit_local_as_rvalue (gcc_jit_local *local);
-
extern gcc_jit_rvalue *
gcc_jit_lvalue_as_rvalue (gcc_jit_lvalue *lvalue);
@@ -420,6 +403,12 @@ gcc_jit_context_new_field_access (gcc_jit_context *ctxt,
gcc_jit_rvalue *ptr_or_struct,
const char *fieldname);
+extern gcc_jit_lvalue *
+gcc_jit_function_new_local (gcc_jit_function *func,
+ gcc_jit_location *loc,
+ gcc_jit_type *type,
+ const char *name);
+
/* Add evaluation of an rvalue, discarding the result
(e.g. a function call that "returns" void). */
extern void
@@ -17,7 +17,6 @@
gcc_jit_context_new_field_access;
gcc_jit_context_new_function;
gcc_jit_context_new_global;
- gcc_jit_context_new_local;
gcc_jit_context_new_location;
gcc_jit_context_new_param;
gcc_jit_context_new_rvalue_from_int;
@@ -38,10 +37,9 @@
gcc_jit_function_add_label;
gcc_jit_function_add_return;
gcc_jit_function_new_forward_label;
+ gcc_jit_function_new_local;
gcc_jit_function_new_loop;
gcc_jit_function_place_forward_label;
- gcc_jit_local_as_lvalue;
- gcc_jit_local_as_rvalue;
gcc_jit_loop_end;
gcc_jit_lvalue_as_rvalue;
gcc_jit_param_as_lvalue;
@@ -1,3 +1,9 @@
+2013-10-16 David Malcolm <dmalcolm@redhat.com>
+
+ * jit.dg/test-dot-product.c (code_making_callback): Update for
+ API changes to locals.
+ * jit.dg/test-sum-of-squares.c (code_making_callback): Likewise.
+
2013-10-14 David Malcolm <dmalcolm@redhat.com>
* jit.dg/jit.exp (jit-dg-test): Detect compilation errors and
@@ -41,30 +41,30 @@ code_making_callback (gcc_jit_context *ctxt, void *user_data)
3, params, 0);
/* Build: "double result = 0.;" */
- gcc_jit_local *result =
- gcc_jit_context_new_local (ctxt, NULL, val_type, "result");
+ gcc_jit_lvalue *result =
+ gcc_jit_function_new_local (func, NULL, val_type, "result");
gcc_jit_function_add_assignment (func, NULL,
- gcc_jit_local_as_lvalue (result),
+ result,
gcc_jit_context_zero (ctxt, val_type));
/* Build: "for (int i = 0; i < n; i++)" */
- gcc_jit_local *i =
- gcc_jit_context_new_local (ctxt, NULL, int_type, "i");
+ gcc_jit_lvalue *i =
+ gcc_jit_function_new_local (func, NULL, int_type, "i");
gcc_jit_function_add_assignment (func, NULL,
- gcc_jit_local_as_lvalue (i), gcc_jit_context_zero (ctxt, int_type));
+ i, gcc_jit_context_zero (ctxt, int_type));
gcc_jit_loop *loop = gcc_jit_function_new_loop (func, NULL,
/* (i < n) */
gcc_jit_context_new_comparison (
ctxt, NULL,
GCC_JIT_COMPARISON_LT,
- gcc_jit_local_as_rvalue (i),
+ gcc_jit_lvalue_as_rvalue (i),
gcc_jit_param_as_rvalue (param_n)));
/* Build: "result += a[i] * b[i];" */
gcc_jit_function_add_assignment_op (
func, NULL,
- gcc_jit_local_as_lvalue (result),
+ result,
GCC_JIT_BINARY_OP_PLUS,
gcc_jit_context_new_binary_op (ctxt, NULL,
GCC_JIT_BINARY_OP_MULT,
@@ -72,16 +72,16 @@ code_making_callback (gcc_jit_context *ctxt, void *user_data)
gcc_jit_context_new_array_lookup(
ctxt, NULL,
gcc_jit_param_as_rvalue (param_a),
- gcc_jit_local_as_rvalue (i)),
+ gcc_jit_lvalue_as_rvalue (i)),
gcc_jit_context_new_array_lookup(
ctxt, NULL,
gcc_jit_param_as_rvalue (param_b),
- gcc_jit_local_as_rvalue (i))));
+ gcc_jit_lvalue_as_rvalue (i))));
/* Build: "i++" */
gcc_jit_function_add_assignment_op (
func, NULL,
- gcc_jit_local_as_lvalue (i),
+ i,
GCC_JIT_BINARY_OP_PLUS,
gcc_jit_context_one (ctxt, int_type));
@@ -91,7 +91,7 @@ code_making_callback (gcc_jit_context *ctxt, void *user_data)
gcc_jit_function_add_return (
func,
NULL,
- gcc_jit_local_as_rvalue (result));
+ gcc_jit_lvalue_as_rvalue (result));
return 0;
}
@@ -36,10 +36,10 @@ code_making_callback (gcc_jit_context *ctxt, void *user_data)
1, params, 0);
/* Build locals: */
- gcc_jit_local *i =
- gcc_jit_context_new_local (ctxt, NULL, the_type, "i");
- gcc_jit_local *sum =
- gcc_jit_context_new_local (ctxt, NULL, the_type, "sum");
+ gcc_jit_lvalue *i =
+ gcc_jit_function_new_local (func, NULL, the_type, "i");
+ gcc_jit_lvalue *sum =
+ gcc_jit_function_new_local (func, NULL, the_type, "sum");
/* Create forward label: */
gcc_jit_label *label_after_loop =
@@ -48,13 +48,13 @@ code_making_callback (gcc_jit_context *ctxt, void *user_data)
/* sum = 0; */
gcc_jit_function_add_assignment (
func, NULL,
- gcc_jit_local_as_lvalue (sum),
+ sum,
gcc_jit_context_new_rvalue_from_int (ctxt, the_type, 0));
/* i = 0; */
gcc_jit_function_add_assignment (
func, NULL,
- gcc_jit_local_as_lvalue (i),
+ i,
gcc_jit_context_new_rvalue_from_int (ctxt, the_type, 0));
@@ -68,7 +68,7 @@ code_making_callback (gcc_jit_context *ctxt, void *user_data)
gcc_jit_context_new_comparison (
ctxt, NULL,
GCC_JIT_COMPARISON_GE,
- gcc_jit_local_as_rvalue (i),
+ gcc_jit_lvalue_as_rvalue (i),
gcc_jit_param_as_rvalue (n)),
label_after_loop,
NULL);
@@ -76,25 +76,25 @@ code_making_callback (gcc_jit_context *ctxt, void *user_data)
/* sum += i * i */
gcc_jit_function_add_assignment (
func, NULL,
- gcc_jit_local_as_lvalue (sum),
+ sum,
gcc_jit_context_new_binary_op (
ctxt, NULL,
GCC_JIT_BINARY_OP_PLUS, the_type,
- gcc_jit_local_as_rvalue (sum),
+ gcc_jit_lvalue_as_rvalue (sum),
gcc_jit_context_new_binary_op (
ctxt, NULL,
GCC_JIT_BINARY_OP_MULT, the_type,
- gcc_jit_local_as_rvalue (i),
- gcc_jit_local_as_rvalue (i))));
+ gcc_jit_lvalue_as_rvalue (i),
+ gcc_jit_lvalue_as_rvalue (i))));
/* i++ */
gcc_jit_function_add_assignment (
func, NULL,
- gcc_jit_local_as_lvalue (i),
+ i,
gcc_jit_context_new_binary_op (
ctxt, NULL,
GCC_JIT_BINARY_OP_PLUS, the_type,
- gcc_jit_local_as_rvalue (i),
+ gcc_jit_lvalue_as_rvalue (i),
gcc_jit_context_new_rvalue_from_int (
ctxt,
the_type,
@@ -112,7 +112,7 @@ code_making_callback (gcc_jit_context *ctxt, void *user_data)
gcc_jit_function_add_return (
func,
NULL,
- gcc_jit_local_as_rvalue (sum));
+ gcc_jit_lvalue_as_rvalue (sum));
return 0;
}