当前位置: 首页>>代码示例>>C++>>正文


C++ TREE_INT_CST_LOW函数代码示例

本文整理汇总了C++中TREE_INT_CST_LOW函数的典型用法代码示例。如果您正苦于以下问题:C++ TREE_INT_CST_LOW函数的具体用法?C++ TREE_INT_CST_LOW怎么用?C++ TREE_INT_CST_LOW使用的例子?那么, 这里精选的函数代码示例或许可以为您提供帮助。


在下文中一共展示了TREE_INT_CST_LOW函数的15个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的C++代码示例。

示例1: createFieldInfo

struct FieldInfo* createFieldInfo(const tree field_decl)
{
  struct FieldInfo* fi = (struct FieldInfo*) xcalloc(1, sizeof(struct FieldInfo));
  fi->isSpecial = DECL_ARTIFICIAL(field_decl);
  fi->isBitField = DECL_BIT_FIELD(field_decl);

  const char* fieldName;
  if (fi->isSpecial)
    fieldName = fieldNames[FIELD_BASE];
  else if (DECL_NAME(field_decl))
    fieldName = IDENTIFIER_POINTER(DECL_NAME(field_decl));
  else
    fieldName = fieldNames[FIELD_NONAME];

  fi->name = xstrdup(fieldName);

  fi->size = TREE_INT_CST_LOW(DECL_SIZE(field_decl));

  // Offset calculation is a little bit wierd. According to GCC docs:
  // "... DECL_FIELD_OFFSET is position, counting in bytes, of the
  // DECL_OFFSET_ALIGN-bit sized word ..." and ".. DECL_FIELD_BIT_OFFSET is the
  // bit offset of the first bit of the field within this word"
  fi->offset = TREE_INT_CST_LOW(DECL_FIELD_OFFSET(field_decl)) * BITS_PER_UNIT +
    TREE_INT_CST_LOW(DECL_FIELD_BIT_OFFSET(field_decl));

  fi->align = DECL_ALIGN(field_decl);

  return fi;
}
开发者ID:ostash,项目名称:recordsize2,代码行数:29,代码来源:rs-plugin.c

示例2: find_earlier_clone

static tree
find_earlier_clone (struct clone_info* info)
{
  int i;

  if (info->which_thunks_ok == NO_THUNKS
      || info->next_clone == 0)
    return NULL_TREE;

  if (info->which_thunks_ok == ALL_THUNKS)
    return info->clones [0];

  if (info->which_thunks_ok == IN_CHARGE_1)
    for (i = 0; i < info->next_clone; i++)
      if ((TREE_INT_CST_LOW (info->in_charge_value [i]) & 1)
	  == (TREE_INT_CST_LOW (info->in_charge_value [info->next_clone]) & 1))
	return info->clones [i];

  if (info->which_thunks_ok == IN_CHARGE_0)
    for (i = 0; i < info->next_clone; i++)
      if ((TREE_INT_CST_LOW (info->in_charge_value [i]) == 0)
	  == (TREE_INT_CST_LOW (info->in_charge_value [info->next_clone]) == 0))
	return info->clones [i];

  return NULL_TREE;
}
开发者ID:5432935,项目名称:crossbridge,代码行数:26,代码来源:optimize.c

示例3: pp_c_integer_constant

static void
pp_c_integer_constant (c_pretty_printer *pp, tree i)
{
  tree type = TREE_TYPE (i);

  if (TREE_INT_CST_HIGH (i) == 0)
    pp_wide_integer (pp, TREE_INT_CST_LOW (i));
  else
    {
      if (tree_int_cst_sgn (i) < 0)
	{
	  pp_character (pp, '-');
	  i = build_int_cst_wide (NULL_TREE,
				  -TREE_INT_CST_LOW (i),
				  ~TREE_INT_CST_HIGH (i)
				  + !TREE_INT_CST_LOW (i));
	}
      sprintf (pp_buffer (pp)->digit_buffer,
	       HOST_WIDE_INT_PRINT_DOUBLE_HEX,
	       TREE_INT_CST_HIGH (i), TREE_INT_CST_LOW (i));
      pp_string (pp, pp_buffer (pp)->digit_buffer);
    }
  if (TYPE_UNSIGNED (type))
    pp_character (pp, 'u');
  if (type == long_integer_type_node || type == long_unsigned_type_node)
    pp_character (pp, 'l');
  else if (type == long_long_integer_type_node
	   || type == long_long_unsigned_type_node)
    pp_string (pp, "ll");
}
开发者ID:DmitrySkiba,项目名称:itoa-toolchain,代码行数:30,代码来源:c-pretty-print.c

