• Home
  • Line#
  • Scopes#
  • Navigate#
  • Raw
  • Download
1 /*
2  * Copyright 2015 Tilera Corporation. All Rights Reserved.
3  *
4  *   This program is free software; you can redistribute it and/or
5  *   modify it under the terms of the GNU General Public License
6  *   as published by the Free Software Foundation, version 2.
7  *
8  *   This program is distributed in the hope that it will be useful, but
9  *   WITHOUT ANY WARRANTY; without even the implied warranty of
10  *   MERCHANTABILITY OR FITNESS FOR A PARTICULAR PURPOSE, GOOD TITLE or
11  *   NON INFRINGEMENT.  See the GNU General Public License for
12  *   more details.
13  */
14 #ifndef __ASM_TILE_INSN_H
15 #define __ASM_TILE_INSN_H
16 
17 #include <arch/opcode.h>
18 
NOP(void)19 static inline tilegx_bundle_bits NOP(void)
20 {
21 	return create_UnaryOpcodeExtension_X0(FNOP_UNARY_OPCODE_X0) |
22 		create_RRROpcodeExtension_X0(UNARY_RRR_0_OPCODE_X0) |
23 		create_Opcode_X0(RRR_0_OPCODE_X0) |
24 		create_UnaryOpcodeExtension_X1(NOP_UNARY_OPCODE_X1) |
25 		create_RRROpcodeExtension_X1(UNARY_RRR_0_OPCODE_X1) |
26 		create_Opcode_X1(RRR_0_OPCODE_X1);
27 }
28 
tilegx_gen_branch(unsigned long pc,unsigned long addr,bool link)29 static inline tilegx_bundle_bits tilegx_gen_branch(unsigned long pc,
30 					    unsigned long addr,
31 					    bool link)
32 {
33 	tilegx_bundle_bits opcode_x0, opcode_x1;
34 	long pcrel_by_instr = (addr - pc) >> TILEGX_LOG2_BUNDLE_SIZE_IN_BYTES;
35 
36 	if (link) {
37 		/* opcode: jal addr */
38 		opcode_x1 =
39 			create_Opcode_X1(JUMP_OPCODE_X1) |
40 			create_JumpOpcodeExtension_X1(JAL_JUMP_OPCODE_X1) |
41 			create_JumpOff_X1(pcrel_by_instr);
42 	} else {
43 		/* opcode: j addr */
44 		opcode_x1 =
45 			create_Opcode_X1(JUMP_OPCODE_X1) |
46 			create_JumpOpcodeExtension_X1(J_JUMP_OPCODE_X1) |
47 			create_JumpOff_X1(pcrel_by_instr);
48 	}
49 
50 	/* opcode: fnop */
51 	opcode_x0 =
52 		create_UnaryOpcodeExtension_X0(FNOP_UNARY_OPCODE_X0) |
53 		create_RRROpcodeExtension_X0(UNARY_RRR_0_OPCODE_X0) |
54 		create_Opcode_X0(RRR_0_OPCODE_X0);
55 
56 	return opcode_x1 | opcode_x0;
57 }
58 
59 #endif /* __ASM_TILE_INSN_H */
60