Add multiple of the pointer target size
This commit is contained in:
@ -74,7 +74,7 @@ namespace gcc
|
||||
{
|
||||
auto body_type = build_type(expression->body());
|
||||
|
||||
this->current_expression = build1(CONVERT_EXPR, this->symbol_map->lookup("Word"), TYPE_SIZE_UNIT(body_type));
|
||||
this->current_expression = build1(CONVERT_EXPR, this->symbol_map->lookup("Word"), size_in_bytes(body_type));
|
||||
}
|
||||
|
||||
bool generic_visitor::is_integral_type(tree type)
|
||||
|
@ -88,16 +88,25 @@ namespace gcc
|
||||
tree do_pointer_arithmetic(boot::binary_operator binary_operator, tree left, tree right)
|
||||
{
|
||||
tree result = error_mark_node;
|
||||
tree convert_expression = fold_convert(sizetype, right);
|
||||
tree pointer_type = TREE_TYPE(left);
|
||||
tree offset_type = TREE_TYPE(right);
|
||||
|
||||
gcc_assert(is_pointer_type(pointer_type));
|
||||
|
||||
tree size_exp = fold_convert(offset_type, size_in_bytes(TREE_TYPE(pointer_type)));
|
||||
tree convert_expression = right;
|
||||
|
||||
convert_expression = fold_build2(MULT_EXPR, offset_type, convert_expression, size_exp);
|
||||
convert_expression = fold_convert(sizetype, convert_expression);
|
||||
|
||||
if (binary_operator == boot::binary_operator::sum)
|
||||
{
|
||||
result = fold_build2(POINTER_PLUS_EXPR, TREE_TYPE(left), left, convert_expression);
|
||||
result = fold_build2(POINTER_PLUS_EXPR, pointer_type, left, convert_expression);
|
||||
}
|
||||
else if (binary_operator == boot::binary_operator::subtraction)
|
||||
{
|
||||
convert_expression = fold_build1(NEGATE_EXPR, sizetype, convert_expression);
|
||||
result = fold_build2(POINTER_PLUS_EXPR, TREE_TYPE(left), left, convert_expression);
|
||||
result = fold_build2(POINTER_PLUS_EXPR, pointer_type, left, convert_expression);
|
||||
}
|
||||
return result;
|
||||
}
|
||||
|
Reference in New Issue
Block a user