示例4: test_string_literals

static void
test_string_literals (gimple *stmt)
{
  gcall *call = check_for_named_call (stmt, "__emit_string_literal_range", 4);
  if (!call)
    return;

  /* We expect an ADDR_EXPR with a STRING_CST inside it for the
     initial arg.  */
  tree t_addr_string = gimple_call_arg (call, 0);
  if (TREE_CODE (t_addr_string) != ADDR_EXPR)
    {
      error_at (call->location, "string literal required for arg 1");
      return;
    }

  tree t_string = TREE_OPERAND (t_addr_string, 0);
  if (TREE_CODE (t_string) != STRING_CST)
    {
      error_at (call->location, "string literal required for arg 1");
      return;
    }

  tree t_caret_idx = gimple_call_arg (call, 1);
  if (TREE_CODE (t_caret_idx) != INTEGER_CST)
    {
      error_at (call->location, "integer constant required for arg 2");
      return;
    }
  int caret_idx = TREE_INT_CST_LOW (t_caret_idx);

  tree t_start_idx = gimple_call_arg (call, 2);
  if (TREE_CODE (t_start_idx) != INTEGER_CST)
    {
      error_at (call->location, "integer constant required for arg 3");
      return;
    }
  int start_idx = TREE_INT_CST_LOW (t_start_idx);

  tree t_end_idx = gimple_call_arg (call, 3);
  if (TREE_CODE (t_end_idx) != INTEGER_CST)
    {
      error_at (call->location, "integer constant required for arg 4");
      return;
    }
  int end_idx = TREE_INT_CST_LOW (t_end_idx);

  /* A STRING_CST doesn't have a location, but the ADDR_EXPR does.  */
  location_t strloc = EXPR_LOCATION (t_addr_string);
  location_t loc;
  substring_loc substr_loc (strloc, TREE_TYPE (t_string),
			    caret_idx, start_idx, end_idx);
  const char *err = substr_loc.get_location (&loc);
  if (err)
    error_at (strloc, "unable to read substring location: %s", err);
  else
    emit_warning (loc);
}
开发者ID:MaxKellermann,项目名称:gcc,代码行数:58,代码来源:diagnostic_plugin_test_string_literals.c

示例5: alloc_object_size

static unsigned HOST_WIDE_INT
alloc_object_size (const_gimple call, int object_size_type)
{
  tree callee, bytes = NULL_TREE;
  tree alloc_size;
  int arg1 = -1, arg2 = -1;

  gcc_assert (is_gimple_call (call));

  callee = gimple_call_fndecl (call);
  if (!callee)
    return unknown[object_size_type];

  alloc_size = lookup_attribute ("alloc_size",
				 TYPE_ATTRIBUTES (TREE_TYPE (callee)));
  if (alloc_size && TREE_VALUE (alloc_size))
    {
      tree p = TREE_VALUE (alloc_size);

      arg1 = TREE_INT_CST_LOW (TREE_VALUE (p))-1;
      if (TREE_CHAIN (p))
        arg2 = TREE_INT_CST_LOW (TREE_VALUE (TREE_CHAIN (p)))-1;
    }

  if (DECL_BUILT_IN_CLASS (callee) == BUILT_IN_NORMAL)
    switch (DECL_FUNCTION_CODE (callee))
      {
      case BUILT_IN_CALLOC:
	arg2 = 1;
	/* fall through */
      case BUILT_IN_MALLOC:
      case BUILT_IN_ALLOCA:
      case BUILT_IN_ALLOCA_WITH_ALIGN:
	arg1 = 0;
      default:
	break;
      }

  if (arg1 < 0 || arg1 >= (int)gimple_call_num_args (call)
      || TREE_CODE (gimple_call_arg (call, arg1)) != INTEGER_CST
      || (arg2 >= 0
	  && (arg2 >= (int)gimple_call_num_args (call)
	      || TREE_CODE (gimple_call_arg (call, arg2)) != INTEGER_CST)))
    return unknown[object_size_type];

  if (arg2 >= 0)
    bytes = size_binop (MULT_EXPR,
	fold_convert (sizetype, gimple_call_arg (call, arg1)),
	fold_convert (sizetype, gimple_call_arg (call, arg2)));
  else if (arg1 >= 0)
    bytes = fold_convert (sizetype, gimple_call_arg (call, arg1));

  if (bytes && host_integerp (bytes, 1))
    return tree_low_cst (bytes, 1);

  return unknown[object_size_type];
}
开发者ID:ChaosJohn,项目名称:gcc,代码行数:57,代码来源:tree-object-size.c

