LCOV - code coverage report
Current view: top level - gcc - gimple-builder.c (source / functions) Hit Total Coverage
Test: gcc.info Lines: 28 28 100.0 %
Date: 2020-04-04 11:58:09 Functions: 9 9 100.0 %
Legend: Lines: hit not hit | Branches: + taken - not taken # not executed Branches: 0 0 -

           Branch data     Line data    Source code
       1                 :            : /* Functions for high level gimple building routines.
       2                 :            :    Copyright (C) 2013-2020 Free Software Foundation, Inc.
       3                 :            : 
       4                 :            : This file is part of GCC.
       5                 :            : 
       6                 :            : GCC is free software; you can redistribute it and/or modify
       7                 :            : it under the terms of the GNU General Public License as published by
       8                 :            : the Free Software Foundation; either version 3, or (at your option)
       9                 :            : any later version.
      10                 :            : 
      11                 :            : GCC is distributed in the hope that it will be useful,
      12                 :            : but WITHOUT ANY WARRANTY; without even the implied warranty of
      13                 :            : MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
      14                 :            : GNU General Public License for more details.
      15                 :            : 
      16                 :            : You should have received a copy of the GNU General Public License
      17                 :            : along with GCC; see the file COPYING3.  If not see
      18                 :            : <http://www.gnu.org/licenses/>.  */
      19                 :            : 
      20                 :            : #include "config.h"
      21                 :            : #include "system.h"
      22                 :            : #include "coretypes.h"
      23                 :            : #include "backend.h"
      24                 :            : #include "tree.h"
      25                 :            : #include "gimple.h"
      26                 :            : #include "stringpool.h"
      27                 :            : #include "tree-vrp.h"
      28                 :            : #include "tree-ssanames.h"
      29                 :            : 
      30                 :            : 
      31                 :            : /* Return the expression type to use based on the CODE and type of
      32                 :            :    the given operand OP.  If the expression CODE is a comparison,
      33                 :            :    the returned type is boolean_type_node.  Otherwise, it returns
      34                 :            :    the type of OP.  */
      35                 :            : 
      36                 :            : static tree
      37                 :      11744 : get_expr_type (enum tree_code code, tree op)
      38                 :            : {
      39                 :      11744 :   return (TREE_CODE_CLASS (code) == tcc_comparison)
      40                 :      11744 :          ? boolean_type_node
      41                 :       6004 :          : TREE_TYPE (op);
      42                 :            : }
      43                 :            : 
      44                 :            : 
      45                 :            : /* Build a new gimple assignment.  The LHS of the assignment is a new
      46                 :            :    temporary whose type matches the given expression.  MODE indicates
      47                 :            :    whether the LHS should be an SSA or a normal temporary.  CODE is
      48                 :            :    the expression code for the RHS.  OP1 is the first operand and VAL
      49                 :            :    is an integer value to be used as the second operand.  */
      50                 :            : 
      51                 :            : gassign *
      52                 :       5651 : build_assign (enum tree_code code, tree op1, int val, tree lhs)
      53                 :            : {
      54                 :       5651 :   tree op2 = build_int_cst (TREE_TYPE (op1), val);
      55                 :       5651 :   if (lhs == NULL_TREE)
      56                 :       5651 :     lhs = make_ssa_name (get_expr_type (code, op1));
      57                 :       5651 :   return gimple_build_assign (lhs, code, op1, op2);
      58                 :            : }
      59                 :            : 
      60                 :            : gassign *
      61                 :        578 : build_assign (enum tree_code code, gimple *g, int val, tree lhs )
      62                 :            : {
      63                 :        578 :   return build_assign (code, gimple_assign_lhs (g), val, lhs);
      64                 :            : }
      65                 :            : 
      66                 :            : 
      67                 :            : /* Build and return a new GIMPLE assignment.  The new assignment will
      68                 :            :    have the opcode CODE and operands OP1 and OP2.  The type of the
      69                 :            :    expression on the RHS is inferred to be the type of OP1.
      70                 :            : 
      71                 :            :    The LHS of the statement will be an SSA name or a GIMPLE temporary
      72                 :            :    in normal form depending on the type of builder invoking this
      73                 :            :    function.  */
      74                 :            : 
      75                 :            : gassign *
      76                 :       6093 : build_assign (enum tree_code code, tree op1, tree op2, tree lhs)
      77                 :            : {
      78                 :       6093 :   if (lhs == NULL_TREE)
      79                 :       6093 :     lhs = make_ssa_name (get_expr_type (code, op1));
      80                 :       6093 :   return gimple_build_assign (lhs, code, op1, op2);
      81                 :            : }
      82                 :            : 
      83                 :            : gassign *
      84                 :        353 : build_assign (enum tree_code code, gimple *op1, tree op2, tree lhs)
      85                 :            : {
      86                 :        353 :   return build_assign (code, gimple_assign_lhs (op1), op2, lhs);
      87                 :            : }
      88                 :            : 
      89                 :            : gassign *
      90                 :        353 : build_assign (enum tree_code code, tree op1, gimple *op2, tree lhs)
      91                 :            : {
      92                 :        353 :   return build_assign (code, op1, gimple_assign_lhs (op2), lhs);
      93                 :            : }
      94                 :            : 
      95                 :            : gassign *
      96                 :       2870 : build_assign (enum tree_code code, gimple *op1, gimple *op2, tree lhs)
      97                 :            : {
      98                 :       2870 :   return build_assign (code, gimple_assign_lhs (op1), gimple_assign_lhs (op2),
      99                 :       2870 :                        lhs);
     100                 :            : }
     101                 :            : 
     102                 :            : 
     103                 :            : /* Create and return a type cast assignment. This creates a NOP_EXPR
     104                 :            :    that converts OP to TO_TYPE.  */
     105                 :            : 
     106                 :            : gassign *
     107                 :       2291 : build_type_cast (tree to_type, tree op, tree lhs)
     108                 :            : {
     109                 :       2291 :   if (lhs == NULL_TREE)
     110                 :       2291 :     lhs = make_ssa_name (to_type);
     111                 :       2291 :   return gimple_build_assign (lhs, NOP_EXPR, op);
     112                 :            : }
     113                 :            : 
     114                 :            : gassign *
     115                 :       2203 : build_type_cast (tree to_type, gimple *op, tree lhs)
     116                 :            : {
     117                 :       2203 :   return build_type_cast (to_type, gimple_assign_lhs (op), lhs);
     118                 :            : }
     119                 :            : 
     120                 :            : 
     121                 :            : 

Generated by: LCOV version 1.0

LCOV profile is generated on x86_64 machine using following configure options: configure --disable-bootstrap --enable-coverage=opt --enable-languages=c,c++,fortran,go,jit,lto --enable-host-shared. GCC test suite is run with the built compiler.