[syntax tree] fixed bug in pointer arithmetic
This commit is contained in:
@@ -22,7 +22,7 @@ const char src[] =
|
||||
"\
|
||||
void test(fp32 *A, fp32 *B, fp32 *C, int32 i){\
|
||||
int32 tile[16, 16] = 0;\
|
||||
int32 test[16, 16] = tile + i;\
|
||||
fp32 *test[16, 16] = tile + A;\
|
||||
i = 1;\
|
||||
A = A + i;\
|
||||
}\
|
||||
|
@@ -56,7 +56,11 @@ void node::implicit_cast(ir::builder &builder, ir::value *&lhs, ir::value *&rhs,
|
||||
ir::type *left_ty = lhs->get_type()->get_scalar_ty();
|
||||
ir::type *right_ty = rhs->get_type()->get_scalar_ty();
|
||||
// One operand is pointer
|
||||
if(left_ty->is_pointer_ty()){
|
||||
if(left_ty->is_pointer_ty() || right_ty->is_pointer_ty()){
|
||||
if(left_ty->is_pointer_ty() && right_ty->is_pointer_ty())
|
||||
throw std::runtime_error("invalid operands");
|
||||
if(right_ty->is_pointer_ty())
|
||||
std::swap(lhs, rhs);
|
||||
is_ptr = true;
|
||||
}
|
||||
// One operand is double
|
||||
|
@@ -248,7 +248,7 @@ getelementptr_inst::getelementptr_inst(type *pointee_ty, value *ptr, const std::
|
||||
|
||||
type *getelementptr_inst::get_return_type(type *elt_ty, value *ptr, const std::vector<value *> &idx_list) {
|
||||
// result pointer type
|
||||
type *ptr_ty = pointer_type::get(get_indexed_type(elt_ty, idx_list), ptr->get_type()->get_pointer_address_space());
|
||||
type *ptr_ty = pointer_type::get(get_indexed_type(elt_ty, idx_list), ptr->get_type()->get_scalar_ty()->get_pointer_address_space());
|
||||
// Tile GEP
|
||||
if(ptr->get_type()->is_tile_ty())
|
||||
return tile_type::get_same_shapes(ptr_ty, ptr->get_type());
|
||||
|
Reference in New Issue
Block a user