示例6: llvm_rs6000_should_return_vector_as_shadow

/* Non-altivec vectors bigger than 8 bytes are returned by sret. */
bool llvm_rs6000_should_return_vector_as_shadow(tree type, 
                                      bool isBuiltin ATTRIBUTE_UNUSED) {
  if (!TARGET_64BIT &&
      TREE_CODE(type) == VECTOR_TYPE &&
      TYPE_SIZE(type) &&
      TREE_CODE(TYPE_SIZE(type))==INTEGER_CST &&
      TREE_INT_CST_LOW(TYPE_SIZE(type))>64 &&
      TREE_INT_CST_LOW(TYPE_SIZE(type))!=128)
    return true;
  return false;
}
开发者ID:aosm,项目名称:llvmgcc42,代码行数:12,代码来源:llvm-rs6000.cpp

示例7: UI_From_gnu

Uint
UI_From_gnu (tree Input)
{
  tree gnu_type = TREE_TYPE (Input), gnu_base, gnu_temp;
  /* UI_Base is defined so that 5 Uint digits is sufficient to hold the
     largest possible signed 64-bit value.  */
  const int Max_For_Dint = 5;
  int v[Max_For_Dint], i;
  Vector_Template temp;
  Int_Vector vec;

#if HOST_BITS_PER_WIDE_INT == 64
  /* On 64-bit hosts, host_integerp tells whether the input fits in a
     signed 64-bit integer.  Then a truncation tells whether it fits
     in a signed 32-bit integer.  */
  if (host_integerp (Input, 0))
    {
      HOST_WIDE_INT hw_input = TREE_INT_CST_LOW (Input);
      if (hw_input == (int) hw_input)
	return UI_From_Int (hw_input);
    }
  else
    return No_Uint;
#else
  /* On 32-bit hosts, host_integerp tells whether the input fits in a
     signed 32-bit integer.  Then a sign test tells whether it fits
     in a signed 64-bit integer.  */
  if (host_integerp (Input, 0))
    return UI_From_Int (TREE_INT_CST_LOW (Input));
  else if (TREE_INT_CST_HIGH (Input) < 0
	   && TYPE_UNSIGNED (gnu_type)
	   && !(TREE_CODE (gnu_type) == INTEGER_TYPE
		&& TYPE_IS_SIZETYPE (gnu_type)))
    return No_Uint;
#endif

  gnu_base = build_int_cst (gnu_type, UI_Base);
  gnu_temp = Input;

  for (i = Max_For_Dint - 1; i >= 0; i--)
    {
      v[i] = tree_low_cst (fold_build1 (ABS_EXPR, gnu_type,
					fold_build2 (TRUNC_MOD_EXPR, gnu_type,
						     gnu_temp, gnu_base)),
			   0);
      gnu_temp = fold_build2 (TRUNC_DIV_EXPR, gnu_type, gnu_temp, gnu_base);
    }

  temp.Low_Bound = 1, temp.High_Bound = Max_For_Dint;
  vec.Array = v, vec.Bounds = &temp;
  return Vector_To_Uint (vec, tree_int_cst_sgn (Input) < 0);
}
开发者ID:AsherBond,项目名称:MondocosmOS-Dependencies,代码行数:52,代码来源:cuintp.c

示例8: llvm_rs6000_should_return_vector_as_scalar

/* (Generic) vectors 4 bytes long are returned as an int.
   Vectors 8 bytes long are returned as 2 ints. */
tree llvm_rs6000_should_return_vector_as_scalar(tree type, 
                                    bool isBuiltin ATTRIBUTE_UNUSED) {
  if (!TARGET_64BIT &&
      TREE_CODE(type) == VECTOR_TYPE &&
      TYPE_SIZE(type) &&
      TREE_CODE(TYPE_SIZE(type))==INTEGER_CST) {
    if (TREE_INT_CST_LOW(TYPE_SIZE(type))==32)
      return uint32_type_node;
    else if (TREE_INT_CST_LOW(TYPE_SIZE(type))==64)
      return uint64_type_node;
  }
  return 0;
}
开发者ID:aosm,项目名称:llvmgcc42,代码行数:15,代码来源:llvm-rs6000.cpp

示例9: real_value_from_int_cst

/*
 *	Return a new REAL_CST node whose type is TYPE
 *	and whose value is the integer value of the
 *	INTEGER_CST node I.
 */
