1 /* brig-copy-move-inst-handler.cc -- brig copy/move instruction handling
2 Copyright (C) 2016-2018 Free Software Foundation, Inc.
3 Contributed by Pekka Jaaskelainen <pekka.jaaskelainen@parmance.com>
4 for General Processor Tech.
6 This file is part of GCC.
8 GCC is free software; you can redistribute it and/or modify it under
9 the terms of the GNU General Public License as published by the Free
10 Software Foundation; either version 3, or (at your option) any later
13 GCC is distributed in the hope that it will be useful, but WITHOUT ANY
14 WARRANTY; without even the implied warranty of MERCHANTABILITY or
15 FITNESS FOR A PARTICULAR PURPOSE. See the GNU General Public License
18 You should have received a copy of the GNU General Public License
19 along with GCC; see the file COPYING3. If not see
20 <http://www.gnu.org/licenses/>. */
22 #include "brig-code-entry-handler.h"
23 #include "tree-pretty-print.h"
24 #include "print-tree.h"
26 #include "brig-util.h"
29 brig_copy_move_inst_handler::handle_lda (const BrigInstBase
*brig_inst
)
31 tree dest_type
= gccbrig_tree_type_for_hsa_type (brig_inst
->type
);
33 tree input
= build_tree_operand_from_brig (brig_inst
, NULL
, 1);
34 tree output
= build_tree_operand_from_brig (brig_inst
, dest_type
, 0);
36 build_output_assignment (*brig_inst
, output
, input
);
37 return brig_inst
->base
.byteCount
;
41 brig_copy_move_inst_handler::operator () (const BrigBase
*base
)
43 const BrigInstBase
*brig_inst
44 = (const BrigInstBase
*) &((const BrigInstBasic
*) base
)->base
;
46 if (brig_inst
->opcode
== BRIG_OPCODE_LDA
)
47 return handle_lda (brig_inst
);
49 const BrigInstSourceType
*inst_src_type
= (const BrigInstSourceType
*) base
;
51 tree source_type
= gccbrig_tree_type_for_hsa_type (inst_src_type
->sourceType
);
52 tree dest_type
= gccbrig_tree_type_for_hsa_type (brig_inst
->type
);
54 tree input
= build_tree_operand_from_brig (brig_inst
, source_type
, 1);
55 tree output
= build_tree_operand_from_brig (brig_inst
, dest_type
, 0);
57 if (brig_inst
->opcode
== BRIG_OPCODE_COMBINE
)
59 /* For combine, a simple reinterpret cast from the array constructor
61 tree casted
= build_resize_convert_view (TREE_TYPE (output
), input
);
62 tree assign
= build2 (MODIFY_EXPR
, TREE_TYPE (output
), output
, casted
);
63 m_parent
.m_cf
->append_statement (assign
);
65 else if (brig_inst
->opcode
== BRIG_OPCODE_EXPAND
)
66 build_output_assignment (*brig_inst
, output
, input
);
69 brig_basic_inst_handler
basic (m_parent
);
72 return base
->byteCount
;