7 Jul 2012 08:55
Extracting the size of a variable from its tree representation
Amittai Aviram <amittai.aviram <at> yale.edu>
2012-07-07 06:55:44 GMT
2012-07-07 06:55:44 GMT
I have written a modification of the function "lower_omp_clauses" inside gcc/omp-low.c . Whenever this
function encounters an OpenMP reduction clause, my code needs to get the type and size of the reduction
variable. (By size, I mean the integer constant equal to the result of the sizeof operator applied to that
variable.) I have managed to do this so far for C target code, but I've run into a problem with a Fortran
program that has a reduction on a variable of type "double precision" (i.e., double). My code reports the
type, correctly, as REAL_TYPE, but it reports the size erroneously as 0 instead of 8.
Here is a reduced version of how I go about trying to gather my information. What should I be doing instead,
particularly to get the size?
lower_reduction_clauses (tree clauses, gimple_seq *stmt_seqp, omp_context *ctx)
{
tree c;
/* ... */
for (c = clauses; c ; c = OMP_CLAUSE_CHAIN (c))
{
tree var, ref, new_var;
enum tree_code code;
enum tree_code new_var_type;
size_t new_var_size;
location_t clause_loc = OMP_CLAUSE_LOCATION (c);
var = OMP_CLAUSE_DECL (c);
new_var = lookup_decl (var, ctx);
if (is_reference (var))
new_var = build_simple_mem_ref_loc (clause_loc, new_var);
ref = build_outer_var_ref (var, ctx);
code = OMP_CLAUSE_REDUCTION_CODE (c);
(Continue reading)
RSS Feed