REAL_VALUE_TYPE
real_value_from_int_cst (tree i)
{
	REAL_VALUE_TYPE		d;

#ifdef REAL_ARITHMETIC

	REAL_VALUE_FROM_INT (d, TREE_INT_CST_LOW (i), TREE_INT_CST_HIGH (i));

#else /* not REAL_ARITHMETIC */
#define MASK ((unsigned)1 << (HOST_BITS_PER_INT - 1))

	if (TREE_INT_CST_HIGH (i) < 0)
	{
		d = (double) (~ TREE_INT_CST_HIGH (i));
		d *= ((double) (1 << (HOST_BITS_PER_INT / 2)) *
			(double) (1 << (HOST_BITS_PER_INT / 2)));
		/*
		 *	The following four lines are equivalent
		 *	to converting ~ TREE_INT_CST_LOW (i) from
		 *	unsigned to double, but that is broken in
		 *	some compilers.
		 */
		if (((~ TREE_INT_CST_LOW (i)) & MASK) != 0)
			d += ((double) MASK +
				(double) ((~ MASK) & ~ TREE_INT_CST_LOW (i)));
		else
			d += (double) (unsigned) (~ TREE_INT_CST_LOW (i));

		d = (- d - 1.0);
	}
	else
	{
		d = (double) TREE_INT_CST_HIGH (i);
		d *= ((double) (1 << (HOST_BITS_PER_INT / 2)) *
			(double) (1 << (HOST_BITS_PER_INT / 2)));

		if ((TREE_INT_CST_LOW (i) & MASK) != 0)
			d += ((double) MASK +
				(double) ((~ MASK) & TREE_INT_CST_LOW (i)));
		else
			d += (double) (unsigned) TREE_INT_CST_LOW (i);
	}

#undef MASK
#endif /* not REAL_ARITHMETIC */

	return (d);

}	/* end real_value_from_int_cst */
开发者ID:marioaugustorama,项目名称:tropix-cmd,代码行数:55,代码来源:tree-build.c

示例10: hash_type_name

hashval_t
hash_type_name (tree t)
{
  gcc_checking_assert (TYPE_MAIN_VARIANT (t) == t);

  /* If not in LTO, all main variants are unique, so we can do
     pointer hash.  */
  if (!in_lto_p)
    return htab_hash_pointer (t);

  /* Anonymous types are unique.  */
  if (type_in_anonymous_namespace_p (t))
    return htab_hash_pointer (t);

  /* For polymorphic types, we can simply hash the virtual table.  */
  if (TYPE_BINFO (t) && BINFO_VTABLE (TYPE_BINFO (t)))
    {
      tree v = BINFO_VTABLE (TYPE_BINFO (t));
      hashval_t hash = 0;

      if (TREE_CODE (v) == POINTER_PLUS_EXPR)
	{
	  hash = TREE_INT_CST_LOW (TREE_OPERAND (v, 1));
	  v = TREE_OPERAND (TREE_OPERAND (v, 0), 0);
	}

      v = DECL_ASSEMBLER_NAME (v);
      hash = iterative_hash_hashval_t (hash, htab_hash_pointer (v));
      return hash;
    }

  /* Rest is not implemented yet.  */
  gcc_unreachable ();
}
开发者ID:Nodplus,项目名称:gcc,代码行数:34,代码来源:ipa-devirt.c

示例11: build_index_type

/*
 *	Create a type of integers to be the TYPE_DOMAIN
 *	of an ARRAY_TYPE. MAXVAL should be the maximum
 *	value in the domain (one less than the length of
 *	the array).
 */
tree
build_index_type (tree maxval)
{
	register tree	itype = make_node (INTEGER_TYPE);

	TYPE_PRECISION (itype) = BITS_PER_WORD;
	TYPE_MIN_VALUE (itype) = build_int_2 (0, 0);
	TREE_TYPE (TYPE_MIN_VALUE (itype)) = sizetype;
	TYPE_MAX_VALUE (itype) = convert (sizetype, maxval);
	TYPE_MODE (itype) = SImode;
	TYPE_SIZE (itype) = TYPE_SIZE (sizetype);
	TYPE_SIZE_UNIT (itype) = TYPE_SIZE_UNIT (sizetype);
	TYPE_ALIGN (itype) = TYPE_ALIGN (sizetype);

	if (TREE_CODE (maxval) == INTEGER_CST)
	{
		int maxint = TREE_INT_CST_LOW (maxval);

		return (type_hash_canon (maxint > 0 ? maxint : - maxint, itype));
	}
	else
	{
		return (itype);
	}

}	/* end build_index_type */
开发者ID:marioaugustorama,项目名称:tropix-cmd,代码行数:32,代码来源:tree-build.c

示例12: gfc_conv_string_init

