blob: cde7573f397b9edfde5127499e101fdbb1335c33 [file] [log] [blame]
Zhigang Lu65a792e2015-09-30 10:11:45 +08001/*
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
15#ifndef _ASM_TILE_JUMP_LABEL_H
16#define _ASM_TILE_JUMP_LABEL_H
17
18#include <arch/opcode.h>
19
20#define JUMP_LABEL_NOP_SIZE TILE_BUNDLE_SIZE_IN_BYTES
21
22static __always_inline bool arch_static_branch(struct static_key *key,
23 bool branch)
24{
25 asm_volatile_goto("1:\n\t"
26 "nop" "\n\t"
27 ".pushsection __jump_table, \"aw\"\n\t"
28 ".quad 1b, %l[l_yes], %0 + %1 \n\t"
29 ".popsection\n\t"
30 : : "i" (key), "i" (branch) : : l_yes);
31 return false;
32l_yes:
33 return true;
34}
35
36static __always_inline bool arch_static_branch_jump(struct static_key *key,
37 bool branch)
38{
39 asm_volatile_goto("1:\n\t"
40 "j %l[l_yes]" "\n\t"
41 ".pushsection __jump_table, \"aw\"\n\t"
42 ".quad 1b, %l[l_yes], %0 + %1 \n\t"
43 ".popsection\n\t"
44 : : "i" (key), "i" (branch) : : l_yes);
45 return false;
46l_yes:
47 return true;
48}
49
50typedef u64 jump_label_t;
51
52struct jump_entry {
53 jump_label_t code;
54 jump_label_t target;
55 jump_label_t key;
56};
57
58#endif /* _ASM_TILE_JUMP_LABEL_H */