tree
gfc_conv_string_init (tree length, gfc_expr * expr)
{
  gfc_char_t *s;
  HOST_WIDE_INT len;
  int slen;
  tree str;
  bool free_s = false;

  gcc_assert (expr->expr_type == EXPR_CONSTANT);
  gcc_assert (expr->ts.type == BT_CHARACTER);
  gcc_assert (INTEGER_CST_P (length));
  gcc_assert (TREE_INT_CST_HIGH (length) == 0);

  len = TREE_INT_CST_LOW (length);
  slen = expr->value.character.length;

  if (len > slen)
    {
      s = gfc_get_wide_string (len);
      memcpy (s, expr->value.character.string, slen * sizeof (gfc_char_t));
      gfc_wide_memset (&s[slen], ' ', len - slen);
      free_s = true;
    }
  else
    s = expr->value.character.string;

  str = gfc_build_wide_string_const (expr->ts.kind, len, s);

  if (free_s)
    free (s);

  return str;
}
开发者ID:BoxianLai,项目名称:moxiedev,代码行数:34,代码来源:trans-const.c

示例13: XIL_DecodeAttribute

const char* XIL_DecodeAttribute(tree attr,
                                const char **text_value, int *int_value)
{
    tree purpose = TREE_PURPOSE(attr);
    if (!purpose || TREE_CODE(purpose) != IDENTIFIER_NODE) {
        TREE_UNEXPECTED(attr);
        return NULL;
    }
    const char *name = IDENTIFIER_POINTER(purpose);

    tree value = TREE_VALUE(attr);
    if (!value)
        return name;

    if (TREE_CODE(value) != TREE_LIST) {
        TREE_UNEXPECTED(attr);
        return name;
    }
    value = TREE_VALUE(value);

    if (TREE_CODE(value) == STRING_CST) {
        if (text_value)
            *text_value = TREE_STRING_POINTER(value);
    }
    else if (TREE_CODE(value) == INTEGER_CST) {
        if (int_value)
            *int_value = TREE_INT_CST_LOW(value);
    }

    return name;
}
开发者ID:killbug2004,项目名称:implementations,代码行数:31,代码来源:xgill.c

示例14: narrowest_signed_type

/* Ditto, but narrowest signed type.  */
static enum integer_type_kind
narrowest_signed_type (unsigned HOST_WIDE_INT low,
		       unsigned HOST_WIDE_INT high, unsigned int flags)
{
  enum integer_type_kind itk;

  if ((flags & CPP_N_WIDTH) == CPP_N_SMALL)
    itk = itk_int;
  else if ((flags & CPP_N_WIDTH) == CPP_N_MEDIUM)
    itk = itk_long;
  else
    itk = itk_long_long;


  for (; itk < itk_none; itk += 2 /* skip signed types */)
    {
      tree upper = TYPE_MAX_VALUE (integer_types[itk]);
      
      if ((unsigned HOST_WIDE_INT) TREE_INT_CST_HIGH (upper) > high
	  || ((unsigned HOST_WIDE_INT) TREE_INT_CST_HIGH (upper) == high
	      && TREE_INT_CST_LOW (upper) >= low))
	return itk;
    }

  return itk_none;
}
开发者ID:AhmadTux,项目名称:DragonFlyBSD,代码行数:27,代码来源:c-lex.c

示例15: gfc_conv_string_init

tree
gfc_conv_string_init (tree length, gfc_expr * expr)
{
  char *s;
  HOST_WIDE_INT len;
  int slen;
  tree str;

  gcc_assert (expr->expr_type == EXPR_CONSTANT);
  gcc_assert (expr->ts.type == BT_CHARACTER && expr->ts.kind == 1);
  gcc_assert (INTEGER_CST_P (length));
  gcc_assert (TREE_INT_CST_HIGH (length) == 0);

  len = TREE_INT_CST_LOW (length);
  slen = expr->value.character.length;

  if (len > slen)
    {
      s = gfc_getmem (len);
      memcpy (s, expr->value.character.string, slen);
      memset (&s[slen], ' ', len - slen);
      str = gfc_build_string_const (len, s);
      gfc_free (s);
    }
  else
    str = gfc_build_string_const (len, expr->value.character.string);

  return str;
}
开发者ID:BackupTheBerlios,项目名称:iphone-binutils-svn,代码行数:29,代码来源:trans-const.c


注:本文中的TREE_INT_CST_LOW函数示例由纯净天空整理自Github/MSDocs等开源代码及文档管理平台,相关代码片段筛选自各路编程大神贡献的开源项目,源码版权归原作者所有,传播和使用请参考对应项目的License;未经允许,请勿转载。